setting the mainItem property of a Dialog element, it will create a top level window with that item as the graphicsWidget() right now it works only with QGraphicsWidget{} elements, Plasma::Dialog will be given the api to make this work with any QGraphicsObject as well.
64 lines
2.2 KiB
C++
64 lines
2.2 KiB
C++
/***************************************************************************
|
|
* 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>
|
|
|
|
class QGraphicsObject;
|
|
|
|
namespace Plasma
|
|
{
|
|
class Dialog;
|
|
}
|
|
|
|
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)
|
|
|
|
public:
|
|
DialogProxy(QObject *parent = 0);
|
|
~DialogProxy();
|
|
|
|
QGraphicsObject *mainItem() const;
|
|
void setMainItem(QGraphicsObject *mainItem);
|
|
|
|
bool isVisible() const;
|
|
void setVisible(const bool visible);
|
|
|
|
Q_INVOKABLE void showPopup(QGraphicsObject *item);
|
|
|
|
Q_SIGNALS:
|
|
void mainItemChanged();
|
|
void visibleChanged();
|
|
|
|
protected Q_SLOTS:
|
|
void syncMainItem();
|
|
|
|
private:
|
|
Plasma::Dialog *m_dialog;
|
|
QWeakPointer<QGraphicsObject> m_mainItem;
|
|
};
|
|
|
|
#endif
|