commit c092149734dc3e2e7887ef9fff5fb1f981593dea Author: Denis Manherz Date: Sun Aug 25 21:06:01 2024 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f317667 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "debug", + "type": "lldb", + "request": "launch", + "program":"./build/bin/kirigami-hello", + "cwd":"$workspaceRoot", + "preRunCommands": [ + "echo a", + "cmake -B build", + "cmake --build build" + ] + } + ], +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..379e22e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.20) +project(kirigami-tutorial) + +find_package(ECM 6.0.0 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(ECMFindQmlModule) +include(ECMQmlModule) + +find_package(Qt6 REQUIRED COMPONENTS + Core + Quick + Test + Gui + QuickControls2 + Widgets +) + +find_package(KF6 REQUIRED COMPONENTS + Kirigami + I18n + CoreAddons + QQC2DesktopStyle + IconThemes +) + +add_subdirectory(src) + +install(PROGRAMS org.kde.tutorial.desktop DESTINATION ${KDE_INSTALL_APPDIR}) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..af6aa81 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1724224976, + "narHash": "sha256-Z/ELQhrSd7bMzTO8r7NZgi9g5emh+aRKoCdaAv5fiO0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c374d94f1536013ca8e92341b540eba4c22f9c62", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9688c2c --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + outputs = { + self, + nixpkgs, + }: let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + in { + devShells.x86_64-linux = { + default = pkgs.mkShell { + propagatedBuildInputs = with pkgs; [ + bashInteractive + cmake + gcc + gdb + kdePackages.extra-cmake-modules + kdePackages.kcoreaddons + kdePackages.ki18n + kdePackages.kiconthemes + kdePackages.kirigami-addons.dev + kdePackages.kirigami + kdePackages.qqc2-desktop-style + kdePackages.qtbase.dev + kdePackages.qtdeclarative + kdePackages.qttools.dev + makeWrapper + pkg-config + qt6.wrapQtAppsHook + qtcreator + qt6.full + ]; + # This creates the proper qt env so that plugins are found right. + shellHook = '' + setQtEnvironment=$(mktemp --suffix .setQtEnvironment.sh) + echo "shellHook: setQtEnvironment = $setQtEnvironment" + makeWrapper "/bin/sh" "$setQtEnvironment" "''${qtWrapperArgs[@]}" + sed "/^exec/d" -i "$setQtEnvironment" + source "$setQtEnvironment" + ''; + }; + }; + }; +} diff --git a/launch.json b/launch.json new file mode 100644 index 0000000..3402a77 --- /dev/null +++ b/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "debug", + "type": "lldb", + "request": "launch", + "program":"./build/bin/kirigami-hello", + "cwd":"$workspaceRoot", + "preRunCommands": [ + "cmake -B build", + "cmake --build build" + ] + } + ], +} \ No newline at end of file diff --git a/org.kde.tutorial.desktop b/org.kde.tutorial.desktop new file mode 100644 index 0000000..7951d4d --- /dev/null +++ b/org.kde.tutorial.desktop @@ -0,0 +1,21 @@ +[Desktop Entry] +Name=Kirigami Tutorial +Name[ca]=Guia d'aprenentatge del Kirigami +Name[cs]=Tutoriál Kirigami +Name[eo]=Lernilo pri Kirigami +Name[es]=Tutorial de Kirigami +Name[fr]=Tutoriel pour Kirigami +Name[it]=Esercitazione di Kirigami +Name[nl]=Kirigami handleiding +Name[sl]=Učbenik Kirigami +Name[sv]=Kirigami-handledning +Name[tr]=Kirigami Öğreticisi +Name[uk]=Підручник з Kirigami +Name[x-test]=xxKirigami Tutorialxx +Name[zh_TW]=Kirigami 教學 +Exec=kirigami-hello +Icon=kde +Type=Application +Terminal=false +Categories=Utility + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..4f97a9e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,31 @@ +add_executable(kirigami-hello) + +ecm_add_qml_module(kirigami-hello + URI + org.kde.tutorial +) + +target_sources(kirigami-hello + PRIVATE + main.cpp +) + +ecm_target_qml_sources(kirigami-hello + SOURCES + Main.qml +) + +target_link_libraries(kirigami-hello + PRIVATE + Qt6::Quick + Qt6::Qml + Qt6::Gui + Qt6::QuickControls2 + Qt6::Widgets + KF6::I18n + KF6::CoreAddons + KF6::IconThemes +) + +install(TARGETS kirigami-hello ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + diff --git a/src/Main.qml b/src/Main.qml new file mode 100644 index 0000000..23d3f43 --- /dev/null +++ b/src/Main.qml @@ -0,0 +1,100 @@ +// Includes relevant modules used by the QML +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls as Controls +import org.kde.kirigami as Kirigami + +// Provides basic features needed for all kirigami applications +Kirigami.ApplicationWindow { + // Unique identifier to reference this object + id: root + + width: 400 + height: 300 + + // 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!") + } + } + Kirigami.CardsListView { + id: cardsView + model: kountdownModel + delegate: kountdownDelegate + } + ListModel { + id: kountdownModel + // Each ListElement is an element on the list, containing information + ListElement { + name: "Dog birthday!!" + description: "Big doggo birthday blowout." + date: 100 + } + } +Component { + id: kountdownDelegate + Kirigami.AbstractCard { + contentItem: Item { + // implicitWidth/Height define the natural width/height + // of an item if no width or height is specified. + // The setting below defines a component's preferred size based on its content + implicitWidth: delegateLayout.implicitWidth + implicitHeight: delegateLayout.implicitHeight + GridLayout { + id: delegateLayout + anchors { + left: parent.left + top: parent.top + right: parent.right + } + rowSpacing: Kirigami.Units.largeSpacing + columnSpacing: Kirigami.Units.largeSpacing + columns: root.wideScreen ? 4 : 2 + + Kirigami.Heading { + Layout.fillHeight: true + level: 1 + text: date + } + + ColumnLayout { + Kirigami.Heading { + Layout.fillWidth: true + level: 2 + text: name + } + Kirigami.Separator { + Layout.fillWidth: true + visible: description.length > 0 + } + Controls.Label { + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: description + visible: description.length > 0 + } + } + Controls.Button { + Layout.alignment: Qt.AlignRight + Layout.columnSpan: 2 + text: i18n("Edit") + // onClicked: to be done... soon! + } + } + } + } + } + + + +} + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0531e04 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + KIconTheme::initTheme(); // this is not available in nixpkgs version of + // KiconTheme + QApplication app(argc, argv); + KLocalizedString::setApplicationDomain("tutorial"); + QApplication::setOrganizationName(QStringLiteral("KDE")); + QApplication::setOrganizationDomain(QStringLiteral("kde.org")); + QApplication::setApplicationName(QStringLiteral("Kirigami Tutorial")); + QApplication::setDesktopFileName(QStringLiteral("org.kde.tutorial")); + + QApplication::setStyle(QStringLiteral("breeze")); + if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { + QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); + } + + QQmlApplicationEngine engine; + + engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); + engine.loadFromModule("org.kde.tutorial", "Main"); + + if (engine.rootObjects().isEmpty()) { + return -1; + } + + return app.exec(); +}