Commit e33ae373 authored by Janet Blackquill's avatar Janet Blackquill 🌈
Browse files

Mobile support for KISS

parent ea004331
import QtQuick 2.5
import QtQuick.Controls 2.10
import QtQuick.Layouts 1.10
import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.extras 2.0 as PE
import org.kde.plasma.core 2.0 as PlasmaCore
ApplicationWindow {
id: appWindow
visible: true
property string language: ""
property int currentPage: 0
property int oldPage: 0
property bool goingForward: true
onCurrentPageChanged: {
if (oldPage < currentPage) {
goingForward = true
} else {
goingForward = false
}
oldPage = currentPage
staccy.currentItem.apply()
staccy.replace(`qrc:/pages/${KISS.pages[currentPage]}/Page.qml`)
}
Rectangle {
anchors.fill: parent
color: PlasmaCore.ColorScope.backgroundColor
}
ColumnLayout {
anchors.fill: parent
spacing: 0
QtObject {
id: plasmoid
property int location: PlasmaCore.Types.TopEdge
}
PE.PlasmoidHeading {
Layout.leftMargin: -leftInset
Layout.rightMargin: -rightInset
Layout.bottomMargin: -bottomInset
Layout.topMargin: -topInset
Behavior on implicitHeight {
NumberAnimation {
duration: Kirigami.Units.shortDuration
easing.type: Easing.InOutCirc
}
}
contentItem: ColumnLayout {
Kirigami.Heading {
text: staccy.currentItem.title ?? "yeet"
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
}
Kirigami.Heading {
opacity: text !== "" ? 0.7 : 0
Layout.preferredHeight: text !== "" ? -1 : 0
text: staccy.currentItem.description ?? ""
horizontalAlignment: Text.AlignHCenter
level: 4
Behavior on opacity {
NumberAnimation {
duration: Kirigami.Units.shortDuration
easing.type: Easing.InOutCirc
}
}
Layout.fillWidth: true
}
}
}
StackView {
id: staccy
Layout.fillHeight: true
Layout.fillWidth: true
Layout.leftMargin: 1
Layout.rightMargin: 1
Layout.bottomMargin: 1
clip: true
initialItem: `pages/${KISS.pages[0]}/Page.qml`
property real aniFrom: (staccy.mirrored ? -1 : 1) * staccy.width
property real aniTo: (staccy.mirrored ? -1 : 1) * -staccy.width
replaceEnter: Transition {
XAnimator {
from: appWindow.goingForward ? staccy.aniFrom : staccy.aniTo
to: 0
duration: Kirigami.Units.shortDuration
easing.type: Easing.InOutCirc
}
}
replaceExit: Transition {
XAnimator {
from: 0
to: appWindow.goingForward ? staccy.aniTo : staccy.aniFrom
duration: Kirigami.Units.shortDuration
easing.type: Easing.InOutCirc
}
}
}
PE.PlasmoidHeading {
Layout.leftMargin: -leftInset
Layout.rightMargin: -rightInset
Layout.bottomMargin: -bottomInset
Layout.topMargin: -topInset
location: PE.PlasmoidHeading.Footer
contentItem: RowLayout {
Button {
text: "Previous"
visible: appWindow.currentPage > 0
onClicked: appWindow.currentPage--
}
Item {
Layout.fillWidth: true
}
Button {
text: "Next"
visible: (staccy.currentItem.canNext) && (appWindow.currentPage + 1 != KISS.pages.length)
onClicked: appWindow.currentPage++
}
}
}
}
}
<RCC>
<qresource prefix="/">
<file>Main.qml</file>
<file>MobileMain.qml</file>
<!-- User Details Page-->
<file>pages/user/Page.qml</file>
<!-- Locale/Welcome Page-->
......
......@@ -19,7 +19,9 @@ Item {
}
Kirigami.FormLayout {
anchors.centerIn: parent
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
TextField {
id: name
......
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickStyle>
#include "KISS.h"
......@@ -12,8 +13,21 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QScopedPointer<KISS> kiss(new KISS);
QCommandLineParser parser;
QCommandLineOption mobileOpt("m", "mobile");
parser.addOption(mobileOpt);
parser.process(app);
QUrl url;
if (parser.isSet(mobileOpt)) {
url = QStringLiteral("qrc:/MobileMain.qml");
QQuickStyle::setStyle("plasma");
} else {
url = QStringLiteral("qrc:/Main.qml");
QQuickStyle::setStyle("org.kde.desktop");
}
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/Main.qml"));
engine.rootContext()->setContextProperty("KISS", kiss.data());
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated,
......
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