From ab140c8c1e87e79bee66fd2ee30e44383ba5f9d4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 6 Feb 2014 18:49:28 +0100 Subject: [PATCH 1/2] add properties for tooltips metadata --- .../qml/plasmoid/appletinterface.cpp | 38 +++++++++++++++++++ .../qml/plasmoid/appletinterface.h | 22 +++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 99a33c602..1e47662a9 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -171,6 +171,44 @@ void AppletInterface::setTitle(const QString &title) emit titleChanged(); } +QString AppletInterface::toolTipMainText() const +{ + if (m_toolTipMainText.isNull()) { + return title(); + } else { + return m_toolTipMainText; + } +} + +void AppletInterface::setToolTipMainText(const QString &text) +{ + if (m_toolTipMainText == text) { + return; + } + + m_toolTipMainText = text; + emit toolTipMainTextChanged(); +} + +QString AppletInterface::toolTipSubText() const +{ + if (m_toolTipMainText.isNull()) { + return applet()->pluginInfo().comment(); + } else { + return m_toolTipSubText; + } +} + +void AppletInterface::setToolTipSubText(const QString &text) +{ + if (m_toolTipSubText == text) { + return; + } + + m_toolTipSubText = text; + emit toolTipSubTextChanged(); +} + bool AppletInterface::isBusy() const { return m_busy; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 7c0c3cd7c..10cd15d9b 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -67,6 +67,18 @@ class AppletInterface : public AppletQuickItem */ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + /** + * Main title for the plasmoid tooltip or other means of quick information: + * it's the same as the title property by default, but it can be personalized + */ + Q_PROPERTY(QString toolTipMainText READ toolTipMainText WRITE setToolTipMainText NOTIFY toolTipMainTextChanged) + + /** + * Description for the plasmoid tooltip or other means of quick information: + * it comes from the pluginifo comment by default, but it can be personalized + */ + Q_PROPERTY(QString toolTipSubText READ toolTipSubText WRITE setToolTipSubText NOTIFY toolTipSubTextChanged) + /** * Icon to represent the plasmoid */ @@ -230,6 +242,12 @@ public: QString title() const; void setTitle(const QString &title); + QString toolTipMainText() const; + void setToolTipMainText(const QString &text); + + QString toolTipSubText() const; + void setToolTipSubText(const QString &text); + uint id() const; Plasma::Types::FormFactor formFactor() const; @@ -278,6 +296,8 @@ Q_SIGNALS: //PROPERTY change notifiers-------------- void iconChanged(); void titleChanged(); + void toolTipMainTextChanged(); + void toolTipSubTextChanged(); void formFactorChanged(); void locationChanged(); void contextChanged(); @@ -307,6 +327,8 @@ private: //UI-specific members ------------------ + QString m_toolTipMainText; + QString m_toolTipSubText; Plasma::Types::BackgroundHints m_backgroundHints; bool m_busy : 1; bool m_hideOnDeactivate : 1; From 2b7a1eef4851e859009a800646044525f3da0661 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 6 Feb 2014 19:07:26 +0100 Subject: [PATCH 2/2] Initialise values Fixes valgrind screaming about us doing a jump on unitialised memory --- src/declarativeimports/core/units.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index 91a730103..138742f2c 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -40,6 +40,8 @@ Units::Units (QObject *parent) : QObject(parent), m_gridUnit(-1), m_devicePixelRatio(-1), + m_smallSpacing(-1), + m_largeSpacing(-1), m_longDuration(defaultLongDuration) // default base value for animations { m_iconSizes = new QQmlPropertyMap(this);