Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<!--
|
||||
SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
-->
|
||||
<group name="General">
|
||||
<entry name="someSetting" type="Bool">
|
||||
<label>Some setting description</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
# SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
File=%{APPNAMELC}config.kcfg
|
||||
ClassName=%{APPNAME}Config
|
||||
Mutators=true
|
||||
DefaultValueGetters=true
|
||||
GenerateProperties=true
|
||||
ParentInConstructor=true
|
||||
Singleton=true
|
||||
@@ -0,0 +1,48 @@
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
# SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
|
||||
# Target: static library
|
||||
qt_add_qml_module(%{APPNAMELC}_static
|
||||
STATIC
|
||||
URI org.kde.%{APPNAMELC}
|
||||
VERSION 1.0
|
||||
QML_FILES
|
||||
contents/ui/Main.qml
|
||||
contents/ui/About.qml
|
||||
)
|
||||
|
||||
target_sources(%{APPNAMELC}_static PUBLIC
|
||||
app.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(%{APPNAMELC}_static PUBLIC
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Qml
|
||||
Qt6::Quick
|
||||
Qt6::QuickControls2
|
||||
Qt6::Svg
|
||||
KF6::I18n
|
||||
KF6::CoreAddons
|
||||
KF6::ConfigCore
|
||||
KF6::ConfigGui
|
||||
)
|
||||
target_include_directories(%{APPNAMELC}_static PUBLIC ${CMAKE_BINARY_DIR})
|
||||
|
||||
if (ANDROID)
|
||||
kirigami_package_breeze_icons(ICONS
|
||||
list-add
|
||||
help-about
|
||||
application-exit
|
||||
applications-graphics
|
||||
)
|
||||
else()
|
||||
target_link_libraries(%{APPNAMELC}_static PUBLIC Qt::Widgets)
|
||||
endif()
|
||||
|
||||
kconfig_add_kcfg_files(%{APPNAMELC}_static GENERATE_MOC %{APPNAMELC}config.kcfgc)
|
||||
|
||||
# Target: main executable
|
||||
add_executable(%{APPNAMELC} main.cpp)
|
||||
target_link_libraries(%{APPNAMELC} PUBLIC %{APPNAMELC}_static %{APPNAMELC}_staticplugin)
|
||||
install(TARGETS %{APPNAMELC} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
|
||||
#include "app.h"
|
||||
#include <KSharedConfig>
|
||||
#include <KWindowConfig>
|
||||
#include <QQuickWindow>
|
||||
|
||||
void App::restoreWindowGeometry(QQuickWindow *window, const QString &group) const
|
||||
{
|
||||
KConfig dataResource(QStringLiteral("data"), KConfig::SimpleConfig, QStandardPaths::AppDataLocation);
|
||||
KConfigGroup windowGroup(&dataResource, QStringLiteral("Window-") + group);
|
||||
KWindowConfig::restoreWindowSize(window, windowGroup);
|
||||
KWindowConfig::restoreWindowPosition(window, windowGroup);
|
||||
}
|
||||
|
||||
void App::saveWindowGeometry(QQuickWindow *window, const QString &group) const
|
||||
{
|
||||
KConfig dataResource(QStringLiteral("data"), KConfig::SimpleConfig, QStandardPaths::AppDataLocation);
|
||||
KConfigGroup windowGroup(&dataResource, QStringLiteral("Window-") + group);
|
||||
KWindowConfig::saveWindowPosition(window, windowGroup);
|
||||
KWindowConfig::saveWindowSize(window, windowGroup);
|
||||
dataResource.sync();
|
||||
}
|
||||
|
||||
#include "moc_app.cpp"
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlEngine>
|
||||
|
||||
class QQuickWindow;
|
||||
|
||||
class App : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_SINGLETON
|
||||
|
||||
public:
|
||||
// Restore current window geometry
|
||||
Q_INVOKABLE void restoreWindowGeometry(QQuickWindow *window, const QString &group = QStringLiteral("main")) const;
|
||||
// Save current window geometry
|
||||
Q_INVOKABLE void saveWindowGeometry(QQuickWindow *window, const QString &group = QStringLiteral("main")) const;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
// SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.coreaddons
|
||||
|
||||
FormCard.AboutPage {
|
||||
aboutData: AboutData
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.%{APPNAMELC}
|
||||
|
||||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
|
||||
title: i18n("%{APPNAME}")
|
||||
|
||||
minimumWidth: Kirigami.Units.gridUnit * 20
|
||||
minimumHeight: Kirigami.Units.gridUnit * 20
|
||||
|
||||
onClosing: App.saveWindowGeometry(root)
|
||||
|
||||
onWidthChanged: saveWindowGeometryTimer.restart()
|
||||
onHeightChanged: saveWindowGeometryTimer.restart()
|
||||
onXChanged: saveWindowGeometryTimer.restart()
|
||||
onYChanged: saveWindowGeometryTimer.restart()
|
||||
|
||||
Component.onCompleted: App.restoreWindowGeometry(root)
|
||||
|
||||
// This timer allows to batch update the window size change to reduce
|
||||
// the io load and also work around the fact that x/y/width/height are
|
||||
// changed when loading the page and overwrite the saved geometry from
|
||||
// the previous session.
|
||||
Timer {
|
||||
id: saveWindowGeometryTimer
|
||||
interval: 1000
|
||||
onTriggered: App.saveWindowGeometry(root)
|
||||
}
|
||||
|
||||
property int counter: 0
|
||||
|
||||
globalDrawer: Kirigami.GlobalDrawer {
|
||||
isMenu: !Kirigami.Settings.isMobile
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Plus One")
|
||||
icon.name: "list-add"
|
||||
onTriggered: root.counter += 1
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("About %{APPNAME}")
|
||||
icon.name: "help-about"
|
||||
onTriggered: root.pageStack.pushDialogLayer("qrc:/qt/qml/org/kde/%{APPNAME}/contents/ui/About.qml")
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Quit")
|
||||
icon.name: "application-exit"
|
||||
onTriggered: Qt.quit()
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
contextDrawer: Kirigami.ContextDrawer {
|
||||
id: contextDrawer
|
||||
}
|
||||
|
||||
pageStack.initialPage: page
|
||||
|
||||
Kirigami.Page {
|
||||
id: page
|
||||
|
||||
title: i18n("Main Page")
|
||||
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Plus One")
|
||||
icon.name: "list-add"
|
||||
tooltip: i18n("Add one to the counter")
|
||||
onTriggered: root.counter += 1
|
||||
}
|
||||
]
|
||||
|
||||
ColumnLayout {
|
||||
width: page.width
|
||||
|
||||
anchors.centerIn: parent
|
||||
|
||||
Kirigami.Heading {
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
text: root.counter === 0 ? i18n("Hello, World!") : root.counter
|
||||
}
|
||||
|
||||
QQC2.Button {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: i18n("+ 1")
|
||||
onClicked: root.counter += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
|
||||
*/
|
||||
|
||||
#include <QtGlobal>
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QGuiApplication>
|
||||
#else
|
||||
#include <QApplication>
|
||||
#endif
|
||||
|
||||
#include <QIcon>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickStyle>
|
||||
#include <QUrl>
|
||||
|
||||
#include "app.h"
|
||||
#include "version-%{APPNAMELC}.h"
|
||||
#include <KAboutData>
|
||||
#include <KLocalizedContext>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include "%{APPNAMELC}config.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
Q_DECL_EXPORT
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
QGuiApplication app(argc, argv);
|
||||
QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
|
||||
#else
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// Default to org.kde.desktop style unless the user forces another style
|
||||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
|
||||
QQuickStyle::setStyle(u"org.kde.desktop"_s);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
freopen("CONOUT$", "w", stderr);
|
||||
}
|
||||
|
||||
QApplication::setStyle(QStringLiteral("breeze"));
|
||||
auto font = app.font();
|
||||
font.setPointSize(10);
|
||||
app.setFont(font);
|
||||
#endif
|
||||
|
||||
KLocalizedString::setApplicationDomain("%{APPNAMELC}");
|
||||
QCoreApplication::setOrganizationName(u"KDE"_s);
|
||||
|
||||
KAboutData aboutData(
|
||||
// The program name used internally.
|
||||
u"%{APPNAMELC}"_s,
|
||||
// A displayable program name string.
|
||||
i18nc("@title", "%{APPNAME}"),
|
||||
// The program version string.
|
||||
QStringLiteral(%{APPNAMEUC}_VERSION_STRING),
|
||||
// Short description of what the app does.
|
||||
i18n("Application Description"),
|
||||
// The license this code is released under.
|
||||
KAboutLicense::GPL,
|
||||
// Copyright Statement.
|
||||
i18n("(c) %{CURRENT_YEAR}"));
|
||||
aboutData.addAuthor(i18nc("@info:credit", "%{AUTHOR}"),
|
||||
i18nc("@info:credit", "Maintainer"),
|
||||
u"%{EMAIL}"_s,
|
||||
u"https://yourwebsite.com"_s);
|
||||
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
|
||||
KAboutData::setApplicationData(aboutData);
|
||||
QGuiApplication::setWindowIcon(QIcon::fromTheme(u"org.kde.%{APPNAMELC}"_s));
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
auto config = %{APPNAME}Config::self();
|
||||
|
||||
qmlRegisterSingletonInstance("org.kde.%{APPNAMELC}.private", 1, 0, "Config", config);
|
||||
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
engine.loadFromModule("org.kde.%{APPNAMELC}", u"Main");
|
||||
|
||||
if (engine.rootObjects().isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user