forked from denis/a811
Initial commit
This commit is contained in:
commit
c092149734
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
build/
|
||||
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
35
CMakeLists.txt
Normal file
35
CMakeLists.txt
Normal file
|
|
@ -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)
|
||||
|
||||
27
flake.lock
Normal file
27
flake.lock
Normal file
|
|
@ -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
|
||||
}
|
||||
46
flake.nix
Normal file
46
flake.nix
Normal file
|
|
@ -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"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
19
launch.json
Normal file
19
launch.json
Normal file
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
21
org.kde.tutorial.desktop
Normal file
21
org.kde.tutorial.desktop
Normal file
|
|
@ -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
|
||||
|
||||
31
src/CMakeLists.txt
Normal file
31
src/CMakeLists.txt
Normal file
|
|
@ -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})
|
||||
|
||||
100
src/Main.qml
Normal file
100
src/Main.qml
Normal file
|
|
@ -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!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
35
src/main.cpp
Normal file
35
src/main.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include <KIconTheme>
|
||||
#include <KLocalizedContext>
|
||||
#include <KLocalizedString>
|
||||
#include <QApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickStyle>
|
||||
#include <QUrl>
|
||||
#include <QtQml>
|
||||
|
||||
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();
|
||||
}
|
||||
Loading…
Reference in a new issue