diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ include(ECMQtDeclareLoggingCategory) include(ECMAddQch) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) +include(KDEPackageAppTemplates) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Kirigami2") @@ -119,6 +120,7 @@ add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_subdirectory(src) +add_subdirectory(templates) if (BUILD_EXAMPLES AND NOT STATIC_LIBRARY) add_subdirectory(examples) diff --git a/templates/CMakeLists.txt b/templates/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/templates/CMakeLists.txt @@ -0,0 +1,3 @@ +set(apptemplate_DIRS kirigami) + +kde_package_app_templates(TEMPLATES ${apptemplate_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) diff --git a/templates/kirigami/CMakeLists.txt b/templates/kirigami/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/templates/kirigami/CMakeLists.txt @@ -0,0 +1,34 @@ +project(%{APPNAMELC}) + +cmake_minimum_required(VERSION 3.0) + +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}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(ECMSetupVersion) +include(ECMGenerateHeaders) +include(ECMPoQmTools) + +################# Find dependencies ################# +find_package(Qt5 REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg) +find_package(KF5Kirigami2) +find_package(KF5I18n) + +################# Enable C++11 features for clang and gcc ################# +set(CMAKE_CXX_STANDARD 11) + +################# build and install ################# +add_subdirectory(src) + +install(PROGRAMS org.kde.%{APPNAMELC}.desktop DESTINATION ${KDE_INSTALL_APPDIR}) +install(FILES org.kde.%{APPNAMELC}.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/templates/kirigami/kirigami-app.png b/templates/kirigami/kirigami-app.png new file mode 100644 diff --git a/templates/kirigami/kirigami.kdevtemplate b/templates/kirigami/kirigami.kdevtemplate new file mode 100644 --- /dev/null +++ b/templates/kirigami/kirigami.kdevtemplate @@ -0,0 +1,8 @@ +# KDE Config File +[General] +Name=Kirigami Application +Comment=Touch friendly application using Qt Quick Controls 2 and Kirigami + +Category=Qt/Graphical +Icon=kirigami-app.png +ShowFilesAfterGeneration=src/main.cpp diff --git a/templates/kirigami/org.kde.%{APPNAMELC}.appdata.xml b/templates/kirigami/org.kde.%{APPNAMELC}.appdata.xml new file mode 100644 --- /dev/null +++ b/templates/kirigami/org.kde.%{APPNAMELC}.appdata.xml @@ -0,0 +1,18 @@ + + + org.kde.%{APPNAMELC} + Kirigami Application + A short summary describing what this software is about + A permissive license for this metadata, e.g. "FSFAP" + The license of this software as SPDX string, e.g. "GPL-3+" + The software vendor name, e.g. "ACME Corporation" + +

Multiple paragraphs of long description, describing this software component.

+

You can also use ordered and unordered lists:

+ +

Keep in mind to XML-escape characters, and that this is not HTML markup.

+
+
diff --git a/templates/kirigami/org.kde.%{APPNAMELC}.desktop b/templates/kirigami/org.kde.%{APPNAMELC}.desktop new file mode 100644 --- /dev/null +++ b/templates/kirigami/org.kde.%{APPNAMELC}.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=%{APPNAME} +Comment=%{APPNAME} Kirigami Application +Version=1.0 +Exec=%{APPNAMELC} +MimeType=application/x-%{APPNAMELC}; +Icon=applications-development +Type=Application +Terminal=false +Categories=Qt;KDE; diff --git a/templates/kirigami/src/CMakeLists.txt b/templates/kirigami/src/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/templates/kirigami/src/CMakeLists.txt @@ -0,0 +1,4 @@ +qt5_add_resources(%{APPNAMELC}_SRCS resources.qrc) +add_executable(%{APPNAMELC} main.cpp ${%{APPNAMELC}_SRCS}) +target_link_libraries(%{APPNAMELC} Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::Svg KF5::I18n) +install(TARGETS %{APPNAMELC} ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/templates/kirigami/src/contents/ui/main.qml b/templates/kirigami/src/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/templates/kirigami/src/contents/ui/main.qml @@ -0,0 +1,77 @@ +import QtQuick 2.1 +import org.kde.kirigami 2.4 as Kirigami +import QtQuick.Controls 2.0 as Controls + +Kirigami.ApplicationWindow { + id: root + + title: i18n("%{APPNAME}") + + globalDrawer: Kirigami.GlobalDrawer { + title: i18n("%{APPNAME}") + titleIcon: "applications-graphics" + actions: [ + Kirigami.Action { + text: i18n("View") + iconName: "view-list-icons" + Kirigami.Action { + text: i18n("View Action 1") + onTriggered: showPassiveNotification(i18n("View Action 1 clicked")) + } + Kirigami.Action { + text: i18n("View Action 2") + onTriggered: showPassiveNotification(i18n("View Action 2 clicked")) + } + }, + Kirigami.Action { + text: i18n("Action 1") + onTriggered: showPassiveNotification(i18n("Action 1 clicked")) + }, + Kirigami.Action { + text: i18n("Action 2") + onTriggered: showPassiveNotification(i18n("Action 2 clicked")) + } + ] + } + + contextDrawer: Kirigami.ContextDrawer { + id: contextDrawer + } + + pageStack.initialPage: mainPageComponent + + Component { + id: mainPageComponent + + Kirigami.Page { + title: i18n("%{APPNAME}") + + actions { + main: Kirigami.Action { + iconName: "go-home" + onTriggered: showPassiveNotification(i18n("Main action triggered")) + } + left: Kirigami.Action { + iconName: "go-previous" + onTriggered: showPassiveNotification(i18n("Left action triggered")) + } + right: Kirigami.Action { + iconName: "go-next" + onTriggered: showPassiveNotification(i18n("Right action triggered")) + } + contextualActions: [ + Kirigami.Action { + text: i18n("Contextual Action 1") + iconName: "bookmarks" + onTriggered: showPassiveNotification(i18n("Contextual action 1 clicked")) + }, + Kirigami.Action { + text: i18n("Contextual Action 2") + iconName: "folder" + enabled: false + } + ] + } + } + } +} diff --git a/templates/kirigami/src/main.cpp b/templates/kirigami/src/main.cpp new file mode 100644 --- /dev/null +++ b/templates/kirigami/src/main.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include + +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("%{APPNAME}"); + + 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/templates/kirigami/src/resources.qrc b/templates/kirigami/src/resources.qrc new file mode 100644 --- /dev/null +++ b/templates/kirigami/src/resources.qrc @@ -0,0 +1,5 @@ + + + contents/ui/main.qml + +