diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2009-06-12 14:53:40 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2009-06-12 15:05:11 (GMT) |
commit | 4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7 (patch) | |
tree | 766d2cbcad6082f794217000778b46ac8d2a7890 /src/gui/kernel/qapplication.cpp | |
parent | 56b93b836f70e121540e8d8da9447f5dc6e1fdd6 (diff) | |
download | Qt-4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7.zip Qt-4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7.tar.gz Qt-4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7.tar.bz2 |
Integrating QProxyStyle
This class adds convenient support for proxy styles in Qt.
Note that to support proper proxying, styles now
call their functions through proxy() so that the proxy regains control
over subcomponents. Note that there is a small price to be payed
by the extra function call which can at the cost of readability
be redirected to the private class member in the future.
Task-number: 229556
Reviewed-by: trond
Diffstat (limited to 'src/gui/kernel/qapplication.cpp')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4ab653d..b066f4d 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -391,6 +391,7 @@ Qt::MouseButtons QApplicationPrivate::mouse_buttons = Qt::NoButton; Qt::KeyboardModifiers QApplicationPrivate::modifier_buttons = Qt::NoModifier; QStyle *QApplicationPrivate::app_style = 0; // default application style +QString QApplicationPrivate::styleOverride; // style override #ifndef QT_NO_STYLE_STYLESHEET QString QApplicationPrivate::styleSheet; // default application stylesheet @@ -438,7 +439,6 @@ bool QApplicationPrivate::animate_tooltip = false; bool QApplicationPrivate::fade_tooltip = false; bool QApplicationPrivate::animate_toolbox = false; bool QApplicationPrivate::widgetCount = false; -QString* QApplicationPrivate::styleOverride = 0; #if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) bool QApplicationPrivate::inSizeMove = false; #endif @@ -548,9 +548,7 @@ void QApplicationPrivate::process_cmdline() delete app_style; app_style = 0; } - if (!styleOverride) - styleOverride = new QString; - *styleOverride = s; + styleOverride = s; } } @@ -1287,44 +1285,14 @@ QStyle *QApplication::style() return 0; } -#if defined(Q_WS_X11) - if(!QApplicationPrivate::styleOverride) - QApplicationPrivate::x11_initialize_style(); // run-time search for default style -#endif if (!QApplicationPrivate::app_style) { // Compile-time search for default style // QString style; - if (QApplicationPrivate::styleOverride) { - style = *QApplicationPrivate::styleOverride; - delete QApplicationPrivate::styleOverride; - QApplicationPrivate::styleOverride = 0; - } else { -#if defined(Q_WS_WIN) && defined(Q_WS_WINCE) - if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()) - style = QLatin1String("WindowsMobile"); - else - style = QLatin1String("WindowsCE"); - -#elif defined(Q_WS_WIN) - if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA - && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) - style = QLatin1String("WindowsVista"); - else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP - && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) - style = QLatin1String("WindowsXP"); - else - style = QLatin1String("Windows"); // default styles for Windows -#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS) - style = QLatin1String("CDE"); // default style for X11 on Solaris -#elif defined(Q_WS_X11) && defined(Q_OS_IRIX) - style = QLatin1String("SGI"); // default style for X11 on IRIX -#elif defined(Q_WS_X11) || defined(Q_WS_QWS) - style = QLatin1String("Plastique"); // default style for X11 and small devices -#elif defined(Q_WS_MAC) - style = QLatin1String("Macintosh"); // default style for all Mac's -#endif - } + if (!QApplicationPrivate::styleOverride.isEmpty()) + style = QApplicationPrivate::styleOverride; + else + style = QApplicationPrivate::desktopStyleKey(); QStyle *&app_style = QApplicationPrivate::app_style; app_style = QStyleFactory::create(style); @@ -1412,9 +1380,8 @@ void QApplication::setStyle(QStyle *style) } else #endif // QT_NO_STYLE_STYLESHEET QApplicationPrivate::app_style = style; - QApplicationPrivate::app_style->setParent(qApp); // take ownership - + // take care of possible palette requirements of certain gui // styles. Do it before polishing the application since the style // might call QApplication::setPalette() itself @@ -1936,6 +1903,40 @@ void QApplicationPrivate::setSystemFont(const QFont &font) QApplication::setFont(*sys_font); } +/*! \internal +*/ +QString QApplicationPrivate::desktopStyleKey() +{ +QString desktopstyle; +#if defined(Q_WS_WIN) && defined(Q_WS_WINCE) + if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc()) + desktopstyle = QLatin1String("WindowsMobile"); + else + desktopstyle = QLatin1String("WindowsCE"); + +#elif defined(Q_WS_WIN) + if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA + && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) + desktopstyle = QLatin1String("WindowsVista"); + else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP + && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) + desktopstyle = QLatin1String("WindowsXP"); + else + desktopstyle = QLatin1String("Windows"); // default styles for Windows +#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS) + desktopstyle = QLatin1String("CDE"); // default style for X11 on Solaris +#elif defined(Q_WS_X11) && defined(Q_OS_IRIX) + desktopstyle = QLatin1String("SGI"); // default style for X11 on IRIX +#elif defined(Q_WS_QWS) + desktopstyle = QLatin1String("Plastique"); // default style for X11 and small devices +#elif defined(Q_WS_X11) + desktopstyle = QApplicationPrivate::x11_desktop_style(); // default runtime dependant style for X11 +#elif defined(Q_WS_MAC) + desktopstyle = QLatin1String("Macintosh"); // default style for all Mac's +#endif + return desktopstyle; +} + /*! \property QApplication::windowIcon \brief the default window icon |