filemanager/qml/main.qml

139 lines
4.2 KiB
QML
Raw Normal View History

2021-05-24 04:01:26 -07:00
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: revenmartin <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 00:02:20 -07:00
import QtQuick 2.12
2021-03-29 01:51:34 -07:00
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
2021-03-16 00:02:20 -07:00
import QtQuick.Window 2.12
2021-04-09 07:49:19 -07:00
import FishUI 1.0 as FishUI
2021-03-16 00:02:20 -07:00
2021-03-29 01:51:34 -07:00
import "./Controls"
2021-04-09 07:49:19 -07:00
FishUI.Window {
2021-03-16 00:02:20 -07:00
id: root
width: settings.width
height: settings.height
minimumWidth: 900
2021-03-29 01:51:34 -07:00
minimumHeight: 580
2021-03-16 00:02:20 -07:00
visible: true
title: qsTr("File Manager")
2021-06-23 02:29:47 -07:00
header.height: 36 + FishUI.Units.largeSpacing
2021-08-17 14:35:23 -07:00
background.opacity: root.compositing ? 0.9 : 1.0
2021-06-23 02:29:47 -07:00
2021-09-10 23:41:22 -07:00
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
2021-06-23 02:29:47 -07:00
FishUI.WindowBlur {
view: root
geometry: Qt.rect(root.x, root.y, root.width, root.height)
windowRadius: root.background.radius
enabled: true
}
2021-03-16 00:02:20 -07:00
property QtObject settings: GlobalSettings { }
onClosing: {
2021-03-29 01:51:34 -07:00
if (root.visibility !== Window.Maximized &&
root.visibility !== Window.FullScreen) {
settings.width = root.width
settings.height = root.height
}
2021-03-16 00:02:20 -07:00
}
2021-04-19 01:07:58 -07:00
OptionsMenu {
id: optionsMenu
}
2021-06-22 21:37:42 -07:00
headerItem: Item {
2021-03-16 00:02:20 -07:00
RowLayout {
anchors.fill: parent
2021-04-13 10:09:01 -07:00
anchors.leftMargin: FishUI.Units.smallSpacing * 1.5
anchors.rightMargin: FishUI.Units.smallSpacing * 1.5
anchors.topMargin: FishUI.Units.smallSpacing * 1.5
anchors.bottomMargin: FishUI.Units.smallSpacing * 1.5
2021-03-29 01:51:34 -07:00
2021-04-09 07:49:19 -07:00
spacing: FishUI.Units.smallSpacing
2021-03-16 00:02:20 -07:00
IconButton {
Layout.fillHeight: true
implicitWidth: height
2021-04-09 07:49:19 -07:00
source: FishUI.Theme.darkMode ? "qrc:/images/dark/go-previous.svg"
2021-07-08 08:48:56 -07:00
: "qrc:/images/light/go-previous.svg"
2021-03-29 01:51:34 -07:00
onClicked: _folderPage.goBack()
2021-03-16 00:02:20 -07:00
}
IconButton {
Layout.fillHeight: true
implicitWidth: height
2021-04-09 07:49:19 -07:00
source: FishUI.Theme.darkMode ? "qrc:/images/dark/go-next.svg"
2021-07-08 08:48:56 -07:00
: "qrc:/images/light/go-next.svg"
2021-03-29 01:51:34 -07:00
onClicked: _folderPage.goForward()
2021-03-16 00:02:20 -07:00
}
PathBar {
2021-03-29 01:51:34 -07:00
id: _pathBar
2021-03-16 00:02:20 -07:00
Layout.fillWidth: true
Layout.fillHeight: true
2021-03-29 01:51:34 -07:00
onItemClicked: _folderPage.openUrl(path)
onEditorAccepted: _folderPage.openUrl(path)
2021-03-16 00:02:20 -07:00
}
IconButton {
Layout.fillHeight: true
implicitWidth: height
2021-04-09 07:49:19 -07:00
property var gridSource: FishUI.Theme.darkMode ? "qrc:/images/dark/grid.svg" : "qrc:/images/light/grid.svg"
property var listSource: FishUI.Theme.darkMode ? "qrc:/images/dark/list.svg" : "qrc:/images/light/list.svg"
2021-03-29 01:51:34 -07:00
source: settings.viewMethod === 0 ? listSource : gridSource
onClicked: {
2021-04-19 01:07:58 -07:00
optionsMenu.popup()
2021-03-29 01:51:34 -07:00
}
2021-03-16 00:02:20 -07:00
}
}
}
2021-03-29 01:51:34 -07:00
RowLayout {
2021-03-16 00:02:20 -07:00
anchors.fill: parent
2021-03-29 01:51:34 -07:00
spacing: 0
2021-03-16 00:02:20 -07:00
2021-03-29 01:51:34 -07:00
SideBar {
id: _sideBar
2021-03-16 00:02:20 -07:00
Layout.fillHeight: true
2021-04-14 08:40:22 -07:00
width: 180 + FishUI.Units.largeSpacing
2021-03-29 01:51:34 -07:00
onClicked: _folderPage.openUrl(path)
}
2021-03-16 00:02:20 -07:00
2021-03-29 01:51:34 -07:00
FolderPage {
id: _folderPage
Layout.fillWidth: true
Layout.fillHeight: true
onCurrentUrlChanged: {
_sideBar.updateSelection(currentUrl)
_pathBar.updateUrl(currentUrl)
}
onRequestPathEditor: {
_pathBar.openEditor()
2021-03-16 00:02:20 -07:00
}
}
}
}