From 98e64e01a611cb0e52c15470b06fa81780905b7d Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 26 Feb 2018 07:11:54 +0100 Subject: [PATCH] Templates: consistent naming, fix translation catalog names & more Summary: * remove unneeded cmake includes * consistently use org.kde.plasma.* prefix for names * fix catalog names to match applet identifier * bump min cmake version to 3.0 * remove duplicated X-KDE-PluginInfo-Name entries * remove no longer (Plasma >=5.8) needed i18nd in wallpaper code * prepare qml extension for ki18n usage Reviewers: mart Reviewed By: mart Subscribers: kde-frameworks-devel, apol Tags: #frameworks Differential Revision: https://phabricator.kde.org/D10848 --- templates/cpp-plasmoid/CMakeLists.txt | 10 ++++------ templates/cpp-plasmoid/Messages.sh | 3 +-- templates/cpp-plasmoid/README | 17 +++++++++++++++++ templates/cpp-plasmoid/src/CMakeLists.txt | 5 +++-- .../cpp-plasmoid/src/package/metadata.desktop | 3 +-- .../CMakeLists.txt | 1 + .../plasma-wallpaper-with-qml-extension/README | 17 +++++++++++++++++ templates/plasma-wallpaper/CMakeLists.txt | 3 ++- templates/plasma-wallpaper/README | 17 +++++++++++++++++ .../package/contents/ui/main.qml | 3 +-- .../CMakeLists.txt | 8 ++++++-- .../qml-plasmoid-with-qml-extension/Messages.sh | 2 +- .../qml-plasmoid-with-qml-extension/README | 17 +++++++++++++++++ .../package/metadata.desktop | 3 +-- .../plugin/%{APPNAMELC}plugin.cpp | 5 ++++- .../plugin/CMakeLists.txt | 3 +++ templates/qml-plasmoid/CMakeLists.txt | 5 +++-- templates/qml-plasmoid/Messages.sh | 2 +- templates/qml-plasmoid/README | 17 +++++++++++++++++ templates/qml-plasmoid/package/metadata.desktop | 3 +-- 20 files changed, 118 insertions(+), 26 deletions(-) diff --git a/templates/cpp-plasmoid/CMakeLists.txt b/templates/cpp-plasmoid/CMakeLists.txt index c6881d4e4..f63e36333 100644 --- a/templates/cpp-plasmoid/CMakeLists.txt +++ b/templates/cpp-plasmoid/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.0) project(plasma-%{APPNAMELC}) @@ -8,20 +8,18 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) -include(ECMInstallIcons) -include(ECMMarkAsTest) -include(ECMMarkNonGuiExecutable) include(FeatureSummary) -include(CheckIncludeFiles) find_package(KF5 REQUIRED COMPONENTS Plasma I18n ) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS +find_package(Qt5 CONFIG REQUIRED COMPONENTS Quick Core ) add_subdirectory(src) + +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/templates/cpp-plasmoid/Messages.sh b/templates/cpp-plasmoid/Messages.sh index 2f6056b84..8bfc20562 100644 --- a/templates/cpp-plasmoid/Messages.sh +++ b/templates/cpp-plasmoid/Messages.sh @@ -1,3 +1,2 @@ #! /usr/bin/env bash -$XGETTEXT `find . -name \*.qml` -o $podir/plasma_applet_%{APPNAMELC}.pot -$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_%{APPNAMELC}.pot +$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.%{APPNAMELC}.pot diff --git a/templates/cpp-plasmoid/README b/templates/cpp-plasmoid/README index 2985196f9..05724a598 100644 --- a/templates/cpp-plasmoid/README +++ b/templates/cpp-plasmoid/README @@ -1,6 +1,23 @@ Plasma Applet mixed C++/QML Template ---------------------- +-- Namespace adaption -- + +Each Plasma plugin has a unique identifier, which is also used to find related +resources (like the translation catalogs). +To avoid naming collisions, Plasma plugins use a reverse domain name notation +for that identifier: + +* org.kde.plasma.* - plugins coming from Plasma modules +* org.kde.* - plugins coming from other software from KDE +* $(my.domain).* - plugins of your 3rd-party + +The generated code uses the "org.kde.plasma" namespace for the plugin identifier. +As this namespace is reserved for use by plugins part of Plasma modules, you will +need to adapt this namespace if you are writing a plugin which is not intended to +end up in the Plasma modules. + + -- Build instructions -- cd /where/your/applet/is/generated diff --git a/templates/cpp-plasmoid/src/CMakeLists.txt b/templates/cpp-plasmoid/src/CMakeLists.txt index 36ab39dd6..548e77732 100644 --- a/templates/cpp-plasmoid/src/CMakeLists.txt +++ b/templates/cpp-plasmoid/src/CMakeLists.txt @@ -1,4 +1,5 @@ -add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.%{APPNAMELC}\") +# TODO: adapt "org.kde.plasma" here & elsewhere if needed (see README) +add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.%{APPNAMELC}\") set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp @@ -16,4 +17,4 @@ target_link_libraries(plasma_applet_%{APPNAMELC} install(TARGETS plasma_applet_%{APPNAMELC} DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) -plasma_install_package(package org.kde.%{APPNAMELC}) +plasma_install_package(package org.kde.plasma.%{APPNAMELC}) diff --git a/templates/cpp-plasmoid/src/package/metadata.desktop b/templates/cpp-plasmoid/src/package/metadata.desktop index 2e4dab9e1..852b16786 100644 --- a/templates/cpp-plasmoid/src/package/metadata.desktop +++ b/templates/cpp-plasmoid/src/package/metadata.desktop @@ -85,14 +85,13 @@ X-KDE-Library=plasma_applet_%{APPNAMELC} X-KDE-PluginInfo-Author=%{AUTHOR} X-KDE-PluginInfo-Email=%{EMAIL} -X-KDE-PluginInfo-Name=%{APPNAMELC} +X-KDE-PluginInfo-Name=org.kde.plasma.%{APPNAMELC} X-KDE-PluginInfo-Version=1.0 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-Category=Utilities X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=org.kde.%{APPNAMELC} X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml diff --git a/templates/plasma-wallpaper-with-qml-extension/CMakeLists.txt b/templates/plasma-wallpaper-with-qml-extension/CMakeLists.txt index 52940e531..3830662a8 100644 --- a/templates/plasma-wallpaper-with-qml-extension/CMakeLists.txt +++ b/templates/plasma-wallpaper-with-qml-extension/CMakeLists.txt @@ -22,6 +22,7 @@ find_package(Qt5 CONFIG REQUIRED COMPONENTS ) # wallpaper applet +# TODO: adapt "org.kde.plasma" here & elsewhere if needed (see README) plasma_install_package(package org.kde.plasma.%{APPNAMELC} wallpapers wallpaper) # qml extension plugin diff --git a/templates/plasma-wallpaper-with-qml-extension/README b/templates/plasma-wallpaper-with-qml-extension/README index e6c4ed0cd..a130ef27c 100644 --- a/templates/plasma-wallpaper-with-qml-extension/README +++ b/templates/plasma-wallpaper-with-qml-extension/README @@ -1,6 +1,23 @@ Plasma Wallpaper Template ---------------------- +-- Namespace adaption -- + +Each Plasma plugin has a unique identifier, which is also used to find related +resources (like the translation catalogs). +To avoid naming collisions, Plasma plugins use a reverse domain name notation +for that identifier: + +* org.kde.plasma.* - plugins coming from Plasma modules +* org.kde.* - plugins coming from other software from KDE +* $(my.domain).* - plugins of your 3rd-party + +The generated code uses the "org.kde.plasma" namespace for the plugin identifier. +As this namespace is reserved for use by plugins part of Plasma modules, you will +need to adapt this namespace if you are writing a plugin which is not intended to +end up in the Plasma modules. + + -- Build instructions -- cd /where/your/wallpaper/is/generated diff --git a/templates/plasma-wallpaper/CMakeLists.txt b/templates/plasma-wallpaper/CMakeLists.txt index ff772e51e..1b9957dfc 100644 --- a/templates/plasma-wallpaper/CMakeLists.txt +++ b/templates/plasma-wallpaper/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.0) project(plasma-%{APPNAMELC}) @@ -7,4 +7,5 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) find_package(KF5Plasma REQUIRED) +# TODO: adapt "org.kde.plasma" here & elsewhere if needed (see README) plasma_install_package(package org.kde.plasma.%{APPNAMELC} wallpapers wallpaper) diff --git a/templates/plasma-wallpaper/README b/templates/plasma-wallpaper/README index e6c4ed0cd..a130ef27c 100644 --- a/templates/plasma-wallpaper/README +++ b/templates/plasma-wallpaper/README @@ -1,6 +1,23 @@ Plasma Wallpaper Template ---------------------- +-- Namespace adaption -- + +Each Plasma plugin has a unique identifier, which is also used to find related +resources (like the translation catalogs). +To avoid naming collisions, Plasma plugins use a reverse domain name notation +for that identifier: + +* org.kde.plasma.* - plugins coming from Plasma modules +* org.kde.* - plugins coming from other software from KDE +* $(my.domain).* - plugins of your 3rd-party + +The generated code uses the "org.kde.plasma" namespace for the plugin identifier. +As this namespace is reserved for use by plugins part of Plasma modules, you will +need to adapt this namespace if you are writing a plugin which is not intended to +end up in the Plasma modules. + + -- Build instructions -- cd /where/your/wallpaper/is/generated diff --git a/templates/plasma-wallpaper/package/contents/ui/main.qml b/templates/plasma-wallpaper/package/contents/ui/main.qml index 30d9743ae..ae12574aa 100644 --- a/templates/plasma-wallpaper/package/contents/ui/main.qml +++ b/templates/plasma-wallpaper/package/contents/ui/main.qml @@ -32,8 +32,7 @@ Item { PlasmaExtras.Title { anchors.centerIn: parent - // use i18nd in wallpaper QML, as the default textdomain is not setup at least in Plasma 5.7 text: wallpaper.configuration.DisplayText || - i18nd("plasma_wallpaper_org.kde.plasma.%{APPNAMELC}", "") + i18n("") } } diff --git a/templates/qml-plasmoid-with-qml-extension/CMakeLists.txt b/templates/qml-plasmoid-with-qml-extension/CMakeLists.txt index 3969d9b7c..ba0ff4aa9 100644 --- a/templates/qml-plasmoid-with-qml-extension/CMakeLists.txt +++ b/templates/qml-plasmoid-with-qml-extension/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.0) project(plasma-%{APPNAMELC}) @@ -8,6 +8,7 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) +include(FeatureSummary) find_package(KF5 REQUIRED COMPONENTS Plasma @@ -21,7 +22,10 @@ find_package(Qt5 CONFIG REQUIRED COMPONENTS ) # plasmoid -plasma_install_package(package org.kde.%{APPNAMELC}) +# TODO: adapt "org.kde.plasma" here & elsewhere if needed (see README) +plasma_install_package(package org.kde.plasma.%{APPNAMELC}) # qml extension plugin add_subdirectory(plugin) + +feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/templates/qml-plasmoid-with-qml-extension/Messages.sh b/templates/qml-plasmoid-with-qml-extension/Messages.sh index b8af9a77e..a8a1548aa 100644 --- a/templates/qml-plasmoid-with-qml-extension/Messages.sh +++ b/templates/qml-plasmoid-with-qml-extension/Messages.sh @@ -1,2 +1,2 @@ #! /usr/bin/env bash -$XGETTEXT `find . -name \*.qml` -o $podir/plasma_applet_%{APPNAMELC}.pot \ No newline at end of file +$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.%{APPNAMELC}.pot diff --git a/templates/qml-plasmoid-with-qml-extension/README b/templates/qml-plasmoid-with-qml-extension/README index 727fa943b..8d1e5d72d 100644 --- a/templates/qml-plasmoid-with-qml-extension/README +++ b/templates/qml-plasmoid-with-qml-extension/README @@ -1,6 +1,23 @@ Plasma Applet Template ---------------------- +-- Namespace adaption -- + +Each Plasma plugin has a unique identifier, which is also used to find related +resources (like the translation catalogs). +To avoid naming collisions, Plasma plugins use a reverse domain name notation +for that identifier: + +* org.kde.plasma.* - plugins coming from Plasma modules +* org.kde.* - plugins coming from other software from KDE +* $(my.domain).* - plugins of your 3rd-party + +The generated code uses the "org.kde.plasma" namespace for the plugin identifier. +As this namespace is reserved for use by plugins part of Plasma modules, you will +need to adapt this namespace if you are writing a plugin which is not intended to +end up in the Plasma modules. + + -- Build instructions -- cd /where/your/applet/is/generated diff --git a/templates/qml-plasmoid-with-qml-extension/package/metadata.desktop b/templates/qml-plasmoid-with-qml-extension/package/metadata.desktop index 314696d92..925dd84a6 100644 --- a/templates/qml-plasmoid-with-qml-extension/package/metadata.desktop +++ b/templates/qml-plasmoid-with-qml-extension/package/metadata.desktop @@ -83,14 +83,13 @@ X-KDE-ServiceTypes=Plasma/Applet X-KDE-PluginInfo-Author=%{AUTHOR} X-KDE-PluginInfo-Email=%{EMAIL} -X-KDE-PluginInfo-Name=%{APPNAMELC} +X-KDE-PluginInfo-Name=org.kde.plasma.%{APPNAMELC} X-KDE-PluginInfo-Version=1.0 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-Category=Utilities X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=org.kde.%{APPNAMELC} X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml diff --git a/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp b/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp index dfd85ae4a..b60e768b2 100644 --- a/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp +++ b/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp @@ -18,6 +18,9 @@ #include "%{APPNAMELC}plugin.h" +// KF +#include +// Qt #include #include #include @@ -27,7 +30,7 @@ static QJSValue singletonTypeExampleProvider(QQmlEngine* engine, QJSEngine* scri Q_UNUSED(engine) QJSValue helloWorld = scriptEngine->newObject(); - helloWorld.setProperty("text", QStringLiteral("Hello world!")); + helloWorld.setProperty("text", i18n("Hello world!")); return helloWorld; } diff --git a/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt b/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt index ac2e237c1..46cdf13ab 100644 --- a/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt +++ b/templates/qml-plasmoid-with-qml-extension/plugin/CMakeLists.txt @@ -1,3 +1,5 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.%{APPNAMELC}\") + set(%{APPNAMELC}plugin_SRCS %{APPNAMELC}plugin.cpp ) @@ -5,6 +7,7 @@ set(%{APPNAMELC}plugin_SRCS add_library(%{APPNAMELC}plugin SHARED ${%{APPNAMELC}plugin_SRCS}) target_link_libraries(%{APPNAMELC}plugin + KF5::I18n Qt5::Gui Qt5::Qml ) diff --git a/templates/qml-plasmoid/CMakeLists.txt b/templates/qml-plasmoid/CMakeLists.txt index d9cbb7fe5..31b6f6456 100644 --- a/templates/qml-plasmoid/CMakeLists.txt +++ b/templates/qml-plasmoid/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.0) project(plasma-%{APPNAMELC}) @@ -7,4 +7,5 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) find_package(KF5Plasma REQUIRED) -plasma_install_package(package org.kde.%{APPNAMELC}) +# TODO: adapt "org.kde.plasma" here & elsewhere if needed (see README) +plasma_install_package(package org.kde.plasma.%{APPNAMELC}) diff --git a/templates/qml-plasmoid/Messages.sh b/templates/qml-plasmoid/Messages.sh index b8af9a77e..b7b1d793f 100644 --- a/templates/qml-plasmoid/Messages.sh +++ b/templates/qml-plasmoid/Messages.sh @@ -1,2 +1,2 @@ #! /usr/bin/env bash -$XGETTEXT `find . -name \*.qml` -o $podir/plasma_applet_%{APPNAMELC}.pot \ No newline at end of file +$XGETTEXT `find . -name \*.qml` -o $podir/plasma_applet_org.kde.plasma.%{APPNAMELC}.pot diff --git a/templates/qml-plasmoid/README b/templates/qml-plasmoid/README index 8deeea58d..38c59a56c 100644 --- a/templates/qml-plasmoid/README +++ b/templates/qml-plasmoid/README @@ -1,6 +1,23 @@ Plasma Applet Template ---------------------- +-- Namespace adaption -- + +Each Plasma plugin has a unique identifier, which is also used to find related +resources (like the translation catalogs). +To avoid naming collisions, Plasma plugins use a reverse domain name notation +for that identifier: + +* org.kde.plasma.* - plugins coming from Plasma modules +* org.kde.* - plugins coming from other software from KDE +* $(my.domain).* - plugins of your 3rd-party + +The generated code uses the "org.kde.plasma" namespace for the plugin identifier. +As this namespace is reserved for use by plugins part of Plasma modules, you will +need to adapt this namespace if you are writing a plugin which is not intended to +end up in the Plasma modules. + + -- Build instructions -- cd /where/your/applet/is/generated diff --git a/templates/qml-plasmoid/package/metadata.desktop b/templates/qml-plasmoid/package/metadata.desktop index 314696d92..925dd84a6 100644 --- a/templates/qml-plasmoid/package/metadata.desktop +++ b/templates/qml-plasmoid/package/metadata.desktop @@ -83,14 +83,13 @@ X-KDE-ServiceTypes=Plasma/Applet X-KDE-PluginInfo-Author=%{AUTHOR} X-KDE-PluginInfo-Email=%{EMAIL} -X-KDE-PluginInfo-Name=%{APPNAMELC} +X-KDE-PluginInfo-Name=org.kde.plasma.%{APPNAMELC} X-KDE-PluginInfo-Version=1.0 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-Category=Utilities X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-Name=org.kde.%{APPNAMELC} X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml