feat: 设置方面相关更新;优化标记的颜色显示;修复软件关于显示开源协议时文字无换行的问题;
This commit is contained in:
parent
c08c2a859e
commit
912dfaf227
|
@ -93,11 +93,13 @@ bool QHexDocument::metafgVisible() { return m_metafg; }
|
|||
|
||||
bool QHexDocument::metaCommentVisible() { return m_metacomment; }
|
||||
|
||||
bool QHexDocument::isDocSaved() { return m_undostack->isClean(); }
|
||||
bool QHexDocument::isDocSaved() { return m_isSaved; }
|
||||
|
||||
void QHexDocument::setDocSaved(bool b) {
|
||||
if (b) {
|
||||
m_undostack->setClean();
|
||||
}
|
||||
m_isSaved = b;
|
||||
emit documentSaved(b);
|
||||
}
|
||||
|
||||
|
@ -188,7 +190,11 @@ bool QHexDocument::RemoveBookMarks(const QList<qsizetype> &pos) {
|
|||
|
||||
bool QHexDocument::removeBookMark(qsizetype pos) {
|
||||
if (m_keepsize) {
|
||||
return _bookmarks.remove(pos) != 0;
|
||||
auto ret = _bookmarks.remove(pos) != 0;
|
||||
if (ret) {
|
||||
setDocSaved(false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -197,6 +203,7 @@ bool QHexDocument::modBookMark(qsizetype pos, const QString &comment) {
|
|||
if (m_keepsize) {
|
||||
if (_bookmarks.contains(pos)) {
|
||||
_bookmarks[pos] = comment;
|
||||
setDocSaved(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -332,8 +339,10 @@ QHexDocument::QHexDocument(QHexBuffer *buffer, bool readonly)
|
|||
m_metadata = new QHexMetadata(m_undostack, this);
|
||||
m_metadata->setLineWidth(m_hexlinewidth);
|
||||
|
||||
connect(m_metadata, &QHexMetadata::metadataChanged, this,
|
||||
&QHexDocument::metaDataChanged);
|
||||
connect(m_metadata, &QHexMetadata::metadataChanged, this, [this] {
|
||||
setDocSaved(false);
|
||||
emit metaDataChanged();
|
||||
});
|
||||
|
||||
/*=======================*/
|
||||
// added by wingsummer
|
||||
|
|
|
@ -190,6 +190,8 @@ private:
|
|||
/*======================*/
|
||||
// added by wingsummer
|
||||
|
||||
bool m_isSaved = true;
|
||||
|
||||
bool m_readonly;
|
||||
bool m_keepsize;
|
||||
bool m_islocked;
|
||||
|
|
|
@ -33,7 +33,7 @@ class QCE_EXPORT QSnippetManager : public QObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QSnippetManager(QObject *p = 0);
|
||||
explicit QSnippetManager(QObject *p = nullptr);
|
||||
virtual ~QSnippetManager();
|
||||
|
||||
int snippetCount() const;
|
||||
|
|
|
@ -8,7 +8,7 @@ set(CMAKE_AUTORCC ON)
|
|||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(PROJECT_VERSION 1.0.0)
|
||||
set(PROJECT_VERSION "2.0.0-WIP")
|
||||
|
||||
find_package(
|
||||
QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network Concurrent
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -161,7 +161,7 @@ def update(build_path):
|
|||
run_command_interactive(
|
||||
["xdg-icon-resource", "forceupdate"])
|
||||
run_command_interactive(
|
||||
["gtk-update-icon-caches", "/usr/share/icons/hicolor"])
|
||||
["gtk-update-icon-cache", "/usr/share/icons/hicolor"])
|
||||
run_command_interactive(
|
||||
["update-desktop-database", "/usr/share/applications"])
|
||||
print(Fore.GREEN + ">> Installation finished..." + Style.RESET_ALL)
|
||||
|
|
|
@ -43,7 +43,11 @@ SkinManager::SkinManager(QObject *parent) : QObject(parent) {
|
|||
break;
|
||||
}
|
||||
qss.open(QFile::ReadOnly | QFile::Text);
|
||||
#ifdef Q_OS_WIN
|
||||
qApp->setStyle(QStyleFactory::create("windowsvista"));
|
||||
#else
|
||||
qApp->setStyle(QStyleFactory::create("fusion"));
|
||||
#endif
|
||||
qApp->setStyleSheet(qss.readAll());
|
||||
qss.close();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,13 @@ AboutSoftwareDialog::AboutSoftwareDialog(QWidget *parent)
|
|||
ui->tbTr->setMarkdown(data.trans);
|
||||
ui->lblVersion->setText(qApp->applicationVersion());
|
||||
|
||||
QFile license(QStringLiteral(":/com.wingsummer.winghex/LICENSE"));
|
||||
auto ret = license.open(QFile::ReadOnly);
|
||||
Q_ASSERT(ret);
|
||||
Q_UNUSED(ret);
|
||||
auto ltxt = license.readAll();
|
||||
ui->tbLicense->setText(ltxt);
|
||||
|
||||
_dialog = new FramelessDialogBase(parent);
|
||||
_dialog->buildUpContent(this);
|
||||
_dialog->setWindowTitle(this->windowTitle());
|
||||
|
|
|
@ -131,11 +131,6 @@
|
|||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="source">
|
||||
<url>
|
||||
<string>qrc:/com.wingsummer.winghex/LICENSE</string>
|
||||
</url>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
@ -1106,6 +1106,7 @@ RibbonTabContent *MainWindow::buildPluginPage(RibbonTabContent *tab) {
|
|||
pannel->setVisible(false);
|
||||
connect(pannel, &RibbonButtonGroup::emptyStatusChanged, this,
|
||||
[pannel](bool isEmpty) { pannel->setVisible(!isEmpty); });
|
||||
m_pluginSettingsGroup = pannel;
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
@ -1149,35 +1150,89 @@ RibbonTabContent *MainWindow::buildAboutPage(RibbonTabContent *tab) {
|
|||
}
|
||||
|
||||
void MainWindow::buildUpSettingDialog() {
|
||||
QStringList usedIDs;
|
||||
QString id;
|
||||
|
||||
m_setdialog = new SettingDialog(this);
|
||||
auto generalPage = new GeneralSettingDialog(m_setdialog);
|
||||
connect(generalPage, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
m_setdialog->addPage(generalPage);
|
||||
id = generalPage->id();
|
||||
Q_ASSERT(!id.isEmpty());
|
||||
Q_ASSERT(usedIDs.indexOf(id) < 0);
|
||||
usedIDs.append(id);
|
||||
|
||||
auto editorPage = new EditorSettingDialog(m_setdialog);
|
||||
connect(editorPage, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
m_setdialog->addPage(editorPage);
|
||||
id = editorPage->id();
|
||||
Q_ASSERT(!id.isEmpty());
|
||||
Q_ASSERT(usedIDs.indexOf(id) < 0);
|
||||
usedIDs.append(id);
|
||||
|
||||
auto plgPage = new PluginSettingDialog(m_setdialog);
|
||||
connect(plgPage, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
plgPage->buildUp(m_settingPages);
|
||||
plgPage->buildUp(m_plgPages);
|
||||
m_setdialog->addPage(plgPage);
|
||||
id = plgPage->id();
|
||||
Q_ASSERT(!id.isEmpty());
|
||||
Q_ASSERT(usedIDs.indexOf(id) < 0);
|
||||
usedIDs.append(id);
|
||||
|
||||
auto scriptPage = new ScriptSettingDialog(m_setdialog);
|
||||
connect(scriptPage, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
m_setdialog->addPage(scriptPage);
|
||||
|
||||
for (auto &page : m_settingPages) {
|
||||
if (!page->isInPluginPage()) {
|
||||
connect(page, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
m_setdialog->addPage(page);
|
||||
}
|
||||
}
|
||||
id = scriptPage->id();
|
||||
Q_ASSERT(!id.isEmpty());
|
||||
Q_ASSERT(usedIDs.indexOf(id) < 0);
|
||||
usedIDs.append(id);
|
||||
|
||||
auto otherPage = new OtherSettingsDialog(m_setdialog);
|
||||
id = otherPage->id();
|
||||
Q_ASSERT(!id.isEmpty());
|
||||
Q_ASSERT(usedIDs.indexOf(id) < 0);
|
||||
usedIDs.append(id);
|
||||
|
||||
for (auto page_p = m_settingPages.constKeyValueBegin();
|
||||
page_p != m_settingPages.constKeyValueEnd(); ++page_p) {
|
||||
auto page = page_p->first;
|
||||
auto name = page->name();
|
||||
auto id = page->id();
|
||||
|
||||
// check
|
||||
if (id.isEmpty()) {
|
||||
id = name;
|
||||
auto plg = page->property("__plg__").value<IWingPlugin *>();
|
||||
Logger::warning(
|
||||
QStringLiteral("[") + plg->metaObject()->className() +
|
||||
QStringLiteral("::") + name + QStringLiteral("] ") +
|
||||
QStringLiteral(":") + tr("SetPageIDEmptyTryUseName"));
|
||||
}
|
||||
|
||||
if (usedIDs.contains(id)) {
|
||||
auto plg = page->property("__plg__").value<IWingPlugin *>();
|
||||
Logger::critical(
|
||||
QStringLiteral("[") + plg->metaObject()->className() +
|
||||
QStringLiteral("::") + name + QStringLiteral("] ") +
|
||||
QStringLiteral(":") + tr("SetPageDupNameIgnored"));
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(page, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
m_setdialog->addPage(page);
|
||||
if (page_p->second) {
|
||||
auto icon = page->categoryIcon();
|
||||
addPannelAction(m_pluginSettingsGroup, icon, name,
|
||||
[=] { m_setdialog->showConfig(id); });
|
||||
}
|
||||
usedIDs.append(id);
|
||||
}
|
||||
|
||||
connect(otherPage, &SettingPage::optionNeedRestartChanged, m_setdialog,
|
||||
&SettingDialog::toastTakeEffectReboot);
|
||||
m_setdialog->addPage(otherPage);
|
||||
|
|
|
@ -486,10 +486,12 @@ private:
|
|||
EditorView *m_curEditor = nullptr;
|
||||
|
||||
SettingDialog *m_setdialog = nullptr;
|
||||
SettingDialog *m_plgsetdlg = nullptr;
|
||||
RecentFileManager *m_recentmanager = nullptr;
|
||||
QMenu *m_recentMenu = nullptr;
|
||||
|
||||
RibbonButtonGroup *m_scriptDBGroup = nullptr;
|
||||
RibbonButtonGroup *m_pluginSettingsGroup = nullptr;
|
||||
ScriptManager::ScriptActionMaps _scriptMaps;
|
||||
|
||||
//===================================================
|
||||
|
@ -525,7 +527,8 @@ private:
|
|||
QHash<QString, RibbonTabContent *> m_ribbonMaps;
|
||||
QList<QMenu *> m_hexContextMenu;
|
||||
QMap<IWingPlugin *, QList<WingEditorViewWidget *>> m_editorViewWidgets;
|
||||
QList<SettingPage *> m_settingPages;
|
||||
QHash<SettingPage *, bool> m_settingPages;
|
||||
QList<PluginPage *> m_plgPages;
|
||||
QList<WingEditorViewWidget *> m_editorViewWidgetsBuffer;
|
||||
|
||||
ads::CDockAreaWidget *m_leftViewArea = nullptr;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "qeditor.h"
|
||||
#include "qformatscheme.h"
|
||||
#include "qlinemarksinfocenter.h"
|
||||
#include "qsnippetmanager.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QHeaderView>
|
||||
|
@ -95,6 +96,9 @@ ScriptingDialog::ScriptingDialog(QWidget *parent)
|
|||
m_language = new QLanguageFactory(format, this);
|
||||
m_language->addDefinitionPath(QStringLiteral(":/qcodeedit"));
|
||||
|
||||
auto snippet = new QSnippetManager(this);
|
||||
m_snipbind = new QSnippetBinding(snippet);
|
||||
|
||||
auto lmic = QLineMarksInfoCenter::instance();
|
||||
lmic->loadMarkTypes(QCE::fetchDataFile(":/qcodeedit/marks.qxm"));
|
||||
// get symbol ID
|
||||
|
@ -120,6 +124,8 @@ ScriptingDialog::ScriptingDialog(QWidget *parent)
|
|||
this->setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
ScriptingDialog::~ScriptingDialog() { delete m_snipbind; }
|
||||
|
||||
void ScriptingDialog::initConsole() {
|
||||
Q_ASSERT(m_consoleout);
|
||||
m_consoleout->init();
|
||||
|
@ -243,8 +249,7 @@ void ScriptingDialog::buildUpRibbonBar() {
|
|||
buildViewPage(m_ribbon->addTab(tr("View")));
|
||||
m_editStateWidgets << buildDebugPage(m_ribbon->addTab(tr("Debugger")));
|
||||
|
||||
// TODO: not available for v1.0.0
|
||||
// buildSettingPage(m_ribbon->addTab(tr("Setting")));
|
||||
buildSettingPage(m_ribbon->addTab(tr("Setting")));
|
||||
buildAboutPage(m_ribbon->addTab(tr("About")));
|
||||
|
||||
connect(m_ribbon, &Ribbon::onDragDropFiles, this,
|
||||
|
@ -719,6 +724,7 @@ void ScriptingDialog::registerEditorView(ScriptEditor *editor) {
|
|||
});
|
||||
|
||||
m_language->setLanguage(editor->editor(), QStringLiteral("AngelScript"));
|
||||
editor->editor()->addInputBinding(m_snipbind);
|
||||
|
||||
m_views.append(editor);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "model/dbgcallstackmodel.h"
|
||||
#include "model/dbgvarshowmodel.h"
|
||||
#include "qlanguagefactory.h"
|
||||
#include "qsnippetbinding.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#include <QShortcut>
|
||||
|
@ -70,6 +71,7 @@ private:
|
|||
|
||||
public:
|
||||
explicit ScriptingDialog(QWidget *parent = nullptr);
|
||||
virtual ~ScriptingDialog();
|
||||
|
||||
void initConsole();
|
||||
|
||||
|
@ -250,6 +252,7 @@ private:
|
|||
ads::CDockManager *m_dock = nullptr;
|
||||
ads::CDockAreaWidget *m_editorViewArea = nullptr;
|
||||
QLanguageFactory *m_language = nullptr;
|
||||
QSnippetBinding *m_snipbind = nullptr;
|
||||
|
||||
QByteArray _defaultLayout;
|
||||
QByteArray _savedLayout;
|
||||
|
|
|
@ -75,6 +75,19 @@ void SettingDialog::showConfig(int index) {
|
|||
_dialog->exec();
|
||||
}
|
||||
|
||||
void SettingDialog::showConfig(const QString &id) {
|
||||
if (id.isEmpty()) {
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
auto r = std::find_if(
|
||||
m_pages.begin(), m_pages.end(),
|
||||
[id](const WingHex::SettingPage *page) { return page->id() == id; });
|
||||
if (r == m_pages.end()) {
|
||||
ui->listWidget->setCurrentRow(0);
|
||||
}
|
||||
ui->listWidget->setCurrentRow(m_pages.indexOf(*r));
|
||||
}
|
||||
|
||||
void SettingDialog::toastTakeEffectReboot() {
|
||||
auto page = qobject_cast<WingHex::SettingPage *>(sender());
|
||||
if (page) {
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
void addPage(WingHex::SettingPage *page);
|
||||
void build(); // you can only call once
|
||||
void showConfig(int index = -1);
|
||||
void showConfig(const QString &id);
|
||||
|
||||
public slots:
|
||||
void toastTakeEffectReboot();
|
||||
|
|
|
@ -32,7 +32,8 @@ int MetaDataModel::columnCount(const QModelIndex &parent) const {
|
|||
|
||||
QVariant MetaDataModel::data(const QModelIndex &index, int role) const {
|
||||
switch (role) {
|
||||
case Qt::DisplayRole: {
|
||||
case Qt::DisplayRole:
|
||||
case Qt::ToolTipRole: {
|
||||
auto r = index.row();
|
||||
const auto &b = _doc->metadata()->getAllMetadata();
|
||||
auto d = b.at(r);
|
||||
|
@ -47,52 +48,28 @@ QVariant MetaDataModel::data(const QModelIndex &index, int role) const {
|
|||
if (d.foreground.alpha() == 0) {
|
||||
return QStringLiteral("-");
|
||||
}
|
||||
return QVariant();
|
||||
break;
|
||||
return d.foreground.name();
|
||||
}
|
||||
case 3:
|
||||
if (d.background.alpha() == 0) {
|
||||
return QStringLiteral("-");
|
||||
}
|
||||
return QVariant();
|
||||
break;
|
||||
return d.background.name();
|
||||
case 4:
|
||||
return d.comment;
|
||||
}
|
||||
}
|
||||
case Qt::ToolTipRole: {
|
||||
auto r = index.row();
|
||||
const auto &b = _doc->metadata()->getAllMetadata();
|
||||
auto d = b.at(r);
|
||||
switch (index.column()) {
|
||||
case 2: {
|
||||
if (d.foreground.alpha() == 0) {
|
||||
return QStringLiteral("-");
|
||||
} else {
|
||||
return d.foreground.name();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
if (d.background.alpha() == 0) {
|
||||
return QStringLiteral("-");
|
||||
} else {
|
||||
return d.background.name();
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
return d.comment;
|
||||
}
|
||||
} break;
|
||||
case Qt::BackgroundRole: {
|
||||
case Qt::DecorationRole: {
|
||||
auto r = index.row();
|
||||
const auto &b = _doc->metadata()->getAllMetadata();
|
||||
auto d = b.at(r);
|
||||
switch (index.column()) {
|
||||
case 2:
|
||||
return d.foreground;
|
||||
if (d.foreground.alpha() > 0)
|
||||
return d.foreground;
|
||||
case 3:
|
||||
return d.background;
|
||||
if (d.background.alpha() > 0)
|
||||
return d.background;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <QCryptographicHash>
|
||||
#include <QDockWidget>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QMenu>
|
||||
#include <QObject>
|
||||
#include <QToolBar>
|
||||
|
@ -496,6 +497,10 @@ signals:
|
|||
|
||||
class IWingPlugin : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// TODO: implement the basic type only
|
||||
typedef std::function<QVariant(const QVariantList &)> ScriptFn;
|
||||
|
||||
public:
|
||||
virtual int sdkVersion() const = 0;
|
||||
virtual const QString signature() const = 0;
|
||||
|
@ -515,11 +520,18 @@ public:
|
|||
virtual QList<WingRibbonToolBoxInfo> registeredRibbonTools() const {
|
||||
return {};
|
||||
}
|
||||
virtual QList<SettingPage *> registeredSettingPages() const { return {}; }
|
||||
// QMap<page, whether is visible in setting tab>
|
||||
virtual QHash<SettingPage *, bool> registeredSettingPages() const {
|
||||
return {};
|
||||
}
|
||||
virtual QList<PluginPage *> registeredPages() const { return {}; }
|
||||
virtual QList<WingEditorViewWidget *> registeredEditorViewWidgets() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
// QHash<signature, fn>
|
||||
virtual QHash<QString, ScriptFn> registeredScriptFn() { return {}; }
|
||||
|
||||
signals:
|
||||
// extension and exposed to WingHexAngelScript
|
||||
void toast(const QPixmap &icon, const QString &message);
|
||||
|
|
|
@ -130,17 +130,28 @@ void PluginSystem::cleanUpEditorViewHandle(EditorView *view) {
|
|||
// clean up
|
||||
for (auto &plg : v) {
|
||||
auto handles = m_plgHandles.value(plg);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
handles.erase(
|
||||
std::remove_if(handles.begin(), handles.end(),
|
||||
[view](const QPair<int, EditorView *> &v) {
|
||||
return v.second == view;
|
||||
}));
|
||||
}
|
||||
|
||||
#else
|
||||
handles.removeIf([view](const QPair<int, EditorView *> &v) {
|
||||
return v.second == view;
|
||||
});
|
||||
#endif
|
||||
}
|
||||
m_viewBindings.remove(view);
|
||||
}
|
||||
}
|
||||
|
||||
void PluginSystem::registerFn(IWingPlugin *plg,
|
||||
const IWingPlugin::ScriptFn &fn) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool PluginSystem::loadPlugin(IWingPlugin *p) {
|
||||
QList<WingPluginInfo> loadedplginfos;
|
||||
try {
|
||||
|
@ -267,17 +278,43 @@ bool PluginSystem::loadPlugin(IWingPlugin *p) {
|
|||
}
|
||||
}
|
||||
|
||||
if (p->registeredHexContextMenu()) {
|
||||
_win->m_hexContextMenu.append(p->registeredHexContextMenu());
|
||||
{
|
||||
auto menu = p->registeredHexContextMenu();
|
||||
if (menu) {
|
||||
_win->m_hexContextMenu.append(menu);
|
||||
}
|
||||
}
|
||||
|
||||
if (!p->registeredEditorViewWidgets().isEmpty()) {
|
||||
_win->m_editorViewWidgets.insert(p,
|
||||
p->registeredEditorViewWidgets());
|
||||
{
|
||||
auto vieww = p->registeredEditorViewWidgets();
|
||||
if (!vieww.isEmpty()) {
|
||||
_win->m_editorViewWidgets.insert(p, vieww);
|
||||
}
|
||||
}
|
||||
|
||||
if (!p->registeredSettingPages().isEmpty()) {
|
||||
_win->m_settingPages.append(p->registeredSettingPages());
|
||||
{
|
||||
auto sp = p->registeredSettingPages();
|
||||
if (!sp.isEmpty()) {
|
||||
for (auto page = sp.keyBegin(); page != sp.keyEnd(); ++page) {
|
||||
auto pp = *page;
|
||||
pp->setProperty("__plg__", QVariant::fromValue(p));
|
||||
}
|
||||
_win->m_settingPages.insert(sp);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto rp = p->registeredPages();
|
||||
if (!rp.isEmpty()) {
|
||||
for (auto &page : rp) {
|
||||
page->setProperty("__plg__", QVariant::fromValue(p));
|
||||
}
|
||||
_win->m_plgPages.append(rp);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &fn : p->registeredScriptFn()) {
|
||||
registerFn(p, fn);
|
||||
}
|
||||
|
||||
connectInterface(p);
|
||||
|
|
|
@ -115,6 +115,8 @@ public:
|
|||
|
||||
void cleanUpEditorViewHandle(EditorView *view);
|
||||
|
||||
void registerFn(IWingPlugin *plg, const IWingPlugin::ScriptFn &fn);
|
||||
|
||||
private:
|
||||
bool loadPlugin(IWingPlugin *p);
|
||||
|
||||
|
|
|
@ -22,23 +22,35 @@
|
|||
|
||||
namespace WingHex {
|
||||
|
||||
class SettingPage : public QWidget {
|
||||
class PageBase : public QWidget {
|
||||
public:
|
||||
explicit PageBase(QWidget *parent = nullptr) : QWidget(parent) {}
|
||||
|
||||
public:
|
||||
virtual QIcon categoryIcon() const = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual QString id() const = 0;
|
||||
};
|
||||
|
||||
class SettingPage : public PageBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingPage(QWidget *parent = nullptr) : QWidget(parent) {}
|
||||
explicit SettingPage(QWidget *parent = nullptr) : PageBase(parent) {}
|
||||
|
||||
signals:
|
||||
void optionNeedRestartChanged();
|
||||
|
||||
public:
|
||||
virtual QIcon categoryIcon() const = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual bool isInPluginPage() const = 0;
|
||||
virtual void apply() = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void cancel() = 0;
|
||||
};
|
||||
|
||||
class PluginPage : public PageBase {
|
||||
public:
|
||||
explicit PluginPage(QWidget *parent = nullptr) : PageBase(parent) {}
|
||||
};
|
||||
|
||||
} // namespace WingHex
|
||||
|
||||
#endif // SETTINGPAGE_H
|
||||
|
|
|
@ -192,7 +192,7 @@ QIcon QEditConfig::categoryIcon() const { return ICONRES("file"); }
|
|||
|
||||
QString QEditConfig::name() const { return tr("Edit"); }
|
||||
|
||||
bool QEditConfig::isInPluginPage() const { return false; }
|
||||
QString QEditConfig::id() const { return QStringLiteral("Edit"); }
|
||||
|
||||
/*!
|
||||
\brief Fills the widget subcontrols from a settings map
|
||||
|
|
|
@ -20,8 +20,7 @@ public:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
|
||||
virtual QString id() const override;
|
||||
virtual void apply() override;
|
||||
virtual void cancel() override;
|
||||
virtual void reset() override;
|
||||
|
|
|
@ -103,8 +103,6 @@ QIcon QFormatConfig::categoryIcon() const { return ICONRES(""); }
|
|||
|
||||
QString QFormatConfig::name() const { return tr("Format"); }
|
||||
|
||||
bool QFormatConfig::isInPluginPage() const { return false; }
|
||||
|
||||
/*!
|
||||
\brief Add a format scheme to the config widget
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ public:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
virtual void apply() override;
|
||||
virtual void cancel() override;
|
||||
virtual void reset() override;
|
||||
|
|
|
@ -34,13 +34,15 @@
|
|||
*/
|
||||
|
||||
QSnippetEdit::QSnippetEdit(QWidget *p)
|
||||
: QWidget(p), m_editedSnippet(-1), m_manager(nullptr) {
|
||||
: QWidget(p), ui(new Ui::QSnippetEdit), m_editedSnippet(-1),
|
||||
m_manager(nullptr) {
|
||||
ui->setupUi(this);
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
QSnippetEdit::QSnippetEdit(QSnippetManager *mgr, QWidget *p)
|
||||
: QWidget(p), m_editedSnippet(-1), m_manager(nullptr) {
|
||||
: QWidget(p), ui(new Ui::QSnippetEdit), m_editedSnippet(-1),
|
||||
m_manager(nullptr) {
|
||||
ui->setupUi(this);
|
||||
setSnippetManager(mgr);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ QIcon EditorSettingDialog::categoryIcon() const { return ICONRES("edit"); }
|
|||
|
||||
QString EditorSettingDialog::name() const { return tr("Editor"); }
|
||||
|
||||
bool EditorSettingDialog::isInPluginPage() const { return false; }
|
||||
QString EditorSettingDialog::id() const { return QStringLiteral("Editor"); }
|
||||
|
||||
void EditorSettingDialog::apply() {
|
||||
auto &set = SettingManager::instance();
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
virtual QString id() const override;
|
||||
virtual void apply() override;
|
||||
virtual void reset() override;
|
||||
virtual void cancel() override;
|
||||
|
|
|
@ -111,7 +111,7 @@ QIcon GeneralSettingDialog::categoryIcon() const { return ICONRES("general"); }
|
|||
|
||||
QString GeneralSettingDialog::name() const { return tr("General"); }
|
||||
|
||||
bool GeneralSettingDialog::isInPluginPage() const { return false; }
|
||||
QString GeneralSettingDialog::id() const { return QStringLiteral("General"); }
|
||||
|
||||
void GeneralSettingDialog::apply() {
|
||||
auto &set = SettingManager::instance();
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
virtual QString id() const override;
|
||||
virtual void apply() override;
|
||||
virtual void reset() override;
|
||||
virtual void cancel() override;
|
||||
|
|
|
@ -64,7 +64,7 @@ QIcon OtherSettingsDialog::categoryIcon() const { return ICONRES("other"); }
|
|||
|
||||
QString OtherSettingsDialog::name() const { return tr("Others"); }
|
||||
|
||||
bool OtherSettingsDialog::isInPluginPage() const { return false; }
|
||||
QString OtherSettingsDialog::id() const { return QStringLiteral("Others"); }
|
||||
|
||||
void OtherSettingsDialog::apply() {
|
||||
auto &set = SettingManager::instance();
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
virtual QString id() const override;
|
||||
virtual void apply() override;
|
||||
virtual void reset() override;
|
||||
virtual void cancel() override;
|
||||
|
|
|
@ -47,13 +47,10 @@ PluginSettingDialog::PluginSettingDialog(QWidget *parent)
|
|||
|
||||
PluginSettingDialog::~PluginSettingDialog() { delete ui; }
|
||||
|
||||
void PluginSettingDialog::buildUp(const QList<SettingPage *> &pages) {
|
||||
void PluginSettingDialog::buildUp(const QList<PluginPage *> &pages) {
|
||||
ASSERT_SINGLETON;
|
||||
for (auto &page : pages) {
|
||||
if (page->isInPluginPage()) {
|
||||
ui->tabWidget->addTab(page, page->categoryIcon(), page->name());
|
||||
_pages << page;
|
||||
}
|
||||
ui->tabWidget->addTab(page, page->categoryIcon(), page->name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,24 +66,17 @@ QIcon PluginSettingDialog::categoryIcon() const { return ICONRES("plugin"); }
|
|||
|
||||
QString PluginSettingDialog::name() const { return tr("Plugin"); }
|
||||
|
||||
bool PluginSettingDialog::isInPluginPage() const { return false; }
|
||||
QString PluginSettingDialog::id() const { return QStringLiteral("Plugin"); }
|
||||
|
||||
void PluginSettingDialog::apply() {
|
||||
auto &set = SettingManager::instance();
|
||||
set.setEnablePlugin(ui->cbEnablePlugin->isChecked());
|
||||
set.setEnablePlgInRoot(ui->cbEnablePluginRoot->isChecked());
|
||||
set.save(SettingManager::SETTING::PLUGIN);
|
||||
|
||||
for (auto &page : _pages) {
|
||||
page->apply();
|
||||
}
|
||||
}
|
||||
|
||||
void PluginSettingDialog::reset() {
|
||||
SettingManager::instance().reset(SettingManager::SETTING::PLUGIN);
|
||||
for (auto &page : _pages) {
|
||||
page->reset();
|
||||
}
|
||||
reload();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,10 @@ public:
|
|||
explicit PluginSettingDialog(QWidget *parent = nullptr);
|
||||
~PluginSettingDialog();
|
||||
|
||||
void buildUp(const QList<WingHex::SettingPage *> &pages);
|
||||
void buildUp(const QList<WingHex::PluginPage *> &pages);
|
||||
|
||||
private:
|
||||
Ui::PluginSettingDialog *ui;
|
||||
QList<WingHex::SettingPage *> _pages;
|
||||
|
||||
void reload();
|
||||
|
||||
|
@ -44,7 +43,7 @@ private:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
virtual QString id() const override;
|
||||
virtual void apply() override;
|
||||
virtual void reset() override;
|
||||
virtual void cancel() override;
|
||||
|
|
|
@ -76,7 +76,7 @@ QIcon ScriptSettingDialog::categoryIcon() const { return ICONRES("script"); }
|
|||
|
||||
QString ScriptSettingDialog::name() const { return tr("Script"); }
|
||||
|
||||
bool ScriptSettingDialog::isInPluginPage() const { return false; }
|
||||
QString ScriptSettingDialog::id() const { return QStringLiteral("Script"); }
|
||||
|
||||
void ScriptSettingDialog::apply() {
|
||||
QStringList usrHideCats;
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
public:
|
||||
virtual QIcon categoryIcon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual bool isInPluginPage() const override;
|
||||
virtual QString id() const override;
|
||||
virtual void apply() override;
|
||||
virtual void reset() override;
|
||||
virtual void cancel() override;
|
||||
|
|
Loading…
Reference in New Issue