forked from qt-creator/qt-creator
StudioWelcome: Use QQuickWindow on macOS
This fixes flickering on macOS introduced by Qt 6.4. Unfortuntly keyboard focus does not work on Windows in this case if the splashscreen flag is set. Therefore we only use QQuickWindow on macOS. Simplfiying code and removing unused code. The variable doNotShowAgain is always true now. The check in delayedInitialize can be removed, since we already show a warning during creation. Task-number: QDS-8113 Change-Id: I8185a58175f4d2eafe92561fbded535d7ae393a2 Reviewed-by: Henning Gründl <henning.gruendl@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QMainWindow>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
@@ -91,7 +92,8 @@ const char CRASH_REPORTER_SETTING[] = "CrashReportingEnabled";
|
|||||||
|
|
||||||
const char EXAMPLES_DOWNLOAD_PATH[] = "StudioWelcome/ExamplesDownloadPath";
|
const char EXAMPLES_DOWNLOAD_PATH[] = "StudioWelcome/ExamplesDownloadPath";
|
||||||
|
|
||||||
QPointer<QQuickWidget> s_view = nullptr;
|
QPointer<QQuickView> s_viewWindow = nullptr;
|
||||||
|
QPointer<QQuickWidget> s_viewWidget = nullptr;
|
||||||
static StudioWelcomePlugin *s_pluginInstance = nullptr;
|
static StudioWelcomePlugin *s_pluginInstance = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<QSettings> makeUserFeedbackSettings()
|
std::unique_ptr<QSettings> makeUserFeedbackSettings()
|
||||||
@@ -449,22 +451,13 @@ private:
|
|||||||
|
|
||||||
void StudioWelcomePlugin::closeSplashScreen()
|
void StudioWelcomePlugin::closeSplashScreen()
|
||||||
{
|
{
|
||||||
if (!s_view.isNull()) {
|
Utils::CheckableMessageBox::doNotAskAgain(Core::ICore::settings(),
|
||||||
const bool doNotShowAgain = s_view->rootObject()->property("doNotShowAgain").toBool();
|
DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY);
|
||||||
if (doNotShowAgain)
|
if (!s_viewWindow.isNull())
|
||||||
Utils::CheckableMessageBox::doNotAskAgain(Core::ICore::settings(),
|
s_viewWindow->deleteLater();
|
||||||
DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY);
|
|
||||||
|
|
||||||
s_view->deleteLater();
|
if (!s_viewWidget.isNull())
|
||||||
}
|
s_viewWidget->deleteLater();
|
||||||
}
|
|
||||||
|
|
||||||
void StudioWelcomePlugin::showSystemSettings()
|
|
||||||
{
|
|
||||||
Core::ICore::infoBar()->removeInfo("WarnCrashReporting");
|
|
||||||
Core::ICore::infoBar()->globallySuppressInfo("WarnCrashReporting");
|
|
||||||
|
|
||||||
Core::ICore::showOptionsDialog(Core::Constants::SETTINGS_ID_SYSTEM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioWelcomePlugin::StudioWelcomePlugin()
|
StudioWelcomePlugin::StudioWelcomePlugin()
|
||||||
@@ -537,47 +530,80 @@ void StudioWelcomePlugin::extensionsInitialized()
|
|||||||
|
|
||||||
if (showSplashScreen()) {
|
if (showSplashScreen()) {
|
||||||
connect(Core::ICore::instance(), &Core::ICore::coreOpened, this, [this] {
|
connect(Core::ICore::instance(), &Core::ICore::coreOpened, this, [this] {
|
||||||
s_view = new QQuickWidget(Core::ICore::dialogParent());
|
if (Utils::HostOsInfo::isMacHost()) {
|
||||||
s_view->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
s_viewWindow = new QQuickView(Core::ICore::mainWindow()->windowHandle());
|
||||||
s_view->setWindowFlag(Qt::SplashScreen, true);
|
|
||||||
s_view->setWindowModality(Qt::ApplicationModal);
|
s_viewWindow->setFlag(Qt::FramelessWindowHint);
|
||||||
s_view->engine()->addImportPath("qrc:/studiofonts");
|
|
||||||
|
s_viewWindow->setModality(Qt::ApplicationModal);
|
||||||
|
s_viewWindow->engine()->addImportPath("qrc:/studiofonts");
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
s_view->engine()->addImportPath(QLatin1String(STUDIO_QML_PATH) + "splashscreen/imports");
|
s_viewWindow->engine()->addImportPath(QLatin1String(STUDIO_QML_PATH)
|
||||||
s_view->setSource(
|
+ "splashscreen/imports");
|
||||||
QUrl::fromLocalFile(QLatin1String(STUDIO_QML_PATH) + "splashscreen/main.qml"));
|
s_viewWindow->setSource(
|
||||||
|
QUrl::fromLocalFile(QLatin1String(STUDIO_QML_PATH) + "splashscreen/main.qml"));
|
||||||
#else
|
#else
|
||||||
s_view->engine()->addImportPath("qrc:/qml/splashscreen/imports");
|
s_viewWindow->engine()->addImportPath("qrc:/qml/splashscreen/imports");
|
||||||
s_view->setSource(QUrl("qrc:/qml/splashscreen/main.qml"));
|
s_viewWindow->setSource(QUrl("qrc:/qml/splashscreen/main.qml"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QTC_ASSERT(s_viewWindow->rootObject(),
|
||||||
|
qWarning() << "The StudioWelcomePlugin has a runtime depdendency on "
|
||||||
|
"qt/qtquicktimeline.";
|
||||||
|
return );
|
||||||
|
|
||||||
QTC_ASSERT(s_view->rootObject(),
|
connect(s_viewWindow->rootObject(),
|
||||||
qWarning() << "The StudioWelcomePlugin has a runtime depdendency on "
|
SIGNAL(closeClicked()),
|
||||||
"qt/qtquicktimeline.";
|
this,
|
||||||
return );
|
SLOT(closeSplashScreen()));
|
||||||
|
|
||||||
connect(s_view->rootObject(), SIGNAL(closeClicked()), this, SLOT(closeSplashScreen()));
|
auto mainWindow = Core::ICore::mainWindow()->windowHandle();
|
||||||
connect(s_view->rootObject(),
|
s_viewWindow->setPosition((mainWindow->width() - s_viewWindow->width()) / 2,
|
||||||
SIGNAL(configureClicked()),
|
(mainWindow->height() - s_viewWindow->height()) / 2);
|
||||||
this,
|
|
||||||
SLOT(showSystemSettings()));
|
|
||||||
|
|
||||||
s_view->show();
|
s_viewWindow->show();
|
||||||
s_view->raise();
|
s_viewWindow->raise();
|
||||||
s_view->setFocus();
|
|
||||||
|
s_viewWindow->requestActivate();
|
||||||
|
} else {
|
||||||
|
s_viewWidget = new QQuickWidget(Core::ICore::dialogParent());
|
||||||
|
|
||||||
|
s_viewWidget->setWindowFlag(Qt::SplashScreen, true);
|
||||||
|
|
||||||
|
s_viewWidget->setWindowModality(Qt::ApplicationModal);
|
||||||
|
s_viewWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
|
s_viewWidget->engine()->addImportPath("qrc:/studiofonts");
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
s_viewWidget->engine()->addImportPath(QLatin1String(STUDIO_QML_PATH)
|
||||||
|
+ "splashscreen/imports");
|
||||||
|
s_viewWidget->setSource(
|
||||||
|
QUrl::fromLocalFile(QLatin1String(STUDIO_QML_PATH) + "splashscreen/main.qml"));
|
||||||
|
#else
|
||||||
|
s_viewWidget->engine()->addImportPath("qrc:/qml/splashscreen/imports");
|
||||||
|
s_viewWidget->setSource(QUrl("qrc:/qml/splashscreen/main.qml"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QTC_ASSERT(s_viewWidget->rootObject(),
|
||||||
|
qWarning() << "The StudioWelcomePlugin has a runtime depdendency on "
|
||||||
|
"qt/qtquicktimeline.";
|
||||||
|
return );
|
||||||
|
|
||||||
|
connect(s_viewWidget->rootObject(),
|
||||||
|
SIGNAL(closeClicked()),
|
||||||
|
this,
|
||||||
|
SLOT(closeSplashScreen()));
|
||||||
|
|
||||||
|
s_viewWidget->show();
|
||||||
|
s_viewWidget->raise();
|
||||||
|
s_viewWidget->setFocus();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StudioWelcomePlugin::delayedInitialize()
|
bool StudioWelcomePlugin::delayedInitialize()
|
||||||
{
|
{
|
||||||
if (s_view.isNull())
|
return true;
|
||||||
return false;
|
|
||||||
|
|
||||||
QTC_ASSERT(s_view->rootObject(), return true);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FilePath StudioWelcomePlugin::defaultExamplesPath()
|
Utils::FilePath StudioWelcomePlugin::defaultExamplesPath()
|
||||||
|
@@ -45,7 +45,6 @@ class StudioWelcomePlugin final : public ExtensionSystem::IPlugin
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeSplashScreen();
|
void closeSplashScreen();
|
||||||
void showSystemSettings();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StudioWelcomePlugin();
|
StudioWelcomePlugin();
|
||||||
|
Reference in New Issue
Block a user