From 7bd86505f5db6a28fbc0618536a779b2db2dc7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 5 Aug 2013 14:55:37 +0200 Subject: [PATCH] Port add/remove buttons in DesktopGrid to QtQuick 2 With this change we no longer need to link QtDeclarative in the Effects. --- effects/CMakeLists.txt | 1 - effects/desktopgrid/desktopgrid.cpp | 34 +++++++++-------------------- effects/desktopgrid/desktopgrid.h | 6 ++--- effects/desktopgrid/main.qml | 9 +++++--- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 7ab4ba1f34..89e8f8977f 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -12,7 +12,6 @@ set(kwin_effect_KDE_LIBS ) set(kwin_effect_QT_LIBS - ${Qt5Declarative_LIBRARIES} ${Qt5Quick_LIBRARIES} ${Qt5X11Extras_LIBRARIES} ${Qt5DBus_LIBRARIES} diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp index 81b73e5b97..30124495b9 100644 --- a/effects/desktopgrid/desktopgrid.cpp +++ b/effects/desktopgrid/desktopgrid.cpp @@ -34,15 +34,14 @@ along with this program. If not, see . #include #include #include -#include #include #include #include #include #include -#include -#include -#include +#include +#include +#include namespace KWin { @@ -1117,9 +1116,9 @@ void DesktopGridEffect::setup() connect(view, SIGNAL(addDesktop()), SLOT(slotAddDesktop())); connect(view, SIGNAL(removeDesktop()), SLOT(slotRemoveDesktop())); const QRect screenRect = effects->clientArea(FullScreenArea, i, 1); - view->setGeometry(screenRect.right() + 1 - view->sceneRect().width(), - screenRect.bottom() + 1 - view->sceneRect().height(), - view->sceneRect().width(), view->sceneRect().height()); + view->setGeometry(screenRect.right() + 1 - view->width(), + screenRect.bottom() + 1 - view->height(), + view->width(), view->height()); view->show(); m_desktopButtonsViews.insert(view, NULL); } @@ -1382,24 +1381,11 @@ bool DesktopGridEffect::isRelevantWithPresentWindows(EffectWindow *w) const /************************************************ * DesktopButtonView ************************************************/ -DesktopButtonsView::DesktopButtonsView(QWidget *parent) - : QDeclarativeView(parent) +DesktopButtonsView::DesktopButtonsView(QWindow *parent) + : QQuickView(parent) { - setWindowFlags(Qt::X11BypassWindowManagerHint); - setAttribute(Qt::WA_TranslucentBackground); - QPalette pal = palette(); - pal.setColor(backgroundRole(), Qt::transparent); - setPalette(pal); - for (const QString &importPath : KGlobal::dirs()->findDirs("module", QStringLiteral("imports"))) { - engine()->addImportPath(importPath); - } -#warning Port declarative code to QtQuick2 -#if KWIN_QT5_PORTING - KDeclarative kdeclarative; - kdeclarative.setDeclarativeEngine(engine()); - kdeclarative.initialize(); - kdeclarative.setupBindings(); -#endif + setFlags(Qt::X11BypassWindowManagerHint); + setColor(Qt::transparent); rootContext()->setContextProperty(QStringLiteral("add"), QVariant(true)); rootContext()->setContextProperty(QStringLiteral("remove"), QVariant(true)); diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index 12c18550ba..c3fc4627c4 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -25,19 +25,19 @@ along with this program. If not, see . #include #include #include -#include #include +#include namespace KWin { class PresentWindowsEffectProxy; -class DesktopButtonsView : public QDeclarativeView +class DesktopButtonsView : public QQuickView { Q_OBJECT public: - explicit DesktopButtonsView(QWidget *parent = 0); + explicit DesktopButtonsView(QWindow *parent = 0); void windowInputMouseEvent(QMouseEvent* e); void setAddDesktopEnabled(bool enable); void setRemoveDesktopEnabled(bool enable); diff --git a/effects/desktopgrid/main.qml b/effects/desktopgrid/main.qml index 9c4591d6c1..ce28c53756 100644 --- a/effects/desktopgrid/main.qml +++ b/effects/desktopgrid/main.qml @@ -17,13 +17,16 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -import QtQuick 1.1 -import org.kde.plasma.components 0.1 as Plasma +import QtQuick 2.0 +import org.kde.plasma.components 2.0 as Plasma Item { + width: childrenRect.width + height: childrenRect.height Plasma.ButtonRow { - anchors.fill: parent exclusive: false + width: childrenRect.width + height: childrenRect.height Plasma.Button { id: removeButton objectName: "removeButton"