diff --git a/.gitignore b/.gitignore index f44c79a..5af6af5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ *.user *.userosscache *.sln.docstates - +build # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/CMakeLists.txt b/CMakeLists.txt index f1d6eea..ec442ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(notepad--) +project(NotePad-- VERSION 1.22.0) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) @@ -7,49 +7,84 @@ set(CMAKE_AUTORCC ON) find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) -# TODO: use system provided libraries to build -# current status: some header can not be found,for example: Scintilla.h -find_library(QSCINTILLA_LIB_PATH qscintilla2_qt5) -find_path(QSCINTILLA_INC_PATH qsciscintilla.h PATHS /usr/include/) -find_path(SCINTILLA_INC_PATH Scintilla.h PATHS /usr/include/) -if((${QSCINTILLA_LIB_PATH} STREQUAL "QSCINTILLA_LIB_PATH-NOTFOUND") OR - (${QSCINTILLA_INC_PATH} STREQUAL "QSCINTILLA_INC_PATH-NOTFOUND") OR - (${SCINTILLA_INC_PATH} STREQUAL "SCINTILLA_INC_PATH-NOTFOUND") ) -set(NOTEPAD_USE_SYS_LIB OFF) -message("system libraries or header not found,build from local") +# qscint 关键依赖库 add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) -else() -set(NOTEPAD_USE_SYS_LIB ON) -message("use system libraries") -message("QSCINTILLA_LIB_PATH:" ${QSCINTILLA_LIB_PATH}) -message("QSCINTILLA_INC_PATH:" ${QSCINTILLA_INC_PATH}) -message("SCINTILLA_INC_PATH:" ${SCINTILLA_INC_PATH}) + +# 插件库包含 +# helloworld 动态插件库 +add_subdirectory(${PROJECT_SOURCE_DIR}/src/plugin/helloworld) + +# win下需要开启UNICODE进行支持TCHAR +if(CMAKE_HOST_WIN32) + add_definitions(-D_UNICODE -DUNICODE) endif() + +if(${PLUGIN_EN}) + if(${PLUGIN_EN} STREQUAL on) + add_definitions(-DNO_PLUGIN=1) + endif(${PLUGIN_EN}) +endif() + + + file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui) set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui) aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC) aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC) -add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) -target_include_directories(${PROJECT_NAME} PRIVATE -${PROJECT_SOURCE_DIR}/src -${PROJECT_SOURCE_DIR}/src/cceditor -) -if(NOTEPAD_USE_SYS_LIB) -target_include_directories(${PROJECT_NAME} PRIVATE ${QSCINTILLA_INC_PATH} ${SCINTILLA_INC_PATH}) +if(CMAKE_HOST_WIN32) +# 添加 WIN32 保证主程序启动没有命令行 + list(APPEND WIN_RCS ${PROJECT_SOURCE_DIR}/src/RealCompareToMinGw.rc) + add_executable(${PROJECT_NAME} WIN32 ${WIN_RCS} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) +else() + add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) endif() -target_link_libraries(${PROJECT_NAME} qscintilla2_qt5 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) +target_include_directories(${PROJECT_NAME} PRIVATE +${PROJECT_SOURCE_DIR}/src +${PROJECT_SOURCE_DIR}/src/cceditor -install( - TARGETS ${PROJECT_NAME} - DESTINATION "bin" +${PROJECT_SOURCE_DIR}/src/qscint/src +${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib +${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex ) -install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr - DESTINATION "/") +target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) -include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake) -include(CPack) +# set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin") +# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +if(CMAKE_HOST_UNIX) + install( + TARGETS ${PROJECT_NAME} + DESTINATION "bin" + ) + + install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr + DESTINATION "/") + + include(${PROJECT_SOURCE_DIR}/cmake/deb_package_config.cmake) + include(CPack) +elseif(CMAKE_HOST_WIN32) + install(TARGETS ${PROJECT_NAME} + DESTINATION "/") + + install(DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin/ + DESTINATION "/") + # 设置软件版本 + set(CPACK_PACKAGE_NAME "NotePad--") + set(CPACK_PACKAGE_DESCRIPTION "NotePad--") + set(CPACK_PACKAGE_COPYRIGHT "Copyright (c) 2023") + set(CPACK_PACKAGE_VERSION "1.22.0") + set(CPACK_PACKAGE_VERSION_MAJOR "1") + set(CPACK_PACKAGE_VERSION_MINOR "22") + set(CPACK_PACKAGE_VERSION_PATCH "0") + + include(${PROJECT_SOURCE_DIR}/cmake/nsis_package_config.cmake) + include(CPack) +endif() diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2db5182 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +UNAME:=WIN32 +UNAME:=$(shell uname) + +# Win下使用Git Bash运行make + +ifeq ($(UNAME), Linux) +all:linux +linux: + make -f linux.mk package +else +all: + make -f win.mk all +msvc: + make -f win.mk msvc +mingw: + make -f win.mk mingw +endif diff --git a/README.md b/README.md old mode 100755 new mode 100644 index 2d8f18f..8fc4aa3 --- a/README.md +++ b/README.md @@ -41,11 +41,14 @@ NDD已初步推出插件编写功能,希望广大的CPP/QT开发者加入我 - ArchLinux -1. 安装编译环境 `sudo pacman -S gcc cmake make ` -1. 安装qt工具和库 `sudo pacman -S qt5-tools qt5-base qt5-xmlpatterns ` -1. 配置 `cmake -B build -DCMAKE_BUILD_TYPE=Release` -1. 编译 `cd build && make -j` -1. 打包:使用aur +1. 安装编译环境 `sudo pacman -S gcc cmake make ninja` +1. 安装 qt 工具和库 `sudo pacman -S qt5-tools qt5-base qt5-xmlpatterns` +1. 配置 `cmake -S . -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -W no-dev` +1. 编译 `ninja -C build && ninja -C build install` +1. 打包: 使用 [AUR/notepad---git](https://aur.archlinux.org/packages/notepad---git) `yay -S notepad---git` +1. 安装: + - 预编译包添加 [ArchLinuxCN/notepad---git](https://github.com/archlinuxcn/repo) 镜像 `yay -S archlinuxcn/notepad---git` + - 预编译包 [Debuginfod/notepad---git-debug](https://wiki.archlinux.org/title/Debuginfod) 包 `yay -S archlinuxcn/notepad---git-debug` - openSUSE Tumbleweed @@ -68,6 +71,11 @@ NDD已初步推出插件编写功能,希望广大的CPP/QT开发者加入我 ``` yay -S notepad---git ``` +## 联络方式 + +QQ群:959439826 用户群,做NDD的问题反馈、功能建议等。 + +QQ群 616606091 开发群,建议懂CPP/QT、愿意参与NDD项目代码贡献的开发人士加入。 ## 效果预览 diff --git a/README_EN.md b/README_EN.md index b9d4b24..537d025 100644 --- a/README_EN.md +++ b/README_EN.md @@ -34,11 +34,14 @@ Creating a free text editor requires support from users like you. If you'd like - ArchLinux -1. Install compilation environment `sudo pacman -S gcc cmake make ` +1. Install compilation environment `sudo pacman -S gcc cmake make ninja` 1. Install qt tools and libraries `sudo pacman -S qt5-tools qt5-base qt5-xmlpatterns ` -1. Configure `cmake -B build -DCMAKE_BUILD_TYPE=Release` -1. Compile `cd build && make -j` -1. Package: use aur +1. Configure `cmake -S . -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -W no-dev` +1. Compile `ninja -C build && ninja -C build install` +1. Package: use [AUR/notepad---git](https://aur.archlinux.org/packages/notepad---git) `yay -S notepad---git` +1. Installation: + - Pre-compiled package add [ArchLinuxCN/notepad---git](https://github.com/archlinuxcn/repo) mirror `yay -S archlinuxcn/notepad---git` + - Pre-compiled package [Debuginfod/notepad---git-debug](https://wiki.archlinux.org/title/Debuginfod) package `yay -S archlinuxcn/notepad---git-debug` **Qt Project Compilation Instructions:** @@ -63,4 +66,4 @@ yay -S notepad---git ![Input description picture](png/3.png) -![Input description picture](png/7.png) \ No newline at end of file +![Input description picture](png/7.png) diff --git a/cmake/package_config.cmake b/cmake/deb_package_config.cmake similarity index 100% rename from cmake/package_config.cmake rename to cmake/deb_package_config.cmake diff --git a/cmake/nsis_package_config.cmake b/cmake/nsis_package_config.cmake new file mode 100644 index 0000000..0098d39 --- /dev/null +++ b/cmake/nsis_package_config.cmake @@ -0,0 +1,59 @@ +set(CPACK_GENERATOR NSIS) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}") +# 维护人员 +set(CPACK_PACKAGE_CONTACT "XiaoPb") + +set(P4_VERSION_INFO_CL_HIGH "0") +set(P4_VERSION_INFO_CL_LOW "0") +# set(CPACK_PACKAGE_VERSION_PATCH "0") + +set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") + +set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") + +set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico") +set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License") + +set (CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}" ) + +# 设置 安装包属性信息 +set (CPACK_NSIS_DEFINES " + ${CPACK_NSIS_DEFINES} + VIProductVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW} + VIFileVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW} + VIAddVersionKey /LANG=0 \\\"ProductName\\\" \\\"${CPACK_PACKAGE_NAME}\\\" + VIAddVersionKey /LANG=0 \\\"ProductVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\" + VIAddVersionKey /LANG=0 \\\"Comments\\\" \\\"${CPACK_PACKAGE_DESCRIPTION}\\\" + VIAddVersionKey /LANG=0 \\\"CompanyName\\\" \\\"${CPACK_PACKAGE_VENDOR}\\\" + VIAddVersionKey /LANG=0 \\\"LegalCopyright\\\" \\\"${CPACK_PACKAGE_COPYRIGHT}\\\" + VIAddVersionKey /LANG=0 \\\"FileDescription\\\" \\\"${CPACK_PACKAGE_NAME} Installer\\\" + VIAddVersionKey /LANG=0 \\\"FileVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\" + " +) + +# 设置 安装时需要的环境变量 +set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + WriteRegStr SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\" \\\"\\\" \\\"open\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\\open\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" \\\"\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"Edit with ${PROJECT_NAME}\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"Icon\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\" + ") + +# 设置 卸载时需要的环境变量 +set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " + Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\" + Delete \\\"$SMPROGRAMS\\\\${PROJECT_NAME}.lnk\\\" + DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" + DeleteRegKey SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\bin\\\\${PROJECT_NAME}.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\" + DeleteRegKey SHCTX \\\"Software\\\\${PROJECT_NAME}\\\" + DeleteRegValue SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" + DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\" + ") diff --git a/linux.mk b/linux.mk new file mode 100644 index 0000000..43f4a79 --- /dev/null +++ b/linux.mk @@ -0,0 +1,42 @@ +CPUS=$(shell nproc) +CALENDAR=$(shell date '+%Y%m%d') +OSID=$(shell lsb_release -si) +OSRELEASE=$(shell lsb_release -sr) +SUFFIX= +ifneq ("$(OSID)", "") +SUFFIX=_$(OSID)$(OSRELEASE) +endif + +PROJECT_NAME=notepad-- +PACKAGE_NAME=com.hmja.notepad + +all: + mkdir -p build + cd build && cmake .. + cd build && make -j$(CPUS) + +run: all + exec $(shell find build/ -maxdepth 1 -type f -executable | grep $(PROJECT_NAME)) + +debug: + mkdir -p build + cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. + cd build && make -j$(CPUS) + +release: + mkdir -p build + cd build && cmake -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=off -DPACKAGE_SUFFIX="$(SUFFIX)" .. + cd build && make -j$(CPUS) + +package: release + cd build && make package + tree build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)-* +# dpkg-deb --contents build/$(PROJECT_NAME)$(SUFFIX).deb + +builddeps: + cd build && make builddeps + +cpus: + @echo "CPU数量: $(CPUS)" + + diff --git a/src/RealCompare.rc b/src/RealCompare.rc index 6a8f8d3..55fa7fd 100755 Binary files a/src/RealCompare.rc and b/src/RealCompare.rc differ diff --git a/src/RealCompareToMinGw.rc b/src/RealCompareToMinGw.rc new file mode 100644 index 0000000..26799a9 --- /dev/null +++ b/src/RealCompareToMinGw.rc @@ -0,0 +1,38 @@ +#include + +IDI_ICON1 ICON DISCARDABLE ".\\Resources\\edit\\global\\ndd.ico" + +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,22,0,0 + PRODUCTVERSION 1,22,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080404b0" + BEGIN + VALUE "FileDescription", "notepad-- v1.22.0\0" + VALUE "FileVersion", "1.22.0.0\0" + VALUE "LegalCopyright", "Copyright (C) 2020-2023\0" + VALUE "OriginalFilename", "Notepad--.exe\0" + VALUE "ProductName", "notepad-- \0" + VALUE "ProductVersion", "1.22.0.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0804, 1200 + END + END +/* End of Version info */ + diff --git a/src/cceditor/ccnotepad.ui b/src/cceditor/ccnotepad.ui index 2062894..d20e1b8 100755 --- a/src/cceditor/ccnotepad.ui +++ b/src/cceditor/ccnotepad.ui @@ -87,7 +87,7 @@ Qt::LeftToRight - File(&F) + &File @@ -103,7 +103,7 @@ Qt::LeftToRight - Edit(&E) + &Edit @@ -180,7 +180,7 @@ - Search(&S) + &Search @@ -204,7 +204,7 @@ - View(&V) + &View @@ -232,7 +232,7 @@ - Encoding(&N) + E&ncoding @@ -263,7 +263,7 @@ - Language(&L) + &Language @@ -466,7 +466,7 @@ - Set(&T) + Se&t @@ -495,7 +495,7 @@ - Tools(&O) + T&ools diff --git a/src/columnedit.cpp b/src/columnedit.cpp index 50fd9ae..3fae34a 100755 --- a/src/columnedit.cpp +++ b/src/columnedit.cpp @@ -216,13 +216,13 @@ void ColumnEdit::slot_ok() { QByteArray s_space(cursorCol - lineEndCol, ' '); lineData.append(s_space); - lineData.append(text); + lineData.append(text.toUtf8()); } else { int posAbs2Start = pEdit->execute(SCI_FINDCOLUMN, i, cursorCol); int posRelative2Start = posAbs2Start - lineBegin; - lineData.insert(posRelative2Start, text); + lineData.insert(posRelative2Start, text.toUtf8()); } pEdit->SendScintilla(SCI_SETTARGETRANGE, lineBegin, lineEnd); diff --git a/src/ctipwin.cpp b/src/ctipwin.cpp index 9412777..f894ad8 100755 --- a/src/ctipwin.cpp +++ b/src/ctipwin.cpp @@ -9,7 +9,7 @@ CTipWin::CTipWin(QWidget *parent) this->setWindowFlags(Qt::ToolTip); QPalette palette(this->palette()); - palette.setColor(QPalette::Background, QColor(0xfff29d)); + palette.setColor(QPalette::Window, QColor(0xfff29d)); this->setPalette(palette); } diff --git a/src/include/pluginGl.h b/src/include/pluginGl.h index 069f6c2..135babf 100755 --- a/src/include/pluginGl.h +++ b/src/include/pluginGl.h @@ -4,11 +4,13 @@ #define NDD_EXPORTDLL #if defined(Q_OS_WIN) -#if defined(NDD_EXPORTDLL) -#define NDD_EXPORT __declspec(dllexport) + #if defined(NDD_EXPORTDLL) + #define NDD_EXPORT __declspec(dllexport) + #else + #define NDD_EXPORT __declspec(dllimport) + #endif #else -#define NDD_EXPORT __declspec(dllimport) -#endif + #define NDD_EXPORT __attribute__((visibility("default"))) #endif struct ndd_proc_data diff --git a/src/plugin/helloworld/CMakeLists.txt b/src/plugin/helloworld/CMakeLists.txt new file mode 100644 index 0000000..f4acbcd --- /dev/null +++ b/src/plugin/helloworld/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.16) +project(helloworld) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) + +find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) + +add_definitions(-D_UNICODE -DUNICODE) + + + + +file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/*.ui) +file(GLOB SRC ${PROJECT_SOURCE_DIR}/*.cpp) +file(GLOB MOC_HEADER ${PROJECT_SOURCE_DIR}/*.h) +# add_executable(${PROJECT_NAME} ${IS_WIN} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc) + +add_library(${PROJECT_NAME} SHARED ${SRC} ${UI_SRC} ${MOC_HEADER}) + +target_include_directories(${PROJECT_NAME} PRIVATE +${PROJECT_SOURCE_DIR} + +${PROJECT_SOURCE_DIR}/../../include +${PROJECT_SOURCE_DIR}/../../qscint/src +${PROJECT_SOURCE_DIR}/../../qscint/src/Qsci +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/src +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/include +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/lexlib +${PROJECT_SOURCE_DIR}/../../qscint/scintilla/boostregex +) + +target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) + +# if(NOT DEFINED ${notepad--_BINARY_DIR}) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(LIBRARY_OUTPUT_PATH ${notepad--_BINARY_DIR}/bin/plugin) +# set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# endif() diff --git a/src/plugin/helloworld/helloworld.pro b/src/plugin/helloworld/helloworld.pro index 0e791d2..ec08b04 100755 --- a/src/plugin/helloworld/helloworld.pro +++ b/src/plugin/helloworld/helloworld.pro @@ -1,7 +1,7 @@ TEMPLATE = lib LANGUAGE = C++ -CONFIG += qt warn_on Debug +CONFIG += qt warn_on QT += core gui widgets HEADERS += *.h diff --git a/src/plugin/helloworld/helloworldexport.cpp b/src/plugin/helloworld/helloworldexport.cpp index 84c3f49..aba2a40 100755 --- a/src/plugin/helloworld/helloworldexport.cpp +++ b/src/plugin/helloworld/helloworldexport.cpp @@ -8,11 +8,13 @@ #define NDD_EXPORTDLL #if defined(Q_OS_WIN) -#if defined(NDD_EXPORTDLL) -#define NDD_EXPORT __declspec(dllexport) + #if defined(NDD_EXPORTDLL) + #define NDD_EXPORT __declspec(dllexport) + #else + #define NDD_EXPORT __declspec(dllimport) + #endif #else -#define NDD_EXPORT __declspec(dllimport) -#endif + #define NDD_EXPORT __attribute__((visibility("default"))) #endif #ifdef __cplusplus diff --git a/src/plugin/test/test.cpp b/src/plugin/test/test.cpp index bd11bb4..c2ccca1 100755 --- a/src/plugin/test/test.cpp +++ b/src/plugin/test/test.cpp @@ -7,11 +7,13 @@ #define NDD_EXPORTDLL #if defined(Q_OS_WIN) -#if defined(NDD_EXPORTDLL) -#define NDD_EXPORT __declspec(dllexport) + #if defined(NDD_EXPORTDLL) + #define NDD_EXPORT __declspec(dllexport) + #else + #define NDD_EXPORT __declspec(dllimport) + #endif #else -#define NDD_EXPORT __declspec(dllimport) -#endif + #define NDD_EXPORT __attribute__((visibility("default"))) #endif #ifdef __cplusplus diff --git a/src/plugin/test/test.pro b/src/plugin/test/test.pro index 4a8ea94..9a9492b 100755 --- a/src/plugin/test/test.pro +++ b/src/plugin/test/test.pro @@ -1,7 +1,7 @@ TEMPLATE = lib LANGUAGE = C++ -CONFIG += qt warn_on Debug +CONFIG += qt warn_on QT += core gui widgets HEADERS += *.h diff --git a/src/qscint/CMakeLists.txt b/src/qscint/CMakeLists.txt index b114614..b213b21 100644 --- a/src/qscint/CMakeLists.txt +++ b/src/qscint/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(qscintilla2_qt5 CXX) +project(qscint CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) @@ -19,6 +19,9 @@ file(GLOB MOC_HEADER ${PROJECT_SOURCE_DIR}/src/Qsci/*.h) add_library(${PROJECT_NAME} STATIC ${SRC} ${MOC_HEADER}) +# add_definitions(-DQSCINTILLA_MAKE_DLL) +# add_library(${PROJECT_NAME} SHARED ${SRC} ${MOC_HEADER}) + target_compile_definitions(${PROJECT_NAME} PRIVATE SCINTILLA_QT SCI_LEXER INCLUDE_DEPRECATED_FEATURES) target_include_directories(${PROJECT_NAME} PRIVATE @@ -28,8 +31,24 @@ ${PROJECT_SOURCE_DIR}/scintilla/boostregex target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/src -${PROJECT_SOURCE_DIR}/src/Qsci +${PROJECT_SOURCE_DIR}/src/Qsci ${PROJECT_SOURCE_DIR}/scintilla/src ${PROJECT_SOURCE_DIR}/scintilla/include) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport) + +if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5") +else() + set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5d") +endif() + + + +# if(NOT DEFINED ${notepad--_BINARY_DIR}) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# set(LIBRARY_OUTPUT_PATH ${notepad--_BINARY_DIR}/bin/plugin) +# set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin) +# endif() diff --git a/win.bat b/win.bat new file mode 100644 index 0000000..f2d9d63 --- /dev/null +++ b/win.bat @@ -0,0 +1,5 @@ +cd build/bin + +windeployqt notepad--.exe +@REM copy .\src\qscint\libqscint.a .\%1\plugin +@REM copy .\src\plugin\^*\^*.dll .\%1\plugin diff --git a/win.mk b/win.mk new file mode 100644 index 0000000..7ac2002 --- /dev/null +++ b/win.mk @@ -0,0 +1,42 @@ + +# 基于 Git Bash 环境编写 +# 设置编译链信息是为了避免环境存在多个Qt环境时编译异常 + +# 填入Qt的Mingw相关工具安装路径 (不使用MINGW时可不填) +# 填入Mingw Qt G++程序完整路径 +Qt_MINGW_CXX_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/g++.exe +# 填入Mingw Qt GCC程序完整路径 +Qt_MINGW_C_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/gcc.exe +# 填入Mingw Qt库查找路径 +Qt_MINGW_PREFIX_PATH:=d:/SOFT/Qt/Qt5.14.2/5.14.2/mingw73_64 +# 指定生成的Makefiles格式 +Qt_MINGW_G:=CodeBlocks - MinGW Makefiles + +# 填入Qt的msvc相关工具安装路径 (不使用MSVC时可不填) +# 填入Msvc Qt库查找路径 +Qt_MSVC_PREFIX_PATH:=d:/CompilationTools/Qt/5.15.2/msvc2019_64 + + +all:msvc + + +mingw: + cmake -G"${Qt_MINGW_G}" -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MINGW_PREFIX_PATH} -DCMAKE_CXX_COMPILER=${Qt_MINGW_CXX_COMPILER} -DCMAKE_C_COMPILER=${Qt_MINGW_C_COMPILER} . + cmake --build ./build --config=Release -- -j$$(nproc) + mkdir -p build/bin/plugin + cp -f build/NotePad--.exe build/bin/ + cd build/bin && windeployqt --qmldir=${Qt_MINGW_PREFIX_PATH}/qml NotePad--.exe + cp -r -f build/src/*/*/*.dll build/bin/plugin + cp -r -f build/src/*/*.a build/bin/plugin + cd build && cpack --config CPackConfig.cmake + +msvc: + cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} . + cmake --build ./build --config=Release -j$$(nproc) + mkdir -p build/bin/plugin + cp -f build/Release/NotePad--.exe build/bin/ + cd build/bin && windeployqt --qmldir=${Qt_MSVC_PREFIX_PATH}/qml NotePad--.exe + cp -r -f build/src/*/*/Release/*.dll build/bin/plugin + cp -r -f build/src/*/Release/*.lib build/bin/plugin + cd build && cpack --config CPackConfig.cmake +