Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
Serein207 committed Jan 3, 2024
1 parent 62cc8b3 commit 35fe9e5
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 25 deletions.
2 changes: 2 additions & 0 deletions res/img/heart-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions res/img/heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/img/netease-music.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions sast_music.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
<file>app.ico</file>
<file>app.icns</file>
<file>app_icon.svg</file>
<file>res/img/netease-music.png</file>
<file>res/img/heart.svg</file>
<file>res/img/heart-solid.svg</file>
<file>ui/component/IconButton.qml</file>
</qresource>
</RCC>
3 changes: 0 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include <qfontdatabase.h>

#include <QFontDatabase>
#include <QGuiApplication>
#include <QIcon>
#include <QQmlApplicationEngine>
Expand Down
138 changes: 117 additions & 21 deletions ui/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ ApplicationWindow {
visible: true
width: 1400
height: 850
minimumWidth: 1050
title: "SAST Music"

readonly property color activeColor: "#335eea"
readonly property color backgroundColor: Qt.rgba(209 / 255, 209 / 255,
214 / 255, 0.28)
readonly property string homePageUrl: "qrc:///ui/page/T_home.qml"
readonly property string explorePageUrl: "qrc:///ui/page/T_explore.qml"
readonly property string libraryPageUrl: "qrc:///ui/page/T_library.qml"
Expand All @@ -25,25 +28,28 @@ ApplicationWindow {
function isPageInStack(pageName) {
for (var i = 0; i < stackView.depth; ++i) {
if (stackView.get(i).objectName === pageName) {
return true;
return true
}
}
return false;
return false
}

// This function pops pages until the target page is on top
function popToTargetPage(targetPageName) {
while (stackView.depth > 1 && stackView.currentItem.objectName !== targetPageName) {
stackView.pop();
while (stackView.depth > 1
&& stackView.currentItem.objectName !== targetPageName) {
stackView.pop()
}
}

// This function pushes a new page or pops to an existing instance of the page
function pushOrPopToPage(pageUrl, pageName) {
if (isPageInStack(pageName)) {
popToTargetPage(pageName);
popToTargetPage(pageName)
} else {
stackView.push(pageUrl, { objectName: pageName });
stackView.push(pageUrl, {
"objectName": pageName
})
}
topPageUrl = pageUrl
}
Expand Down Expand Up @@ -71,13 +77,16 @@ ApplicationWindow {
}

function url2Name(url) {
if (url === homePageUrl) return "home"
if (url === explorePageUrl) return "explore"
if (url === libraryPageUrl) return "library"
if (url === homePageUrl)
return "home"
if (url === explorePageUrl)
return "explore"
if (url === libraryPageUrl)
return "library"
}

Component.onCompleted: {
pushPage(homePageUrl);
pushPage(homePageUrl)
}
}

Expand All @@ -86,7 +95,6 @@ ApplicationWindow {
width: parent.width
height: 60
blurRadius: 100
color: Qt.rgba(1, 1, 1, 0.99)
target: stackView
Row {
spacing: 5
Expand All @@ -98,14 +106,14 @@ ApplicationWindow {
FluIconButton {
id: btn_back
radius: 6
hoverColor: Qt.rgba(209/255, 209/255, 214/255, 0.28)
hoverColor: backgroundColor
iconSource: FluentIcons.ChevronLeftSmall
onClicked: stackView.popPage()
}
FluIconButton {
id: btn_redo
radius: 6
hoverColor: Qt.rgba(209/255, 209/255, 214/255, 0.28)
hoverColor: backgroundColor
iconSource: FluentIcons.ChevronRightSmall
onClicked: stackView.redoPage()
}
Expand All @@ -124,7 +132,7 @@ ApplicationWindow {
textColor: topPageUrl === homePageUrl ? activeColor : "#000"
implicitHeight: 30
normalColor: Qt.rgba(0, 0, 0, 1)
backgroundHoverColor: Qt.rgba(209/255, 209/255, 214/255, 0.28)
backgroundHoverColor: backgroundColor
onClicked: stackView.pushPage(homePageUrl)
}

Expand All @@ -137,7 +145,7 @@ ApplicationWindow {
textColor: topPageUrl === explorePageUrl ? activeColor : "#000"
implicitHeight: 30
normalColor: Qt.rgba(0, 0, 0, 1)
backgroundHoverColor: Qt.rgba(209/255, 209/255, 214/255, 0.28)
backgroundHoverColor: backgroundColor
onClicked: stackView.pushPage(explorePageUrl)
}

Expand All @@ -150,7 +158,7 @@ ApplicationWindow {
textColor: topPageUrl === libraryPageUrl ? activeColor : "#000"
implicitHeight: 30
normalColor: Qt.rgba(0, 0, 0, 1)
backgroundHoverColor: Qt.rgba(209/255, 209/255, 214/255, 0.28)
backgroundHoverColor: backgroundColor
onClicked: stackView.pushPage(libraryPageUrl)
}
}
Expand All @@ -161,8 +169,7 @@ ApplicationWindow {
rightMargin: 15
verticalCenter: parent.verticalCenter
}
onCommit: (content) => {
// TODO: post search request
onCommit: content => {// TODO: post search request
}
}

Expand All @@ -184,7 +191,9 @@ ApplicationWindow {

Rectangle {
anchors.fill: parent
color: item_mouse.containsMouse ? Qt.rgba(46/255, 46/255, 41/255, 0.28) : "transparent"
color: item_mouse.containsMouse ? Qt.rgba(46 / 255,
46 / 255, 41 / 255,
0.28) : "transparent"
}

MouseArea {
Expand Down Expand Up @@ -214,15 +223,16 @@ ApplicationWindow {
font.family: "Barlow-Bold"
font.bold: true
}
MenuSeparator{}
MenuSeparator {}
RadiusMenuItem {
iconSize: 20
iconUrl: "qrc:///res/img/github.svg"
text: "GitHub Repo"
font.family: "Barlow-Bold"
font.bold: true
onClicked: {
Qt.openUrlExternally("https://github.com/NJUPT-SAST-Cpp/sast-music")
Qt.openUrlExternally(
"https://github.com/NJUPT-SAST-Cpp/sast-music")
}
}
}
Expand All @@ -233,4 +243,90 @@ ApplicationWindow {
focusPolicy: Qt.ClickFocus
}
}

Rectangle {
width: parent.width
height: 2
color: "#e6e6e6"
anchors {
bottom: playerBar.top
}
}

BlurRectangle {
id: playerBar
width: parent.width
height: 60
blurRadius: 100
target: stackView
anchors {
bottom: parent.bottom
}

FluClip {
id: image_song
radius: [3, 3, 3, 3]
width: 45
height: 45
anchors {
left: parent.left
leftMargin: 65
verticalCenter: parent.verticalCenter
}
FluImage {
anchors.fill: parent
source: "qrc:///res/img/netease-music.png"
}
FluShadow {}
}

Text {
id: text_song
text: "Song"
width: 100
elide: Text.ElideRight
maximumLineCount: 1
font.family: "Barlow-Bold"
font.bold: true
font.pixelSize: 16
anchors {
left: image_song.right
leftMargin: 10
top: parent.top
topMargin: 10
}
}

Text {
id: text_singer
text: "singer"
width: 100
elide: Text.ElideRight
maximumLineCount: 1
font.family: "Barlow-Bold"
font.pixelSize: 12
color: "#73706c"
anchors {
left: image_song.right
leftMargin: 10
top: parent.top
topMargin: 35
}
}

IconButton {
property bool liked: false
width: 30
height: 30
iconUrl: liked ? "qrc:///res/img/heart.svg" : "qrc:///res/img/heart-solid.svg"
anchors {
left: image_song.right
leftMargin: 20 + (text_song.implicitWidth > text_singer.implicitWidth ? text_song.implicitWidth : text_singer.implicitWidth)
verticalCenter: parent.verticalCenter
}
onClicked: {
liked = !liked
}
}
}
}
17 changes: 17 additions & 0 deletions ui/component/IconButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick 2.15
import FluentUI

FluIconButton {
id: control
property bool liked: false
property string iconUrl
property int iconSize: 15
width: 30
height: 30
iconDelegate: Image{
width: control.iconSize
height: control.iconSize
source: iconUrl
}
hoverColor: Qt.rgba(209/255, 209/255, 214/255, 0.28)
}
2 changes: 1 addition & 1 deletion ui/component/RadiusMenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ T.MenuItem {
right: parent.right
rightMargin: (control.mirrored ? indicatorPadding : arrowPadding)+5
}
FluLoader{
Loader{
id:loader_icon
sourceComponent: iconDelegate
anchors.verticalCenter: parent.verticalCenter
Expand Down
2 changes: 2 additions & 0 deletions ui/component/ScrollablePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ Item {
spacing: control.spacing
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
right: parent.right
topMargin: control.topMargin
bottomMargin: control.topMargin
leftMargin: control.leftRightMargin
rightMargin: control.leftRightMargin
}
Expand Down

0 comments on commit 35fe9e5

Please sign in to comment.