2011-02-24 18:24:45 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright 2011 Marco Martin <mart@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, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
|
|
***************************************************************************/
|
|
|
|
#ifndef DIALOG_PROXY_P
|
|
|
|
#define DIALOG_PROXY_P
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWeakPointer>
|
2011-03-21 19:18:28 +01:00
|
|
|
#include <QPoint>
|
2011-02-24 18:24:45 +01:00
|
|
|
|
2011-08-15 19:32:01 +02:00
|
|
|
#include <Plasma/Plasma>
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
class QGraphicsObject;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class Dialog;
|
|
|
|
}
|
|
|
|
|
2011-02-24 23:46:23 +01:00
|
|
|
class DeclarativeItemContainer;
|
|
|
|
|
2011-06-08 17:53:19 +02:00
|
|
|
class DialogMargins : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(int left READ left NOTIFY leftChanged)
|
|
|
|
Q_PROPERTY(int top READ top NOTIFY topChanged)
|
|
|
|
Q_PROPERTY(int right READ right NOTIFY rightChanged)
|
|
|
|
Q_PROPERTY(int bottom READ bottom NOTIFY bottomChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
DialogMargins(Plasma::Dialog *dialog, QObject *parent = 0);
|
|
|
|
|
|
|
|
int left() const;
|
|
|
|
int top() const;
|
|
|
|
int right() const;
|
|
|
|
int bottom() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void leftChanged();
|
|
|
|
void rightChanged();
|
|
|
|
void topChanged();
|
|
|
|
void bottomChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void checkMargins();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_left;
|
|
|
|
int m_top;
|
|
|
|
int m_right;
|
|
|
|
int m_bottom;
|
|
|
|
Plasma::Dialog *m_dialog;
|
|
|
|
friend class DialogProxy;
|
|
|
|
};
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
class DialogProxy : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QGraphicsObject *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged)
|
|
|
|
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
|
2011-06-07 16:40:33 +02:00
|
|
|
Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
|
|
|
|
Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
|
|
|
|
//to set the size try to force doing so from the inner item
|
|
|
|
Q_PROPERTY(int width READ width NOTIFY widthChanged)
|
2011-06-13 13:44:45 +02:00
|
|
|
Q_PROPERTY(int height READ height NOTIFY heightChanged)
|
2011-03-21 21:38:48 +01:00
|
|
|
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
|
2011-06-08 17:53:19 +02:00
|
|
|
Q_PROPERTY(QObject *margins READ margins CONSTANT)
|
2011-06-19 23:08:15 +02:00
|
|
|
Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged)
|
2011-08-15 19:32:01 +02:00
|
|
|
Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged)
|
2011-02-24 18:24:45 +01:00
|
|
|
|
|
|
|
public:
|
2011-02-25 19:00:01 +01:00
|
|
|
enum WidgetAttribute {
|
|
|
|
WA_X11NetWmWindowTypeDock = Qt::WA_X11NetWmWindowTypeDock
|
|
|
|
};
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
DialogProxy(QObject *parent = 0);
|
|
|
|
~DialogProxy();
|
|
|
|
|
|
|
|
QGraphicsObject *mainItem() const;
|
|
|
|
void setMainItem(QGraphicsObject *mainItem);
|
|
|
|
|
|
|
|
bool isVisible() const;
|
|
|
|
void setVisible(const bool visible);
|
|
|
|
|
2011-02-25 20:37:56 +01:00
|
|
|
int x() const;
|
|
|
|
void setX(int x);
|
|
|
|
|
|
|
|
int y() const;
|
|
|
|
void setY(int y);
|
|
|
|
|
2011-06-07 16:40:33 +02:00
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
|
2011-06-19 23:08:15 +02:00
|
|
|
bool isActiveWindow() const;
|
|
|
|
|
2011-11-16 21:11:58 +01:00
|
|
|
Q_INVOKABLE void activateWindow();
|
|
|
|
|
2011-03-21 21:38:48 +01:00
|
|
|
//FIXME: passing an int is ugly
|
|
|
|
int windowFlags() const;
|
|
|
|
void setWindowFlags(const int);
|
|
|
|
|
2011-08-15 19:32:01 +02:00
|
|
|
int location() const;
|
|
|
|
void setLocation(int location);
|
|
|
|
|
2011-06-08 17:53:19 +02:00
|
|
|
QObject *margins() const;
|
|
|
|
|
2011-11-03 14:46:05 +01:00
|
|
|
/**
|
|
|
|
* @returns The suggested screen position for the popup
|
|
|
|
* @arg item the item the popup has to be positioned relatively to. if null, the popup will be positioned in the center of the window
|
|
|
|
* @arg alignment alignment of the popup compared to the item
|
|
|
|
*/
|
2011-06-08 13:02:22 +02:00
|
|
|
//FIXME: alignment should be Qt::AlignmentFlag
|
2011-11-03 14:46:05 +01:00
|
|
|
Q_INVOKABLE QPoint popupPosition(QGraphicsObject *item, int alignment=Qt::AlignLeft) ;
|
2011-02-25 19:00:01 +01:00
|
|
|
//FIXME:: Qt::WidgetAttribute should be already
|
|
|
|
Q_INVOKABLE void setAttribute(int attribute, bool on);
|
2011-02-24 18:24:45 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void mainItemChanged();
|
|
|
|
void visibleChanged();
|
2011-06-07 16:40:33 +02:00
|
|
|
void xChanged();
|
|
|
|
void yChanged();
|
|
|
|
void widthChanged();
|
|
|
|
void heightChanged();
|
2011-06-19 23:08:15 +02:00
|
|
|
void activeWindowChanged();
|
2011-08-15 19:32:01 +02:00
|
|
|
void locationChanged();
|
2011-02-24 18:24:45 +01:00
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
void syncMainItem();
|
|
|
|
|
2011-02-25 20:37:56 +01:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event);
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
private:
|
|
|
|
Plasma::Dialog *m_dialog;
|
2011-03-21 21:38:48 +01:00
|
|
|
Qt::WindowFlags m_flags;
|
2011-02-24 23:46:23 +01:00
|
|
|
DeclarativeItemContainer *m_declarativeItemContainer;
|
2011-02-24 18:24:45 +01:00
|
|
|
QWeakPointer<QGraphicsObject> m_mainItem;
|
2011-06-08 17:53:19 +02:00
|
|
|
DialogMargins *m_margins;
|
2011-06-19 23:08:15 +02:00
|
|
|
bool m_activeWindow;
|
2011-08-15 19:32:01 +02:00
|
|
|
Plasma::Location m_location;
|
2011-11-02 18:15:17 +01:00
|
|
|
static int offscreenX;
|
|
|
|
static int offscreenY;
|
2011-02-24 18:24:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|