filemanager/qml/Dialogs/PropertiesDialog.qml

209 lines
6.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
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
2021-04-09 07:49:19 -07:00
import FishUI 1.0 as FishUI
2021-03-16 00:02:20 -07:00
Window {
id: control
title: qsTr("Properties")
2021-03-29 01:51:34 -07:00
flags: Qt.Dialog
2021-03-16 00:02:20 -07:00
visible: true
2021-03-20 02:33:00 -07:00
Rectangle {
anchors.fill: parent
2021-07-19 01:11:42 -07:00
color: FishUI.Theme.secondBackgroundColor
2021-03-20 02:33:00 -07:00
}
2021-03-16 00:02:20 -07:00
onVisibleChanged: {
if (visible) updateWindowSize()
}
function updateWindowSize() {
if (visible) {
control.width = _mainLayout.implicitWidth + _mainLayout.anchors.leftMargin + _mainLayout.anchors.rightMargin
control.height = _mainLayout.implicitHeight + _mainLayout.anchors.topMargin + _mainLayout.anchors.bottomMargin
control.minimumWidth = control.width
control.minimumHeight = control.height
control.maximumWidth = control.width
control.maximumHeight = control.height
if (_textField.enabled)
_textField.forceActiveFocus()
}
}
Item {
id: _contentItem
anchors.fill: parent
focus: true
Keys.enabled: true
Keys.onEscapePressed: control.close()
ColumnLayout {
id: _mainLayout
anchors.fill: parent
2021-04-09 07:49:19 -07:00
anchors.leftMargin: FishUI.Units.largeSpacing * 2
anchors.rightMargin: FishUI.Units.largeSpacing * 2
anchors.topMargin: FishUI.Units.largeSpacing
2021-06-17 06:22:18 -07:00
anchors.bottomMargin: FishUI.Units.largeSpacing * 1.5
2021-04-09 07:49:19 -07:00
spacing: FishUI.Units.largeSpacing
2021-03-16 00:02:20 -07:00
RowLayout {
2021-04-09 07:49:19 -07:00
spacing: FishUI.Units.largeSpacing * 2
2021-03-16 00:02:20 -07:00
Image {
width: 64
height: width
sourceSize: Qt.size(width, height)
source: "image://icontheme/" + main.iconName
}
TextField {
id: _textField
text: main.fileName
focus: true
Layout.fillWidth: true
Keys.onEscapePressed: control.close()
2021-03-29 01:51:34 -07:00
enabled: !main.multiple && main.isWritable
2021-03-16 00:02:20 -07:00
}
}
GridLayout {
columns: 2
2021-04-09 07:49:19 -07:00
columnSpacing: FishUI.Units.largeSpacing
rowSpacing: FishUI.Units.largeSpacing
2021-03-16 00:02:20 -07:00
Layout.alignment: Qt.AlignTop
onHeightChanged: updateWindowSize()
onImplicitHeightChanged: updateWindowSize()
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Type:")
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
color: FishUI.Theme.disabledTextColor
2021-03-16 00:02:20 -07:00
visible: mimeType.visible
}
Label {
id: mimeType
text: main.mimeType
visible: text
}
Label {
text: qsTr("Location:")
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
color: FishUI.Theme.disabledTextColor
2021-03-16 00:02:20 -07:00
}
Label {
id: location
text: main.location
}
Label {
text: qsTr("Size:")
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
color: FishUI.Theme.disabledTextColor
2021-03-20 02:33:00 -07:00
// visible: size.visible
2021-03-16 00:02:20 -07:00
}
Label {
id: size
2021-03-29 01:51:34 -07:00
text: main.size ? main.size : qsTr("Calculating...")
2021-03-20 02:33:00 -07:00
// visible: text
2021-03-16 00:02:20 -07:00
}
Label {
text: qsTr("Created:")
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
color: FishUI.Theme.disabledTextColor
2021-03-16 00:02:20 -07:00
visible: creationTime.visible
}
Label {
id: creationTime
text: main.creationTime
visible: text
}
Label {
text: qsTr("Modified:")
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
color: FishUI.Theme.disabledTextColor
2021-03-16 00:02:20 -07:00
visible: modifiedTime.visible
}
Label {
id: modifiedTime
text: main.modifiedTime
visible: text
}
Label {
text: qsTr("Accessed:")
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
color: FishUI.Theme.disabledTextColor
2021-03-16 00:02:20 -07:00
visible: accessTime.visible
}
Label {
id: accessTime
text: main.accessedTime
visible: text
}
}
Item {
2021-04-09 07:49:19 -07:00
height: FishUI.Units.largeSpacing
2021-03-16 00:02:20 -07:00
}
RowLayout {
Layout.alignment: Qt.AlignRight
2021-04-09 07:49:19 -07:00
spacing: FishUI.Units.largeSpacing
2021-03-16 00:02:20 -07:00
Button {
text: qsTr("Cancel")
Layout.fillWidth: true
2021-03-29 01:51:34 -07:00
onClicked: {
control.close()
main.reject()
}
2021-03-16 00:02:20 -07:00
}
Button {
text: qsTr("OK")
Layout.fillWidth: true
2021-03-29 01:51:34 -07:00
onClicked: {
main.accept(_textField.text)
control.close()
}
2021-03-20 02:33:00 -07:00
flat: true
2021-03-16 00:02:20 -07:00
}
}
}
}
}