Use a QDeclarativeView for button views in Present Windows and Desktop Grid
Declarative UI++ REVIEW: 109409
This commit is contained in:
parent
fbc11aad13
commit
fb65c07bf7
9 changed files with 146 additions and 143 deletions
|
@ -8,6 +8,11 @@ set(kwin_effect_OWN_LIBS
|
||||||
set(kwin_effect_KDE_LIBS
|
set(kwin_effect_KDE_LIBS
|
||||||
${KDE4_KDEUI_LIBS}
|
${KDE4_KDEUI_LIBS}
|
||||||
${KDE4_PLASMA_LIBS}
|
${KDE4_PLASMA_LIBS}
|
||||||
|
${KDECLARATIVE_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(kwin_effect_QT_LIBS
|
||||||
|
${QT_QTDECLARATIVE_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(kwin_effect_XLIB_LIBS
|
set(kwin_effect_XLIB_LIBS
|
||||||
|
@ -34,7 +39,7 @@ endif()
|
||||||
|
|
||||||
macro( KWIN4_ADD_EFFECT_BACKEND name )
|
macro( KWIN4_ADD_EFFECT_BACKEND name )
|
||||||
kde4_add_plugin( ${name} ${ARGN} )
|
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()
|
endmacro()
|
||||||
|
|
||||||
# Adds effect plugin with given name. Sources are given after the name
|
# Adds effect plugin with given name. Sources are given after the name
|
||||||
|
|
|
@ -12,6 +12,10 @@ kde4_add_kcfg_files(kwin4_effect_builtins_sources desktopgrid/desktopgridconfig.
|
||||||
install( FILES
|
install( FILES
|
||||||
desktopgrid/desktopgrid.desktop
|
desktopgrid/desktopgrid.desktop
|
||||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||||
|
install( FILES
|
||||||
|
desktopgrid/main.qml
|
||||||
|
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects/desktopgrid/
|
||||||
|
)
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Config
|
# Config
|
||||||
|
|
|
@ -32,17 +32,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <KDE/KLocalizedString>
|
#include <KDE/KLocalizedString>
|
||||||
|
#include <KDE/KStandardDirs>
|
||||||
|
#include <kdeclarative.h>
|
||||||
#include <netwm_def.h>
|
#include <netwm_def.h>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <kglobalsettings.h>
|
#include <kglobalsettings.h>
|
||||||
#include <QtGui/QPainter>
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
#include <QtGui/QVector2D>
|
#include <QtGui/QVector2D>
|
||||||
#include <Plasma/FrameSvg>
|
#include <QDeclarativeEngine>
|
||||||
#include <Plasma/PushButton>
|
#include <QDeclarativeContext>
|
||||||
#include <Plasma/Theme>
|
#include <QGraphicsObject>
|
||||||
#include <Plasma/WindowEffects>
|
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -1383,58 +1382,34 @@ bool DesktopGridEffect::isRelevantWithPresentWindows(EffectWindow *w) const
|
||||||
/************************************************
|
/************************************************
|
||||||
* DesktopButtonView
|
* DesktopButtonView
|
||||||
************************************************/
|
************************************************/
|
||||||
DesktopButtonsView::DesktopButtonsView(QWidget* parent)
|
DesktopButtonsView::DesktopButtonsView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QDeclarativeView(parent)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
setFrameShape(QFrame::NoFrame);
|
|
||||||
QPalette pal = palette();
|
QPalette pal = palette();
|
||||||
pal.setColor(backgroundRole(), Qt::transparent);
|
pal.setColor(backgroundRole(), Qt::transparent);
|
||||||
setPalette(pal);
|
setPalette(pal);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
engine()->addImportPath(importPath);
|
||||||
|
}
|
||||||
// setup the scene
|
KDeclarative kdeclarative;
|
||||||
QGraphicsScene* scene = new QGraphicsScene(this);
|
kdeclarative.setDeclarativeEngine(engine());
|
||||||
m_addDesktopButton = new Plasma::PushButton();
|
kdeclarative.initialize();
|
||||||
m_addDesktopButton->setIcon(KIcon("list-add"));
|
kdeclarative.setupBindings();
|
||||||
m_removeDesktopButton = new Plasma::PushButton();
|
|
||||||
m_removeDesktopButton->setIcon(KIcon("list-remove"));
|
rootContext()->setContextProperty("add", QVariant(true));
|
||||||
scene->addItem(m_addDesktopButton);
|
rootContext()->setContextProperty("remove", QVariant(true));
|
||||||
scene->addItem(m_removeDesktopButton);
|
setSource(QUrl(KStandardDirs::locate("data", QLatin1String("kwin/effects/desktopgrid/main.qml"))));
|
||||||
connect(m_addDesktopButton, SIGNAL(clicked()), SIGNAL(addDesktop()));
|
if (QObject *item = rootObject()->findChild<QObject*>("addButton")) {
|
||||||
connect(m_removeDesktopButton, SIGNAL(clicked()), SIGNAL(removeDesktop()));
|
connect(item, SIGNAL(clicked()), SIGNAL(addDesktop()));
|
||||||
|
}
|
||||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
|
if (QObject *item = rootObject()->findChild<QObject*>("removeButton")) {
|
||||||
layout->addItem(m_addDesktopButton);
|
connect(item, SIGNAL(clicked()), SIGNAL(removeDesktop()));
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
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) {
|
if (e->type() == QEvent::MouseMove) {
|
||||||
mouseMoveEvent(e);
|
mouseMoveEvent(e);
|
||||||
|
@ -1449,19 +1424,12 @@ void DesktopButtonsView::windowInputMouseEvent(QMouseEvent* e)
|
||||||
|
|
||||||
void DesktopButtonsView::setAddDesktopEnabled(bool enable)
|
void DesktopButtonsView::setAddDesktopEnabled(bool enable)
|
||||||
{
|
{
|
||||||
m_addDesktopButton->setEnabled(enable);
|
rootContext()->setContextProperty("add", QVariant(enable));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopButtonsView::setRemoveDesktopEnabled(bool enable)
|
void DesktopButtonsView::setRemoveDesktopEnabled(bool enable)
|
||||||
{
|
{
|
||||||
m_removeDesktopButton->setEnabled(enable);
|
rootContext()->setContextProperty("remove", QVariant(enable));
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopButtonsView::drawBackground(QPainter* painter, const QRectF& rect)
|
|
||||||
{
|
|
||||||
Q_UNUSED(rect)
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
|
||||||
m_frame->paintFrame(painter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -25,38 +25,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
#include <kshortcut.h>
|
#include <kshortcut.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDeclarativeView>
|
||||||
#include <QTimeLine>
|
#include <QTimeLine>
|
||||||
#include <QGraphicsView>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
class PushButton;
|
|
||||||
class FrameSvg;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
class PresentWindowsEffectProxy;
|
class PresentWindowsEffectProxy;
|
||||||
|
|
||||||
class DesktopButtonsView : public QGraphicsView
|
class DesktopButtonsView : public QDeclarativeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DesktopButtonsView(QWidget* parent = 0);
|
explicit DesktopButtonsView(QWidget *parent = 0);
|
||||||
void windowInputMouseEvent(QMouseEvent* e);
|
void windowInputMouseEvent(QMouseEvent* e);
|
||||||
void setAddDesktopEnabled(bool enable);
|
void setAddDesktopEnabled(bool enable);
|
||||||
void setRemoveDesktopEnabled(bool enable);
|
void setRemoveDesktopEnabled(bool enable);
|
||||||
virtual void drawBackground(QPainter* painter, const QRectF& rect);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void addDesktop();
|
void addDesktop();
|
||||||
void removeDesktop();
|
void removeDesktop();
|
||||||
|
|
||||||
private:
|
|
||||||
Plasma::PushButton* m_addDesktopButton;
|
|
||||||
Plasma::PushButton* m_removeDesktopButton;
|
|
||||||
Plasma::FrameSvg* m_frame;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DesktopGridEffect
|
class DesktopGridEffect
|
||||||
|
|
44
effects/desktopgrid/main.qml
Normal file
44
effects/desktopgrid/main.qml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/********************************************************************
|
||||||
|
KWin - the KDE window manager
|
||||||
|
This file is part of the KDE project.
|
||||||
|
|
||||||
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,10 @@ kde4_add_kcfg_files(kwin4_effect_builtins_sources presentwindows/presentwindowsc
|
||||||
install( FILES
|
install( FILES
|
||||||
presentwindows/presentwindows.desktop
|
presentwindows/presentwindows.desktop
|
||||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||||
|
install( FILES
|
||||||
|
presentwindows/main.qml
|
||||||
|
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects/presentwindows/
|
||||||
|
)
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Config
|
# Config
|
||||||
|
|
32
effects/presentwindows/main.qml
Normal file
32
effects/presentwindows/main.qml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/********************************************************************
|
||||||
|
KWin - the KDE window manager
|
||||||
|
This file is part of the KDE project.
|
||||||
|
|
||||||
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,25 +26,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <KDE/KIcon>
|
#include <KDE/KIcon>
|
||||||
#include <KDE/KLocalizedString>
|
#include <KDE/KLocalizedString>
|
||||||
|
#include <KDE/KStandardDirs>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kglobalsettings.h>
|
#include <kglobalsettings.h>
|
||||||
|
#include <kdeclarative.h>
|
||||||
|
|
||||||
#include <kwinglutils.h>
|
#include <kwinglutils.h>
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QtGui/QPainter>
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
#include <Plasma/FrameSvg>
|
|
||||||
#include <Plasma/PushButton>
|
|
||||||
#include <Plasma/Theme>
|
|
||||||
#include <Plasma/WindowEffects>
|
|
||||||
#include <netwm_def.h>
|
#include <netwm_def.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDeclarativeContext>
|
||||||
|
#include <QDeclarativeEngine>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QGraphicsObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QVector4D>
|
#include <QVector4D>
|
||||||
|
@ -1927,51 +1926,29 @@ void PresentWindowsEffect::screenCountChanged()
|
||||||
/************************************************
|
/************************************************
|
||||||
* CloseWindowView
|
* CloseWindowView
|
||||||
************************************************/
|
************************************************/
|
||||||
CloseWindowView::CloseWindowView(QWidget* parent)
|
CloseWindowView::CloseWindowView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QDeclarativeView(parent)
|
||||||
, m_armTimer(new QTimer(this))
|
, m_armTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
setFrameShape(QFrame::NoFrame);
|
|
||||||
QPalette pal = palette();
|
QPalette pal = palette();
|
||||||
pal.setColor(backgroundRole(), Qt::transparent);
|
pal.setColor(backgroundRole(), Qt::transparent);
|
||||||
setPalette(pal);
|
setPalette(pal);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
engine()->addImportPath(importPath);
|
||||||
|
}
|
||||||
// setup the scene
|
KDeclarative kdeclarative;
|
||||||
QGraphicsScene* scene = new QGraphicsScene(this);
|
kdeclarative.setDeclarativeEngine(engine());
|
||||||
m_closeButton = new Plasma::PushButton();
|
kdeclarative.initialize();
|
||||||
m_closeButton->setIcon(KIcon("window-close"));
|
kdeclarative.setupBindings();
|
||||||
scene->addItem(m_closeButton);
|
|
||||||
connect(m_closeButton, SIGNAL(clicked()), SIGNAL(close()));
|
rootContext()->setContextProperty("armed", QVariant(false));
|
||||||
|
|
||||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
|
setSource(QUrl(KStandardDirs::locate("data", QLatin1String("kwin/effects/presentwindows/main.qml"))));
|
||||||
layout->addItem(m_closeButton);
|
if (QObject *item = rootObject()->findChild<QObject*>("closeButton")) {
|
||||||
|
connect(item, SIGNAL(clicked()), SIGNAL(close()));
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
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
|
// setup the timer - attempt to prevent accidental clicks
|
||||||
m_armTimer->setSingleShot(true);
|
m_armTimer->setSingleShot(true);
|
||||||
|
@ -1979,9 +1956,9 @@ CloseWindowView::CloseWindowView(QWidget* parent)
|
||||||
connect(m_armTimer, SIGNAL(timeout()), SLOT(arm()));
|
connect(m_armTimer, SIGNAL(timeout()), SLOT(arm()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseWindowView::windowInputMouseEvent(QMouseEvent* e)
|
void CloseWindowView::windowInputMouseEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
if (!isEnabled())
|
if (m_armTimer->isActive())
|
||||||
return;
|
return;
|
||||||
if (e->type() == QEvent::MouseMove) {
|
if (e->type() == QEvent::MouseMove) {
|
||||||
mouseMoveEvent(e);
|
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()
|
void CloseWindowView::arm()
|
||||||
{
|
{
|
||||||
setEnabled(true);
|
rootContext()->setContextProperty("armed", QVariant(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseWindowView::disarm()
|
void CloseWindowView::disarm()
|
||||||
{
|
{
|
||||||
setEnabled(false);
|
rootContext()->setContextProperty("armed", QVariant(false));
|
||||||
m_armTimer->start();
|
m_armTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "presentwindows.moc"
|
#include "presentwindows.moc"
|
||||||
|
|
|
@ -26,26 +26,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
#include <kshortcut.h>
|
#include <kshortcut.h>
|
||||||
#include <QGraphicsView>
|
#include <QDeclarativeView>
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
class PushButton;
|
|
||||||
class FrameSvg;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
class CloseWindowView : public QDeclarativeView
|
||||||
class CloseWindowView : public QGraphicsView
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CloseWindowView(QWidget* parent = 0);
|
explicit CloseWindowView(QWidget *parent = 0);
|
||||||
void windowInputMouseEvent(QMouseEvent* e);
|
void windowInputMouseEvent(QMouseEvent* e);
|
||||||
virtual void drawBackground(QPainter* painter, const QRectF& rect);
|
|
||||||
|
|
||||||
void disarm();
|
void disarm();
|
||||||
public slots:
|
public slots:
|
||||||
void arm();
|
void arm();
|
||||||
|
@ -54,8 +46,6 @@ Q_SIGNALS:
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plasma::PushButton* m_closeButton;
|
|
||||||
Plasma::FrameSvg* m_frame;
|
|
||||||
QTimer* m_armTimer;
|
QTimer* m_armTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue