Commit faf6ee52 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Initialize prototype application that could be used as a base for an address...

Initialize prototype application that could be used as a base for an address book or any similar application that displays a list of cards.
parents
project(kirigami-tutorial)
cmake_minimum_required(VERSION 2.8.12)
set(KF5_MIN_VERSION "5.18.0")
set(QT_MIN_VERSION "5.5.0")
################# Disallow in-source build #################
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "This application requires an out of source build. Please create a separate build directory.")
endif()
include(FeatureSummary)
################# set KDE specific information #################
find_package(ECM 0.0.8 REQUIRED NO_MODULE)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(ECMPoQmTools)
include(KDECompilerSettings NO_POLICY_SCOPE)
################# Find dependencies #################
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2)
find_package(KF5Kirigami2 ${KF5_MIN_VERSION})
################# Enable C++11 features for clang and gcc #################
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x")
endif()
################# build and install #################
add_subdirectory(src)
install(PROGRAMS org.kde.kirigami-tutorial.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES org.kde.kirigami-tutorial.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
# kirigami-tutorial
Prototype application to be used in application development tutorials in https://docs.plasma-mobile.org/
<?xml version="1.0" encoding="utf-8"?>
<component type="desktop-application">
<id>org.kde.kirigami-tutorial</id>
<name>Kirigami Example Application</name>
<summary>A short summary describing what this software is about</summary>
<metadata_license>A permissive license for this metadata, e.g. "FSFAP"</metadata_license>
<project_license>The license of this software as SPDX string, e.g. "GPL-3+"</project_license>
<developer_name>The software vendor name, e.g. "ACME Corporation"</developer_name>
<description>
<p>Multiple paragraphs of long description, describing this software component.</p>
<p>You can also use ordered and unordered lists:</p>
<ul>
<li>Feature 1</li>
<li>Feature 2</li>
</ul>
<p>Keep in mind to XML-escape characters, and that this is not HTML markup.</p>
</description>
</component>
[Desktop Entry]
Name=KirigamiTutorial
Comment=Kirigami Tutorial
Version=1.0
Exec=kirigami-tutorial
MimeType=application/x-kirigami-tutorial;
Icon=applications-development
Type=Application
Terminal=false
Categories=Qt;KDE;
{
"id": "org.kde.kirigami-tutorial",
"runtime": "org.kde.Platform",
"runtime-version": "5.12",
"sdk": "org.kde.Sdk",
"command": "kirigami-tutorial",
"tags": ["nightly"],
"desktop-file-name-suffix": " (Nightly)",
"finish-args": [
"--share=ipc",
"--share=network",
"--socket=x11",
"--socket=wayland",
"--device=dri",
"--filesystem=home",
"--talk-name=org.freedesktop.Notifications"
],
"separate-locales": false,
"modules": [
{
"name": "kirigami-tutorial",
"buildsystem": "cmake-ninja",
"builddir": true,
"sources": [ { "type": "dir", "path": ".", "skip": [".git"] } ]
}
]
}
set(kirigami-tutorial_SRCS
main.cpp
)
qt5_add_resources(RESOURCES resources.qrc)
add_executable(kirigami-tutorial ${kirigami-tutorial_SRCS} ${RESOURCES})
target_link_libraries(kirigami-tutorial Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg)
install(TARGETS kirigami-tutorial ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
import QtQuick 2.1
import org.kde.kirigami 2.4 as Kirigami
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.11 as Layouts
Kirigami.ApplicationWindow {
id: root
title: "Kirigami Tutorial"
pageStack.initialPage: mainPageComponent
Component {
id: mainPageComponent
Kirigami.ScrollablePage {
title: "Address book (prototype)"
Component {
id: card
Kirigami.Card {
banner {
title: model.firstname + " " + model.lastname
source: model.photo
}
contentItem: Layouts.ColumnLayout {
Controls.Label {
wrapMode: Text.WordWrap
text: "Mobile: " + model.cellphone
}
Controls.Label {
wrapMode: Text.WordWrap
text: "Email: " + model.email
}
}
actions: [
Kirigami.Action {
text: "Call"
icon.name: "call-start"
onTriggered: { showPassiveNotification("Calling " + model.firstname + " " + model.lastname + " ...") }
}
]
}
}
Layouts.ColumnLayout {
Kirigami.CardsLayout {
id: view
Repeater {
model: ListModel {
id: mainModel
}
delegate: card
}
}
}
Component.onCompleted: {
mainModel.append({"firstname": "Pablo", "lastname": "Doe", "cellphone": "6300000002", "email" : "jane-doe@example.com", "photo": "qrc:/konqi.jpg"});
mainModel.append({"firstname": "Paul", "lastname": "Adams", "cellphone": "6300000003", "email" : "paul-adams@example.com", "photo": "qrc:/katie.jpg"});
mainModel.append({"firstname": "John", "lastname": "Doe", "cellphone": "6300000001", "email" : "john-doe@example.com", "photo": "qrc:/konqi.jpg"});
mainModel.append({"firstname": "Ken", "lastname": "Brown", "cellphone": "6300000004", "email" : "ken-brown@example.com", "photo": "qrc:/konqi.jpg"});
mainModel.append({"firstname": "Al", "lastname": "Anderson", "cellphone": "6300000005", "email" : "al-anderson@example.com", "photo": "qrc:/katie.jpg"});
mainModel.append({"firstname": "Kate", "lastname": "Adams", "cellphone": "6300000005", "email" : "kate-adams@example.com", "photo": "qrc:/konqi.jpg"});
}
}
}
}
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QUrl>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("KDE");
QCoreApplication::setOrganizationDomain("kde.org");
QCoreApplication::setApplicationName("Kirigami Tutorial");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
if (engine.rootObjects().isEmpty()) {
return -1;
}
int ret = app.exec();
return ret;
}
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
<file alias="konqi.jpg">contents/ui/konqi.jpg</file>
<file alias="katie.jpg">contents/ui/katie.jpg</file>
</qresource>
</RCC>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment