diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b506b77..d70adf05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,119 +1,121 @@ cmake_minimum_required(VERSION 3.0) set(KF5_VERSION "5.37.0") # handled by release scripts set(KF5_DEP_VERSION "5.36.0") # handled by release scripts project(KTextEditor VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) find_package(ECM 5.36.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) # add own modules to search path, too set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(ECMSetupVersion) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(CheckFunctionExists) include(CheckSymbolExists) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) +include(KDEPackageAppTemplates) include(GenerateExportHeader) include(ECMAddQch) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version( PROJECT VARIABLE_PREFIX KTEXTEDITOR VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/ktexteditor_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfigVersion.cmake" SOVERSION 5 ) # Dependencies set(REQUIRED_QT_VERSION 5.6.0) # Required Qt5 components to build this framework find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets Script PrintSupport Xml XmlPatterns) find_package(KF5Archive ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5GuiAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED) find_package(KF5KIO ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Parts ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Sonnet ${KF5_DEP_VERSION} REQUIRED) find_package(KF5IconThemes ${KF5_DEP_VERSION} REQUIRED) find_package(KF5SyntaxHighlighting ${KF5_DEP_VERSION} REQUIRED) # libgit2 integration, at least 0.22 with proper git_libgit2_init() find_package(LibGit2 "0.22.0") # EditorConfig integration find_package(EditorConfig) # vi mode on per default option (BUILD_VIMODE "Build vimode in" ON) # Subdirectories add_definitions(-DTRANSLATION_DOMAIN=\"ktexteditor5\") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) endif() +add_subdirectory(templates) # Create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5TextEditor") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5TextEditor_QCH FILE KF5TextEditorQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5TextEditorQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5TextEditorConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfig.cmake" INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}" ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5TextEditorConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5TextEditorTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5TextEditorTargets.cmake NAMESPACE KF5:: ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ktexteditor_version.h" DESTINATION "${KDE_INSTALL_INCLUDEDIR_KF5}" COMPONENT Devel ) # config.h check_symbol_exists (fdatasync unistd.h HAVE_FDATASYNC) configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) # let our config.h be found first in any case include_directories (BEFORE ${CMAKE_CURRENT_BINARY_DIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/ExtraDesktop.sh b/ExtraDesktop.sh new file mode 100644 index 00000000..0c46ec14 --- /dev/null +++ b/ExtraDesktop.sh @@ -0,0 +1,4 @@ +#! /bin/sh +#This file outputs in a separate line each file with a .desktop syntax +#that needs to be translated but has a non .desktop extension +find -name \*.kdevtemplate -print diff --git a/templates/CMakeLists.txt b/templates/CMakeLists.txt new file mode 100644 index 00000000..7ebfc0b7 --- /dev/null +++ b/templates/CMakeLists.txt @@ -0,0 +1,5 @@ +set(apptemplate_DIRS + ktexteditor-plugin +) + +kde_package_app_templates(TEMPLATES ${apptemplate_DIRS} INSTALL_DIR ${KDE_INSTALL_KTEMPLATESDIR}) diff --git a/templates/ktexteditor-plugin/CMakeLists.txt b/templates/ktexteditor-plugin/CMakeLists.txt new file mode 100644 index 00000000..d78cf14a --- /dev/null +++ b/templates/ktexteditor-plugin/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.0) + +project(%{APPNAMELC}) + +set(REQUIRED_ECM_VERSION "5.23.0") +find_package(ECM ${REQUIRED_ECM_VERSION} REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(FeatureSummary) + +set(REQUIRED_KF5_VERSION "5.23.0") +find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED COMPONENTS + I18n + TextEditor +) + +add_subdirectory(src) + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/templates/ktexteditor-plugin/README.md b/templates/ktexteditor-plugin/README.md new file mode 100644 index 00000000..0b59f458 --- /dev/null +++ b/templates/ktexteditor-plugin/README.md @@ -0,0 +1,38 @@ +# Readme file + +## Introduction + +This is a simple Kate plugin right now. Make it do something :) + + +## Installation instructions + +Define some testing install dir: + + export MYKATEPLUGINPATH=$HOME/mykateplugins + +Build and install: + + mkdir build + cd build + cmake .. -DKDE_INSTALL_PLUGINDIR=$MYKATEPLUGINPATH + make + make install + + +## Check the plugin + +Start Kate on the commandline, with adapted QT_PLUGIN_PATH: + + export QT_PLUGIN_PATH=$MYKATEPLUGINPATH:$QT_PLUGIN_PATH + kate --startanon + +Go to Settings / Configurate Kate / Application / Plugins +Search and enable your plugin + + +## Help + +https://api.kde.org/frameworks/ktexteditor/html/classKTextEditor_1_1Plugin.html#plugin_intro + +For help or more information, contact the Kate team diff --git a/templates/ktexteditor-plugin/ktexteditor-plugin.kdevtemplate b/templates/ktexteditor-plugin/ktexteditor-plugin.kdevtemplate new file mode 100644 index 00000000..3bcd9618 --- /dev/null +++ b/templates/ktexteditor-plugin/ktexteditor-plugin.kdevtemplate @@ -0,0 +1,7 @@ +# KDE Config File +[General] +Name=C++ +Comment=Generates a KTextEditor C++ plugin to perform special operations on text in KWrite, Kate, KDevelop etc. +Category=KTextEditor/Plugin +Icon=ktexteditor-plugin.png +ShowFilesAfterGeneration=%{dest}/README.md diff --git a/templates/ktexteditor-plugin/ktexteditor-plugin.png b/templates/ktexteditor-plugin/ktexteditor-plugin.png new file mode 100644 index 00000000..8b638def Binary files /dev/null and b/templates/ktexteditor-plugin/ktexteditor-plugin.png differ diff --git a/templates/ktexteditor-plugin/src/%{APPNAMELC}.json b/templates/ktexteditor-plugin/src/%{APPNAMELC}.json new file mode 100644 index 00000000..d29465da --- /dev/null +++ b/templates/ktexteditor-plugin/src/%{APPNAMELC}.json @@ -0,0 +1,16 @@ +{ + "KPlugin": { + "Authors": [ + { + "Email": "%{EMAIL}", + "Name": "%{AUTHOR}" + } + ], + "Description": "A KTextEditor plugin", + "Icon": "tool-text", + "Name": "%{APPNAME}", + "ServiceTypes": [ + "KTextEditor/Plugin" + ] + } +} diff --git a/templates/ktexteditor-plugin/src/%{APPNAMELC}plugin.cpp b/templates/ktexteditor-plugin/src/%{APPNAMELC}plugin.cpp new file mode 100644 index 00000000..4a8a6e93 --- /dev/null +++ b/templates/ktexteditor-plugin/src/%{APPNAMELC}plugin.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . + */ + +#include "%{APPNAMELC}plugin.h" + +#include "%{APPNAMELC}view.h" + +// KF headers +#include + +#include +#include + +K_PLUGIN_FACTORY_WITH_JSON(%{APPNAME}PluginFactory, "%{APPNAMELC}.json", registerPlugin<%{APPNAME}Plugin>();) + + +%{APPNAME}Plugin::%{APPNAME}Plugin(QObject* parent, const QVariantList& /*args*/) + : KTextEditor::Plugin(parent) +{ +} + +%{APPNAME}Plugin::~%{APPNAME}Plugin() +{ +} + +QObject* %{APPNAME}Plugin::createView(KTextEditor::MainWindow* mainwindow) +{ + return new %{APPNAME}View(this, mainwindow); +} + + +// needed for K_PLUGIN_FACTORY_WITH_JSON +#include <%{APPNAMELC}plugin.moc> diff --git a/templates/ktexteditor-plugin/src/%{APPNAMELC}plugin.h b/templates/ktexteditor-plugin/src/%{APPNAMELC}plugin.h new file mode 100644 index 00000000..d8f4b352 --- /dev/null +++ b/templates/ktexteditor-plugin/src/%{APPNAMELC}plugin.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . + */ + +#ifndef %{APPNAMEUC}PLUGIN_H +#define %{APPNAMEUC}PLUGIN_H + +// KF headers +#include + +class %{APPNAME}Plugin : public KTextEditor::Plugin +{ + Q_OBJECT + +public: + /** + * Default constructor, with arguments as expected by KPluginFactory + */ + %{APPNAME}Plugin(QObject* parent, const QVariantList& args); + + ~%{APPNAME}Plugin() override; + +public: // KTextEditor::Plugin API + QObject* createView(KTextEditor::MainWindow* mainWindow) override; +}; + +#endif // %{APPNAMEUC}PLUGIN_H diff --git a/templates/ktexteditor-plugin/src/%{APPNAMELC}view.cpp b/templates/ktexteditor-plugin/src/%{APPNAMELC}view.cpp new file mode 100644 index 00000000..29389f69 --- /dev/null +++ b/templates/ktexteditor-plugin/src/%{APPNAMELC}view.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . + */ + +#include "%{APPNAMELC}view.h" + +#include "%{APPNAMELC}plugin.h" + +// KF headers +#include +#include +#include + +#include + + +%{APPNAME}View::%{APPNAME}View(%{APPNAME}Plugin* plugin, KTextEditor::MainWindow* mainwindow) + : QObject(mainwindow) +{ + Q_UNUSED(plugin); +} + +%{APPNAME}View::~%{APPNAME}View() +{ +} diff --git a/templates/ktexteditor-plugin/src/%{APPNAMELC}view.h b/templates/ktexteditor-plugin/src/%{APPNAMELC}view.h new file mode 100644 index 00000000..b3b64d6d --- /dev/null +++ b/templates/ktexteditor-plugin/src/%{APPNAMELC}view.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . + */ + +#ifndef %{APPNAMEUC}VIEW_H +#define %{APPNAMEUC}VIEW_H + +// Qt headers +#include + +namespace KTextEditor { +class MainWindow; +} + +class %{APPNAME}Plugin; + +class %{APPNAME}View: public QObject +{ + Q_OBJECT + +public: + %{APPNAME}View(%{APPNAME}Plugin* plugin, KTextEditor::MainWindow *view); + ~%{APPNAME}View() override; +}; + +#endif // %{APPNAMEUC}VIEW_H diff --git a/templates/ktexteditor-plugin/src/CMakeLists.txt b/templates/ktexteditor-plugin/src/CMakeLists.txt new file mode 100644 index 00000000..ed6c1b77 --- /dev/null +++ b/templates/ktexteditor-plugin/src/CMakeLists.txt @@ -0,0 +1,15 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"%{APPNAMELC}\") + +set(%{APPNAMELC}_SRCS + %{APPNAMELC}plugin.cpp + %{APPNAMELC}view.cpp +) + +add_library(%{APPNAMELC} MODULE ${%{APPNAMELC}_SRCS}) + +target_link_libraries(%{APPNAMELC} + KF5::TextEditor + KF5::I18n +) + +install(TARGETS %{APPNAMELC} DESTINATION ${KDE_INSTALL_PLUGINDIR}/ktexteditor) diff --git a/templates/ktexteditor-plugin/src/Message.sh b/templates/ktexteditor-plugin/src/Message.sh new file mode 100644 index 00000000..3e6642c9 --- /dev/null +++ b/templates/ktexteditor-plugin/src/Message.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name \*.cpp` -o $podir/%{APPNAMELC}.pot