From 964fafb0e332c7c165f5e6d099976015065ea818 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:29:40 +0200 Subject: [PATCH 01/10] README: Mark theme options as finished --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8c04ba..5f8c6c7 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ When the project loads, click on the green flag button to run it. - [x] Stage size options - [x] HQ pen - [x] Mute sounds -- [ ] Theme options (light/dark mode, accent color, etc.) +- [x] Theme options (light/dark mode, accent color, etc.) See the [open issues](https://github.com/scratchcpp/scratchcpp-player/issues) for a full list of proposed features (and known issues). From 4486d40942a23565f31929ce62895ee4c8c22557 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Sat, 5 Oct 2024 11:04:36 +0200 Subject: [PATCH 02/10] Set version to 0.5.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07fd3b8..f784d0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(scratchcpp-player VERSION 0.4.0 LANGUAGES CXX) +project(scratchcpp-player VERSION 0.5.0 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) From b82e38c65ab4645b76b0882b2c604338898211d5 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Sat, 5 Oct 2024 11:04:39 +0200 Subject: [PATCH 03/10] Fix main window background color --- src/app/qml/main.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/qml/main.qml b/src/app/qml/main.qml index 7c6eb52..e3e0420 100644 --- a/src/app/qml/main.qml +++ b/src/app/qml/main.qml @@ -16,7 +16,7 @@ ApplicationWindow { minimumHeight: menuBar.height + layout.implicitHeight + layout.anchors.margins * 2 visible: true title: Qt.application.displayName - color: Material.background + color: ThemeEngine.bgColor Material.accent: ThemeEngine.accentColor Material.theme: ThemeEngine.theme == ThemeEngine.DarkTheme ? Material.Dark : Material.Light onActiveFocusItemChanged: UiEngine.activeFocusItem = activeFocusItem From dd335caf13c4941a36f46f8ce7a0ece473acb860 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:51:35 +0200 Subject: [PATCH 04/10] Add IconLabel to UI components --- src/uicomponents/CMakeLists.txt | 1 + src/uicomponents/IconLabel.qml | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 src/uicomponents/IconLabel.qml diff --git a/src/uicomponents/CMakeLists.txt b/src/uicomponents/CMakeLists.txt index 2ba3eb6..8475ef4 100644 --- a/src/uicomponents/CMakeLists.txt +++ b/src/uicomponents/CMakeLists.txt @@ -12,6 +12,7 @@ set(MODULE_QML_FILES CustomMenuSeparator.qml CustomDialog.qml CustomMessageDialog.qml + IconLabel.qml internal/CustomDialogButtonBox.qml ) set(MODULE_SRC diff --git a/src/uicomponents/IconLabel.qml b/src/uicomponents/IconLabel.qml new file mode 100644 index 0000000..e02f687 --- /dev/null +++ b/src/uicomponents/IconLabel.qml @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import QtQuick.Controls.impl as Controls + +Controls.IconLabel {} From 808826543f6a6382b21fa231e4a06d238e142d01 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:19:11 +0100 Subject: [PATCH 05/10] Update scratchcpp-render to v0.8.0 --- scratchcpp-render | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scratchcpp-render b/scratchcpp-render index 9dc264a..7b1ced7 160000 --- a/scratchcpp-render +++ b/scratchcpp-render @@ -1 +1 @@ -Subproject commit 9dc264a9dbb737e109c1e05a0550c5ae8e6f3747 +Subproject commit 7b1ced7b9e6edc56f961e1cdf7a9507462bc9158 From 9e42cb0c65b836f92dde7805adf48287fb55dc40 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:19:49 +0100 Subject: [PATCH 06/10] Add FPS counter Resolves: #30 --- src/app/qml/dialogs/ProjectSettingsDialog.qml | 8 ++++++++ src/app/qml/main.qml | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/app/qml/dialogs/ProjectSettingsDialog.qml b/src/app/qml/dialogs/ProjectSettingsDialog.qml index 53fd2cd..74352e9 100644 --- a/src/app/qml/dialogs/ProjectSettingsDialog.qml +++ b/src/app/qml/dialogs/ProjectSettingsDialog.qml @@ -9,6 +9,7 @@ import ScratchCPP.Render CustomDialog { property ProjectPlayer projectPlayer: null + property bool showCurrentFps: false title: qsTr("Project settings") standardButtons: Dialog.Close @@ -44,6 +45,13 @@ CustomDialog { onCheckedChanged: projectPlayer.hqPen = checked } + CheckBox { + id: showFpsCheckBox + text: qsTr("Show current FPS") + checked: showCurrentFps + onCheckedChanged: showCurrentFps = checked + } + // Remove limits Label { text: qsTr("Remove limits") diff --git a/src/app/qml/main.qml b/src/app/qml/main.qml index e3e0420..aceacd2 100644 --- a/src/app/qml/main.qml +++ b/src/app/qml/main.qml @@ -170,6 +170,25 @@ ApplicationWindow { onLoaded: { if(unsupportedBlocks.length > 0) unsupportedBlocksDialog.open() + + currentFps.enable = true; + } + + Loader { + id: currentFps + property bool enable: false + active: projectSettingsDialog.showCurrentFps && enable + anchors.right: player.stageRect.right + anchors.top: player.stageRect.top + + sourceComponent: Text { + text: player.renderFps + font.pointSize: 20 * player.stageScale + font.family: "mono" + color: Qt.rgba(1, 0, 0, 0.75) + style: Text.Outline + styleColor: "black" + } } } } From cef3b4f71f6f581f066ae74be3a31abe1f55d687 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:25:12 +0100 Subject: [PATCH 07/10] Update to Qt 6.8 --- .github/workflows/linux-build.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/utests.yml | 2 +- .github/workflows/windows-build.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index cd2fde1..2e5e847 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - qt-version: ['6.7'] + qt-version: ['6.8'] qt-target: ['desktop'] qt-modules: [''] arch: ['amd64'] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a77f09..afacd16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - qt-version: ['6.7'] + qt-version: ['6.8'] qt-target: ['desktop'] qt-modules: [''] arch: ['amd64'] @@ -99,7 +99,7 @@ jobs: runs-on: windows-latest strategy: matrix: - qt-version: ['6.7'] + qt-version: ['6.8'] qt-target: ['desktop'] qt-modules: [''] mingw-version: ['11.2.0'] diff --git a/.github/workflows/utests.yml b/.github/workflows/utests.yml index c0ca8bc..60d23e9 100644 --- a/.github/workflows/utests.yml +++ b/.github/workflows/utests.yml @@ -26,7 +26,7 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v4 with: - version: '6.7.*' + version: '6.8.*' arch: 'linux_gcc_64' - name: Configure CMake run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=ON diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index f087c6a..a595232 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -12,7 +12,7 @@ jobs: runs-on: windows-latest strategy: matrix: - qt-version: ['6.7'] + qt-version: ['6.8'] qt-target: ['desktop'] qt-modules: [''] mingw-version: ['11.2.0'] From 871f46ced1d0033dbf928c5326b20d7b61cd69a1 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:32:49 +0100 Subject: [PATCH 08/10] Link against Qt DBus on Linux --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f784d0f..2ffd010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,11 @@ option(SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS "Build unit tests" ON) find_package(Qt6 6.6 COMPONENTS Quick QuickControls2 Widgets OpenGLWidgets REQUIRED) set(QT_LIBS Qt6::Quick Qt6::QuickControls2 Qt6::Widgets Qt6::OpenGLWidgets) +if (LINUX) + find_package(Qt6 6.6 COMPONENTS DBus REQUIRED) + set(QT_LIBS ${QT_LIBS} Qt6::DBus) +endif() + if (SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS) set(GTEST_DIR thirdparty/googletest) add_subdirectory(${PROJECT_SOURCE_DIR}/${GTEST_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${GTEST_DIR}) From e6534d60fd0614bf2526ca7ee5f3b0cfcd9f1bac Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:33:13 +0100 Subject: [PATCH 09/10] UiEngine: Add useNativeMenuBar() method --- src/ui/internal/uiengine.cpp | 25 +++++++++++++++++++++++++ src/ui/internal/uiengine.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/src/ui/internal/uiengine.cpp b/src/ui/internal/uiengine.cpp index 4ca1d0a..d4d3440 100644 --- a/src/ui/internal/uiengine.cpp +++ b/src/ui/internal/uiengine.cpp @@ -2,6 +2,10 @@ #include #include +#ifdef Q_OS_LINUX +#include +#include +#endif #include "uiengine.h" @@ -66,3 +70,24 @@ void UiEngine::setActiveFocusItem(QQuickItem *newActiveFocusItem) m_activeFocusItem = newActiveFocusItem; emit activeFocusItemChanged(); } + +bool UiEngine::useNativeMenuBar() const +{ +#if defined(Q_OS_MACOS) +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) + return true; +#else + // Since Qt 6.8, Qt Quick Controls menu bar is native + return false; +#endif +#elif defined(Q_OS_LINUX) + const QDBusConnection connection = QDBusConnection::sessionBus(); + static const QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar"); + if (const auto iface = connection.interface()) + return iface->isServiceRegistered(registrarService); + else + return false; +#else + return false; +#endif +} diff --git a/src/ui/internal/uiengine.h b/src/ui/internal/uiengine.h index 3d01231..f0d2389 100644 --- a/src/ui/internal/uiengine.h +++ b/src/ui/internal/uiengine.h @@ -19,6 +19,7 @@ class UiEngine { Q_OBJECT Q_PROPERTY(QQuickItem *activeFocusItem READ activeFocusItem WRITE setActiveFocusItem NOTIFY activeFocusItemChanged) + Q_PROPERTY(bool useNativeMenuBar READ useNativeMenuBar NOTIFY useNativeMenuBarChanged FINAL) public: explicit UiEngine(QObject *parent = nullptr); @@ -34,8 +35,11 @@ class UiEngine QQuickItem *activeFocusItem() const; void setActiveFocusItem(QQuickItem *newActiveFocusItem); + bool useNativeMenuBar() const; + signals: void activeFocusItemChanged(); + void useNativeMenuBarChanged(); private: static std::shared_ptr m_instance; From f5f0a80cc6f6a494f3c8edece52b4f564015cfa8 Mon Sep 17 00:00:00 2001 From: adazem009 <68537469+adazem009@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:33:40 +0100 Subject: [PATCH 10/10] CustomMenuBar: Enable native menu bar code --- src/uicomponents/CustomMenuBar.qml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/uicomponents/CustomMenuBar.qml b/src/uicomponents/CustomMenuBar.qml index a495f24..3a789e1 100644 --- a/src/uicomponents/CustomMenuBar.qml +++ b/src/uicomponents/CustomMenuBar.qml @@ -2,6 +2,7 @@ import QtQuick import QtQuick.Controls +import Qt.labs.platform as Platform import ScratchCPP.Ui import ScratchCPP.UiComponents @@ -22,8 +23,7 @@ MenuBar { } function getComponentString(typeName) { - //var imports = "import QtQuick; import QtQuick.Controls; import Qt.labs.platform as Platform;" - var imports = "import QtQuick; import QtQuick.Controls;" + var imports = "import QtQuick; import QtQuick.Controls; import Qt.labs.platform as Platform;" return imports + " " + typeName + " {}"; } @@ -103,11 +103,11 @@ MenuBar { } function reload() { - /*if(nativeMenuBarEnabled) + if(UiEngine.useNativeMenuBar) { root.visible = false; return; - }*/ + } var oldObjects = []; @@ -132,14 +132,14 @@ MenuBar { Component.onCompleted: reload(); - /*onEnabledChanged: { + onEnabledChanged: { if(platformMenuBarLoader.active) platformMenuBarLoader.item.reload(); } Loader { id: platformMenuBarLoader - active: // whether the native menu bar is active + active: UiEngine.useNativeMenuBar sourceComponent: Platform.MenuBar { id: platformMenuBar @@ -149,14 +149,14 @@ MenuBar { createMenuBar(platformMenuBar, "Platform.Menu", "Platform.MenuItem", "Platform.MenuSeparator"); } - Connections { - target: QmlUtils + /*Connections { + target: // TODO: Add a class for the menu bar reload signal function onMenuBarReloadTriggered() { platformMenuBar.reload(); } - } + }*/ Component.onCompleted: reload(); } - }*/ + } }