Add setting page and expose about data info

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan 2022-12-13 21:48:47 +01:00
parent b2e83f506c
commit b930114eb0
3 changed files with 73 additions and 1 deletions

View file

@ -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}

View file

@ -17,6 +17,7 @@
#include <KColorSchemeManager>
#include <KLocalizedContext>
#include <KLocalizedString>
#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")));

58
app/qml/Settings.qml Normal file
View file

@ -0,0 +1,58 @@
// SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
// 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)
}
}
}
}
}