2011-02-24 18:24:45 +01:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright 2011 Marco Martin <mart@kde.org> *
|
2013-02-20 05:30:22 +01:00
|
|
|
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
|
2011-02-24 18:24:45 +01:00
|
|
|
* *
|
|
|
|
* 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
|
|
|
|
|
2013-02-01 17:26:26 +01:00
|
|
|
#include <QQuickItem>
|
2013-02-20 04:25:29 +01:00
|
|
|
#include <QQuickWindow>
|
2011-02-24 18:24:45 +01:00
|
|
|
#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>
|
|
|
|
|
2013-02-20 04:25:29 +01:00
|
|
|
class QQuickItem;
|
2011-02-24 18:24:45 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
2013-02-21 14:32:48 +01:00
|
|
|
class FrameSvgItem;
|
2011-02-24 18:24:45 +01:00
|
|
|
}
|
|
|
|
|
2011-02-24 23:46:23 +01:00
|
|
|
|
2012-12-14 16:14:31 +01:00
|
|
|
/**
|
|
|
|
* QML wrapper for kdelibs Plasma::Dialog
|
|
|
|
*
|
|
|
|
* Exposed as `Dialog` in QML.
|
|
|
|
*/
|
2013-02-20 05:30:22 +01:00
|
|
|
class DialogProxy : public QQuickWindow
|
2011-02-24 18:24:45 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2011-12-23 14:50:34 +01:00
|
|
|
/**
|
|
|
|
* The main QML item that will be displayed in the Dialog
|
|
|
|
*/
|
2013-02-20 04:25:29 +01:00
|
|
|
Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged)
|
2011-12-23 14:50:34 +01:00
|
|
|
|
2013-02-20 20:39:15 +01:00
|
|
|
/**
|
|
|
|
* The main QML item that will be displayed in the Dialog
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(QQuickItem *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged)
|
|
|
|
|
2011-12-23 14:50:34 +01:00
|
|
|
/**
|
|
|
|
* Visibility of the Dialog window. Doesn't have anything to do with the visibility of the mainItem.
|
|
|
|
*/
|
2011-02-24 18:24:45 +01:00
|
|
|
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
|
2011-12-23 14:50:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Window flags of the Dialog window
|
|
|
|
*/
|
2011-03-21 21:38:48 +01:00
|
|
|
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
|
2011-12-23 14:50:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Margins of the dialog around the mainItem.
|
|
|
|
* @see DialogMargins
|
|
|
|
*/
|
2011-06-08 17:53:19 +02:00
|
|
|
Q_PROPERTY(QObject *margins READ margins CONSTANT)
|
2011-12-23 14:50:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the dialog window is the active one in the window manager.
|
|
|
|
*/
|
2011-06-19 23:08:15 +02:00
|
|
|
Q_PROPERTY(bool activeWindow READ isActiveWindow NOTIFY activeWindowChanged)
|
2011-12-23 14:50:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plasma Location of the dialog window. Useful if this dialog is apopup for a panel
|
|
|
|
*/
|
2013-02-25 17:49:49 +01:00
|
|
|
Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged)
|
2012-04-06 13:08:49 +02:00
|
|
|
//This won't be available on windows, but should be used only by kwin and never by applets anyways
|
|
|
|
#ifndef Q_WS_WIN
|
2012-03-24 10:51:12 +01:00
|
|
|
/**
|
|
|
|
* Window ID of the dialog window.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(qulonglong windowId READ windowId CONSTANT)
|
2012-04-06 13:08:49 +02:00
|
|
|
#endif
|
2012-03-24 10:51:12 +01:00
|
|
|
|
2013-02-20 19:31:06 +01:00
|
|
|
Q_CLASSINFO("DefaultProperty", "mainItem")
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
public:
|
2011-02-25 19:00:01 +01:00
|
|
|
enum WidgetAttribute {
|
|
|
|
WA_X11NetWmWindowTypeDock = Qt::WA_X11NetWmWindowTypeDock
|
|
|
|
};
|
|
|
|
|
2013-02-01 17:26:26 +01:00
|
|
|
DialogProxy(QQuickItem *parent = 0);
|
2011-02-24 18:24:45 +01:00
|
|
|
~DialogProxy();
|
|
|
|
|
2013-02-20 04:25:29 +01:00
|
|
|
QQuickItem *mainItem() const;
|
|
|
|
void setMainItem(QQuickItem *mainItem);
|
2011-02-24 18:24:45 +01:00
|
|
|
|
2013-02-20 20:39:15 +01:00
|
|
|
QQuickItem *visualParent() const;
|
|
|
|
void setVisualParent(QQuickItem *visualParent);
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
bool isVisible() const;
|
|
|
|
void setVisible(const bool visible);
|
|
|
|
|
2011-06-19 23:08:15 +02:00
|
|
|
bool isActiveWindow() const;
|
|
|
|
|
2011-12-23 14:50:34 +01:00
|
|
|
/**
|
|
|
|
* Ask the window manager to activate the window.
|
|
|
|
* The window manager may or may not accept the activiation request
|
|
|
|
*/
|
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);
|
|
|
|
|
2013-02-25 17:49:49 +01:00
|
|
|
int location() const;
|
|
|
|
void setLocation(int location);
|
2011-08-15 19:32:01 +02:00
|
|
|
|
2011-06-08 17:53:19 +02:00
|
|
|
QObject *margins() const;
|
|
|
|
|
2012-04-06 13:08:49 +02:00
|
|
|
#ifndef Q_WS_WIN
|
2012-03-24 10:51:12 +01:00
|
|
|
qulonglong windowId() const;
|
2012-04-06 13:08:49 +02:00
|
|
|
#endif
|
2012-03-24 10:51:12 +01:00
|
|
|
|
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
|
2013-02-22 03:54:14 +01:00
|
|
|
QPoint popupPosition(QQuickItem *item, Qt::AlignmentFlag alignment=Qt::AlignCenter) ;
|
2011-12-23 14:50:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a Qt.WidgetAttribute to the dialog window
|
|
|
|
*
|
|
|
|
* @arg int attribute see Qt.WidgetAttribute
|
|
|
|
* @arg bool on activate or deactivate the atrtibute
|
|
|
|
*/
|
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-19 23:08:15 +02:00
|
|
|
void activeWindowChanged();
|
2011-08-15 19:32:01 +02:00
|
|
|
void locationChanged();
|
2013-02-20 20:39:15 +01:00
|
|
|
void visualParentChanged();
|
2011-02-24 18:24:45 +01:00
|
|
|
|
2013-02-20 19:31:06 +01:00
|
|
|
private Q_SLOTS:
|
2013-02-21 14:49:28 +01:00
|
|
|
void syncMainItemToSize();
|
2013-02-20 19:31:06 +01:00
|
|
|
void syncToMainItemSize();
|
2011-02-24 18:24:45 +01:00
|
|
|
|
2011-02-25 20:37:56 +01:00
|
|
|
protected:
|
2013-02-20 15:51:28 +01:00
|
|
|
// bool eventFilter(QObject *watched, QEvent *event);
|
2013-02-20 15:18:58 +01:00
|
|
|
void resizeEvent(QResizeEvent *re);
|
2013-02-20 19:39:03 +01:00
|
|
|
void focusInEvent(QFocusEvent *ev);
|
|
|
|
void focusOutEvent(QFocusEvent *ev);
|
2011-02-25 20:37:56 +01:00
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
private:
|
2011-03-21 21:38:48 +01:00
|
|
|
Qt::WindowFlags m_flags;
|
2013-02-20 19:31:06 +01:00
|
|
|
QTimer *m_syncTimer;
|
2013-02-20 04:25:29 +01:00
|
|
|
QWeakPointer<QQuickItem> m_mainItem;
|
2013-02-20 20:39:15 +01:00
|
|
|
QWeakPointer<QQuickItem> m_visualParent;
|
2011-06-19 23:08:15 +02:00
|
|
|
bool m_activeWindow;
|
2013-02-25 17:49:49 +01:00
|
|
|
Plasma::Location m_location;
|
2013-02-21 14:32:48 +01:00
|
|
|
Plasma::FrameSvgItem *m_frameSvgItem;
|
2013-02-26 05:39:49 +01:00
|
|
|
QRect m_cachedGeometry;
|
2011-02-24 18:24:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|