123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- import QtQuick 2.15
- import QtQuick.Window 2.15
- import QtGraphicalEffects 1.15
- import DMusic 1.0
- import "pages"
- Window {
- id: _window
- visible: true
- flags: Config.csd? Qt.FramelessWindowHint | Qt.Window : Qt.Window
- width: 1280 + 20
- height: 720 + 20
- minimumWidth: 520 + shadowRadius * 2
- minimumHeight: 300 + shadowRadius * 2
- property real shadowRadius: (Config.csd && !maximized)? 10 : 0
- property bool maximized: visibility == 4
- property bool needReadWH: false
- title: "DMusic"
- function updateConfigWidth() { Config.width = _window.width - _window.shadowRadius * 2 }
- function updateConfigHeight() { Config.height = _window.height - _window.shadowRadius * 2 }
- function maximize() {
- visibility = visibility == 2 ? 4 : 2
- }
- function minimize() {
- _window.showMinimized()
- }
- color: "transparent"
- Component.onCompleted: {
- if (Config.width == Screen.desktopAvailableWidth && Config.height == Screen.desktopAvailableHeight) {
- visibility = 4
- } else {
- _window.width = Config.width + shadowRadius * 2
- _window.height = Config.height + shadowRadius * 2
- }
- widthChanged.connect(updateConfigWidth)
- heightChanged.connect(updateConfigHeight)
- }
- DropShadow {
- anchors.fill: _root
- enabled: Config.csd && !maximized
- opacity: 0.6
- samples: 20
- radius: shadowRadius
- transparentBorder: true
- color: "#000000"
- source: Rectangle {
- width: _root.width
- height: _root.height
- color: "#000000"
- radius: 7.5
- }
- }
- Rectangle {
- id: _root
- width: _window.width - shadowRadius * 2
- height: _window.height - shadowRadius * 2
- x: shadowRadius
- y: shadowRadius
- color: Style.window.background
- focus: true
- MouseArea {
- anchors.fill: parent
- onClicked: _root.focus = true
- }
- PageSwitcher {
- id: _pages
- anchors.left: _root.left
- anchors.top: _title.bottom
- anchors.right: _root.right
- anchors.bottom: _player.top
- }
- Title {
- id: _title
- width: _root.width
- windowSize: Qt.size(_root.width, _root.height)
- clientSideDecorations: Config.csd
- maximized: _window.maximized
- }
- ListModel {
- id: _messages
- }
- Column {
- spacing: 15
- anchors.bottom: _player.top
- anchors.bottomMargin: 15
- anchors.horizontalCenter: parent.horizontalCenter
- add: Transition {
- NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200 }
- }
- Repeater {
- model: _messages
- Message {
- text: elementText
- details: elementDetails
- isError: elementIsError
- anchors.horizontalCenter: parent.horizontalCenter
- onClosed: _messages.remove(index)
- }
- }
- }
- Messages {
- id: _messagesReciever
- onMessage: _messages.append({ "elementText": text, "elementDetails": details, "elementIsError": false })
- onError: _messages.append({ "elementText": text, "elementDetails": details, "elementIsError": true })
- Component.onCompleted: init()
- }
- Player {
- id: _player
- width: _root.width
- height: 66
- anchors.bottom: parent.bottom
- }
- Rectangle {
- visible: !Style.darkHeader
- height: Style.window.border.width
- anchors.left: _player.left
- anchors.right: _player.right
- anchors.verticalCenter: _player.top
- color: Style.window.border.color
- }
- Shortcut { sequence: "Space"; onActivated: AudioPlayer.playing? AudioPlayer.pause() : AudioPlayer.play(); context: Qt.ApplicationShortcut }
- Shortcut { sequence: "Right"; onActivated: AudioPlayer.next(); context: Qt.ApplicationShortcut }
- Shortcut { sequence: "Left"; onActivated: AudioPlayer.prev(); context: Qt.ApplicationShortcut }
- Shortcut { sequence: "D"; onActivated: AudioPlayer.next(); context: Qt.ApplicationShortcut }
- Shortcut { sequence: "A"; onActivated: AudioPlayer.prev(); context: Qt.ApplicationShortcut }
- Shortcut { sequence: "Ctrl+S"; onActivated: PlayingTrackInfo.save(); context: Qt.ApplicationShortcut }
- Shortcut { sequence: "Up"; onActivated: AudioPlayer.volume += 0.05; context: Qt.ApplicationShortcut }
- Shortcut { sequence: "Down"; onActivated: AudioPlayer.volume -= 0.05; context: Qt.ApplicationShortcut }
- Shortcut { sequence: "M"; onActivated: AudioPlayer.muted = !AudioPlayer.muted; context: Qt.ApplicationShortcut }
- Shortcut { sequence: "S"; onActivated: AudioPlayer.shuffle = !AudioPlayer.shuffle; context: Qt.ApplicationShortcut }
- Shortcut { sequence: "C"; onActivated: AudioPlayer.loop = (AudioPlayer.loop + 1) % 3; context: Qt.ApplicationShortcut }
- Shortcut { sequence: "Ctrl+Y"; onActivated: Qt.openUrlExternally(PlayingTrackInfo.page); context: Qt.ApplicationShortcut }
- layer.enabled: Config.csd && visibility != 4
- layer.effect: OpacityMask {
- maskSource: Rectangle {
- width: _root.width
- height: _root.height
- radius: 7.5
- }
- }
- }
- }
|