Change in plasma-framework[master]: export textFormat for the tooltip

Marco Martin (Code Review) noreply at kde.org
Tue Jan 27 16:19:14 UTC 2015


Marco Martin has uploaded a new change for review.

  https://gerrit.vesnicky.cesnet.cz/r/345

Change subject: export textFormat for the tooltip
......................................................................

export textFormat for the tooltip

in some cases richtext in the tooltip is not desired, like
in the case of klipper. export a property to set
the text format

Change-Id: Ib4e8e913e060b868188b4f0b46db2162f33d8bb1
---
M src/declarativeimports/core/private/DefaultToolTip.qml
M src/declarativeimports/core/tooltip.cpp
M src/declarativeimports/core/tooltip.h
M src/scriptengines/qml/plasmoid/appletinterface.cpp
M src/scriptengines/qml/plasmoid/appletinterface.h
5 files changed, 62 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.vesnicky.cesnet.cz:29418/plasma-framework refs/changes/45/345/1

diff --git a/src/declarativeimports/core/private/DefaultToolTip.qml b/src/declarativeimports/core/private/DefaultToolTip.qml
index 1e299c3..6010571 100644
--- a/src/declarativeimports/core/private/DefaultToolTip.qml
+++ b/src/declarativeimports/core/private/DefaultToolTip.qml
@@ -83,6 +83,7 @@
             width: Math.min(tooltipSubtext.implicitWidth, preferredTextWidth)
             wrapMode: Text.WordWrap
             text: toolTip ? toolTip.subText : ""
+            textFormat: toolTip.textFormat
             opacity: 0.5
         }
     }
diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp
index eb58bca..987dc96 100644
--- a/src/declarativeimports/core/tooltip.cpp
+++ b/src/declarativeimports/core/tooltip.cpp
@@ -35,9 +35,10 @@
 
 ToolTip::ToolTip(QQuickItem *parent)
     : QQuickItem(parent),
+      m_textFormat(0),
       m_tooltipsEnabledGlobally(false),
-      m_containsMouse(false),
       m_location(Plasma::Types::Floating),
+      m_containsMouse(false),
       m_active(true),
       m_interactive(false),
       m_usingDialog(false)
@@ -182,6 +183,21 @@
     emit subTextChanged();
 }
 
+int ToolTip::textFormat() const
+{
+    return m_textFormat;
+}
+
+void ToolTip::setTextFormat(int format)
+{
+    if (m_textFormat == format) {
+        return;
+    }
+
+    m_textFormat = format;
+    emit textFormatChanged();
+}
+
 Plasma::Types::Location ToolTip::location() const
 {
     return m_location;
diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h
index 2fc7942..4ab11e7 100644
--- a/src/declarativeimports/core/tooltip.h
+++ b/src/declarativeimports/core/tooltip.h
@@ -83,6 +83,15 @@
     Q_PROPERTY(QString subText READ subText WRITE setSubText NOTIFY subTextChanged)
 
     /**
+     * how to handle the text format of the tooltip:
+     * * Text.AutoText (default)
+     * * Text.PlainText
+     * * Text.StyledText
+     * * Text.RichText
+     */
+    Q_PROPERTY(int textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
+
+    /**
      * An icon for this tooltip, accepted values are an icon name, a QIcon, QImage or QPixmap
      */
     Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged)
@@ -131,6 +140,9 @@
     QString subText() const;
     void setSubText(const QString &subText);
 
+    int textFormat() const;
+    void setTextFormat(int format);
+
     QVariant icon() const;
     void setIcon(const QVariant &icon);
 
@@ -168,6 +180,7 @@
     void visibleChanged();
     void mainTextChanged();
     void subTextChanged();
+    void textFormatChanged();
     void iconChanged();
     void imageChanged();
     void containsMouseChanged();
@@ -187,6 +200,7 @@
     QTimer *m_showTimer;
     QString m_mainText;
     QString m_subText;
+    int m_textFormat;
     QVariant m_image;
     QVariant m_icon;
     bool m_active;
diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp
index 7e0dd9f..0ec2c34 100644
--- a/src/scriptengines/qml/plasmoid/appletinterface.cpp
+++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp
@@ -55,6 +55,7 @@
 
 AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariantList &args, QQuickItem *parent)
     : AppletQuickItem(script->applet(), parent),
+      m_toolTipTextFormat(0),
       m_args(args),
       m_actionSignals(0),
       m_appletScriptEngine(script),
@@ -333,6 +334,21 @@
     emit toolTipSubTextChanged();
 }
 
+int AppletInterface::toolTipTextFormat() const
+{
+    return m_toolTipTextFormat;
+}
+
+void AppletInterface::setToolTipTextFormat(int format)
+{
+    if (m_toolTipTextFormat == format) {
+        return;
+    }
+
+    m_toolTipTextFormat = format;
+    emit toolTipTextFormatChanged();
+}
+
 bool AppletInterface::isBusy() const
 {
     return m_busy;
diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h
index be19a6c..824b3e2 100644
--- a/src/scriptengines/qml/plasmoid/appletinterface.h
+++ b/src/scriptengines/qml/plasmoid/appletinterface.h
@@ -91,6 +91,15 @@
     Q_PROPERTY(QString toolTipSubText READ toolTipSubText WRITE setToolTipSubText NOTIFY toolTipSubTextChanged)
 
     /**
+     * how to handle the text format of the tooltip:
+     * * Text.AutoText (default)
+     * * Text.PlainText
+     * * Text.StyledText
+     * * Text.RichText
+     */
+    Q_PROPERTY(int toolTipTextFormat READ toolTipTextFormat WRITE setToolTipTextFormat NOTIFY toolTipTextFormatChanged)
+
+    /**
      * Icon to represent the plasmoid
      */
     Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
@@ -267,6 +276,9 @@
     QString toolTipSubText() const;
     void setToolTipSubText(const QString &text);
 
+    int toolTipTextFormat() const;
+    void setToolTipTextFormat(int format);
+
     uint id() const;
 
     Plasma::Types::FormFactor formFactor() const;
@@ -332,6 +344,7 @@
     void titleChanged();
     void toolTipMainTextChanged();
     void toolTipSubTextChanged();
+    void toolTipTextFormatChanged();
     void formFactorChanged();
     void locationChanged();
     void contextChanged();
@@ -369,6 +382,7 @@
 
     QString m_toolTipMainText;
     QString m_toolTipSubText;
+    int m_toolTipTextFormat;
     QVariantList m_args;
     Plasma::Types::BackgroundHints m_backgroundHints;
     bool m_busy : 1;

-- 
To view, visit https://gerrit.vesnicky.cesnet.cz/r/345
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4e8e913e060b868188b4f0b46db2162f33d8bb1
Gerrit-PatchSet: 1
Gerrit-Project: plasma-framework
Gerrit-Branch: master
Gerrit-Owner: Marco Martin <notmart at gmail.com>


More information about the Plasma-devel mailing list