move styleOverride from QApplicationPrivate to QGuiApplicationPrivate

* -style option is also used in other cases than widget world

Change-Id: I8555d309a7b9df0d26ad7a7b930411260537180e
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
This commit is contained in:
Liang Qi 2015-11-11 14:58:22 +01:00
parent bee361209f
commit 6f84d50457
4 changed files with 18 additions and 16 deletions

View File

@ -127,6 +127,8 @@ Qt::MouseButtons QGuiApplicationPrivate::tabletState = Qt::NoButton;
QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; QWindow *QGuiApplicationPrivate::tabletPressTarget = 0;
QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; QWindow *QGuiApplicationPrivate::currentMouseWindow = 0;
QString QGuiApplicationPrivate::styleOverride;
Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
bool QGuiApplicationPrivate::highDpiScalingUpdated = false; bool QGuiApplicationPrivate::highDpiScalingUpdated = false;
@ -1256,6 +1258,7 @@ void QGuiApplicationPrivate::init()
session_key = QString::fromWCharArray(guidstr); session_key = QString::fromWCharArray(guidstr);
# endif # endif
#endif #endif
QString s;
int j = argc ? 1 : 0; int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') { if (argv[i] && *argv[i] != '-') {
@ -1298,9 +1301,16 @@ void QGuiApplicationPrivate::init()
#endif #endif
} else if (arg == "-testability") { } else if (arg == "-testability") {
loadTestability = true; loadTestability = true;
} else if (arg.indexOf("-style=", 0) != -1) {
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
} else if (arg == "-style" && i < argc-1) {
s = QString::fromLocal8Bit(argv[++i]).toLower();
} else { } else {
argv[j++] = argv[i]; argv[j++] = argv[i];
} }
if (!s.isEmpty())
styleOverride = s;
} }
if (j < argc) { if (j < argc) {

View File

@ -220,6 +220,7 @@ public:
static QFont *app_font; static QFont *app_font;
static QString styleOverride;
static QStyleHints *styleHints; static QStyleHints *styleHints;
static bool obey_desktop_settings; static bool obey_desktop_settings;
QInputMethod *inputMethod; QInputMethod *inputMethod;

View File

@ -398,8 +398,6 @@ void qt_cleanup();
QStyle *QApplicationPrivate::app_style = 0; // default application style QStyle *QApplicationPrivate::app_style = 0; // default application style
bool QApplicationPrivate::overrides_native_style = false; // whether native QApplication style is bool QApplicationPrivate::overrides_native_style = false; // whether native QApplication style is
// overridden, i.e. not native // overridden, i.e. not native
QString QApplicationPrivate::styleOverride; // style override
#ifndef QT_NO_STYLE_STYLESHEET #ifndef QT_NO_STYLE_STYLESHEET
QString QApplicationPrivate::styleSheet; // default application stylesheet QString QApplicationPrivate::styleSheet; // default application stylesheet
#endif #endif
@ -465,6 +463,13 @@ QDesktopWidget *qt_desktopWidget = 0; // root window widgets
*/ */
void QApplicationPrivate::process_cmdline() void QApplicationPrivate::process_cmdline()
{ {
if (!styleOverride.isEmpty()) {
if (app_style) {
delete app_style;
app_style = 0;
}
}
// process platform-indep command line // process platform-indep command line
if (!qt_is_gui_used || !argc) if (!qt_is_gui_used || !argc)
return; return;
@ -480,13 +485,8 @@ void QApplicationPrivate::process_cmdline()
QByteArray arg = argv[i]; QByteArray arg = argv[i];
if (arg.startsWith("--")) if (arg.startsWith("--"))
arg.remove(0, 1); arg.remove(0, 1);
QString s;
if (arg == "-qdevel" || arg == "-qdebug") { if (arg == "-qdevel" || arg == "-qdebug") {
// obsolete argument // obsolete argument
} else if (arg.indexOf("-style=", 0) != -1) {
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
} else if (arg == "-style" && i < argc-1) {
s = QString::fromLocal8Bit(argv[++i]).toLower();
#ifndef QT_NO_STYLE_STYLESHEET #ifndef QT_NO_STYLE_STYLESHEET
} else if (arg == "-stylesheet" && i < argc -1) { } else if (arg == "-stylesheet" && i < argc -1) {
styleSheet = QLatin1String("file:///"); styleSheet = QLatin1String("file:///");
@ -500,13 +500,6 @@ void QApplicationPrivate::process_cmdline()
} else { } else {
argv[j++] = argv[i]; argv[j++] = argv[i];
} }
if (!s.isEmpty()) {
if (app_style) {
delete app_style;
app_style = 0;
}
styleOverride = s;
}
} }
if(j < argc) { if(j < argc) {

View File

@ -219,8 +219,6 @@ public:
static QApplicationPrivate *instance() { return self; } static QApplicationPrivate *instance() { return self; }
static QString styleOverride;
#ifdef QT_KEYPAD_NAVIGATION #ifdef QT_KEYPAD_NAVIGATION
static QWidget *oldEditFocus; static QWidget *oldEditFocus;
static Qt::NavigationMode navigationMode; static Qt::NavigationMode navigationMode;