From 29d171e73a59558825fc4606203fd52692d3bf4c Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Thu, 29 Oct 2020 21:21:00 +0000 Subject: [PATCH] Launcher: port the QQC2 check to next Since we require QQC2 on next, make it a critical warning. --- src/GUI/LauncherMainWindow.cxx | 28 ++++++++++++++++++++++++++++ src/GUI/LauncherMainWindow.hxx | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/GUI/LauncherMainWindow.cxx b/src/GUI/LauncherMainWindow.cxx index f7bd4cbdf..4b28f3de0 100755 --- a/src/GUI/LauncherMainWindow.cxx +++ b/src/GUI/LauncherMainWindow.cxx @@ -82,6 +82,13 @@ LauncherMainWindow::LauncherMainWindow(bool inSimMode) : QQuickView() connect(qa, &QAction::triggered, m_controller, &LauncherController::quit); } + if (!checkQQC2Availability()) { + QMessageBox::critical(nullptr, "Missing required component", + tr("Your system is missing a required UI component (QtQuick Controls 2). " + "This normally occurs on Linux platforms where Qt is split into many small packages. " + "On Ubuntu/Debian systems, the package is called 'qml-module-qtquick-controls2'")); + } + connect(this, &QQuickView::statusChanged, this, &LauncherMainWindow::onQuickStatusChanged); m_controller->initialRestoreSettings(); @@ -147,6 +154,27 @@ void LauncherMainWindow::onQuickStatusChanged(QQuickView::Status status) } } +bool LauncherMainWindow::checkQQC2Availability() +{ + QQmlComponent comp(engine()); + comp.setData(R"( + import QtQuick.Controls 2.0 + ScrollBar { + } + )", + {}); + if (comp.isError()) { + return false; + } + + + auto item = comp.create(); + const bool haveQQC2 = (item != nullptr); + if (item) + item->deleteLater(); + return haveQQC2; +} + LauncherMainWindow::~LauncherMainWindow() { } diff --git a/src/GUI/LauncherMainWindow.hxx b/src/GUI/LauncherMainWindow.hxx index 051fb2cb4..39ffa89d3 100644 --- a/src/GUI/LauncherMainWindow.hxx +++ b/src/GUI/LauncherMainWindow.hxx @@ -53,6 +53,8 @@ private slots: void onQuickStatusChanged(QQuickView::Status status); private: + bool checkQQC2Availability(); + LauncherController* m_controller; };