Make wheelScrollLines a QStyleHint
The number of lines to scroll on a wheel click have previously been a QPlatformTheme hint and QApplication setting, this patch moves it to QStyleHint so it may be easier read by QGuiApplications. Change-Id: I80673c7b99d78c6407b1202b3742e1cb5fef0583 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>bb10
parent
69e233d2ba
commit
4d3a35f637
|
|
@ -409,6 +409,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
|
|||
return QPlatformTheme::defaultThemeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick);
|
||||
case UiEffects:
|
||||
return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects);
|
||||
case WheelScrollLines:
|
||||
return QPlatformTheme::defaultThemeHint(QPlatformTheme::WheelScrollLines);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -157,7 +157,8 @@ public:
|
|||
TabFocusBehavior,
|
||||
ReplayMousePressOutsidePopup,
|
||||
ItemViewActivateItemOnSingleClick,
|
||||
UiEffects
|
||||
UiEffects,
|
||||
WheelScrollLines,
|
||||
};
|
||||
|
||||
virtual QVariant styleHint(StyleHint hint) const;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public:
|
|||
, m_cursorFlashTime(-1)
|
||||
, m_tabFocusBehavior(-1)
|
||||
, m_uiEffects(-1)
|
||||
, m_wheelScrollLines(-1)
|
||||
{}
|
||||
|
||||
int m_mouseDoubleClickInterval;
|
||||
|
|
@ -88,6 +89,7 @@ public:
|
|||
int m_cursorFlashTime;
|
||||
int m_tabFocusBehavior;
|
||||
int m_uiEffects;
|
||||
int m_wheelScrollLines;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
@ -495,4 +497,33 @@ void QStyleHints::setUseHoverEffects(bool useHoverEffects)
|
|||
emit useHoverEffectsChanged(useHoverEffects);
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QStyleHints::wheelScrollLines
|
||||
\brief Number of lines to scroll by default for each wheel click.
|
||||
|
||||
\since 5.9
|
||||
*/
|
||||
int QStyleHints::wheelScrollLines() const
|
||||
{
|
||||
Q_D(const QStyleHints);
|
||||
if (d->m_wheelScrollLines > 0)
|
||||
return d->m_wheelScrollLines;
|
||||
return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a wheelScrollLines.
|
||||
\internal
|
||||
\sa wheelScrollLines()
|
||||
\since 5.9
|
||||
*/
|
||||
void QStyleHints::setWheelScrollLines(int scrollLines)
|
||||
{
|
||||
Q_D(QStyleHints);
|
||||
if (d->m_wheelScrollLines == scrollLines)
|
||||
return;
|
||||
d->m_wheelScrollLines = scrollLines;
|
||||
emit wheelScrollLinesChanged(scrollLines);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
|
|||
Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL)
|
||||
Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL)
|
||||
Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL)
|
||||
Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL)
|
||||
|
||||
public:
|
||||
void setMouseDoubleClickInterval(int mouseDoubleClickInterval);
|
||||
|
|
@ -99,6 +100,8 @@ public:
|
|||
bool singleClickActivation() const;
|
||||
bool useHoverEffects() const;
|
||||
void setUseHoverEffects(bool useHoverEffects);
|
||||
int wheelScrollLines() const;
|
||||
void setWheelScrollLines(int scrollLines);
|
||||
|
||||
Q_SIGNALS:
|
||||
void cursorFlashTimeChanged(int cursorFlashTime);
|
||||
|
|
@ -109,6 +112,7 @@ Q_SIGNALS:
|
|||
void startDragTimeChanged(int startDragTime);
|
||||
void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior);
|
||||
void useHoverEffectsChanged(bool useHoverEffects);
|
||||
void wheelScrollLinesChanged(int scrollLines);
|
||||
|
||||
private:
|
||||
friend class QGuiApplication;
|
||||
|
|
|
|||
|
|
@ -408,7 +408,6 @@ QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input foc
|
|||
QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show()
|
||||
QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
|
||||
QPointer<QWidget> QApplicationPrivate::wheel_widget;
|
||||
#endif
|
||||
bool qt_in_tab_key_event = false;
|
||||
|
|
@ -642,19 +641,12 @@ void QApplicationPrivate::initialize()
|
|||
if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0)
|
||||
QCoreApplication::setAttribute(Qt::AA_NativeWindows);
|
||||
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
QApplicationPrivate::wheel_scroll_lines = 3;
|
||||
#endif
|
||||
|
||||
if (qt_is_gui_used)
|
||||
initializeMultitouch();
|
||||
|
||||
if (QApplication::desktopSettingsAware())
|
||||
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
|
||||
QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt();
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
QApplicationPrivate::wheel_scroll_lines = theme->themeHint(QPlatformTheme::WheelScrollLines).toInt();
|
||||
#endif
|
||||
}
|
||||
|
||||
is_app_running = true; // no longer starting up
|
||||
|
|
@ -4049,16 +4041,18 @@ int QApplication::keyboardInputInterval()
|
|||
or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}.
|
||||
|
||||
By default, this property has a value of 3.
|
||||
|
||||
\sa QStyleHints::wheelScrollLines()
|
||||
*/
|
||||
#ifndef QT_NO_WHEELEVENT
|
||||
int QApplication::wheelScrollLines()
|
||||
{
|
||||
return QApplicationPrivate::wheel_scroll_lines;
|
||||
return styleHints()->wheelScrollLines();
|
||||
}
|
||||
|
||||
void QApplication::setWheelScrollLines(int lines)
|
||||
{
|
||||
QApplicationPrivate::wheel_scroll_lines = lines;
|
||||
styleHints()->setWheelScrollLines(lines);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue