diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt index 13f9592fba1..283ebad166a 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt @@ -16,11 +16,12 @@ project(%{PluginName}) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) find_package(QtCreator REQUIRED COMPONENTS Core) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) -set(QtX Qt${QT_VERSION_MAJOR}) +find_package(Qt6 COMPONENTS Widgets REQUIRED) # Add a CMake option that enables building your plugin with tests. # You don't want your released plugin binaries to contain tests, @@ -30,7 +31,7 @@ option(WITH_TESTS "Builds with tests" NO) if(WITH_TESTS) # Look for QtTest - find_package(${QtX} REQUIRED COMPONENTS Test) + find_package(Qt6 REQUIRED COMPONENTS Test) # Tell CMake functions like add_qtc_plugin about the QtTest component. set(IMPLICIT_DEPENDS Qt::Test) @@ -43,7 +44,7 @@ add_qtc_plugin(%{PluginName} PLUGIN_DEPENDS QtCreator::Core DEPENDS - ${QtX}::Widgets + Qt::Widgets QtCreator::ExtensionSystem QtCreator::Utils SOURCES @@ -51,8 +52,6 @@ add_qtc_plugin(%{PluginName} .github/workflows/README.md README.md %{SrcFileName} - %{HdrFileName} - %{GlobalHdrFileName} %{ConstantsHdrFileName} %{TrHdrFileName} ) diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml index d69cbfae59a..1f922040863 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml @@ -7,6 +7,7 @@ env: QT_VERSION: %{JS: Util.qtVersion()} QT_CREATOR_VERSION: %{JS: Util.qtCreatorVersion()} QT_CREATOR_SNAPSHOT: NO + MACOS_DEPLOYMENT_TARGET: 11.0 CMAKE_VERSION: 3.21.1 NINJA_VERSION: 1.10.1 @@ -107,17 +108,21 @@ jobs: set(url_os "windows_x86") set(qt_package_arch_suffix "win64_msvc2019_64") set(qt_dir_prefix "${qt_version}/msvc2019_64") - set(qt_package_suffix "-Windows-Windows_10_21H2-MSVC2019-Windows-Windows_10_21H2-X86_64") + set(qt_package_suffix "-Windows-Windows_10_22H2-MSVC2019-Windows-Windows_10_22H2-X86_64") elseif ("${{ runner.os }}" STREQUAL "Linux") set(url_os "linux_x64") - set(qt_package_arch_suffix "gcc_64") + if (qt_version VERSION_LESS "6.7.0") + set(qt_package_arch_suffix "gcc_64") + else() + set(qt_package_arch_suffix "linux_gcc_64") + endif() set(qt_dir_prefix "${qt_version}/gcc_64") - set(qt_package_suffix "-Linux-RHEL_8_4-GCC-Linux-RHEL_8_4-X86_64") + set(qt_package_suffix "-Linux-RHEL_8_8-GCC-Linux-RHEL_8_8-X86_64") elseif ("${{ runner.os }}" STREQUAL "macOS") set(url_os "mac_x64") set(qt_package_arch_suffix "clang_64") set(qt_dir_prefix "${qt_version}/macos") - set(qt_package_suffix "-MacOS-MacOS_12-Clang-MacOS-MacOS_12-X86_64-ARM64") + set(qt_package_suffix "-MacOS-MacOS_13-Clang-MacOS-MacOS_13-X86_64-ARM64") endif() set(qt_base_url "https://download.qt.io/online/qtsdkrepository/${url_os}/desktop/qt6_${qt_version_dotless}") @@ -202,7 +207,7 @@ jobs: run: | set(ENV{CC} ${{ matrix.config.cc }}) set(ENV{CXX} ${{ matrix.config.cxx }}) - set(ENV{MACOSX_DEPLOYMENT_TARGET} "10.13") + set(ENV{MACOSX_DEPLOYMENT_TARGET} "${{ env.MACOS_DEPLOYMENT_TARGET }}") if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") execute_process( @@ -255,6 +260,7 @@ jobs: release: if: contains(github.ref, 'tags/v') runs-on: ubuntu-latest + permissions: write-all needs: build steps: diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp index c6724f1b0a8..d045fd19bb1 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.cpp @@ -1,78 +1,89 @@ %{Cpp:LicenseTemplate}\ -#include "%{HdrFileName}" #include "%{ConstantsHdrFileName}" #include "%{TrHdrFileName}" -#include -#include +#include #include #include -#include #include +#include +#include + +#include #include -#include #include #include +#include namespace %{PluginName}::Internal { -%{CN}::%{CN}() +class %{CN} : public ExtensionSystem::IPlugin { - // Create your members -} + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "%{PluginName}.json") -%{CN}::~%{CN}() -{ - // Unregister objects from the plugin manager's object pool - // Delete members -} +public: + %{CN}() + { + // Create your members + } -void %{CN}::initialize() -{ - // Register objects in the plugin manager's object pool - // Load settings - // Add actions to menus - // Connect to other plugins' signals - // In the initialize function, a plugin can be sure that the plugins it - // depends on have initialized their members. + ~%{CN}() final + { + // Unregister objects from the plugin manager's object pool + // Delete members + } - // If you need access to command line arguments or to report errors, use the - // bool IPlugin::initialize(const QStringList &arguments, QString *errorString) - // overload. + void initialize() final + { + // Register objects in the plugin manager's object pool + // Load settings + // Add actions to menus + // Connect to other plugins' signals + // In the initialize function, a plugin can be sure that the plugins it + // depends on have initialized their members. - auto action = new QAction(Tr::tr("%{PluginName} Action"), this); - Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID, - Core::Context(Core::Constants::C_GLOBAL)); - cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+Meta+A"))); - connect(action, &QAction::triggered, this, &%{CN}::triggerAction); + // If you need access to command line arguments or to report errors, use the + // bool IPlugin::initialize(const QStringList &arguments, QString *errorString) + // overload. - Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); - menu->menu()->setTitle(Tr::tr("%{PluginName}")); - menu->addAction(cmd); - Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); -} + auto action = new QAction(Tr::tr("%{PluginName} Action"), this); + Core::Command *cmd = Core::ActionManager::registerAction( + action, Constants::ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); + cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+Meta+A"))); + connect(action, &QAction::triggered, this, &%{CN}::triggerAction); -void %{CN}::extensionsInitialized() -{ - // Retrieve objects from the plugin manager's object pool - // In the extensionsInitialized function, a plugin can be sure that all - // plugins that depend on it are completely initialized. -} + Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); + menu->menu()->setTitle(Tr::tr("%{PluginName}")); + menu->addAction(cmd); + Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); + } -ExtensionSystem::IPlugin::ShutdownFlag %{CN}::aboutToShutdown() -{ - // Save settings - // Disconnect from signals that are not needed during shutdown - // Hide UI (if you add UI that is not in the main window directly) - return SynchronousShutdown; -} + void extensionsInitialized() final + { + // Retrieve objects from the plugin manager's object pool + // In the extensionsInitialized function, a plugin can be sure that all + // plugins that depend on it are completely initialized. + } -void %{CN}::triggerAction() -{ - QMessageBox::information(Core::ICore::mainWindow(), - Tr::tr("Action Triggered"), - Tr::tr("This is an action from %{PluginName}.")); -} + ShutdownFlag aboutToShutdown() final + { + // Save settings + // Disconnect from signals that are not needed during shutdown + // Hide UI (if you add UI that is not in the main window directly) + return SynchronousShutdown; + } + +private: + void triggerAction() + { + QMessageBox::information(Core::ICore::mainWindow(), + Tr::tr("Action Triggered"), + Tr::tr("This is an action from %{PluginName}.")); + } +}; } // namespace %{PluginName}::Internal + +#include <%{MocFileName}> diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h deleted file mode 100644 index 6e1fad933c0..00000000000 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin.h +++ /dev/null @@ -1,27 +0,0 @@ -%{Cpp:LicenseTemplate}\ -#pragma once - -#include "%{GlobalHdrFileName}" - -#include - -namespace %{PluginName}::Internal { - -class %{CN} : public ExtensionSystem::IPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "%{PluginName}.json") - -public: - %{CN}(); - ~%{CN}() override; - - void initialize() override; - void extensionsInitialized() override; - ShutdownFlag aboutToShutdown() override; - -private: - void triggerAction(); -}; - -} // namespace %{PluginName}::Internal diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin_global.h b/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin_global.h deleted file mode 100644 index a81c8fcee0d..00000000000 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/myplugin_global.h +++ /dev/null @@ -1,10 +0,0 @@ -%{Cpp:LicenseTemplate}\ -#pragma once - -#include - -#if defined(%{LibraryDefine}) -# define %{LibraryExport} Q_DECL_EXPORT -#else -# define %{LibraryExport} Q_DECL_IMPORT -#endif diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json b/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json index e1feaa53bbb..8066d883c24 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/wizard.json @@ -19,8 +19,7 @@ { "key": "LibraryDefine", "value": "%{JS: Cpp.headerGuard(value('PluginName')) + '_LIBRARY'}" }, { "key": "LibraryExport", "value": "%{JS: Cpp.headerGuard(value('PluginName')) + '_EXPORT'}" }, { "key": "SrcFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), Util.preferredSuffix('text/x-c++src'))}" }, - { "key": "HdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), Util.preferredSuffix('text/x-c++hdr'))}" }, - { "key": "GlobalHdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower') + '_global', Util.preferredSuffix('text/x-c++hdr'))}" }, + { "key": "MocFileName", "value": "%{JS: Util.fileName(value('PluginNameLower'), 'moc')}" }, { "key": "ConstantsHdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower') + 'constants', Util.preferredSuffix('text/x-c++hdr'))}" }, { "key": "TrHdrFileName", "value": "%{JS: Util.fileName(value('PluginNameLower') + 'tr', Util.preferredSuffix('text/x-c++hdr'))}" }, { "key": "CN", "value": "%{JS: Cpp.className(value('PluginName') + 'Plugin')}" }, @@ -170,14 +169,6 @@ "source": "myplugin.cpp", "target": "%{SrcFileName}" }, - { - "source": "myplugin.h", - "target": "%{HdrFileName}" - }, - { - "source": "myplugin_global.h", - "target": "%{GlobalHdrFileName}" - }, { "source": "mypluginconstants.h", "target": "%{ConstantsHdrFileName}" @@ -197,7 +188,7 @@ }, { "source": "../projects/git.ignore", - "target": ".gitignore", + "target": ".gitignore" "condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}" } ]