sync the panel controller size with screen

This commit is contained in:
Marco Martin 2013-03-20 20:23:11 +01:00
parent 195f76c85a
commit a1eda09446
2 changed files with 34 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#include <QQmlComponent> #include <QQmlComponent>
#include <QQmlEngine> #include <QQmlEngine>
#include <QQmlContext> #include <QQmlContext>
#include <QScreen>
#include <KGlobal> #include <KGlobal>
#include <KLocalizedString> #include <KLocalizedString>
@ -36,9 +37,11 @@
//////////////////////////////PanelConfigView //////////////////////////////PanelConfigView
PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *parent) PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *parent)
: QQuickView(parent), : QQuickView(parent),
m_containment(containment) m_containment(containment),
m_panelView(panelView)
{ {
setFlags(Qt::FramelessWindowHint);
//FIXME: problem on nvidia, all windows should be transparent or won't show //FIXME: problem on nvidia, all windows should be transparent or won't show
setColor(Qt::transparent); setColor(Qt::transparent);
setTitle(i18n("%1 Settings", m_containment->title())); setTitle(i18n("%1 Settings", m_containment->title()));
@ -53,12 +56,38 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa
engine()->rootContext()->setContextProperty("panel", panelView); engine()->rootContext()->setContextProperty("panel", panelView);
engine()->rootContext()->setContextProperty("configDialog", this); engine()->rootContext()->setContextProperty("configDialog", this);
setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui"))); setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui")));
syncGeometry();
} }
PanelConfigView::~PanelConfigView() PanelConfigView::~PanelConfigView()
{ {
} }
void PanelConfigView::syncGeometry()
{
if (!m_containment) {
return;
}
if (m_containment->formFactor() == Plasma::Vertical) {
resize(128, screen()->size().height());
if (m_containment->location() == Plasma::LeftEdge) {
setPosition(m_panelView->width(), 0);
} else if (m_containment->location() == Plasma::RightEdge) {
setPosition(screen()->size().width() - m_panelView->width(), 0);
}
} else {
resize(screen()->size().width(), 128);
if (m_containment->location() == Plasma::TopEdge) {
setPosition(0, m_panelView->height());
} else if (m_containment->location() == Plasma::BottomEdge) {
setPosition(0, screen()->size().width() - m_panelView->height());
}
}
}
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have //To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void PanelConfigView::hideEvent(QHideEvent *ev) void PanelConfigView::hideEvent(QHideEvent *ev)

View File

@ -44,12 +44,16 @@ public:
PanelConfigView(Plasma::Containment *interface, PanelView *panelView, QWindow *parent = 0); PanelConfigView(Plasma::Containment *interface, PanelView *panelView, QWindow *parent = 0);
virtual ~PanelConfigView(); virtual ~PanelConfigView();
protected Q_SLOTS:
void syncGeometry();
protected: protected:
void hideEvent(QHideEvent *ev); void hideEvent(QHideEvent *ev);
void resizeEvent(QResizeEvent *re); void resizeEvent(QResizeEvent *re);
private: private:
Plasma::Containment *m_containment; Plasma::Containment *m_containment;
PanelView *m_panelView;
}; };
#endif // multiple inclusion guard #endif // multiple inclusion guard