filemanager/qml/Dialogs/PropertiesDialog.qml

194 lines
5.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
Item {
2021-03-16 00:02:20 -07:00
id: control
width: _mainLayout.implicitWidth + FishUI.Units.largeSpacing * 4
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
focus: true
Keys.enabled: true
Keys.onEscapePressed: main.reject()
2021-03-16 00:02:20 -07:00
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 close() {
main.close()
}
2021-03-16 00:02:20 -07:00
function updateWindowSize() {
if (visible) {
if (_textField.enabled)
_textField.forceActiveFocus()
}
}
ColumnLayout {
id: _mainLayout
2021-03-16 00:02:20 -07:00
anchors.fill: parent
anchors.leftMargin: FishUI.Units.largeSpacing * 2
anchors.rightMargin: FishUI.Units.largeSpacing * 2
anchors.topMargin: FishUI.Units.smallSpacing
anchors.bottomMargin: FishUI.Units.largeSpacing * 1.5
spacing: FishUI.Units.largeSpacing
RowLayout {
spacing: FishUI.Units.largeSpacing * 2
Image {
width: 64
height: width
sourceSize: Qt.size(width, height)
source: "image://icontheme/" + main.iconName
2021-03-16 00:02:20 -07:00
}
TextField {
id: _textField
text: main.fileName
focus: true
Layout.fillWidth: true
Keys.onEscapePressed: main.reject()
enabled: main.isWritable
}
}
2021-03-16 00:02:20 -07:00
GridLayout {
columns: 2
columnSpacing: FishUI.Units.largeSpacing
rowSpacing: FishUI.Units.largeSpacing
Layout.alignment: Qt.AlignTop
2021-03-16 00:02:20 -07:00
onHeightChanged: updateWindowSize()
onImplicitHeightChanged: updateWindowSize()
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Type:")
Layout.alignment: Qt.AlignRight
color: FishUI.Theme.disabledTextColor
visible: mimeType.visible
}
2021-03-16 00:02:20 -07:00
Label {
id: mimeType
text: main.mimeType
visible: text
}
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Location:")
Layout.alignment: Qt.AlignRight
color: FishUI.Theme.disabledTextColor
}
2021-03-16 00:02:20 -07:00
Label {
id: location
text: main.location
}
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Size:")
Layout.alignment: Qt.AlignRight
color: FishUI.Theme.disabledTextColor
}
2021-03-16 00:02:20 -07:00
Label {
id: size
text: main.fileSize ? main.fileSize : qsTr("Calculating...")
}
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Created:")
Layout.alignment: Qt.AlignRight
color: FishUI.Theme.disabledTextColor
visible: creationTime.visible
}
2021-03-16 00:02:20 -07:00
Label {
id: creationTime
text: main.creationTime
visible: text
}
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Modified:")
Layout.alignment: Qt.AlignRight
color: FishUI.Theme.disabledTextColor
visible: modifiedTime.visible
}
2021-03-16 00:02:20 -07:00
Label {
id: modifiedTime
text: main.modifiedTime
visible: text
}
2021-03-16 00:02:20 -07:00
Label {
text: qsTr("Accessed:")
Layout.alignment: Qt.AlignRight
color: FishUI.Theme.disabledTextColor
visible: accessTime.visible
2021-03-16 00:02:20 -07:00
}
Label {
id: accessTime
text: main.accessedTime
visible: text
2021-03-16 00:02:20 -07:00
}
}
2021-03-16 00:02:20 -07:00
Item {
height: FishUI.Units.smallSpacing
}
RowLayout {
Layout.alignment: Qt.AlignRight
spacing: FishUI.Units.largeSpacing
Button {
text: qsTr("Cancel")
Layout.fillWidth: true
onClicked: main.reject()
}
2021-03-16 00:02:20 -07:00
Button {
text: qsTr("OK")
Layout.fillWidth: true
onClicked: {
main.accept(_textField.text)
2021-03-16 00:02:20 -07:00
}
flat: true
2021-03-16 00:02:20 -07:00
}
}
}
}