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>
|
2014-01-23 15:17:18 +01:00
|
|
|
#include <Plasma/Theme>
|
2011-08-15 19:32:01 +02:00
|
|
|
|
2013-10-30 14:08:32 +01:00
|
|
|
#include <netwm_def.h>
|
|
|
|
|
2013-02-20 04:25:29 +01:00
|
|
|
class QQuickItem;
|
2014-02-03 16:46:01 +01:00
|
|
|
class QScreen;
|
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
|
|
|
/**
|
2013-02-26 05:47:12 +01:00
|
|
|
* QML wrapper for dialogs
|
2012-12-14 16:14:31 +01:00
|
|
|
*
|
2013-02-26 05:47:12 +01:00
|
|
|
* Exposed as `PlasmaCore.Dialog` in QML.
|
2012-12-14 16:14:31 +01:00
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
/**
|
2014-01-11 11:17:08 +01:00
|
|
|
* Plasma Location of the dialog window. Useful if this dialog is a popup for a panel
|
2011-12-23 14:50:34 +01:00
|
|
|
*/
|
2013-10-18 16:50:56 +02:00
|
|
|
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
|
2012-03-24 10:51:12 +01:00
|
|
|
|
2013-10-30 14:08:32 +01:00
|
|
|
/**
|
|
|
|
* Type of the window
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(WindowType type READ type WRITE setType NOTIFY typeChanged)
|
|
|
|
|
2013-12-11 11:15:07 +01:00
|
|
|
/**
|
|
|
|
* Whether the dialog should be hidden when the dialog loses focus.
|
|
|
|
*
|
|
|
|
* The default value is @c false.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(bool hideOnWindowDeactivate READ hideOnWindowDeactivate WRITE setHideOnWindowDeactivate NOTIFY hideOnWindowDeactivateChanged)
|
|
|
|
|
2014-01-20 10:11:58 +01:00
|
|
|
/**
|
|
|
|
* Whether the dialog is output only. Default value is @c false. If it is @c true
|
|
|
|
* the dialog does not accept input and all pointer events are not accepted, thus the dialog
|
|
|
|
* is click through.
|
|
|
|
*
|
|
|
|
* This property is currently only supported on the X11 platform. On any other platform the
|
|
|
|
* property has no effect.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(bool outputOnly READ isOutputOnly WRITE setOutputOnly NOTIFY outputOnlyChanged)
|
|
|
|
|
2013-02-20 19:31:06 +01:00
|
|
|
Q_CLASSINFO("DefaultProperty", "mainItem")
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
public:
|
2013-10-30 14:08:32 +01:00
|
|
|
enum WindowType {
|
|
|
|
Normal = NET::Normal,
|
|
|
|
Dock = NET::Dock,
|
|
|
|
Dialog = NET::Dialog,
|
|
|
|
PopupMenu = NET::PopupMenu,
|
2014-01-20 09:13:15 +01:00
|
|
|
Tooltip = NET::Tooltip,
|
|
|
|
Notification = NET::Notification
|
2011-02-25 19:00:01 +01:00
|
|
|
};
|
2013-10-30 14:08:32 +01:00
|
|
|
Q_ENUMS(WindowType)
|
2011-02-25 19:00:01 +01:00
|
|
|
|
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);
|
|
|
|
|
2013-10-18 16:50:56 +02:00
|
|
|
Plasma::Types::Location location() const;
|
|
|
|
void setLocation(Plasma::Types::Location location);
|
2011-08-15 19:32:01 +02:00
|
|
|
|
2011-06-08 17:53:19 +02:00
|
|
|
QObject *margins() const;
|
|
|
|
|
2014-01-09 12:10:22 +01:00
|
|
|
/*
|
|
|
|
* set the dialog position. subclasses may change it. ToolTipDialog adjusts the position in an animated way
|
|
|
|
*/
|
2014-01-09 16:36:59 +01:00
|
|
|
virtual void adjustGeometry(const QRect &geom);
|
2014-01-09 12:10:22 +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
|
|
|
|
*/
|
2014-01-12 17:29:07 +01:00
|
|
|
QPoint popupPosition(QQuickItem *item, const QSize &size, Qt::AlignmentFlag alignment=Qt::AlignCenter) ;
|
2011-12-23 14:50:34 +01:00
|
|
|
|
2013-10-30 14:08:32 +01:00
|
|
|
void setType(WindowType type);
|
|
|
|
WindowType type() const;
|
2013-12-11 11:15:07 +01:00
|
|
|
bool hideOnWindowDeactivate() const;
|
|
|
|
void setHideOnWindowDeactivate(bool hide);
|
2011-02-24 18:24:45 +01:00
|
|
|
|
2014-01-20 10:11:58 +01:00
|
|
|
void setOutputOnly(bool outputOnly);
|
|
|
|
bool isOutputOnly() const;
|
|
|
|
void updateInputShape();
|
|
|
|
|
2011-02-24 18:24:45 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
void mainItemChanged();
|
2011-08-15 19:32:01 +02:00
|
|
|
void locationChanged();
|
2013-02-20 20:39:15 +01:00
|
|
|
void visualParentChanged();
|
2013-10-30 14:08:32 +01:00
|
|
|
void typeChanged();
|
2013-12-11 11:15:07 +01:00
|
|
|
void hideOnWindowDeactivateChanged();
|
2014-01-20 10:11:58 +01:00
|
|
|
void outputOnlyChanged();
|
2011-02-24 18:24:45 +01:00
|
|
|
|
2013-04-09 00:08:23 +02:00
|
|
|
public Q_SLOTS:
|
2013-02-21 14:49:28 +01:00
|
|
|
void syncMainItemToSize();
|
2013-02-20 19:31:06 +01:00
|
|
|
void syncToMainItemSize();
|
2014-01-29 18:48:59 +01:00
|
|
|
void requestSyncToMainItemSize(bool delayed = false);
|
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);
|
2013-08-29 15:11:07 +02:00
|
|
|
void showEvent(QShowEvent *event);
|
2014-01-12 17:29:07 +01:00
|
|
|
void hideEvent(QHideEvent *event);
|
|
|
|
bool event(QEvent *event);
|
2011-02-25 20:37:56 +01:00
|
|
|
|
2013-02-20 19:31:06 +01:00
|
|
|
QTimer *m_syncTimer;
|
2013-05-14 18:27:27 +02:00
|
|
|
Plasma::Types::Location m_location;
|
2013-04-04 23:50:44 +02:00
|
|
|
Plasma::FrameSvgItem *m_frameSvgItem;
|
2013-02-20 04:25:29 +01:00
|
|
|
QWeakPointer<QQuickItem> m_mainItem;
|
2013-02-20 20:39:15 +01:00
|
|
|
QWeakPointer<QQuickItem> m_visualParent;
|
2013-04-04 23:50:44 +02:00
|
|
|
|
2013-10-18 17:20:59 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void syncBorders();
|
|
|
|
|
2014-01-12 17:29:07 +01:00
|
|
|
void updateVisibility(bool visible);
|
2013-12-17 01:21:59 +01:00
|
|
|
|
2014-01-31 19:59:45 +01:00
|
|
|
void updateMinimumWidth();
|
|
|
|
void updateMinimumHeight();
|
|
|
|
void updateMaximumWidth();
|
|
|
|
void updateMaximumHeight();
|
|
|
|
|
2013-04-04 23:50:44 +02:00
|
|
|
private:
|
2014-02-03 16:46:01 +01:00
|
|
|
QScreen* screenForItem(QQuickItem *item) const;
|
|
|
|
|
2013-02-26 05:39:49 +01:00
|
|
|
QRect m_cachedGeometry;
|
2013-10-30 14:08:32 +01:00
|
|
|
WindowType m_type;
|
2013-12-11 11:15:07 +01:00
|
|
|
bool m_hideOnWindowDeactivate;
|
2014-01-20 10:11:58 +01:00
|
|
|
bool m_outputOnly;
|
2014-01-23 15:17:18 +01:00
|
|
|
Plasma::Theme m_theme;
|
2014-01-31 19:59:45 +01:00
|
|
|
|
|
|
|
//Attached Layout property of mainItem, if any
|
|
|
|
QWeakPointer <QObject> m_mainItemLayout;
|
2011-02-24 18:24:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|