hideOnWindowDeactivate property for plasmoid object

This allows to control whether to automatically close panel popups when
they lose focus. Applets can set this to false in case they want to keep
the popup open (even temporarily).
This commit is contained in:
Sebastian Kügler 2013-12-12 00:22:47 +01:00
parent 78276bd589
commit 6b4ca35897
2 changed files with 29 additions and 1 deletions

View File

@ -58,7 +58,8 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
m_actionSignals(0),
m_backgroundHints(Plasma::Types::StandardBackground),
m_busy(false),
m_expanded(false)
m_expanded(false),
m_hideOnDeactivate(true)
{
qmlRegisterType<AppletInterface>();
qmlRegisterType<QAction>();
@ -619,6 +620,20 @@ int AppletInterface::screen() const
return -1;
}
void AppletInterface::setHideOnWindowDeactivate(bool hide)
{
if (m_hideOnDeactivate != hide) {
m_hideOnDeactivate = hide;
emit hideOnWindowDeactivateChanged();
}
}
bool AppletInterface::hideOnWindowDeactivate() const
{
return m_hideOnDeactivate;
}
QString AppletInterface::downloadPath(const QString &file)
{
const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/Plasma/" + applet()->pluginInfo().pluginName() + '/';

View File

@ -162,6 +162,14 @@ class AppletInterface : public QQuickItem
*/
Q_PROPERTY(bool fillHeight READ fillHeight NOTIFY fillHeightChanged)
/**
* 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)
public:
AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent = 0);
~AppletInterface();
@ -273,6 +281,9 @@ public:
bool userConfiguring() const;
int apiVersion() const;
bool hideOnWindowDeactivate() const;
void setHideOnWindowDeactivate(bool hide);
bool fillWidth() const;
bool fillHeight() const;
qreal minimumWidth() const;
@ -305,6 +316,7 @@ Q_SIGNALS:
void busyChanged();
void expandedChanged();
void screenChanged();
void hideOnWindowDeactivateChanged();
void minimumWidthChanged();
void minimumHeightChanged();
@ -350,6 +362,7 @@ private:
Plasma::Types::BackgroundHints m_backgroundHints;
bool m_busy : 1;
bool m_expanded : 1;
bool m_hideOnDeactivate : 1;
friend class ContainmentInterface;
};