Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/core/tooltip.h
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 67 | { | |||
---|---|---|---|---|---|
98 | Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged) | 98 | Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged) | ||
99 | 99 | | |||
100 | /** | 100 | /** | ||
101 | * Returns whether the mouse is inside the item | 101 | * Returns whether the mouse is inside the item | ||
102 | */ | 102 | */ | ||
103 | Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) | 103 | Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) | ||
104 | 104 | | |||
105 | /** | 105 | /** | ||
106 | * Returns whether the mouse is inside the tool tip window | ||||
107 | */ | ||||
108 | Q_PROPERTY(bool toolTipWindowContainsMouse READ toolTipWindowContainsMouse NOTIFY toolTipWindowContainsMouseChanged) | ||||
109 | | ||||
110 | /** | ||||
106 | * Plasma Location of the dialog window. Useful if this dialog is a popup for a panel | 111 | * Plasma Location of the dialog window. Useful if this dialog is a popup for a panel | ||
107 | */ | 112 | */ | ||
108 | Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) | 113 | Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) | ||
109 | 114 | | |||
110 | /** | 115 | /** | ||
111 | * TODO: single property for images? | 116 | * TODO: single property for images? | ||
112 | * An image for this tooltip, accepted values are an icon name, a QIcon, QImage or QPixmap | 117 | * An image for this tooltip, accepted values are an icon name, a QIcon, QImage or QPixmap | ||
113 | */ | 118 | */ | ||
114 | Q_PROPERTY(QVariant image READ image WRITE setImage NOTIFY imageChanged) | 119 | Q_PROPERTY(QVariant image READ image WRITE setImage NOTIFY imageChanged) | ||
115 | 120 | | |||
116 | /** | 121 | /** | ||
117 | * Property that controls if a tooltips will show on mouse over. | 122 | * Property that controls if a tooltips will show on mouse over. | ||
118 | * The default is true. | 123 | * The default is true. | ||
119 | */ | 124 | */ | ||
120 | Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged) | 125 | Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged) | ||
121 | 126 | | |||
122 | /** | 127 | /** | ||
128 | * Property that controls if a tooltips will show automatically or if they are shown/hidden manually. | ||||
129 | * The default is true. | ||||
130 | */ | ||||
131 | Q_PROPERTY(bool autoShowHide MEMBER m_autoShowHide WRITE setAutoShowHide NOTIFY autoShowHideChanged) | ||||
132 | | ||||
133 | /** | ||||
123 | * if interactive is false (default), the tooltip will automatically hide | 134 | * if interactive is false (default), the tooltip will automatically hide | ||
124 | * itself as soon as the mouse leaves the tooltiparea, if is true, if the mouse leaves tooltiparea and goes over the tooltip itself, the tooltip won't hide, so it will be possible to interact with tooltip contents | 135 | * itself as soon as the mouse leaves the tooltiparea, if is true, if the mouse leaves tooltiparea and goes over the tooltip itself, the tooltip won't hide, so it will be possible to interact with tooltip contents | ||
125 | */ | 136 | */ | ||
126 | Q_PROPERTY(bool interactive MEMBER m_interactive WRITE setInteractive NOTIFY interactiveChanged) | 137 | Q_PROPERTY(bool interactive MEMBER m_interactive WRITE setInteractive NOTIFY interactiveChanged) | ||
127 | 138 | | |||
128 | public: | 139 | public: | ||
129 | /// @cond INTERNAL_DOCS | 140 | /// @cond INTERNAL_DOCS | ||
130 | ToolTip(QQuickItem *parent = nullptr); | 141 | ToolTip(QQuickItem *parent = nullptr); | ||
131 | ~ToolTip(); | 142 | ~ToolTip(); | ||
132 | 143 | | |||
133 | QQuickItem *mainItem() const; | 144 | QQuickItem *mainItem() const; | ||
134 | void setMainItem(QQuickItem *mainItem); | 145 | void setMainItem(QQuickItem *mainItem); | ||
135 | 146 | | |||
136 | void showToolTip(); | 147 | Q_INVOKABLE void showToolTip(); | ||
137 | 148 | | |||
138 | QString mainText() const; | 149 | QString mainText() const; | ||
139 | void setMainText(const QString &mainText); | 150 | void setMainText(const QString &mainText); | ||
140 | 151 | | |||
141 | QString subText() const; | 152 | QString subText() const; | ||
142 | void setSubText(const QString &subText); | 153 | void setSubText(const QString &subText); | ||
143 | 154 | | |||
144 | int textFormat() const; | 155 | int textFormat() const; | ||
145 | void setTextFormat(int format); | 156 | void setTextFormat(int format); | ||
146 | 157 | | |||
147 | QVariant icon() const; | 158 | QVariant icon() const; | ||
148 | void setIcon(const QVariant &icon); | 159 | void setIcon(const QVariant &icon); | ||
149 | 160 | | |||
150 | QVariant image() const; | 161 | QVariant image() const; | ||
151 | void setImage(const QVariant &image); | 162 | void setImage(const QVariant &image); | ||
152 | 163 | | |||
153 | Plasma::Types::Location location() const; | 164 | Plasma::Types::Location location() const; | ||
154 | void setLocation(Plasma::Types::Location location); | 165 | void setLocation(Plasma::Types::Location location); | ||
155 | 166 | | |||
156 | bool containsMouse() const; | 167 | bool containsMouse() const; | ||
157 | void setContainsMouse(bool contains); | 168 | void setContainsMouse(bool contains); | ||
158 | 169 | | |||
170 | bool toolTipWindowContainsMouse() const; | ||||
171 | | ||||
159 | void setActive(bool active); | 172 | void setActive(bool active); | ||
160 | 173 | | |||
174 | void setAutoShowHide(bool autoShowHide); | ||||
175 | | ||||
161 | void setInteractive(bool interactive); | 176 | void setInteractive(bool interactive); | ||
162 | /// @endcond | 177 | /// @endcond | ||
163 | 178 | | |||
164 | public Q_SLOTS: | 179 | public Q_SLOTS: | ||
165 | /** | 180 | /** | ||
166 | * Hides the tooltip if shown. Does not affect whether the tooltip area is active. | 181 | * Hides the tooltip if shown. Does not affect whether the tooltip area is active. | ||
167 | */ | 182 | */ | ||
168 | void hideToolTip(); | 183 | void hideToolTip(); | ||
Show All 10 Lines | |||||
179 | Q_SIGNALS: | 194 | Q_SIGNALS: | ||
180 | void mainItemChanged(); | 195 | void mainItemChanged(); | ||
181 | void mainTextChanged(); | 196 | void mainTextChanged(); | ||
182 | void subTextChanged(); | 197 | void subTextChanged(); | ||
183 | void textFormatChanged(); | 198 | void textFormatChanged(); | ||
184 | void iconChanged(); | 199 | void iconChanged(); | ||
185 | void imageChanged(); | 200 | void imageChanged(); | ||
186 | void containsMouseChanged(); | 201 | void containsMouseChanged(); | ||
202 | void toolTipWindowContainsMouseChanged(); | ||||
187 | void locationChanged(); | 203 | void locationChanged(); | ||
188 | void activeChanged(); | 204 | void activeChanged(); | ||
205 | void autoShowHideChanged(); | ||||
189 | void interactiveChanged(); | 206 | void interactiveChanged(); | ||
190 | 207 | | |||
191 | private Q_SLOTS: | 208 | private Q_SLOTS: | ||
192 | void settingsChanged(); | 209 | void settingsChanged(); | ||
210 | void toolTipWindowContainsMouseChangedSlot(); | ||||
193 | 211 | | |||
194 | private: | 212 | private: | ||
195 | bool isValid() const; | 213 | bool isValid() const; | ||
196 | 214 | | |||
197 | void loadSettings(); | 215 | void loadSettings(); | ||
198 | bool m_tooltipsEnabledGlobally; | 216 | bool m_tooltipsEnabledGlobally; | ||
199 | bool m_containsMouse; | 217 | bool m_containsMouse; | ||
218 | bool m_toolTipWindowContainsMouse; | ||||
200 | Plasma::Types::Location m_location; | 219 | Plasma::Types::Location m_location; | ||
201 | QWeakPointer<QQuickItem> m_mainItem; | 220 | QWeakPointer<QQuickItem> m_mainItem; | ||
202 | QTimer *m_showTimer; | 221 | QTimer *m_showTimer; | ||
203 | QString m_mainText; | 222 | QString m_mainText; | ||
204 | QString m_subText; | 223 | QString m_subText; | ||
205 | int m_textFormat; | 224 | int m_textFormat; | ||
206 | QVariant m_image; | 225 | QVariant m_image; | ||
207 | QVariant m_icon; | 226 | QVariant m_icon; | ||
208 | bool m_active; | 227 | bool m_active; | ||
228 | bool m_autoShowHide; | ||||
209 | bool m_interactive; | 229 | bool m_interactive; | ||
210 | int m_interval; | 230 | int m_interval; | ||
211 | 231 | | |||
212 | //ToolTipDialog is not a Q_GLOBAL_STATIC because QQuickwindows as global static | 232 | //ToolTipDialog is not a Q_GLOBAL_STATIC because QQuickwindows as global static | ||
213 | //are deleted too later after some stuff in the qml runtime has already been deleted, | 233 | //are deleted too later after some stuff in the qml runtime has already been deleted, | ||
214 | //causing a crash on exit | 234 | //causing a crash on exit | ||
215 | bool m_usingDialog : 1; | 235 | bool m_usingDialog : 1; | ||
216 | static ToolTipDialog *s_dialog; | 236 | static ToolTipDialog *s_dialog; | ||
217 | static int s_dialogUsers; | 237 | static int s_dialogUsers; | ||
218 | }; | 238 | }; | ||
219 | 239 | | |||
220 | #endif | 240 | #endif |