commit 499f9a0e18493514edc48567511115929a659f8d Author: Florian RICHER Date: Sun Dec 31 16:43:34 2023 +0100 Initial commit diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e76f894 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.16) +project(tutorial_kirigami2) + +find_package(ECM REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) + +find_package(Qt${QT_MAJOR_VERSION} REQUIRED NO_MODULE COMPONENTS + Core + Quick + Test + Gui + QuickControls2 + Widgets +) + +find_package(KF${QT_MAJOR_VERSION} REQUIRED COMPONENTS + Kirigami2 + I18n + CoreAddons +) + +add_subdirectory(src) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..181a103 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,17 @@ +add_executable(tutorial_kirigami2) + +target_sources(tutorial_kirigami2 PRIVATE + main.cpp + resources.qrc +) + +target_link_libraries(tutorial_kirigami2 + Qt${QT_MAJOR_VERSION}::Quick + Qt${QT_MAJOR_VERSION}::Qml + Qt${QT_MAJOR_VERSION}::Gui + Qt${QT_MAJOR_VERSION}::QuickControls2 + Qt${QT_MAJOR_VERSION}::Widgets + KF${QT_MAJOR_VERSION}::I18n +) + +install(TARGETS tutorial_kirigami2 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) \ No newline at end of file diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml new file mode 100644 index 0000000..e406383 --- /dev/null +++ b/src/contents/ui/main.qml @@ -0,0 +1,26 @@ +// Includes relevant modules used by the QML +import QtQuick 2.15 +import QtQuick.Controls 2.15 as Controls +import QtQuick.Layouts 1.15 +import org.kde.kirigami 2.20 as Kirigami + +// Provides basic features needed for all kirigami applications +Kirigami.ApplicationWindow { + // Unique identifier to reference this object + id: root + + // Window title + // i18nc() makes a string translatable + // and provides additional context for the translators + title: i18nc("@title:window", "Hello World") + + // Set the first page that will be loaded when the app opens + // This can also be set to an id of a Kirigami.Page + pageStack.initialPage: Kirigami.Page { + Controls.Label { + // Center label horizontally and vertically within parent object + anchors.centerIn: parent + text: i18n("Hello World!") + } + } +} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..2261238 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("helloworld"); + QCoreApplication::setOrganizationName(QStringLiteral("KDE")); + QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); + QCoreApplication::setApplicationName(QStringLiteral("Hello World")); + + if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { + QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); + } + + QQmlApplicationEngine engine; + + engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + if (engine.rootObjects().isEmpty()) { + return -1; + } + + return app.exec(); +} diff --git a/src/resources.qrc b/src/resources.qrc new file mode 100644 index 0000000..b2b45f8 --- /dev/null +++ b/src/resources.qrc @@ -0,0 +1,5 @@ + + + contents/ui/main.qml + +