QPA: Add a themeHint for the animations.
Introduce a flag matching the Qt::UI_Effect enumeration and return it as hint. Replace the separate boolean flags in QApplication by a single integer using the flags. Change-Id: I29e33d4d23d13723ddb1b3f62fe781b9c0747572 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
parent
55070e8637
commit
e996009eb7
@ -86,7 +86,8 @@ public:
|
||||
DialogButtonBoxLayout,
|
||||
DialogButtonBoxButtonsHaveIcons,
|
||||
UseFullScreenForPopupMenu,
|
||||
KeyboardScheme
|
||||
KeyboardScheme,
|
||||
UiEffects
|
||||
};
|
||||
|
||||
enum DialogType {
|
||||
@ -149,6 +150,17 @@ public:
|
||||
CdeKeyboardScheme
|
||||
};
|
||||
|
||||
enum UiEffect
|
||||
{
|
||||
GeneralUiEffect = 0x1,
|
||||
AnimateMenuUiEffect = 0x2,
|
||||
FadeMenuUiEffect = 0x4,
|
||||
AnimateComboUiEffect = 0x8,
|
||||
AnimateTooltipUiEffect = 0x10,
|
||||
FadeTooltipUiEffect = 0x20,
|
||||
AnimateToolBoxUiEffect = 0x40
|
||||
};
|
||||
|
||||
virtual ~QPlatformTheme();
|
||||
|
||||
virtual QPlatformMenu *createPlatformMenu(QMenu *menu = 0) const;
|
||||
|
@ -99,6 +99,8 @@ QT_BEGIN_NAMESPACE
|
||||
\value KeyboardScheme (int) An integer value (enum KeyboardSchemes) specifying the
|
||||
keyboard scheme.
|
||||
|
||||
\value UiEffects (int) A flag value consisting of UiEffect values specifying the enabled UI animations.
|
||||
|
||||
\sa themeHint(), QStyle::pixelMetric()
|
||||
*/
|
||||
|
||||
@ -175,6 +177,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
|
||||
return QVariant(-1);
|
||||
case KeyboardScheme:
|
||||
return QVariant(int(WindowsKeyboardScheme));
|
||||
case UiEffects:
|
||||
return QVariant(int(0));
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -296,6 +296,22 @@ static inline QStringList styleNames()
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline int uiEffects()
|
||||
{
|
||||
int result = 0;
|
||||
if (booleanSystemParametersInfo(SPI_GETUIEFFECTS, false))
|
||||
result |= QPlatformTheme::GeneralUiEffect;
|
||||
if (booleanSystemParametersInfo(SPI_GETMENUANIMATION, false))
|
||||
result |= QPlatformTheme::AnimateMenuUiEffect;
|
||||
if (booleanSystemParametersInfo(SPI_GETMENUFADE, false))
|
||||
result |= QPlatformTheme::FadeMenuUiEffect;
|
||||
if (booleanSystemParametersInfo(SPI_GETCOMBOBOXANIMATION, false))
|
||||
result |= QPlatformTheme::AnimateComboUiEffect;
|
||||
if (booleanSystemParametersInfo(SPI_GETTOOLTIPANIMATION, false))
|
||||
result |= QPlatformTheme::AnimateTooltipUiEffect;
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant QWindowsTheme::themeHint(ThemeHint hint) const
|
||||
{
|
||||
switch (hint) {
|
||||
@ -315,6 +331,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
|
||||
return QVariant(qRound(qreal(QWindowsContext::instance()->defaultDPI()) * 1.375));
|
||||
case KeyboardScheme:
|
||||
return QVariant(int(WindowsKeyboardScheme));
|
||||
case UiEffects:
|
||||
return QVariant(uiEffects());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -402,13 +402,7 @@ bool Q_WIDGETS_EXPORT qt_tab_all_widgets = true;
|
||||
bool qt_in_tab_key_event = false;
|
||||
int qt_antialiasing_threshold = -1;
|
||||
QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
|
||||
bool QApplicationPrivate::animate_ui = true;
|
||||
bool QApplicationPrivate::animate_menu = false;
|
||||
bool QApplicationPrivate::fade_menu = false;
|
||||
bool QApplicationPrivate::animate_combo = false;
|
||||
bool QApplicationPrivate::animate_tooltip = false;
|
||||
bool QApplicationPrivate::fade_tooltip = false;
|
||||
bool QApplicationPrivate::animate_toolbox = false;
|
||||
int QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect;
|
||||
bool QApplicationPrivate::widgetCount = false;
|
||||
bool QApplicationPrivate::load_testability = false;
|
||||
#ifdef QT_KEYPAD_NAVIGATION
|
||||
@ -685,6 +679,10 @@ void QApplicationPrivate::initialize()
|
||||
|
||||
if (qt_is_gui_used)
|
||||
initializeMultitouch();
|
||||
|
||||
if (QApplication::desktopSettingsAware())
|
||||
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
|
||||
QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -819,12 +817,7 @@ QApplication::~QApplication()
|
||||
QApplicationPrivate::obey_desktop_settings = true;
|
||||
|
||||
QApplicationPrivate::app_strut = QSize(0, 0);
|
||||
QApplicationPrivate::animate_ui = true;
|
||||
QApplicationPrivate::animate_menu = false;
|
||||
QApplicationPrivate::fade_menu = false;
|
||||
QApplicationPrivate::animate_combo = false;
|
||||
QApplicationPrivate::animate_tooltip = false;
|
||||
QApplicationPrivate::fade_tooltip = false;
|
||||
QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect;
|
||||
QApplicationPrivate::widgetCount = false;
|
||||
|
||||
#ifndef QT_NO_STATEMACHINE
|
||||
|
@ -266,13 +266,7 @@ public:
|
||||
static int wheel_scroll_lines;
|
||||
#endif
|
||||
|
||||
static bool animate_ui;
|
||||
static bool animate_menu;
|
||||
static bool animate_tooltip;
|
||||
static bool animate_combo;
|
||||
static bool fade_menu;
|
||||
static bool fade_tooltip;
|
||||
static bool animate_toolbox;
|
||||
static int enabledAnimations; // Combination of QPlatformTheme::UiEffect
|
||||
static bool widgetCount; // Coupled with -widgetcount switch
|
||||
static bool load_testability; // Coupled with -testability switch
|
||||
|
||||
|
@ -354,58 +354,47 @@ int QApplication::wheelScrollLines()
|
||||
}
|
||||
#endif
|
||||
|
||||
void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
|
||||
static inline int uiEffectToFlag(Qt::UIEffect effect)
|
||||
{
|
||||
switch (effect) {
|
||||
case Qt::UI_General:
|
||||
return QPlatformTheme::GeneralUiEffect;
|
||||
case Qt::UI_AnimateMenu:
|
||||
QApplicationPrivate::animate_menu = enable;
|
||||
break;
|
||||
return QPlatformTheme::AnimateMenuUiEffect;
|
||||
case Qt::UI_FadeMenu:
|
||||
if (enable)
|
||||
QApplicationPrivate::animate_menu = true;
|
||||
QApplicationPrivate::fade_menu = enable;
|
||||
break;
|
||||
return QPlatformTheme::FadeMenuUiEffect;
|
||||
case Qt::UI_AnimateCombo:
|
||||
QApplicationPrivate::animate_combo = enable;
|
||||
break;
|
||||
return QPlatformTheme::AnimateComboUiEffect;
|
||||
case Qt::UI_AnimateTooltip:
|
||||
QApplicationPrivate::animate_tooltip = enable;
|
||||
break;
|
||||
return QPlatformTheme::AnimateTooltipUiEffect;
|
||||
case Qt::UI_FadeTooltip:
|
||||
if (enable)
|
||||
QApplicationPrivate::animate_tooltip = true;
|
||||
QApplicationPrivate::fade_tooltip = enable;
|
||||
break;
|
||||
return QPlatformTheme::FadeTooltipUiEffect;
|
||||
case Qt::UI_AnimateToolBox:
|
||||
QApplicationPrivate::animate_toolbox = enable;
|
||||
break;
|
||||
default:
|
||||
QApplicationPrivate::animate_ui = enable;
|
||||
break;
|
||||
return QPlatformTheme::AnimateToolBoxUiEffect;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
|
||||
{
|
||||
int effectFlags = uiEffectToFlag(effect);
|
||||
if (enable) {
|
||||
if (effectFlags & QPlatformTheme::FadeMenuUiEffect)
|
||||
effectFlags |= QPlatformTheme::AnimateMenuUiEffect;
|
||||
if (effectFlags & QPlatformTheme::FadeTooltipUiEffect)
|
||||
effectFlags |= QPlatformTheme::AnimateTooltipUiEffect;
|
||||
QApplicationPrivate::enabledAnimations |= effectFlags;
|
||||
} else {
|
||||
QApplicationPrivate::enabledAnimations &= ~effectFlags;
|
||||
}
|
||||
}
|
||||
|
||||
bool QApplication::isEffectEnabled(Qt::UIEffect effect)
|
||||
{
|
||||
if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui)
|
||||
return QColormap::instance().depth() >= 16
|
||||
&& (QApplicationPrivate::enabledAnimations & QPlatformTheme::GeneralUiEffect)
|
||||
&& (QApplicationPrivate::enabledAnimations & uiEffectToFlag(effect));
|
||||
return false;
|
||||
|
||||
switch(effect) {
|
||||
case Qt::UI_AnimateMenu:
|
||||
return QApplicationPrivate::animate_menu;
|
||||
case Qt::UI_FadeMenu:
|
||||
return QApplicationPrivate::fade_menu;
|
||||
case Qt::UI_AnimateCombo:
|
||||
return QApplicationPrivate::animate_combo;
|
||||
case Qt::UI_AnimateTooltip:
|
||||
return QApplicationPrivate::animate_tooltip;
|
||||
case Qt::UI_FadeTooltip:
|
||||
return QApplicationPrivate::fade_tooltip;
|
||||
case Qt::UI_AnimateToolBox:
|
||||
return QApplicationPrivate::animate_toolbox;
|
||||
default:
|
||||
return QApplicationPrivate::animate_ui;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *QApplication::topLevelAt(const QPoint &pos)
|
||||
|
Loading…
Reference in New Issue
Block a user