From 9e4b62a4d0c82dfe36094ddb1cd09865cdbe1258 Mon Sep 17 00:00:00 2001 From: jopejoe1 Date: Tue, 9 Jul 2024 17:50:34 +0200 Subject: [PATCH] native: basic qml app again --- native/AudioInfoBox.qml | 93 ----------------------- native/CMakeLists.txt | 15 ++-- native/ImageButton.qml | 23 ------ native/Main.qml | 159 +++------------------------------------- native/TextButton.qml | 45 ------------ native/pre_build.bat | 8 -- 6 files changed, 17 insertions(+), 326 deletions(-) delete mode 100644 native/AudioInfoBox.qml delete mode 100644 native/ImageButton.qml delete mode 100644 native/TextButton.qml delete mode 100644 native/pre_build.bat diff --git a/native/AudioInfoBox.qml b/native/AudioInfoBox.qml deleted file mode 100644 index 7d9b66c..0000000 --- a/native/AudioInfoBox.qml +++ /dev/null @@ -1,93 +0,0 @@ -import QtQuick -import QtMultimedia - -Item { - SystemPalette { id: systemColors; colorGroup: SystemPalette.Active } - id: root - - required property int songIndex - property alias title: titleText.text - property alias authorName: authorText.text - property alias imageSource: albumImage.source - property alias videoSource: albumVideo.source - property alias video: albumVideo - - visible: playerController.currentSongIndex === root.songIndex - - Image { - id: albumImage - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - } - - width: 150 - height: 150 - } - - Video { - id: albumVideo - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - } - - width: 400 - height: 400 - - loops: MediaPlayer.Infinite - volume: 0 - } - - Text { - id: titleText - - anchors { - bottom: parent.verticalCenter - left: playerController.currentSongIndex === 3 ? albumVideo.right : albumImage.right - margins: 20 - right: parent.right - } - - color: systemColors.windowText - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - - font { - pixelSize: 20 - bold: true - } - - text: qsTr("text") - } - - Text { - id: authorText - - anchors { - top: parent.verticalCenter - left: titleText.left - topMargin: 5 - right: parent.right - } - - color: systemColors.windowText - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - - font { - pixelSize: 16 - } - - text: qsTr("text") - } - - onVisibleChanged: { - if (visible) { - albumVideo.play() - } else { - albumVideo.seek(0) - albumVideo.stop() - } - } -} diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index c650f60..51bdbef 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -5,7 +5,7 @@ project(Alisa VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt6 6.2 REQUIRED COMPONENTS Quick Multimedia) +find_package(Qt6 6.2 REQUIRED COMPONENTS Quick) qt_add_executable(alisa @@ -15,13 +15,12 @@ qt_add_executable(alisa qt_add_qml_module(alisa URI Alisa VERSION 1.0 - QML_FILES Main.qml - QML_FILES AudioInfoBox.qml - QML_FILES ImageButton.qml + QML_FILES + Main.qml RESOURCES - Assets/Images/Boygenius_-_the_record.jpg - Assets/Icons/turbo.svg + Assets/Images/Boygenius_-_the_record.jpg + Assets/Icons/turbo.svg ) set_target_properties(alisa PROPERTIES @@ -32,8 +31,8 @@ set_target_properties(alisa PROPERTIES WIN32_EXECUTABLE TRUE ) -target_link_libraries(alisa - PRIVATE Qt6::Quick Qt6::Multimedia +target_link_libraries(alisa PRIVATE + Qt6::Quick ) include(GNUInstallDirs) diff --git a/native/ImageButton.qml b/native/ImageButton.qml deleted file mode 100644 index f041ed3..0000000 --- a/native/ImageButton.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick - -Image { - id: root - - signal clicked() - - width: buttonMouseArea.containsPress ? 49.5 : 50 - height: buttonMouseArea.containsPress ? 49.5 : 50 - opacity: buttonMouseArea.containsMouse ? 0.75 : 1 - mipmap: true - - MouseArea { - id: buttonMouseArea - - anchors.fill: parent - hoverEnabled: true - - onClicked: { - root.clicked() - } - } -} diff --git a/native/Main.qml b/native/Main.qml index 8ddd10b..dcbe808 100644 --- a/native/Main.qml +++ b/native/Main.qml @@ -3,167 +3,28 @@ import QtQuick.Window import QtQuick.Layouts Window { - SystemPalette { id: systemColors; colorGroup: SystemPalette.Active } + SystemPalette { id: activeColors; colorGroup: SystemPalette.Active } + SystemPalette { id: inactiveColors; colorGroup: SystemPalette.Inactive } + SystemPalette { id: disabledColors; colorGroup: SystemPalette.Disabled } id: root width: 640 height: 480 visible: true + color: active ? activeColors.window : inactiveColors.window - title: qsTr("Jukebox") + title: qsTr("Alisa - License Managment") Rectangle { - id: topbar - + id: s1 anchors { top: parent.top left: parent.left - right: parent.right + right: parent.rightali } - height: 50 - color: systemColors.window - } - - Rectangle { - id: mainSection - - anchors { - top: topbar.bottom - bottom: bottomBar.top - left: parent.left - right: parent.right - } - - color: systemColors.window - - AudioInfoBox { - id: firstSong - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - right: parent.right - margins: 20 - } - - songIndex: 0 - title: "The Record" - authorName: "Boygenius" - imageSource: "Assets/Images/Boygenius_-_the_record.jpg" - } - - AudioInfoBox { - id: secondSong - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - right: parent.right - margins: 20 - } - - songIndex: 1 - title: "Desire, I Want to Turn Into You" - authorName: "Caroline Polachek" - imageSource: "Assets/Images/Boygenius_-_the_record.jpg" - } - - AudioInfoBox { - id: thirdSong - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - right: parent.right - margins: 20 - } - - songIndex: 2 - title: "Softscars" - authorName: "Yeule" - imageSource: "Assets/Images/Boygenius_-_the_record.jpg" - } - - } - - Rectangle { - id: bottomBar - - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - } - - height: 100 - color: systemColors.window - - - ImageButton { - id: previousButton - - anchors { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - horizontalCenterOffset: -70 - } - - source: "Assets/Images/Boygenius_-_the_record.jpgg" - - onClicked: playerController.switchToPreviousSong() - } - - ImageButton { - id: playPauseButton - - anchors.centerIn: parent - - source: playerController.playing ? "Assets/Images/Boygenius_-_the_record.jpg" : "Assets/Images/Boygenius_-_the_record.jpg" - - onClicked: playerController.playPause() - } - - ImageButton { - id: nextButton - - anchors { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - horizontalCenterOffset: 70 - } - - source: "Assets/Images/Boygenius_-_the_record.jpg" - - onClicked: playerController.switchToNextSong() - } - } - - QtObject { - id: playerController - - property int currentSongIndex: 0 - property int songCount: 4 - property bool playing: true - - function playPause() { - playing = !playing - if (playing) { - fourthSong.video.play() - } else { - fourthSong.video.pause() - } - } - - function switchToNextSong() { - currentSongIndex = (currentSongIndex + 1) % songCount - console.log(currentSongIndex) - } - - function switchToPreviousSong() { - if (currentSongIndex == 0) currentSongIndex = songCount; - currentSongIndex = (currentSongIndex - 1) % songCount - console.log(currentSongIndex) - } + border.width: 5 + border.color: root.active ? activeColors.accent : inactiveColors.accent + color: root.active ? activeColors.midlight : inactiveColors.midlight } } diff --git a/native/TextButton.qml b/native/TextButton.qml deleted file mode 100644 index 598936a..0000000 --- a/native/TextButton.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick - -Item { - SystemPalette { id: systemColors; colorGroup: SystemPalette.Active } - id: root - - property color color: systemColors.window - property alias text: buttonText.text - - signal clicked() - - Rectangle { - id: background - anchors.fill: parent - color: getModifiedColor(buttonMouseArea, root.color) - } - - Text { - id: buttonText - - anchors.centerIn: parent - } - - MouseArea { - id: buttonMouseArea - - anchors.fill: parent - hoverEnabled: true - - onClicked: { - root.clicked() - } - } - - function getModifiedColor(item, color) - { - if (item.containsPress) { - return Qt.darker(color) - } else if (item.containsMouse) { - return Qt.lighter(color) - } else { - return color - } - } -} diff --git a/native/pre_build.bat b/native/pre_build.bat deleted file mode 100644 index 9971816..0000000 --- a/native/pre_build.bat +++ /dev/null @@ -1,8 +0,0 @@ -@ECHO OFF - -set path=%path%;C:\Qt\Tools\mingw1120_64\bin -C:\Qt\6.6.0\mingw_64\bin\windeployqt6.exe D:\GitHub\Qt-Apps\Qt-Quick\build-Qt6-Quick-Example-Desktop_Qt_6_6_0_MinGW_64_bit-Release - -echo "Finished pre-build" -popd -exit /b 0 \ No newline at end of file