Commit 4bd3bfb4 authored by Devin Lin's avatar Devin Lin 🎨 Committed by Devin Lin
Browse files

Add DialogGallery and switch InfoSheet to use Kirigami.Dialog

parent 7c8b00cb
......@@ -84,6 +84,11 @@ Kirigami.ScrollablePage {
targetPage: "gallery/DrawerGallery.qml"
img: "img/drawers.svg"
}
ListElement {
title: "Dialogs"
targetPage: "gallery/DialogGallery.qml"
img: "img/overlay-sheets.svg"
}
ListElement {
title: "Overlay Sheets"
targetPage: "gallery/OverlaySheetGallery.qml"
......
......@@ -34,7 +34,7 @@ ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -34,7 +34,7 @@ ScrollablePage {
iconName: sheet.sheetOpen ? "dialog-cancel" : "document-edit"
text: "Main Action Text"
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+S"
}
left: Action {
......
......@@ -33,7 +33,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -33,7 +33,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -33,7 +33,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
/*
* Copyright 2021 Devin Lin <espidev@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.18 as Kirigami
import "components"
Kirigami.ScrollablePage {
id: page
Layout.fillWidth: true
//implicitWidth: Units.gridUnit * (Math.floor(Math.random() * 35) + 10)
title: qsTr("Dialogs")
actions.main: Kirigami.Action {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
//Close the drawer with the back button
onBackRequested: {
if (sheet.sheetOpen) {
event.accepted = true;
sheet.close();
}
}
InfoSheet {
id: sheet
page: page
component: "DialogGallery"
}
Kirigami.PromptDialog {
id: promptDialog
title: "Reset settings?"
subtitle: "The stored settings for the application will be deleted, with the defaults restored."
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
onAccepted: showPassiveNotification("Accepted")
onRejected: console.log("Rejected")
}
Kirigami.PromptDialog {
id: textPromptDialog
title: "New Folder"
standardButtons: Kirigami.Dialog.NoButton
customFooterActions: [
Kirigami.Action {
text: qsTr("Create Folder")
iconName: "dialog-ok"
onTriggered: {
showPassiveNotification("Created");
textPromptDialog.close();
}
},
Kirigami.Action {
text: qsTr("Cancel")
iconName: "dialog-cancel"
onTriggered: {
textPromptDialog.close();
}
}
]
Controls.TextField {
placeholderText: qsTr("Folder name...")
}
}
Kirigami.Dialog {
id: selectDialog
title: qsTr("Alarm Snooze Length")
preferredWidth: Kirigami.Units.gridUnit * 16
ColumnLayout {
spacing: 0
Repeater {
model: ListModel {
// we can't use qsTr/i18n with ListElement
Component.onCompleted: {
append({"name": qsTr("1 minute"), "value": 1});
append({"name": qsTr("2 minutes"), "value": 2});
append({"name": qsTr("3 minutes"), "value": 3});
append({"name": qsTr("4 minutes"), "value": 4});
append({"name": qsTr("5 minutes"), "value": 5});
append({"name": qsTr("10 minutes"), "value": 10});
append({"name": qsTr("30 minutes"), "value": 30});
append({"name": qsTr("1 hour"), "value": 60});
}
}
delegate: Controls.RadioDelegate {
Layout.fillWidth: true
topPadding: Kirigami.Units.smallSpacing * 2
bottomPadding: Kirigami.Units.smallSpacing * 2
text: name
checked: value == 1
onCheckedChanged: {
if (checked) {
showPassiveNotification("Selected " + name + " with value " + value);
}
}
}
}
}
}
Kirigami.Dialog {
id: scrollableDialog
title: qsTr("Select Number")
ListView {
id: listView
implicitWidth: Kirigami.Units.gridUnit * 16
implicitHeight: Kirigami.Units.gridUnit * 16
leftMargin: 0; rightMargin: 0; topMargin: 0; bottomMargin: 0;
model: 100
delegate: Controls.RadioDelegate {
topPadding: Kirigami.Units.smallSpacing * 2
bottomPadding: Kirigami.Units.smallSpacing * 2
implicitWidth: listView.width
text: modelData
}
}
}
Kirigami.PromptDialog {
id: noFooterDialog
title: qsTr("No Footer Dialog")
subtitle: qsTr("This dialog has no footer buttons.<br/>It also has no close button.")
standardButtons: Kirigami.Dialog.NoButton
showCloseButton: false
}
Kirigami.MenuDialog {
id: menuDialog
title: qsTr("Track Options")
actions: [
Kirigami.Action {
iconName: "media-playback-start"
text: qsTr("Play", "Start playback of the selected track")
tooltip: qsTr("Start playback of the selected track")
},
Kirigami.Action {
enabled: false
iconName: "document-open-folder"
text: qsTr("Show in folder", "Show the file for this song in the file manager")
tooltip: qsTr("Show the file for this song in the file manager")
},
Kirigami.Action {
iconName: "documentinfo"
text: qsTr("View details", "Show track metadata")
tooltip: qsTr("Show track metadata")
},
Kirigami.Action {
iconName: "list-add"
text: qsTr("Play next", "Add the track to the queue, right after the current track")
tooltip: qsTr("Add the track to the queue, right after the current track")
},
Kirigami.Action {
iconName: "list-add"
text: qsTr("Add to queue", "Enqueue current track")
tooltip: qsTr("Enqueue current track")
}
]
}
ColumnLayout {
width: page.width
spacing: Kirigami.Units.smallSpacing
Controls.Button {
text: qsTr("Prompt Dialog")
Layout.alignment: Qt.AlignHCenter
onClicked: promptDialog.open()
}
Controls.Button {
text: qsTr("Text Prompt Dialog")
Layout.alignment: Qt.AlignHCenter
onClicked: textPromptDialog.open()
}
Controls.Button {
text: qsTr("Selection Dialog")
Layout.alignment: Qt.AlignHCenter
onClicked: selectDialog.open()
}
Controls.Button {
text: qsTr("Scrollable Dialog")
Layout.alignment: Qt.AlignHCenter
onClicked: scrollableDialog.open()
}
Controls.Button {
text: qsTr("No Footer Dialog")
Layout.alignment: Qt.AlignHCenter
onClicked: noFooterDialog.open()
}
Controls.Button {
text: qsTr("Menu Dialog")
Layout.alignment: Qt.AlignHCenter
onClicked: menuDialog.open()
}
}
}
......@@ -34,7 +34,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
contextualActions: [
......
......@@ -14,7 +14,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -34,7 +34,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -32,7 +32,7 @@ Kirigami.ScrollablePage {
iconName: sheet.sheetOpen ? "dialog-cancel" : "document-edit"
text: "Main Action Text"
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
}
}
......
......@@ -34,7 +34,7 @@ Page {
}
text: "Main Action Text"
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
}
}
......
......@@ -35,7 +35,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -30,7 +30,7 @@ Kirigami.ScrollablePage {
iconName: "documentinfo"
text: qsTr("Info")
checkable: true
onCheckedChanged: sheet.sheetOpen = checked;
onCheckedChanged: sheet.visible = checked;
shortcut: "Alt+I"
}
......
......@@ -20,56 +20,44 @@
import QtQuick 2.6
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kirigami 2.18 as Kirigami
import Data 1.0
Kirigami.OverlaySheet {
Kirigami.PromptDialog {
id: root
property Kirigami.Page page
property url higUrl: infoData.higUrl
property url sourceUrl: infoData.sourceUrl
property url apiUrl: infoData.apiUrl
property alias title: titleLabel.text
property alias text: mainText.text
property string text: infoData.text
property alias component: infoData.component
onSheetOpenChanged: page.actions.main.checked = sheetOpen
header: Kirigami.Heading {
id: titleLabel
text: infoData.title
Layout.fillWidth: true
InfoData {
id: infoData
}
title: infoData.title
subtitle: text
preferredWidth: Kirigami.Units.gridUnit * 20
onVisibleChanged: page.actions.main.checked = visible
flatFooterButtons: true
property var info: InfoData {
id: infoData
}
footer: RowLayout {
Item {
Layout.fillWidth: true
}
Controls.ToolButton {
standardButtons: Kirigami.Dialog.NoButton
customFooterActions: [
Kirigami.Action {
text: qsTr("HIG...")
enabled: higUrl != ""
onClicked: Qt.openUrlExternally(higUrl)
}
Controls.ToolButton {
onTriggered: Qt.openUrlExternally(higUrl);
},
Kirigami.Action {
text: qsTr("Source code...")
enabled: sourceUrl != ""
onClicked: Qt.openUrlExternally(sourceUrl)
}
Controls.ToolButton {
onTriggered: Qt.openUrlExternally(sourceUrl)
},
Kirigami.Action {
text: qsTr("API...")
enabled: apiUrl != ""
onClicked: Qt.openUrlExternally(apiUrl)
onTriggered: Qt.openUrlExternally(apiUrl)
}
}
Controls.Label {
id: mainText
text: infoData.text
property int implicitWidth: Kirigami.Units.gridUnit * 25
wrapMode: Text.WordWrap
}
]
}
......@@ -25,6 +25,12 @@
"apiUrl": "https://api.kde.org/frameworks/kirigami/html/classorg_1_1kde_1_1kirigami_1_1OverlayDrawer.html",
"text": "Drawers are bars anchored to an edge of the screen: left, right, top or bottom.<br>On the left edge they should contain controls and settings global for the whole app, and is strongly encouraged to use the default component GlobalDrawer and to have only one instance for the whole application.<br>On the right edge they should have context-dependent actions linked to the current Page. It is strongly suggested to use the default component ContextDrawer for this and to have only one instance for the whole application.<br>Drawers can be modal(default) in which they block input in the rest of the application window, clicking on a darkened out area will dismiss the drawer.<br>Non modal drawers will leave the rest of the application window functional and vertical(left and right edge) drawers will become sidebars.<br>Non modal drawers can also be collapsible, switching from a full vertical sidebar to a more compact vertical toolbar.<br>You can test between different Drawer modes in the \"Global Drawer Mode...\" menu entry in the global drawer of this application running on Desktop systems."
},
"DialogGallery": {
"title": "Dialogs",
"sourceUrl": "https://invent.kde.org/sdk/kirigami-gallery/-/blob/master/src/data/contents/ui/gallery/DialogGallery.qml",
"apiUrl": "https://api.kde.org/frameworks/kirigami/html/classorg_1_1kde_1_1kirigami_1_1Dialog.html",
"text": "Dialogs are a type of a modal that goes over application content, and prompts users with information."
},
"OverlaySheetGallery": {
"title": "Overlay Sheets",
"sourceUrl": "https://invent.kde.org/sdk/kirigami-gallery/-/blob/master/src/data/contents/ui/gallery/OverlaySheetGallery.qml",
......
......@@ -5,6 +5,7 @@
<file alias="contents/ui/gallery/components/InfoSheet.qml">./data/contents/ui/gallery/components/InfoSheet.qml</file>
<file alias="contents/ui/gallery/NonScrollableGallery.qml">./data/contents/ui/gallery/NonScrollableGallery.qml</file>
<file alias="contents/ui/gallery/ButtonGallery.qml">./data/contents/ui/gallery/ButtonGallery.qml</file>
<file alias="contents/ui/gallery/DialogGallery.qml">./data/contents/ui/gallery/DialogGallery.qml</file>
<file alias="contents/ui/gallery/OverlaySheetGallery.qml">./data/contents/ui/gallery/OverlaySheetGallery.qml</file>
<file alias="contents/ui/gallery/DrawerGallery.qml">./data/contents/ui/gallery/DrawerGallery.qml</file>
<file alias="contents/ui/gallery/ProgressBarGallery.qml">./data/contents/ui/gallery/ProgressBarGallery.qml</file>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment