├── .gitignore ├── CMakeLists.txt ├── dolphin ├── CMakeLists.txt ├── advanced_dolphin_plugin │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── advanced_dolphin_plugin.kdevtemplate │ └── src │ │ ├── %{APPNAMELC}.cpp │ │ ├── %{APPNAMELC}.desktop │ │ ├── %{APPNAMELC}.h │ │ └── CMakeLists.txt ├── dolphinservicemenuplugin │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── dolphinservicemenuplugin.kdevtemplate │ └── src │ │ ├── %{APPNAMELC}.cpp │ │ ├── %{APPNAMELC}.desktop │ │ ├── %{APPNAMELC}.h │ │ └── CMakeLists.txt └── dolphinservicemenus │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── SimpleMenu.desktop │ ├── Submenu.desktop │ └── dolphinservicemenus.kdevtemplate ├── java_templates ├── .gitignore ├── CMakeLists.txt ├── basic_javafx_template │ ├── %{APPNAME}.iml │ ├── .gitignore │ ├── Makefile │ ├── basic_javafx_template.kdevtemplate │ └── src │ │ └── main │ │ └── Main.java ├── java_apache_commons_cli_template │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── java.png │ ├── java_apache_commons_cli_template.kdevtemplate │ ├── pkg2appimage │ ├── pom.xml │ ├── recipies │ │ ├── %{APPNAMELC}-java11openjdk.yml │ │ └── %{APPNAMELC}-java11openjdkmodular.yml │ └── src │ │ ├── deb │ │ ├── control │ │ │ └── control │ │ └── install │ │ │ ├── %{APPNAMELC} │ │ │ └── %{APPNAMELC}_rpm │ │ └── main │ │ └── java │ │ └── main │ │ ├── Main.java │ │ └── Utils.java ├── java_argparse4j_cli_template │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── java.png │ ├── java_argparse4j_cli_template.kdevtemplate │ ├── pkg2appimage │ ├── pom.xml │ ├── recipies │ │ ├── %{APPNAMELC}-java11openjdk.yml │ │ └── %{APPNAMELC}-java11openjdkmodular.yml │ └── src │ │ ├── deb │ │ ├── control │ │ │ └── control │ │ └── install │ │ │ ├── %{APPNAMELC} │ │ │ └── %{APPNAMELC}_rpm │ │ └── main │ │ └── java │ │ └── main │ │ └── Main.java ├── java_jcommander_cli_template │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── java.png │ ├── java_jcommander_cli_template.kdevtemplate │ ├── pkg2appimage │ ├── pom.xml │ ├── recipies │ │ ├── %{APPNAMELC}-java11openjdk.yml │ │ └── %{APPNAMELC}-java11openjdkmodular.yml │ └── src │ │ ├── deb │ │ ├── control │ │ │ └── control │ │ └── install │ │ │ ├── %{APPNAMELC} │ │ │ └── %{APPNAMELC}_rpm │ │ └── main │ │ └── java │ │ └── main │ │ ├── Args.java │ │ └── Main.java ├── java_junit5_file_template │ ├── java_junit5_file_template.desktop │ ├── java_junit5_file_template.java │ └── options.kcfg ├── java_maven_basic_setup │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── java_maven_basic_setup.kdevtemplate │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── main │ │ │ └── Main.java │ │ └── test │ │ └── java │ │ └── MainTest.java ├── java_picocli_cli_template │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── java.png │ ├── java_picocli_cli_template.kdevtemplate │ ├── pkg2appimage │ ├── pom.xml │ ├── recipies │ │ ├── %{APPNAMELC}-java11openjdk.yml │ │ └── %{APPNAMELC}-java11openjdkmodular.yml │ └── src │ │ ├── deb │ │ ├── control │ │ │ └── control │ │ └── install │ │ │ ├── %{APPNAMELC} │ │ │ └── %{APPNAMELC}_rpm │ │ ├── main │ │ └── java │ │ │ └── main │ │ │ ├── Args.java │ │ │ └── Main.java │ │ └── test │ │ └── java │ │ └── ExampleTest.java ├── javafx_fxml_maven_template │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── javafx_fxml_maven_template.kdevtemplate │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── main │ │ │ ├── Controller.java │ │ │ └── Main.java │ │ └── resources │ │ ├── main │ │ └── sample.fxml │ │ └── translations.properties ├── javafx_fxml_maven_testfx_template │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── javafx_fxml_maven_testfx_template.kdevtemplate │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── main │ │ │ │ ├── Controller.java │ │ │ │ └── Main.java │ │ └── resources │ │ │ ├── main │ │ │ └── sample.fxml │ │ │ └── translations.properties │ │ └── test │ │ └── java │ │ └── main │ │ └── MainTest.java ├── javafx_fxml_template │ ├── %{APPNAME}.iml │ ├── .gitignore │ ├── Makefile │ ├── javafx_fxml_template.kdevtemplate │ └── src │ │ └── main │ │ ├── Controller.java │ │ ├── Main.java │ │ └── sample.fxml └── javafx_maven_build_scripts │ ├── %{APPNAMELC}.iml │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── bintray.sh │ ├── java.png │ ├── javafx_maven_build_scripts.kdevtemplate │ ├── pkg2appimage │ ├── pom.xml │ ├── recipies │ ├── %{APPNAMELC}-java11openjdk.yml │ └── %{APPNAMELC}-javafxpackager.yml │ ├── snap │ └── snapcraft.yaml │ └── src │ ├── deb │ ├── control │ │ └── control │ └── install │ │ ├── %{APPNAMELC} │ │ ├── %{APPNAMELC}-snap.desktop │ │ ├── %{APPNAMELC}.desktop │ │ ├── %{APPNAMELC}_rpm │ │ └── %{APPNAMELC}_rpm.desktop │ ├── main │ ├── java │ │ └── main │ │ │ ├── Controller.java │ │ │ ├── Launcher.java │ │ │ └── Main.java │ └── resources │ │ ├── main │ │ └── sample.fxml │ │ └── translations.properties │ └── test │ └── java │ └── main │ └── MainTest.java ├── kdevelop_app_template ├── %{APPNAMELC} │ ├── %{APPNAMELC}.kdevtemplate │ ├── .gitignore │ └── ExampleFile.txt ├── .gitignore ├── CMakeLists.txt ├── kdevelop_app_template.kdevtemplate └── package.sh ├── kdevelop_file_template ├── %{APPNAMELC} │ ├── %{APPNAMELC}.desktop │ ├── DemoFile.txt │ └── options.kcfg ├── .gitignore ├── CMakeLists.txt ├── kdevelop_file_template_template.kdevtemplate └── package.sh ├── krunner_dbus_templates ├── CMakeLists.txt ├── krunner_dbus_cpp │ ├── .gitignore │ ├── CMakeLists.txt │ ├── krunner_dbus_cpp │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── README.md │ │ ├── krunner_dbus_cpp.kdevtemplate │ │ └── src │ │ │ ├── %{APPNAMELC}.cpp │ │ │ ├── %{APPNAMELC}.h │ │ │ ├── CMakeLists.txt │ │ │ ├── dbus_utils.h │ │ │ └── plasma-runner-%{APPNAMELC}.desktop │ └── package.sh ├── krunner_dbus_javascript │ ├── .gitignore │ ├── README.md │ ├── krunner_dbus_javascript.kdevtemplate │ ├── package.json │ ├── plasma-runner-%{APPNAMELC}.desktop │ └── src │ │ ├── dbus-connection.js │ │ ├── index.js │ │ └── runner.js ├── modular_krunner_python_template │ ├── %{APPNAMELC} │ │ ├── Runner.py │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── main.py │ │ ├── resources │ │ │ ├── %{APPNAMELC}_autostart.desktop │ │ │ └── plasma-runner-%{APPNAMELC}.desktop │ │ └── utilities │ │ │ ├── Action.py │ │ │ ├── Match.py │ │ │ └── __init__.py │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── python_modular_runner_template.kdevtemplate │ └── setup.py └── simple_krunner_python_template │ ├── %{APPNAMELC}.py │ ├── .gitignore │ ├── README.md │ ├── install.sh │ ├── org.kde.%{APPNAMELC}.service │ ├── plasma-runner-%{APPNAMELC}.desktop │ ├── simple_krunner_python_template.kdevtemplate │ └── uninstall.sh ├── package.sh ├── python_templates ├── CMakeLists.txt ├── PythonArgparseProject │ ├── %{APPNAMELC}.py │ ├── .gitignore │ └── python3_argparse_cli.kdevtemplate ├── PythonArgparseTypedModularProject │ ├── %{APPNAMELC} │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── main.py │ │ └── utilities │ │ │ ├── ArgsNamespace.py │ │ │ ├── CustomHelpFormatter.py │ │ │ └── __init__.py │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── python3_modular_argparse_cli.kdevtemplate │ ├── setup.py │ └── snap │ │ └── snapcraft.yaml └── PythonArgparseTypedProject │ ├── %{APPNAMELC}.py │ ├── .gitignore │ └── python3_argparse_cli.kdevtemplate ├── qt_cpp_templates ├── CMakeLists.txt ├── krunner_templates │ ├── CMakeLists.txt │ ├── krunner │ │ ├── CMakeLists.txt │ │ ├── basic_runner │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── LICENSE │ │ │ ├── Messages.sh │ │ │ ├── README.md │ │ │ ├── install.sh │ │ │ ├── runner.kdevtemplate │ │ │ └── src │ │ │ │ ├── %{APPNAMELC}.cpp │ │ │ │ ├── %{APPNAMELC}.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── plasma-runner-%{APPNAMELC}.desktop │ │ └── extended_runner │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── LICENSE │ │ │ ├── Messages.sh │ │ │ ├── README.md │ │ │ ├── install.sh │ │ │ ├── runner.kdevtemplate │ │ │ └── src │ │ │ ├── %{APPNAMELC}.cpp │ │ │ ├── %{APPNAMELC}.h │ │ │ ├── CMakeLists.txt │ │ │ └── plasma-runner-%{APPNAMELC}.desktop │ └── runner_kcmodule │ │ ├── CMakeLists.txt │ │ ├── extendedrunnerwithconfig │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── Messages.sh │ │ ├── README.md │ │ ├── install.sh │ │ ├── runnerwithkcmodule.kdevtemplate │ │ └── src │ │ │ ├── %{APPNAMELC}.cpp │ │ │ ├── %{APPNAMELC}.h │ │ │ ├── CMakeLists.txt │ │ │ ├── config │ │ │ ├── %{APPNAMELC}_config.cpp │ │ │ ├── %{APPNAMELC}_config.h │ │ │ ├── %{APPNAMELC}_config.ui │ │ │ └── plasma-runner-%{APPNAMELC}_config.desktop │ │ │ └── plasma-runner-%{APPNAMELC}.desktop │ │ └── runnerwithconfig │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── Messages.sh │ │ ├── README.md │ │ ├── install.sh │ │ ├── runnerwithkcmodule.kdevtemplate │ │ └── src │ │ ├── %{APPNAMELC}.cpp │ │ ├── %{APPNAMELC}.h │ │ ├── CMakeLists.txt │ │ ├── config │ │ ├── %{APPNAMELC}_config.cpp │ │ ├── %{APPNAMELC}_config.h │ │ ├── %{APPNAMELC}_config.ui │ │ └── plasma-runner-%{APPNAMELC}_config.desktop │ │ └── plasma-runner-%{APPNAMELC}.desktop └── qt_cli_templates │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── basic_qt_cli_template │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Makefile │ ├── basic_qt_cli_template.kdevtemplate │ └── main.cpp │ └── validated_qt_cli_template │ ├── .gitignore │ ├── CMakeLists.txt │ ├── Makefile │ ├── Validator.cpp │ ├── Validator.h │ ├── main.cpp │ └── validated_qt_cli_template.kdevtemplate └── simple_desktop_application_file ├── simple_desktop_application_file.desktop └── template.desktop /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /*/build 3 | /*/*/build 4 | /.idea 5 | /*/.idea 6 | /*/*/.idea 7 | /.vscode 8 | /*/.vscode 9 | /*/*/.vscode 10 | /cmake-build-debug 11 | /target 12 | *.swap 13 | .directory 14 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | include(FeatureSummary) 3 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 4 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 5 | 6 | include(KDEInstallDirs) 7 | include(KDEPackageAppTemplates) 8 | 9 | set(kdevelop_app_template_DIRS kdevelop_app_template) 10 | set(kdevelop_file_template_DIRS kdevelop_file_template) 11 | set(simple_desktop_application_file_DIRS simple_desktop_application_file) 12 | 13 | kde_package_app_templates(TEMPLATES ${kdevelop_app_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 14 | kde_package_app_templates(TEMPLATES ${kdevelop_file_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 15 | kde_package_app_templates(TEMPLATES ${simple_desktop_application_file_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 16 | 17 | 18 | add_subdirectory(dolphin) 19 | add_subdirectory(krunner_dbus_templates) 20 | add_subdirectory(qt_cpp_templates) 21 | add_subdirectory(java_templates) 22 | add_subdirectory(python_templates) 23 | -------------------------------------------------------------------------------- /dolphin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(dolphinservicemenuplugin_DIRS dolphinservicemenuplugin) 2 | kde_package_app_templates(TEMPLATES ${dolphinservicemenuplugin_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 3 | 4 | set(advanced_dolphin_plugin_DIRS advanced_dolphin_plugin) 5 | kde_package_app_templates(TEMPLATES ${advanced_dolphin_plugin_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 6 | 7 | set(dolphinservicemenus_DIRS dolphinservicemenus) 8 | kde_package_app_templates(TEMPLATES ${dolphinservicemenus_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 9 | 10 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *.kdev4 8 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(%{APPNAMELC}) 2 | 3 | cmake_minimum_required(VERSION 3.0.0) 4 | 5 | set(KF5_MIN_VERSION "5.0.0") 6 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 7 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) 8 | 9 | find_package(KF5 REQUIRED COMPONENTS KIO) 10 | include(KDEInstallDirs) 11 | include(KDECMakeSettings) 12 | include(KDECompilerSettings NO_POLICY_SCOPE) 13 | include(FeatureSummary) 14 | 15 | add_subdirectory(src) 16 | 17 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 18 | 19 | # CPack configuration 20 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "%{APPNAME} Dolphin Plugin") 21 | set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) 22 | set(CPACK_PACKAGE_VERSION "0.0.1") 23 | set(CPACK_DEBIAN_PACKAGE_SECTION "utils") 24 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "%{AUTHOR}") 25 | set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") 26 | 27 | INCLUDE(CPack) 28 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/README.md: -------------------------------------------------------------------------------- 1 | # Dolphin Service Menu Plugin 2 | 3 | This project is a plugin for dolphin which provides service menus. 4 | See https://api.kde.org/frameworks-api/frameworks-apidocs/frameworks/kio/html/classKAbstractFileItemActionPlugin.html for the official docs. 5 | 6 | To build this plugin run: 7 | ``` 8 | mkdir -p build 9 | cd build 10 | cmake .. 11 | # With Makefiles 12 | make -j$(nproc) 13 | sudo make install 14 | # or with ninja 15 | ninja -j$(nproc) 16 | sudo ninja install 17 | ``` 18 | 19 | To create a more optimized release build run instead of 20 | `cmake ..` `cmake -DCMAKE_BUILD_TYPE=Release ..` 21 | 22 | The plugin can be disabled in Configure Dolphin -> Services -> uncheck %{APPNAME} 23 | or uninstalled by running `sudo make uninstall` or `sudo ninja uninstall` from the build directory 24 | 25 | You can also build binary packages: 26 | ``` 27 | cd build 28 | # Make sure that you create a release build 29 | cmake -DCMAKE_BUILD_TYPE=Release .. 30 | make -j$(nproc) 31 | cpack -G DEB 32 | cpack -G RPM 33 | ``` 34 | And you can also build any other package format cpack supports. 35 | 36 | ### Required Dependencies 37 | 38 | Debian/Ubuntu 39 | `sudo apt install cmake extra-cmake-modules build-essential libkf5kio-dev` 40 | 41 | openSUSE 42 | `sudo zypper install cmake extra-cmake-modules kio-devel` 43 | 44 | Fedora 45 | `sudo dnf install cmake extra-cmake-modules kf5-kio-devel` 46 | 47 | Arch(Manjaro): 48 | `sudo pacman -S cmake extra-cmake-modules kio` 49 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/advanced_dolphin_plugin.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Advanced Dolphin C++ Service Menu 3 | Comment=Dolphin service menu plugin written in C++ with latest Macros and build scripts for binary packages. 4 | Category=Dolphin/ServiceMenu 5 | Icon=system-file-manager 6 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2020 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License or (at your option) version 3 or any later version 9 | * accepted by the membership of KDE e.V. (or its successor approved 10 | * by the membership of KDE e.V.), which shall act as a proxy 11 | * defined in Section 14 of version 3 of the license. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include "%{APPNAMELC}.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | %{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) 33 | : KAbstractFileItemActionPlugin(parent) 34 | { 35 | Q_UNUSED(args) 36 | } 37 | 38 | %{APPNAME}::~%{APPNAME}() 39 | { 40 | } 41 | 42 | QList %{APPNAME}::actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget) 43 | { 44 | Q_UNUSED(fileItemInfos) 45 | Q_UNUSED(parentWidget) 46 | 47 | QList actions; 48 | auto *menuAction = new KActionMenu(this); 49 | menuAction->setIcon(QIcon::fromTheme("kdevelop")); 50 | menuAction->setText("%{APPNAME}"); 51 | auto action = new QAction(QIcon::fromTheme("planetkde"), "Hello There!", this); 52 | connect(action, &QAction::triggered, this, &%{APPNAME}::helloThere); 53 | menuAction->addAction(action); 54 | actions.append(menuAction); 55 | return {actions}; 56 | } 57 | void %{APPNAME}::helloThere() 58 | { 59 | // Only for demo purposes, use KNotifications for real applications 60 | QProcess::startDetached("notify-send", {"Hello There!", "--icon", "planetkde"}); 61 | } 62 | 63 | K_PLUGIN_CLASS_WITH_JSON(%{APPNAME}, "%{APPNAMELC}.json") 64 | 65 | #include "%{APPNAMELC}.moc" 66 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/src/%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | Name=%{APPNAME} 4 | Icon=planetkde 5 | X-KDE-ServiceTypes=KFileItemAction/Plugin 6 | MimeType=inode/directory 7 | X-KDE-Library=%{APPNAMELC} 8 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2020 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License or (at your option) version 3 or any later version 9 | * accepted by the membership of KDE e.V. (or its successor approved 10 | * by the membership of KDE e.V.), which shall act as a proxy 11 | * defined in Section 14 of version 3 of the license. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #ifndef %{APPNAMEUC}_H 23 | #define %{APPNAMEUC}_H 24 | 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /** 32 | * @todo write docs 33 | */ 34 | class %{APPNAME}: public KAbstractFileItemActionPlugin 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | %{APPNAME}(QObject *parent = nullptr, const QVariantList &args = QVariantList()); 40 | virtual ~%{APPNAME}(); 41 | virtual QList actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget) override; 42 | 43 | protected Q_SLOTS: 44 | void helloThere(); 45 | }; 46 | 47 | #endif // %{APPNAMEUC}_H 48 | -------------------------------------------------------------------------------- /dolphin/advanced_dolphin_plugin/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTRANSLATION_DOMAIN=\"%{APPNAMELC}\") 2 | 3 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 4 | kcoreaddons_add_plugin(%{APPNAMELC} SOURCES ${%{APPNAMELC}_SRCS} INSTALL_NAMESPACE "kf5/kfileitemaction") 5 | kcoreaddons_desktop_to_json(%{APPNAMELC} %{APPNAMELC}.desktop) # generate the json file with metadata 6 | target_link_libraries(%{APPNAMELC} KF5::KIOCore KF5::KIOWidgets) 7 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *.kdev4 8 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(%{APPNAMELC}) 2 | 3 | cmake_minimum_required(VERSION 3.0.0) 4 | 5 | set(KF5_MIN_VERSION "5.0.0") 6 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 7 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) 8 | 9 | find_package(KF5 REQUIRED COMPONENTS KIO) 10 | include(KDEInstallDirs) 11 | include(KDECMakeSettings) 12 | include(KDECompilerSettings NO_POLICY_SCOPE) 13 | include(FeatureSummary) 14 | 15 | add_subdirectory(src) 16 | 17 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 18 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/README.md: -------------------------------------------------------------------------------- 1 | # Dolphin Service Menu Plugin 2 | 3 | This project is a plugin for dolphin which provides service menus. 4 | 5 | To build this plugin run: 6 | ``` 7 | mkdir -p build 8 | cd build 9 | cmake .. 10 | # With Makefiles 11 | make -j$(nproc) 12 | sudo make install 13 | # or with ninja 14 | ninja -j$(nproc) 15 | sudo ninja install 16 | ``` 17 | 18 | To create a more optimized release build run instead of 19 | `cmake ..` `cmake -DCMAKE_BUILD_TYPE=Release ..` 20 | 21 | The plugin can be disabled in Configure Dolphin -> Services -> uncheck %{APPNAME} 22 | or uninstalled by running `sudo make uninstall` or `sudo ninja uninstall` from the build directory 23 | 24 | See https://api.kde.org/frameworks-api/frameworks-apidocs/frameworks/kio/html/classKAbstractFileItemActionPlugin.html for the official docs. -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/dolphinservicemenuplugin.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Dolphin C++ Service Menu 3 | Comment=Dolphin service menu written in C++ 4 | Category=Dolphin/ServiceMenu 5 | Icon=planetkde 6 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2020 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License or (at your option) version 3 or any later version 9 | * accepted by the membership of KDE e.V. (or its successor approved 10 | * by the membership of KDE e.V.), which shall act as a proxy 11 | * defined in Section 14 of version 3 of the license. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include "%{APPNAMELC}.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | %{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) 33 | : KAbstractFileItemActionPlugin(parent) 34 | { 35 | Q_UNUSED(args) 36 | } 37 | 38 | %{APPNAME}::~%{APPNAME}() 39 | { 40 | } 41 | 42 | QList %{APPNAME}::actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget) 43 | { 44 | Q_UNUSED(fileItemInfos) 45 | Q_UNUSED(parentWidget) 46 | 47 | QList actions; 48 | auto *menuAction = new KActionMenu(this); 49 | menuAction->setIcon(QIcon::fromTheme("kdevelop")); 50 | menuAction->setText("%{APPNAME}"); 51 | auto action = new QAction(QIcon::fromTheme("planetkde"), "Hello There!", this); 52 | connect(action, &QAction::triggered, this, &%{APPNAME}::helloThere); 53 | menuAction->addAction(action); 54 | actions.append(menuAction); 55 | return {actions}; 56 | } 57 | void %{APPNAME}::helloThere() 58 | { 59 | // Only for demo purposes, use KNotifications for real applications 60 | QProcess::startDetached("notify-send", {"Hello There!", "--icon", "planetkde"}); 61 | } 62 | 63 | K_PLUGIN_FACTORY(%{APPNAME}Factory, registerPlugin<%{APPNAME}>();) 64 | 65 | #include "%{APPNAMELC}.moc" 66 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/src/%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | Name=%{APPNAME} 4 | Icon=planetkde 5 | X-KDE-ServiceTypes=KFileItemAction/Plugin 6 | MimeType=inode/directory 7 | X-KDE-Library=%{APPNAMELC} 8 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 2020 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of 8 | * the License or (at your option) version 3 or any later version 9 | * accepted by the membership of KDE e.V. (or its successor approved 10 | * by the membership of KDE e.V.), which shall act as a proxy 11 | * defined in Section 14 of version 3 of the license. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #ifndef %{APPNAMEUC}_H 23 | #define %{APPNAMEUC}_H 24 | 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | /** 32 | * @todo write docs 33 | */ 34 | class %{APPNAME}: public KAbstractFileItemActionPlugin 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | %{APPNAME}(QObject *parent = nullptr, const QVariantList &args = QVariantList()); 40 | virtual ~%{APPNAME}(); 41 | virtual QList actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget) override; 42 | 43 | protected Q_SLOTS: 44 | void helloThere(); 45 | }; 46 | 47 | #endif // %{APPNAMEUC}_H 48 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenuplugin/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTRANSLATION_DOMAIN=\"%{APPNAMELC}\") 2 | 3 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 4 | add_library(%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) 5 | target_link_libraries(%{APPNAMELC} KF5::KIOCore KF5::KIOWidgets) 6 | 7 | install(FILES %{APPNAMELC}.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) 8 | install(TARGETS %{APPNAMELC} DESTINATION ${PLUGIN_INSTALL_DIR}) 9 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenus/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *.kdev4 8 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenus/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | mkdir -p ~/.local/share/kservices5/ServiceMenus 3 | # Delete files for changed to be loaded 4 | rm -rf ~/.local/share/kservices5/ServiceMenus/Submenu.desktop ~/.local/share/kservices5/ServiceMenus/SimpleMenu.desktop 5 | cp Submenu.desktop SimpleMenu.desktop ~/.local/share/kservices5/ServiceMenus 6 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenus/README.md: -------------------------------------------------------------------------------- 1 | # Dolphin Service Menu templates 2 | 3 | This simple template provides two Dolphin service menus. 4 | 5 | See the official documentation: 6 | https://techbase.kde.org/Development/Tutorials/Creating_Konqueror_Service_Menus 7 | 8 | See for the Exec key options: 9 | https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html 10 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenus/SimpleMenu.desktop: -------------------------------------------------------------------------------- 1 | # This Menu will appear for folders 2 | [Desktop Entry] 3 | Type=Service 4 | ServiceTypes=KonqPopupMenu/Plugin 5 | MimeType=inode/directory 6 | Actions=DemoMenu 7 | # Without this line the menu will appear under the actions submenu 8 | X-KDE-Priority=TopLevel 9 | 10 | [Desktop Action DemoMenu] 11 | Name=Demo Menu 12 | Icon=planetkde 13 | Exec=notify-send --icon planetkde "Demo Menu" %u 14 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenus/Submenu.desktop: -------------------------------------------------------------------------------- 1 | # This submenu will appear for folders 2 | [Desktop Entry] 3 | Type=Service 4 | MimeType=inode/directory 5 | X-KDE-ServiceTypes=KonqPopupMenu/Plugin 6 | Actions=First;Second 7 | Icon=planetkde 8 | X-KDE-Submenu=Demo Submenu 9 | # Without this line the menu will appear under the actions submenu 10 | X-KDE-Priority=TopLevel 11 | 12 | [Desktop Action First] 13 | Name=Hello World 14 | Icon=planetkde 15 | Exec=notify-send --icon planetkde "Hello World!" %u 16 | 17 | [Desktop Action Second] 18 | Name=Hello There 19 | Icon=planetkde 20 | Exec=notify-send --icon planetkde "Hello There!" %u 21 | -------------------------------------------------------------------------------- /dolphin/dolphinservicemenus/dolphinservicemenus.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Dolphin Service Menus 3 | Comment=Two "Hello World" service menus for dolpin that will help you get started 4 | Category=Dolphin/ServiceMenu 5 | Icon=system-file-manager 6 | -------------------------------------------------------------------------------- /java_templates/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the following files 2 | *~ 3 | *.[oa] 4 | *.diff 5 | *.kate-swp 6 | *.kdev4 7 | .kdev_include_paths 8 | *.kdevelop.pcs 9 | *.moc 10 | *.moc.cpp 11 | *.orig 12 | *.user 13 | .*.swp 14 | .swp.* 15 | Doxyfile 16 | avail 17 | random_seed 18 | /build*/ 19 | CMakeLists.txt.user* 20 | *.unc-backup* 21 | /.vscode 22 | /.idea 23 | .directory 24 | /cmake-build-debug -------------------------------------------------------------------------------- /java_templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(basic_javafx_template_DIRS basic_javafx_template) 2 | set(javafx_fxml_template_DIRS javafx_fxml_template) 3 | set(java_apache_commons_cli_template_DIRS java_apache_commons_cli_template) 4 | set(java_jcommander_cli_template_DIRS java_jcommander_cli_template) 5 | set(java_argparse4j_cli_template_DIRS java_argparse4j_cli_template) 6 | set(javafx_fxml_maven_template_DIRS javafx_fxml_maven_template) 7 | set(javafx_fxml_maven_testfx_template_DIRS javafx_fxml_maven_testfx_template) 8 | set(java_maven_basic_setup_template_DIRS java_maven_basic_setup) 9 | set(java_picocli_cli_template_DIRS java_picocli_cli_template) 10 | set(java_junit5_file_template_DIRS java_junit5_file_template) 11 | set(javafx_maven_build_scripts_DIRS javafx_maven_build_scripts) 12 | 13 | kde_package_app_templates(TEMPLATES ${basic_javafx_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 14 | kde_package_app_templates(TEMPLATES ${javafx_fxml_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 15 | kde_package_app_templates(TEMPLATES ${java_apache_commons_cli_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 16 | kde_package_app_templates(TEMPLATES ${java_jcommander_cli_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 17 | kde_package_app_templates(TEMPLATES ${java_argparse4j_cli_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 18 | kde_package_app_templates(TEMPLATES ${javafx_fxml_maven_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 19 | kde_package_app_templates(TEMPLATES ${javafx_fxml_maven_testfx_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 20 | kde_package_app_templates(TEMPLATES ${java_maven_basic_setup_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 21 | kde_package_app_templates(TEMPLATES ${java_picocli_cli_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 22 | kde_package_app_templates(TEMPLATES ${java_junit5_file_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 23 | kde_package_app_templates(TEMPLATES ${javafx_maven_build_scripts_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 24 | -------------------------------------------------------------------------------- /java_templates/basic_javafx_template/%{APPNAME}.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /java_templates/basic_javafx_template/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.metadata 3 | /target 4 | /.settings 5 | /dist 6 | /.vscode 7 | /out 8 | /bin 9 | /build -------------------------------------------------------------------------------- /java_templates/basic_javafx_template/Makefile: -------------------------------------------------------------------------------- 1 | compile: 2 | mkdir -p build 3 | javac -d build -sourcepath src src/main/Main.java 4 | start: 5 | java -cp build main.Main 6 | clean: 7 | rm -rf build 8 | rm -rf bin 9 | start_dev: 10 | make compile start 11 | package: 12 | mkdir -p build 13 | mkdir -p bin 14 | javac -d build -sourcepath src src/main/Main.java 15 | echo "Main-Class: main.Main" > build/MANIFEST.MF 16 | jar -cfm bin/project.jar build/MANIFEST.MF -C build/ . 17 | chmod +x bin/project.jar 18 | -------------------------------------------------------------------------------- /java_templates/basic_javafx_template/basic_javafx_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Basic JavaFX Application 3 | Comment=A Hello World JavaFX Application 4 | Category=Java/JavaFX 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/basic_javafx_template/src/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.application.Application; 4 | import javafx.geometry.Pos; 5 | import javafx.scene.Scene; 6 | import javafx.scene.control.Label; 7 | import javafx.scene.layout.GridPane; 8 | import javafx.stage.Stage; 9 | 10 | public class Main extends Application { 11 | 12 | public static void main(String[] args) { 13 | launch(args); 14 | } 15 | 16 | @Override 17 | public void start(Stage window) { 18 | GridPane parent = new GridPane(); 19 | parent.setAlignment(Pos.CENTER); 20 | parent.getChildren().add(new Label("Hello World!")); 21 | Scene scene = new Scene(parent, 400,200); 22 | window.setScene(scene); 23 | window.show(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | .classpath 10 | .factorypath 11 | .project 12 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java -Dexec.args="$(args)" 3 | build: 4 | mvn compile package 5 | clean: 6 | mvn clean 7 | 8 | package-appimage: 9 | # Build appimage, build required jar file first 10 | mvn compile assembly:single 11 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdk.yml 12 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 13 | 14 | package-appimage-modular: 15 | # Build appimage, build required jar file first 16 | mvn compile assembly:single 17 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdkmodular.yml 18 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 19 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/README: -------------------------------------------------------------------------------- 1 | This project uses Maven and the Apache Commons CLI library. 2 | 3 | To run/build/install the project you can use the scripts from the Makerfile, 4 | this requires you to have Maven installed. 5 | 6 | If you want to pass in commands to the program you can type: make start args="" 7 | 8 | The RPM package config is based on: http://www.mojohaus.org/rpm-maven-plugin/example1.html 9 | 10 | If the modular AppImage fails to run, you can check with "jdeps --list-deps target/%{APPNAMELC}-1.0-jar-with-dependencies.jar" 11 | if there are additional modules needed and add them to the recipies/%{APPNAMELC}-java11openjdkmodular.yml file. 12 | 13 | Tip: If you want to start the file using ./filename.jar you can install the jarwrapper package. -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/java_templates/java_apache_commons_cli_template/java.png -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/java_apache_commons_cli_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Java CLI Using Apache Commons 3 | Comment=Setup with files and build scripts for a CLI with Apache Commons and the Maven architecture. 4 | Category=Java/Terminal 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/recipies/%{APPNAMELC}-java11openjdk.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Download JRE, replace with own script if you are not on a Debian based distro 5 | - apt download openjdk-11-jre-headless 6 | - mv openjdk-11-jre-headless*.deb openjdk-11-jre-headless.deb 7 | - ar vx openjdk-11-jre-headless.deb 8 | - rm control.tar.xz debian-binary openjdk-11-jre-headless.deb 9 | - tar xf data.tar.xz 10 | - ln -s ./lib/jvm/java-11-openjdk-amd64/bin/java usr/java 11 | # Copy icon, create folders 12 | - cp ../../java.png usr/share/icons/java.png 13 | - mkdir -p usr/lib/java/ 14 | # Copy jar file and make java executable 15 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 16 | - chmod +x usr/lib/jvm/java-11-openjdk-amd64/bin/java 17 | # Create Desktop Entry to launch application 18 | - cat > usr/bin/launcher <<\EOF 19 | - ./lib/jvm/java-11-openjdk-amd64/bin/java -jar %{APPNAMELC}.jar $@ 20 | - EOF 21 | - chmod +x usr/bin/launcher 22 | - cat > %{APPNAMELC}.desktop <<\EOF 23 | - [Desktop Entry] 24 | - Type=Application 25 | - Name=%{APPNAME} 26 | - Icon=/usr/share/icons/java 27 | - Exec=launcher 28 | - Categories=Utility; 29 | - EOF 30 | 31 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/recipies/%{APPNAMELC}-java11openjdkmodular.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Create custom JRE using required only modules => optimized file size 5 | - jlink --add-modules java.base --output usr/jre 6 | # Copy icon, create folders 7 | - cp ../../java.png usr/share/icons/java.png 8 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 9 | # Create Desktop Entry to launch application 10 | - echo "./bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 11 | - echo "./jre/bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 12 | - cat > usr/bin/launcher <<\EOF 13 | - ./jre/bin/java -jar %{APPNAMELC}.jar $@ 14 | - EOF 15 | - chmod +x usr/bin/launcher 16 | - cat > %{APPNAMELC}.desktop <<\EOF 17 | - [Desktop Entry] 18 | - Type=Application 19 | - Name=%{APPNAME} 20 | - Icon=/usr/share/icons/java 21 | - Exec=launcher 22 | - Categories=Utility; 23 | - EOF 24 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/src/deb/control/control: -------------------------------------------------------------------------------- 1 | Package: %{APPNAME} 2 | Version: 1.0.0 3 | Section: misc 4 | Priority: low 5 | Architecture: all 6 | Description: [[description]] 7 | Maintainer: %{AUTHOR} 8 | Depends: openjdk-11-jre -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/src/deb/install/%{APPNAMELC}: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/src/deb/install/%{APPNAMELC}_rpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/jre-11-openjdk/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ 4 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import org.apache.commons.cli.*; 4 | 5 | import static main.Utils.checkHelpRequested; 6 | import static main.Utils.checkVersionRequested; 7 | 8 | public class Main { 9 | 10 | public static void main(String[] args) { 11 | Options options = new Options(); 12 | 13 | Option argOption = Option.builder("a") 14 | .longOpt("arg") 15 | .argName("arg") 16 | .hasArg(true) 17 | .required() 18 | .desc("Argument for program") 19 | .build(); 20 | options.addOption(argOption); 21 | 22 | // option, long option, hasArg, description 23 | options.addOption(new Option("d", "debug", false, "Debug output")); 24 | options.addOption(new Option("h", "help", false, "Show Help")); 25 | options.addOption(new Option("v", "version", false, "Show Version")); 26 | 27 | // Handle help and version requests 28 | if (checkHelpRequested(args)) { 29 | HelpFormatter formatter = new HelpFormatter(); 30 | formatter.printHelp("%{APPNAMELC} ", options, true); 31 | return; 32 | } 33 | if (checkVersionRequested(args)) { 34 | String version = Main.class.getPackage().getImplementationVersion(); 35 | if (version == null) version = "1.0.0-Dev"; // Value is != null when running executable jar 36 | System.out.println("%{APPNAMELC}: " + version); 37 | return; 38 | } 39 | 40 | CommandLineParser parser = new DefaultParser(); 41 | CommandLine line = null; 42 | try { 43 | line = parser.parse(options, args); 44 | } catch (ParseException exp) { 45 | System.err.println("Parsing failed. Reason: " + exp.getMessage()); 46 | return; 47 | } 48 | 49 | if (line.hasOption("debug")) { 50 | System.out.println("Value of arg is: " + line.getOptionValue("arg")); 51 | System.out.println("Positional arguments: " + line.getArgList()); 52 | } 53 | 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /java_templates/java_apache_commons_cli_template/src/main/java/main/Utils.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import java.util.Arrays; 4 | 5 | class Utils { 6 | 7 | static boolean checkHelpRequested(String[] args) { 8 | return Arrays.asList(args).contains("-h") || Arrays.asList(args).contains("--help"); 9 | } 10 | 11 | static boolean checkVersionRequested(String[] args) { 12 | return Arrays.asList(args).contains("-v") || Arrays.asList(args).contains("--version"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | .classpath 10 | .factorypath 11 | .project 12 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java -Dexec.args="$(args)" 3 | build: 4 | mvn compile package 5 | clean: 6 | mvn clean 7 | 8 | package-appimage: 9 | # Build appimage, build required jar file first 10 | mvn compile assembly:single 11 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdk.yml 12 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 13 | 14 | package-appimage-modular: 15 | # Build appimage, build required jar file first 16 | mvn compile assembly:single 17 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdkmodular.yml 18 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 19 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/README: -------------------------------------------------------------------------------- 1 | This project uses Maven and the Argparse4j library. 2 | 3 | To run/build/install the project you can use the scripts from the Makerfile, this requires you to have Maven installed. 4 | 5 | If you want to pass in commands to the program you can type: make start args="" 6 | 7 | The RPM package config is based on: http://www.mojohaus.org/rpm-maven-plugin/example1.html 8 | 9 | If the modular AppImage fails to run, you can check with "jdeps --list-deps target/%{APPNAMELC}-1.0-jar-with-dependencies.jar" 10 | if there are additional modules needed and add them to the recipies/%{APPNAMELC}-java11openjdkmodular.yml file. 11 | 12 | Tip: If you want to start the file using ./filename.jar you can install the jarwrapper package. -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/java_templates/java_argparse4j_cli_template/java.png -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/java_argparse4j_cli_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Java CLI Using Argpparse4j 3 | Comment=Setup with files and build scripts for a CLI with Argpparse4j and the Maven architecture. 4 | Category=Java/Terminal 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/recipies/%{APPNAMELC}-java11openjdk.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Download JRE, replace with own script if you are not on a Debian based distro 5 | - apt download openjdk-11-jre-headless 6 | - mv openjdk-11-jre-headless*.deb openjdk-11-jre-headless.deb 7 | - ar vx openjdk-11-jre-headless.deb 8 | - rm control.tar.xz debian-binary openjdk-11-jre-headless.deb 9 | - tar xf data.tar.xz 10 | - ln -s ./lib/jvm/java-11-openjdk-amd64/bin/java usr/java 11 | # Copy icon, create folders 12 | - cp ../../java.png usr/share/icons/java.png 13 | - mkdir -p usr/lib/java/ 14 | # Copy jar file and make java executable 15 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 16 | - chmod +x usr/lib/jvm/java-11-openjdk-amd64/bin/java 17 | # Create Desktop Entry to launch application 18 | - cat > usr/bin/launcher <<\EOF 19 | - ./lib/jvm/java-11-openjdk-amd64/bin/java -jar %{APPNAMELC}.jar $@ 20 | - EOF 21 | - chmod +x usr/bin/launcher 22 | - cat > %{APPNAMELC}.desktop <<\EOF 23 | - [Desktop Entry] 24 | - Type=Application 25 | - Name=%{APPNAME} 26 | - Icon=/usr/share/icons/java 27 | - Exec=launcher 28 | - Categories=Utility; 29 | - EOF 30 | 31 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/recipies/%{APPNAMELC}-java11openjdkmodular.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Create custom JRE using required only modules => optimized file size 5 | - jlink --add-modules java.base --output usr/jre 6 | # Copy icon, create folders 7 | - cp ../../java.png usr/share/icons/java.png 8 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 9 | # Create Desktop Entry to launch application 10 | - echo "./bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 11 | - cat > usr/bin/launcher <<\EOF 12 | - ./jre/bin/java -jar %{APPNAMELC}.jar $@ 13 | - EOF 14 | - chmod +x usr/bin/launcher 15 | - cat > %{APPNAMELC}.desktop <<\EOF 16 | - [Desktop Entry] 17 | - Type=Application 18 | - Name=%{APPNAME} 19 | - Icon=/usr/share/icons/java 20 | - Exec=launcher 21 | - Categories=Utility; 22 | - EOF 23 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/src/deb/control/control: -------------------------------------------------------------------------------- 1 | Package: %{APPNAME} 2 | Version: 1.0.0 3 | Section: misc 4 | Priority: low 5 | Architecture: all 6 | Description: [[description]] 7 | Maintainer: %{AUTHOR} 8 | Depends: openjdk-11-jre -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/src/deb/install/%{APPNAMELC}: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/src/deb/install/%{APPNAMELC}_rpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/jre-11-openjdk/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ 4 | -------------------------------------------------------------------------------- /java_templates/java_argparse4j_cli_template/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import net.sourceforge.argparse4j.ArgumentParsers; 4 | import net.sourceforge.argparse4j.impl.Arguments; 5 | import net.sourceforge.argparse4j.inf.ArgumentParser; 6 | import net.sourceforge.argparse4j.inf.ArgumentParserException; 7 | import net.sourceforge.argparse4j.inf.Namespace; 8 | 9 | public class Main { 10 | public static void main(String[] args) { 11 | String version = Main.class.getPackage().getImplementationVersion(); 12 | if (version == null) version = "1.0-DEV"; 13 | 14 | ArgumentParser parser = ArgumentParsers.newFor("%{APPNAME}").build() 15 | .defaultHelp(true) 16 | .version(version) 17 | .description("Describe your project"); 18 | parser.addArgument("-v", "--version") 19 | .action(Arguments.version()) 20 | .help("Show version"); 21 | 22 | parser.addArgument("-d", "--debug") 23 | .action(Arguments.storeTrue()) 24 | .help("Debug information"); 25 | 26 | // Argparse4j allows you to parse/validate positional arguments 27 | parser.addArgument("args") 28 | .nargs("+") 29 | .help("Positional arguments"); 30 | parser.addArgument("args2") 31 | .help("Positional argument2"); 32 | 33 | Namespace namespace = null; 34 | try { 35 | namespace = parser.parseArgs(args); 36 | } catch (ArgumentParserException e) { 37 | parser.handleError(e); 38 | System.exit(1); 39 | } 40 | 41 | if (namespace.getBoolean("debug")) { 42 | System.out.println(namespace.getList("args")); 43 | System.out.println(namespace.getString("args2")); 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | .classpath 10 | .factorypath 11 | .project -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java -Dexec.args="$(args)" 3 | build: 4 | mvn compile package 5 | clean: 6 | mvn clean 7 | 8 | package-appimage: 9 | # Build appimage, build required jar file first 10 | mvn compile assembly:single 11 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdk.yml 12 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 13 | 14 | package-appimage-modular: 15 | # Build appimage, build required jar file first 16 | mvn compile assembly:single 17 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdkmodular.yml 18 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 19 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/README: -------------------------------------------------------------------------------- 1 | This project uses Maven and the JCommander libary. 2 | 3 | To run/build/install the project you can use the scripts from the Makerfile. 4 | 5 | If you want to pass in commands to the program you can type: make start args="" 6 | 7 | The RPM package config is based on: http://www.mojohaus.org/rpm-maven-plugin/example1.html 8 | 9 | If the modular AppImage fails to run, you can check with "jdeps --list-deps target/%{APPNAMELC}-1.0-jar-with-dependencies.jar" 10 | if there are additional modules needed and add them to the recipies/%{APPNAMELC}-java11openjdkmodular.yml file. 11 | 12 | Tip: If you want to start the file using ./filename.jar you can install the jarwrapper package. -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/java_templates/java_jcommander_cli_template/java.png -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/java_jcommander_cli_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Java CLI Using JCommander 3 | Comment=Setup with files and build scripts for a CLI with JCommander and the Maven architecture. 4 | Category=Java/Terminal 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/recipies/%{APPNAMELC}-java11openjdk.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Download JRE, replace with own script if you are not on a Debian based distro 5 | - apt download openjdk-11-jre-headless 6 | - mv openjdk-11-jre-headless*.deb openjdk-11-jre-headless.deb 7 | - ar vx openjdk-11-jre-headless.deb 8 | - rm control.tar.xz debian-binary openjdk-11-jre-headless.deb 9 | - tar xf data.tar.xz 10 | - ln -s ./lib/jvm/java-11-openjdk-amd64/bin/java usr/java 11 | # Copy icon, create folders 12 | - cp ../../java.png usr/share/icons/java.png 13 | - mkdir -p usr/lib/java/ 14 | # Copy jar file and make java executable 15 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 16 | - chmod +x usr/lib/jvm/java-11-openjdk-amd64/bin/java 17 | # Create Desktop Entry to launch application 18 | - cat > usr/bin/launcher <<\EOF 19 | - ./lib/jvm/java-11-openjdk-amd64/bin/java -jar %{APPNAMELC}.jar $@ 20 | - EOF 21 | - chmod +x usr/bin/launcher 22 | - cat > %{APPNAMELC}.desktop <<\EOF 23 | - [Desktop Entry] 24 | - Type=Application 25 | - Name=%{APPNAME} 26 | - Icon=/usr/share/icons/java 27 | - Exec=launcher 28 | - Categories=Utility; 29 | - EOF 30 | 31 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/recipies/%{APPNAMELC}-java11openjdkmodular.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Create custom JRE using required only modules => optimized file size 5 | - jlink --add-modules java.base --output usr/jre 6 | # Copy icon, create folders 7 | - cp ../../java.png usr/share/icons/java.png 8 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 9 | # Create Desktop Entry to launch application 10 | - echo "./bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 11 | - echo "./jre/bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 12 | - cat > usr/bin/launcher <<\EOF 13 | - ./jre/bin/java -jar %{APPNAMELC}.jar $@ 14 | - EOF 15 | - chmod +x usr/bin/launcher 16 | - cat > %{APPNAMELC}.desktop <<\EOF 17 | - [Desktop Entry] 18 | - Type=Application 19 | - Name=%{APPNAME} 20 | - Icon=/usr/share/icons/java 21 | - Exec=launcher 22 | - Categories=Utility; 23 | - EOF 24 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/src/deb/control/control: -------------------------------------------------------------------------------- 1 | Package: %{APPNAME} 2 | Version: 1.0.0 3 | Section: misc 4 | Priority: low 5 | Architecture: all 6 | Description: [[description]] 7 | Maintainer: %{AUTHOR} 8 | Depends: openjdk-11-jre -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/src/deb/install/%{APPNAMELC}: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/src/deb/install/%{APPNAMELC}_rpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/jre-11-openjdk/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ 4 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/src/main/java/main/Args.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import com.beust.jcommander.Parameter; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | class Args { 10 | @Parameter(description = "", required = true) 11 | private List args; 12 | 13 | @Parameter(names = {"-o", "--option"}) 14 | private String opt = ""; 15 | 16 | @Parameter(names = {"-d", "--debug"}, description = "Debug mode") 17 | private boolean debug = false; 18 | 19 | @Parameter(names = {"-h", "--help"}, description = "Display help information", help = true) 20 | private boolean help; 21 | 22 | @Parameter(names = {"-v", "--version"}, description = "Display version number", help = true) 23 | private boolean version; 24 | } 25 | -------------------------------------------------------------------------------- /java_templates/java_jcommander_cli_template/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import com.beust.jcommander.JCommander; 4 | 5 | public class Main { 6 | 7 | public static void main(String[] args) { 8 | Args parsedArgs = new Args(); 9 | JCommander builder = JCommander.newBuilder().addObject(parsedArgs).build(); 10 | 11 | builder.setProgramName("%{APPNAME}"); 12 | builder.parse(args); 13 | 14 | if (parsedArgs.isHelp()) { 15 | builder.usage(); 16 | return; 17 | } else if (parsedArgs.isVersion()) { 18 | // Correctly displayed in packaged jar 19 | System.out.println(builder.getProgramName() + " " + Main.class.getPackage().getImplementationVersion()); 20 | return; 21 | } 22 | 23 | if (parsedArgs.isDebug()) { 24 | System.out.println("Debug: " + parsedArgs.isDebug()); 25 | System.out.println("Positional argument: " + parsedArgs.getArgs().toString()); 26 | System.out.println("Option value: " + parsedArgs.getOpt()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java_templates/java_junit5_file_template/java_junit5_file_template.desktop: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=JUnit5 Template 3 | Comment=Basic JUnit5 Test Template 4 | Category=Java/Test 5 | Type=Test 6 | Language=Java 7 | Files=Test 8 | OptionsFile=options.kcfg 9 | 10 | [Test] 11 | Name=JUnit5 Test 12 | File=java_junit5_file_template.java 13 | OutputFile={{ name }}Test.java -------------------------------------------------------------------------------- /java_templates/java_junit5_file_template/java_junit5_file_template.java: -------------------------------------------------------------------------------- 1 | {% if package and package != "none" %} 2 | 3 | package {{ package }}; 4 | 5 | {% endif %} 6 | 7 | import static org.junit.jupiter.api.Assertions.*; 8 | 9 | 10 | import org.junit.jupiter.api.AfterAll; 11 | import org.junit.jupiter.api.AfterEach; 12 | import org.junit.jupiter.api.BeforeAll; 13 | import org.junit.jupiter.api.BeforeEach; 14 | import org.junit.jupiter.api.Disabled; 15 | import org.junit.jupiter.api.Test; 16 | 17 | 18 | class {{ name }}Test { 19 | 20 | {% if before_all_method %} 21 | 22 | 23 | @BeforeAll 24 | static void initAll() { 25 | } 26 | {% endif %} 27 | 28 | {% if before_each_method %} 29 | 30 | @BeforeEach 31 | void init() { 32 | } 33 | {% endif %} 34 | 35 | {% for test in testCases %} 36 | 37 | @Test 38 | void {{ test }}() { 39 | // TODO Implement 40 | } 41 | 42 | {% endfor %} 43 | 44 | {% if after_all_method %} 45 | @AfterEach 46 | void tearDown() { 47 | } 48 | {% endif %} 49 | 50 | 51 | {% if after_each_method %} 52 | @AfterAll 53 | static void tearDownAll() { 54 | } 55 | {% endif %} 56 | 57 | 58 | } -------------------------------------------------------------------------------- /java_templates/java_junit5_file_template/options.kcfg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | none 11 | 12 | 13 | 14 | true 15 | 16 | 17 | 18 | true 19 | 20 | 21 | 22 | true 23 | 24 | 25 | 26 | true 27 | 28 | 29 | -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.metadata 3 | /target 4 | /.settings 5 | /dist 6 | /.vscode 7 | /out 8 | /build 9 | /bin 10 | /.kdev4 11 | .classpath 12 | .factorypath 13 | .project 14 | -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java 3 | build: 4 | mvn compile assembly:single 5 | clean: 6 | mvn clean 7 | rm -rf bin 8 | test: 9 | mvn test 10 | install: 11 | chmod +x target/%{APPNAMELC}-*-jar-with-dependencies.jar 12 | mkdir -p bin 13 | cp target/%{APPNAMELC}-*-jar-with-dependencies.jar bin 14 | deploy: 15 | make clean build test install 16 | -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/java_maven_basic_setup.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Java Maven Project 3 | Comment=An empty Java project with Maven and configured tasks for running/testings/building the application. 4 | Category=Java/Empty 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | org.%{AUTHOR}.%{APPNAMELC} 7 | %{APPNAMELC} 8 | 1.0 9 | jar 10 | 11 | UTF-8 12 | 13 | 14 | 15 | 16 | 17 | org.junit.jupiter 18 | junit-jupiter-api 19 | 5.5.1 20 | test 21 | 22 | 23 | 24 | org.junit.jupiter 25 | junit-jupiter-params 26 | 5.5.1 27 | test 28 | 29 | 30 | 31 | org.junit.jupiter 32 | junit-jupiter-engine 33 | 5.5.1 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-compiler-plugin 44 | 3.8.1 45 | 46 | 8 47 | 8 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-surefire-plugin 54 | 3.0.0-M3 55 | 56 | 57 | 58 | org.codehaus.mojo 59 | exec-maven-plugin 60 | 1.6.0 61 | 62 | main.Main 63 | 64 | 65 | 66 | 67 | maven-assembly-plugin 68 | 3.1.1 69 | 70 | 71 | jar-with-dependencies 72 | 73 | 74 | 75 | main.Main 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello World!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /java_templates/java_maven_basic_setup/src/test/java/MainTest.java: -------------------------------------------------------------------------------- 1 | import org.junit.jupiter.api.DisplayName; 2 | import org.junit.jupiter.api.Test; 3 | 4 | import static org.junit.jupiter.api.Assertions.*; 5 | 6 | class MainTest { 7 | 8 | @Test 9 | @DisplayName("Very simple test") 10 | void simpleTest() { 11 | assertEquals(42, 42); 12 | assertNotEquals(42, 4587); 13 | } 14 | 15 | @Test 16 | @DisplayName("Another very simple test") 17 | void anotherSimpleTest() { 18 | assertEquals("Hello World!", "Hello World!"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | .classpath 10 | .factorypath 11 | .project 12 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java -Dexec.args="$(args)" 3 | build: 4 | mvn compile package 5 | make autocomplete 6 | clean: 7 | mvn clean 8 | rm -rf bin 9 | test: 10 | mvn test 11 | autocomplete: 12 | java -cp target/%{APPNAMELC}-1.0-jar-with-dependencies.jar picocli.AutoComplete -n %{APPNAMELC}-1.0-jar-with-dependencies.jar main.Args --force 13 | 14 | package-appimage: 15 | # Build appimage, build required jar file first 16 | mvn compile assembly:single 17 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdk.yml 18 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 19 | 20 | package-appimage-modular: 21 | # Build appimage, build required jar file first 22 | mvn compile assembly:single 23 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdkmodular.yml 24 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/README: -------------------------------------------------------------------------------- 1 | This project uses Maven and the PicoCLI library. 2 | 3 | To run/build/install the project you can use the scripts from the Makerfile, this requires you to have Maven installed. 4 | If you want to pass in commands to the program you can type: make start args="" 5 | 6 | The RPM package config is based on: http://www.mojohaus.org/rpm-maven-plugin/example1.html 7 | 8 | If the modular AppImage fails to run, you can check with "jdeps --list-deps target/%{APPNAMELC}-1.0-jar-with-dependencies.jar" 9 | if there are additional modules needed and add them to the recipies/%{APPNAMELC}-java11openjdkmodular.yml file. 10 | 11 | Tip: If you want to start the program using ./filename.jar you can install the jarwrapper package. -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/java_templates/java_picocli_cli_template/java.png -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/java_picocli_cli_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Java CLI using Picocli 3 | Comment=Setup with files and build scripts for a CLI with Picocli and the Maven architecture. The Makefile also has a command to generate the autocompletion file implemented. 4 | Category=Java/Terminal 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/recipies/%{APPNAMELC}-java11openjdk.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Download JRE, replace with own script if you are not on a Debian based distro 5 | - apt download openjdk-11-jre-headless 6 | - mv openjdk-11-jre-headless*.deb openjdk-11-jre-headless.deb 7 | - ar vx openjdk-11-jre-headless.deb 8 | - rm control.tar.xz debian-binary openjdk-11-jre-headless.deb 9 | - tar xf data.tar.xz 10 | - ln -s ./lib/jvm/java-11-openjdk-amd64/bin/java usr/java 11 | # Copy icon, create folders 12 | - cp ../../java.png usr/share/icons/java.png 13 | - mkdir -p usr/lib/java/ 14 | # Copy jar file and make java executable 15 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 16 | - chmod +x usr/lib/jvm/java-11-openjdk-amd64/bin/java 17 | # Create Desktop Entry to launch application 18 | - cat > usr/bin/launcher <<\EOF 19 | - ./lib/jvm/java-11-openjdk-amd64/bin/java -jar %{APPNAMELC}.jar $@ 20 | - EOF 21 | - chmod +x usr/bin/launcher 22 | - cat > %{APPNAMELC}.desktop <<\EOF 23 | - [Desktop Entry] 24 | - Type=Application 25 | - Name=%{APPNAME} 26 | - Icon=/usr/share/icons/java 27 | - Exec=launcher 28 | - Categories=Utility; 29 | - EOF 30 | 31 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/recipies/%{APPNAMELC}-java11openjdkmodular.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Create custom JRE using required only modules => optimized file size 5 | - jlink --add-modules java.base --output usr/jre 6 | # Copy icon, create folders 7 | - cp ../../java.png usr/share/icons/java.png 8 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 9 | # Create Desktop Entry to launch application 10 | - echo "./bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 11 | - echo "./jre/bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 12 | - cat > usr/bin/launcher <<\EOF 13 | - ./jre/bin/java -jar %{APPNAMELC}.jar $@ 14 | - EOF 15 | - chmod +x usr/bin/launcher 16 | - cat > %{APPNAMELC}.desktop <<\EOF 17 | - [Desktop Entry] 18 | - Type=Application 19 | - Name=%{APPNAME} 20 | - Icon=/usr/share/icons/java 21 | - Exec=launcher 22 | - Categories=Utility; 23 | - EOF 24 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/src/deb/control/control: -------------------------------------------------------------------------------- 1 | Package: %{APPNAME} 2 | Version: 1.0.0 3 | Section: misc 4 | Priority: low 5 | Architecture: all 6 | Description: [[description]] 7 | Maintainer: %{AUTHOR} 8 | Depends: openjdk-11-jre -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/src/deb/install/%{APPNAMELC}: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/src/deb/install/%{APPNAMELC}_rpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/jre-11-openjdk/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ 4 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/src/main/java/main/Args.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import lombok.Data; 4 | import picocli.CommandLine.*; 5 | 6 | @Data 7 | @Command(description = "Description of this command", versionProvider = Args.MavenVersionProvider.class) 8 | public class Args { 9 | 10 | @Parameters(description = "person to greet", defaultValue = "World") 11 | private String name; 12 | 13 | 14 | @Option(names = {"-d", "--debug"}, negatable = true, description = "debug given information") 15 | private boolean debug = false; 16 | 17 | @Option(names = {"-h", "--help"}, usageHelp = true, description = "display a help message") 18 | private boolean helpRequested = false; 19 | 20 | @Option(names = {"-v", "--version"}, versionHelp = true, description = "display a version message") 21 | private boolean versionRequested = false; 22 | 23 | static class MavenVersionProvider implements IVersionProvider { 24 | 25 | @Override 26 | public String[] getVersion() { 27 | String version = getClass().getPackage().getImplementationVersion(); 28 | if (version == null) version = "DEV"; 29 | return new String[]{"%{APPNAME}" + ": " + version}; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import picocli.CommandLine; 4 | 5 | import java.util.Arrays; 6 | 7 | public class Main { 8 | public static void main(String[] args) { 9 | Args parsedArgs = new Args(); 10 | CommandLine commandLine = new CommandLine(parsedArgs); 11 | commandLine.setCommandName("%{APPNAMELC}"); 12 | commandLine.parseArgs(args); 13 | 14 | 15 | if (commandLine.isUsageHelpRequested()) { 16 | commandLine.usage(System.out); 17 | return; 18 | } else if (commandLine.isVersionHelpRequested()) { 19 | commandLine.printVersionHelp(System.out); 20 | return; 21 | } 22 | 23 | if (parsedArgs.isDebug()) { 24 | System.out.println("Command line arguments: " + Arrays.toString(args)); 25 | System.out.println("Name: " + parsedArgs.getName()); 26 | } 27 | 28 | System.out.println("Hello " + parsedArgs.getName() + " !"); 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java_templates/java_picocli_cli_template/src/test/java/ExampleTest.java: -------------------------------------------------------------------------------- 1 | import main.Args; 2 | import org.junit.jupiter.api.Test; 3 | import picocli.CommandLine; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertTrue; 6 | 7 | class ExampleTest { 8 | 9 | @Test 10 | void checkHelpRequest() { 11 | String[] args = {"--help"}; 12 | Args parsedArgs = new Args(); 13 | CommandLine commandLine = new CommandLine(parsedArgs); 14 | commandLine.parseArgs(args); 15 | 16 | assertTrue(commandLine.isUsageHelpRequested()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java 3 | build: 4 | mvn compile assembly:single 5 | clean: 6 | mvn clean 7 | rm -rf bin 8 | install: 9 | chmod +x target/%{APPNAMELC}-*-jar-with-dependencies.jar 10 | mkdir -p bin 11 | cp target/%{APPNAMELC}-*-jar-with-dependencies.jar bin 12 | deploy: 13 | make clean build install 14 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/README: -------------------------------------------------------------------------------- 1 | This template used Maven and JavaFX. 2 | 3 | You can run the project with your IDE of choice or in the command line (maven package is required). 4 | 5 | Tip: If you want to start the file using ./filename.jar you can install the jarwrapper package. -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/javafx_fxml_maven_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=JavaFX Application With Maven and FXML 3 | Comment=Setup with files and build scripts for a JavaFX application with the Maven architecture. 4 | Category=Java/JavaFX 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.author.%{APPNAMELC} 8 | %{APPNAMELC} 9 | 1.0 10 | 11 | UTF-8 12 | 13 | 14 | 15 | 16 | 17 | org.apache.maven.plugins 18 | maven-compiler-plugin 19 | 3.8.1 20 | 21 | 8 22 | 8 23 | 24 | 25 | 26 | 27 | org.codehaus.mojo 28 | exec-maven-plugin 29 | 1.6.0 30 | 31 | main.Main 32 | 33 | 34 | 35 | 36 | maven-assembly-plugin 37 | 3.1.1 38 | 39 | 40 | jar-with-dependencies 41 | 42 | 43 | 44 | main.Main 45 | true 46 | true 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/src/main/java/main/Controller.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.fxml.FXML; 4 | import javafx.fxml.Initializable; 5 | import javafx.scene.control.Label; 6 | 7 | import java.net.URL; 8 | import java.util.ResourceBundle; 9 | 10 | public class Controller implements Initializable { 11 | 12 | @FXML 13 | private Label helloWorldLabel; 14 | 15 | @Override 16 | public void initialize(URL location, ResourceBundle resources) { 17 | helloWorldLabel.setText(resources.getString("message")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | import java.util.ResourceBundle; 10 | 11 | public class Main extends Application { 12 | 13 | @Override 14 | public void start(Stage window) throws Exception{ 15 | ResourceBundle bundle = ResourceBundle.getBundle("translations"); 16 | Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"), bundle); 17 | window.setTitle("Hello World"); 18 | window.setScene(new Scene(root, 300, 275)); 19 | window.show(); 20 | } 21 | 22 | 23 | public static void main(String[] args) { 24 | launch(args); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/src/main/resources/main/sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_template/src/main/resources/translations.properties: -------------------------------------------------------------------------------- 1 | message=Hello World! -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java 3 | build: 4 | mvn compile assembly:single 5 | clean: 6 | mvn clean 7 | rm -rf bin 8 | test: 9 | mvn test 10 | install: 11 | chmod +x target/%{APPNAMELC}-*-jar-with-dependencies.jar 12 | mkdir -p bin 13 | cp target/%{APPNAMELC}-*-jar-with-dependencies.jar bin 14 | deploy: 15 | make clean build test install 16 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/README: -------------------------------------------------------------------------------- 1 | This template used Maven, JavaFX and TestFX. 2 | 3 | You can run the project with your IDE of choice or in the command line (maven package is required) 4 | 5 | Additionally this project has a headless test setup for the TestFX library. 6 | 7 | Tip: If you want to start the file using ./filename.jar you can install the jarwrapper package. -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/javafx_fxml_maven_testfx_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=JavaFX App With Maven and Testing 3 | Comment=Setup with files and build scripts for a JavaFX application with the Maven architecture and headless TestFX testing. 4 | Category=Java/JavaFX 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/src/main/java/main/Controller.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.fxml.FXML; 4 | import javafx.fxml.Initializable; 5 | import javafx.scene.control.Label; 6 | 7 | import java.net.URL; 8 | import java.util.ResourceBundle; 9 | 10 | public class Controller implements Initializable { 11 | 12 | @FXML 13 | private Label helloWorldLabel; 14 | 15 | @Override 16 | public void initialize(URL location, ResourceBundle resources) { 17 | if(resources != null){ 18 | helloWorldLabel.setText(resources.getString("message")); 19 | }else { 20 | helloWorldLabel.setText("Hello Default!"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | import java.util.ResourceBundle; 10 | 11 | public class Main extends Application { 12 | 13 | @Override 14 | public void start(Stage window) throws Exception{ 15 | ResourceBundle bundle = ResourceBundle.getBundle("translations"); 16 | Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"), bundle); 17 | window.setTitle("Hello World"); 18 | window.setScene(new Scene(root, 300, 275)); 19 | window.show(); 20 | } 21 | 22 | 23 | public static void main(String[] args) { 24 | launch(args); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/src/main/resources/main/sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/src/main/resources/translations.properties: -------------------------------------------------------------------------------- 1 | message=Hello World! -------------------------------------------------------------------------------- /java_templates/javafx_fxml_maven_testfx_template/src/test/java/main/MainTest.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.fxml.FXMLLoader; 4 | import javafx.scene.Parent; 5 | import javafx.scene.Scene; 6 | import javafx.scene.control.Label; 7 | import javafx.stage.Stage; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.api.Test; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertEquals; 12 | 13 | import org.testfx.framework.junit5.ApplicationTest; 14 | 15 | public class MainTest extends ApplicationTest { 16 | 17 | // Headless testing 18 | @BeforeAll 19 | static void setUp() { 20 | if (Boolean.getBoolean("headless")) { 21 | System.setProperty("testfx.robot", "glass"); 22 | System.setProperty("testfx.headless", "true"); 23 | System.setProperty("prism.order", "sw"); 24 | System.setProperty("prism.text", "t2k"); 25 | System.setProperty("java.awt.headless", "true"); 26 | } 27 | } 28 | 29 | public void start(Stage stage) throws Exception { 30 | Parent rootNode = FXMLLoader.load(getClass().getResource("sample.fxml")); 31 | Scene scene = new Scene(rootNode); 32 | stage.setTitle("Hello JavaFX and Maven Test"); 33 | stage.setScene(scene); 34 | stage.show(); 35 | } 36 | 37 | 38 | @Test 39 | void labelTextTest() { 40 | interact(()->{ 41 | Label label = lookup("#helloWorldLabel").query(); 42 | assertEquals(label.getText(), "Hello Default!"); 43 | }); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/%{APPNAME}.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /.metadata 3 | /target 4 | /.settings 5 | /dist 6 | /.vscode 7 | /out 8 | /build 9 | /bin -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/Makefile: -------------------------------------------------------------------------------- 1 | compile: 2 | make copy_resources 3 | javac -d build -sourcepath src src/main/Main.java src/main/Controller.java 4 | copy_resources: 5 | mkdir -p build/main 6 | cp src/main/sample.fxml build/main 7 | start: 8 | java -cp build main.Main 9 | clean: 10 | rm -rf build 11 | rm -rf bin 12 | start_dev: 13 | make compile start 14 | package: 15 | make clean 16 | make compile 17 | mkdir -p bin 18 | echo "Main-Class: main.Main" > build/MANIFEST.MF 19 | jar -cfm bin/project.jar build/MANIFEST.MF -C build/ . 20 | chmod +x bin/project.jar 21 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/javafx_fxml_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=JavaFX Application with FXML 3 | Comment=A Hello World JavaFX Application which uses FXML and MVC Design Pattern 4 | Category=Java/JavaFX 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/src/main/Controller.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.fxml.FXML; 4 | import javafx.fxml.Initializable; 5 | import javafx.scene.control.Label; 6 | 7 | import java.net.URL; 8 | import java.util.ResourceBundle; 9 | 10 | public class Controller implements Initializable { 11 | 12 | @FXML 13 | private Label helloWorldLabel; 14 | 15 | @Override 16 | public void initialize(URL location, ResourceBundle resources) { 17 | helloWorldLabel.setText("Hello World!"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/src/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | public class Main extends Application { 10 | 11 | @Override 12 | public void start(Stage window) throws Exception{ 13 | Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); 14 | window.setTitle("Hello World!"); 15 | window.setScene(new Scene(root, 300, 275)); 16 | window.show(); 17 | } 18 | 19 | 20 | public static void main(String[] args) { 21 | launch(args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /java_templates/javafx_fxml_template/src/main/sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/%{APPNAMELC}.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.idea 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode 8 | /out 9 | /%{APPNAME} -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/Makefile: -------------------------------------------------------------------------------- 1 | start: 2 | mvn compile exec:java 3 | test: 4 | mvn test 5 | clean: 6 | # Deletes compile output and AppImage folder 7 | rm -rf target/* 8 | rm -rf %{APPNAME}/* 9 | package-javafxpackager: 10 | # Files get created in target/jfx/native/%{APPNAMELC} 11 | # This requires the oracle java8 jdk 12 | export JAVA_HOME="/usr/lib/jvm/java-8-oracle/"; mvn jfx:native 13 | package-appimage: 14 | # Build appimage, build required jar file first 15 | mvn compile assembly:single 16 | ./pkg2appimage recipies/%{APPNAMELC}-java11openjdk.yml 17 | cd ./%{APPNAME} && ./appimagetool %{APPNAME}.AppDir/ 18 | package: 19 | # Builds standalone jar and deb package 20 | mvn compile package 21 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/README: -------------------------------------------------------------------------------- 1 | This template used Maven, JavaFX and TestFX. 2 | 3 | Additionally it has build scripts for deb, rpm, app images, snap and executable jars configured. 4 | 5 | It is also compatible with oracle jdk 8 and any higher versions <=11 if you adjust the dependencies 6 | in the pom.xml file. 7 | 8 | Note: The JFoenix library is just for demo purposes included. 9 | 10 | The script pkg2appimage if from: https://github.com/AppImage/pkg2appimage/blob/master/pkg2appimage 11 | 12 | The RPM package config is based on: http://www.mojohaus.org/rpm-maven-plugin/example1.html 13 | 14 | Snap packaging requires: 15 | Snap to be installed end enabled, 16 | sudo snap install snapcraft --clasic 17 | sudo snap install multipass --beta --classic 18 | 19 | If you have these programs set up you can run "snapcraft" to build your snap package 20 | and then "sudo snap install MY_PROJECT.snap --devmode " 21 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/java_templates/javafx_maven_build_scripts/java.png -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/javafx_maven_build_scripts.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=JavaFX With Maven, Testing, Build Scripts 3 | Comment=Setup with files for a JavaFX application with the Maven architecture, headless TestFX testing and build scripts for: Jar, AppImage, Deb, Rpm, Snap. 4 | Category=Java/JavaFX 5 | Icon=application-x-java -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/recipies/%{APPNAMELC}-java11openjdk.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | # Download JRE, replace with own script if you are not on a Debian based distro 5 | - apt download openjdk-11-jre-headless 6 | - mv openjdk-11-jre-headless*.deb openjdk-11-jre-headless.deb 7 | - ar vx openjdk-11-jre-headless.deb 8 | - rm control.tar.xz debian-binary openjdk-11-jre-headless.deb 9 | - tar xf data.tar.xz 10 | - ln -s ./lib/jvm/java-11-openjdk-amd64/bin/java usr/java 11 | # Copy icon, create folders 12 | - cp ../../java.png usr/share/icons/java.png 13 | - mkdir -p usr/lib/java/ 14 | # Copy jar file and make java executable 15 | - cp ../../target/%{APPNAMELC}-*-jar-with-dependencies.jar usr/%{APPNAMELC}.jar 16 | - chmod +x usr/lib/jvm/java-11-openjdk-amd64/bin/java 17 | # Create Desktop Entry to launch application 18 | - echo "./lib/jvm/java-11-openjdk-amd64/bin/java -jar %{APPNAMELC}.jar" > usr/bin/launcher 19 | - chmod +x usr/bin/launcher 20 | - cat > %{APPNAMELC}.desktop <<\EOF 21 | - [Desktop Entry] 22 | - Type=Application 23 | - Name=%{APPNAME} 24 | - Icon=/usr/share/icons/java 25 | - Exec=launcher 26 | - Categories=Utility; 27 | - EOF 28 | 29 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/recipies/%{APPNAMELC}-javafxpackager.yml: -------------------------------------------------------------------------------- 1 | app: %{APPNAME} 2 | 3 | script: 4 | - cp -r ../../target/jfx/native/%{APPNAMELC}-1.0/* usr/bin 5 | - cp ../../java.png usr/share/icons/java.png 6 | - cat > %{APPNAMELC}.desktop <<\EOF 7 | - [Desktop Entry] 8 | - Type=Application 9 | - Name=%{APPNAME} 10 | - Icon=/usr/share/icons/java 11 | - Exec=%{APPNAMELC}-1.0 12 | - Categories=Utility; 13 | - EOF 14 | - chmod +x usr/bin/%{APPNAMELC}-1.0 15 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: %{APPNAMELC} # you probably want to 'snapcraft register ' 2 | base: core18 # the base snap is the execution environment for this snap 3 | version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' 4 | summary: Single-line elevator pitch for your amazing snap # 79 char long summary 5 | description: | 6 | This is my-snap's description. You have a paragraph or two to tell the 7 | most important story about your snap. Keep it under 100 words though, 8 | we live in tweetspace and your description wants to look good in the snap 9 | store. 10 | 11 | grade: devel # must be 'stable' to release into candidate/stable channels 12 | confinement: devmode # use 'strict' once you have the right plugs and slots 13 | 14 | apps: 15 | %{APPNAMELC}: 16 | command: usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar $SNAP/usr/lib/java/%{APPNAMELC}.jar 17 | desktop: usr/share/applications/%{APPNAMELC}-snap.desktop 18 | extensions: 19 | - gnome-3-28 # For fonts etc. required 20 | environment: 21 | JAVA_HOME: "$SNAP/usr/lib/jvm/java-11-openjdk-amd64" 22 | JAVA_TOOL_OPTIONS: "-Duser.home=$SNAP_USER_COMMON" 23 | plugs: 24 | - home 25 | - network 26 | parts: 27 | %{APPNAMELC}: 28 | plugin: maven 29 | source: . 30 | override-build: | 31 | mvn compile test assembly:single 32 | mkdir -p /root/prime/usr/share/applications/ 33 | mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr/lib/java/ 34 | cp target/%{APPNAMELC}-*-jar-with-dependencies.jar "${SNAPCRAFT_PART_INSTALL}/usr/lib/java/%{APPNAMELC}.jar" 35 | cp src/deb/install/%{APPNAMELC}-snap.desktop /root/prime/usr/share/applications/%{APPNAMELC}-snap.desktop 36 | build-packages: [openjdk-11-jdk, openjfx, maven] 37 | stage-packages: [openjdk-11-jre] 38 | 39 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/deb/control/control: -------------------------------------------------------------------------------- 1 | Package: %{APPNAMELC} 2 | Version: 1.0.0 3 | Section: misc 4 | Priority: low 5 | Architecture: all 6 | Description: [[description]] 7 | Maintainer: %{AUTHOR} 8 | Depends: openjdk-11-jre -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/deb/install/%{APPNAMELC}: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/deb/install/%{APPNAMELC}-snap.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Categories=Application; 3 | Comment=Just a hello world project 4 | Exec=usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar 5 | GenericName=%{APPNAME} 6 | Icon=openjdk-11 7 | Name=%{APPNAME} 8 | Type=Application 9 | Version=1.0 10 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/deb/install/%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Categories=Application; 3 | Comment=Just a hello world project 4 | Exec=/usr/lib/jvm/java-11-openjdk-amd64/bin/java -jar /usr/share/java/%{APPNAMELC}.jar 5 | GenericName=My Java Application 6 | Icon=application-x-java 7 | Name=%{APPNAME} 8 | Type=Application 9 | Version=1.0 10 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/deb/install/%{APPNAMELC}_rpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | /usr/lib/jvm/jre-11-openjdk/bin/java -jar /usr/share/java/%{APPNAMELC}.jar $@ 4 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/deb/install/%{APPNAMELC}_rpm.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Categories=Application; 3 | Comment=Just a hello world project 4 | Exec=/usr/lib/jvm/jre-11-openjdk/bin/java -jar /usr/share/java/%{APPNAMELC}.jar 5 | GenericName=My Java Application 6 | Icon=application-x-java 7 | Name=%{APPNAME} 8 | Type=Application 9 | Version=1.0 10 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/main/java/main/Controller.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import javafx.fxml.FXML; 5 | import javafx.fxml.Initializable; 6 | import javafx.scene.control.Label; 7 | 8 | import java.net.URL; 9 | import java.util.ResourceBundle; 10 | 11 | public class Controller implements Initializable { 12 | 13 | @FXML 14 | private JFXButton btn; 15 | 16 | @Override 17 | public void initialize(URL location, ResourceBundle resources) { 18 | if(resources != null){ 19 | btn.setText(resources.getString("message")); 20 | }else { 21 | btn.setText("Hello Default!"); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/main/java/main/Launcher.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | // Used as a wrapper 4 | public class Launcher { 5 | public static void main(String[] args) { 6 | Main.main(args); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/main/java/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | import java.util.ResourceBundle; 10 | 11 | public class Main extends Application { 12 | 13 | @Override 14 | public void start(Stage window) throws Exception{ 15 | ResourceBundle bundle = ResourceBundle.getBundle("translations"); 16 | Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"), bundle); 17 | window.setTitle("Hello World"); 18 | window.setScene(new Scene(root, 300, 275)); 19 | window.show(); 20 | } 21 | 22 | 23 | public static void main(String[] args) { 24 | launch(args); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/main/resources/main/sample.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/main/resources/translations.properties: -------------------------------------------------------------------------------- 1 | message=Hello World! 2 | -------------------------------------------------------------------------------- /java_templates/javafx_maven_build_scripts/src/test/java/main/MainTest.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import com.jfoenix.controls.JFXButton; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.scene.control.Label; 8 | import javafx.stage.Stage; 9 | import org.junit.jupiter.api.BeforeAll; 10 | import org.junit.jupiter.api.Disabled; 11 | import org.junit.jupiter.api.Test; 12 | 13 | import static org.junit.jupiter.api.Assertions.assertEquals; 14 | 15 | import org.testfx.framework.junit5.ApplicationTest; 16 | 17 | public class MainTest extends ApplicationTest { 18 | 19 | // Headless testing 20 | @BeforeAll 21 | static void setUp() { 22 | if (Boolean.getBoolean("headless")) { 23 | System.setProperty("testfx.robot", "glass"); 24 | System.setProperty("testfx.headless", "true"); 25 | System.setProperty("prism.order", "sw"); 26 | System.setProperty("prism.text", "t2k"); 27 | System.setProperty("java.awt.headless", "true"); 28 | } 29 | } 30 | 31 | public void start(Stage stage) throws Exception { 32 | Parent rootNode = FXMLLoader.load(getClass().getResource("sample.fxml")); 33 | Scene scene = new Scene(rootNode); 34 | stage.setTitle("Hello JavaFX and Maven Test"); 35 | stage.setScene(scene); 36 | stage.show(); 37 | } 38 | 39 | 40 | @Test 41 | void labelTextTest() { 42 | interact(()->{ 43 | JFXButton btn = lookup("#btn").query(); 44 | assertEquals(btn.getText(), "Hello Default!"); 45 | }); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /kdevelop_app_template/%{APPNAMELC}/%{APPNAMELC}.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=%{APPNAME} 3 | Comment=A short comment... 4 | Category=Category/Subcategory 5 | Icon=planetkde 6 | -------------------------------------------------------------------------------- /kdevelop_app_template/%{APPNAMELC}/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *.kdev4 -------------------------------------------------------------------------------- /kdevelop_app_template/%{APPNAMELC}/ExampleFile.txt: -------------------------------------------------------------------------------- 1 | This is an example file from the %{APPNAME} project template -------------------------------------------------------------------------------- /kdevelop_app_template/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap -------------------------------------------------------------------------------- /kdevelop_app_template/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | include(FeatureSummary) 4 | 5 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 6 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 7 | 8 | include(KDEInstallDirs) 9 | include(KDEPackageAppTemplates) 10 | 11 | set(%{APPNAMELC}_DIRS 12 | %{APPNAMELC} 13 | ) 14 | 15 | kde_package_app_templates(TEMPLATES ${%{APPNAMELC}_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 16 | -------------------------------------------------------------------------------- /kdevelop_app_template/kdevelop_app_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=KDevelop App Template 3 | Comment=This template sets up your custom KDevelop template which is packaged using CMake. Additionally it contains a package script that packages and updates the template in your local folder. 4 | Category=KDevelop/Template 5 | ShowFilesAfterGeneration=%{APPNAMELC}/%{APPNAMELC}.kdevtemplate 6 | -------------------------------------------------------------------------------- /kdevelop_app_template/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | mkdir -p ~/.local/share/kdevappwizard/template_descriptions/ 5 | mkdir -p ~/.local/share/kdevappwizard/templates/ 6 | 7 | # This automatically updates/installs the template in your local templates folder 8 | if [[ $(basename "$PWD") == "%{PROJECTDIRNAME}" ]];then 9 | mkdir -p build 10 | rm -rf build/* 11 | cd build 12 | cmake .. 13 | make 14 | /bin/cp ../%{APPNAMELC}/%{APPNAMELC}.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions/ 15 | /bin/cp %{APPNAMELC}.tar.bz2 ~/.local/share/kdevappwizard/templates/ 16 | else 17 | echo "Please go to the project root" 18 | fi -------------------------------------------------------------------------------- /kdevelop_file_template/%{APPNAMELC}/%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [General] 2 | # See https://techbase.kde.org/KDevelop5/File_template_specification for documentation 3 | Name=%{APPNAME} 4 | Comment= 5 | Category=MyCategory/Subcategory 6 | Type=Class 7 | Language=MyProgrammingLanguage 8 | Files=MYFILE 9 | OptionsFile=options.kcfg 10 | 11 | [MYFILE] 12 | Name=Demo File 13 | File=DemoFile.txt 14 | OutputFile={{ name }}.txt -------------------------------------------------------------------------------- /kdevelop_file_template/%{APPNAMELC}/DemoFile.txt: -------------------------------------------------------------------------------- 1 | Example Value: {{ example }} -------------------------------------------------------------------------------- /kdevelop_file_template/%{APPNAMELC}/options.kcfg: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | Example tooltip (optional) 10 | 11 | :-) 12 | 13 | 14 | -------------------------------------------------------------------------------- /kdevelop_file_template/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *.kdev4 -------------------------------------------------------------------------------- /kdevelop_file_template/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | include(FeatureSummary) 4 | 5 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 6 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 7 | 8 | include(KDEInstallDirs) 9 | include(KDEPackageAppTemplates) 10 | 11 | set(%{APPNAMELC}_DIRS 12 | %{APPNAMELC} 13 | ) 14 | 15 | kde_package_app_templates(TEMPLATES ${%{APPNAMELC}_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 16 | -------------------------------------------------------------------------------- /kdevelop_file_template/kdevelop_file_template_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=KDevelop File Template 3 | Comment=This template sets up your custom KDevelop file template which is packaged using CMake. Additionally it contains a package script that packages and updates the template in your local folder. 4 | Category=KDevelop/Template 5 | ShowFilesAfterGeneration=%{APPNAMELC}/%{APPNAMELC}.desktop 6 | -------------------------------------------------------------------------------- /kdevelop_file_template/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ~/.local/share/kdevfiletemplates/template_descriptions/ 4 | mkdir -p ~/.local/share/kdevfiletemplates/templates/ 5 | 6 | # This automatically updates/installs the template in your local templates folder 7 | if [[ $(basename "$PWD") == "%{PROJECTDIRNAME}" ]];then 8 | mkdir -p build 9 | rm -rf build/* 10 | cd build 11 | cmake .. 12 | make 13 | cp ../%{APPNAMELC}/%{APPNAMELC}.desktop ~/.local/share/kdevfiletemplates/template_descriptions/ 14 | cp %{APPNAMELC}.tar.bz2 ~/.local/share/kdevfiletemplates/templates/ 15 | else 16 | echo "Please go to the project root" 17 | fi -------------------------------------------------------------------------------- /krunner_dbus_templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(simple_krunner_python_template_DIRS simple_krunner_python_template) 2 | set(modular_krunner_python_template_DIRS modular_krunner_python_template) 3 | set(js_runner_template_DIRS krunner_dbus_javascript) 4 | kde_package_app_templates(TEMPLATES ${simple_krunner_python_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 5 | kde_package_app_templates(TEMPLATES ${modular_krunner_python_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 6 | kde_package_app_templates(TEMPLATES ${js_runner_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 7 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *kdev4 -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | include(FeatureSummary) 4 | 5 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 6 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 7 | 8 | include(KDEInstallDirs) 9 | include(KDEPackageAppTemplates) 10 | 11 | set(krunner_dbus_cpp_DIRS 12 | krunner_dbus_cpp 13 | ) 14 | 15 | kde_package_app_templates(TEMPLATES ${krunner_dbus_cpp_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 16 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | /target 6 | *.swap 7 | *.kdev4 8 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | if (NOT CMAKE_BUILD_TYPE) 5 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) 6 | endif() 7 | 8 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 9 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 10 | 11 | # Find the required Libaries 12 | find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS DBus) 13 | find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Runner) 14 | include(KDEInstallDirs) 15 | include(KDECMakeSettings) 16 | include(KDECompilerSettings NO_POLICY_SCOPE) 17 | include(FeatureSummary) 18 | 19 | add_subdirectory(src) 20 | 21 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 22 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/README.md: -------------------------------------------------------------------------------- 1 | ## %{APPNAME} 2 | 3 | This is a KRunner plugin written in C++ and Qt which uses the DBus API. 4 | It is based on a test class of the official KRunner project: https://github.com/KDE/krunner/blob/master/autotests/testremoterunner.h 5 | For more information and the advantages of DBus visit: http://blog.davidedmundson.co.uk/blog/cross-process-runners/ 6 | 7 | ### Required Dependencies 8 | 9 | Debian/Ubuntu: 10 | `sudo apt install cmake extra-cmake-modules build-essential libkf5runner-dev` 11 | 12 | openSUSE: 13 | `sudo zypper install cmake extra-cmake-modules libQt5Core5 krunner-devel` 14 | 15 | Fedora: 16 | `sudo dnf install cmake extra-cmake-modules kf5-krunner-devel` 17 | 18 | Arch (Manjaro): 19 | `sudo pacman -S cmake extra-cmake-modules` 20 | 21 | ### Build instructions 22 | 23 | ``` 24 | cd /path/to/%{APPNAME} 25 | mkdir build 26 | cd build 27 | cmake .. 28 | make 29 | make install 30 | kquitapp5 krunner 2> /dev/null; kstart5 --windowclass krunner krunner > /dev/null 2>&1 & 31 | ``` 32 | The `make install` command installs the config file. You have to start the executable manually: 33 | `./build/bin/%{APPNAMELC}` 34 | Or you can start the app using your IDE and for example a debugger. 35 | 36 | If you want to install the app you have to configure your project differently: 37 | `cmake -DCMAKE_BUILD_TYPE=Release ..` 38 | With this the `make install` command will place the executable in the ~/.config/autostart-scripts/ folder and the build is optimized. 39 | 40 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/krunner_dbus_cpp.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Krunner DBus C++ 3 | Comment=Krunner plugin which uses DBus written in C++ and Qt, based on files from the official KRunner project. 4 | Category=Plasma/KRunner 5 | Icon=planetkde 6 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. See License in the project root for license information. 2 | #include "%{APPNAMELC}.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | // Generated by qt5_add_dbus_adaptor command im CMakeLists.txt file 12 | #include "krunner1adaptor.h" 13 | 14 | %{APPNAME}::%{APPNAME}() { 15 | new Krunner1Adaptor(this); 16 | qDBusRegisterMetaType(); 17 | qDBusRegisterMetaType(); 18 | qDBusRegisterMetaType(); 19 | qDBusRegisterMetaType(); 20 | QDBusConnection::sessionBus().registerService(QStringLiteral("net.%{APPNAMELC}2")); 21 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/%{APPNAMELC}"), this); 22 | } 23 | 24 | RemoteMatches %{APPNAME}::Match(const QString &searchTerm) { 25 | RemoteMatches ms; 26 | if (searchTerm.contains(QLatin1String("hello"))) { 27 | RemoteMatch m; 28 | m.id = QStringLiteral("id"); 29 | m.text = QStringLiteral("Hello There!"); 30 | m.iconName = QStringLiteral("planetkde"); 31 | m.type = Plasma::QueryMatch::ExactMatch; 32 | m.relevance = 0.8; 33 | ms.append(m); 34 | } 35 | return ms; 36 | 37 | } 38 | 39 | RemoteActions %{APPNAME}::Actions() { 40 | RemoteAction action; 41 | action.id = QStringLiteral("action1"); 42 | action.text = QStringLiteral("Action 1"); 43 | action.iconName = QStringLiteral("documentinfo"); 44 | 45 | return RemoteActions({action}); 46 | } 47 | 48 | void %{APPNAME}::Run(const QString &id, const QString &actionId) { 49 | std::cout << "Running:" << qPrintable(id) << ":" << qPrintable(actionId) << std::endl; 50 | std::cout.flush(); 51 | } 52 | 53 | int main(int argc, char **argv) { 54 | QCoreApplication app(argc, argv); 55 | %{APPNAME} r; 56 | QCoreApplication::exec(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. See License in the project root for license information. 2 | #pragma once 3 | 4 | #include 5 | #include "dbus_utils.h" 6 | 7 | class %{APPNAME} : public QObject { 8 | Q_OBJECT 9 | 10 | public: 11 | explicit %{APPNAME}(); 12 | 13 | public Q_SLOTS: 14 | 15 | RemoteActions Actions(); 16 | 17 | RemoteMatches Match(const QString &searchTerm); 18 | 19 | void Run(const QString &id, const QString &actionId); 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 2 | 3 | qt5_add_dbus_adaptor(%{APPNAMELC}_SRCS "/usr/share/dbus-1/interfaces/kf5_org.kde.krunner1.xml" %{APPNAMELC}.h %{APPNAME}) 4 | 5 | add_executable(%{APPNAMELC} ${%{APPNAMELC}_SRCS}) 6 | target_link_libraries(%{APPNAMELC} 7 | Qt5::DBus 8 | KF5::Runner 9 | ) 10 | 11 | set(CMAKE_BINARY_DIR "../bin") 12 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) 13 | 14 | install(FILES %{APPNAMELC}.desktop DESTINATION ~/.local/share/kservices5/) 15 | if(CMAKE_BUILD_TYPE STREQUAL "Release") 16 | install(TARGETS %{APPNAMELC} DESTINATION ~/.config/autostart-scripts/) 17 | endif() -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/src/dbus_utils.h: -------------------------------------------------------------------------------- 1 | // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. See License in the project root for license information. 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | struct RemoteMatch { 12 | // sssuda{sv} 13 | QString id; 14 | QString text; 15 | QString iconName; 16 | Plasma::QueryMatch::Type type = Plasma::QueryMatch::NoMatch; 17 | qreal relevance = 0; 18 | QVariantMap properties; 19 | }; 20 | 21 | typedef QList RemoteMatches; 22 | 23 | struct RemoteAction { 24 | // sss 25 | QString id; 26 | QString text; 27 | QString iconName; 28 | }; 29 | 30 | typedef QList RemoteActions; 31 | 32 | inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteMatch &match) { 33 | argument.beginStructure(); 34 | argument << match.id; 35 | argument << match.text; 36 | argument << match.iconName; 37 | argument << match.type; 38 | argument << match.relevance; 39 | argument << match.properties; 40 | argument.endStructure(); 41 | return argument; 42 | } 43 | 44 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatch &match) { 45 | argument.beginStructure(); 46 | argument >> match.id; 47 | argument >> match.text; 48 | argument >> match.iconName; 49 | uint type; 50 | argument >> type; 51 | match.type = static_cast(type); 52 | argument >> match.relevance; 53 | argument >> match.properties; 54 | argument.endStructure(); 55 | 56 | return argument; 57 | } 58 | 59 | inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteAction &action) { 60 | argument.beginStructure(); 61 | argument << action.id; 62 | argument << action.text; 63 | argument << action.iconName; 64 | argument.endStructure(); 65 | return argument; 66 | } 67 | 68 | inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteAction &action) { 69 | argument.beginStructure(); 70 | argument >> action.id; 71 | argument >> action.text; 72 | argument >> action.iconName; 73 | argument.endStructure(); 74 | return argument; 75 | } 76 | 77 | Q_DECLARE_METATYPE(RemoteMatch) 78 | Q_DECLARE_METATYPE(RemoteMatches) 79 | Q_DECLARE_METATYPE(RemoteAction) 80 | Q_DECLARE_METATYPE(RemoteActions) 81 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/krunner_dbus_cpp/src/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} KRunner plugin 4 | X-KDE-ServiceTypes=Plasma/Runner 5 | Type=Service 6 | Icon=internet-web-browser 7 | X-KDE-PluginInfo-Author=%{AUTHOR} 8 | X-KDE-PluginInfo-Email=kde@example.com 9 | X-KDE-PluginInfo-Name=%{APPNAMELC} 10 | X-KDE-PluginInfo-Version=1.0 11 | X-KDE-PluginInfo-License=LGPL 12 | X-KDE-PluginInfo-EnabledByDefault=true 13 | X-Plasma-API=DBus 14 | X-Plasma-DBusRunner-Service=net.%{APPNAMELC}2 15 | X-Plasma-DBusRunner-Path=/%{APPNAMELC} 16 | 17 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_cpp/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | mkdir -p ~/.local/share/kdevappwizard/template_descriptions/ 5 | mkdir -p ~/.local/share/kdevappwizard/templates/ 6 | 7 | # This automatically updates/installs the template in your local templates folder 8 | if [[ $(basename "$PWD") == "krunner_dbus_cpp" ]];then 9 | mkdir -p build 10 | rm -rf build/* 11 | cd build 12 | cmake .. 13 | make 14 | /bin/cp ../krunner_dbus_cpp/krunner_dbus_cpp.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions/ 15 | /bin/cp krunner_dbus_cpp.tar.bz2 ~/.local/share/kdevappwizard/templates/ 16 | else 17 | echo "Please go to the project root" 18 | fi 19 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/node,visualstudiocode 2 | # Edit at https://www.gitignore.io/?templates=node,visualstudiocode 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # TypeScript v1 declaration files 49 | typings/ 50 | 51 | # TypeScript cache 52 | *.tsbuildinfo 53 | 54 | # Optional npm cache directory 55 | .npm 56 | 57 | # Optional eslint cache 58 | .eslintcache 59 | 60 | # Optional REPL history 61 | .node_repl_history 62 | 63 | # Output of 'npm pack' 64 | *.tgz 65 | 66 | # Yarn Integrity file 67 | .yarn-integrity 68 | 69 | # dotenv environment variables file 70 | .env 71 | .env.test 72 | 73 | # parcel-bundler cache (https://parceljs.org/) 74 | .cache 75 | 76 | # next.js build output 77 | .next 78 | 79 | # nuxt.js build output 80 | .nuxt 81 | 82 | # react / gatsby 83 | public/ 84 | 85 | # vuepress build output 86 | .vuepress/dist 87 | 88 | # Serverless directories 89 | .serverless/ 90 | 91 | # FuseBox cache 92 | .fusebox/ 93 | 94 | # DynamoDB Local files 95 | .dynamodb/ 96 | 97 | ### VisualStudioCode ### 98 | .vscode/* 99 | !.vscode/settings.json 100 | !.vscode/tasks.json 101 | !.vscode/launch.json 102 | !.vscode/extensions.json 103 | 104 | ### VisualStudioCode Patch ### 105 | # Ignore all local history of files 106 | .history 107 | 108 | # End of https://www.gitignore.io/api/node,visualstudiocode 109 | 110 | # Build files 111 | bin -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/README.md: -------------------------------------------------------------------------------- 1 | # %{APPNAME} 2 | 3 | This plugin uses DBus to communicate with KRunner. 4 | 5 | 6 | ## Installation 7 | 8 | ```bash 9 | cd /path/to/%{APPNAME} 10 | npm install 11 | cp plasma-runner-%{APPNAMELC}.desktop ~/.local/share/kservices5/ 12 | kquitapp5 krunner 2> /dev/null; kstart5 --windowclass krunner krunner > /dev/null 2>&1 & 13 | npm start 14 | ``` 15 | 16 | In order to use the bundle-standalone script you have to install the pkg npm package (`npm i -g pkg`), for the bundle-dependencies 17 | script you have to install makeself from github (https://github.com/megastep/makeself) or your package manager. 18 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/krunner_dbus_javascript.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Krunner DBus JavaScript 3 | Comment=Krunner plugin which uses DBus written in JavaScript 4 | Category=Plasma/KRunner 5 | Icon=planetkde 6 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "%{APPNAMELC}", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "start": "node src/index.js", 8 | "bundle-dependencies": "mkdir -p bin;makeself --tar-extra \"--exclude=*.md --exclude=package-lock.json --exclude=.vscode --exclude=.idea --exclude=bin --exclude=dist --exclude=*.desktop --exclude-vcs\" . %{APPNAMELC}.run %{APPNAMELC} node src/index.js; mv %{APPNAMELC}.run bin/", 9 | "bundle-standalone": "pkg src/index.js --target=node12-linux-x64 --output ./bin/%{APPNAMELC}-standalone.run" 10 | }, 11 | "author": "%{AUTHOR}", 12 | "license": "GPL-3.0", 13 | "dependencies": { 14 | "dbus-native": "^0.4.0" 15 | } 16 | } -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} KRunner plugin 4 | X-KDE-ServiceTypes=Plasma/Runner 5 | Type=Service 6 | Icon=planetkde 7 | X-KDE-PluginInfo-Author=%{AUTHOR} 8 | X-KDE-PluginInfo-Email=kde@example.com 9 | X-KDE-PluginInfo-Name=%{APPNAMELC} 10 | X-KDE-PluginInfo-Version=1.0 11 | X-KDE-PluginInfo-License=GPL-3.0 12 | X-KDE-PluginInfo-EnabledByDefault=true 13 | X-Plasma-API=DBus 14 | X-Plasma-DBusRunner-Service=net.%{APPNAMELC}2 15 | X-Plasma-DBusRunner-Path=/%{APPNAMELC} 16 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/src/dbus-connection.js: -------------------------------------------------------------------------------- 1 | const dbus = require('dbus-native'); 2 | 3 | const sessionBus = dbus.sessionBus(); 4 | if (!sessionBus) throw new Error('Could not connect to session bus'); 5 | 6 | sessionBus.requestName('net.%{APPNAMELC}2', 0x04, (err, code) => { 7 | if (err) throw new Error(err); 8 | 9 | if (code === 3) throw new Error(`Another instance is already running`); 10 | if (code !== 1) throw new Error(`Received code ${code} while requesting service name "net.%{APPNAMELC}2"`); 11 | }); 12 | 13 | // Interface definition from https://github.com/KDE/krunner/blob/master/src/data/org.kde.krunner1.xml 14 | module.exports.createKRunnerInterface = ({ path, actionsFunction, runFunction, matchFunction }) => { 15 | 16 | const interface = {}; 17 | const interfaceDesc = { 18 | name: 'org.kde.krunner1', 19 | methods: {}, 20 | }; 21 | 22 | if (actionsFunction) { 23 | interface.Actions = actionsFunction; 24 | interfaceDesc.methods.Actions = ['', 'a(sss)', [], ['matches']]; 25 | } 26 | 27 | if (runFunction) { 28 | interface.Run = runFunction; 29 | interfaceDesc.methods.Run = ['ss', '', ['matchId', 'actionId'], []]; 30 | } 31 | 32 | if (matchFunction) { 33 | interface.Match = matchFunction; 34 | interfaceDesc.methods.Match = ['s', 'a(sssida{sv})', ['query'], ['matches']]; 35 | } 36 | 37 | sessionBus.exportInterface(interface, path, interfaceDesc); 38 | } 39 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/src/index.js: -------------------------------------------------------------------------------- 1 | require('./runner'); 2 | -------------------------------------------------------------------------------- /krunner_dbus_templates/krunner_dbus_javascript/src/runner.js: -------------------------------------------------------------------------------- 1 | const dbus = require('dbus-native'); 2 | 3 | const { createKRunnerInterface } = require('./dbus-connection'); 4 | 5 | const sessionBus = dbus.sessionBus(); 6 | if (!sessionBus) throw new Error('Failed to connect to the session bus'); 7 | 8 | 9 | createKRunnerInterface({ 10 | path: '/%{APPNAMELC}', 11 | async runFunction(matchID, actionID) { 12 | console.log(`Match ID: ${matchID} ActionID: ${actionID}`); 13 | }, 14 | async matchFunction(query) { 15 | console.log(`Javascript Runner: ${query}`); 16 | return [ 17 | ['JS-Runer', 'Hello There!', 'planetkde', 50, 1, {}] 18 | ]; 19 | }, 20 | }); -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/Runner.py: -------------------------------------------------------------------------------- 1 | import dbus 2 | import dbus.service 3 | 4 | from %{APPNAMELC}.utilities import convert_to_tupel 5 | from %{APPNAMELC}.utilities.Match import Match 6 | from %{APPNAMELC}.utilities.Action import Action 7 | 8 | class Runner(dbus.service.Object): 9 | objpath = "/%{APPNAMELC}" 10 | iface = "org.kde.krunner1" 11 | 12 | def __init__(self): 13 | dbus.service.Object.__init__(self, dbus.service.BusName("net.%{APPNAMELC}2", dbus.SessionBus()), self.objpath) 14 | 15 | @dbus.service.method(iface, in_signature='s', out_signature='a(sssida{sv})') 16 | @convert_to_tupel 17 | def Match(self, query: str): 18 | matches: [Match] = [] 19 | if query == "hello": 20 | match = Match() 21 | match.text = "Hello There!" 22 | match.data = "Data :-)" 23 | match.subtext = "Example" 24 | match.icon = "planetkde" 25 | matches.append(match) 26 | return matches 27 | 28 | @dbus.service.method(iface, out_signature='a(sss)') 29 | @convert_to_tupel 30 | def Actions(self): 31 | action = Action() 32 | action.id = "id" 33 | action.text = "Tooltip" 34 | action.icon = "planetkde" 35 | return [action] 36 | 37 | @dbus.service.method(iface, in_signature='ss') 38 | def Run(self, data: str, action_id: str): 39 | print(data, action_id) 40 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/__init__.py -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/__main__.py: -------------------------------------------------------------------------------- 1 | from .main import main 2 | 3 | main() 4 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/main.py: -------------------------------------------------------------------------------- 1 | from dbus.mainloop.glib import DBusGMainLoop 2 | from gi.repository import GLib 3 | 4 | from %{APPNAMELC}.Runner import Runner 5 | 6 | 7 | def main(): 8 | DBusGMainLoop(set_as_default=True) 9 | runner = Runner() 10 | loop = GLib.MainLoop() 11 | loop.run() 12 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/resources/%{APPNAMELC}_autostart.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=%{APPNAME} 5 | Comment=Autostart entry for a Krunner plugin 6 | Keywords=Runner;Krunner 7 | Categories=Utilities 8 | Exec=python3 -m %{APPNAMELC} 9 | Icon=python 10 | StartupNotify=true 11 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/resources/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=Python runner test 4 | X-KDE-ServiceTypes=Plasma/Runner 5 | Type=Service 6 | Icon=planetkde 7 | X-KDE-PluginInfo-Author=Some Developer 8 | X-KDE-PluginInfo-Website=https://example.com/ 9 | X-KDE-PluginInfo-Email=kde@example.com 10 | X-KDE-PluginInfo-Name=%{APPNAMELC} 11 | X-KDE-PluginInfo-Version=1.0 12 | X-KDE-PluginInfo-License=LGPL 13 | X-KDE-PluginInfo-EnabledByDefault=true 14 | X-Plasma-API=DBus 15 | X-Plasma-DBusRunner-Service=net.%{APPNAMELC}2 16 | X-Plasma-DBusRunner-Path=/%{APPNAMELC} -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/utilities/Action.py: -------------------------------------------------------------------------------- 1 | class Action: 2 | """The intention of this class is to make it easier to handle the matches, it is not essential""" 3 | 4 | id = "" 5 | text = "" 6 | icon = "" 7 | 8 | def to_tupel(self) -> (): 9 | return self.id, self.text, self.icon 10 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/utilities/Match.py: -------------------------------------------------------------------------------- 1 | class Match: 2 | """The intention of this class is to make it easier to handle the matches, it is not essential""" 3 | 4 | data = "" 5 | text = "" 6 | icon = "" 7 | relevance = 0 8 | # NoMatch = 0, CompletionMatch = 10, PossibleMatch = 30, InformationalMatch = 50, HelperMatch = 70, ExactMatch = 100 9 | type = 100 10 | subtext = "" 11 | category = "" 12 | 13 | def to_tupel(self) -> (): 14 | properties = {} 15 | if self.subtext: 16 | properties["subtext"] = self.subtext 17 | if self.category: 18 | properties["category"] = self.category 19 | return self.data, self.text, self.icon, self.type, self.relevance, properties 20 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/%{APPNAMELC}/utilities/__init__.py: -------------------------------------------------------------------------------- 1 | from functools import wraps 2 | 3 | 4 | def convert_to_tupel(original_function): 5 | @wraps(original_function) 6 | def wrapper_function(*args, **kwargs): 7 | return [match.to_tupel() for match in original_function(*args, **kwargs)] 8 | 9 | return wrapper_function 10 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.kdev4 4 | /.vscode 5 | /PythonModularKrunner.egg-info 6 | /PythonModularKrunner-*.tar.gz 7 | /build 8 | /dist 9 | /deb_dist 10 | /__pycache__ 11 | /*/__pycache__ 12 | /*/*/__pycache__ 13 | run.spec 14 | *.snap 15 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/Makefile: -------------------------------------------------------------------------------- 1 | install-dev: 2 | mkdir -p ~/.local/share/kservices5/ 3 | cp %{APPNAMELC}/resources/plasma-runner-%{APPNAMELC}.desktop ~/.local/share/kservices5/ 4 | kquitapp5 krunner; kstart5 krunner 5 | install: 6 | python3 setup.py install --user 7 | make install-dev 8 | mkdir -p ~/.config/autostart/ 9 | cp %{APPNAMELC}/resources/%{APPNAMELC}_autostart.desktop ~/.config/autostart/ 10 | -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/README.md: -------------------------------------------------------------------------------- 1 | ### Simple Krunner dbus template 2 | 3 | This plugin provides a simple template for a Krunner plugin using dbus. 4 | 5 | To run this plugin you have to execute the `make install-dev` command. 6 | This installs the .desktop file so that your runner gets recognized. 7 | Secondly you have to run your project. 8 | Because KRunner queries the dbus interface and does not load a 9 | plugin you can use for example a debugger. 10 | 11 | #### How It Is Organized 12 | This project is organized using modules, which makes it easier to manage 13 | multiple files. 14 | When your run this project `python3 -m %{APPNAMELC}` the main function 15 | from %{APPNAMELC}/main.py gets executed and the Runner class, which contains the 16 | important logic for the runner is loaded. 17 | 18 | In this class there are the Match and Run Method. The Match method is used 19 | to generate the matches and it gets the query the user typed in as a parameter. 20 | The method returns a list of QueryMatches, these get converted by the 21 | `@convert_matches` decorator to tupels. 22 | The Run method gets the data of the selected match. The action id is by default empty, 23 | unless you define custom actions. 24 | 25 | 26 | More information can be found here: 27 | https://invent.kde.org/frameworks/krunner/-/blob/master/src/data/org.kde.krunner1.xml 28 | https://develop.kde.org/docs/use/d-bus/introduction_to_dbus/ 29 | 30 | On Debian/Ubuntu you need: 31 | `sudo apt install python3 python3-hglib` -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/python_modular_runner_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Modular Python KRunner Plugin 3 | Comment=Template for a more complex KRunner plugin that is organized in modules 4 | Category=Plasma/KRunner -------------------------------------------------------------------------------- /krunner_dbus_templates/modular_krunner_python_template/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | from setuptools import setup, find_packages 4 | 5 | setup( 6 | name="%{APPNAME}", 7 | version="1.0.0", 8 | author="%{AUTHOR}", 9 | author_email="%{EMAIL}", 10 | description="%{DESCRIPTION}", 11 | url="%{URL}", 12 | entry_points={ 13 | "console_scripts": ["pythonmodularkrunner = pythonmodularkrunner.main:main"], 14 | }, 15 | packages=find_packages(), 16 | ) 17 | -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/%{APPNAMELC}.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """A Plasma runner.""" 3 | import dbus.service 4 | from dbus.mainloop.glib import DBusGMainLoop 5 | from gi.repository import GLib 6 | 7 | DBusGMainLoop(set_as_default=True) 8 | 9 | OBJPATH = "/%{APPNAMELC}" 10 | IFACE = "org.kde.krunner1" 11 | SERVICE = "org.kde.%{APPNAMELC}" 12 | 13 | 14 | class Runner(dbus.service.Object): 15 | def __init__(self): 16 | dbus.service.Object.__init__( 17 | self, 18 | dbus.service.BusName(SERVICE, dbus.SessionBus()), 19 | OBJPATH, 20 | ) 21 | 22 | @dbus.service.method(IFACE, in_signature="s", out_signature="a(sssida{sv})") 23 | def Match(self, query: str): 24 | """This method is used to get the matches and it returns a list of tupels""" 25 | if query == "hello": 26 | # data, display text, icon, type (Plasma::QueryType), relevance (0-1), properties (subtext, category and urls) 27 | return [ 28 | ( 29 | "Hello", 30 | "Hello from %{APPNAME}!", 31 | "document-edit", 32 | 100, 33 | 1.0, 34 | {"subtext": "Demo Subtext"}, 35 | ) 36 | ] 37 | return [] 38 | 39 | @dbus.service.method(IFACE, out_signature="a(sss)") 40 | def Actions(self): 41 | # id, text, icon 42 | return [("id", "Tooltip", "planetkde")] 43 | 44 | @dbus.service.method(IFACE, in_signature="ss") 45 | def Run(self, data: str, action_id: str): 46 | print(data, action_id) 47 | 48 | 49 | runner = Runner() 50 | loop = GLib.MainLoop() 51 | loop.run() 52 | -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /bin 3 | /.metadata 4 | /target 5 | /.settings 6 | /dist 7 | /.vscode -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/README.md: -------------------------------------------------------------------------------- 1 | ### %{APPNAME} 2 | 3 | This plugin provides a simple template for a KRunner plugin using dbus. 4 | 5 | The install script copies the Krunner config file and a dbus activation service file 6 | to their appropiate locations. This way the python script gets executed when KRunner 7 | requests matches and it does not need to be autostarted. 8 | 9 | If you want to run the plugin manually to debug it you can do the following: 10 | ```bash 11 | mkdir -p ~/.local/share/kservices5/ 12 | cp plasma-runner-%{APPNAMELC}.desktop ~/.local/share/kservices5/ 13 | kquitapp5 krunner 14 | python3 %{APPNAMELC}.py 15 | ``` 16 | 17 | After that you should see your runner when typing `hello` in KRunner. 18 | 19 | More information can be found here: 20 | https://invent.kde.org/frameworks/krunner/-/blob/master/src/data/org.kde.krunner1.xml 21 | https://develop.kde.org/docs/use/d-bus/introduction_to_dbus/ 22 | 23 | 24 | If you feel confident about your runner you can upload it to the KDE Store 25 | https://store.kde.org/browse/cat/628/order/latest/. 26 | -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if something fails 4 | set -e 5 | 6 | mkdir -p ~/.local/share/kservices5/ 7 | mkdir -p ~/.local/share/dbus-1/services/ 8 | 9 | cp plasma-runner-%{APPNAMELC}.desktop ~/.local/share/kservices5/ 10 | sed "s|%{PROJECTDIR}/%{APPNAMELC}.py|${PWD}/%{APPNAMELC}.py|" "org.kde.%{APPNAMELC}.service" > ~/.local/share/dbus-1/services/org.kde.%{APPNAMELC}.service 11 | 12 | kquitapp5 krunner 13 | -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/org.kde.%{APPNAMELC}.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.kde.%{APPNAMELC} 3 | Exec=/usr/bin/python3 "%{PROJECTDIR}/%{APPNAMELC}.py" 4 | -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} Runner written in Python 4 | X-KDE-ServiceTypes=Plasma/Runner 5 | Type=Service 6 | Icon=planetkde 7 | X-KDE-PluginInfo-Website=https://example.com/ 8 | X-KDE-PluginInfo-Author=%{AUTHOR} 9 | X-KDE-PluginInfo-Email=%{EMAIL} 10 | X-KDE-PluginInfo-Name=%{APPNAMELC} 11 | X-KDE-PluginInfo-Version=1.0 12 | X-KDE-PluginInfo-License=LGPL 13 | X-KDE-PluginInfo-EnabledByDefault=true 14 | X-Plasma-API=DBus 15 | X-Plasma-DBusRunner-Service=org.kde.%{APPNAMELC} 16 | X-Plasma-DBusRunner-Path=/%{APPNAMELC} 17 | -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/simple_krunner_python_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Basic Python KRunner Plugin 3 | Comment=Template for a basic KRunner python plugin using dbus 4 | Category=Plasma/KRunner -------------------------------------------------------------------------------- /krunner_dbus_templates/simple_krunner_python_template/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if something fails 4 | set -e 5 | 6 | rm ~/.local/share/kservices5/plasma-runner-%{APPNAMELC}.desktop 7 | rm ~/.local/share/dbus-1/services/org.kde.%{APPNAMELC}.service 8 | kquitapp5 krunner 9 | -------------------------------------------------------------------------------- /package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This automatically updates/installs the template in your local templates folder 4 | if [[ $(basename "$PWD") == "KDevelopTemplates" ]];then 5 | mkdir -p build 6 | cd build 7 | rm ./*.tar.bz2 8 | rm ./*/*.tar.bz2 9 | rm ./*/*/*.tar.bz2 10 | rm ./*/*/*/*.tar.bz2 11 | cmake -DKDE_INSTALL_KTEMPLATESDIR=~/.local/share/kdevappwizard/templates .. 12 | make install -j4 13 | cp ./*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 14 | cp ./*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 15 | cp ./*/*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 16 | cp ./*/*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 17 | cp ./*/*/*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 18 | cp ./*/*/*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 19 | cp ./*/*/*/*.desktop ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 20 | cp ./*/*/*/*.kdevtemplate ~/.local/share/kdevappwizard/template_descriptions 2>>/dev/null 21 | else 22 | echo "Please go to the project root" 23 | fi 24 | -------------------------------------------------------------------------------- /python_templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(template_DIRS PythonArgparseProject) 2 | set(typed_template_DIRS PythonArgparseTypedProject) 3 | set(modular_typed_template_DIRS PythonArgparseTypedModularProject) 4 | 5 | kde_package_app_templates(TEMPLATES ${template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 6 | kde_package_app_templates(TEMPLATES ${typed_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 7 | kde_package_app_templates(TEMPLATES ${modular_typed_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 8 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseProject/%{APPNAMELC}.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import argparse 4 | from argparse import HelpFormatter 5 | from functools import partial 6 | 7 | 8 | class CustomHelpFormatter(HelpFormatter): 9 | 10 | def _format_action_invocation(self, action): 11 | if not action.option_strings: 12 | # Use default methods for positional arguments 13 | default = self._get_default_metavar_for_positional(action) 14 | metavar, = self._metavar_formatter(action, default)(1) 15 | return metavar 16 | 17 | else: 18 | parts = [] 19 | if action.nargs == 0: 20 | # Just add options, if they expects no values (like --help) 21 | parts.extend(action.option_strings) 22 | else: 23 | default = self._get_default_metavar_for_optional(action) 24 | args_string = self._format_args(action, default) 25 | for option_string in action.option_strings: 26 | parts.append(option_string) 27 | # Join the argument names (like -p --param ) and add the metavar at the end 28 | return '%s %s' % (', '.join(parts), args_string) 29 | 30 | return ', '.join(parts) 31 | 32 | 33 | """ 34 | With the custom formatter the metavar does not get displayed twice. 35 | With the max_help_position you can decide how long the parameters + metavar should be before a line break gets inserted, 36 | additionally the width parameter defines the maximum length of a line. 37 | The difference can be seen here: 38 | https://github.com/alex1701c/Screenshots/blob/master/PythonArgparseCLI/default_output.png 39 | https://github.com/alex1701c/Screenshots/blob/master/PythonArgparseCLI/customized_output_format.png 40 | """ 41 | 42 | if __name__ == "__main__": 43 | parser = argparse.ArgumentParser(description='Describe your project', formatter_class=CustomHelpFormatter) 44 | parser.add_argument('-v', '--version', action='version', version='%{APPNAMELC} 1.0') 45 | parser.add_argument('-n', '--name', metavar='', help='An optional parameter') 46 | parser.add_argument('-e', '--extra', action='store_true', help='This Value is False by default') 47 | args = parser.parse_args() 48 | 49 | if args.name and args.extra: 50 | print('Hello There ' + args.name + '!') 51 | elif args.extra: 52 | print('Hello There!') 53 | elif args.name: 54 | print('Hello ' + args.name + '!') 55 | else: 56 | print('Hello World!') 57 | 58 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseProject/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.kdev4 4 | /.vscode 5 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseProject/python3_argparse_cli.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Basic CLI Template 3 | Comment=Template for command line application with Python3 and argparse 4 | Category=Python/Terminal -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/__init__.py -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/__main__.py: -------------------------------------------------------------------------------- 1 | from .main import main 2 | 3 | main() -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import argparse 4 | from typing import cast 5 | 6 | from .utilities.ArgsNamespace import ArgsNamespace 7 | from .utilities.CustomHelpFormatter import CustomHelpFormatter 8 | 9 | """ 10 | Make sure that you have the Python KDevelop plugin installed. 11 | """ 12 | 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser(description='Describe your project', formatter_class=CustomHelpFormatter) 16 | parser.add_argument('-v', '--version', action='version', version='%{APPNAMELC} 1.0') 17 | parser.add_argument('-n', '--name', metavar='', help='An optional parameter') 18 | parser.add_argument('-e', '--extra', action='store_true', help='This Value is False by default') 19 | args: ArgsNamespace = cast(ArgsNamespace, parser.parse_args()) 20 | 21 | if args.name and args.extra: 22 | print('Hello There ' + args.name + '!') 23 | elif args.extra: 24 | print('Hello There!') 25 | elif args.name: 26 | print('Hello ' + args.name + '!') 27 | else: 28 | print('Hello World!') 29 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/utilities/ArgsNamespace.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | 4 | class ArgsNamespace(argparse.Namespace): 5 | name: str 6 | extra: bool 7 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/utilities/CustomHelpFormatter.py: -------------------------------------------------------------------------------- 1 | from argparse import HelpFormatter 2 | from typing import Any 3 | 4 | 5 | class CustomHelpFormatter(HelpFormatter): 6 | 7 | def __init__(self, prog: Any, *_args, **_kwargs) -> None: 8 | super().__init__(prog, indent_increment=2, width=400, max_help_position=48) 9 | 10 | def _format_action_invocation(self, action): 11 | if not action.option_strings: 12 | # Use default methods for positional arguments 13 | default = self._get_default_metavar_for_positional(action) 14 | metavar, = self._metavar_formatter(action, default)(1) 15 | return metavar 16 | 17 | else: 18 | parts = [] 19 | if action.nargs == 0: 20 | # Just add options, if they expects no values (like --help) 21 | parts.extend(action.option_strings) 22 | else: 23 | default = self._get_default_metavar_for_optional(action) 24 | args_string = self._format_args(action, default) 25 | for option_string in action.option_strings: 26 | parts.append(option_string) 27 | # Join the argument names (like -p --param ) and add the metavar at the end 28 | return '%s %s' % (', '.join(parts), args_string) 29 | 30 | return ', '.join(parts) 31 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/utilities/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alex1701c/KDevelopTemplates/3956b65328778e0e522e435670eddb5a80ec885e/python_templates/PythonArgparseTypedModularProject/%{APPNAMELC}/utilities/__init__.py -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.kdev4 4 | /.vscode 5 | /%{APPNAME}.egg-info 6 | /%{APPNAME}-*.tar.gz 7 | /build 8 | /dist 9 | /deb_dist 10 | /__pycache__ 11 | /*/__pycache__ 12 | /*/*/__pycache__ 13 | run.spec 14 | *.snap -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/Makefile: -------------------------------------------------------------------------------- 1 | deb-package: 2 | python3 setup.py --command-packages=stdeb.command bdist_deb 3 | snap-package: 4 | snapcraft 5 | standalone: 6 | echo "from %{APPNAMELC}.main import main; main()" > main.py 7 | PYTHONOPTIMIZE=1 pyinstaller main.py -F -n %{APPNAMELC} --distpath dist/ 8 | rm main.py 9 | py-install: 10 | python3 setup.py install --user 11 | py-bundle: 12 | # Bundles all the project files into a compressed, executable file. No interpreter or libraies included 13 | rm -rf tmp 14 | mkdir -p tmp 15 | # Copy files recrusively and reserve attributes 16 | for d in %{APPNAMELC} %{APPNAMELC}/utilities ; do \ 17 | mkdir -p tmp/$$d ;\ 18 | cp -pPR $$d/*.py tmp/$$d/ ;\ 19 | done 20 | # Create entry point and package archive 21 | echo "from %{APPNAMELC}.main import main; main()" > tmp/__main__.py 22 | cd tmp ; zip -q _%{APPNAMELC} %{APPNAMELC}/*.py %{APPNAMELC}/*/*.py __main__.py 23 | # Add shebang line and append zip file content 24 | echo '#!/usr/bin/python3' > %{APPNAMELC}_bundled 25 | cat tmp/_%{APPNAMELC}.zip >> %{APPNAMELC}_bundled 26 | chmod a+x %{APPNAMELC}_bundled 27 | rm -rf tmp 28 | clean: 29 | rm -rf build dist deb_dist %{APPNAME}.egg-info 30 | rm -rf %{APPNAME}*.snap %{APPNAME}-*.tar.gz main.spec -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/README: -------------------------------------------------------------------------------- 1 | This project uses modules and a setup.py file to build your app. 2 | 3 | To run the project have to type: 4 | python3 -m %{APPNAMELC}.__main__ 5 | 6 | To install/build the project you can use the scripts in the Makefile 7 | (make sure that you have the setup.py file parameters edited). 8 | 9 | This requires: 10 | sudo apt install debhelper python3 python3-pip python3-all 11 | pip3 install stdeb setuptools pyinstaller --user 12 | 13 | Snap packaging requires: 14 | Snap to be installed end enabled, 15 | sudo snap install snapcraft --clasic 16 | sudo snap install multipass --beta --classic -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/python3_modular_argparse_cli.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Modular Python CLI 3 | Comment=This is a typed template for command line application with Python3 and argparse. Additionally it is organized in modules, has a setup.py and build scripts configured. 4 | Category=Python/Terminal -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | from setuptools import setup, find_packages 4 | 5 | setup( 6 | name='%{APPNAME}', 7 | version='1.0.0', 8 | author='%{AUTHOR}', 9 | author_email='%{EMAIL}', 10 | description='%{DESCRIPTION}', 11 | url='%{URL}', 12 | entry_points={ 13 | 'console_scripts': ['%{APPNAMELC} = %{APPNAMELC}.main:main'], 14 | }, 15 | packages=find_packages(), 16 | ) 17 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedModularProject/snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | # https://snapcraft.io/docs/snapcraft-yaml-reference 2 | name: %{APPNAMELC} # you probably want to 'snapcraft register ' 3 | title: %{APPNAME} 4 | base: core18 # the base snap is the execution environment for this snap 5 | version: 1.0.0 # just for humans, typically '1.2+git' or '1.3.2' 6 | summary: %{Summary} # 79 char long summary 7 | description: | 8 | %{DESCRIPTION} 9 | confinement: devmode 10 | grade: devel 11 | 12 | apps: 13 | %{APPNAMELC}: 14 | command: python3 -m %{APPNAMELC}.__main__ 15 | 16 | parts: 17 | %{APPNAMELC}: 18 | plugin: python 19 | source: . 20 | python-version: python3 -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedProject/%{APPNAMELC}.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import argparse 4 | from argparse import HelpFormatter 5 | from functools import partial 6 | from typing import Any, cast 7 | 8 | 9 | class CustomHelpFormatter(HelpFormatter): 10 | 11 | def _format_action_invocation(self, action): 12 | if not action.option_strings: 13 | # Use default methods for positional arguments 14 | default = self._get_default_metavar_for_positional(action) 15 | metavar, = self._metavar_formatter(action, default)(1) 16 | return metavar 17 | 18 | else: 19 | parts = [] 20 | if action.nargs == 0: 21 | # Just add options, if they expects no values (like --help) 22 | parts.extend(action.option_strings) 23 | else: 24 | default = self._get_default_metavar_for_optional(action) 25 | args_string = self._format_args(action, default) 26 | for option_string in action.option_strings: 27 | parts.append(option_string) 28 | # Join the argument names (like -p --param ) and add the metavar at the end 29 | return '%s %s' % (', '.join(parts), args_string) 30 | 31 | return ', '.join(parts) 32 | 33 | 34 | class ArgsNamespace(argparse.Namespace): 35 | name: str 36 | extra: bool 37 | 38 | def __init__(self, **kwargs: Any) -> None: 39 | super().__init__(**kwargs) 40 | 41 | 42 | """ 43 | In addition to the other Python argparse CLI template this one supports type checking. 44 | Make sure that you have the Python KDevelop plugin installed. 45 | """ 46 | 47 | if __name__ == "__main__": 48 | parser = argparse.ArgumentParser(description='Describe your project', formatter_class=CustomHelpFormatter) 49 | parser.add_argument('-v', '--version', action='version', version='%{APPNAMELC} 1.0') 50 | parser.add_argument('-n', '--name', metavar='', help='An optional parameter') 51 | parser.add_argument('-e', '--extra', action='store_true', help='This Value is False by default') 52 | args: ArgsNamespace = cast(ArgsNamespace, parser.parse_args()) 53 | 54 | if args.name and args.extra: 55 | print('Hello There ' + args.name + '!') 56 | elif args.extra: 57 | print('Hello There!') 58 | elif args.name: 59 | print('Hello ' + args.name + '!') 60 | else: 61 | print('Hello World!') 62 | 63 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedProject/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.kdev4 4 | /.vscode 5 | -------------------------------------------------------------------------------- /python_templates/PythonArgparseTypedProject/python3_argparse_cli.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Typed CLI Template 3 | Comment=Typed Template for command line application with Python3 and argparse 4 | Category=Python/Terminal -------------------------------------------------------------------------------- /qt_cpp_templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(krunner_templates) 2 | add_subdirectory(qt_cli_templates) 3 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(krunner) 2 | add_subdirectory(runner_kcmodule) 3 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(basic_runner_template_DIRS basic_runner) 2 | set(extended_runner_template_DIRS extended_runner) 3 | 4 | kde_package_app_templates(TEMPLATES ${basic_runner_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 5 | kde_package_app_templates(TEMPLATES ${extended_runner_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 6 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /cmake-build-debug 3 | /build 4 | /.kdev4 5 | /.vscode -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | 5 | set(QT_MIN_VERSION "5.0.0") 6 | set(KF5_MIN_VERSION "5.0.0") 7 | 8 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 9 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) 10 | find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Widgets) 11 | find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Runner I18n) 12 | 13 | include(KDEInstallDirs) 14 | include(KDECMakeSettings) 15 | include(KDECompilerSettings NO_POLICY_SCOPE) 16 | include(FeatureSummary) 17 | 18 | add_subdirectory(src) 19 | 20 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 21 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $XGETTEXT src/*.cpp -o $podir/plasma_runner_org.kde.%{APPNAMELC}.pot 3 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/README.md: -------------------------------------------------------------------------------- 1 | Explain what this plugin does... 2 | 3 | ### Required Dependencies 4 | 5 | Debian/Ubuntu 6 | `sudo apt install cmake extra-cmake-modules build-essential libkf5runner-dev libkf5textwidgets-dev qtdeclarative5-dev gettext` 7 | 8 | openSUSE 9 | `sudo zypper install cmake extra-cmake-modules libQt5Widgets5 libQt5Core5 libqt5-qtlocation-devel ki18n-devel ktextwidgets-devel kservice-devel krunner-devel gettext-tools` 10 | 11 | Fedora 12 | `sudo dnf install cmake extra-cmake-modules kf5-ki18n-devel kf5-kservice-devel kf5-krunner-devel kf5-ktextwidgets-devel gettext` 13 | 14 | ### Build instructions 15 | 16 | If you build the project for the first after generating the template and cmake says "No targets specified and no makefile found." you have to delete the content of the build folder ( rm -rf build/* ) and try again. 17 | Afterwards you can remove this message. 18 | ``` 19 | cd /path/to/%{APPNAME} 20 | mkdir build 21 | cd build 22 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 23 | make 24 | sudo make install 25 | ``` 26 | 27 | Restart krunner to load the runner (in a terminal type: kquitapp5 krunner;kstart5 krunner ) 28 | 29 | After this you should see your runner in the system settings: 30 | 31 | systemsettings5 (Head to "Search") 32 | 33 | You can also launch KRunner via Alt-F2 and you will find your runner. 34 | 35 | This project is based on the following template: https://github.com/alex1701c/krunner -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if something fails 4 | set -e 5 | 6 | # TODO Enable if the project is on Github 7 | if [[ $(basename "$PWD") != "%{APPNAME}"* ]];then 8 | #git clone https://github.com/%{USERNAME}/%{APPNAME} 9 | #cd %{APPNAME}/ 10 | echo "Please go to the project folder" 11 | exit 12 | fi 13 | 14 | mkdir -p build 15 | cd build 16 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 17 | make -j$(nproc) 18 | sudo make install 19 | 20 | kquitapp5 krunner 2> /dev/null 21 | kstart5 --windowclass krunner krunner > /dev/null 2>&1 & 22 | 23 | echo "Installation finished !"; -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/runner.kdevtemplate: -------------------------------------------------------------------------------- 1 | # KDE Config File 2 | [General] 3 | Name=Basic Runner Template 4 | Comment=Basic Plasma Runner Template. A plasma runner template 5 | Category=Plasma/KRunner 6 | Icon=planetkde 7 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | #include "%{APPNAMELC}.h" 2 | 3 | // KF 4 | #include 5 | 6 | %{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) 7 | : Plasma::AbstractRunner(parent, args) { 8 | setObjectName(QStringLiteral("%{APPNAME}")); 9 | 10 | QList syntaxes; 11 | syntaxes.append(Plasma::RunnerSyntax("query", "Explain query")); 12 | setSyntaxes(syntaxes); 13 | } 14 | 15 | %{APPNAME}::~%{APPNAME}() { 16 | } 17 | 18 | 19 | void %{APPNAME}::match(Plasma::RunnerContext &context) { 20 | if(!context.isValid()) return; 21 | const QString term = context.query(); 22 | if (term.length() < 3) { 23 | return; 24 | } 25 | QList matches; 26 | 27 | Plasma::QueryMatch match(this); 28 | match.setIconName("kdeapp"); 29 | match.setText("Hello World!"); 30 | matches.append(match); 31 | 32 | context.addMatches(matches); 33 | } 34 | 35 | void %{APPNAME}::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { 36 | Q_UNUSED(context) 37 | Q_UNUSED(match) 38 | 39 | // TODO 40 | } 41 | 42 | K_EXPORT_PLASMA_RUNNER(%{APPNAMELC}, %{APPNAME}) 43 | 44 | // needed for the QObject subclass declared as part of K_EXPORT_PLASMA_RUNNER 45 | #include "%{APPNAMELC}.moc" 46 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAMEUC}_H 2 | #define %{APPNAMEUC}_H 3 | 4 | #include 5 | 6 | class %{APPNAME} : public Plasma::AbstractRunner 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | %{APPNAME}(QObject *parent, const QVariantList &args); 12 | ~%{APPNAME}() override; 13 | 14 | public: // Plasma::AbstractRunner API 15 | void match(Plasma::RunnerContext &context) override; 16 | void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_org.kde.%{APPNAMELC}\") 2 | 3 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 4 | 5 | add_library(krunner_%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) 6 | target_link_libraries(krunner_%{APPNAMELC} KF5::Runner KF5::I18n) 7 | 8 | install(TARGETS krunner_%{APPNAMELC} DESTINATION ${KDE_INSTALL_PLUGINDIR}) 9 | 10 | install(FILES plasma-runner-%{APPNAMELC}.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) 11 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/basic_runner/src/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} runner 4 | Icon=planetkde 5 | 6 | X-KDE-ServiceTypes=Plasma/Runner 7 | Type=Service 8 | X-KDE-Library=krunner_%{APPNAMELC} 9 | X-KDE-PluginInfo-Author=%{AUTHOR} 10 | X-KDE-PluginInfo-Email=%{EMAIL} 11 | X-KDE-PluginInfo-Name=%{APPNAMELC} 12 | X-KDE-PluginInfo-Version=0.1 13 | X-KDE-PluginInfo-License=LGPL 3 14 | X-KDE-PluginInfo-EnabledByDefault=true 15 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /cmake-build-debug 3 | /build 4 | /.kdev4 5 | /.vscode -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | 5 | set(QT_MIN_VERSION "5.0.0") 6 | set(KF5_MIN_VERSION "5.0.0") 7 | 8 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 9 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) 10 | find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Widgets) 11 | find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Runner I18n) 12 | 13 | include(KDEInstallDirs) 14 | include(KDECMakeSettings) 15 | include(KDECompilerSettings NO_POLICY_SCOPE) 16 | include(FeatureSummary) 17 | 18 | add_subdirectory(src) 19 | 20 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 21 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $XGETTEXT src/*.cpp -o $podir/plasma_runner_org.kde.%{APPNAMELC}.pot 3 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/README.md: -------------------------------------------------------------------------------- 1 | Explain what this plugin does... 2 | 3 | ### Required Dependencies 4 | 5 | Debian/Ubuntu 6 | `sudo apt install cmake extra-cmake-modules build-essential libkf5runner-dev libkf5textwidgets-dev qtdeclarative5-dev gettext` 7 | 8 | openSUSE 9 | `sudo zypper install cmake extra-cmake-modules libQt5Widgets5 libQt5Core5 libqt5-qtlocation-devel ki18n-devel ktextwidgets-devel kservice-devel krunner-devel gettext-tools` 10 | 11 | Fedora 12 | `sudo dnf install cmake extra-cmake-modules kf5-ki18n-devel kf5-kservice-devel kf5-krunner-devel kf5-ktextwidgets-devel gettext` 13 | 14 | ### Build instructions 15 | 16 | If you build the project for the first after generating the template and cmake says "No targets specified and no makefile found." you have to delete the content of the build folder ( rm -rf build/* ) and try again. 17 | Afterwards you can remove this message. 18 | ``` 19 | cd /path/to/%{APPNAME} 20 | mkdir build 21 | cd build 22 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 23 | make 24 | sudo make install 25 | ``` 26 | 27 | Restart krunner to load the runner (in a terminal type: kquitapp5 krunner;kstart5 krunner ) 28 | 29 | After this you should see your runner in the system settings: 30 | 31 | systemsettings5 (Head to "Search") 32 | 33 | You can also launch KRunner via Alt-F2 and you will find your runner. 34 | 35 | This project is based on the following template: https://github.com/alex1701c/krunner -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if something fails 4 | set -e 5 | 6 | # TODO Enable if the project is on Github 7 | if [[ $(basename "$PWD") != "%{APPNAME}"* ]];then 8 | #git clone https://github.com/%{USERNAME}/%{APPNAME} 9 | #cd %{APPNAME}/ 10 | echo "Please go to the project folder" 11 | exit 12 | fi 13 | 14 | mkdir -p build 15 | cd build 16 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 17 | make -j$(nproc) 18 | sudo make install 19 | 20 | kquitapp5 krunner 2> /dev/null 21 | kstart5 --windowclass krunner krunner > /dev/null 2>&1 & 22 | 23 | echo "Installation finished !"; -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/runner.kdevtemplate: -------------------------------------------------------------------------------- 1 | # KDE Config File 2 | [General] 3 | Name=Extended Runner Template 4 | Comment=Extended Plasma Runner Template. A plasma runner template 5 | Category=Plasma/KRunner 6 | Icon=planetkde 7 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | #include "%{APPNAMELC}.h" 2 | 3 | // KF 4 | #include 5 | #include 6 | 7 | %{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) 8 | : Plasma::AbstractRunner(parent, args) { 9 | setObjectName(QStringLiteral("%{APPNAME}")); 10 | 11 | QList syntaxes; 12 | syntaxes.append(Plasma::RunnerSyntax("query", "Explain query")); 13 | setSyntaxes(syntaxes); 14 | } 15 | 16 | %{APPNAME}::~%{APPNAME}() { 17 | } 18 | 19 | void %{APPNAME}::init() { 20 | reloadConfiguration(); 21 | connect(this, &%{APPNAME}::prepare, this, &%{APPNAME}::prepareForMatchSession); 22 | connect(this, &%{APPNAME}::teardown, this, &%{APPNAME}::matchSessionFinished); 23 | } 24 | 25 | void %{APPNAME}::prepareForMatchSession() { 26 | } 27 | 28 | void %{APPNAME}::matchSessionFinished() { 29 | } 30 | 31 | 32 | void %{APPNAME}::reloadConfiguration() { 33 | } 34 | 35 | void %{APPNAME}::match(Plasma::RunnerContext &context) { 36 | if(!context.isValid()) return; 37 | const QString term = context.query(); 38 | if (term.length() < 3) { 39 | return; 40 | } 41 | QList matches; 42 | 43 | Plasma::QueryMatch match(this); 44 | match.setIconName("kdeapp"); 45 | match.setText("Hello World!"); 46 | matches.append(match); 47 | 48 | context.addMatches(matches); 49 | } 50 | 51 | void %{APPNAME}::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { 52 | Q_UNUSED(context) 53 | Q_UNUSED(match) 54 | 55 | // TODO 56 | } 57 | 58 | K_EXPORT_PLASMA_RUNNER(%{APPNAMELC}, %{APPNAME}) 59 | 60 | // needed for the QObject subclass declared as part of K_EXPORT_PLASMA_RUNNER 61 | #include "%{APPNAMELC}.moc" 62 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAMEUC}_H 2 | #define %{APPNAMEUC}_H 3 | 4 | #include 5 | 6 | class %{APPNAME} : public Plasma::AbstractRunner 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | %{APPNAME}(QObject *parent, const QVariantList &args); 12 | ~%{APPNAME}() override; 13 | 14 | protected Q_SLOTS: 15 | void init() override; 16 | void prepareForMatchSession(); 17 | void matchSessionFinished(); 18 | 19 | public: // Plasma::AbstractRunner API 20 | void match(Plasma::RunnerContext &context) override; 21 | void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; 22 | void reloadConfiguration() override; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_org.kde.%{APPNAMELC}\") 2 | 3 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 4 | 5 | add_library(krunner_%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) 6 | target_link_libraries(krunner_%{APPNAMELC} KF5::Runner KF5::I18n) 7 | 8 | install(TARGETS krunner_%{APPNAMELC} DESTINATION ${KDE_INSTALL_PLUGINDIR}) 9 | 10 | install(FILES plasma-runner-%{APPNAMELC}.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) 11 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/krunner/extended_runner/src/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} runner 4 | Icon=planetkde 5 | 6 | X-KDE-ServiceTypes=Plasma/Runner 7 | Type=Service 8 | X-KDE-Library=krunner_%{APPNAMELC} 9 | X-KDE-PluginInfo-Author=%{AUTHOR} 10 | X-KDE-PluginInfo-Email=%{EMAIL} 11 | X-KDE-PluginInfo-Name=%{APPNAMELC} 12 | X-KDE-PluginInfo-Version=0.1 13 | X-KDE-PluginInfo-License=LGPL 3 14 | X-KDE-PluginInfo-EnabledByDefault=true 15 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(template_DIRS runnerwithconfig) 2 | set(extendedTemplate_DIRS extendedrunnerwithconfig) 3 | 4 | kde_package_app_templates(TEMPLATES ${template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 5 | kde_package_app_templates(TEMPLATES ${extendedTemplate_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 6 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | src/config/*.autosave 6 | src/config/ui_%{APPNAMELC}_config.h 7 | #Copying this file from build folder provides better autocompletion. 8 | #If the .ui file changes it has to be deleted and after building the project it can be copies again 9 | #Otherwise the changes do not take effect 10 | *.swap -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | 5 | set(QT_MIN_VERSION "5.0.0") 6 | set(KF5_MIN_VERSION "5.0.0") 7 | 8 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 9 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 10 | 11 | # Find the required Libaries 12 | find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS Widgets Core Quick QuickWidgets) 13 | find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n Service Runner TextWidgets ConfigWidgets PlasmaQuick) 14 | include(KDEInstallDirs) 15 | include(KDECMakeSettings) 16 | include(KDECompilerSettings NO_POLICY_SCOPE) 17 | include(FeatureSummary) 18 | 19 | add_subdirectory(src) 20 | 21 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 22 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $XGETTEXT src/*.cpp -o $podir/plasma_runner_org.kde.%{APPNAMELC}.pot 3 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/README.md: -------------------------------------------------------------------------------- 1 | Explain what this plugin does... 2 | 3 | ### Required Dependencies 4 | 5 | Debian/Ubuntu 6 | `sudo apt install cmake extra-cmake-modules build-essential libkf5runner-dev libkf5textwidgets-dev qtdeclarative5-dev gettext` 7 | 8 | openSUSE 9 | `sudo zypper install cmake extra-cmake-modules libQt5Widgets5 libQt5Core5 libqt5-qtlocation-devel ki18n-devel ktextwidgets-devel kservice-devel krunner-devel gettext-tools kconfigwidgets-devel` 10 | 11 | Fedora 12 | `sudo dnf install cmake extra-cmake-modules kf5-ki18n-devel kf5-kservice-devel kf5-krunner-devel kf5-ktextwidgets-devel gettext` 13 | 14 | ### Build instructions 15 | 16 | If you build the project for the first after generating the template and cmake says "No targets specified and no makefile found." you have to delete the content of the build folder ( rm -rf build/* ) and try again. 17 | Afterwards you can remove this message. 18 | ``` 19 | cd /path/to/%{APPNAME} 20 | mkdir build 21 | cd build 22 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 23 | make 24 | sudo make install 25 | ``` 26 | 27 | 28 | Restart krunner to load the runner (in a terminal type: kquitapp5 krunner;kstart5 krunner ) 29 | 30 | After this you should see your runner in the system settings: 31 | 32 | systemsettings5 (Head to "Search") 33 | 34 | You can also launch KRunner via Alt-F2 and you will find your runner. 35 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if something fails 4 | set -e 5 | 6 | # TODO Enable if the project is on Github 7 | if [[ $(basename "$PWD") != "%{APPNAME}"* ]];then 8 | #git clone https://github.com/%{USERNAME}/%{APPNAME} 9 | #cd %{APPNAME}/ 10 | echo "Please go to the project folder" 11 | exit 12 | fi 13 | 14 | mkdir -p build 15 | cd build 16 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 17 | make -j$(nproc) 18 | sudo make install 19 | 20 | kquitapp5 krunner 2> /dev/null 21 | kstart5 --windowclass krunner krunner > /dev/null 2>&1 & 22 | 23 | echo "Installation finished !"; -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/runnerwithkcmodule.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Extended Runner Template With Config 3 | Comment=Extended Plasma Runner Template. A plasma runner template which includes a KCModule 4 | Category=Plasma/KRunner 5 | Icon=planetkde 6 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | #include "%{APPNAMELC}.h" 2 | 3 | // KF 4 | #include 5 | #include 6 | 7 | %{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) 8 | : Plasma::AbstractRunner(parent, args) { 9 | setObjectName(QStringLiteral("%{APPNAME}")); 10 | 11 | QList syntaxes; 12 | syntaxes.append(Plasma::RunnerSyntax("query", "Explain query")); 13 | setSyntaxes(syntaxes); 14 | } 15 | 16 | %{APPNAME}::~%{APPNAME}() { 17 | } 18 | 19 | void %{APPNAME}::init() { 20 | reloadConfiguration(); 21 | connect(this, &%{APPNAME}::prepare, this, &%{APPNAME}::prepareForMatchSession); 22 | connect(this, &%{APPNAME}::teardown, this, &%{APPNAME}::matchSessionFinished); 23 | } 24 | 25 | void %{APPNAME}::reloadConfiguration() { 26 | // Open config file from ~/.config/krunnerrc and the group [Runners][%{APPNAMELC}] 27 | KConfigGroup configGroup = config(); 28 | configGroup.writeEntry("test", "Hello There!"); 29 | } 30 | 31 | void %{APPNAME}::prepareForMatchSession() { 32 | } 33 | 34 | void %{APPNAME}::matchSessionFinished() { 35 | } 36 | 37 | void %{APPNAME}::match(Plasma::RunnerContext &context) { 38 | if (!context.isValid()) { 39 | return; 40 | } 41 | 42 | const QString term = context.query(); 43 | if (term.length() < 3) { 44 | return; 45 | } 46 | QList matches; 47 | 48 | Plasma::QueryMatch match(this); 49 | match.setIconName("kdeapp"); 50 | match.setText("Hello World!"); 51 | matches.append(match); 52 | 53 | context.addMatches(matches); 54 | } 55 | 56 | void %{APPNAME}::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { 57 | Q_UNUSED(context) 58 | Q_UNUSED(match) 59 | 60 | // TODO 61 | } 62 | 63 | K_EXPORT_PLASMA_RUNNER(%{APPNAMELC}, %{APPNAME}) 64 | 65 | // needed for the QObject subclass declared as part of K_EXPORT_PLASMA_RUNNER 66 | #include "%{APPNAMELC}.moc" 67 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAMEUC}_H 2 | #define %{APPNAMEUC}_H 3 | 4 | #include 5 | 6 | class %{APPNAME} : public Plasma::AbstractRunner 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | %{APPNAME}(QObject *parent, const QVariantList &args); 12 | ~%{APPNAME}() override; 13 | 14 | protected Q_SLOTS: 15 | void init() override; 16 | void prepareForMatchSession(); 17 | void matchSessionFinished(); 18 | 19 | public: // Plasma::AbstractRunner API 20 | void reloadConfiguration() override; 21 | void match(Plasma::RunnerContext &context) override; 22 | void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_org.kde.%{APPNAMELC}\") 2 | 3 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 4 | 5 | add_library(krunner_%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) 6 | target_link_libraries(krunner_%{APPNAMELC} KF5::Runner KF5::I18n) 7 | 8 | set(kcm_krunner_%{APPNAMELC}_SRCS 9 | config/%{APPNAMELC}_config.cpp 10 | ) 11 | 12 | ki18n_wrap_ui(kcm_krunner_%{APPNAMELC}_SRCS config/%{APPNAMELC}_config.ui) 13 | add_library(kcm_krunner_%{APPNAMELC} MODULE ${kcm_krunner_%{APPNAMELC}_SRCS}) 14 | target_link_libraries(kcm_krunner_%{APPNAMELC} 15 | Qt5::Core 16 | Qt5::Gui 17 | KF5::CoreAddons 18 | KF5::ConfigCore 19 | KF5::I18n 20 | KF5::ConfigWidgets 21 | KF5::Runner 22 | ) 23 | 24 | add_dependencies(krunner_%{APPNAMELC} kcm_krunner_%{APPNAMELC}) 25 | 26 | 27 | install(TARGETS krunner_%{APPNAMELC} kcm_krunner_%{APPNAMELC} DESTINATION ${PLUGIN_INSTALL_DIR}) 28 | install(FILES plasma-runner-%{APPNAMELC}.desktop config/plasma-runner-%{APPNAMELC}_config.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) 29 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/config/%{APPNAMELC}_config.cpp: -------------------------------------------------------------------------------- 1 | #include "%{APPNAMELC}_config.h" 2 | #include 3 | #include 4 | #include 5 | 6 | K_PLUGIN_FACTORY(%{APPNAME}ConfigFactory, registerPlugin<%{APPNAME}Config>("kcm_krunner_%{APPNAMELC}");) 7 | 8 | %{APPNAME}ConfigForm::%{APPNAME}ConfigForm(QWidget *parent) : QWidget(parent) { 9 | setupUi(this); 10 | } 11 | 12 | %{APPNAME}Config::%{APPNAME}Config(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { 13 | m_ui = new %{APPNAME}ConfigForm(this); 14 | auto *layout = new QGridLayout(this); 15 | layout->addWidget(m_ui, 0, 0); 16 | 17 | // TODO connect signals 18 | 19 | // Open config file 20 | config = KSharedConfig::openConfig("krunnerrc")->group("Runners").group("%{APPNAMELC}"); 21 | } 22 | 23 | void %{APPNAME}Config::load() { 24 | 25 | KCModule::load(); 26 | 27 | // TODO load settings into GUI 28 | emit changed(false); 29 | } 30 | 31 | 32 | void %{APPNAME}Config::save() { 33 | 34 | KCModule::save(); 35 | 36 | // TODO save settings 37 | emit changed(false); 38 | } 39 | 40 | void %{APPNAME}Config::defaults() { 41 | 42 | KCModule::defaults(); 43 | 44 | // TODO set default values in GUI 45 | emit changed(true); 46 | } 47 | 48 | 49 | #include "%{APPNAMELC}_config.moc" 50 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/config/%{APPNAMELC}_config.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAME}CONFIG_H 2 | #define %{APPNAME}CONFIG_H 3 | 4 | #include "ui_%{APPNAMELC}_config.h" 5 | #include 6 | #include 7 | 8 | class %{APPNAME}ConfigForm : public QWidget, public Ui::%{APPNAME}ConfigUi { 9 | Q_OBJECT 10 | 11 | public: 12 | explicit %{APPNAME}ConfigForm(QWidget *parent); 13 | }; 14 | 15 | class %{APPNAME}Config : public KCModule { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit %{APPNAME}Config(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); 20 | 21 | public Q_SLOTS: 22 | void save() override; 23 | void load() override; 24 | void defaults() override; 25 | 26 | private: 27 | KConfigGroup config; 28 | %{APPNAME}ConfigForm *m_ui; 29 | 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/config/%{APPNAMELC}_config.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | %{AUTHOR} 4 | %{APPNAME}ConfigUi 5 | 6 | 7 | 8 | 0 9 | 0 10 | 669 11 | 580 12 | 13 | 14 | 15 | 16 | 300 17 | 0 18 | 19 | 20 | 21 | 22 | 23 | 24 | true 25 | 26 | 27 | 28 | 0 29 | 0 30 | 31 | 32 | 33 | Qt::LeftToRight 34 | 35 | 36 | %{APPNAME} Config 37 | 38 | 39 | 40 | 41 | 42 | Hello World ! 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/config/plasma-runner-%{APPNAMELC}_config.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | X-KDE-ServiceTypes=KCModule 4 | X-KDE-Library=kcm_krunner_%{APPNAMELC} 5 | X-KDE-ParentComponents=%{APPNAMELC} 6 | X-KDE-PluginKeyword=kcm_krunner_%{APPNAMELC} 7 | 8 | Name=%{APPNAMELC} 9 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/extendedrunnerwithconfig/src/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} runner 4 | Icon=planetkde 5 | 6 | X-KDE-ServiceTypes=Plasma/Runner 7 | Type=Service 8 | X-KDE-Library=krunner_%{APPNAMELC} 9 | X-KDE-PluginInfo-Author=%{AUTHOR} 10 | X-KDE-PluginInfo-Email=%{EMAIL} 11 | X-KDE-PluginInfo-Name=%{APPNAMELC} 12 | X-KDE-PluginInfo-Version=0.1 13 | X-KDE-PluginInfo-License=LGPL 2.1+ 14 | X-KDE-PluginInfo-EnabledByDefault=true 15 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | /.vscode 4 | /cmake-build-debug 5 | src/config/ui_%{APPNAMELC}_config.h 6 | #Copying this file from build folder provides better autocompletion. 7 | #If the .ui file changes it has to be deleted and after building the project it can be copies again 8 | #Otherwise the changes do not take effect 9 | *.swap -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | 5 | set(QT_MIN_VERSION "5.0.0") 6 | set(KF5_MIN_VERSION "5.0.0") 7 | 8 | find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) 9 | set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH}) 10 | 11 | # Find the required Libaries 12 | find_package(Qt5 ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS Widgets Core Quick QuickWidgets) 13 | find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n Service Runner TextWidgets ConfigWidgets PlasmaQuick) 14 | include(KDEInstallDirs) 15 | include(KDECMakeSettings) 16 | include(KDECompilerSettings NO_POLICY_SCOPE) 17 | include(FeatureSummary) 18 | 19 | add_subdirectory(src) 20 | 21 | feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) 22 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/Messages.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | $XGETTEXT src/*.cpp -o $podir/plasma_runner_org.kde.%{APPNAMELC}.pot 3 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/README.md: -------------------------------------------------------------------------------- 1 | Explain what this plugin does... 2 | 3 | ### Required Dependencies 4 | 5 | Debian/Ubuntu 6 | `sudo apt install cmake extra-cmake-modules build-essential libkf5runner-dev libkf5textwidgets-dev qtdeclarative5-dev gettext` 7 | 8 | openSUSE 9 | `sudo zypper install cmake extra-cmake-modules libQt5Widgets5 libQt5Core5 libqt5-qtlocation-devel ki18n-devel ktextwidgets-devel kservice-devel krunner-devel gettext-tools kconfigwidgets-devel` 10 | 11 | Fedora 12 | `sudo dnf install cmake extra-cmake-modules kf5-ki18n-devel kf5-kservice-devel kf5-krunner-devel kf5-ktextwidgets-devel gettext` 13 | 14 | ### Build instructions 15 | 16 | If you build the project for the first after generating the template and cmake says "No targets specified and no makefile found." you have to delete the content of the build folder ( rm -rf build/* ) and try again. 17 | Afterwards you can remove this message. 18 | ``` 19 | cd /path/to/%{APPNAME} 20 | mkdir build 21 | cd build 22 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 23 | make 24 | sudo make install 25 | ``` 26 | 27 | Restart krunner to load the runner (in a terminal type: kquitapp5 krunner;kstart5 krunner ) 28 | 29 | After this you should see your runner in the system settings: 30 | 31 | systemsettings5 (Head to "Search") 32 | 33 | You can also launch KRunner via Alt-F2 and you will find your runner. 34 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if something fails 4 | set -e 5 | 6 | # TODO Enable if the project is on Github 7 | if [[ $(basename "$PWD") != "%{APPNAME}"* ]];then 8 | #git clone https://github.com/%{USERNAME}/%{APPNAME} 9 | #cd %{APPNAME}/ 10 | echo "Please go to the project folder" 11 | exit 12 | fi 13 | 14 | mkdir -p build 15 | cd build 16 | cmake -DQT_PLUGIN_INSTALL_DIR=`kf5-config --qt-plugins` -DCMAKE_BUILD_TYPE=Release .. 17 | make -j$(nproc) 18 | sudo make install 19 | 20 | kquitapp5 krunner 2> /dev/null 21 | kstart5 --windowclass krunner krunner > /dev/null 2>&1 & 22 | 23 | echo "Installation finished !"; -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/runnerwithkcmodule.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Runner Template With Config 3 | Comment=Plasma Runner Template. A plasma runner template which includes a KCModule 4 | Category=Plasma/KRunner 5 | Icon=planetkde 6 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/%{APPNAMELC}.cpp: -------------------------------------------------------------------------------- 1 | #include "%{APPNAMELC}.h" 2 | 3 | // KF 4 | #include 5 | #include 6 | 7 | %{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) 8 | : Plasma::AbstractRunner(parent, args) 9 | { 10 | setObjectName(QStringLiteral("%{APPNAME}")); 11 | } 12 | 13 | %{APPNAME}::~%{APPNAME}() { 14 | } 15 | 16 | void %{APPNAME}::init() { 17 | reloadConfiguration(); 18 | } 19 | 20 | void %{APPNAME}::reloadConfiguration() { 21 | // Open config file from ~/.config/krunnerrc and the group [Runners][%{APPNAMELC}] 22 | KConfigGroup configGroup = config(); 23 | configGroup.writeEntry("test", "Hello There!"); 24 | } 25 | 26 | void %{APPNAME}::match(Plasma::RunnerContext &context) { 27 | if(!context.isValid()) return; 28 | const QString term = context.query(); 29 | if (term.length() < 3) { 30 | return; 31 | } 32 | QList matches; 33 | 34 | Plasma::QueryMatch match(this); 35 | match.setIconName("kdeapp"); 36 | match.setText("Hello World!"); 37 | matches.append(match); 38 | 39 | context.addMatches(matches); 40 | } 41 | 42 | void %{APPNAME}::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { 43 | Q_UNUSED(context) 44 | Q_UNUSED(match) 45 | 46 | // TODO 47 | } 48 | 49 | K_EXPORT_PLASMA_RUNNER(%{APPNAMELC}, %{APPNAME}) 50 | 51 | // needed for the QObject subclass declared as part of K_EXPORT_PLASMA_RUNNER 52 | #include "%{APPNAMELC}.moc" 53 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/%{APPNAMELC}.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAMEUC}_H 2 | #define %{APPNAMEUC}_H 3 | 4 | #include 5 | 6 | class %{APPNAME} : public Plasma::AbstractRunner { 7 | Q_OBJECT 8 | 9 | public: 10 | %{APPNAME}(QObject *parent, const QVariantList &args); 11 | ~%{APPNAME}() override; 12 | 13 | protected Q_SLOTS: 14 | void init() override; 15 | 16 | public: // Plasma::AbstractRunner API 17 | void reloadConfiguration() override; 18 | void match(Plasma::RunnerContext &context) override; 19 | void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_org.kde.%{APPNAMELC}\") 2 | 3 | set(%{APPNAMELC}_SRCS %{APPNAMELC}.cpp) 4 | 5 | add_library(krunner_%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) 6 | target_link_libraries(krunner_%{APPNAMELC} KF5::Runner KF5::I18n) 7 | 8 | set(kcm_krunner_%{APPNAMELC}_SRCS 9 | config/%{APPNAMELC}_config.cpp 10 | ) 11 | 12 | ki18n_wrap_ui(kcm_krunner_%{APPNAMELC}_SRCS config/%{APPNAMELC}_config.ui) 13 | add_library(kcm_krunner_%{APPNAMELC} MODULE ${kcm_krunner_%{APPNAMELC}_SRCS}) 14 | target_link_libraries(kcm_krunner_%{APPNAMELC} 15 | Qt5::Core 16 | Qt5::Gui 17 | KF5::CoreAddons 18 | KF5::ConfigCore 19 | KF5::I18n 20 | KF5::ConfigWidgets 21 | KF5::Runner 22 | ) 23 | 24 | add_dependencies(krunner_%{APPNAMELC} kcm_krunner_%{APPNAMELC}) 25 | 26 | 27 | install(TARGETS krunner_%{APPNAMELC} kcm_krunner_%{APPNAMELC} DESTINATION ${PLUGIN_INSTALL_DIR}) 28 | install(FILES plasma-runner-%{APPNAMELC}.desktop config/plasma-runner-%{APPNAMELC}_config.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) 29 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/config/%{APPNAMELC}_config.cpp: -------------------------------------------------------------------------------- 1 | #include "%{APPNAMELC}_config.h" 2 | #include 3 | #include 4 | #include 5 | 6 | K_PLUGIN_FACTORY(%{APPNAME}ConfigFactory, registerPlugin<%{APPNAME}Config>("kcm_krunner_%{APPNAMELC}");) 7 | 8 | %{APPNAME}ConfigForm::%{APPNAME}ConfigForm(QWidget *parent) : QWidget(parent) { 9 | setupUi(this); 10 | } 11 | 12 | %{APPNAME}Config::%{APPNAME}Config(QWidget *parent, const QVariantList &args) : KCModule(parent, args) { 13 | m_ui = new %{APPNAME}ConfigForm(this); 14 | auto *layout = new QGridLayout(this); 15 | layout->addWidget(m_ui, 0, 0); 16 | 17 | // TODO connect signals 18 | 19 | // Open config file 20 | config = KSharedConfig::openConfig("krunnerrc")->group("Runners").group("%{APPNAMELC}"); 21 | } 22 | 23 | void %{APPNAME}Config::load() { 24 | 25 | KCModule::load(); 26 | 27 | // TODO load settings into GUI 28 | emit changed(false); 29 | } 30 | 31 | 32 | void %{APPNAME}Config::save() { 33 | 34 | KCModule::save(); 35 | 36 | // TODO save settings 37 | emit changed(false); 38 | } 39 | 40 | void %{APPNAME}Config::defaults() { 41 | 42 | KCModule::defaults(); 43 | 44 | // TODO set default values in GUI 45 | emit changed(true); 46 | } 47 | 48 | 49 | #include "%{APPNAMELC}_config.moc" 50 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/config/%{APPNAMELC}_config.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAME}CONFIG_H 2 | #define %{APPNAME}CONFIG_H 3 | 4 | #include "ui_%{APPNAMELC}_config.h" 5 | #include 6 | #include 7 | 8 | class %{APPNAME}ConfigForm : public QWidget, public Ui::%{APPNAME}ConfigUi { 9 | Q_OBJECT 10 | 11 | public: 12 | explicit %{APPNAME}ConfigForm(QWidget *parent); 13 | }; 14 | 15 | class %{APPNAME}Config : public KCModule { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit %{APPNAME}Config(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); 20 | 21 | public Q_SLOTS: 22 | void save() override; 23 | void load() override; 24 | void defaults() override; 25 | 26 | private: 27 | KConfigGroup config; 28 | %{APPNAME}ConfigForm *m_ui; 29 | 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/config/%{APPNAMELC}_config.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | %{AUTHOR} 4 | %{APPNAME}ConfigUi 5 | 6 | 7 | 8 | 0 9 | 0 10 | 669 11 | 580 12 | 13 | 14 | 15 | 16 | 300 17 | 0 18 | 19 | 20 | 21 | 22 | 23 | 24 | true 25 | 26 | 27 | 28 | 0 29 | 0 30 | 31 | 32 | 33 | Qt::LeftToRight 34 | 35 | 36 | %{APPNAME} Config 37 | 38 | 39 | 40 | 41 | 42 | Hello World ! 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/config/plasma-runner-%{APPNAMELC}_config.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | X-KDE-ServiceTypes=KCModule 4 | X-KDE-Library=kcm_krunner_%{APPNAMELC} 5 | X-KDE-ParentComponents=%{APPNAMELC} 6 | X-KDE-PluginKeyword=kcm_krunner_%{APPNAMELC} 7 | 8 | Name=%{APPNAMELC} 9 | -------------------------------------------------------------------------------- /qt_cpp_templates/krunner_templates/runner_kcmodule/runnerwithconfig/src/plasma-runner-%{APPNAMELC}.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=%{APPNAME} 3 | Comment=%{APPNAME} runner 4 | Icon=planetkde 5 | 6 | X-KDE-ServiceTypes=Plasma/Runner 7 | Type=Service 8 | X-KDE-Library=krunner_%{APPNAMELC} 9 | X-KDE-PluginInfo-Author=%{AUTHOR} 10 | X-KDE-PluginInfo-Email=%{EMAIL} 11 | X-KDE-PluginInfo-Name=%{APPNAMELC} 12 | X-KDE-PluginInfo-Version=0.1 13 | X-KDE-PluginInfo-License=LGPL 2.1+ 14 | X-KDE-PluginInfo-EnabledByDefault=true 15 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/.gitignore: -------------------------------------------------------------------------------- 1 | /cmake-build-debug 2 | /build 3 | /bin 4 | /.kdev4 5 | /.idea 6 | /.vscode 7 | 8 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(basic_cli_template_DIRS basic_qt_cli_template) 2 | set(validated_cli_template_DIRS validated_qt_cli_template) 3 | 4 | kde_package_app_templates(TEMPLATES ${basic_cli_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 5 | kde_package_app_templates(TEMPLATES ${validated_cli_template_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) 6 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/README.md: -------------------------------------------------------------------------------- 1 | Templates for Qt command line application. 2 | ----------------------------------------------------------------------- 3 | 4 | These are templates for CLI projects which used the QCommandLineParser. 5 | They are inspired by the official docs: https://doc.qt.io/qt-5/qcommandlineparser.html -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/basic_qt_cli_template/.gitignore: -------------------------------------------------------------------------------- 1 | /cmake-build-debug 2 | /build 3 | /bin 4 | /.kdev4 5 | /.idea 6 | /.vscode 7 | 8 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/basic_qt_cli_template/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | 5 | set(QT_MIN_VERSION "5.2") 6 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 7 | set(CMAKE_AUTOMOC ON) 8 | 9 | find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Core ) 10 | 11 | add_executable(${PROJECT_NAME} main.cpp) 12 | 13 | target_link_libraries(${PROJECT_NAME} Qt5::Core) 14 | 15 | install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 16 | 17 | # CPack configuration 18 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test package") 19 | set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) 20 | set(CPACK_PACKAGE_VERSION "0.0.1") 21 | set(CPACK_DEBIAN_PACKAGE_SECTION "utils") 22 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "%{AUTHOR}") 23 | set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.2)") 24 | 25 | set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") 26 | set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.2") 27 | 28 | INCLUDE(CPack) -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/basic_qt_cli_template/Makefile: -------------------------------------------------------------------------------- 1 | build-executable: 2 | mkdir -p build 3 | cd build; \ 4 | cmake ..; \ 5 | make -j4 6 | 7 | package-deb: 8 | cd build; \ 9 | cpack -G DEB 10 | 11 | package-rpm: 12 | cd build; \ 13 | cpack -G RPM 14 | 15 | build-packages: 16 | rm -rf build 17 | mkdir -p build 18 | cd build; \ 19 | cmake -D CMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ..; \ 20 | make -j4; \ 21 | make package-deb 22 | make package-rpm 23 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/basic_qt_cli_template/basic_qt_cli_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Basic CLI with Qt 3 | Comment=Basic CLI with the Qt CommandLineParser and deb/rpm builds 4 | Category=Qt/Terminal 5 | Icon=qtcreator -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/basic_qt_cli_template/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) { 5 | QCoreApplication app(argc, argv); 6 | QCoreApplication::setApplicationName("%{APPNAME}"); 7 | QCoreApplication::setApplicationVersion("1.0"); 8 | 9 | QCommandLineParser parser; 10 | parser.setApplicationDescription("Description for %{APPNAME}..."); 11 | parser.addHelpOption(); 12 | parser.addVersionOption(); 13 | parser.addPositionalArgument("arg", "Positional argument"); 14 | 15 | // Gets triggered with -t and expects value 16 | QCommandLineOption testOption("t", "Description", ""); 17 | parser.addOption(testOption); 18 | // Gets triggered with -d and --debug and expects no value 19 | QCommandLineOption debugOption(QStringList() << "d" << "debug", "Debug results"); 20 | parser.addOption(debugOption); 21 | 22 | parser.process(app); 23 | 24 | const QStringList args = parser.positionalArguments(); 25 | const QString testResult = parser.value(testOption); 26 | if (parser.isSet(debugOption)) { 27 | // For docs see https://doc.qt.io/qt-5/qcommandlineparser.html 28 | qDebug() << "Positional parameters:" << args; 29 | qDebug() << "Test:" << testResult; 30 | } 31 | 32 | 33 | } -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/.gitignore: -------------------------------------------------------------------------------- 1 | /cmake-build-debug 2 | /build 3 | /bin 4 | /.kdev4 5 | /.idea 6 | /.vscode 7 | 8 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(%{APPNAMELC}) 4 | 5 | set(QT_MIN_VERSION "5.2") 6 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 7 | set(CMAKE_AUTOMOC ON) 8 | 9 | find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Core ) 10 | 11 | add_executable(${PROJECT_NAME} main.cpp Validator.cpp Validator.h) 12 | 13 | target_link_libraries(${PROJECT_NAME} Qt5::Core) 14 | 15 | install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 16 | 17 | # CPack configuration 18 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test package") 19 | set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) 20 | set(CPACK_PACKAGE_VERSION "0.0.1") 21 | set(CPACK_DEBIAN_PACKAGE_SECTION "utils") 22 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "%{AUTHOR}") 23 | set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.2)") 24 | 25 | set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") 26 | set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.2") 27 | 28 | INCLUDE(CPack) -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/Makefile: -------------------------------------------------------------------------------- 1 | build-executable: 2 | mkdir -p build 3 | cd build; \ 4 | cmake ..; \ 5 | make -j4 6 | 7 | package-deb: 8 | cd build; \ 9 | cpack -G DEB 10 | 11 | package-rpm: 12 | cd build; \ 13 | cpack -G RPM 14 | 15 | build-packages: 16 | rm -rf build 17 | mkdir -p build 18 | cd build; \ 19 | cmake -D CMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ..; \ 20 | make -j4; \ 21 | make package-deb 22 | make package-rpm 23 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/Validator.cpp: -------------------------------------------------------------------------------- 1 | #include "Validator.h" 2 | #include 3 | 4 | CommandLineParseResult validateCommandLine(QCommandLineParser &parser, CommandLineValues *data, QString *errorMessage) { 5 | parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); 6 | parser.setApplicationDescription("Description..."); 7 | 8 | const QCommandLineOption helpOption = parser.addHelpOption(); 9 | const QCommandLineOption versionOption = parser.addVersionOption(); 10 | 11 | parser.addPositionalArgument("data", "Data property of struct", ""); 12 | 13 | const QCommandLineOption debugOption(QStringList() << "d" << "debug", "Debug results"); 14 | parser.addOption(debugOption); 15 | 16 | if (!parser.parse(QCoreApplication::arguments())) { 17 | *errorMessage = parser.errorText(); 18 | return CommandLineError; 19 | } 20 | 21 | if (parser.isSet(versionOption)) 22 | return CommandLineVersionRequested; 23 | 24 | if (parser.isSet(helpOption)) 25 | return CommandLineHelpRequested; 26 | 27 | const QStringList positionalArguments = parser.positionalArguments(); 28 | 29 | if (positionalArguments.isEmpty() || positionalArguments.first().isEmpty()) { 30 | *errorMessage = "Argument missing."; 31 | return CommandLineError; 32 | } 33 | if (positionalArguments.size() > 1) { 34 | *errorMessage = "Several arguments specified."; 35 | return CommandLineError; 36 | } 37 | 38 | data->data = positionalArguments.first(); 39 | 40 | if (parser.isSet(debugOption)) { 41 | qDebug() << "Positional arguments: " << positionalArguments; 42 | } 43 | 44 | return CommandLineOk; 45 | } 46 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/Validator.h: -------------------------------------------------------------------------------- 1 | #ifndef %{APPNAMEUC}_VALIDATOR_H 2 | #define %{APPNAMEUC}_VALIDATOR_H 3 | 4 | #include 5 | 6 | struct CommandLineValues { 7 | QString data; 8 | }; 9 | 10 | enum CommandLineParseResult { 11 | CommandLineOk, 12 | CommandLineError, 13 | CommandLineVersionRequested, 14 | CommandLineHelpRequested 15 | }; 16 | 17 | CommandLineParseResult validateCommandLine(QCommandLineParser &parser, CommandLineValues *data, QString *errorMessage); 18 | 19 | #endif //%{APPNAMEUC}_VALIDATOR_H 20 | -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) { 5 | QCoreApplication app(argc, argv); 6 | QCoreApplication::setApplicationName("%{APPNAME}"); 7 | QCoreApplication::setApplicationVersion("1.0"); 8 | 9 | QCommandLineParser parser; 10 | QString errorMessage; 11 | CommandLineValues data; 12 | 13 | switch (validateCommandLine(parser, &data, &errorMessage)) { 14 | case CommandLineOk: 15 | break; 16 | case CommandLineError: 17 | fprintf(stderr, "%s\n\n%s", qPrintable(errorMessage), qPrintable(parser.helpText())); 18 | exit(1); 19 | case CommandLineVersionRequested: 20 | parser.showVersion(); 21 | case CommandLineHelpRequested: 22 | parser.showHelp(0); 23 | } 24 | } -------------------------------------------------------------------------------- /qt_cpp_templates/qt_cli_templates/validated_qt_cli_template/validated_qt_cli_template.kdevtemplate: -------------------------------------------------------------------------------- 1 | [General] 2 | Name=Qt CLI with validation 3 | Comment=A CLI with the QCommandLineParser, validation setup and deb/rpm builds 4 | Category=Qt/Terminal 5 | Icon=qtcreator 6 | -------------------------------------------------------------------------------- /simple_desktop_application_file/simple_desktop_application_file.desktop: -------------------------------------------------------------------------------- 1 | [General] 2 | # See https://techbase.kde.org/KDevelop5/File_template_specification for documentation 3 | Name=Desktop File 4 | Comment=A simple .desktop file for an application 5 | Category=Utility/Desktop 6 | Type=File 7 | Language=Text 8 | Files=DESKTOP_FILE 9 | 10 | [DESKTOP_FILE] 11 | Name=Desktop File 12 | File=template.desktop 13 | OutputFile={{ name }}.desktop 14 | -------------------------------------------------------------------------------- /simple_desktop_application_file/template.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Encoding=UTF-8 3 | Version=1.0 4 | Type=Application 5 | Terminal=false 6 | Exec=/path/to/executable 7 | Name=Name of Application 8 | Icon=/path/to/icon 9 | --------------------------------------------------------------------------------