dock/qml/main.qml

186 lines
5.1 KiB
QML
Raw Normal View History

2021-05-25 19:44:02 +08:00
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: rekols <revenmartin@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2021-03-16 11:17:11 +08:00
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
2021-03-16 18:20:04 +08:00
import Cutefish.Dock 1.0
2021-04-09 22:38:15 +08:00
import FishUI 1.0 as FishUI
2021-03-16 11:17:11 +08:00
Item {
id: root
visible: true
2021-03-25 00:14:48 +08:00
property bool isHorizontal: Settings.direction === DockSettings.Bottom
2021-04-18 21:23:47 +08:00
property real windowRadius: isHorizontal ? root.height * 0.3 : root.width * 0.3
2021-08-16 08:58:33 +08:00
property bool compositing: windowHelper.compositing
onCompositingChanged: {
mainWindow.updateSize()
}
2021-03-20 17:17:41 +08:00
2021-10-16 19:53:52 +08:00
Component.onCompleted: {
console.log(Settings.style)
}
2021-03-16 11:17:11 +08:00
DropArea {
anchors.fill: parent
enabled: true
}
2021-05-07 11:05:52 +08:00
// Background
Rectangle {
id: _background
2021-03-16 11:17:11 +08:00
anchors.fill: parent
2021-10-16 19:53:52 +08:00
radius: root.compositing && Settings.style === 0 ? windowRadius : 0
2021-09-21 10:43:23 +08:00
color: FishUI.Theme.darkMode ? "#666666" : "#E6E6E6"
2021-10-16 19:53:52 +08:00
opacity: root.compositing ? FishUI.Theme.darkMode ? 0.5 : 0.5 : 0.9
2021-06-02 23:59:42 +08:00
border.width: 0
2021-03-17 23:17:51 +08:00
2021-03-16 11:17:11 +08:00
Behavior on color {
ColorAnimation {
2021-03-17 21:33:06 +08:00
duration: 200
2021-03-17 23:17:51 +08:00
easing.type: Easing.Linear
2021-03-16 11:17:11 +08:00
}
}
}
2021-06-16 13:52:47 +08:00
FishUI.WindowHelper {
id: windowHelper
}
2021-05-30 00:45:15 +08:00
FishUI.WindowShadow {
view: mainWindow
geometry: Qt.rect(root.x, root.y, root.width, root.height)
strength: 1
2021-10-16 19:53:52 +08:00
radius: _background.radius
2021-05-07 11:05:52 +08:00
}
2021-04-16 01:13:45 +08:00
FishUI.WindowBlur {
view: mainWindow
geometry: Qt.rect(root.x, root.y, root.width, root.height)
2021-10-16 19:53:52 +08:00
windowRadius: _background.radius
2021-04-16 01:13:45 +08:00
enabled: true
2021-03-16 11:17:11 +08:00
}
2021-04-09 22:38:15 +08:00
FishUI.PopupTips {
2021-03-16 11:17:11 +08:00
id: popupTips
2021-08-01 03:11:02 +08:00
backgroundColor: _background.color
backgroundOpacity: _background.opacity
2021-03-16 11:17:11 +08:00
}
GridLayout {
id: mainLayout
anchors.fill: parent
2021-10-16 19:53:52 +08:00
anchors.topMargin: Settings.style === 1
&& (Settings.direction === 0 || Settings.direction === 2)
? 28 : 0
2021-03-16 11:17:11 +08:00
flow: isHorizontal ? Grid.LeftToRight : Grid.TopToBottom
columnSpacing: 0
rowSpacing: 0
ListView {
id: appItemView
orientation: isHorizontal ? Qt.Horizontal : Qt.Vertical
snapMode: ListView.SnapToItem
interactive: false
model: appModel
clip: true
Layout.fillHeight: true
Layout.fillWidth: true
delegate: AppItem {
id: appItemDelegate
2021-03-24 19:44:53 +08:00
implicitWidth: isHorizontal ? appItemView.height : appItemView.width
implicitHeight: isHorizontal ? appItemView.height : appItemView.width
2021-03-16 11:17:11 +08:00
}
moveDisplaced: Transition {
NumberAnimation {
properties: "x, y"
duration: 300
easing.type: Easing.InOutQuad
}
}
}
2021-05-07 13:36:48 +08:00
DockItem {
id: trashItem
implicitWidth: isHorizontal ? root.height : root.width
implicitHeight: isHorizontal ? root.height : root.width
popupText: qsTr("Trash")
enableActivateDot: false
iconName: trash.count === 0 ? "user-trash-empty" : "user-trash-full"
onClicked: trash.openTrash()
onRightClicked: trashMenu.popup()
2021-11-03 01:29:31 +08:00
dropArea.enabled: true
Rectangle {
anchors.fill: parent
anchors.margins: FishUI.Units.smallSpacing / 2
color: "transparent"
border.color: FishUI.Theme.textColor
radius: height * 0.3
border.width: 1
opacity: trashItem.dropArea.containsDrag ? 0.8 : 0
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
}
2021-05-07 13:36:48 +08:00
FishUI.DesktopMenu {
id: trashMenu
MenuItem {
text: qsTr("Open")
onTriggered: trash.openTrash()
}
MenuItem {
text: qsTr("Empty Trash")
onTriggered: trash.emptyTrash()
}
}
}
2021-03-16 11:17:11 +08:00
}
Connections {
target: Settings
function onDirectionChanged() {
popupTips.hide()
}
}
2021-06-22 15:24:16 +08:00
Connections {
target: mainWindow
function onVisibleChanged() {
popupTips.hide()
}
}
2021-03-16 11:17:11 +08:00
}