diff --git a/templates/CMakeLists.txt b/templates/CMakeLists.txt --- a/templates/CMakeLists.txt +++ b/templates/CMakeLists.txt @@ -2,6 +2,7 @@ qml-plasmoid qml-plasmoid-with-qml-extension cpp-plasmoid + kcm-qml plasma-wallpaper plasma-wallpaper-with-qml-extension ) diff --git a/templates/kcm-qml/%{APPNAMELC}settings.kcfg b/templates/kcm-qml/%{APPNAMELC}settings.kcfg new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/%{APPNAMELC}settings.kcfg @@ -0,0 +1,13 @@ + + + + + + + An Example String + + + diff --git a/templates/kcm-qml/%{APPNAMELC}settings.kcfgc b/templates/kcm-qml/%{APPNAMELC}settings.kcfgc new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/%{APPNAMELC}settings.kcfgc @@ -0,0 +1,6 @@ +File=%{APPNAMELC}settings.kcfg +ClassName=%{APPNAME}Settings +Mutators=true +DefaultValueGetters=true +GenerateProperties=true +ParentInConstructor=true diff --git a/templates/kcm-qml/CMakeLists.txt b/templates/kcm-qml/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/CMakeLists.txt @@ -0,0 +1,25 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"kcm5_%{APPNAMELC}\") + +set(SRCS_%{APPNAMELC} + kcm.cpp +) +kconfig_add_kcfg_files(SRCS_%{APPNAMELC} %{APPNAMELC}settings.kcfgc GENERATE_MOC) + +add_library(kcm_%{APPNAMELC} MODULE ${SRCS_%{APPNAMELC}}) + +target_link_libraries(kcm_%{APPNAMELC} + KF5::CoreAddons + KF5::KCMUtils + KF5::I18n + KF5::QuickAddons + Qt5::DBus + Qt5::Widgets +) + +kcoreaddons_desktop_to_json(kcm_%{APPNAMELC} "kcm_%{APPNAMELC}.desktop") + +install(FILES %{APPNAMELC}settings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) +install(FILES kcm_%{APPNAMELC}.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) +install(TARGETS kcm_%{APPNAMELC} DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) + +kpackage_install_package(package kcm_%{APPNAMELC} kcms) diff --git a/templates/kcm-qml/Messages.sh b/templates/kcm-qml/Messages.sh new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/Messages.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name "*.ui"` >> rc.cpp || exit 11 +$XGETTEXT `find . -name "*.cpp"` -o $podir/kcm5_%{APPNAMELC}.pot +rm -f rc.cpp diff --git a/templates/kcm-qml/README b/templates/kcm-qml/README new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/README @@ -0,0 +1,20 @@ +Plasma KCM Template +---------------------- + +Create the project folder inside plasma-desktop/kcms and add the name of the folder in the parent CMake + +-- Build instructions -- + +Create the project folder inside plasma-desktop/kcms and add the name of the folder in the parent CMake +then compile normally plasma-desktop. + +test the kcm with +kcmshell5 kcm_KCM_NAME_HERE + + +-- Tutorials and resources -- +The explanation of the template +https://techbase.kde.org/Development/Tutorials/Plasma5/QML2/GettingStarted + +Plasma QML API explained +https://techbase.kde.org/Development/Tutorials/Plasma2/QML2/API diff --git a/templates/kcm-qml/kcm-qml.kdevtemplate b/templates/kcm-qml/kcm-qml.kdevtemplate new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/kcm-qml.kdevtemplate @@ -0,0 +1,7 @@ +# KDE Config File +[General] +Name=KCM Qml Interface + +Comment=Plasma KCM Configuration Template +Category=Plasma/KCM +Icon= diff --git a/templates/kcm-qml/kcm.h b/templates/kcm-qml/kcm.h new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/kcm.h @@ -0,0 +1,39 @@ +/* This file is part of the KDE Project + * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef %{APPNAMEUC}_H +#define %{APPNAMEUC}_H + +#include + +class %{APPNAME}Settings; + +class %{APPNAME} : public KQuickAddons::ManagedConfigModule +{ + Q_OBJECT + Q_PROPERTY(%{APPNAME}Settings *settings MEMBER m_settings CONSTANT) + +public: + %{APPNAME}(QObject* parent, const QVariantList& args); + virtual ~%{APPNAME}() override; + +private: + %{APPNAME}Settings *m_settings; +}; + +#endif diff --git a/templates/kcm-qml/kcm.cpp b/templates/kcm-qml/kcm.cpp new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/kcm.cpp @@ -0,0 +1,51 @@ +/* This file is part of the KDE Project + Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kcm.h" + +#include +#include +#include +#include + +#include "%{APPNAMELC}settings.h" + +K_PLUGIN_FACTORY_WITH_JSON(KCM%{APPNAME}Factory, "kcm_%{APPNAMELC}.json", registerPlugin<%{APPNAME}>();) + +%{APPNAME}::%{APPNAME}(QObject* parent, const QVariantList& args) + : KQuickAddons::ManagedConfigModule(parent, args) + , m_settings(new %{APPNAME}Settings(this)) +{ + qmlRegisterType<%{APPNAME}Settings>(); + + KAboutData* about = new KAboutData( + QStringLiteral("kcm_%{APPNAMELC}"), i18n("%{APPNAME} Configuration Module"), + QStringLiteral("0.1"), QString(), KAboutLicense::GPL, + i18n("Copyright %{CURRENT_YEAR} %{AUTHOR}")); + + about->addAuthor(i18n("%{AUTHOR}"), QString(), QStringLiteral("%{EMAIL}")); + + setAboutData(about); + setButtons(Help | Apply | Default); +} + +%{APPNAME}::~%{APPNAME}() +{ +} + +#include "kcm.moc" diff --git a/templates/kcm-qml/kcm_%{APPNAMELC}.desktop b/templates/kcm-qml/kcm_%{APPNAMELC}.desktop new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/kcm_%{APPNAMELC}.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Exec=kcmshell5 kcm_%{APPNAMELC} +Icon=plasma +Type=Service + +X-KDE-ServiceTypes=KCModule +X-KDE-Library=kcm_%{APPNAMELC} +X-KDE-ParentApp=kcontrol + +X-KDE-System-Settings-Parent-Category=Specify Your Category Here +X-KDE-Weight=10 + +Name=%{APPNAME} +Comment=What your kcm is all about? +X-KDE-Keywords=Colors, Mouse, Monitor diff --git a/templates/kcm-qml/package/contents/ui/main.qml b/templates/kcm-qml/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/package/contents/ui/main.qml @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.11 as QQC2 +import QtQuick.Dialogs 1.2 as QtDialogs +import org.kde.kirigami 2.4 as Kirigami +import org.kde.kcm 1.1 as KCM + +KCM.SimpleKCM { + id: root + + KCM.ConfigModule.quickHelp: i18n("Quick help for the KCM that does nothing..") + ColumnLayout { + anchors.fill: parent + anchors.margins: Kirigami.Units.largeSpacing + + QQC2.Label { + text: i18n("Example KCM that does nothing") + } + + QQC2.TextField { + text: kcm.settings.exampleSetting + onEditingFinished: kcm.settings.exampleSetting = text + enabled: kcm.settings.isImmutable("exampleSetting") + } + } +} diff --git a/templates/kcm-qml/package/metadata.desktop b/templates/kcm-qml/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/templates/kcm-qml/package/metadata.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Name=%{APPNAME} +Comment=what your app does in a few words +Icon=Plasma +Type=Service +X-KDE-PluginInfo-Author=%{AUTHOR} +X-KDE-PluginInfo-Email=%{EMAIL} +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=kcm_%{APPNAMELC} +X-KDE-PluginInfo-Version=%{VERSION} +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Generic +X-Plasma-API=declarativeappletscript + +X-Plasma-MainScript=ui/main.qml +