location property that decides the sliding effect

This commit is contained in:
Marco Martin 2011-08-15 19:32:01 +02:00
parent 96edc153a8
commit 6d7b475468
2 changed files with 28 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#include <Plasma/Corona>
#include <Plasma/Dialog>
#include <Plasma/WindowEffects>
DialogMargins::DialogMargins(Plasma::Dialog *dialog, QObject *parent)
@ -83,7 +84,8 @@ int DialogMargins::bottom() const
DialogProxy::DialogProxy(QObject *parent)
: QObject(parent),
m_declarativeItemContainer(0),
m_activeWindow(false)
m_activeWindow(false),
m_location(Plasma::Floating)
{
m_dialog = new Plasma::Dialog();
m_margins = new DialogMargins(m_dialog, this);
@ -248,6 +250,21 @@ void DialogProxy::setWindowFlags(const int flags)
m_dialog->setWindowFlags((Qt::WindowFlags)flags);
}
int DialogProxy::location() const
{
return (int)m_location;
}
void DialogProxy::setLocation(int location)
{
if (m_location == location) {
return;
}
m_location = (Plasma::Location)location;
emit locationChanged();
}
QObject *DialogProxy::margins() const
{
return m_margins;
@ -275,8 +292,10 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
emit heightChanged();
}
} else if (watched == m_dialog && event->type() == QEvent::Show) {
Plasma::WindowEffects::slideWindow(m_dialog, m_location);
emit visibleChanged();
} else if (watched == m_dialog && event->type() == QEvent::Hide) {
Plasma::WindowEffects::slideWindow(m_dialog, m_location);
emit visibleChanged();
} else if (watched == m_dialog && event->type() == QEvent::WindowActivate) {
m_activeWindow = true;

View File

@ -23,6 +23,8 @@
#include <QWeakPointer>
#include <QPoint>
#include <Plasma/Plasma>
class QGraphicsObject;
namespace Plasma
@ -81,6 +83,7 @@ class DialogProxy : public QObject
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(QObject *margins READ margins CONSTANT)
Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged)
Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged)
public:
enum WidgetAttribute {
@ -111,6 +114,9 @@ public:
int windowFlags() const;
void setWindowFlags(const int);
int location() const;
void setLocation(int location);
QObject *margins() const;
//FIXME: alignment should be Qt::AlignmentFlag
@ -126,6 +132,7 @@ Q_SIGNALS:
void widthChanged();
void heightChanged();
void activeWindowChanged();
void locationChanged();
protected Q_SLOTS:
void syncMainItem();
@ -140,6 +147,7 @@ private:
QWeakPointer<QGraphicsObject> m_mainItem;
DialogMargins *m_margins;
bool m_activeWindow;
Plasma::Location m_location;
};
#endif