feat: 增加插件项目模板
This commit is contained in:
parent
b235513f70
commit
bd5ddfba9a
|
@ -10,4 +10,5 @@ jobs:
|
|||
uses: jidicula/clang-format-action@v4.14.0
|
||||
with:
|
||||
clang-format-version: '12'
|
||||
exclude-regex: '(qt-template|mkinstaller)'
|
||||
fallback-style: 'LLVM' # optional
|
||||
|
|
|
@ -12,3 +12,4 @@ jobs:
|
|||
uses: neg-c/cmake-format-action@v0.1.3
|
||||
with:
|
||||
inplace: true
|
||||
exclude: "qt-template mkinstaller"
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
#include "testsettingpage.h"
|
||||
#include "testwingeditorviewwidget.h"
|
||||
|
||||
TestPlugin::TestPlugin() : puid(QStringLiteral("TestPlugin2")) {
|
||||
TestPlugin::TestPlugin()
|
||||
: WingHex::IWingPlugin(), puid(QStringLiteral("TestPlugin2")) {
|
||||
// 在构造函数中,所有的 API 都无法调用。插件的翻译文件也不会自动加载。
|
||||
// 在构造函数中,仅适合做一些为初始化准备的操作。
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Qt-Template
|
||||
|
||||
  该目录是模板目录,用于存放与插件开发的相关模板,极大的提高开发 WingHexExploer2 的插件便利性。
|
||||
|
||||
  目前该目录下只有一个`winghexplugin`,这个存放着 QT 认可的项目模板向导相关文件。而`qt-template-installer.py`是安装管理器,用于方便模板的卸载和安装,你可以使用以下方式进行安装/卸载:
|
||||
|
||||
```bash
|
||||
python3 qt-template-installer.py install # 安装模板
|
||||
python3 qt-template-installer.py uninstall # 卸载模板
|
||||
```
|
||||
|
||||
  当然,你可以手动进行安装,只需把`winghexplugin`拷贝到对应的模板存放目录,具体请看 [官方文档](https://docs.huihoo.com/qt/qtcreator/4.2/creator-project-wizards.html#locating-wizards) 。
|
||||
|
||||
  安装完毕之后,你在新建项目的 Library 分类下将会看到你已经安装好的模板:
|
||||
|
||||

|
||||
|
||||
  它和创建`Qt Creator Plugin`的逻辑比较相像,但有不同之处,就是需要指定插件版本和开发库目录以及主程序目录:
|
||||
|
||||

|
||||
|
||||
  `SDK Paths`填写开发头文件放置的位置,`WingHexExplorer2 Installation`填写安装该十六进制编辑器的安装目录,这里启动程序 **请不要填写安装器给你安装的目录位置,因为启动测试模式会把编译的测试 Dll 拷贝到插件目录,如果没有管理员权限会导致拷贝失败。** 这个软件可以认为是绿色软件的性质,只是建立了文件关联和在个人电脑保存了配置。完全可以把安装目录单独拷贝到一个不需要管理员权限的位置然后继续。
|
||||
|
||||

|
||||
|
||||
  在选择构建套件时候一定要注意你开发插件的套件的 QT 版本一定要和`WingHexExplorer2`保持一致,不然开发编译之后的插件会因为 Qt 版本检查不通过导致插件无法加载。详细的 QT 版本细节可以到 **软件设置** 的 **基本** 下查看,如下图所示:
|
||||
|
||||

|
||||
|
||||
  最后祝你开发插件愉快!
|
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
After Width: | Height: | Size: 78 KiB |
|
@ -0,0 +1,60 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
# @Time : 2024/12/27
|
||||
# @Author : 寂静的羽夏(wingsummer)
|
||||
# @FileName: qt-template-installer.py
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import pathlib
|
||||
from colorama import Fore, Style
|
||||
|
||||
def install():
|
||||
installer_path = os.path.dirname(os.path.abspath(__file__))
|
||||
install_path = os.path.join(getQtTemplateDir(), "winghexplugin")
|
||||
shutil.copytree(os.path.join(installer_path, "winghexplugin"),
|
||||
install_path, dirs_exist_ok=True)
|
||||
print(Fore.GREEN + "WingHexExplorer2 plugin Template was installed under: " + install_path + Style.RESET_ALL)
|
||||
|
||||
def uninstall():
|
||||
install_path = os.path.join(getQtTemplateDir(), "winghexplugin")
|
||||
shutil.rmtree(install_path)
|
||||
print(Fore.RED + "WingHexExplorer2 plugin Template was removed: " + install_path + Style.RESET_ALL)
|
||||
|
||||
|
||||
def getQtTemplateDir() -> pathlib.Path:
|
||||
# https://docs.huihoo.com/qt/qtcreator/4.2/creator-project-wizards.html#locating-wizards
|
||||
home = pathlib.Path.home()
|
||||
if sys.platform == "win32":
|
||||
return home / "AppData/QtProject/qtcreator/templates/wizards"
|
||||
else:
|
||||
return home / ".config/QtProject/qtcreator/templates/wizards"
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="qt-template-installer.py", description=f"A WingHexExplorer2 Plugin tempalte installer for QT.")
|
||||
parser.add_argument(
|
||||
"action",
|
||||
choices=["install", "uninstall"],
|
||||
nargs="?",
|
||||
help="Action to perform: install or uninstall."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# checking build toolkits
|
||||
if args.action == "install":
|
||||
install()
|
||||
elif args.action == "uninstall":
|
||||
uninstall()
|
||||
|
||||
exit(0)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
else:
|
||||
print(
|
||||
Fore.RED + "[Error] Please run this script in main mode" + Style.RESET_ALL)
|
|
@ -0,0 +1 @@
|
|||
colorama==0.4.6
|
Binary file not shown.
After Width: | Height: | Size: 174 KiB |
|
@ -0,0 +1,150 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveBitFields: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
...
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# -----------------------------
|
||||
# Options effecting formatting.
|
||||
# -----------------------------
|
||||
with section("format"):
|
||||
|
||||
# How wide to allow formatted cmake files
|
||||
line_width = 80
|
||||
|
||||
# How many spaces to tab for indent
|
||||
tab_size = 4
|
||||
|
||||
# If true, separate flow control names from their parentheses with a space
|
||||
separate_ctrl_name_with_space = False
|
||||
|
||||
# If true, separate function names from parentheses with a space
|
||||
separate_fn_name_with_space = False
|
||||
|
||||
# If a statement is wrapped to more than one line, than dangle the closing
|
||||
# parenthesis on its own line.
|
||||
dangle_parens = False
|
|
@ -0,0 +1,110 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(%{ProjectName} LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
if(MSVC)
|
||||
string(APPEND CMAKE_CXX_FLAGS " /utf-8")
|
||||
string(APPEND CMAKE_C_FLAGS " /utf-8")
|
||||
endif()
|
||||
|
||||
option(TEST_MODE TRUE)
|
||||
|
||||
set(WINGHEX_SDK "%{WingHexSDKPath}")
|
||||
|
||||
set(PLUGIN_INTERFACE_FOUND FALSE)
|
||||
set(PLUGIN_SETPAGE_FOUND FALSE)
|
||||
if(EXISTS "${WINGHEX_SDK}/iwingplugin.h")
|
||||
set(PLUGIN_INTERFACE_FOUND TRUE)
|
||||
endif()
|
||||
if(EXISTS "${WINGHEX_SDK}/settingpage.h")
|
||||
set(PLUGIN_SETPAGE_FOUND TRUE)
|
||||
endif()
|
||||
if(PLUGIN_INTERFACE_FOUND AND PLUGIN_SETPAGE_FOUND)
|
||||
message(STATUS "${WINGHEX_SDK} is valid SDK path")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid SDK path!")
|
||||
endif()
|
||||
|
||||
set(WINGHEX_SDK_HEADER "${WINGHEX_SDK}/iwingplugin.h"
|
||||
"${WINGHEX_SDK}/settingpage.h")
|
||||
include_directories(${WINGHEX_SDK})
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
|
||||
@if %{HasTranslation}
|
||||
set(TS_FILES %{TsFileName})
|
||||
|
||||
set(TRANSLATION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(${QT_VERSION_MAJOR} EQUAL 5)
|
||||
qt5_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
elseif(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
qt6_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported QT version")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TranslationUtils.cmake)
|
||||
add_plugin_translations_resource(QM_RES %{ProjectName} ${QM_FILES})
|
||||
@else
|
||||
## Example for WingHexExplorer2 Plugin Localization
|
||||
|
||||
# set(TS_FILES )
|
||||
|
||||
# set(TRANSLATION_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# if(${QT_VERSION_MAJOR} EQUAL 5)
|
||||
# qt5_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
# elseif(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
# qt6_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES})
|
||||
# else()
|
||||
# message(FATAL_ERROR "Unsupported QT version")
|
||||
# endif()
|
||||
|
||||
# include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TranslationUtils.cmake)
|
||||
# add_plugin_translations_resource(QM_RES %{ProjectName} ${QM_FILES})
|
||||
@endif
|
||||
|
||||
add_library(%{ProjectName} SHARED
|
||||
${WINGHEX_SDK_HEADER}
|
||||
@if %{HasTranslation}
|
||||
${QM_FILES}
|
||||
${QM_RES}
|
||||
@else
|
||||
# ${QM_FILES}
|
||||
# ${QM_RES}
|
||||
@endif
|
||||
%{SrcFileName}
|
||||
%{HdrFileName}
|
||||
%{PluginJsonFile}
|
||||
)
|
||||
|
||||
set_target_properties(%{ProjectName} PROPERTIES SUFFIX ".wingplg")
|
||||
|
||||
if(TEST_MODE)
|
||||
# If you want to be able to debug easily every time you compile, please set
|
||||
# this variable. Because this test plugin is a subproject of the main
|
||||
# project, use CMAKE_BINARY_DIR
|
||||
|
||||
set(WINGHEX_PATH "%{WingHexEXEPath}")
|
||||
|
||||
set(WINGHEX_PLUGIN_PATH "${WINGHEX_PATH}/plugin")
|
||||
add_custom_command(
|
||||
TARGET %{ProjectName}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${WINGHEX_PLUGIN_PATH}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:%{ProjectName}>
|
||||
${WINGHEX_PLUGIN_PATH})
|
||||
endif()
|
||||
|
||||
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
\"Id\" : \"%{JS: value('PluginName').toLowerCase()}\",
|
||||
\"Name\" : \"%{PluginName}\",
|
||||
\"Version\" : \"0.0.1\",
|
||||
\"CompatVersion\" : \"0.0.1\",
|
||||
\"Vendor\" : \"%{VendorName}\",
|
||||
\"VendorId\" : \"%{JS: value('VendorName').toLowerCase().replace(/ /g, '')}\",
|
||||
\"Copyright\" : \"%{Copyright}\",
|
||||
\"License\" : \"%{License}\",
|
||||
\"Description\" : \"%{Description}\",
|
||||
\"Url\" : \"%{Url}\",
|
||||
\"DocumentationUrl\" : \"\"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2019-2022, Pedro López-Cabanillas
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,51 @@
|
|||
# ==============================================================================
|
||||
# Copyright (C) 2024-2027 WingSummer
|
||||
#
|
||||
# You can redistribute this file and/or modify it under the terms of the BSD
|
||||
# 3-Clause.
|
||||
#
|
||||
# THIS FILE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# =============================================================================
|
||||
|
||||
if(NOT TARGET Qt${QT_VERSION_MAJOR}::lconvert)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"The package \\"Qt${QT_VERSION_MAJOR}LinguistTools\\" is required.")
|
||||
endif()
|
||||
|
||||
set(Qt_LCONVERT_EXECUTABLE Qt${QT_VERSION_MAJOR}::lconvert)
|
||||
|
||||
function(ADD_PLUGIN_TRANSLATIONS_RESOURCE res_file target)
|
||||
set(_qm_files ${ARGN})
|
||||
set(_res_file ${CMAKE_CURRENT_BINARY_DIR}/app_translations.qrc)
|
||||
|
||||
file(
|
||||
WRITE ${_res_file}
|
||||
"<!DOCTYPE RCC><RCC version=\\"1.0\\">\\n <qresource prefix=\\"/PLGLANG/${target}\\">\\n"
|
||||
)
|
||||
foreach(_lang ${_qm_files})
|
||||
get_filename_component(_filename ${_lang} NAME)
|
||||
file(APPEND ${_res_file} " <file>${_filename}</file>\\n")
|
||||
endforeach()
|
||||
file(APPEND ${_res_file} " </qresource>\\n</RCC>\\n")
|
||||
|
||||
set(${res_file}
|
||||
${_res_file}
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
add_custom_target(
|
||||
lupdate
|
||||
COMMAND ${Qt${QT_VERSION_MAJOR}_LUPDATE_EXECUTABLE} -recursive
|
||||
${PROJECT_SOURCE_DIR} -ts *.ts
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Updating translations")
|
|
@ -0,0 +1,80 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
*.deb
|
||||
*.rpm
|
||||
RC*
|
||||
!app.rc
|
||||
!favicon.rc
|
||||
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
build/
|
||||
*.pro.user*
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
#VSCode
|
||||
.vscode/
|
|
@ -0,0 +1,30 @@
|
|||
%{Cpp:LicenseTemplate}\
|
||||
#include "%{JS: Util.relativeFilePath('%{Path}/%{HdrFileName}', '%{Path}' + '/' + Util.path('%{SrcFileName}'))}"
|
||||
|
||||
%{CN}::%{CN}() : WingHex::IWingPlugin(){
|
||||
}
|
||||
|
||||
%{CN}::~%{CN}() {}
|
||||
|
||||
int %{CN}::sdkVersion() const { return WingHex::SDKVERSION; }
|
||||
|
||||
const QString %{CN}::signature() const { return WingHex::WINGSUMMER; }
|
||||
|
||||
bool %{CN}::init(const std::unique_ptr<QSettings> &set) {
|
||||
// Your codes there
|
||||
return true;
|
||||
}
|
||||
|
||||
void %{CN}::unload(std::unique_ptr<QSettings> &set) {
|
||||
// Your unloading codes here
|
||||
}
|
||||
|
||||
const QString %{CN}::pluginName() const { return tr("%{CN}"); }
|
||||
|
||||
const QString %{CN}::pluginAuthor() const { return WingHex::WINGSUMMER; }
|
||||
|
||||
uint %{CN}::pluginVersion() const { return %{PluginVersion}; }
|
||||
|
||||
const QString %{CN}::pluginComment() const {
|
||||
return tr("%{Description}%");
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
%{Cpp:LicenseTemplate}\
|
||||
@if '%{Cpp:PragmaOnce}'
|
||||
#pragma once
|
||||
@else
|
||||
#ifndef %{GUARD}
|
||||
#define %{GUARD}
|
||||
@endif
|
||||
|
||||
#include "iwingplugin.h"
|
||||
|
||||
class %{CN} final : public WingHex::IWingPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "com.wingsummer.iwingplugin" FILE "%{PluginJsonFile}")
|
||||
Q_INTERFACES(WingHex::IWingPlugin)
|
||||
|
||||
public:
|
||||
explicit %{CN}();
|
||||
virtual ~%{CN}();
|
||||
|
||||
// If you are writing codes with QtCreator,
|
||||
// you can press Alt+Enter in a empty line or line with spaces only to
|
||||
// trigger "Insert Virtual Functions of Base Classes" to select optional
|
||||
// virtual functions you want to implement.
|
||||
|
||||
public:
|
||||
virtual int sdkVersion() const override;
|
||||
virtual const QString signature() const override;
|
||||
virtual bool init(const std::unique_ptr<QSettings> &set) override;
|
||||
virtual void unload(std::unique_ptr<QSettings> &set) override;
|
||||
virtual const QString pluginName() const override;
|
||||
virtual const QString pluginAuthor() const override;
|
||||
virtual uint pluginVersion() const override;
|
||||
virtual const QString pluginComment() const override;
|
||||
|
||||
private:
|
||||
// Your private members
|
||||
};
|
||||
|
||||
@if ! '%{Cpp:PragmaOnce}'
|
||||
#endif // %{GUARD}
|
||||
@endif
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
|
@ -0,0 +1,216 @@
|
|||
{
|
||||
"version": 1,
|
||||
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject" ],
|
||||
"id": "H.WingHex2Plugin",
|
||||
"category": "G.Library",
|
||||
"trDescription": "Creates a plugin for WingHexExplorer2.",
|
||||
"trDisplayName": "WingHexExplorer2 Plugin",
|
||||
"trDisplayCategory": "Library",
|
||||
"icon": "winghexplugin.png",
|
||||
"iconKind": "Themed",
|
||||
"enabled": "%{JS: value('Plugins').indexOf('CppEditor') >= 0 && value('Plugins').indexOf('CMakeProjectManager') >= 0 }",
|
||||
|
||||
"options":
|
||||
[
|
||||
{ "key": "WingHexSDKPath", "value": "%{SDKPath}" },
|
||||
{ "key": "WingHexEXEPath", "value": "%{WingHexPath}" },
|
||||
{ "key": "ProjectFile", "value": "%{JS: value('CMakeFile') }" },
|
||||
{ "key": "PluginNameLower", "value": "%{JS: value('PluginName').toLowerCase()}"},
|
||||
{ "key": "PluginJsonFile", "value": "%{JS: Util.fileName(value('PluginName'), 'json.in')}" },
|
||||
{ "key": "CMakeFile", "value": "%{ProjectDirectory}/CMakeLists.txt" },
|
||||
{ "key": "PluginJsonFile", "value": "%{JS: Util.fileName(value('ProjectName'), 'json')}" },
|
||||
{ "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": "BaseClassName", "value": "%{JS: value('BaseClassInfo').BaseClassName }" },
|
||||
{ "key": "CN", "value": "%{JS: Cpp.className(value('PluginName'))}" },
|
||||
{ "key": "GUARD", "value": "%{JS: Cpp.headerGuard(value('HdrFileName'))}" },
|
||||
{ "key": "HasTranslation", "value": "%{JS: value('TsFileName') !== ''}" }
|
||||
],
|
||||
|
||||
"pages":
|
||||
[
|
||||
{
|
||||
"trDisplayName": "Project Location",
|
||||
"trShortTitle": "Location",
|
||||
"typeId": "Project",
|
||||
"data": { "trDescription": "This wizard creates a plugin for WingHexExplorer2." }
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Define Project Details",
|
||||
"trShortTitle": "Details",
|
||||
"typeId": "Fields",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"name": "ClassPageDescription",
|
||||
"type": "Label",
|
||||
"data":
|
||||
{
|
||||
"trText": "Specify details about your WingHexExplorer2 plugin.",
|
||||
"wordWrap": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "PluginName",
|
||||
"trDisplayName": "Plugin name:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"validator": "[a-zA-Z_][a-zA-Z_0-9]*",
|
||||
"text": "%{JS: value('ProjectName').charAt(0).toUpperCase() + value('ProjectName').slice(1)}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "PluginVersion",
|
||||
"trDisplayName": "Plugin version:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"validator": "^[1-9][0-9]*$",
|
||||
"text": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "VendorName",
|
||||
"persistenceKey": "VendorName",
|
||||
"trDisplayName": "Vendor name:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "MyCompany"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Copyright",
|
||||
"trDisplayName": "Copyright:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "(C) %{VendorName}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "License",
|
||||
"trDisplayName": "License:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "Put short license information here"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Description",
|
||||
"trDisplayName": "Description:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"trText": "Put a short description of your plugin here"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Url",
|
||||
"persistenceKey": "VendorUrl",
|
||||
"trDisplayName": "URL:",
|
||||
"mandatory": true,
|
||||
"type": "LineEdit",
|
||||
"data":
|
||||
{
|
||||
"text": "https://www.%{JS: encodeURIComponent(value('VendorName').toLowerCase())}.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SDKPath",
|
||||
"persistenceKey": "SDKPath",
|
||||
"trDisplayName": "SDK Path:",
|
||||
"mandatory": true,
|
||||
"type": "PathChooser",
|
||||
"data":
|
||||
{
|
||||
"kind": "existingDirectory"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "WingHexPath",
|
||||
"persistenceKey": "WingHexPath",
|
||||
"type": "PathChooser",
|
||||
"trDisplayName": "WingHexExplorer2 Installation:",
|
||||
"mandatory": true,
|
||||
"data":
|
||||
{
|
||||
"kind": "existingDirectory"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Translation File",
|
||||
"trShortTitle": "Translation",
|
||||
"data": { "enabled": "yes" },
|
||||
"typeId": "QtTranslation"
|
||||
},
|
||||
{
|
||||
"trDisplayName": "Kit Selection",
|
||||
"trShortTitle": "Kits",
|
||||
"typeId": "Kits",
|
||||
"data": { "projectFilePath": "%{ProjectFile}" }
|
||||
},
|
||||
|
||||
{
|
||||
"trDisplayName": "Project Management",
|
||||
"trShortTitle": "Summary",
|
||||
"typeId": "Summary"
|
||||
}
|
||||
],
|
||||
"generators":
|
||||
[
|
||||
{
|
||||
"typeId": "File",
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"source": "CMakeLists.txt",
|
||||
"openAsProject": true
|
||||
},
|
||||
{
|
||||
"source": "lib.cpp",
|
||||
"target": "%{SrcFileName}",
|
||||
"openInEditor": true
|
||||
},
|
||||
{
|
||||
"source": "lib.h",
|
||||
"target": "%{HdrFileName}"
|
||||
},
|
||||
{
|
||||
"source": "cmake/TranslationUtils.cmake",
|
||||
"target": "cmake/TranslationUtils.cmake"
|
||||
},
|
||||
{
|
||||
"source": "cmake/LICENSE.txt",
|
||||
"target": "cmake/LICENSE.txt"
|
||||
},
|
||||
{
|
||||
"source": "MyPlugin.json.in",
|
||||
"target": "%{PluginJsonFile}"
|
||||
},
|
||||
{
|
||||
"source": "git.ignore",
|
||||
"target": ".gitignore"
|
||||
},
|
||||
{
|
||||
"source": ".clang-format",
|
||||
"target": ".clang-format"
|
||||
},
|
||||
{
|
||||
"source": ".cmake-format.py",
|
||||
"target": ".cmake-format.py"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue