diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt
index 8ba07e6a55..abbbba4941 100644
--- a/effects/CMakeLists.txt
+++ b/effects/CMakeLists.txt
@@ -8,6 +8,11 @@ set(kwin_effect_OWN_LIBS
set(kwin_effect_KDE_LIBS
${KDE4_KDEUI_LIBS}
${KDE4_PLASMA_LIBS}
+ ${KDECLARATIVE_LIBRARIES}
+)
+
+set(kwin_effect_QT_LIBS
+ ${QT_QTDECLARATIVE_LIBRARY}
)
set(kwin_effect_XLIB_LIBS
@@ -34,7 +39,7 @@ endif()
macro( KWIN4_ADD_EFFECT_BACKEND name )
kde4_add_plugin( ${name} ${ARGN} )
- target_link_libraries( ${name} ${kwin_effect_OWN_LIBS} ${kwin_effect_KDE_LIBS} ${kwin_effect_XLIB_LIBS} ${kwin_effect_XCB_LIBS})
+ target_link_libraries( ${name} ${kwin_effect_OWN_LIBS} ${kwin_effect_KDE_LIBS} ${kwin_effect_QT_LIBS} ${kwin_effect_XLIB_LIBS} ${kwin_effect_XCB_LIBS})
endmacro()
# Adds effect plugin with given name. Sources are given after the name
diff --git a/effects/desktopgrid/CMakeLists.txt b/effects/desktopgrid/CMakeLists.txt
index 12618f36bd..ecd106be2f 100644
--- a/effects/desktopgrid/CMakeLists.txt
+++ b/effects/desktopgrid/CMakeLists.txt
@@ -12,6 +12,10 @@ kde4_add_kcfg_files(kwin4_effect_builtins_sources desktopgrid/desktopgridconfig.
install( FILES
desktopgrid/desktopgrid.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
+install( FILES
+ desktopgrid/main.qml
+ DESTINATION ${DATA_INSTALL_DIR}/kwin/effects/desktopgrid/
+)
#######################################
# Config
diff --git a/effects/desktopgrid/desktopgrid.cpp b/effects/desktopgrid/desktopgrid.cpp
index 37ea252d8e..232393cd3c 100644
--- a/effects/desktopgrid/desktopgrid.cpp
+++ b/effects/desktopgrid/desktopgrid.cpp
@@ -32,17 +32,16 @@ along with this program. If not, see .
#include
#include
#include
+#include
+#include
#include
#include
#include
#include
-#include
-#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
namespace KWin
{
@@ -1383,58 +1382,34 @@ bool DesktopGridEffect::isRelevantWithPresentWindows(EffectWindow *w) const
/************************************************
* DesktopButtonView
************************************************/
-DesktopButtonsView::DesktopButtonsView(QWidget* parent)
- : QGraphicsView(parent)
+DesktopButtonsView::DesktopButtonsView(QWidget *parent)
+ : QDeclarativeView(parent)
{
setWindowFlags(Qt::X11BypassWindowManagerHint);
setAttribute(Qt::WA_TranslucentBackground);
- setFrameShape(QFrame::NoFrame);
QPalette pal = palette();
pal.setColor(backgroundRole(), Qt::transparent);
setPalette(pal);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
- // setup the scene
- QGraphicsScene* scene = new QGraphicsScene(this);
- m_addDesktopButton = new Plasma::PushButton();
- m_addDesktopButton->setIcon(KIcon("list-add"));
- m_removeDesktopButton = new Plasma::PushButton();
- m_removeDesktopButton->setIcon(KIcon("list-remove"));
- scene->addItem(m_addDesktopButton);
- scene->addItem(m_removeDesktopButton);
- connect(m_addDesktopButton, SIGNAL(clicked()), SIGNAL(addDesktop()));
- connect(m_removeDesktopButton, SIGNAL(clicked()), SIGNAL(removeDesktop()));
-
- QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
- layout->addItem(m_addDesktopButton);
- layout->addItem(m_removeDesktopButton);
-
- QGraphicsWidget *form = new QGraphicsWidget;
- form->setLayout(layout);
- form->setGeometry(0, 0, 64 * 2, 64);
- scene->addItem(form);
-
- m_frame = new Plasma::FrameSvg(this);
- if (Plasma::Theme::defaultTheme()->currentThemeHasImage("translucent/dialogs/background")) {
- m_frame->setImagePath("translucent/dialogs/background");
- } else {
- m_frame->setImagePath("dialogs/background");
+ foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
+ engine()->addImportPath(importPath);
+ }
+ KDeclarative kdeclarative;
+ kdeclarative.setDeclarativeEngine(engine());
+ kdeclarative.initialize();
+ kdeclarative.setupBindings();
+
+ rootContext()->setContextProperty("add", QVariant(true));
+ rootContext()->setContextProperty("remove", QVariant(true));
+ setSource(QUrl(KStandardDirs::locate("data", QLatin1String("kwin/effects/desktopgrid/main.qml"))));
+ if (QObject *item = rootObject()->findChild("addButton")) {
+ connect(item, SIGNAL(clicked()), SIGNAL(addDesktop()));
+ }
+ if (QObject *item = rootObject()->findChild("removeButton")) {
+ connect(item, SIGNAL(clicked()), SIGNAL(removeDesktop()));
}
- m_frame->setCacheAllRenderedFrames(true);
- m_frame->setEnabledBorders(Plasma::FrameSvg::AllBorders);
- qreal left, top, right, bottom;
- m_frame->getMargins(left, top, right, bottom);
- qreal width = form->size().width() + left + right;
- qreal height = form->size().height() + top + bottom;
- m_frame->resizeFrame(QSizeF(width, height));
- Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame->mask());
- form->setPos(left, top);
- scene->setSceneRect(QRectF(QPointF(0, 0), QSizeF(width, height)));
- setScene(scene);
}
-void DesktopButtonsView::windowInputMouseEvent(QMouseEvent* e)
+void DesktopButtonsView::windowInputMouseEvent(QMouseEvent *e)
{
if (e->type() == QEvent::MouseMove) {
mouseMoveEvent(e);
@@ -1449,19 +1424,12 @@ void DesktopButtonsView::windowInputMouseEvent(QMouseEvent* e)
void DesktopButtonsView::setAddDesktopEnabled(bool enable)
{
- m_addDesktopButton->setEnabled(enable);
+ rootContext()->setContextProperty("add", QVariant(enable));
}
void DesktopButtonsView::setRemoveDesktopEnabled(bool enable)
{
- m_removeDesktopButton->setEnabled(enable);
-}
-
-void DesktopButtonsView::drawBackground(QPainter* painter, const QRectF& rect)
-{
- Q_UNUSED(rect)
- painter->setRenderHint(QPainter::Antialiasing);
- m_frame->paintFrame(painter);
+ rootContext()->setContextProperty("remove", QVariant(enable));
}
} // namespace
diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h
index 83976a518f..b78404f8bc 100644
--- a/effects/desktopgrid/desktopgrid.h
+++ b/effects/desktopgrid/desktopgrid.h
@@ -25,38 +25,25 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
-#include
-
-namespace Plasma
-{
-class PushButton;
-class FrameSvg;
-}
namespace KWin
{
class PresentWindowsEffectProxy;
-class DesktopButtonsView : public QGraphicsView
+class DesktopButtonsView : public QDeclarativeView
{
Q_OBJECT
public:
- explicit DesktopButtonsView(QWidget* parent = 0);
+ explicit DesktopButtonsView(QWidget *parent = 0);
void windowInputMouseEvent(QMouseEvent* e);
void setAddDesktopEnabled(bool enable);
void setRemoveDesktopEnabled(bool enable);
- virtual void drawBackground(QPainter* painter, const QRectF& rect);
-
Q_SIGNALS:
void addDesktop();
void removeDesktop();
-
-private:
- Plasma::PushButton* m_addDesktopButton;
- Plasma::PushButton* m_removeDesktopButton;
- Plasma::FrameSvg* m_frame;
};
class DesktopGridEffect
diff --git a/effects/desktopgrid/main.qml b/effects/desktopgrid/main.qml
new file mode 100644
index 0000000000..9c4591d6c1
--- /dev/null
+++ b/effects/desktopgrid/main.qml
@@ -0,0 +1,44 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2013 Martin Gräßlin
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+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
+
+Item {
+ Plasma.ButtonRow {
+ anchors.fill: parent
+ exclusive: false
+ Plasma.Button {
+ id: removeButton
+ objectName: "removeButton"
+ enabled: remove
+ width: 64
+ height: 64
+ iconSource: "list-remove"
+ }
+ Plasma.Button {
+ id: addButton
+ objectName: "addButton"
+ enabled: add
+ width: 64
+ height: 64
+ iconSource: "list-add"
+ }
+ }
+}
diff --git a/effects/presentwindows/CMakeLists.txt b/effects/presentwindows/CMakeLists.txt
index 5da922dd52..94f6236bea 100644
--- a/effects/presentwindows/CMakeLists.txt
+++ b/effects/presentwindows/CMakeLists.txt
@@ -13,6 +13,10 @@ kde4_add_kcfg_files(kwin4_effect_builtins_sources presentwindows/presentwindowsc
install( FILES
presentwindows/presentwindows.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
+install( FILES
+ presentwindows/main.qml
+ DESTINATION ${DATA_INSTALL_DIR}/kwin/effects/presentwindows/
+)
#######################################
# Config
diff --git a/effects/presentwindows/main.qml b/effects/presentwindows/main.qml
new file mode 100644
index 0000000000..e456a48a30
--- /dev/null
+++ b/effects/presentwindows/main.qml
@@ -0,0 +1,32 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2013 Martin Gräßlin
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+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
+
+Item {
+ Plasma.Button {
+ id: closeButton
+ objectName: "closeButton"
+ enabled: armed
+ width: 32
+ height: 32
+ iconSource: "window-close"
+ }
+}
diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp
index 62b1a32705..0091c9fb57 100755
--- a/effects/presentwindows/presentwindows.cpp
+++ b/effects/presentwindows/presentwindows.cpp
@@ -26,25 +26,24 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
#include
+#include
#include
#include
-#include
-#include
-#include
-#include
-#include
-#include
#include
#include
#include
#include
#include
+#include
+#include
#include
+#include
#include
#include
#include
@@ -1927,51 +1926,29 @@ void PresentWindowsEffect::screenCountChanged()
/************************************************
* CloseWindowView
************************************************/
-CloseWindowView::CloseWindowView(QWidget* parent)
- : QGraphicsView(parent)
+CloseWindowView::CloseWindowView(QWidget *parent)
+ : QDeclarativeView(parent)
, m_armTimer(new QTimer(this))
{
setWindowFlags(Qt::X11BypassWindowManagerHint);
setAttribute(Qt::WA_TranslucentBackground);
- setFrameShape(QFrame::NoFrame);
QPalette pal = palette();
pal.setColor(backgroundRole(), Qt::transparent);
setPalette(pal);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
- // setup the scene
- QGraphicsScene* scene = new QGraphicsScene(this);
- m_closeButton = new Plasma::PushButton();
- m_closeButton->setIcon(KIcon("window-close"));
- scene->addItem(m_closeButton);
- connect(m_closeButton, SIGNAL(clicked()), SIGNAL(close()));
-
- QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
- layout->addItem(m_closeButton);
-
- QGraphicsWidget *form = new QGraphicsWidget;
- form->setLayout(layout);
- form->setGeometry(0, 0, 32, 32);
- scene->addItem(form);
-
- m_frame = new Plasma::FrameSvg(this);
- if (Plasma::Theme::defaultTheme()->currentThemeHasImage("translucent/dialogs/background")) {
- m_frame->setImagePath("translucent/dialogs/background");
- } else {
- m_frame->setImagePath("dialogs/background");
+ foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
+ engine()->addImportPath(importPath);
+ }
+ KDeclarative kdeclarative;
+ kdeclarative.setDeclarativeEngine(engine());
+ kdeclarative.initialize();
+ kdeclarative.setupBindings();
+
+ rootContext()->setContextProperty("armed", QVariant(false));
+
+ setSource(QUrl(KStandardDirs::locate("data", QLatin1String("kwin/effects/presentwindows/main.qml"))));
+ if (QObject *item = rootObject()->findChild("closeButton")) {
+ connect(item, SIGNAL(clicked()), SIGNAL(close()));
}
- m_frame->setCacheAllRenderedFrames(true);
- m_frame->setEnabledBorders(Plasma::FrameSvg::AllBorders);
- qreal left, top, right, bottom;
- m_frame->getMargins(left, top, right, bottom);
- qreal width = form->size().width() + left + right;
- qreal height = form->size().height() + top + bottom;
- m_frame->resizeFrame(QSizeF(width, height));
- Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame->mask());
- form->setPos(left, top);
- scene->setSceneRect(QRectF(QPointF(0, 0), QSizeF(width, height)));
- setScene(scene);
// setup the timer - attempt to prevent accidental clicks
m_armTimer->setSingleShot(true);
@@ -1979,9 +1956,9 @@ CloseWindowView::CloseWindowView(QWidget* parent)
connect(m_armTimer, SIGNAL(timeout()), SLOT(arm()));
}
-void CloseWindowView::windowInputMouseEvent(QMouseEvent* e)
+void CloseWindowView::windowInputMouseEvent(QMouseEvent *e)
{
- if (!isEnabled())
+ if (m_armTimer->isActive())
return;
if (e->type() == QEvent::MouseMove) {
mouseMoveEvent(e);
@@ -1994,25 +1971,17 @@ void CloseWindowView::windowInputMouseEvent(QMouseEvent* e)
}
}
-void CloseWindowView::drawBackground(QPainter* painter, const QRectF& rect)
-{
- Q_UNUSED(rect)
- painter->setRenderHint(QPainter::Antialiasing);
- m_frame->paintFrame(painter);
-}
-
void CloseWindowView::arm()
{
- setEnabled(true);
+ rootContext()->setContextProperty("armed", QVariant(true));
}
void CloseWindowView::disarm()
{
- setEnabled(false);
+ rootContext()->setContextProperty("armed", QVariant(false));
m_armTimer->start();
}
-
} // namespace
#include "presentwindows.moc"
diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h
index e856226bf2..ed2807eb9c 100644
--- a/effects/presentwindows/presentwindows.h
+++ b/effects/presentwindows/presentwindows.h
@@ -26,26 +26,18 @@ along with this program. If not, see .
#include
#include
-#include
+#include
class QTimer;
-namespace Plasma
-{
-class PushButton;
-class FrameSvg;
-}
namespace KWin
{
-
-class CloseWindowView : public QGraphicsView
+class CloseWindowView : public QDeclarativeView
{
Q_OBJECT
public:
- explicit CloseWindowView(QWidget* parent = 0);
+ explicit CloseWindowView(QWidget *parent = 0);
void windowInputMouseEvent(QMouseEvent* e);
- virtual void drawBackground(QPainter* painter, const QRectF& rect);
-
void disarm();
public slots:
void arm();
@@ -54,8 +46,6 @@ Q_SIGNALS:
void close();
private:
- Plasma::PushButton* m_closeButton;
- Plasma::FrameSvg* m_frame;
QTimer* m_armTimer;
};