From a1eda09446477d4db5da18f89b6966fb04f14e30 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 20 Mar 2013 20:23:11 +0100 Subject: [PATCH] sync the panel controller size with screen --- src/shell/panelconfigview.cpp | 31 ++++++++++++++++++++++++++++++- src/shell/panelconfigview.h | 4 ++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/shell/panelconfigview.cpp b/src/shell/panelconfigview.cpp index 5501eb425..4613ab522 100644 --- a/src/shell/panelconfigview.cpp +++ b/src/shell/panelconfigview.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -36,9 +37,11 @@ //////////////////////////////PanelConfigView PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *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 setColor(Qt::transparent); 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("configDialog", this); setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui"))); + syncGeometry(); } 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 void PanelConfigView::hideEvent(QHideEvent *ev) diff --git a/src/shell/panelconfigview.h b/src/shell/panelconfigview.h index 447d83dbe..b215f435f 100644 --- a/src/shell/panelconfigview.h +++ b/src/shell/panelconfigview.h @@ -44,12 +44,16 @@ public: PanelConfigView(Plasma::Containment *interface, PanelView *panelView, QWindow *parent = 0); virtual ~PanelConfigView(); +protected Q_SLOTS: + void syncGeometry(); + protected: void hideEvent(QHideEvent *ev); void resizeEvent(QResizeEvent *re); private: Plasma::Containment *m_containment; + PanelView *m_panelView; }; #endif // multiple inclusion guard