mirror of https://gitee.com/cxasm/notepad--.git
src/plugins: 移除不再使用的早期构建,全面转向框架构建
This commit is contained in:
parent
0292adb402
commit
0f1fdf51d7
|
@ -5,24 +5,34 @@ option(USE_NOTEPAD_PLUGIN_BASE "构建 Notepad-- 内部的插件基础模板" OF
|
|||
|
||||
if(USE_NOTEPAD_PLUGIN)
|
||||
|
||||
if(USE_NOTEPAD_PLUGIN_BASE) # 早期构建,准备废弃
|
||||
# 默认的测试插件
|
||||
add_subdirectory(test)
|
||||
# 被 cmake-plugins-dev 构建的 helloworld 插件
|
||||
add_subdirectory(helloworld-next)
|
||||
# 基于源代码构建的系列插件模板
|
||||
add_subdirectory(template-plugins/base-plugin)
|
||||
add_subdirectory(template-plugins/base-widget-plugin)
|
||||
add_subdirectory(template-plugins/base-widget-ui-plugin)
|
||||
add_subdirectory(template-plugins/base-secondary-menu-plugin)
|
||||
add_subdirectory(template-plugins/base-secondary-menu-plugin-v1)
|
||||
add_subdirectory(template-plugins/base-secondary-menu-ui-plugin-v1)
|
||||
endif(USE_NOTEPAD_PLUGIN_BASE)
|
||||
|
||||
# [核心]:[引入插件框架核心模块]
|
||||
include(framework/framework.cmake)
|
||||
include(framework/framework-include.cmake)
|
||||
|
||||
|
||||
if(USE_NOTEPAD_PLUGIN_BASE) # 早期构建,准备废弃
|
||||
# 默认的测试插件
|
||||
add_subdirectory(test)
|
||||
|
||||
# 被 cmake-plugins-dev 构建的
|
||||
# 基于源代码构建的系列插件模板
|
||||
set(base-plugin_ENABLE ON)
|
||||
add_framework_plugin(base-plugin
|
||||
template-plugins/base-plugin)
|
||||
set(base-secondary-plugin_ENABLE ON)
|
||||
add_framework_plugin(base-secondary-plugin
|
||||
template-plugins/base-secondary-plugin
|
||||
)
|
||||
set(base-secondary-widget-plugin_ENABLE ON)
|
||||
add_framework_plugin(base-secondary-widget-plugin
|
||||
template-plugins/base-secondary-widget-plugin
|
||||
)
|
||||
# add_subdirectory(template-plugins/base-widget-plugin)
|
||||
# add_subdirectory(template-plugins/base-widget-ui-plugin)
|
||||
# add_subdirectory(template-plugins/base-secondary-menu-plugin)
|
||||
# add_subdirectory(template-plugins/base-secondary-menu-plugin-v1)
|
||||
# add_subdirectory(template-plugins/base-secondary-menu-ui-plugin-v1)
|
||||
endif(USE_NOTEPAD_PLUGIN_BASE)
|
||||
|
||||
# [开发者计划]:不改变本 CMakeLists.txt 的情况下开发自己的插件
|
||||
# 非冲突化开发方式,在 dev.cmake 中建立自己的本地引用或在线引用来构建自己的插件。
|
||||
# 并将其作为开发者计划的关注位置点,以此保证本 CMakeLists.txt 可以直接随项目更新
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
# helloworld-next/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 helloworld-next 为你的插件名称
|
||||
# helloworld-next -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "helloworld-next")
|
||||
|
||||
# helloworld-next 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 helloworld-next 插件
|
||||
# 1. 默认构建时产出的目标为 helloworld-next
|
||||
# 2. 在此处可对 helloworld-next 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 helloworld-next 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- helloworld-next 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
|
@ -1,87 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "qttestclass.h"
|
||||
|
||||
#define NDD_EXPORTDLL
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#if defined(NDD_EXPORTDLL)
|
||||
#define NDD_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define NDD_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define NDD_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
NDD_EXPORT bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData);
|
||||
NDD_EXPORT int NDD_PROC_MAIN(QWidget* pNotepad, const QString& strFileName, std::function<QsciScintilla* ()>getCurEdit, NDD_PROC_DATA* procData);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static NDD_PROC_DATA s_procData;
|
||||
static QWidget* s_pMainNotepad = nullptr;
|
||||
std::function<QsciScintilla* ()> s_getCurEdit;
|
||||
|
||||
bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData)
|
||||
{
|
||||
if(pProcData == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pProcData->m_strPlugName = QObject::tr("Hello World Plug");
|
||||
pProcData->m_strComment = QObject::tr("char to Upper.");
|
||||
|
||||
pProcData->m_version = QString("v1.0");
|
||||
pProcData->m_auther = QString("zuowei.yin");
|
||||
|
||||
pProcData->m_menuType = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//则点击菜单栏按钮时,会自动调用到该插件的入口点函数。
|
||||
//pNotepad:就是CCNotepad的主界面指针
|
||||
//strFileName:当前插件DLL的全路径,如果不关心,则可以不使用
|
||||
//getCurEdit:从NDD主程序传递过来的仿函数,通过该函数获取当前编辑框操作对象QsciScintilla
|
||||
//pProcData:如果pProcData->m_menuType = 0 ,则该指针为空;如果pProcData->m_menuType = 1,则该指针有值。目前需要关心s_procData.m_rootMenu
|
||||
//开发者可以在该菜单下面,自行创建二级菜单
|
||||
int NDD_PROC_MAIN(QWidget* pNotepad, const QString &strFileName, std::function<QsciScintilla*()>getCurEdit, NDD_PROC_DATA* pProcData)
|
||||
{
|
||||
QsciScintilla* pEdit = getCurEdit();
|
||||
if (pEdit == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//务必拷贝一份pProcData,在外面会释放。
|
||||
if (pProcData != nullptr)
|
||||
{
|
||||
s_procData = *pProcData;
|
||||
}
|
||||
|
||||
s_pMainNotepad = pNotepad;
|
||||
s_getCurEdit = getCurEdit;
|
||||
|
||||
//如果pProcData->m_menuType = 1;是自己要创建二级菜单的场景。则通过s_procData.m_rootMenu 获取该插件的菜单根节点。
|
||||
//插件开发者自行在s_procData.m_rootMenu下添加新的二级菜单项目
|
||||
|
||||
|
||||
//做一个简单的转大写的操作
|
||||
QtTestClass* p = new QtTestClass(pNotepad,pEdit);
|
||||
//主窗口关闭时,子窗口也关闭。避免空指针操作
|
||||
p->setWindowFlag(Qt::Window);
|
||||
p->show();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include "qttestclass.h"
|
||||
#include <qsciscintilla.h>
|
||||
|
||||
QtTestClass::QtTestClass(QWidget *parent, QsciScintilla* pEdit)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
m_pEdit = pEdit;
|
||||
}
|
||||
|
||||
QtTestClass::~QtTestClass()
|
||||
{}
|
||||
|
||||
void QtTestClass::on_upper()
|
||||
{
|
||||
QString text = m_pEdit->text();
|
||||
|
||||
text = text.toUpper();
|
||||
|
||||
m_pEdit->setText(text);
|
||||
}
|
||||
|
||||
void QtTestClass::on_lower()
|
||||
{
|
||||
QString text = m_pEdit->text();
|
||||
|
||||
text = text.toLower();
|
||||
|
||||
m_pEdit->setText(text);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_qttestclass.h"
|
||||
|
||||
class QsciScintilla;
|
||||
class QtTestClass : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtTestClass(QWidget *parent, QsciScintilla* pEdit);
|
||||
~QtTestClass();
|
||||
|
||||
private slots:
|
||||
void on_upper();
|
||||
void on_lower();
|
||||
private:
|
||||
Ui::QtTestClassClass ui;
|
||||
QsciScintilla* m_pEdit;
|
||||
};
|
|
@ -1,108 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QtTestClassClass</class>
|
||||
<widget class="QWidget" name="QtTestClassClass">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QtTestClass</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>这是一个插件例子,把当前文档全部变成大写字母。
|
||||
请给我们提交插件!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="upperBt">
|
||||
<property name="text">
|
||||
<string>TransUpper</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="lowerBt">
|
||||
<property name="text">
|
||||
<string>TransLower</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QtTestClassClass</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>435</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>446</x>
|
||||
<y>246</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>upperBt</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QtTestClassClass</receiver>
|
||||
<slot>on_upper()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>177</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>187</x>
|
||||
<y>247</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>lowerBt</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QtTestClassClass</receiver>
|
||||
<slot>on_lower()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>296</x>
|
||||
<y>182</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>323</x>
|
||||
<y>244</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>on_upper()</slot>
|
||||
<slot>on_lower()</slot>
|
||||
</slots>
|
||||
</ui>
|
|
@ -1,82 +0,0 @@
|
|||
# base-plugin/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 base-plugin 为你的插件名称
|
||||
# base-plugin -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "base-plugin")
|
||||
|
||||
# base-plugin 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 base-plugin 插件
|
||||
# 1. 默认构建时产出的目标为 base-plugin
|
||||
# 2. 在此处可对 base-plugin 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 base-plugin 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
# 确保生成到 Notepad-- 的相对 plugin 目录下
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
|
||||
# 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
|
||||
# install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- base-plugin 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
|
@ -0,0 +1,52 @@
|
|||
#include "baseplugin.h"
|
||||
#include "pluginframeworkhelper.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
BasePlugin::BasePlugin(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
BasePlugin &BasePlugin::instance()
|
||||
{
|
||||
static BasePlugin _plugin;
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
QString BasePlugin::PluginName()
|
||||
{
|
||||
return "base-plugin";
|
||||
}
|
||||
|
||||
QString BasePlugin::PluginVersion()
|
||||
{
|
||||
return "v0.1";
|
||||
}
|
||||
|
||||
QString BasePlugin::PluginAuthor()
|
||||
{
|
||||
return "author";
|
||||
}
|
||||
|
||||
QString BasePlugin::PluginComment()
|
||||
{
|
||||
return u8"基本插件 - 由生成器生成";
|
||||
}
|
||||
|
||||
IPluginFramework::MenuType BasePlugin::PluginMenuType()
|
||||
{
|
||||
return MenuType::None;
|
||||
}
|
||||
|
||||
void BasePlugin::PluginTrigger()
|
||||
{
|
||||
QMessageBox::information(nullptr, "tip", "This is default tip message.");
|
||||
}
|
||||
|
||||
void BasePlugin::registerPluginActions(QMenu *rootMenu)
|
||||
{
|
||||
//Actions: Will never enter here.
|
||||
}
|
||||
|
||||
// Plug-in implementation wrapper
|
||||
NDD_DECLARE_PLUGIN(BasePlugin::instance())
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef BASEPLUGIN_H
|
||||
#define BASEPLUGIN_H
|
||||
|
||||
#include <IPluginFramework.h>
|
||||
#include <QObject>
|
||||
|
||||
class BasePlugin : public QObject, public IPluginFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
explicit BasePlugin(QObject *parent = nullptr);
|
||||
public:
|
||||
static BasePlugin &instance();
|
||||
|
||||
|
||||
// IPluginFramework interface
|
||||
public:
|
||||
QString PluginName();
|
||||
QString PluginVersion();
|
||||
QString PluginAuthor();
|
||||
QString PluginComment();
|
||||
MenuType PluginMenuType();
|
||||
void PluginTrigger();
|
||||
void registerPluginActions(QMenu *rootMenu);
|
||||
|
||||
/** 当前版本 IPluginManager 中已经为此实现 - 如需加载时执行自定义代码请重写 registerNotepad 实现.
|
||||
并在其实现内首行调用 IPluginFramework::registerNotepad(notepad);
|
||||
*/
|
||||
// void registerNotepad(QWidget *notepad);
|
||||
// void registerStrFileName(QString str_file_name);
|
||||
// void registerCurrentEditCallback(std::function<QsciScintilla *(QWidget *)> get_cur_edit_callback);
|
||||
// void registerPluginCallBack(std::function<bool (QWidget *, int, void *)> plugin_callback);
|
||||
};
|
||||
|
||||
#endif // BASEPLUGIN_H
|
|
@ -1,6 +0,0 @@
|
|||
#include "ndd_plugin_implement.h"
|
||||
|
||||
NddPluginImplement::NddPluginImplement()
|
||||
{
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef NDD_PLUGIN_IMPLEMENT_H
|
||||
#define NDD_PLUGIN_IMPLEMENT_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class NddPluginImplement
|
||||
{
|
||||
public:
|
||||
NddPluginImplement();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // NDD_PLUGIN_IMPLEMENT_H
|
|
@ -1,29 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <include/pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "ndd_plugin_implement.h"
|
||||
|
||||
|
||||
bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData) {
|
||||
// NOTEPAD_PLUGIN_METADATA
|
||||
// (name, version, author, comment, filepath)
|
||||
// 使用插件宏模板来完成简单的插件处理
|
||||
NOTEPAD_PLUGIN_METADATA("base-plugin", "0.1", "author", "基本插件", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int NDD_PROC_MAIN(QWidget* pNotepad, const QString& strFileName, std::function<QsciScintilla* ()>getCurEdit) {
|
||||
// NOTEPAD_PLUGIN_IMPLEMENT
|
||||
// (NddPluginImplement);
|
||||
// 使用插件宏模板来完成基本的插件内容处理
|
||||
NddPluginImplement *imp = new NddPluginImplement();
|
||||
|
||||
// 这个插件是一个窗口需要显示
|
||||
// imp->show();
|
||||
|
||||
// 插件已成功实现
|
||||
return 0;
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
# base-secondary-menu-plugin-v1/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 base-secondary-menu-plugin-v1 为你的插件名称
|
||||
# base-secondary-menu-plugin-v1 -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "base-secondary-menu-plugin-v1")
|
||||
|
||||
# base-secondary-menu-plugin-v1 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 base-secondary-menu-plugin-v1 插件
|
||||
# 1. 默认构建时产出的目标为 base-secondary-menu-plugin-v1
|
||||
# 2. 在此处可对 base-secondary-menu-plugin-v1 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 base-secondary-menu-plugin-v1 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
# 确保生成到 Notepad-- 的相对 plugin 目录下
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
|
||||
# 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
|
||||
# install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- base-secondary-menu-plugin-v1 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
|
@ -1,56 +0,0 @@
|
|||
#include "ndd_plugin_implement.h"
|
||||
|
||||
#include <qsciscintilla.h>
|
||||
#include <QDebug>
|
||||
|
||||
NddPluginImplement::NddPluginImplement(QWidget *parent, QsciScintilla *pEdit) : QWidget(parent)
|
||||
, currentWidget(parent)
|
||||
, currentEdit(pEdit)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NddPluginImplement::~NddPluginImplement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NddPluginImplement::setMenuActions(QMenu *menu)
|
||||
{
|
||||
QAction *action1 = menu->addAction(u8"第一项打印");
|
||||
connect(action1, &QAction::triggered, this, [](){
|
||||
// 普通的菜单项
|
||||
qDebug() << "action1";
|
||||
});
|
||||
|
||||
QAction *action2 = menu->addAction(u8"第二项打印");
|
||||
connect(action2, &QAction::triggered, this, [](){
|
||||
// 普通的菜单项
|
||||
qDebug() << "action2";
|
||||
});
|
||||
|
||||
QAction *action3 = menu->addAction(u8"打印默认编辑器内容(源代码项注意)");
|
||||
connect(action3, &QAction::triggered, this, [=](){
|
||||
// FAQ: 当第一次使用 currentEdit 时,使用时可能会引发错误。
|
||||
// 此时 currentEdit 可能是空的。
|
||||
if (currentEdit == nullptr) {
|
||||
qDebug() << "Warring: currentEdit == nullptr!";
|
||||
return;
|
||||
}
|
||||
qDebug() << currentEdit->text();
|
||||
});
|
||||
|
||||
QAction *action4 = menu->addAction(u8"设置当前编辑器为默认");
|
||||
connect(action4, &QAction::triggered, this, [=](){
|
||||
// 获取当前编辑器,并作为当前默认编辑器
|
||||
currentEdit = getCurrentEditFunc();
|
||||
qDebug() << u8"设置完成";
|
||||
});
|
||||
|
||||
QAction *action5 = menu->addAction(u8"打印当前编辑器内容");
|
||||
connect(action5, &QAction::triggered, this, [=](){
|
||||
// 获取当前编辑器,并直接打印编辑器内容
|
||||
QsciScintilla *edit = getCurrentEditFunc();
|
||||
qDebug() << edit->text();
|
||||
});
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef NDD_PLUGIN_IMPLEMENT_H
|
||||
#define NDD_PLUGIN_IMPLEMENT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMenu>
|
||||
|
||||
class QsciScintilla;
|
||||
class NddPluginImplement : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NddPluginImplement(QWidget *parent = nullptr, QsciScintilla *pEdit = nullptr);
|
||||
~NddPluginImplement();
|
||||
|
||||
void setMenuActions(QMenu *menu);
|
||||
void setCurrentEditFunc(std::function<QsciScintilla* ()> func) {
|
||||
getCurrentEditFunc = func;
|
||||
}
|
||||
|
||||
private:
|
||||
// 目前看来需要准备一个完整内部状态
|
||||
QWidget *currentWidget;
|
||||
QsciScintilla *currentEdit;
|
||||
std::function<QsciScintilla* ()> getCurrentEditFunc;
|
||||
};
|
||||
|
||||
#endif // NDD_PLUGIN_IMPLEMENT_H
|
|
@ -1,11 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <include/pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "ndd_plugin_implement.h"
|
||||
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IDENTIFY_V1("base-secondary-menu-plugin-v1", "0.1", "author", "二级菜单高级插件", "");
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IMPLEMENT_V1(NddPluginImplement, false);
|
|
@ -1,82 +0,0 @@
|
|||
# base-secondary-menu-plugin/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 base-secondary-menu-plugin 为你的插件名称
|
||||
# base-secondary-menu-plugin -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "base-secondary-menu-plugin")
|
||||
|
||||
# base-secondary-menu-plugin 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 base-secondary-menu-plugin 插件
|
||||
# 1. 默认构建时产出的目标为 base-secondary-menu-plugin
|
||||
# 2. 在此处可对 base-secondary-menu-plugin 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 base-secondary-menu-plugin 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
# 确保生成到 Notepad-- 的相对 plugin 目录下
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
|
||||
# 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
|
||||
# install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- base-secondary-menu-plugin 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
|
@ -1,6 +0,0 @@
|
|||
#include "ndd_plugin_implement.h"
|
||||
|
||||
NddPluginImplement::NddPluginImplement()
|
||||
{
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef NDD_PLUGIN_IMPLEMENT_H
|
||||
#define NDD_PLUGIN_IMPLEMENT_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class NddPluginImplement
|
||||
{
|
||||
public:
|
||||
NddPluginImplement();
|
||||
|
||||
};
|
||||
|
||||
#endif // NDD_PLUGIN_IMPLEMENT_H
|
|
@ -1,49 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <include/pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "ndd_plugin_implement.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
bool NDD_PROC_IDENTIFY(NDD_PROC_DATA* pProcData) {
|
||||
// NOTEPAD_PLUGIN_METADATA
|
||||
// (name, version, author, comment, filepath)
|
||||
// 使用插件宏模板来完成简单的插件处理
|
||||
NOTEPAD_PLUGIN_METADATA("base-secondary-menu-plugin", "0.1", "author", "基本二级菜单插件", "");
|
||||
|
||||
pProcData->m_menuType = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static QWidget *s_pNotepad;
|
||||
static NDD_PROC_DATA s_pProcData;
|
||||
static std::function<QsciScintilla* ()> s_getCurEdit;
|
||||
|
||||
int NDD_PROC_MAIN(QWidget* pNotepad, const QString& strFileName, std::function<QsciScintilla* ()>getCurEdit, NDD_PROC_DATA* pProcData) {
|
||||
// NOTEPAD_PLUGIN_IMPLEMENT
|
||||
// (NddPluginImplement);
|
||||
// 使用插件宏模板来完成基本的插件内容处理
|
||||
// NddPluginImplement *imp = new NddPluginImplement();
|
||||
|
||||
if(pNotepad != nullptr) {
|
||||
s_pNotepad = pNotepad;
|
||||
} else return -1;
|
||||
|
||||
if(pProcData != nullptr) {
|
||||
s_pProcData = *pProcData;
|
||||
} else return -1;
|
||||
|
||||
if(getCurEdit != nullptr) {
|
||||
s_getCurEdit = getCurEdit;
|
||||
} else return -1;
|
||||
|
||||
QAction *action = s_pProcData.m_rootMenu->addAction("打印信息");
|
||||
action->connect(action, &QAction::triggered, [](){
|
||||
qDebug() << "打印信息";
|
||||
});
|
||||
|
||||
// 插件已成功实现
|
||||
return 0;
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
# base-secondary-menu-ui-plugin-v1/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 base-secondary-menu-ui-plugin-v1 为你的插件名称
|
||||
# base-secondary-menu-ui-plugin-v1 -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "base-secondary-menu-ui-plugin-v1")
|
||||
|
||||
# base-secondary-menu-ui-plugin-v1 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 base-secondary-menu-ui-plugin-v1 插件
|
||||
# 1. 默认构建时产出的目标为 base-secondary-menu-ui-plugin-v1
|
||||
# 2. 在此处可对 base-secondary-menu-ui-plugin-v1 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 base-secondary-menu-ui-plugin-v1 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
# 确保生成到 Notepad-- 的相对 plugin 目录下
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
|
||||
# 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
|
||||
# install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- base-secondary-menu-ui-plugin-v1 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
||||
|
||||
# ----------------- base-secondary-menu-ui-plugin-v1 构建的外部项目依赖 ----------------- #
|
|
@ -1,59 +0,0 @@
|
|||
#include "ndd_plugin_implement.h"
|
||||
#include "ui_ndd_plugin_implement.h"
|
||||
|
||||
#include <qsciscintilla.h>
|
||||
#include <QDebug>
|
||||
#include <QDockWidget>
|
||||
#include <QHostInfo>
|
||||
|
||||
NddPluginImplement::NddPluginImplement(QWidget *parent, QsciScintilla *pEdit) : QMainWindow(parent)
|
||||
, currentWidget(parent)
|
||||
, currentEdit(pEdit)
|
||||
, ui(new Ui::NddPluginImplement)
|
||||
, m_dockWidget(new QDockWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->computer->setText(QHostInfo::localHostName());
|
||||
ui->computer->setReadOnly(true);
|
||||
}
|
||||
|
||||
NddPluginImplement::~NddPluginImplement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NddPluginImplement::setMenuActions(QMenu *menu)
|
||||
{
|
||||
QAction *action1 = menu->addAction(u8"第一项打印");
|
||||
connect(action1, &QAction::triggered, this, [](){
|
||||
// 普通的菜单项
|
||||
qDebug() << "action1";
|
||||
});
|
||||
|
||||
connect(menu->addAction("Show Ui"), &QAction::triggered, this, [=](){
|
||||
on_pushButton_clicked();
|
||||
});
|
||||
|
||||
connect(menu->addAction("Show Sider"), &QAction::triggered, this, [=](){
|
||||
auto mainWindow = dynamic_cast<QMainWindow*>(currentWidget);
|
||||
if(!mainWindow) {
|
||||
qDebug() << "None";
|
||||
return;
|
||||
}
|
||||
|
||||
m_dockWidget->setMinimumSize(100, 200);
|
||||
mainWindow->addDockWidget(Qt::RightDockWidgetArea, m_dockWidget);
|
||||
|
||||
if (!m_dockWidget->isVisible())
|
||||
m_dockWidget->show();
|
||||
|
||||
m_dockWidget->setWidget(this);
|
||||
});
|
||||
}
|
||||
|
||||
void NddPluginImplement::on_pushButton_clicked()
|
||||
{
|
||||
this->setParent(nullptr);
|
||||
this->resize(QSize(480,340));
|
||||
this->show();
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef NDD_PLUGIN_IMPLEMENT_H
|
||||
#define NDD_PLUGIN_IMPLEMENT_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QsciScintilla;
|
||||
namespace Ui {
|
||||
class NddPluginImplement;
|
||||
}
|
||||
class NddPluginImplement : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NddPluginImplement(QWidget *parent = nullptr, QsciScintilla *pEdit = nullptr);
|
||||
~NddPluginImplement();
|
||||
|
||||
void setMenuActions(QMenu *menu);
|
||||
void setCurrentEditFunc(std::function<QsciScintilla* ()> func) {
|
||||
getCurrentEditFunc = func;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
// 目前看来需要准备一个完整内部状态
|
||||
QWidget *currentWidget;
|
||||
QsciScintilla *currentEdit;
|
||||
std::function<QsciScintilla* ()> getCurrentEditFunc;
|
||||
|
||||
private:
|
||||
Ui::NddPluginImplement *ui;
|
||||
QDockWidget *m_dockWidget;
|
||||
};
|
||||
|
||||
#endif // NDD_PLUGIN_IMPLEMENT_H
|
|
@ -1,73 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NddPluginImplement</class>
|
||||
<widget class="QMainWindow" name="NddPluginImplement">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>340</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Sider Ui</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="computer"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Computer:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Eject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,11 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <include/pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "ndd_plugin_implement.h"
|
||||
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IDENTIFY_V1("base-secondary-menu-ui-plugin-v1", "0.1", "author", u8"二级菜单高级 UI 插件", "");
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IMPLEMENT_V1(NddPluginImplement, false);
|
|
@ -0,0 +1,110 @@
|
|||
#include "basesecondaryplugin.h"
|
||||
#include "pluginframeworkhelper.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
BaseSecondaryPlugin::BaseSecondaryPlugin(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
BaseSecondaryPlugin &BaseSecondaryPlugin::instance()
|
||||
{
|
||||
static BaseSecondaryPlugin _plugin;
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
QString BaseSecondaryPlugin::PluginName()
|
||||
{
|
||||
return "base-secondary-plugin";
|
||||
}
|
||||
|
||||
QString BaseSecondaryPlugin::PluginVersion()
|
||||
{
|
||||
return "v0.1";
|
||||
}
|
||||
|
||||
QString BaseSecondaryPlugin::PluginAuthor()
|
||||
{
|
||||
return "author";
|
||||
}
|
||||
|
||||
QString BaseSecondaryPlugin::PluginComment()
|
||||
{
|
||||
return "基本二级菜单插件";
|
||||
}
|
||||
|
||||
IPluginFramework::MenuType BaseSecondaryPlugin::PluginMenuType()
|
||||
{
|
||||
return MenuType::SecondaryMenu;
|
||||
}
|
||||
|
||||
void BaseSecondaryPlugin::PluginTrigger()
|
||||
{
|
||||
//Trigger: Will never enter here.
|
||||
}
|
||||
|
||||
void BaseSecondaryPlugin::registerPluginActions(QMenu *rootMenu)
|
||||
{
|
||||
rootMenu->addAction("Default", this, [this](){
|
||||
QMessageBox::information(nullptr, "tip", "This is default tip message.");
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"第一项打印"), &QAction::triggered, this, [](){
|
||||
// 普通的菜单项
|
||||
qDebug() << "action1";
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"第二项打印"), &QAction::triggered, this, [](){
|
||||
// 普通的菜单项
|
||||
qDebug() << "action2";
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"打印默认编辑器内容(源代码项注意)"), &QAction::triggered, this, [=](){
|
||||
// FAQ: 当第一次使用 m_editor 时,使用时可能会引发错误。
|
||||
// 此时 m_editor 可能是空的。
|
||||
if (m_editor == nullptr) {
|
||||
qDebug() << "Warring: m_editor == nullptr!";
|
||||
return;
|
||||
}
|
||||
qDebug() << m_editor->text();
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"设置当前编辑器为默认"), &QAction::triggered, this, [=](){
|
||||
// 获取当前编辑器,并作为当前默认编辑器
|
||||
m_editor = s_get_cur_edit_callback(s_notepad);
|
||||
qDebug() << u8"设置完成";
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"打印当前编辑器内容"), &QAction::triggered, this, [=](){
|
||||
// 获取当前编辑器,并直接打印编辑器内容
|
||||
auto editor = s_get_cur_edit_callback(s_notepad);
|
||||
qDebug() << editor->text();
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"创建新的编辑器"), &QAction::triggered, this, [=](){
|
||||
// 创建一个新的编辑器
|
||||
QVariant editor = PluginFrameworkHelper::DoNewEdit(s_notepad, s_plugin_callback);
|
||||
qDebug() << editor.toString();
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"改变当前编辑器语法 - Html"), &QAction::triggered, this, [=](){
|
||||
// 改变语法 Html
|
||||
bool re = PluginFrameworkHelper::DoChangeSyntax(s_notepad, s_plugin_callback, SyntaxType::Html);
|
||||
qDebug() << "Html" << re;
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"改变当前编辑器语法 - Js"), &QAction::triggered, this, [=](){
|
||||
// 改变语法 Js
|
||||
bool re = PluginFrameworkHelper::DoChangeSyntax(s_notepad, s_plugin_callback, SyntaxType::Js);
|
||||
qDebug() << "Js" << re;
|
||||
});
|
||||
|
||||
connect(rootMenu->addAction(u8"改变当前编辑器语法 - Json"), &QAction::triggered, this, [=](){
|
||||
// 改变语法 Json
|
||||
bool re = PluginFrameworkHelper::DoChangeSyntax(s_notepad, s_plugin_callback, SyntaxType::Json);
|
||||
qDebug() << "Json" << re;
|
||||
});
|
||||
}
|
||||
|
||||
// Plug-in implementation wrapper
|
||||
NDD_DECLARE_PLUGIN(BaseSecondaryPlugin::instance())
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef BASESECONDARYPLUGIN_H
|
||||
#define BASESECONDARYPLUGIN_H
|
||||
|
||||
#include <IPluginFramework.h>
|
||||
#include <QObject>
|
||||
|
||||
class BaseSecondaryPlugin : public QObject, public IPluginFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
explicit BaseSecondaryPlugin(QObject *parent = nullptr);
|
||||
public:
|
||||
static BaseSecondaryPlugin &instance();
|
||||
|
||||
|
||||
// IPluginFramework interface
|
||||
public:
|
||||
QString PluginName();
|
||||
QString PluginVersion();
|
||||
QString PluginAuthor();
|
||||
QString PluginComment();
|
||||
MenuType PluginMenuType();
|
||||
void PluginTrigger();
|
||||
void registerPluginActions(QMenu *rootMenu);
|
||||
|
||||
/** 当前版本 IPluginManager 中已经为此实现 - 如需加载时执行自定义代码请重写 registerNotepad 实现.
|
||||
并在其实现内首行调用 IPluginFramework::registerNotepad(notepad);
|
||||
*/
|
||||
// void registerNotepad(QWidget *notepad);
|
||||
// void registerStrFileName(QString str_file_name);
|
||||
// void registerCurrentEditCallback(std::function<QsciScintilla *(QWidget *)> get_cur_edit_callback);
|
||||
// void registerPluginCallBack(std::function<bool (QWidget *, int, void *)> plugin_callback);
|
||||
|
||||
|
||||
QsciScintilla *m_editor;
|
||||
};
|
||||
|
||||
#endif // BASESECONDARYPLUGIN_H
|
|
@ -0,0 +1,93 @@
|
|||
#include "basesecondarywidgetplugin.h"
|
||||
#include "pluginframeworkhelper.h"
|
||||
#include "pluginviewer.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QMessageBox>
|
||||
|
||||
BaseSecondaryWidgetPlugin::BaseSecondaryWidgetPlugin(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
BaseSecondaryWidgetPlugin &BaseSecondaryWidgetPlugin::instance()
|
||||
{
|
||||
static BaseSecondaryWidgetPlugin _plugin;
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
QString BaseSecondaryWidgetPlugin::PluginName()
|
||||
{
|
||||
return "base-secondary-widget-plugin";
|
||||
}
|
||||
|
||||
QString BaseSecondaryWidgetPlugin::PluginVersion()
|
||||
{
|
||||
return "v0.1";
|
||||
}
|
||||
|
||||
QString BaseSecondaryWidgetPlugin::PluginAuthor()
|
||||
{
|
||||
return "author";
|
||||
}
|
||||
|
||||
QString BaseSecondaryWidgetPlugin::PluginComment()
|
||||
{
|
||||
return "二级菜单高级 UI 插件";
|
||||
}
|
||||
|
||||
IPluginFramework::MenuType BaseSecondaryWidgetPlugin::PluginMenuType()
|
||||
{
|
||||
return MenuType::SecondaryMenu;
|
||||
}
|
||||
|
||||
void BaseSecondaryWidgetPlugin::PluginTrigger()
|
||||
{
|
||||
//Trigger: Will never enter here.
|
||||
}
|
||||
|
||||
void BaseSecondaryWidgetPlugin::registerPluginActions(QMenu *rootMenu)
|
||||
{
|
||||
rootMenu->addAction("Default", this, [this](){
|
||||
QMessageBox::information(nullptr, "tip", "This is default tip message.");
|
||||
});
|
||||
|
||||
rootMenu->addAction("Show Ui", this, [=](){
|
||||
auto viewer = new PluginViewer();
|
||||
viewer->show();
|
||||
});
|
||||
|
||||
rootMenu->addAction("Show Sider", this, [=](){
|
||||
auto notepad = dynamic_cast<QMainWindow*>(s_notepad);
|
||||
|
||||
auto viewer = new PluginViewer(s_notepad);
|
||||
viewer->show();
|
||||
viewer->setMinimumWidth(300);
|
||||
|
||||
auto dock =new QDockWidget("Plugin Sider Viewer", s_notepad);
|
||||
connect(viewer, &QObject::destroyed, dock, &QObject::deleteLater);
|
||||
|
||||
dock->setAllowedAreas(Qt::DockWidgetArea::LeftDockWidgetArea | Qt::DockWidgetArea::RightDockWidgetArea);
|
||||
dock->setWidget(viewer);
|
||||
|
||||
(dynamic_cast<QMainWindow*>(s_notepad))->addDockWidget(Qt::RightDockWidgetArea, dock);
|
||||
});
|
||||
|
||||
rootMenu->addAction("Show Bottom", this, [=](){
|
||||
auto notepad = dynamic_cast<QMainWindow*>(s_notepad);
|
||||
|
||||
auto viewer = new PluginViewer(s_notepad);
|
||||
viewer->show();
|
||||
viewer->setMinimumHeight(100);
|
||||
|
||||
auto dock =new QDockWidget("Plugin Bottom Viewer", s_notepad);
|
||||
connect(viewer, &QObject::destroyed, dock, &QObject::deleteLater);
|
||||
|
||||
dock->setAllowedAreas(Qt::DockWidgetArea::BottomDockWidgetArea);
|
||||
dock->setWidget(viewer);
|
||||
|
||||
(dynamic_cast<QMainWindow*>(s_notepad))->addDockWidget(Qt::BottomDockWidgetArea, dock);
|
||||
});
|
||||
}
|
||||
|
||||
// Plug-in implementation wrapper
|
||||
NDD_DECLARE_PLUGIN(BaseSecondaryWidgetPlugin::instance())
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef BASESECONDARYWIDGETPLUGIN_H
|
||||
#define BASESECONDARYWIDGETPLUGIN_H
|
||||
|
||||
#include <IPluginFramework.h>
|
||||
#include <QObject>
|
||||
|
||||
class BaseSecondaryWidgetPlugin : public QObject, public IPluginFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
explicit BaseSecondaryWidgetPlugin(QObject *parent = nullptr);
|
||||
public:
|
||||
static BaseSecondaryWidgetPlugin &instance();
|
||||
|
||||
|
||||
// IPluginFramework interface
|
||||
public:
|
||||
QString PluginName();
|
||||
QString PluginVersion();
|
||||
QString PluginAuthor();
|
||||
QString PluginComment();
|
||||
MenuType PluginMenuType();
|
||||
void PluginTrigger();
|
||||
void registerPluginActions(QMenu *rootMenu);
|
||||
|
||||
/** 当前版本 IPluginManager 中已经为此实现 - 如需加载时执行自定义代码请重写 registerNotepad 实现.
|
||||
并在其实现内首行调用 IPluginFramework::registerNotepad(notepad);
|
||||
*/
|
||||
// void registerNotepad(QWidget *notepad);
|
||||
// void registerStrFileName(QString str_file_name);
|
||||
// void registerCurrentEditCallback(std::function<QsciScintilla *(QWidget *)> get_cur_edit_callback);
|
||||
// void registerPluginCallBack(std::function<bool (QWidget *, int, void *)> plugin_callback);
|
||||
};
|
||||
|
||||
#endif // BASESECONDARYWIDGETPLUGIN_H
|
|
@ -0,0 +1,14 @@
|
|||
#include "pluginviewer.h"
|
||||
#include "ui_pluginviewer.h"
|
||||
|
||||
PluginViewer::PluginViewer(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::PluginViewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
PluginViewer::~PluginViewer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef PLUGINVIEWER_H
|
||||
#define PLUGINVIEWER_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class PluginViewer;
|
||||
}
|
||||
|
||||
class PluginViewer : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PluginViewer(QWidget *parent = nullptr);
|
||||
~PluginViewer();
|
||||
|
||||
private:
|
||||
Ui::PluginViewer *ui;
|
||||
};
|
||||
|
||||
#endif // PLUGINVIEWER_H
|
|
@ -0,0 +1,24 @@
|
|||
<ui version="4.0">
|
||||
<author/>
|
||||
<comment/>
|
||||
<exportmacro/>
|
||||
<class>PluginViewer</class>
|
||||
<widget class="QMainWindow" name="PluginViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QMenuBar" name="menubar"/>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<pixmapfunction/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,82 +0,0 @@
|
|||
# base-widget-plugin/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 base-widget-plugin 为你的插件名称
|
||||
# base-widget-plugin -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "base-widget-plugin")
|
||||
|
||||
# base-widget-plugin 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 base-widget-plugin 插件
|
||||
# 1. 默认构建时产出的目标为 base-widget-plugin
|
||||
# 2. 在此处可对 base-widget-plugin 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 base-widget-plugin 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
# 确保生成到 Notepad-- 的相对 plugin 目录下
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
|
||||
# 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
|
||||
# install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- base-widget-plugin 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
|
@ -1,14 +0,0 @@
|
|||
#include "ndd_plugin_implement.h"
|
||||
|
||||
#include <qsciscintilla.h>
|
||||
|
||||
NddPluginImplement::NddPluginImplement(QWidget *parent, QsciScintilla *pEdit) : QWidget(parent)
|
||||
, currentEdit(pEdit)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NddPluginImplement::~NddPluginImplement()
|
||||
{
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef NDD_PLUGIN_IMPLEMENT_H
|
||||
#define NDD_PLUGIN_IMPLEMENT_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QsciScintilla;
|
||||
class NddPluginImplement : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NddPluginImplement(QWidget *parent = nullptr, QsciScintilla *pEdit = nullptr);
|
||||
~NddPluginImplement();
|
||||
|
||||
private:
|
||||
QsciScintilla *currentEdit;
|
||||
};
|
||||
|
||||
#endif // NDD_PLUGIN_IMPLEMENT_H
|
|
@ -1,11 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <include/pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "ndd_plugin_implement.h"
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IDENTIFY("base-widget", "0.1", "author", u8"基于 QMainWindow 的插件", "");
|
||||
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IMPLEMENT(NddPluginImplement, true);
|
|
@ -1,82 +0,0 @@
|
|||
# base-widget-ui-plugin/CMakeLists.txt
|
||||
# 用于在源代码中构建一个插件的模板
|
||||
|
||||
# 如果不是在源代码中构建插件,请不要使用这个部分
|
||||
# 如果想在源代码中添加更多内置模板
|
||||
# 请替换 base-widget-ui-plugin 为你的插件名称
|
||||
# base-widget-ui-plugin -> your plugin name
|
||||
|
||||
set(LOCAL_PLUGIN_NAME "base-widget-ui-plugin")
|
||||
|
||||
# base-widget-ui-plugin 核心构建
|
||||
# 在模块化构建中,这个部分代表着构建 base-widget-ui-plugin 插件
|
||||
# 1. 默认构建时产出的目标为 base-widget-ui-plugin
|
||||
# 2. 在此处可对 base-widget-ui-plugin 目标进行详细的构建计划
|
||||
|
||||
if(TRUE)
|
||||
# 准备构建 base-widget-ui-plugin 主程序扩展
|
||||
spark_file_glob(LocalSources
|
||||
./*.h ./*.cpp ./*.ui
|
||||
)
|
||||
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
|
||||
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/src/cceditor
|
||||
|
||||
${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
|
||||
)
|
||||
# target_link_libraries(${LOCAL_PLUGIN_NAME} QSci)
|
||||
target_link_QSci(${LOCAL_PLUGIN_NAME})
|
||||
if(USE_QT6)
|
||||
# target_link_qt6_Core5Compat(${LOCAL_PLUGIN_NAME}) # 兼容性: Qt6 可使用 Core5Compat 少量更改 Qt5 部分
|
||||
# target_link_qt6_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt6_XmlPatterns(${LOCAL_PLUGIN_NAME}) # Bug 初期配置时无此依赖要求
|
||||
else()
|
||||
# target_link_qt5_PrintSupport(${LOCAL_PLUGIN_NAME})
|
||||
# target_link_qt5_XmlPatterns(${LOCAL_PLUGIN_NAME})
|
||||
endif(USE_QT6)
|
||||
|
||||
# 确保生成到 Notepad-- 的相对 plugin 目录下
|
||||
set_target_properties(${LOCAL_PLUGIN_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin
|
||||
ARCHIVE_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${PROJECT_NAME}>/plugin)
|
||||
|
||||
# 控制是否安装到 bin/plugin 而各种配方之下,每个位置或许都不一样(特别是 Linux)
|
||||
# install(TARGETS ${LOCAL_PLUGIN_NAME} DESTINATION bin/plugin)
|
||||
endif(TRUE)
|
||||
|
||||
|
||||
# ----------------- base-widget-ui-plugin 构建宏支持相关 ----------------- #
|
||||
|
||||
if(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
else()
|
||||
# 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
# QSCINTILLA_DLL # 目前在 Windows 中使用 QSci 库时应该采用 Q_DECL_IMPORT
|
||||
# 控制 QSCINTILLA_EXPORT 符号应为 Q_DECL_IMPORT
|
||||
)
|
||||
endif(WIN32 AND NOTEPAD_BUILD_BY_SHARED)
|
||||
|
||||
if(UNIX)
|
||||
# 默认在 Unix/Linux 中仅需要定义一个内部插件宏管理器
|
||||
target_compile_definitions(${LOCAL_PLUGIN_NAME}
|
||||
PRIVATE
|
||||
NOTEPAD_PLUGIN_MANAGER
|
||||
)
|
||||
endif(UNIX)
|
|
@ -1,16 +0,0 @@
|
|||
#include "ndd_plugin_implement.h"
|
||||
#include "ui_ndd_plugin_implement.h"
|
||||
|
||||
#include <qsciscintilla.h>
|
||||
|
||||
NddPluginImplement::NddPluginImplement(QWidget *parent, QsciScintilla *pEdit) : QMainWindow (parent)
|
||||
, ui(new Ui::NddPluginImplement)
|
||||
, currentEdit(pEdit)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
NddPluginImplement::~NddPluginImplement()
|
||||
{
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef NDD_PLUGIN_IMPLEMENT_H
|
||||
#define NDD_PLUGIN_IMPLEMENT_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QsciScintilla;
|
||||
namespace Ui {
|
||||
class NddPluginImplement;
|
||||
}
|
||||
class NddPluginImplement : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NddPluginImplement(QWidget *parent = nullptr, QsciScintilla *pEdit = nullptr);
|
||||
~NddPluginImplement();
|
||||
|
||||
private:
|
||||
Ui::NddPluginImplement *ui;
|
||||
QsciScintilla *currentEdit;
|
||||
};
|
||||
|
||||
#endif // NDD_PLUGIN_IMPLEMENT_H
|
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NddPluginImplement</class>
|
||||
<widget class="QMainWindow" name="NddPluginImplement">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>554</width>
|
||||
<height>379</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>554</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,11 +0,0 @@
|
|||
#include <qobject.h>
|
||||
#include <qstring.h>
|
||||
#include <include/pluginGl.h>
|
||||
#include <functional>
|
||||
#include <qsciscintilla.h>
|
||||
#include "ndd_plugin_implement.h"
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IDENTIFY("base-widget-ui", "0.1", "author", u8"基于 QMainWindow Ui 的插件", "");
|
||||
|
||||
|
||||
NOTEPAD_PLUGIN_METADATA_IMPLEMENT(NddPluginImplement, true);
|
Loading…
Reference in New Issue