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::currentMouseWindow = 0;
QString QGuiApplicationPrivate::styleOverride;
Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
bool QGuiApplicationPrivate::highDpiScalingUpdated = false;
@ -1256,6 +1258,7 @@ void QGuiApplicationPrivate::init()
session_key = QString::fromWCharArray(guidstr);
# endif
#endif
QString s;
int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') {
@ -1298,9 +1301,16 @@ void QGuiApplicationPrivate::init()
#endif
} else if (arg == "-testability") {
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 {
argv[j++] = argv[i];
}
if (!s.isEmpty())
styleOverride = s;
}
if (j < argc) {

View File

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

View File

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

View File

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