From 7301f6d8b7356de9814c145dacfcd1055267314e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 25 Apr 2013 22:38:27 +0200 Subject: [PATCH] panelconfigview is a subclass of configview --- src/shell/panelconfigview.cpp | 39 +++++++---------------------------- src/shell/panelconfigview.h | 9 ++++---- src/shell/panelview.cpp | 1 + 3 files changed, 12 insertions(+), 37 deletions(-) diff --git a/src/shell/panelconfigview.cpp b/src/shell/panelconfigview.cpp index caf9c641c..bce420ac0 100644 --- a/src/shell/panelconfigview.cpp +++ b/src/shell/panelconfigview.cpp @@ -36,27 +36,13 @@ //////////////////////////////PanelConfigView PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *panelView, QWindow *parent) - : QQuickView(parent), + : ConfigView(containment, parent), 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())); - - if (!m_containment->corona()->package().isValid()) { - qWarning() << "Invalid home screen package"; - } - - setResizeMode(QQuickView::SizeViewToRootObject); - - engine()->rootContext()->setContextProperty("panel", panelView); - engine()->rootContext()->setContextProperty("configDialog", this); - setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui"))); - syncGeometry(); connect(containment, &Plasma::Containment::formFactorChanged, this, &PanelConfigView::syncGeometry); } @@ -65,6 +51,12 @@ PanelConfigView::~PanelConfigView() { } +void PanelConfigView::init() +{ + setSource(QUrl::fromLocalFile(m_containment->corona()->package().filePath("panelconfigurationui"))); + syncGeometry(); +} + void PanelConfigView::syncGeometry() { if (!m_containment) { @@ -91,22 +83,5 @@ void PanelConfigView::syncGeometry() } } -//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have -void PanelConfigView::hideEvent(QHideEvent *ev) -{ - QQuickWindow::hideEvent(ev); - deleteLater(); -} - -void PanelConfigView::resizeEvent(QResizeEvent *re) -{ - if (!rootObject()) { - return; - } - rootObject()->setWidth(re->size().width()); - rootObject()->setHeight(re->size().height()); - QQuickWindow::resizeEvent(re); -} - #include "moc_panelconfigview.cpp" diff --git a/src/shell/panelconfigview.h b/src/shell/panelconfigview.h index b215f435f..dfd202977 100644 --- a/src/shell/panelconfigview.h +++ b/src/shell/panelconfigview.h @@ -20,6 +20,7 @@ #ifndef PANELCONFIGVIEW_H #define PANELCONFIGVIEW_H +#include "configview.h" #include #include #include @@ -36,7 +37,7 @@ namespace Plasma { //TODO: this should be a subclass of ConfigView currently in the scriptengine //TODO: that class should be moved here -class PanelConfigView : public QQuickView +class PanelConfigView : public ConfigView { Q_OBJECT @@ -44,13 +45,11 @@ public: PanelConfigView(Plasma::Containment *interface, PanelView *panelView, QWindow *parent = 0); virtual ~PanelConfigView(); + void init(); + protected Q_SLOTS: void syncGeometry(); -protected: - void hideEvent(QHideEvent *ev); - void resizeEvent(QResizeEvent *re); - private: Plasma::Containment *m_containment; PanelView *m_panelView; diff --git a/src/shell/panelview.cpp b/src/shell/panelview.cpp index c408b922f..c4e33da89 100644 --- a/src/shell/panelview.cpp +++ b/src/shell/panelview.cpp @@ -167,6 +167,7 @@ void PanelView::showPanelController() { if (!m_panelConfigView) { m_panelConfigView = new PanelConfigView(containment(), this); + m_panelConfigView->init(); } m_panelConfigView->show(); }