native: basic qml app again
This commit is contained in:
parent
18eb38a2c1
commit
9e4b62a4d0
6 changed files with 17 additions and 326 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
159
native/Main.qml
159
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
Loading…
Add table
Reference in a new issue