qstylehints.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qstylehints.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include <qstylehints.h>-
35#include <qpa/qplatformintegration.h>-
36#include <qpa/qplatformtheme.h>-
37#include <private/qguiapplication_p.h>-
38#include <qdebug.h>-
39-
40QT_BEGIN_NAMESPACE-
41-
42static inline QVariant hint(QPlatformIntegration::StyleHint h)-
43{-
44 return QGuiApplicationPrivate::platformIntegration()->styleHint(h);
never executed: return QGuiApplicationPrivate::platformIntegration()->styleHint(h);
0
45}-
46-
47static inline QVariant themeableHint(QPlatformTheme::ThemeHint th,-
48 QPlatformIntegration::StyleHint ih)-
49{-
50 if (!QCoreApplication::instance()) {
!QCoreApplication::instance()Description
TRUEnever evaluated
FALSEnever evaluated
0
51 qWarning() << "Must construct a QGuiApplication before accessing a platform theme hint.";-
52 return QVariant();
never executed: return QVariant();
0
53 }-
54 if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const QPlatfor...latformTheme()Description
TRUEnever evaluated
FALSEnever evaluated
0
55 const QVariant themeHint = theme->themeHint(th);-
56 if (themeHint.isValid())
themeHint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
57 return themeHint;
never executed: return themeHint;
0
58 }
never executed: end of block
0
59 return QGuiApplicationPrivate::platformIntegration()->styleHint(ih);
never executed: return QGuiApplicationPrivate::platformIntegration()->styleHint(ih);
0
60}-
61-
62class QStyleHintsPrivate : public QObjectPrivate-
63{-
64 Q_DECLARE_PUBLIC(QStyleHints)-
65public:-
66 inline QStyleHintsPrivate()-
67 : m_mouseDoubleClickInterval(-1)-
68 , m_startDragDistance(-1)-
69 , m_startDragTime(-1)-
70 , m_keyboardInputInterval(-1)-
71 , m_cursorFlashTime(-1)-
72 {}
never executed: end of block
0
73-
74 int m_mouseDoubleClickInterval;-
75 int m_startDragDistance;-
76 int m_startDragTime;-
77 int m_keyboardInputInterval;-
78 int m_cursorFlashTime;-
79};-
80-
81/*!-
82 \class QStyleHints-
83 \since 5.0-
84 \brief The QStyleHints class contains platform specific hints and settings.-
85 \inmodule QtGui-
86-
87 An object of this class, obtained from QGuiApplication, provides access to certain global-
88 user interface parameters of the current platform.-
89-
90 Access is read only; typically the platform itself provides the user a way to tune these-
91 parameters.-
92-
93 Access to these parameters are useful when implementing custom user interface components, in that-
94 they allow the components to exhibit the same behaviour and feel as other components.-
95-
96 \sa QGuiApplication::styleHints()-
97 */-
98QStyleHints::QStyleHints()-
99 : QObject(*new QStyleHintsPrivate(), 0)-
100{-
101}
never executed: end of block
0
102-
103/*!-
104 Sets the \a mouseDoubleClickInterval.-
105 \internal-
106 \sa mouseDoubleClickInterval()-
107 \since 5.3-
108*/-
109void QStyleHints::setMouseDoubleClickInterval(int mouseDoubleClickInterval)-
110{-
111 Q_D(QStyleHints);-
112 if (d->m_mouseDoubleClickInterval == mouseDoubleClickInterval)
d->m_mouseDoub...eClickIntervalDescription
TRUEnever evaluated
FALSEnever evaluated
0
113 return;
never executed: return;
0
114 d->m_mouseDoubleClickInterval = mouseDoubleClickInterval;-
115 emit mouseDoubleClickIntervalChanged(mouseDoubleClickInterval);-
116}
never executed: end of block
0
117-
118/*!-
119 \property QStyleHints::mouseDoubleClickInterval-
120 \brief the time limit in milliseconds that distinguishes a double click-
121 from two consecutive mouse clicks.-
122*/-
123int QStyleHints::mouseDoubleClickInterval() const-
124{-
125 Q_D(const QStyleHints);-
126 return d->m_mouseDoubleClickInterval >= 0 ?
never executed: return d->m_mouseDoubleClickInterval >= 0 ? d->m_mouseDoubleClickInterval : themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
d->m_mouseDoub...kInterval >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
127 d->m_mouseDoubleClickInterval :
never executed: return d->m_mouseDoubleClickInterval >= 0 ? d->m_mouseDoubleClickInterval : themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
0
128 themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
never executed: return d->m_mouseDoubleClickInterval >= 0 ? d->m_mouseDoubleClickInterval : themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
0
129}-
130-
131/*!-
132 \property QStyleHints::mousePressAndHoldInterval-
133 \brief the time limit in milliseconds that activates-
134 a press and hold.-
135-
136 \since 5.3-
137*/-
138int QStyleHints::mousePressAndHoldInterval() const-
139{-
140 return themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
never executed: return themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
0
141}-
142-
143/*!-
144 Sets the \a startDragDistance.-
145 \internal-
146 \sa startDragDistance()-
147 \since 5.3-
148*/-
149void QStyleHints::setStartDragDistance(int startDragDistance)-
150{-
151 Q_D(QStyleHints);-
152 if (d->m_startDragDistance == startDragDistance)
d->m_startDrag...rtDragDistanceDescription
TRUEnever evaluated
FALSEnever evaluated
0
153 return;
never executed: return;
0
154 d->m_startDragDistance = startDragDistance;-
155 emit startDragDistanceChanged(startDragDistance);-
156}
never executed: end of block
0
157-
158/*!-
159 \property QStyleHints::startDragDistance-
160 \brief the distance, in pixels, that the mouse must be moved with a button-
161 held down before a drag and drop operation will begin.-
162-
163 If you support drag and drop in your application, and want to start a drag-
164 and drop operation after the user has moved the cursor a certain distance-
165 with a button held down, you should use this property's value as the-
166 minimum distance required.-
167-
168 For example, if the mouse position of the click is stored in \c startPos-
169 and the current position (e.g. in the mouse move event) is \c currentPos,-
170 you can find out if a drag should be started with code like this:-
171-
172 \snippet code/src_gui_kernel_qapplication.cpp 6-
173-
174 \sa startDragTime, QPoint::manhattanLength(), {Drag and Drop}-
175*/-
176int QStyleHints::startDragDistance() const-
177{-
178 Q_D(const QStyleHints);-
179 return d->m_startDragDistance >= 0 ?
never executed: return d->m_startDragDistance >= 0 ? d->m_startDragDistance : themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
d->m_startDragDistance >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
180 d->m_startDragDistance :
never executed: return d->m_startDragDistance >= 0 ? d->m_startDragDistance : themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
0
181 themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
never executed: return d->m_startDragDistance >= 0 ? d->m_startDragDistance : themeableHint(QPlatformTheme::StartDragDistance, QPlatformIntegration::StartDragDistance).toInt();
0
182}-
183-
184/*!-
185 Sets the \a startDragDragTime.-
186 \internal-
187 \sa startDragTime()-
188 \since 5.3-
189*/-
190void QStyleHints::setStartDragTime(int startDragTime)-
191{-
192 Q_D(QStyleHints);-
193 if (d->m_startDragTime == startDragTime)
d->m_startDrag... startDragTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
194 return;
never executed: return;
0
195 d->m_startDragTime = startDragTime;-
196 emit startDragTimeChanged(startDragTime);-
197}
never executed: end of block
0
198-
199/*!-
200 \property QStyleHints::startDragTime-
201 \brief the time, in milliseconds, that a mouse button must be held down-
202 before a drag and drop operation will begin.-
203-
204 If you support drag and drop in your application, and want to start a drag-
205 and drop operation after the user has held down a mouse button for a-
206 certain amount of time, you should use this property's value as the delay.-
207-
208 \sa startDragDistance, {Drag and Drop}-
209*/-
210int QStyleHints::startDragTime() const-
211{-
212 Q_D(const QStyleHints);-
213 return d->m_startDragTime >= 0 ?
never executed: return d->m_startDragTime >= 0 ? d->m_startDragTime : themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
d->m_startDragTime >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
214 d->m_startDragTime :
never executed: return d->m_startDragTime >= 0 ? d->m_startDragTime : themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
0
215 themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
never executed: return d->m_startDragTime >= 0 ? d->m_startDragTime : themeableHint(QPlatformTheme::StartDragTime, QPlatformIntegration::StartDragTime).toInt();
0
216}-
217-
218/*!-
219 \property QStyleHints::startDragVelocity-
220 \brief the limit for the velocity, in pixels per second, that the mouse may-
221 be moved, with a button held down, for a drag and drop operation to begin.-
222 A value of 0 means there is no such limit.-
223-
224 \sa startDragDistance, {Drag and Drop}-
225*/-
226int QStyleHints::startDragVelocity() const-
227{-
228 return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
never executed: return themeableHint(QPlatformTheme::StartDragVelocity, QPlatformIntegration::StartDragVelocity).toInt();
0
229}-
230-
231/*!-
232 Sets the \a keyboardInputInterval.-
233 \internal-
234 \sa keyboardInputInterval()-
235 \since 5.3-
236*/-
237void QStyleHints::setKeyboardInputInterval(int keyboardInputInterval)-
238{-
239 Q_D(QStyleHints);-
240 if (d->m_keyboardInputInterval == keyboardInputInterval)
d->m_keyboardI...dInputIntervalDescription
TRUEnever evaluated
FALSEnever evaluated
0
241 return;
never executed: return;
0
242 d->m_keyboardInputInterval = keyboardInputInterval;-
243 emit keyboardInputIntervalChanged(keyboardInputInterval);-
244}
never executed: end of block
0
245-
246/*!-
247 \property QStyleHints::keyboardInputInterval-
248 \brief the time limit, in milliseconds, that distinguishes a key press-
249 from two consecutive key presses.-
250*/-
251int QStyleHints::keyboardInputInterval() const-
252{-
253 Q_D(const QStyleHints);-
254 return d->m_keyboardInputInterval >= 0 ?
never executed: return d->m_keyboardInputInterval >= 0 ? d->m_keyboardInputInterval : themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
d->m_keyboardI...tInterval >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
255 d->m_keyboardInputInterval :
never executed: return d->m_keyboardInputInterval >= 0 ? d->m_keyboardInputInterval : themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
0
256 themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
never executed: return d->m_keyboardInputInterval >= 0 ? d->m_keyboardInputInterval : themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
0
257}-
258-
259/*!-
260 \property QStyleHints::keyboardAutoRepeatRate-
261 \brief the rate, in events per second, in which additional repeated key-
262 presses will automatically be generated if a key is being held down.-
263*/-
264int QStyleHints::keyboardAutoRepeatRate() const-
265{-
266 return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
never executed: return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
0
267}-
268-
269/*!-
270 Sets the \a cursorFlashTime.-
271 \internal-
272 \sa cursorFlashTime()-
273 \since 5.3-
274*/-
275void QStyleHints::setCursorFlashTime(int cursorFlashTime)-
276{-
277 Q_D(QStyleHints);-
278 if (d->m_cursorFlashTime == cursorFlashTime)
d->m_cursorFla...ursorFlashTimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
279 return;
never executed: return;
0
280 d->m_cursorFlashTime = cursorFlashTime;-
281 emit cursorFlashTimeChanged(cursorFlashTime);-
282}
never executed: end of block
0
283-
284/*!-
285 \property QStyleHints::cursorFlashTime-
286 \brief the text cursor's flash (blink) time in milliseconds.-
287-
288 The flash time is the time used to display, invert and restore the-
289 caret display. Usually the text cursor is displayed for half the cursor-
290 flash time, then hidden for the same amount of time.-
291*/-
292int QStyleHints::cursorFlashTime() const-
293{-
294 Q_D(const QStyleHints);-
295 return d->m_cursorFlashTime >= 0 ?
never executed: return d->m_cursorFlashTime >= 0 ? d->m_cursorFlashTime : themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
d->m_cursorFlashTime >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
296 d->m_cursorFlashTime :
never executed: return d->m_cursorFlashTime >= 0 ? d->m_cursorFlashTime : themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
0
297 themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
never executed: return d->m_cursorFlashTime >= 0 ? d->m_cursorFlashTime : themeableHint(QPlatformTheme::CursorFlashTime, QPlatformIntegration::CursorFlashTime).toInt();
0
298}-
299-
300/*!-
301 \property QStyleHints::showIsFullScreen-
302 \brief \c true if the platform defaults to windows being fullscreen,-
303 otherwise \c false.-
304-
305 \note The platform may still choose to show certain windows non-fullscreen,-
306 such as popups or dialogs. This property only reports the default behavior.-
307-
308 \sa QWindow::show(), showIsMaximized()-
309*/-
310bool QStyleHints::showIsFullScreen() const-
311{-
312 return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
never executed: return hint(QPlatformIntegration::ShowIsFullScreen).toBool();
0
313}-
314-
315/*!-
316 \property QStyleHints::showIsMaximized-
317 \brief \c true if the platform defaults to windows being maximized,-
318 otherwise \c false.-
319-
320 \note The platform may still choose to show certain windows non-maximized,-
321 such as popups or dialogs. This property only reports the default behavior.-
322-
323 \sa QWindow::show(), showIsFullScreen()-
324 \since 5.6-
325*/-
326bool QStyleHints::showIsMaximized() const-
327{-
328 return hint(QPlatformIntegration::ShowIsMaximized).toBool();
never executed: return hint(QPlatformIntegration::ShowIsMaximized).toBool();
0
329}-
330-
331/*!-
332 \property QStyleHints::passwordMaskDelay-
333 \brief the time, in milliseconds, a typed letter is displayed unshrouded-
334 in a text input field in password mode.-
335*/-
336int QStyleHints::passwordMaskDelay() const-
337{-
338 return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
never executed: return themeableHint(QPlatformTheme::PasswordMaskDelay, QPlatformIntegration::PasswordMaskDelay).toInt();
0
339}-
340-
341/*!-
342 \property QStyleHints::passwordMaskCharacter-
343 \brief the character used to mask the characters typed into text input-
344 fields in password mode.-
345*/-
346QChar QStyleHints::passwordMaskCharacter() const-
347{-
348 return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
never executed: return themeableHint(QPlatformTheme::PasswordMaskCharacter, QPlatformIntegration::PasswordMaskCharacter).toChar();
0
349}-
350-
351/*!-
352 \property QStyleHints::fontSmoothingGamma-
353 \brief the gamma value used in font smoothing.-
354*/-
355qreal QStyleHints::fontSmoothingGamma() const-
356{-
357 return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
never executed: return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
0
358}-
359-
360/*!-
361 \property QStyleHints::useRtlExtensions-
362 \brief \c true if right-to-left writing direction is enabled,-
363 otherwise \c false.-
364*/-
365bool QStyleHints::useRtlExtensions() const-
366{-
367 return hint(QPlatformIntegration::UseRtlExtensions).toBool();
never executed: return hint(QPlatformIntegration::UseRtlExtensions).toBool();
0
368}-
369-
370/*!-
371 \property QStyleHints::setFocusOnTouchRelease-
372 \brief \c true if focus objects (line edits etc) should receive-
373 input focus after a touch/mouse release. This is normal behavior on-
374 touch platforms. On desktop platforms, the standard is to set-
375 focus already on touch/mouse press.-
376*/-
377bool QStyleHints::setFocusOnTouchRelease() const-
378{-
379 return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool();
never executed: return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool();
0
380}-
381-
382/*!-
383 \property QStyleHints::tabFocusBehavior-
384 \since 5.5-
385 \brief The focus behavior on press of the tab key.-
386-
387 \note Do not bind this value in QML because the change notifier-
388 signal is not implemented yet.-
389*/-
390-
391Qt::TabFocusBehavior QStyleHints::tabFocusBehavior() const-
392{-
393 return Qt::TabFocusBehavior(themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
never executed: return Qt::TabFocusBehavior(themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
0
394}-
395-
396/*!-
397 \property QStyleHints::singleClickActivation-
398 \brief \c true if items should be activated by single click, \b false-
399 if they should be activated by double click instead.-
400-
401 \since 5.5-
402*/-
403bool QStyleHints::singleClickActivation() const-
404{-
405 return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
never executed: return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
0
406}-
407-
408QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9