Commit 39b87e42 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Add a variable drawer on console page

parent 5509fae0
......@@ -18,6 +18,7 @@
import org.kde.kirigami 2.5 as Kirigami
import QtQuick 2.2
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.5 as QQC2
import QtQml.Models 2.10
import QtQuick.Dialogs 1.0
......@@ -30,6 +31,37 @@ Kirigami.Page {
title: i18n("Calculator")
ListModel { id: itemModel }
// This content is only available in the desktop version of Kalgebra.
// Don't put any information here that can't be accessed by another
// part of Kalgebra.
readonly property Item drawerContent : ColumnLayout {
visible: true
width: 300
Kirigami.AbstractApplicationHeader {
Layout.fillWidth: true
topPadding: Kirigami.Units.smallSpacing
bottomPadding: Kirigami.Units.largeSpacing
leftPadding: Kirigami.Units.smallSpacing
rightPadding: Kirigami.Units.smallSpacing
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
Kirigami.Heading {
level: 1
text: i18n("Variables")
Layout.fillWidth: true
}
}
QQC2.ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
ListView {
model: VariablesModel { variables: App.variables }
delegate: Kirigami.BasicListItem {
label: model.whatsThis
}
}
}
}
Clipboard {
id: clipboard
}
......
......@@ -42,9 +42,21 @@ Kirigami.ApplicationWindow
modal: !rootItem.wideScreen
onModalChanged: drawerOpen = !modal
handleVisible: modal
width: contentItem ? columnWidth : 0
header: Kirigami.AbstractApplicationHeader {
topPadding: Kirigami.Units.smallSpacing
bottomPadding: Kirigami.Units.largeSpacing
leftPadding: Kirigami.Units.smallSpacing
rightPadding: Kirigami.Units.smallSpacing
implicitHeight: Kirigami.Units.gridUnit * 2
Kirigami.Heading {
level: 1
text: i18n("KAlgebra")
Layout.fillWidth: true
}
}
title: "KAlgebra"
titleIcon: "qrc:/kalgebra.svgz"
drawerOpen: true
actions: [
......@@ -93,5 +105,32 @@ Kirigami.ApplicationWindow
]
}
readonly property Component customDrawer: Kirigami.OverlayDrawer {
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge
modal: !rootItem.wideScreen
onModalChanged: drawerOpen = !modal
drawerOpen: true
onContentItemChanged: if (contentItem) {
contentItem.visible = true;
}
width: contentItem ? columnWidth : 0
contentItem: mainPagePool.lastLoadedItem.drawerContent ?? null
handleVisible: mainPagePool.lastLoadedItem.drawerContent !== undefined
}
readonly property Component normalDrawer: Kirigami.ContextDrawer {}
Component.onCompleted: if (Kirigami.Settings.isMobile) {
contextDrawer = normalDrawer.createObject(rootItem);
} else {
contextDrawer = customDrawer.createObject(rootItem);
}
pageStack.initialPage: mainPagePool.loadPage("qrc:/Console.qml")
}
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