1
From b7eea9e4e4289eeae13fc72004539bec07bd0af3 Mon Sep 17 00:00:00 2001
2
From: Marco Martin <notmart@gmail.com>
3
Date: Mon, 15 Aug 2011 19:32:01 +0200
4
Subject: [PATCH 7/10] location property that decides the sliding effect
7
plasma/declarativeimports/core/dialog.cpp | 21 ++++++++++++++++++++-
8
plasma/declarativeimports/core/dialog.h | 8 ++++++++
9
2 files changed, 28 insertions(+), 1 deletions(-)
11
diff --git a/plasma/declarativeimports/core/dialog.cpp b/plasma/declarativeimports/core/dialog.cpp
12
index d5f1b42..bb74ac5 100644
13
--- a/plasma/declarativeimports/core/dialog.cpp
14
+++ b/plasma/declarativeimports/core/dialog.cpp
17
#include <Plasma/Corona>
18
#include <Plasma/Dialog>
19
+#include <Plasma/WindowEffects>
22
DialogMargins::DialogMargins(Plasma::Dialog *dialog, QObject *parent)
23
@@ -83,7 +84,8 @@ int DialogMargins::bottom() const
24
DialogProxy::DialogProxy(QObject *parent)
26
m_declarativeItemContainer(0),
27
- m_activeWindow(false)
28
+ m_activeWindow(false),
29
+ m_location(Plasma::Floating)
31
m_dialog = new Plasma::Dialog();
32
m_margins = new DialogMargins(m_dialog, this);
33
@@ -244,6 +246,21 @@ void DialogProxy::setWindowFlags(const int flags)
34
m_dialog->setWindowFlags((Qt::WindowFlags)flags);
37
+int DialogProxy::location() const
39
+ return (int)m_location;
42
+void DialogProxy::setLocation(int location)
44
+ if (m_location == location) {
47
+ m_location = (Plasma::Location)location;
48
+ emit locationChanged();
52
QObject *DialogProxy::margins() const
55
@@ -271,8 +288,10 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
58
} else if (watched == m_dialog && event->type() == QEvent::Show) {
59
+ Plasma::WindowEffects::slideWindow(m_dialog, m_location);
60
emit visibleChanged();
61
} else if (watched == m_dialog && event->type() == QEvent::Hide) {
62
+ Plasma::WindowEffects::slideWindow(m_dialog, m_location);
63
emit visibleChanged();
64
} else if (watched == m_dialog && event->type() == QEvent::WindowActivate) {
65
m_activeWindow = true;
66
diff --git a/plasma/declarativeimports/core/dialog.h b/plasma/declarativeimports/core/dialog.h
67
index 5d60d13..a871a80 100644
68
--- a/plasma/declarativeimports/core/dialog.h
69
+++ b/plasma/declarativeimports/core/dialog.h
71
#include <QWeakPointer>
74
+#include <Plasma/Plasma>
76
class QGraphicsObject;
79
@@ -81,6 +83,7 @@ class DialogProxy : public QObject
80
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
81
Q_PROPERTY(QObject *margins READ margins CONSTANT)
82
Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged)
83
+ Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged)
86
enum WidgetAttribute {
87
@@ -111,6 +114,9 @@ public:
88
int windowFlags() const;
89
void setWindowFlags(const int);
91
+ int location() const;
92
+ void setLocation(int location);
94
QObject *margins() const;
96
//FIXME: alignment should be Qt::AlignmentFlag
97
@@ -126,6 +132,7 @@ Q_SIGNALS:
100
void activeWindowChanged();
101
+ void locationChanged();
105
@@ -140,6 +147,7 @@ private:
106
QWeakPointer<QGraphicsObject> m_mainItem;
107
DialogMargins *m_margins;
109
+ Plasma::Location m_location;