From b930114eb03a37a6d6ec07366298e8d8e23b3f59 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 13 Dec 2022 21:48:47 +0100 Subject: [PATCH] Add setting page and expose about data info Signed-off-by: Carl Schwan --- app/CMakeLists.txt | 7 ++++++ app/main.cpp | 9 ++++++- app/qml/Settings.qml | 58 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/qml/Settings.qml diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index eee6d3784..8ed923ae8 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -2,6 +2,11 @@ qt5_add_resources(kdeconnect_SRCS resources.qrc) qt5_add_resources(kdeconnect_custom_icons_SRCS ${CMAKE_SOURCE_DIR}/icons/custom_icons.qrc) +ecm_setup_version(${PROJECT_VERSION} + VARIABLE_PREFIX KDE_CONNECT + VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/kdeconnect-version.h +) + if (WIN32) include(ECMAddAppIcon) ecm_add_app_icon(kdeconnect_SRCS ICONS @@ -17,6 +22,8 @@ if (WIN32) ) endif() +ecm_find_qmlmodule(org.kde.kirigamiaddons.labs.mobileform 0.1) + add_executable(kdeconnect-app main.cpp ${kdeconnect_SRCS} diff --git a/app/main.cpp b/app/main.cpp index 59f04ed21..2a8fcb2e4 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "kdeconnect-version.h" int main(int argc, char *argv[]) { @@ -25,14 +26,16 @@ int main(int argc, char *argv[]) QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("kdeconnect-app"); app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect"))); KAboutData aboutData(QStringLiteral("kdeconnect.app"), i18n("KDE Connect"), - QStringLiteral("1.0"), + QStringLiteral(KDE_CONNECT_VERSION_STRING), i18n("KDE Connect"), KAboutLicense::GPL, i18n("(c) 2015, Aleix Pol Gonzalez")); aboutData.addAuthor(i18n("Aleix Pol Gonzalez"), i18n("Maintainer"), QStringLiteral("aleixpol@kde.org")); + aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails")); KAboutData::setApplicationData(aboutData); #ifdef Q_OS_WIN @@ -63,6 +66,10 @@ int main(int argc, char *argv[]) } } + qmlRegisterSingletonType("org.kde.kdeconnect.app", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { + return engine->toScriptValue(KAboutData::applicationData()); + }); + QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); diff --git a/app/qml/Settings.qml b/app/qml/Settings.qml new file mode 100644 index 000000000..713eeb5dd --- /dev/null +++ b/app/qml/Settings.qml @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: 2022 Carl Schwan +// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL + +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import org.kde.kirigami 2.20 as Kirigami +import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm +import org.kde.kdeconnect 1.0 +import org.kde.kdeconnect.app 1.0 + +Kirigami.ScrollablePage { + title: i18nc("@title:window", "Settings") + + leftPadding: 0 + rightPadding: 0 + + ColumnLayout { + MobileForm.FormCard { + Layout.topMargin: Kirigami.Units.largeSpacing + Layout.fillWidth: true + contentItem: ColumnLayout { + spacing: 0 + + DBusProperty { + id: announcedNameProperty + object: DaemonDbusInterface + read: "announcedName" + defaultValue: "" + } + + MobileForm.FormTextFieldDelegate { + text: announcedNameProperty.value + onAccepted: DaemonDbusInterface.setAnnouncedName(text); + label: i18n("Device name") + } + } + } + + MobileForm.FormCard { + Layout.topMargin: Kirigami.Units.largeSpacing + Layout.fillWidth: true + contentItem: ColumnLayout { + spacing: 0 + Component { + id: aboutPage + MobileForm.AboutPage { + aboutData: About + } + } + MobileForm.FormButtonDelegate { + text: i18n("About KDE Connect") + onClicked: applicationWindow().pageStack.layers.push(aboutPage) + } + } + } + } +}