diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index f429ad2229..87c95e6420 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -503,6 +503,7 @@ static QWindowGeometrySpecification windowGeometrySpecification; \li \c {-qwindowgeometry} \e geometry, specifies window geometry for the main window using the X11-syntax. For example: \c {-qwindowgeometry 100x100+50+50} + \li \c {-qwindowicon}, sets the default window icon \li \c {-qwindowtitle}, sets the title of the first window \li \c{-reverse}, sets the application's layout direction to Qt::RightToLeft. This option is intended to aid debugging and should @@ -1108,12 +1109,15 @@ void QGuiApplicationPrivate::createPlatformIntegration() // Get command line params + QString icon; + int j = argc ? 1 : 0; for (int i=1; i<argc; i++) { if (argv[i] && *argv[i] != '-') { argv[j++] = argv[i]; continue; } + const bool isXcb = platformName == "xcb"; QByteArray arg = argv[i]; if (arg.startsWith("--")) arg.remove(0, 1); @@ -1126,12 +1130,16 @@ void QGuiApplicationPrivate::createPlatformIntegration() } else if (arg == "-platformtheme") { if (++i < argc) platformThemeName = QString::fromLocal8Bit(argv[i]); - } else if (arg == "-qwindowgeometry" || (platformName == "xcb" && arg == "-geometry")) { + } else if (arg == "-qwindowgeometry" || (isXcb && arg == "-geometry")) { if (++i < argc) windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]); - } else if (arg == "-qwindowtitle" || (platformName == "xcb" && arg == "-title")) { + } else if (arg == "-qwindowtitle" || (isXcb && arg == "-title")) { if (++i < argc) firstWindowTitle = QString::fromLocal8Bit(argv[i]); + } else if (arg == "-qwindowicon" || (isXcb && arg == "-icon")) { + if (++i < argc) { + icon = QString::fromLocal8Bit(argv[i]); + } } else { argv[j++] = argv[i]; } @@ -1144,6 +1152,8 @@ void QGuiApplicationPrivate::createPlatformIntegration() init_platform(QLatin1String(platformName), platformPluginPath, platformThemeName, argc, argv); + if (!icon.isEmpty()) + forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon); } /*! @@ -1426,6 +1436,20 @@ QPlatformNativeInterface *QGuiApplication::platformNativeInterface() } /*! + Returns a function pointer from the platformplugin matching \a function +*/ +QFunctionPointer QGuiApplication::platformFunction(const QByteArray &function) +{ + QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); + if (!pi) { + qWarning() << "QGuiApplication::platformFunction(): Must construct a QGuiApplication before accessing a platform function"; + return Q_NULLPTR; + } + + return pi->nativeInterface() ? pi->nativeInterface()->platformFunction(function) : Q_NULLPTR; +} + +/*! Enters the main event loop and waits until exit() is called, and then returns the value that was set to exit() (which is 0 if exit() is called via quit()). @@ -1548,8 +1572,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv case QWindowSystemInterfacePrivate::WindowScreenChanged: QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e)); break; - case QWindowSystemInterfacePrivate::ApplicationStateChanged: - QGuiApplicationPrivate::setApplicationState(static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e)->newState); + case QWindowSystemInterfacePrivate::ApplicationStateChanged: { + QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e); + QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); } break; case QWindowSystemInterfacePrivate::FlushEvents: QWindowSystemInterface::deferredFlushWindowSystemEvents(); @@ -1944,7 +1969,7 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf { if (QWindow *window = wse->window.data()) { if (QScreen *screen = wse->screen.data()) - window->d_func()->setScreen(screen, false /* recreate */); + window->d_func()->setTopLevelScreen(screen, false /* recreate */); else // Fall back to default behavior, and try to find some appropriate screen window->setScreen(0); } @@ -2628,6 +2653,15 @@ QClipboard * QGuiApplication::clipboard() #endif /*! + \since 5.4 + \fn void QGuiApplication::paletteChanged(const QPalette &palette) + + This signal is emitted when the \a palette of the application changes. + + \sa palette() +*/ + +/*! Returns the default application palette. \sa setPalette() @@ -2653,6 +2687,7 @@ void QGuiApplication::setPalette(const QPalette &pal) else *QGuiApplicationPrivate::app_pal = pal; applicationResourceFlags |= ApplicationPaletteExplicitlySet; + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } QRect QGuiApplicationPrivate::applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window) @@ -2862,9 +2897,9 @@ Qt::ApplicationState QGuiApplication::applicationState() \sa applicationState() */ -void QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState state) +void QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState state, bool forcePropagate) { - if (applicationState == state) + if ((applicationState == state) && !forcePropagate) return; applicationState = state; @@ -3065,6 +3100,8 @@ void QGuiApplicationPrivate::saveState() On system start-up, the default layout direction depends on the application's language. + The notifier signal was introduced in Qt 5.4. + \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() */ @@ -3075,7 +3112,10 @@ void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction) layout_direction = direction; - QGuiApplicationPrivate::self->notifyLayoutDirectionChange(); + if (qGuiApp) { + emit qGuiApp->layoutDirectionChanged(direction); + QGuiApplicationPrivate::self->notifyLayoutDirectionChange(); + } } Qt::LayoutDirection QGuiApplication::layoutDirection() |