[scriptengine/qml] Allow applets to set full ToolTip item

Adds new property available as Plasmoid.toolTipItem that allows
to set a full custom item as the tooltip

REVIEW: 126463
This commit is contained in:
Martin Klapetek 2016-01-04 11:38:14 -05:00
parent 532fce558d
commit 3992593f31
2 changed files with 33 additions and 0 deletions

View File

@ -53,6 +53,7 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant
m_configuration(0),
m_appletScriptEngine(script),
m_toolTipTextFormat(0),
m_toolTipItem(0),
m_args(args),
m_backgroundHints(Plasma::Types::StandardBackground),
m_busy(false),
@ -350,6 +351,24 @@ void AppletInterface::setToolTipTextFormat(int format)
emit toolTipTextFormatChanged();
}
QQuickItem *AppletInterface::toolTipItem() const
{
return m_toolTipItem.data();
}
void AppletInterface::setToolTipItem(QQuickItem *toolTipItem)
{
if (m_toolTipItem.data() == toolTipItem) {
return;
}
connect(m_toolTipItem.data(), &QObject::destroyed,
this, &AppletInterface::toolTipItemChanged);
m_toolTipItem = toolTipItem;
emit toolTipItemChanged();
}
bool AppletInterface::isBusy() const
{
return m_busy;

View File

@ -100,6 +100,15 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
*/
Q_PROPERTY(int toolTipTextFormat READ toolTipTextFormat WRITE setToolTipTextFormat NOTIFY toolTipTextFormatChanged)
/**
* This allows to set custom full QML items as the tooltip.
* It will ignore all texts set by setToolTipMainText or setToolTipSubText
*
* @since: 5.19
*/
Q_PROPERTY(QQuickItem *toolTipItem READ toolTipItem WRITE setToolTipItem NOTIFY toolTipItemChanged)
/**
* Icon to represent the plasmoid
*/
@ -285,6 +294,9 @@ public:
int toolTipTextFormat() const;
void setToolTipTextFormat(int format);
QQuickItem *toolTipItem() const;
void setToolTipItem(QQuickItem *toolTipItem);
uint id() const;
Plasma::Types::FormFactor formFactor() const;
@ -353,6 +365,7 @@ Q_SIGNALS:
void toolTipMainTextChanged();
void toolTipSubTextChanged();
void toolTipTextFormatChanged();
void toolTipItemChanged();
void formFactorChanged();
void locationChanged();
void contextChanged();
@ -391,6 +404,7 @@ private:
QString m_toolTipMainText;
QString m_toolTipSubText;
int m_toolTipTextFormat;
QPointer<QQuickItem> m_toolTipItem;
QVariantList m_args;
Plasma::Types::BackgroundHints m_backgroundHints;
bool m_busy : 1;