Initial commit

This commit is contained in:
Florian RICHER 2023-12-31 16:43:34 +01:00
commit 499f9a0e18
5 changed files with 107 additions and 0 deletions

28
CMakeLists.txt Normal file
View file

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

17
src/CMakeLists.txt Normal file
View file

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

26
src/contents/ui/main.qml Normal file
View file

@ -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!")
}
}
}

31
src/main.cpp Normal file
View file

@ -0,0 +1,31 @@
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QUrl>
#include <QQuickStyle>
#include <KLocalizedContext>
#include <KLocalizedString>
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();
}

5
src/resources.qrc Normal file
View file

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
</qresource>
</RCC>