feat: 设置页设置更改为自动保存
This commit is contained in:
parent
a3b465534c
commit
7bbe4da34b
|
@ -72,19 +72,13 @@ private:
|
||||||
|
|
||||||
// SettingInterface interface
|
// SettingInterface interface
|
||||||
public:
|
public:
|
||||||
virtual void apply() override { _isDisabled = _cbblk->isChecked(); }
|
virtual void restore() override { _cbblk->setChecked(false); }
|
||||||
virtual void reset() override {
|
|
||||||
_isDisabled = false;
|
|
||||||
_cbblk->setChecked(false);
|
|
||||||
}
|
|
||||||
virtual void cancel() override { _cbblk->setChecked(_isDisabled); }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isDisableMsg() const { return _isDisabled; }
|
bool isDisableMsg() const { return _cbblk->isChecked(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCheckBox *_cbblk;
|
QCheckBox *_cbblk;
|
||||||
bool _isDisabled = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -41,8 +41,4 @@ QString TestSettingPage::id() const { return _id; }
|
||||||
|
|
||||||
bool TestSettingPage::showInRibbon() const { return _isShownInRibbton; }
|
bool TestSettingPage::showInRibbon() const { return _isShownInRibbton; }
|
||||||
|
|
||||||
void TestSettingPage::apply() {}
|
void TestSettingPage::restore() {}
|
||||||
|
|
||||||
void TestSettingPage::reset() {}
|
|
||||||
|
|
||||||
void TestSettingPage::cancel() {}
|
|
||||||
|
|
|
@ -41,9 +41,7 @@ public:
|
||||||
|
|
||||||
// SettingPage interface
|
// SettingPage interface
|
||||||
public:
|
public:
|
||||||
virtual void apply() override;
|
virtual void restore() override;
|
||||||
virtual void reset() override;
|
|
||||||
virtual void cancel() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *_lbl = nullptr;
|
QLabel *_lbl = nullptr;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3fa9d2ba9d7dd78f719c43b482a5e7f49f135f1c
|
Subproject commit ab94fca27d23da495fa743dd15ccb01ca6a431fc
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QString, CLANG_CUSTOM_STYLE, ("clang.customStyle"))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, CLANG_DEFAULT_CUSTOM,
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, CLANG_DEFAULT_CUSTOM,
|
||||||
("BasedOnStyle: llvm, IndentWidth: 4"))
|
("BasedOnStyle: llvm, IndentWidth: 4"))
|
||||||
|
|
||||||
ClangFormatManager::ClangFormatManager() {
|
ClangFormatManager::ClangFormatManager() : QObject() {
|
||||||
ASSERT_SINGLETON;
|
ASSERT_SINGLETON;
|
||||||
|
|
||||||
// load config
|
// load config
|
||||||
|
|
|
@ -18,9 +18,12 @@
|
||||||
#ifndef CLANGFORMATMANAGER_H
|
#ifndef CLANGFORMATMANAGER_H
|
||||||
#define CLANGFORMATMANAGER_H
|
#define CLANGFORMATMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class ClangFormatManager {
|
class ClangFormatManager : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ClangFormatManager &instance();
|
static ClangFormatManager &instance();
|
||||||
|
|
||||||
|
|
|
@ -27,30 +27,6 @@
|
||||||
#include <KSyntaxHighlighting/Repository>
|
#include <KSyntaxHighlighting/Repository>
|
||||||
#include <KSyntaxHighlighting/Theme>
|
#include <KSyntaxHighlighting/Theme>
|
||||||
|
|
||||||
#define WRITE_CONFIG_EDITOR_SET(config, flag, dvalue) \
|
|
||||||
if (this->_setUnsavedEditor.testFlag(flag)) { \
|
|
||||||
WRITE_CONFIG(config, dvalue); \
|
|
||||||
_setUnsavedEditor.setFlag(flag, false); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define WRITE_CONFIG_EDITOR_RESET(config, flag, dvalue) \
|
|
||||||
do { \
|
|
||||||
WRITE_CONFIG(config, dvalue); \
|
|
||||||
_setUnsavedEditor.setFlag(flag, false); \
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
#define WRITE_CONFIG_CONSOLE_SET(config, flag, dvalue) \
|
|
||||||
if (this->_setUnsavedConsole.testFlag(flag)) { \
|
|
||||||
WRITE_CONFIG(config, dvalue); \
|
|
||||||
_setUnsavedConsole.setFlag(flag, false); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define WRITE_CONFIG_CONSOLE_RESET(config, flag, dvalue) \
|
|
||||||
do { \
|
|
||||||
WRITE_CONFIG(config, dvalue); \
|
|
||||||
_setUnsavedConsole.setFlag(flag, false); \
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, CODEEDIT_FONT, ("codeedit.font"))
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, CODEEDIT_FONT, ("codeedit.font"))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, CODEEDIT_FONT_SIZE, ("codeedit.fontsize"))
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, CODEEDIT_FONT_SIZE, ("codeedit.fontsize"))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, CODEEDIT_THEME, ("codeedit.theme"))
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, CODEEDIT_THEME, ("codeedit.theme"))
|
||||||
|
@ -147,70 +123,6 @@ void ScriptSettings::load() {
|
||||||
READ_CONFIG_BOOL(m_consoleAutoCloseChar, CONSOLE_AUTO_CLOSE_CHAR, true);
|
READ_CONFIG_BOOL(m_consoleAutoCloseChar, CONSOLE_AUTO_CLOSE_CHAR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptSettings::save(SETTINGS cat) {
|
|
||||||
HANDLE_CONFIG;
|
|
||||||
if (cat.testFlag(SETTING::EDITOR)) {
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_FONT, SETTING_ITEM::FONT,
|
|
||||||
m_editorFontFamily);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_FONT_SIZE, SETTING_ITEM::FONT_SIZE,
|
|
||||||
m_editorfontSize);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_THEME, SETTING_ITEM::THEME,
|
|
||||||
m_editorTheme);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_TABS_WIDTH, SETTING_ITEM::TAB_WIDTH,
|
|
||||||
m_editorTabWidth);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_INDENTATION, SETTING_ITEM::INDENTATION,
|
|
||||||
m_editorInden);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_MATCH_BRACES,
|
|
||||||
SETTING_ITEM::MATCH_BRACES,
|
|
||||||
m_editorMatchBraces);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_WORD_WRAP, SETTING_ITEM::WORD_WRAP,
|
|
||||||
m_editorWordWrap);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_SHOW_LINENUMBER,
|
|
||||||
SETTING_ITEM::SHOW_LINENUMBER,
|
|
||||||
m_editorShowLineNumber);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_SHOW_FOLDING,
|
|
||||||
SETTING_ITEM::SHOW_FOLDING, m_editorFolding);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_SHOW_INDENTGUIDES,
|
|
||||||
SETTING_ITEM::SHOW_INDENTGUIDES,
|
|
||||||
m_editorShowGuideLine);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_SHOW_LONGLINEEDGE,
|
|
||||||
SETTING_ITEM::SHOW_LONGLINEEDGE,
|
|
||||||
m_editorShowLineEdges);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_SHOW_WHITESPACE,
|
|
||||||
SETTING_ITEM::SHOW_WHITESPACE,
|
|
||||||
m_editorShowWhiteSpace);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_AUTO_CLOSE_CHAR,
|
|
||||||
SETTING_ITEM::AUTO_CLOSE_CHAR,
|
|
||||||
m_editorAutoCloseChar);
|
|
||||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_AUTO_IDEN, SETTING_ITEM::AUTO_IDEN,
|
|
||||||
m_editorAutoIden);
|
|
||||||
Q_EMIT editorSettingsUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cat.testFlag(SETTING::CONSOLE)) {
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_FONT, SETTING_ITEM::FONT,
|
|
||||||
m_consoleFontFamily);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_FONT_SIZE, SETTING_ITEM::FONT_SIZE,
|
|
||||||
m_consolefontSize);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_THEME, SETTING_ITEM::THEME,
|
|
||||||
m_consoleTheme);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_TABS_WIDTH, SETTING_ITEM::TAB_WIDTH,
|
|
||||||
m_consoleTabWidth);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_INDENTATION, SETTING_ITEM::INDENTATION,
|
|
||||||
m_consoleInden);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_MATCH_BRACES,
|
|
||||||
SETTING_ITEM::MATCH_BRACES,
|
|
||||||
m_consoleMatchBraces);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_SHOW_WHITESPACE,
|
|
||||||
SETTING_ITEM::SHOW_WHITESPACE,
|
|
||||||
m_consoleShowWhiteSpace);
|
|
||||||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_AUTO_CLOSE_CHAR,
|
|
||||||
SETTING_ITEM::AUTO_CLOSE_CHAR,
|
|
||||||
m_consoleAutoCloseChar);
|
|
||||||
Q_EMIT consoleSettingUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptSettings::reset(SETTINGS cat) {
|
void ScriptSettings::reset(SETTINGS cat) {
|
||||||
__reset(cat);
|
__reset(cat);
|
||||||
load();
|
load();
|
||||||
|
@ -219,51 +131,31 @@ void ScriptSettings::reset(SETTINGS cat) {
|
||||||
void ScriptSettings::__reset(SETTINGS cat) {
|
void ScriptSettings::__reset(SETTINGS cat) {
|
||||||
HANDLE_CONFIG;
|
HANDLE_CONFIG;
|
||||||
if (cat.testFlag(SETTING::EDITOR)) {
|
if (cat.testFlag(SETTING::EDITOR)) {
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_FONT, SETTING_ITEM::FONT,
|
WRITE_CONFIG(CODEEDIT_FONT, _defaultFont.defaultFamily());
|
||||||
_defaultFont.defaultFamily());
|
WRITE_CONFIG(CODEEDIT_FONT_SIZE, 10);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_FONT_SIZE, SETTING_ITEM::FONT_SIZE,
|
WRITE_CONFIG(CODEEDIT_THEME, {});
|
||||||
10);
|
WRITE_CONFIG(CODEEDIT_TABS_WIDTH, 4);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_THEME, SETTING_ITEM::THEME, {});
|
WRITE_CONFIG(CODEEDIT_INDENTATION, 0);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_TABS_WIDTH, SETTING_ITEM::TAB_WIDTH,
|
WRITE_CONFIG(CODEEDIT_MATCH_BRACES, true);
|
||||||
4);
|
WRITE_CONFIG(CODEEDIT_WORD_WRAP, false);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_INDENTATION,
|
WRITE_CONFIG(CODEEDIT_SHOW_LINENUMBER, true);
|
||||||
SETTING_ITEM::INDENTATION, 0);
|
WRITE_CONFIG(CODEEDIT_SHOW_FOLDING, true);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_MATCH_BRACES,
|
WRITE_CONFIG(CODEEDIT_SHOW_INDENTGUIDES, true);
|
||||||
SETTING_ITEM::MATCH_BRACES, true);
|
WRITE_CONFIG(CODEEDIT_SHOW_LONGLINEEDGE, false);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_WORD_WRAP, SETTING_ITEM::WORD_WRAP,
|
WRITE_CONFIG(CODEEDIT_SHOW_WHITESPACE, false);
|
||||||
false);
|
WRITE_CONFIG(CODEEDIT_AUTO_CLOSE_CHAR, true);
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_SHOW_LINENUMBER,
|
WRITE_CONFIG(CODEEDIT_AUTO_IDEN, true);
|
||||||
SETTING_ITEM::SHOW_LINENUMBER, true);
|
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_SHOW_FOLDING,
|
|
||||||
SETTING_ITEM::SHOW_FOLDING, true);
|
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_SHOW_INDENTGUIDES,
|
|
||||||
SETTING_ITEM::SHOW_INDENTGUIDES, true);
|
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_SHOW_LONGLINEEDGE,
|
|
||||||
SETTING_ITEM::SHOW_LONGLINEEDGE, false);
|
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_SHOW_WHITESPACE,
|
|
||||||
SETTING_ITEM::SHOW_WHITESPACE, false);
|
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_AUTO_CLOSE_CHAR,
|
|
||||||
SETTING_ITEM::AUTO_CLOSE_CHAR, true);
|
|
||||||
WRITE_CONFIG_EDITOR_RESET(CODEEDIT_AUTO_IDEN, SETTING_ITEM::AUTO_IDEN,
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cat.testFlag(SETTING::CONSOLE)) {
|
if (cat.testFlag(SETTING::CONSOLE)) {
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_FONT, SETTING_ITEM::FONT,
|
WRITE_CONFIG(CONSOLE_FONT, _defaultFont.defaultFamily());
|
||||||
_defaultFont.defaultFamily());
|
WRITE_CONFIG(CONSOLE_FONT_SIZE, 10);
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_FONT_SIZE, SETTING_ITEM::FONT_SIZE,
|
WRITE_CONFIG(CONSOLE_THEME, {});
|
||||||
10);
|
WRITE_CONFIG(CONSOLE_TABS_WIDTH, 4);
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_THEME, SETTING_ITEM::THEME, {});
|
WRITE_CONFIG(CONSOLE_INDENTATION, 0);
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_TABS_WIDTH, SETTING_ITEM::TAB_WIDTH,
|
WRITE_CONFIG(CONSOLE_MATCH_BRACES, true);
|
||||||
4);
|
WRITE_CONFIG(CONSOLE_SHOW_WHITESPACE, false);
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_INDENTATION,
|
WRITE_CONFIG(CONSOLE_AUTO_CLOSE_CHAR, true);
|
||||||
SETTING_ITEM::INDENTATION, 0);
|
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_MATCH_BRACES,
|
|
||||||
SETTING_ITEM::MATCH_BRACES, true);
|
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_SHOW_WHITESPACE,
|
|
||||||
SETTING_ITEM::SHOW_WHITESPACE, false);
|
|
||||||
WRITE_CONFIG_CONSOLE_RESET(CONSOLE_AUTO_CLOSE_CHAR,
|
|
||||||
SETTING_ITEM::AUTO_CLOSE_CHAR, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +167,11 @@ ScriptSettings::ScriptSettings() : QObject() {
|
||||||
bool ScriptSettings::editorAutoIden() const { return m_editorAutoIden; }
|
bool ScriptSettings::editorAutoIden() const { return m_editorAutoIden; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorAutoIden(bool newEditorAutoIden) {
|
void ScriptSettings::setEditorAutoIden(bool newEditorAutoIden) {
|
||||||
m_editorAutoIden = newEditorAutoIden;
|
if (m_editorAutoIden != newEditorAutoIden) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_AUTO_IDEN, newEditorAutoIden);
|
||||||
|
m_editorAutoIden = newEditorAutoIden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptSettings::consoleAutoCloseChar() const {
|
bool ScriptSettings::consoleAutoCloseChar() const {
|
||||||
|
@ -284,8 +180,9 @@ bool ScriptSettings::consoleAutoCloseChar() const {
|
||||||
|
|
||||||
void ScriptSettings::setConsoleAutoCloseChar(bool newConsoleAutoCloseChar) {
|
void ScriptSettings::setConsoleAutoCloseChar(bool newConsoleAutoCloseChar) {
|
||||||
if (m_consoleAutoCloseChar != newConsoleAutoCloseChar) {
|
if (m_consoleAutoCloseChar != newConsoleAutoCloseChar) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_AUTO_CLOSE_CHAR, newConsoleAutoCloseChar);
|
||||||
m_consoleAutoCloseChar = newConsoleAutoCloseChar;
|
m_consoleAutoCloseChar = newConsoleAutoCloseChar;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::AUTO_CLOSE_CHAR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,8 +192,9 @@ bool ScriptSettings::editorAutoCloseChar() const {
|
||||||
|
|
||||||
void ScriptSettings::setEditorAutoCloseChar(bool newEditorAutoCloseChar) {
|
void ScriptSettings::setEditorAutoCloseChar(bool newEditorAutoCloseChar) {
|
||||||
if (m_editorAutoCloseChar != newEditorAutoCloseChar) {
|
if (m_editorAutoCloseChar != newEditorAutoCloseChar) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_AUTO_CLOSE_CHAR, newEditorAutoCloseChar);
|
||||||
m_editorAutoCloseChar = newEditorAutoCloseChar;
|
m_editorAutoCloseChar = newEditorAutoCloseChar;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::AUTO_CLOSE_CHAR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,8 +204,9 @@ bool ScriptSettings::consoleShowWhiteSpace() const {
|
||||||
|
|
||||||
void ScriptSettings::setConsoleShowWhiteSpace(bool newConsoleShowWhiteSpace) {
|
void ScriptSettings::setConsoleShowWhiteSpace(bool newConsoleShowWhiteSpace) {
|
||||||
if (m_consoleShowWhiteSpace != newConsoleShowWhiteSpace) {
|
if (m_consoleShowWhiteSpace != newConsoleShowWhiteSpace) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_SHOW_WHITESPACE, newConsoleShowWhiteSpace);
|
||||||
m_consoleShowWhiteSpace = newConsoleShowWhiteSpace;
|
m_consoleShowWhiteSpace = newConsoleShowWhiteSpace;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::SHOW_WHITESPACE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,8 +216,9 @@ bool ScriptSettings::editorShowWhiteSpace() const {
|
||||||
|
|
||||||
void ScriptSettings::setEditorShowWhiteSpace(bool newEditorShowWhiteSpace) {
|
void ScriptSettings::setEditorShowWhiteSpace(bool newEditorShowWhiteSpace) {
|
||||||
if (m_editorShowWhiteSpace != newEditorShowWhiteSpace) {
|
if (m_editorShowWhiteSpace != newEditorShowWhiteSpace) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_SHOW_WHITESPACE, newEditorShowWhiteSpace);
|
||||||
m_editorShowWhiteSpace = newEditorShowWhiteSpace;
|
m_editorShowWhiteSpace = newEditorShowWhiteSpace;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::SHOW_WHITESPACE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,8 +228,9 @@ bool ScriptSettings::editorShowLineEdges() const {
|
||||||
|
|
||||||
void ScriptSettings::setEditorShowLineEdges(bool newEditorShowLineEdges) {
|
void ScriptSettings::setEditorShowLineEdges(bool newEditorShowLineEdges) {
|
||||||
if (m_editorShowLineEdges != newEditorShowLineEdges) {
|
if (m_editorShowLineEdges != newEditorShowLineEdges) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_SHOW_LONGLINEEDGE, newEditorShowLineEdges);
|
||||||
m_editorShowLineEdges = newEditorShowLineEdges;
|
m_editorShowLineEdges = newEditorShowLineEdges;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::SHOW_LONGLINEEDGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,8 +240,9 @@ bool ScriptSettings::editorShowGuideLine() const {
|
||||||
|
|
||||||
void ScriptSettings::setEditorShowGuideLine(bool newEditorShowGuidLine) {
|
void ScriptSettings::setEditorShowGuideLine(bool newEditorShowGuidLine) {
|
||||||
if (m_editorShowGuideLine != newEditorShowGuidLine) {
|
if (m_editorShowGuideLine != newEditorShowGuidLine) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_SHOW_INDENTGUIDES, newEditorShowGuidLine);
|
||||||
m_editorShowGuideLine = newEditorShowGuidLine;
|
m_editorShowGuideLine = newEditorShowGuidLine;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::SHOW_INDENTGUIDES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,8 +250,9 @@ bool ScriptSettings::editorFolding() const { return m_editorFolding; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorFolding(bool newEditorFolding) {
|
void ScriptSettings::setEditorFolding(bool newEditorFolding) {
|
||||||
if (m_editorFolding != newEditorFolding) {
|
if (m_editorFolding != newEditorFolding) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_SHOW_FOLDING, newEditorFolding);
|
||||||
m_editorFolding = newEditorFolding;
|
m_editorFolding = newEditorFolding;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::SHOW_FOLDING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +262,9 @@ bool ScriptSettings::editorShowLineNumber() const {
|
||||||
|
|
||||||
void ScriptSettings::setEditorShowLineNumber(bool newEditorShowLineNumber) {
|
void ScriptSettings::setEditorShowLineNumber(bool newEditorShowLineNumber) {
|
||||||
if (m_editorShowLineNumber != newEditorShowLineNumber) {
|
if (m_editorShowLineNumber != newEditorShowLineNumber) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_SHOW_LINENUMBER, newEditorShowLineNumber);
|
||||||
m_editorShowLineNumber = newEditorShowLineNumber;
|
m_editorShowLineNumber = newEditorShowLineNumber;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::SHOW_LINENUMBER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,8 +272,9 @@ bool ScriptSettings::editorWordWrap() const { return m_editorWordWrap; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorWordWrap(bool newEditorWordWrap) {
|
void ScriptSettings::setEditorWordWrap(bool newEditorWordWrap) {
|
||||||
if (m_editorWordWrap != newEditorWordWrap) {
|
if (m_editorWordWrap != newEditorWordWrap) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_WORD_WRAP, newEditorWordWrap);
|
||||||
m_editorWordWrap = newEditorWordWrap;
|
m_editorWordWrap = newEditorWordWrap;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::WORD_WRAP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,8 +282,9 @@ bool ScriptSettings::consoleMatchBraces() const { return m_consoleMatchBraces; }
|
||||||
|
|
||||||
void ScriptSettings::setConsoleMatchBraces(bool newConsoleMatchBraces) {
|
void ScriptSettings::setConsoleMatchBraces(bool newConsoleMatchBraces) {
|
||||||
if (m_consoleMatchBraces != newConsoleMatchBraces) {
|
if (m_consoleMatchBraces != newConsoleMatchBraces) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_MATCH_BRACES, newConsoleMatchBraces);
|
||||||
m_consoleMatchBraces = newConsoleMatchBraces;
|
m_consoleMatchBraces = newConsoleMatchBraces;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::MATCH_BRACES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,8 +292,9 @@ bool ScriptSettings::editorMatchBraces() const { return m_editorMatchBraces; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorMatchBraces(bool newEditorMatchBraces) {
|
void ScriptSettings::setEditorMatchBraces(bool newEditorMatchBraces) {
|
||||||
if (m_editorMatchBraces != newEditorMatchBraces) {
|
if (m_editorMatchBraces != newEditorMatchBraces) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_MATCH_BRACES, newEditorMatchBraces);
|
||||||
m_editorMatchBraces = newEditorMatchBraces;
|
m_editorMatchBraces = newEditorMatchBraces;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::MATCH_BRACES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,8 +302,9 @@ int ScriptSettings::consoleInden() const { return m_consoleInden; }
|
||||||
|
|
||||||
void ScriptSettings::setConsoleInden(int newConsoleInden) {
|
void ScriptSettings::setConsoleInden(int newConsoleInden) {
|
||||||
if (m_consoleInden != newConsoleInden) {
|
if (m_consoleInden != newConsoleInden) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_INDENTATION, newConsoleInden);
|
||||||
m_consoleInden = newConsoleInden;
|
m_consoleInden = newConsoleInden;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::INDENTATION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,8 +312,9 @@ int ScriptSettings::editorInden() const { return m_editorInden; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorInden(int newEditorInden) {
|
void ScriptSettings::setEditorInden(int newEditorInden) {
|
||||||
if (m_editorInden != newEditorInden) {
|
if (m_editorInden != newEditorInden) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_INDENTATION, newEditorInden);
|
||||||
m_editorInden = newEditorInden;
|
m_editorInden = newEditorInden;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::INDENTATION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,8 +322,9 @@ int ScriptSettings::consoleTabWidth() const { return m_consoleTabWidth; }
|
||||||
|
|
||||||
void ScriptSettings::setConsoleTabWidth(int newConsoleTabWidth) {
|
void ScriptSettings::setConsoleTabWidth(int newConsoleTabWidth) {
|
||||||
if (m_consoleTabWidth != newConsoleTabWidth) {
|
if (m_consoleTabWidth != newConsoleTabWidth) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_TABS_WIDTH, newConsoleTabWidth);
|
||||||
m_consoleTabWidth = newConsoleTabWidth;
|
m_consoleTabWidth = newConsoleTabWidth;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::TAB_WIDTH);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,8 +332,9 @@ int ScriptSettings::editorTabWidth() const { return m_editorTabWidth; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorTabWidth(int newEditorTabWidth) {
|
void ScriptSettings::setEditorTabWidth(int newEditorTabWidth) {
|
||||||
if (m_editorTabWidth != newEditorTabWidth) {
|
if (m_editorTabWidth != newEditorTabWidth) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_TABS_WIDTH, newEditorTabWidth);
|
||||||
m_editorTabWidth = newEditorTabWidth;
|
m_editorTabWidth = newEditorTabWidth;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::TAB_WIDTH);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,8 +342,9 @@ QString ScriptSettings::consoleTheme() const { return m_consoleTheme; }
|
||||||
|
|
||||||
void ScriptSettings::setConsoleTheme(const QString &newConsoleTheme) {
|
void ScriptSettings::setConsoleTheme(const QString &newConsoleTheme) {
|
||||||
if (m_consoleTheme != newConsoleTheme) {
|
if (m_consoleTheme != newConsoleTheme) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_THEME, newConsoleTheme);
|
||||||
m_consoleTheme = newConsoleTheme;
|
m_consoleTheme = newConsoleTheme;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::THEME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,8 +352,9 @@ QString ScriptSettings::editorTheme() const { return m_editorTheme; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorTheme(const QString &newEditorTheme) {
|
void ScriptSettings::setEditorTheme(const QString &newEditorTheme) {
|
||||||
if (m_editorTheme != newEditorTheme) {
|
if (m_editorTheme != newEditorTheme) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_THEME, newEditorTheme);
|
||||||
m_editorTheme = newEditorTheme;
|
m_editorTheme = newEditorTheme;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::THEME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,8 +362,9 @@ int ScriptSettings::consoleFontSize() const { return m_consolefontSize; }
|
||||||
|
|
||||||
void ScriptSettings::setConsoleFontSize(int newConsolefontSize) {
|
void ScriptSettings::setConsoleFontSize(int newConsolefontSize) {
|
||||||
if (m_consolefontSize != newConsolefontSize) {
|
if (m_consolefontSize != newConsolefontSize) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_FONT_SIZE, newConsolefontSize);
|
||||||
m_consolefontSize = newConsolefontSize;
|
m_consolefontSize = newConsolefontSize;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::FONT_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,8 +372,9 @@ int ScriptSettings::editorFontSize() const { return m_editorfontSize; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorFontSize(int newEditorfontSize) {
|
void ScriptSettings::setEditorFontSize(int newEditorfontSize) {
|
||||||
if (m_editorfontSize != newEditorfontSize) {
|
if (m_editorfontSize != newEditorfontSize) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_FONT_SIZE, newEditorfontSize);
|
||||||
m_editorfontSize = newEditorfontSize;
|
m_editorfontSize = newEditorfontSize;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::FONT_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,8 +384,9 @@ QString ScriptSettings::consoleFontFamily() const {
|
||||||
|
|
||||||
void ScriptSettings::setConsoleFontFamily(const QString &newConsoleFontFamily) {
|
void ScriptSettings::setConsoleFontFamily(const QString &newConsoleFontFamily) {
|
||||||
if (m_consoleFontFamily != newConsoleFontFamily) {
|
if (m_consoleFontFamily != newConsoleFontFamily) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CONSOLE_FONT, newConsoleFontFamily);
|
||||||
m_consoleFontFamily = newConsoleFontFamily;
|
m_consoleFontFamily = newConsoleFontFamily;
|
||||||
_setUnsavedConsole.setFlag(SETTING_ITEM::FONT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +394,8 @@ QString ScriptSettings::editorFontFamily() const { return m_editorFontFamily; }
|
||||||
|
|
||||||
void ScriptSettings::setEditorFontFamily(const QString &newEditorFontFamily) {
|
void ScriptSettings::setEditorFontFamily(const QString &newEditorFontFamily) {
|
||||||
if (m_editorFontFamily != newEditorFontFamily) {
|
if (m_editorFontFamily != newEditorFontFamily) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(CODEEDIT_FONT, newEditorFontFamily);
|
||||||
m_editorFontFamily = newEditorFontFamily;
|
m_editorFontFamily = newEditorFontFamily;
|
||||||
_setUnsavedEditor.setFlag(SETTING_ITEM::FONT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,102 +28,60 @@ public:
|
||||||
enum SETTING { EDITOR = 1, CONSOLE = 2, ALL = EDITOR | CONSOLE };
|
enum SETTING { EDITOR = 1, CONSOLE = 2, ALL = EDITOR | CONSOLE };
|
||||||
Q_DECLARE_FLAGS(SETTINGS, SETTING)
|
Q_DECLARE_FLAGS(SETTINGS, SETTING)
|
||||||
|
|
||||||
private:
|
|
||||||
// Flags to indicate whether the modification has been made.
|
|
||||||
// There are a maximum of 32 flags,
|
|
||||||
// but it is impossible to have more than this.
|
|
||||||
enum class SETTING_ITEM : quint32 {
|
|
||||||
FONT = 1u,
|
|
||||||
FONT_SIZE = 1u << 1,
|
|
||||||
THEME = 1u << 2,
|
|
||||||
TAB_WIDTH = 1u << 3,
|
|
||||||
INDENTATION = 1u << 4,
|
|
||||||
WORD_WRAP = 1u << 5,
|
|
||||||
MATCH_BRACES = 1u << 6,
|
|
||||||
SHOW_LINENUMBER = 1u << 7,
|
|
||||||
SHOW_FOLDING = 1u << 8,
|
|
||||||
SHOW_INDENTGUIDES = 1u << 9,
|
|
||||||
SHOW_LONGLINEEDGE = 1u << 10,
|
|
||||||
SHOW_WHITESPACE = 1u << 11,
|
|
||||||
AUTO_CLOSE_CHAR = 1u << 12,
|
|
||||||
AUTO_IDEN = 1u << 13
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(SETTING_ITEMS, SETTING_ITEM)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ScriptSettings &instance();
|
static ScriptSettings &instance();
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void save(SETTINGS cat = SETTING::ALL);
|
|
||||||
void reset(SETTINGS cat = SETTING::ALL);
|
void reset(SETTINGS cat = SETTING::ALL);
|
||||||
|
|
||||||
void __reset(SETTINGS cat);
|
void __reset(SETTINGS cat);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString editorFontFamily() const;
|
QString editorFontFamily() const;
|
||||||
void setEditorFontFamily(const QString &newEditorFontFamily);
|
|
||||||
|
|
||||||
QString consoleFontFamily() const;
|
QString consoleFontFamily() const;
|
||||||
void setConsoleFontFamily(const QString &newConsoleFontFamily);
|
|
||||||
|
|
||||||
int editorFontSize() const;
|
int editorFontSize() const;
|
||||||
void setEditorFontSize(int newEditorfontSize);
|
|
||||||
|
|
||||||
int consoleFontSize() const;
|
int consoleFontSize() const;
|
||||||
void setConsoleFontSize(int newConsolefontSize);
|
|
||||||
|
|
||||||
QString editorTheme() const;
|
QString editorTheme() const;
|
||||||
void setEditorTheme(const QString &newEditorTheme);
|
|
||||||
|
|
||||||
QString consoleTheme() const;
|
QString consoleTheme() const;
|
||||||
void setConsoleTheme(const QString &newConsoleTheme);
|
|
||||||
|
|
||||||
int editorTabWidth() const;
|
int editorTabWidth() const;
|
||||||
void setEditorTabWidth(int newEditorTabWidth);
|
|
||||||
|
|
||||||
int consoleTabWidth() const;
|
int consoleTabWidth() const;
|
||||||
void setConsoleTabWidth(int newConsoleTabWidth);
|
|
||||||
|
|
||||||
int editorInden() const;
|
int editorInden() const;
|
||||||
void setEditorInden(int newEditorInden);
|
|
||||||
|
|
||||||
int consoleInden() const;
|
int consoleInden() const;
|
||||||
void setConsoleInden(int newConsoleInden);
|
|
||||||
|
|
||||||
bool editorMatchBraces() const;
|
bool editorMatchBraces() const;
|
||||||
void setEditorMatchBraces(bool newEditorMatchBraces);
|
|
||||||
|
|
||||||
bool consoleMatchBraces() const;
|
bool consoleMatchBraces() const;
|
||||||
void setConsoleMatchBraces(bool newConsoleMatchBraces);
|
|
||||||
|
|
||||||
bool editorWordWrap() const;
|
bool editorWordWrap() const;
|
||||||
void setEditorWordWrap(bool newEditorWordWrap);
|
|
||||||
|
|
||||||
bool editorShowLineNumber() const;
|
bool editorShowLineNumber() const;
|
||||||
void setEditorShowLineNumber(bool newEditorShowLineNumber);
|
|
||||||
|
|
||||||
bool editorFolding() const;
|
bool editorFolding() const;
|
||||||
void setEditorFolding(bool newEditorFolding);
|
|
||||||
|
|
||||||
bool editorShowGuideLine() const;
|
bool editorShowGuideLine() const;
|
||||||
void setEditorShowGuideLine(bool newEditorShowGuidLine);
|
|
||||||
|
|
||||||
bool editorShowLineEdges() const;
|
bool editorShowLineEdges() const;
|
||||||
void setEditorShowLineEdges(bool newEditorShowLineEdges);
|
|
||||||
|
|
||||||
bool editorShowWhiteSpace() const;
|
bool editorShowWhiteSpace() const;
|
||||||
void setEditorShowWhiteSpace(bool newEditorShowWhiteSpace);
|
|
||||||
|
|
||||||
bool consoleShowWhiteSpace() const;
|
bool consoleShowWhiteSpace() const;
|
||||||
void setConsoleShowWhiteSpace(bool newConsoleShowWhiteSpace);
|
|
||||||
|
|
||||||
bool editorAutoCloseChar() const;
|
bool editorAutoCloseChar() const;
|
||||||
void setEditorAutoCloseChar(bool newEditorAutoCloseChar);
|
|
||||||
|
|
||||||
bool consoleAutoCloseChar() const;
|
bool consoleAutoCloseChar() const;
|
||||||
void setConsoleAutoCloseChar(bool newConsoleAutoCloseChar);
|
|
||||||
|
|
||||||
bool editorAutoIden() const;
|
bool editorAutoIden() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setEditorFontFamily(const QString &newEditorFontFamily);
|
||||||
|
void setConsoleFontFamily(const QString &newConsoleFontFamily);
|
||||||
|
void setEditorFontSize(int newEditorfontSize);
|
||||||
|
void setConsoleFontSize(int newConsolefontSize);
|
||||||
|
void setEditorTheme(const QString &newEditorTheme);
|
||||||
|
void setConsoleTheme(const QString &newConsoleTheme);
|
||||||
|
void setEditorTabWidth(int newEditorTabWidth);
|
||||||
|
void setConsoleTabWidth(int newConsoleTabWidth);
|
||||||
|
void setEditorInden(int newEditorInden);
|
||||||
|
void setConsoleInden(int newConsoleInden);
|
||||||
|
void setEditorMatchBraces(bool newEditorMatchBraces);
|
||||||
|
void setConsoleMatchBraces(bool newConsoleMatchBraces);
|
||||||
|
void setEditorWordWrap(bool newEditorWordWrap);
|
||||||
|
void setEditorShowLineNumber(bool newEditorShowLineNumber);
|
||||||
|
void setEditorFolding(bool newEditorFolding);
|
||||||
|
void setEditorShowGuideLine(bool newEditorShowGuidLine);
|
||||||
|
void setEditorShowLineEdges(bool newEditorShowLineEdges);
|
||||||
|
void setEditorShowWhiteSpace(bool newEditorShowWhiteSpace);
|
||||||
|
void setConsoleShowWhiteSpace(bool newConsoleShowWhiteSpace);
|
||||||
|
void setEditorAutoCloseChar(bool newEditorAutoCloseChar);
|
||||||
|
void setConsoleAutoCloseChar(bool newConsoleAutoCloseChar);
|
||||||
void setEditorAutoIden(bool newEditorAutoIden);
|
void setEditorAutoIden(bool newEditorAutoIden);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -167,10 +125,6 @@ private:
|
||||||
bool m_editorAutoCloseChar = true;
|
bool m_editorAutoCloseChar = true;
|
||||||
bool m_consoleAutoCloseChar = true;
|
bool m_consoleAutoCloseChar = true;
|
||||||
|
|
||||||
private:
|
|
||||||
SETTING_ITEMS _setUnsavedEditor;
|
|
||||||
SETTING_ITEMS _setUnsavedConsole;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(ScriptSettings)
|
Q_DISABLE_COPY_MOVE(ScriptSettings)
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,18 +25,6 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
#define WRITE_CONFIG_SET(config, dvalue) \
|
|
||||||
if (this->_setUnsaved.testFlag(SETTING_ITEM::config)) { \
|
|
||||||
WRITE_CONFIG(config, dvalue); \
|
|
||||||
_setUnsaved.setFlag(SettingManager::SETTING_ITEM::config, false); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define WRITE_CONFIG_RESET(config, dvalue) \
|
|
||||||
do { \
|
|
||||||
WRITE_CONFIG(config, dvalue); \
|
|
||||||
_setUnsaved.setFlag(SettingManager::SETTING_ITEM::config, false); \
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, DOCK_LAYOUT, ("dock.layout"))
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, DOCK_LAYOUT, ("dock.layout"))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, SCRIPT_DOCK_LAYOUT, ("script.layout"))
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, SCRIPT_DOCK_LAYOUT, ("script.layout"))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, APP_LASTUSED_PATH, ("app.lastusedpath"))
|
Q_GLOBAL_STATIC_WITH_ARGS(QString, APP_LASTUSED_PATH, ("app.lastusedpath"))
|
||||||
|
@ -89,7 +77,11 @@ SettingManager::SettingManager() {
|
||||||
QString SettingManager::lastUsedPath() const { return m_lastUsedPath; }
|
QString SettingManager::lastUsedPath() const { return m_lastUsedPath; }
|
||||||
|
|
||||||
void SettingManager::setLastUsedPath(const QString &newLastUsedPath) {
|
void SettingManager::setLastUsedPath(const QString &newLastUsedPath) {
|
||||||
m_lastUsedPath = newLastUsedPath;
|
if (m_lastUsedPath != newLastUsedPath) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(APP_LASTUSED_PATH, newLastUsedPath);
|
||||||
|
m_lastUsedPath = newLastUsedPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::load() {
|
void SettingManager::load() {
|
||||||
|
@ -200,15 +192,20 @@ int SettingManager::scriptTimeout() const { return m_scriptTimeout; }
|
||||||
void SettingManager::setScriptTimeout(int newScriptTimeout) {
|
void SettingManager::setScriptTimeout(int newScriptTimeout) {
|
||||||
newScriptTimeout = qBound(0, newScriptTimeout, 312480);
|
newScriptTimeout = qBound(0, newScriptTimeout, 312480);
|
||||||
if (m_scriptTimeout != newScriptTimeout) {
|
if (m_scriptTimeout != newScriptTimeout) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_TIMEOUT, newScriptTimeout);
|
||||||
m_scriptTimeout = newScriptTimeout;
|
m_scriptTimeout = newScriptTimeout;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_TIMEOUT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qsizetype SettingManager::logCount() const { return m_logCount; }
|
qsizetype SettingManager::logCount() const { return m_logCount; }
|
||||||
|
|
||||||
void SettingManager::setLogCount(qsizetype newLogCount) {
|
void SettingManager::setLogCount(qsizetype newLogCount) {
|
||||||
m_logCount = newLogCount;
|
if (m_logCount != newLogCount) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(OTHER_LOG_COUNT, newLogCount);
|
||||||
|
m_logCount = newLogCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::checkWriteableAndWarn() {
|
void SettingManager::checkWriteableAndWarn() {
|
||||||
|
@ -222,15 +219,20 @@ void SettingManager::checkWriteableAndWarn() {
|
||||||
bool SettingManager::checkUpdate() const { return m_checkUpdate; }
|
bool SettingManager::checkUpdate() const { return m_checkUpdate; }
|
||||||
|
|
||||||
void SettingManager::setCheckUpdate(bool newCheckUpdate) {
|
void SettingManager::setCheckUpdate(bool newCheckUpdate) {
|
||||||
m_checkUpdate = newCheckUpdate;
|
if (m_checkUpdate != newCheckUpdate) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(OTHER_CHECK_UPDATE, newCheckUpdate);
|
||||||
|
m_checkUpdate = newCheckUpdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingManager::dontUseSplash() const { return m_dontUseSplash; }
|
bool SettingManager::dontUseSplash() const { return m_dontUseSplash; }
|
||||||
|
|
||||||
void SettingManager::setDontUseSplash(bool newDontUseSplash) {
|
void SettingManager::setDontUseSplash(bool newDontUseSplash) {
|
||||||
if (m_dontUseSplash != newDontUseSplash) {
|
if (m_dontUseSplash != newDontUseSplash) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(OTHER_DONT_USE_SPLASH, newDontUseSplash);
|
||||||
m_dontUseSplash = newDontUseSplash;
|
m_dontUseSplash = newDontUseSplash;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::OTHER_DONT_USE_SPLASH);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,8 +240,9 @@ bool SettingManager::scriptEnabled() const { return m_scriptEnabled; }
|
||||||
|
|
||||||
void SettingManager::setScriptEnabled(bool newScriptEnabled) {
|
void SettingManager::setScriptEnabled(bool newScriptEnabled) {
|
||||||
if (m_scriptEnabled != newScriptEnabled) {
|
if (m_scriptEnabled != newScriptEnabled) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_ENABLE, newScriptEnabled);
|
||||||
m_scriptEnabled = newScriptEnabled;
|
m_scriptEnabled = newScriptEnabled;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_ENABLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,22 +252,25 @@ bool SettingManager::allowUsrScriptInRoot() const {
|
||||||
|
|
||||||
void SettingManager::setAllowUsrScriptInRoot(bool newAllowUsrScriptInRoot) {
|
void SettingManager::setAllowUsrScriptInRoot(bool newAllowUsrScriptInRoot) {
|
||||||
if (m_allowUsrScriptInRoot != newAllowUsrScriptInRoot) {
|
if (m_allowUsrScriptInRoot != newAllowUsrScriptInRoot) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_ALLOW_USRSCRIPT_INROOT, newAllowUsrScriptInRoot);
|
||||||
m_allowUsrScriptInRoot = newAllowUsrScriptInRoot;
|
m_allowUsrScriptInRoot = newAllowUsrScriptInRoot;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_ALLOW_USRSCRIPT_INROOT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::setUsrHideCats(const QStringList &newUsrHideCats) {
|
void SettingManager::setUsrHideCats(const QStringList &newUsrHideCats) {
|
||||||
if (m_usrHideCats != newUsrHideCats) {
|
if (m_usrHideCats != newUsrHideCats) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_USRHIDECATS, newUsrHideCats);
|
||||||
m_usrHideCats = newUsrHideCats;
|
m_usrHideCats = newUsrHideCats;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_USRHIDECATS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::setSysHideCats(const QStringList &newSysHideCats) {
|
void SettingManager::setSysHideCats(const QStringList &newSysHideCats) {
|
||||||
if (m_sysHideCats != newSysHideCats) {
|
if (m_sysHideCats != newSysHideCats) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_SYSHIDECATS, newSysHideCats);
|
||||||
m_sysHideCats = newSysHideCats;
|
m_sysHideCats = newSysHideCats;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_SYSHIDECATS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,8 +278,9 @@ int SettingManager::logLevel() const { return m_logLevel; }
|
||||||
|
|
||||||
void SettingManager::setLogLevel(int newLogLevel) {
|
void SettingManager::setLogLevel(int newLogLevel) {
|
||||||
if (m_logLevel != newLogLevel) {
|
if (m_logLevel != newLogLevel) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(OTHER_LOG_LEVEL, newLogLevel);
|
||||||
m_logLevel = newLogLevel;
|
m_logLevel = newLogLevel;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::OTHER_LOG_LEVEL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,8 +288,9 @@ bool SettingManager::useNativeTitleBar() const { return m_useNativeTitleBar; }
|
||||||
|
|
||||||
void SettingManager::setUseNativeTitleBar(bool newUseNativeTitleBar) {
|
void SettingManager::setUseNativeTitleBar(bool newUseNativeTitleBar) {
|
||||||
if (m_useNativeTitleBar != newUseNativeTitleBar) {
|
if (m_useNativeTitleBar != newUseNativeTitleBar) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(OTHER_USE_NATIVE_TITLEBAR, newUseNativeTitleBar);
|
||||||
m_useNativeTitleBar = newUseNativeTitleBar;
|
m_useNativeTitleBar = newUseNativeTitleBar;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::OTHER_USE_NATIVE_TITLEBAR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,8 +300,9 @@ bool SettingManager::useNativeFileDialog() const {
|
||||||
|
|
||||||
void SettingManager::setUseNativeFileDialog(bool newUseNativeFileDialog) {
|
void SettingManager::setUseNativeFileDialog(bool newUseNativeFileDialog) {
|
||||||
if (m_useNativeFileDialog != newUseNativeFileDialog) {
|
if (m_useNativeFileDialog != newUseNativeFileDialog) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(OTHER_USESYS_FILEDIALOG, newUseNativeFileDialog);
|
||||||
m_useNativeFileDialog = newUseNativeFileDialog;
|
m_useNativeFileDialog = newUseNativeFileDialog;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::OTHER_USESYS_FILEDIALOG);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,8 +313,9 @@ QByteArray SettingManager::scriptDockLayout() const {
|
||||||
void SettingManager::setScriptDockLayout(
|
void SettingManager::setScriptDockLayout(
|
||||||
const QByteArray &newScriptDockLayout) {
|
const QByteArray &newScriptDockLayout) {
|
||||||
if (m_scriptDockLayout != newScriptDockLayout) {
|
if (m_scriptDockLayout != newScriptDockLayout) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_DOCK_LAYOUT, newScriptDockLayout);
|
||||||
m_scriptDockLayout = newScriptDockLayout;
|
m_scriptDockLayout = newScriptDockLayout;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_DOCK_LAYOUT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,8 +330,9 @@ QList<RecentFileManager::RecentInfo> SettingManager::recentScriptFiles() const {
|
||||||
void SettingManager::setRecentScriptFiles(
|
void SettingManager::setRecentScriptFiles(
|
||||||
const QList<RecentFileManager::RecentInfo> &newRecentScriptFiles) {
|
const QList<RecentFileManager::RecentInfo> &newRecentScriptFiles) {
|
||||||
if (m_recentScriptFiles != newRecentScriptFiles) {
|
if (m_recentScriptFiles != newRecentScriptFiles) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SCRIPT_RECENTFILES, getVarList(newRecentScriptFiles));
|
||||||
m_recentScriptFiles = newRecentScriptFiles;
|
m_recentScriptFiles = newRecentScriptFiles;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SCRIPT_RECENTFILES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,8 +340,9 @@ QString SettingManager::appFontFamily() const { return m_appFontFamily; }
|
||||||
|
|
||||||
void SettingManager::setAppFontFamily(const QString &newAppFontFamily) {
|
void SettingManager::setAppFontFamily(const QString &newAppFontFamily) {
|
||||||
if (m_appFontFamily != newAppFontFamily) {
|
if (m_appFontFamily != newAppFontFamily) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(APP_FONTFAMILY, newAppFontFamily);
|
||||||
m_appFontFamily = newAppFontFamily;
|
m_appFontFamily = newAppFontFamily;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::APP_FONTFAMILY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,8 +350,9 @@ bool SettingManager::editorShowHeader() const { return m_editorShowHeader; }
|
||||||
|
|
||||||
void SettingManager::setEditorShowHeader(bool newEditorShowAddr) {
|
void SettingManager::setEditorShowHeader(bool newEditorShowAddr) {
|
||||||
if (m_editorShowHeader != newEditorShowAddr) {
|
if (m_editorShowHeader != newEditorShowAddr) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_SHOW_ADDR, newEditorShowAddr);
|
||||||
m_editorShowHeader = newEditorShowAddr;
|
m_editorShowHeader = newEditorShowAddr;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_SHOW_ADDR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,8 +360,9 @@ bool SettingManager::enablePlugin() const { return m_enablePlugin; }
|
||||||
|
|
||||||
void SettingManager::setEnablePlugin(bool newEnablePlugin) {
|
void SettingManager::setEnablePlugin(bool newEnablePlugin) {
|
||||||
if (m_enablePlugin != newEnablePlugin) {
|
if (m_enablePlugin != newEnablePlugin) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(PLUGIN_ENABLE, newEnablePlugin);
|
||||||
m_enablePlugin = newEnablePlugin;
|
m_enablePlugin = newEnablePlugin;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::PLUGIN_ENABLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,8 +373,9 @@ QList<RecentFileManager::RecentInfo> SettingManager::recentHexFiles() const {
|
||||||
void SettingManager::setRecentFiles(
|
void SettingManager::setRecentFiles(
|
||||||
const QList<RecentFileManager::RecentInfo> &newRecentFiles) {
|
const QList<RecentFileManager::RecentInfo> &newRecentFiles) {
|
||||||
if (m_recentHexFiles != newRecentFiles) {
|
if (m_recentHexFiles != newRecentFiles) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_RECENTFILES, getVarList(newRecentFiles));
|
||||||
m_recentHexFiles = newRecentFiles;
|
m_recentHexFiles = newRecentFiles;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_RECENTFILES);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,53 +394,9 @@ void SettingManager::setDefaultWinState(Qt::WindowState newDefaultWinState) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m_defaultWinState != newDefaultWinState) {
|
if (m_defaultWinState != newDefaultWinState) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(APP_WINDOWSIZE, newDefaultWinState);
|
||||||
m_defaultWinState = newDefaultWinState;
|
m_defaultWinState = newDefaultWinState;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::APP_WINDOWSIZE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingManager::save(SETTINGS cat) {
|
|
||||||
HANDLE_CONFIG;
|
|
||||||
WRITE_CONFIG_SET(DOCK_LAYOUT, m_dockLayout);
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_DOCK_LAYOUT, m_scriptDockLayout);
|
|
||||||
WRITE_CONFIG_SET(EDITOR_RECENTFILES, getVarList(m_recentHexFiles));
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_RECENTFILES, getVarList(m_recentScriptFiles));
|
|
||||||
WRITE_CONFIG_SET(APP_LASTUSED_PATH, m_lastUsedPath);
|
|
||||||
if (cat.testFlag(SETTING::APP)) {
|
|
||||||
WRITE_CONFIG_SET(SKIN_THEME, m_themeID);
|
|
||||||
WRITE_CONFIG_SET(APP_LANGUAGE, m_defaultLang);
|
|
||||||
WRITE_CONFIG_SET(APP_FONTFAMILY, m_appFontFamily);
|
|
||||||
WRITE_CONFIG_SET(APP_FONTSIZE, m_appfontSize);
|
|
||||||
WRITE_CONFIG_SET(APP_WINDOWSIZE, m_defaultWinState);
|
|
||||||
}
|
|
||||||
if (cat.testFlag(SETTING::PLUGIN)) {
|
|
||||||
WRITE_CONFIG_SET(PLUGIN_ENABLE, m_enablePlugin);
|
|
||||||
WRITE_CONFIG_SET(PLUGIN_ENABLE_ROOT, m_enablePlgInRoot);
|
|
||||||
}
|
|
||||||
if (cat.testFlag(SETTING::EDITOR)) {
|
|
||||||
WRITE_CONFIG_SET(EDITOR_FONTSIZE, m_editorfontSize);
|
|
||||||
WRITE_CONFIG_SET(EDITOR_SHOW_ADDR, m_editorShowHeader);
|
|
||||||
WRITE_CONFIG_SET(EDITOR_SHOW_COL, m_editorShowcol);
|
|
||||||
WRITE_CONFIG_SET(EDITOR_SHOW_TEXT, m_editorShowtext);
|
|
||||||
WRITE_CONFIG_SET(EDITOR_COPY_LIMIT, m_copylimit);
|
|
||||||
WRITE_CONFIG_SET(EDITOR_DECSTRLIMIT, m_decodeStrlimit);
|
|
||||||
}
|
|
||||||
if (cat.testFlag(SETTING::SCRIPT)) {
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_ENABLE, m_scriptEnabled);
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_TIMEOUT, m_scriptTimeout);
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_ALLOW_USRSCRIPT_INROOT, m_allowUsrScriptInRoot);
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_USRHIDECATS, m_usrHideCats);
|
|
||||||
WRITE_CONFIG_SET(SCRIPT_SYSHIDECATS, m_sysHideCats);
|
|
||||||
}
|
|
||||||
if (cat.testFlag(SETTING::OTHER)) {
|
|
||||||
WRITE_CONFIG_SET(OTHER_USESYS_FILEDIALOG, m_useNativeFileDialog);
|
|
||||||
#ifdef WINGHEX_USE_FRAMELESS
|
|
||||||
WRITE_CONFIG_SET(OTHER_USE_NATIVE_TITLEBAR, m_useNativeTitleBar);
|
|
||||||
#endif
|
|
||||||
WRITE_CONFIG_SET(OTHER_DONT_USE_SPLASH, m_dontUseSplash);
|
|
||||||
WRITE_CONFIG_SET(OTHER_CHECK_UPDATE, m_checkUpdate);
|
|
||||||
WRITE_CONFIG_SET(OTHER_LOG_LEVEL, m_logLevel);
|
|
||||||
WRITE_CONFIG_SET(OTHER_LOG_COUNT, m_logCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,41 +408,41 @@ void SettingManager::reset(SETTINGS cat) {
|
||||||
void SettingManager::__reset(SETTINGS cat) {
|
void SettingManager::__reset(SETTINGS cat) {
|
||||||
HANDLE_CONFIG;
|
HANDLE_CONFIG;
|
||||||
if (cat.testFlag(SETTING::APP)) {
|
if (cat.testFlag(SETTING::APP)) {
|
||||||
WRITE_CONFIG_RESET(SKIN_THEME, 0);
|
WRITE_CONFIG(SKIN_THEME, 0);
|
||||||
WRITE_CONFIG_RESET(APP_LANGUAGE, QString());
|
WRITE_CONFIG(APP_LANGUAGE, QString());
|
||||||
WRITE_CONFIG_RESET(APP_FONTFAMILY, _defaultFont.family());
|
WRITE_CONFIG(APP_FONTFAMILY, _defaultFont.family());
|
||||||
WRITE_CONFIG_RESET(APP_FONTSIZE, _defaultFont.pointSize());
|
WRITE_CONFIG(APP_FONTSIZE, _defaultFont.pointSize());
|
||||||
WRITE_CONFIG_RESET(APP_WINDOWSIZE, Qt::WindowMaximized);
|
WRITE_CONFIG(APP_WINDOWSIZE, Qt::WindowMaximized);
|
||||||
}
|
}
|
||||||
if (cat.testFlag(SETTING::PLUGIN)) {
|
if (cat.testFlag(SETTING::PLUGIN)) {
|
||||||
WRITE_CONFIG_RESET(PLUGIN_ENABLE, true);
|
WRITE_CONFIG(PLUGIN_ENABLE, true);
|
||||||
WRITE_CONFIG_RESET(PLUGIN_ENABLE_ROOT, false);
|
WRITE_CONFIG(PLUGIN_ENABLE_ROOT, false);
|
||||||
}
|
}
|
||||||
if (cat.testFlag(SETTING::EDITOR)) {
|
if (cat.testFlag(SETTING::EDITOR)) {
|
||||||
WRITE_CONFIG_RESET(EDITOR_FONTSIZE, _defaultFont.pointSize());
|
WRITE_CONFIG(EDITOR_FONTSIZE, _defaultFont.pointSize());
|
||||||
WRITE_CONFIG_RESET(EDITOR_SHOW_ADDR, true);
|
WRITE_CONFIG(EDITOR_SHOW_ADDR, true);
|
||||||
WRITE_CONFIG_RESET(EDITOR_SHOW_COL, true);
|
WRITE_CONFIG(EDITOR_SHOW_COL, true);
|
||||||
WRITE_CONFIG_RESET(EDITOR_SHOW_TEXT, true);
|
WRITE_CONFIG(EDITOR_SHOW_TEXT, true);
|
||||||
WRITE_CONFIG_RESET(EDITOR_FIND_MAXCOUNT, 100);
|
WRITE_CONFIG(EDITOR_FIND_MAXCOUNT, 100);
|
||||||
WRITE_CONFIG_RESET(EDITOR_COPY_LIMIT, 100);
|
WRITE_CONFIG(EDITOR_COPY_LIMIT, 100);
|
||||||
WRITE_CONFIG_RESET(EDITOR_DECSTRLIMIT, 10);
|
WRITE_CONFIG(EDITOR_DECSTRLIMIT, 10);
|
||||||
}
|
}
|
||||||
if (cat.testFlag(SETTING::SCRIPT)) {
|
if (cat.testFlag(SETTING::SCRIPT)) {
|
||||||
WRITE_CONFIG_RESET(SCRIPT_ENABLE, true);
|
WRITE_CONFIG(SCRIPT_ENABLE, true);
|
||||||
WRITE_CONFIG_RESET(SCRIPT_TIMEOUT, 10);
|
WRITE_CONFIG(SCRIPT_TIMEOUT, 10);
|
||||||
WRITE_CONFIG_RESET(SCRIPT_ALLOW_USRSCRIPT_INROOT, false);
|
WRITE_CONFIG(SCRIPT_ALLOW_USRSCRIPT_INROOT, false);
|
||||||
WRITE_CONFIG_RESET(SCRIPT_USRHIDECATS, QStringList());
|
WRITE_CONFIG(SCRIPT_USRHIDECATS, QStringList());
|
||||||
WRITE_CONFIG_RESET(SCRIPT_SYSHIDECATS, QStringList());
|
WRITE_CONFIG(SCRIPT_SYSHIDECATS, QStringList());
|
||||||
}
|
}
|
||||||
if (cat.testFlag(SETTING::OTHER)) {
|
if (cat.testFlag(SETTING::OTHER)) {
|
||||||
WRITE_CONFIG_RESET(OTHER_USESYS_FILEDIALOG, true);
|
WRITE_CONFIG(OTHER_USESYS_FILEDIALOG, true);
|
||||||
#ifdef WINGHEX_USE_FRAMELESS
|
#ifdef WINGHEX_USE_FRAMELESS
|
||||||
WRITE_CONFIG_RESET(OTHER_USE_NATIVE_TITLEBAR, false);
|
WRITE_CONFIG(OTHER_USE_NATIVE_TITLEBAR, false);
|
||||||
#endif
|
#endif
|
||||||
WRITE_CONFIG_RESET(OTHER_DONT_USE_SPLASH, false);
|
WRITE_CONFIG(OTHER_DONT_USE_SPLASH, false);
|
||||||
WRITE_CONFIG_RESET(OTHER_CHECK_UPDATE, false);
|
WRITE_CONFIG(OTHER_CHECK_UPDATE, false);
|
||||||
WRITE_CONFIG_RESET(OTHER_LOG_LEVEL, Logger::defaultLevel());
|
WRITE_CONFIG(OTHER_LOG_LEVEL, Logger::defaultLevel());
|
||||||
WRITE_CONFIG_RESET(OTHER_LOG_COUNT, 20);
|
WRITE_CONFIG(OTHER_LOG_COUNT, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,8 +452,9 @@ void SettingManager::setDecodeStrlimit(qsizetype newDecodeStrlimit) {
|
||||||
newDecodeStrlimit =
|
newDecodeStrlimit =
|
||||||
qBound(qsizetype(100), newDecodeStrlimit, qsizetype(1024));
|
qBound(qsizetype(100), newDecodeStrlimit, qsizetype(1024));
|
||||||
if (m_decodeStrlimit != newDecodeStrlimit) {
|
if (m_decodeStrlimit != newDecodeStrlimit) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_DECSTRLIMIT, newDecodeStrlimit);
|
||||||
m_decodeStrlimit = newDecodeStrlimit;
|
m_decodeStrlimit = newDecodeStrlimit;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_DECSTRLIMIT);
|
|
||||||
Q_EMIT sigDecodeStrlimitChanged(m_decodeStrlimit);
|
Q_EMIT sigDecodeStrlimitChanged(m_decodeStrlimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,8 +464,9 @@ qsizetype SettingManager::copylimit() const { return m_copylimit; }
|
||||||
void SettingManager::setCopylimit(qsizetype newCopylimit) {
|
void SettingManager::setCopylimit(qsizetype newCopylimit) {
|
||||||
newCopylimit = qBound(qsizetype(100), newCopylimit, qsizetype(1024));
|
newCopylimit = qBound(qsizetype(100), newCopylimit, qsizetype(1024));
|
||||||
if (m_copylimit != newCopylimit) {
|
if (m_copylimit != newCopylimit) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_COPY_LIMIT, newCopylimit);
|
||||||
m_copylimit = newCopylimit;
|
m_copylimit = newCopylimit;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_COPY_LIMIT);
|
|
||||||
Q_EMIT sigDecodeStrlimitChanged(m_copylimit);
|
Q_EMIT sigDecodeStrlimitChanged(m_copylimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,8 +475,9 @@ bool SettingManager::editorShowtext() const { return m_editorShowtext; }
|
||||||
|
|
||||||
void SettingManager::setEditorShowtext(bool newEditorShowtext) {
|
void SettingManager::setEditorShowtext(bool newEditorShowtext) {
|
||||||
if (m_editorShowtext != newEditorShowtext) {
|
if (m_editorShowtext != newEditorShowtext) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_SHOW_TEXT, newEditorShowtext);
|
||||||
m_editorShowtext = newEditorShowtext;
|
m_editorShowtext = newEditorShowtext;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_SHOW_TEXT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,8 +485,9 @@ bool SettingManager::editorShowcol() const { return m_editorShowcol; }
|
||||||
|
|
||||||
void SettingManager::setEditorShowcol(bool newEditorShowcol) {
|
void SettingManager::setEditorShowcol(bool newEditorShowcol) {
|
||||||
if (m_editorShowcol != newEditorShowcol) {
|
if (m_editorShowcol != newEditorShowcol) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_SHOW_COL, newEditorShowcol);
|
||||||
m_editorShowcol = newEditorShowcol;
|
m_editorShowcol = newEditorShowcol;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_SHOW_COL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,8 +495,9 @@ int SettingManager::editorfontSize() const { return m_editorfontSize; }
|
||||||
|
|
||||||
void SettingManager::setEditorfontSize(int newEditorfontSize) {
|
void SettingManager::setEditorfontSize(int newEditorfontSize) {
|
||||||
if (m_editorfontSize != newEditorfontSize) {
|
if (m_editorfontSize != newEditorfontSize) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(EDITOR_FONTSIZE, newEditorfontSize);
|
||||||
m_editorfontSize = newEditorfontSize;
|
m_editorfontSize = newEditorfontSize;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_FONTSIZE);
|
|
||||||
Q_EMIT sigEditorfontSizeChanged(newEditorfontSize);
|
Q_EMIT sigEditorfontSizeChanged(newEditorfontSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,8 +506,9 @@ int SettingManager::appfontSize() const { return m_appfontSize; }
|
||||||
|
|
||||||
void SettingManager::setAppfontSize(int newAppfontSize) {
|
void SettingManager::setAppfontSize(int newAppfontSize) {
|
||||||
if (m_appfontSize != newAppfontSize) {
|
if (m_appfontSize != newAppfontSize) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(APP_FONTSIZE, newAppfontSize);
|
||||||
m_appfontSize = newAppfontSize;
|
m_appfontSize = newAppfontSize;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::APP_FONTSIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,8 +516,9 @@ bool SettingManager::enablePlgInRoot() const { return m_enablePlgInRoot; }
|
||||||
|
|
||||||
void SettingManager::setEnablePlgInRoot(bool newEnablePlgInRoot) {
|
void SettingManager::setEnablePlgInRoot(bool newEnablePlgInRoot) {
|
||||||
if (m_enablePlgInRoot != newEnablePlgInRoot) {
|
if (m_enablePlgInRoot != newEnablePlgInRoot) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(PLUGIN_ENABLE_ROOT, newEnablePlgInRoot);
|
||||||
m_enablePlgInRoot = newEnablePlgInRoot;
|
m_enablePlgInRoot = newEnablePlgInRoot;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::PLUGIN_ENABLE_ROOT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,8 +526,9 @@ QString SettingManager::defaultLang() const { return m_defaultLang; }
|
||||||
|
|
||||||
void SettingManager::setDefaultLang(const QString &newDefaultLang) {
|
void SettingManager::setDefaultLang(const QString &newDefaultLang) {
|
||||||
if (m_defaultLang != newDefaultLang) {
|
if (m_defaultLang != newDefaultLang) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(APP_LANGUAGE, newDefaultLang);
|
||||||
m_defaultLang = newDefaultLang;
|
m_defaultLang = newDefaultLang;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::APP_LANGUAGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,8 +543,9 @@ QByteArray SettingManager::dockLayout() const { return m_dockLayout; }
|
||||||
|
|
||||||
void SettingManager::setDockLayout(const QByteArray &newDockLayout) {
|
void SettingManager::setDockLayout(const QByteArray &newDockLayout) {
|
||||||
if (m_dockLayout != newDockLayout) {
|
if (m_dockLayout != newDockLayout) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(DOCK_LAYOUT, newDockLayout);
|
||||||
m_dockLayout = newDockLayout;
|
m_dockLayout = newDockLayout;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::DOCK_LAYOUT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +553,8 @@ int SettingManager::themeID() const { return m_themeID; }
|
||||||
|
|
||||||
void SettingManager::setThemeID(int newThemeID) {
|
void SettingManager::setThemeID(int newThemeID) {
|
||||||
if (m_themeID != newThemeID) {
|
if (m_themeID != newThemeID) {
|
||||||
|
HANDLE_CONFIG;
|
||||||
|
WRITE_CONFIG(SKIN_THEME, newThemeID);
|
||||||
m_themeID = newThemeID;
|
m_themeID = newThemeID;
|
||||||
_setUnsaved.setFlag(SETTING_ITEM::SKIN_THEME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,141 +40,78 @@ public:
|
||||||
ALL = APP | PLUGIN | EDITOR | SCRIPT | OTHER
|
ALL = APP | PLUGIN | EDITOR | SCRIPT | OTHER
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(SETTINGS, SETTING)
|
Q_DECLARE_FLAGS(SETTINGS, SETTING)
|
||||||
private:
|
|
||||||
// Flags to indicate whether the modification has been made.
|
|
||||||
// There are a maximum of 32 flags,
|
|
||||||
// but it is impossible to have more than this.
|
|
||||||
enum class SETTING_ITEM : quint32 {
|
|
||||||
DOCK_LAYOUT = 1u,
|
|
||||||
SCRIPT_DOCK_LAYOUT = 1u << 1,
|
|
||||||
APP_LASTUSED_PATH = 1u << 2,
|
|
||||||
SKIN_THEME = 1u << 3,
|
|
||||||
APP_FONTFAMILY = 1u << 4,
|
|
||||||
APP_FONTSIZE = 1u << 5,
|
|
||||||
APP_WINDOWSIZE = 1u << 6,
|
|
||||||
APP_LANGUAGE = 1u << 7,
|
|
||||||
PLUGIN_ENABLE = 1u << 8,
|
|
||||||
PLUGIN_ENABLE_ROOT = 1u << 9,
|
|
||||||
EDITOR_FONTSIZE = 1u << 10,
|
|
||||||
EDITOR_SHOW_ADDR = 1u << 11,
|
|
||||||
EDITOR_SHOW_COL = 1u << 12,
|
|
||||||
EDITOR_SHOW_TEXT = 1u << 13,
|
|
||||||
SCRIPT_TIMEOUT = 1u << 14,
|
|
||||||
EDITOR_FIND_MAXCOUNT = 1u << 15,
|
|
||||||
EDITOR_COPY_LIMIT = 1u << 16,
|
|
||||||
EDITOR_DECSTRLIMIT = 1u << 17,
|
|
||||||
EDITOR_RECENTFILES = 1u << 18,
|
|
||||||
SCRIPT_RECENTFILES = 1u << 19,
|
|
||||||
SCRIPT_ENABLE = 1u << 20,
|
|
||||||
SCRIPT_ALLOW_USRSCRIPT_INROOT = 1u << 21,
|
|
||||||
SCRIPT_USRHIDECATS = 1u << 22,
|
|
||||||
SCRIPT_SYSHIDECATS = 1u << 23,
|
|
||||||
OTHER_USESYS_FILEDIALOG = 1u << 24,
|
|
||||||
OTHER_USE_NATIVE_TITLEBAR = 1u << 25,
|
|
||||||
OTHER_DONT_USE_SPLASH = 1u << 26,
|
|
||||||
OTHER_LOG_LEVEL = 1u << 27,
|
|
||||||
OTHER_CHECK_UPDATE = 1u << 28,
|
|
||||||
OTHER_LOG_COUNT = 1u << 29,
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(SETTING_ITEMS, SETTING_ITEM)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SettingManager &instance();
|
static SettingManager &instance();
|
||||||
|
virtual ~SettingManager();
|
||||||
~SettingManager();
|
|
||||||
|
|
||||||
QByteArray dockLayout() const;
|
QByteArray dockLayout() const;
|
||||||
void setDockLayout(const QByteArray &newDockLayout);
|
|
||||||
|
|
||||||
int themeID() const;
|
int themeID() const;
|
||||||
void setThemeID(int newThemeID);
|
|
||||||
|
|
||||||
QString defaultLang() const;
|
QString defaultLang() const;
|
||||||
void setDefaultLang(const QString &newDefaultLang);
|
|
||||||
|
|
||||||
bool enablePlgInRoot() const;
|
bool enablePlgInRoot() const;
|
||||||
void setEnablePlgInRoot(bool newEnablePlgInRoot);
|
|
||||||
|
|
||||||
int appfontSize() const;
|
int appfontSize() const;
|
||||||
void setAppfontSize(int newAppfontSize);
|
|
||||||
|
|
||||||
int editorfontSize() const;
|
int editorfontSize() const;
|
||||||
void setEditorfontSize(int newEditorfontSize);
|
|
||||||
|
|
||||||
bool editorShowcol() const;
|
bool editorShowcol() const;
|
||||||
void setEditorShowcol(bool newEditorShowcol);
|
|
||||||
|
|
||||||
bool editorShowtext() const;
|
bool editorShowtext() const;
|
||||||
void setEditorShowtext(bool newEditorShowtext);
|
|
||||||
|
|
||||||
qsizetype copylimit() const;
|
qsizetype copylimit() const;
|
||||||
void setCopylimit(qsizetype newCopylimit);
|
|
||||||
|
|
||||||
qsizetype decodeStrlimit() const;
|
qsizetype decodeStrlimit() const;
|
||||||
void setDecodeStrlimit(qsizetype newDecodeStrlimit);
|
|
||||||
|
|
||||||
Qt::WindowState defaultWinState() const;
|
Qt::WindowState defaultWinState() const;
|
||||||
void setDefaultWinState(Qt::WindowState newDefaultWinState);
|
|
||||||
|
|
||||||
void save(SETTINGS cat = SETTING::ALL);
|
|
||||||
void reset(SETTINGS cat);
|
void reset(SETTINGS cat);
|
||||||
|
|
||||||
void __reset(SETTINGS cat);
|
void __reset(SETTINGS cat);
|
||||||
|
|
||||||
QList<RecentFileManager::RecentInfo> recentHexFiles() const;
|
QList<RecentFileManager::RecentInfo> recentHexFiles() const;
|
||||||
void
|
|
||||||
setRecentFiles(const QList<RecentFileManager::RecentInfo> &newRecentFiles);
|
|
||||||
|
|
||||||
bool enablePlugin() const;
|
bool enablePlugin() const;
|
||||||
void setEnablePlugin(bool newEnablePlugin);
|
|
||||||
|
|
||||||
bool editorShowHeader() const;
|
bool editorShowHeader() const;
|
||||||
void setEditorShowHeader(bool newEditorShowAddr);
|
|
||||||
|
|
||||||
QString appFontFamily() const;
|
QString appFontFamily() const;
|
||||||
void setAppFontFamily(const QString &newAppFontFamily);
|
|
||||||
|
|
||||||
QList<RecentFileManager::RecentInfo> recentScriptFiles() const;
|
QList<RecentFileManager::RecentInfo> recentScriptFiles() const;
|
||||||
void setRecentScriptFiles(
|
|
||||||
const QList<RecentFileManager::RecentInfo> &newRecentScriptFiles);
|
|
||||||
|
|
||||||
QStringList usrHideCats() const;
|
QStringList usrHideCats() const;
|
||||||
QStringList sysHideCats() const;
|
QStringList sysHideCats() const;
|
||||||
|
|
||||||
|
QString lastUsedPath() const;
|
||||||
|
QByteArray scriptDockLayout() const;
|
||||||
|
bool useNativeFileDialog() const;
|
||||||
|
bool useNativeTitleBar() const;
|
||||||
|
int logLevel() const;
|
||||||
|
bool allowUsrScriptInRoot() const;
|
||||||
|
bool scriptEnabled() const;
|
||||||
|
bool dontUseSplash() const;
|
||||||
|
bool checkUpdate() const;
|
||||||
|
qsizetype logCount() const;
|
||||||
|
int scriptTimeout() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setThemeID(int newThemeID);
|
||||||
|
void setDockLayout(const QByteArray &newDockLayout);
|
||||||
|
void setDefaultLang(const QString &newDefaultLang);
|
||||||
|
void setEnablePlgInRoot(bool newEnablePlgInRoot);
|
||||||
|
void setAppfontSize(int newAppfontSize);
|
||||||
|
void setEditorfontSize(int newEditorfontSize);
|
||||||
|
void setEditorShowcol(bool newEditorShowcol);
|
||||||
|
void setEditorShowtext(bool newEditorShowtext);
|
||||||
|
void setCopylimit(qsizetype newCopylimit);
|
||||||
|
void setDecodeStrlimit(qsizetype newDecodeStrlimit);
|
||||||
|
void setDefaultWinState(Qt::WindowState newDefaultWinState);
|
||||||
|
void
|
||||||
|
setRecentFiles(const QList<RecentFileManager::RecentInfo> &newRecentFiles);
|
||||||
|
void setEnablePlugin(bool newEnablePlugin);
|
||||||
|
void setEditorShowHeader(bool newEditorShowAddr);
|
||||||
|
void setAppFontFamily(const QString &newAppFontFamily);
|
||||||
|
void setRecentScriptFiles(
|
||||||
|
const QList<RecentFileManager::RecentInfo> &newRecentScriptFiles);
|
||||||
void setSysHideCats(const QStringList &newSysHideCats);
|
void setSysHideCats(const QStringList &newSysHideCats);
|
||||||
void setUsrHideCats(const QStringList &newUsrHideCats);
|
void setUsrHideCats(const QStringList &newUsrHideCats);
|
||||||
|
|
||||||
QString lastUsedPath() const;
|
|
||||||
void setLastUsedPath(const QString &newLastUsedPath);
|
void setLastUsedPath(const QString &newLastUsedPath);
|
||||||
|
|
||||||
QByteArray scriptDockLayout() const;
|
|
||||||
void setScriptDockLayout(const QByteArray &newScriptDockLayout);
|
void setScriptDockLayout(const QByteArray &newScriptDockLayout);
|
||||||
|
|
||||||
bool useNativeFileDialog() const;
|
|
||||||
void setUseNativeFileDialog(bool newUseNativeFileDialog);
|
void setUseNativeFileDialog(bool newUseNativeFileDialog);
|
||||||
|
|
||||||
bool useNativeTitleBar() const;
|
|
||||||
void setUseNativeTitleBar(bool newUseNativeTitleBar);
|
void setUseNativeTitleBar(bool newUseNativeTitleBar);
|
||||||
|
|
||||||
int logLevel() const;
|
|
||||||
void setLogLevel(int newLogLevel);
|
void setLogLevel(int newLogLevel);
|
||||||
|
|
||||||
bool allowUsrScriptInRoot() const;
|
|
||||||
void setAllowUsrScriptInRoot(bool newAllowUsrScriptInRoot);
|
void setAllowUsrScriptInRoot(bool newAllowUsrScriptInRoot);
|
||||||
|
|
||||||
bool scriptEnabled() const;
|
|
||||||
void setScriptEnabled(bool newScriptEnabled);
|
void setScriptEnabled(bool newScriptEnabled);
|
||||||
|
|
||||||
bool dontUseSplash() const;
|
|
||||||
void setDontUseSplash(bool newDontUseSplash);
|
void setDontUseSplash(bool newDontUseSplash);
|
||||||
|
|
||||||
bool checkUpdate() const;
|
|
||||||
void setCheckUpdate(bool newCheckUpdate);
|
void setCheckUpdate(bool newCheckUpdate);
|
||||||
|
|
||||||
qsizetype logCount() const;
|
|
||||||
void setLogCount(qsizetype newLogCount);
|
void setLogCount(qsizetype newLogCount);
|
||||||
|
|
||||||
int scriptTimeout() const;
|
|
||||||
void setScriptTimeout(int newScriptTimeout);
|
void setScriptTimeout(int newScriptTimeout);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -238,7 +175,6 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFont _defaultFont;
|
QFont _defaultFont;
|
||||||
SETTING_ITEMS _setUnsaved;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGMANAGER_H
|
#endif // SETTINGMANAGER_H
|
||||||
|
|
|
@ -293,7 +293,6 @@ MainWindow::MainWindow(SplashDialog *splash) : FramelessMainWindow() {
|
||||||
QMessageBox::critical(this, qAppName(),
|
QMessageBox::critical(this, qAppName(),
|
||||||
tr("ScriptEngineInitFailed"));
|
tr("ScriptEngineInitFailed"));
|
||||||
set.setScriptEnabled(false);
|
set.setScriptEnabled(false);
|
||||||
set.save(SettingManager::SCRIPT);
|
|
||||||
throw CrashCode::ScriptInitFailed;
|
throw CrashCode::ScriptInitFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4030,7 +4029,6 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
if (m_scriptDialog) {
|
if (m_scriptDialog) {
|
||||||
m_scriptDialog->saveDockLayout();
|
m_scriptDialog->saveDockLayout();
|
||||||
set.setRecentFiles(m_recentmanager->saveRecent());
|
set.setRecentFiles(m_recentmanager->saveRecent());
|
||||||
set.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginSystem::instance().destory();
|
PluginSystem::instance().destory();
|
||||||
|
|
|
@ -278,7 +278,6 @@ bool ScriptingDialog::about2Close() {
|
||||||
void ScriptingDialog::saveDockLayout() {
|
void ScriptingDialog::saveDockLayout() {
|
||||||
auto &set = SettingManager::instance();
|
auto &set = SettingManager::instance();
|
||||||
set.setScriptDockLayout(_savedLayout);
|
set.setScriptDockLayout(_savedLayout);
|
||||||
set.save(SettingManager::NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptingDialog::buildUpRibbonBar() {
|
void ScriptingDialog::buildUpRibbonBar() {
|
||||||
|
|
|
@ -23,21 +23,80 @@
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
SettingDialog::SettingDialog(QWidget *parent)
|
SettingDialog::SettingDialog(QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::SettingDialog) {
|
: QWidget(parent), ui(new Ui::SettingDialog) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
connect(ui->listWidget, &QListWidget::currentItemChanged, this,
|
||||||
|
[this](QListWidgetItem *current, QListWidgetItem *previous) {
|
||||||
|
if (previous) {
|
||||||
|
auto page = m_pages.at(
|
||||||
|
ui->listWidget->indexFromItem(current).row());
|
||||||
|
if (page->containUnsavedChanges()) {
|
||||||
|
auto ret = WingMessageBox::question(
|
||||||
|
this, tr("UnsavedChanges"),
|
||||||
|
tr("SaveChangesDiscardLeave?"));
|
||||||
|
if (ret == QMessageBox::Yes) {
|
||||||
|
page->discard();
|
||||||
|
} else {
|
||||||
|
ui->listWidget->setCurrentItem(previous);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (current) {
|
||||||
|
auto curpage = m_pages.at(
|
||||||
|
ui->listWidget->indexFromItem(current).row());
|
||||||
|
ui->stackedWidget->setCurrentWidget(curpage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->btnRestore, &QPushButton::clicked, this, [this]() {
|
||||||
|
auto idx = ui->listWidget->currentRow();
|
||||||
|
auto page = m_pages.at(idx);
|
||||||
|
page->restore();
|
||||||
|
});
|
||||||
|
|
||||||
_dialog = new FramelessDialogBase(parent);
|
_dialog = new FramelessDialogBase(parent);
|
||||||
_dialog->buildUpContent(this);
|
_dialog->buildUpContent(this);
|
||||||
_dialog->setWindowTitle(this->windowTitle());
|
_dialog->setWindowTitle(this->windowTitle());
|
||||||
connect(_dialog, &FramelessDialogBase::rejected, this, [=] {
|
|
||||||
for (auto &page : m_pages) {
|
ui->btnRestore->setStyleSheet(
|
||||||
page->cancel();
|
QStringLiteral("QToolButton::down-arrow { width:10px; height:10px; "
|
||||||
|
"subcontrol-position:right center; "
|
||||||
|
"subcontrol-origin:content; left: -2px;"));
|
||||||
|
auto menu = new QMenu(ui->btnRestore);
|
||||||
|
auto a = menu->addAction(tr("Restore current"));
|
||||||
|
connect(a, &QAction::triggered, this, [this]() {
|
||||||
|
auto ret = WingMessageBox::warning(this, tr("Restore"),
|
||||||
|
tr("RestoreCurPageSets?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (ret == QMessageBox::No) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto idx = ui->listWidget->currentRow();
|
||||||
|
if (idx > 0) {
|
||||||
|
auto page = m_pages.at(idx);
|
||||||
|
page->restore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
a = menu->addAction(tr("Restore all"));
|
||||||
|
connect(a, &QAction::triggered, this, [this]() {
|
||||||
|
auto ret =
|
||||||
|
WingMessageBox::critical(this, tr("Restore"), tr("RestoreAllSets?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (ret == QMessageBox::No) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto &p : m_pages) {
|
||||||
|
p->restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui->btnRestore->setMenu(menu);
|
||||||
|
|
||||||
Utilities::moveToCenter(this);
|
Utilities::moveToCenter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,47 +159,3 @@ void SettingDialog::toastTakeEffectReboot() {
|
||||||
tr("TakeEffectRestart"));
|
tr("TakeEffectRestart"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingDialog::on_buttonBox_clicked(QAbstractButton *button) {
|
|
||||||
auto btnbox = ui->buttonBox;
|
|
||||||
if (button == btnbox->button(QDialogButtonBox::Ok)) {
|
|
||||||
for (auto &page : m_pages) {
|
|
||||||
page->apply();
|
|
||||||
}
|
|
||||||
_dialog->done(1);
|
|
||||||
} else if (button == btnbox->button(QDialogButtonBox::Apply)) {
|
|
||||||
for (auto &page : m_pages) {
|
|
||||||
page->apply();
|
|
||||||
}
|
|
||||||
} else if (button == btnbox->button(QDialogButtonBox::RestoreDefaults)) {
|
|
||||||
auto index = ui->listWidget->currentRow();
|
|
||||||
if (index >= 0) {
|
|
||||||
m_pages.at(index)->reset();
|
|
||||||
}
|
|
||||||
toastTakeEffectReboot();
|
|
||||||
} else if (button == btnbox->button(QDialogButtonBox::Reset)) {
|
|
||||||
auto res = WingMessageBox::warning(
|
|
||||||
this, qAppName(),
|
|
||||||
tr("This will reset all settings. Are you sure to continue?"),
|
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
|
||||||
|
|
||||||
if (res == QMessageBox::No) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &page : m_pages) {
|
|
||||||
page->reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
toastTakeEffectReboot();
|
|
||||||
} else if (button == btnbox->button(QDialogButtonBox::Cancel)) {
|
|
||||||
for (auto &page : m_pages) {
|
|
||||||
page->cancel();
|
|
||||||
}
|
|
||||||
_dialog->done(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingDialog::on_listWidget_currentRowChanged(int currentRow) {
|
|
||||||
ui->stackedWidget->setCurrentWidget(m_pages.at(currentRow));
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,8 +31,9 @@ class SettingDialog : public QWidget {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SettingDialog(QWidget *parent = nullptr);
|
explicit SettingDialog(QWidget *parent = nullptr);
|
||||||
~SettingDialog();
|
virtual ~SettingDialog();
|
||||||
|
|
||||||
|
public:
|
||||||
void addPage(WingHex::SettingPage *page);
|
void addPage(WingHex::SettingPage *page);
|
||||||
void build(); // you can only call once
|
void build(); // you can only call once
|
||||||
void showConfig(int index = -1);
|
void showConfig(int index = -1);
|
||||||
|
@ -41,11 +42,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void toastTakeEffectReboot();
|
void toastTakeEffectReboot();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
|
||||||
|
|
||||||
void on_listWidget_currentRowChanged(int currentRow);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingDialog *ui;
|
Ui::SettingDialog *ui;
|
||||||
QList<WingHex::SettingPage *> m_pages;
|
QList<WingHex::SettingPage *> m_pages;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>750</width>
|
<width>700</width>
|
||||||
<height>800</height>
|
<height>750</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -23,45 +23,69 @@
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>:/img/general.png</normaloff>:/img/general.png</iconset>
|
<normaloff>:/img/general.png</normaloff>:/img/general.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="spacing">
|
<property name="leftMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="childrenCollapsible">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<bool>false</bool>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
</property>
|
<item>
|
||||||
<widget class="QListWidget" name="listWidget">
|
<widget class="QListWidget" name="listWidget">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>200</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionRectVisible">
|
<property name="selectionRectVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="btnRestore">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Restore</string>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::ToolButtonPopupMode::InstantPopup</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonStyle::ToolButtonTextOnly</enum>
|
||||||
|
</property>
|
||||||
|
<property name="arrowType">
|
||||||
|
<enum>Qt::ArrowType::DownArrow</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStackedWidget" name="stackedWidget"/>
|
<widget class="QStackedWidget" name="stackedWidget"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -10,20 +10,27 @@ ClangFormatSetDialog::ClangFormatSetDialog(QWidget *parent)
|
||||||
: WingHex::SettingPage(parent), ui(new Ui::ClangFormatSetDialog) {
|
: WingHex::SettingPage(parent), ui(new Ui::ClangFormatSetDialog) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
auto &clang = ClangFormatManager::instance();
|
auto clang = &ClangFormatManager::instance();
|
||||||
ui->cbStyle->addItems(clang.supportedStyles());
|
ui->cbStyle->addItems(clang->supportedStyles());
|
||||||
|
|
||||||
ui->leLocation->setText(ClangFormatManager::getProgramName());
|
ui->leLocation->setText(ClangFormatManager::getProgramName());
|
||||||
|
|
||||||
if (clang.exists()) {
|
if (clang->exists()) {
|
||||||
ui->lblClangPath->setText(clang.path());
|
ui->lblClangPath->setText(clang->path());
|
||||||
ui->lblClangPath->setToolTip(clang.path());
|
ui->lblClangPath->setToolTip(clang->path());
|
||||||
ui->lblClangVersion->setText(clang.version());
|
ui->lblClangVersion->setText(clang->version());
|
||||||
} else {
|
} else {
|
||||||
ui->lblClangPath->setStyleSheet(QStringLiteral("color:red"));
|
ui->lblClangPath->setStyleSheet(QStringLiteral("color:red"));
|
||||||
}
|
}
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
connect(ui->cbEnabled, &QCheckBox::toggled, clang,
|
||||||
|
&ClangFormatManager::setEnabled);
|
||||||
|
connect(ui->cbAutoFmt, &QCheckBox::toggled, clang,
|
||||||
|
&ClangFormatManager::setAutoFormat);
|
||||||
|
connect(ui->cbStyle, &QComboBox::currentTextChanged, clang,
|
||||||
|
&ClangFormatManager::setClangStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangFormatSetDialog::~ClangFormatSetDialog() { delete ui; }
|
ClangFormatSetDialog::~ClangFormatSetDialog() { delete ui; }
|
||||||
|
@ -59,21 +66,12 @@ QString ClangFormatSetDialog::id() const {
|
||||||
return QStringLiteral("ClangFormat");
|
return QStringLiteral("ClangFormat");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangFormatSetDialog::apply() {
|
void ClangFormatSetDialog::restore() {
|
||||||
auto &clang = ClangFormatManager::instance();
|
|
||||||
clang.setEnabled(ui->cbEnabled->isChecked());
|
|
||||||
clang.setAutoFormat(ui->cbAutoFmt->isChecked());
|
|
||||||
clang.setClangStyle(ui->cbStyle->currentText());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangFormatSetDialog::reset() {
|
|
||||||
auto &clang = ClangFormatManager::instance();
|
auto &clang = ClangFormatManager::instance();
|
||||||
clang.reset();
|
clang.reset();
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangFormatSetDialog::cancel() { reload(); }
|
|
||||||
|
|
||||||
void ClangFormatSetDialog::on_cbStyle_currentTextChanged(const QString &arg1) {
|
void ClangFormatSetDialog::on_cbStyle_currentTextChanged(const QString &arg1) {
|
||||||
ui->btnStyleCustom->setEnabled(arg1 == QStringLiteral("Custom"));
|
ui->btnStyleCustom->setEnabled(arg1 == QStringLiteral("Custom"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,7 @@ public:
|
||||||
|
|
||||||
// SettingPage interface
|
// SettingPage interface
|
||||||
public:
|
public:
|
||||||
virtual void apply() override;
|
virtual void restore() override;
|
||||||
virtual void reset() override;
|
|
||||||
virtual void cancel() override;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_cbStyle_currentTextChanged(const QString &arg1);
|
void on_cbStyle_currentTextChanged(const QString &arg1);
|
||||||
|
|
|
@ -18,16 +18,16 @@
|
||||||
<number>8</number>
|
<number>8</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="cbEnabled">
|
<widget class="QCheckBox" name="cbEnabled">
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
<string notr="true">-</string>
|
<string notr="true">-</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
<string notr="true">-</string>
|
<string notr="true">-</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
|
|
@ -25,6 +25,20 @@ EditorSettingDialog::EditorSettingDialog(QWidget *parent)
|
||||||
: WingHex::SettingPage(parent), ui(new Ui::EditorSettingDialog) {
|
: WingHex::SettingPage(parent), ui(new Ui::EditorSettingDialog) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
auto sm = &SettingManager::instance();
|
||||||
|
connect(ui->cbShowaddr, &QCheckBox::toggled, sm,
|
||||||
|
&SettingManager::setEditorShowHeader);
|
||||||
|
connect(ui->cbShowcol, &QCheckBox::toggled, sm,
|
||||||
|
&SettingManager::setEditorShowcol);
|
||||||
|
connect(ui->cbShowtext, &QCheckBox::toggled, sm,
|
||||||
|
&SettingManager::setEditorShowtext);
|
||||||
|
connect(ui->sbFontSize, &QSpinBox::valueChanged, sm,
|
||||||
|
&SettingManager::setEditorfontSize);
|
||||||
|
connect(ui->sbDecStrLimit, &QSpinBox::valueChanged, sm,
|
||||||
|
&SettingManager::setDecodeStrlimit);
|
||||||
|
connect(ui->sbCopyLimit, &QSpinBox::valueChanged, sm,
|
||||||
|
&SettingManager::setCopylimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorSettingDialog::~EditorSettingDialog() { delete ui; }
|
EditorSettingDialog::~EditorSettingDialog() { delete ui; }
|
||||||
|
@ -45,20 +59,7 @@ QString EditorSettingDialog::name() const { return tr("Editor"); }
|
||||||
|
|
||||||
QString EditorSettingDialog::id() const { return QStringLiteral("Editor"); }
|
QString EditorSettingDialog::id() const { return QStringLiteral("Editor"); }
|
||||||
|
|
||||||
void EditorSettingDialog::apply() {
|
void EditorSettingDialog::restore() {
|
||||||
auto &set = SettingManager::instance();
|
|
||||||
set.setEditorShowHeader(ui->cbShowaddr->isChecked());
|
|
||||||
set.setEditorShowcol(ui->cbShowcol->isChecked());
|
|
||||||
set.setEditorShowtext(ui->cbShowtext->isChecked());
|
|
||||||
set.setEditorfontSize(ui->sbFontSize->value());
|
|
||||||
set.setDecodeStrlimit(ui->sbDecStrLimit->value());
|
|
||||||
set.setCopylimit(ui->sbCopyLimit->value());
|
|
||||||
set.save(SettingManager::SETTING::EDITOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorSettingDialog::reset() {
|
|
||||||
SettingManager::instance().reset(SettingManager::SETTING::EDITOR);
|
SettingManager::instance().reset(SettingManager::SETTING::EDITOR);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorSettingDialog::cancel() { reload(); }
|
|
||||||
|
|
|
@ -42,9 +42,8 @@ public:
|
||||||
virtual QIcon categoryIcon() const override;
|
virtual QIcon categoryIcon() const override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override;
|
||||||
virtual void apply() override;
|
|
||||||
virtual void reset() override;
|
virtual void restore() override;
|
||||||
virtual void cancel() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITORSETTINGDIALOG_H
|
#endif // EDITORSETTINGDIALOG_H
|
||||||
|
|
|
@ -21,16 +21,16 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
|
|
@ -65,6 +65,34 @@ GeneralSettingDialog::GeneralSettingDialog(QWidget *parent)
|
||||||
this, &GeneralSettingDialog::optionNeedRestartChanged);
|
this, &GeneralSettingDialog::optionNeedRestartChanged);
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
auto sm = &SettingManager::instance();
|
||||||
|
connect(ui->cbLanguage, &QComboBox::currentIndexChanged, sm,
|
||||||
|
[this](int index) {
|
||||||
|
auto data = ui->cbLanguage->itemData(index).toString();
|
||||||
|
SettingManager::instance().setDefaultLang(data);
|
||||||
|
});
|
||||||
|
connect(ui->sbFontSize, &QSpinBox::valueChanged, sm,
|
||||||
|
&SettingManager::setAppfontSize);
|
||||||
|
connect(ui->cbFont, &QFontComboBox::currentTextChanged, sm,
|
||||||
|
&SettingManager::setAppFontFamily);
|
||||||
|
connect(ui->cbTheme, &QComboBox::currentIndexChanged, sm,
|
||||||
|
&SettingManager::setThemeID);
|
||||||
|
connect(ui->cbWinState, &QComboBox::currentIndexChanged, sm, [](int index) {
|
||||||
|
Qt::WindowState state;
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
state = Qt::WindowState::WindowNoState;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
state = Qt::WindowState::WindowMaximized;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
state = Qt::WindowState::WindowFullScreen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SettingManager::instance().setDefaultWinState(state);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralSettingDialog::~GeneralSettingDialog() { delete ui; }
|
GeneralSettingDialog::~GeneralSettingDialog() { delete ui; }
|
||||||
|
@ -117,32 +145,7 @@ QString GeneralSettingDialog::name() const { return tr("General"); }
|
||||||
|
|
||||||
QString GeneralSettingDialog::id() const { return QStringLiteral("General"); }
|
QString GeneralSettingDialog::id() const { return QStringLiteral("General"); }
|
||||||
|
|
||||||
void GeneralSettingDialog::apply() {
|
void GeneralSettingDialog::restore() {
|
||||||
auto &set = SettingManager::instance();
|
|
||||||
set.setDefaultLang(ui->cbLanguage->currentData().toString());
|
|
||||||
set.setAppfontSize(ui->sbFontSize->value());
|
|
||||||
set.setAppFontFamily(ui->cbFont->currentText());
|
|
||||||
set.setThemeID(ui->cbTheme->currentIndex());
|
|
||||||
auto s = ui->cbWinState->currentIndex();
|
|
||||||
Qt::WindowState state;
|
|
||||||
switch (s) {
|
|
||||||
case 0:
|
|
||||||
state = Qt::WindowState::WindowNoState;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
state = Qt::WindowState::WindowMaximized;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state = Qt::WindowState::WindowFullScreen;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
set.setDefaultWinState(state);
|
|
||||||
set.save(SettingManager::SETTING::APP);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralSettingDialog::reset() {
|
|
||||||
SettingManager::instance().reset(SettingManager::SETTING::APP);
|
SettingManager::instance().reset(SettingManager::SETTING::APP);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettingDialog::cancel() { reload(); }
|
|
||||||
|
|
|
@ -42,9 +42,8 @@ public:
|
||||||
virtual QIcon categoryIcon() const override;
|
virtual QIcon categoryIcon() const override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override;
|
||||||
virtual void apply() override;
|
|
||||||
virtual void reset() override;
|
virtual void restore() override;
|
||||||
virtual void cancel() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GENERALSETTINGDIALOG_H
|
#endif // GENERALSETTINGDIALOG_H
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
|
|
@ -64,6 +64,20 @@ OtherSettingsDialog::OtherSettingsDialog(QWidget *parent)
|
||||||
this, &OtherSettingsDialog::optionNeedRestartChanged);
|
this, &OtherSettingsDialog::optionNeedRestartChanged);
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
auto set = &SettingManager::instance();
|
||||||
|
connect(ui->cbDontShowSplash, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setDontUseSplash);
|
||||||
|
connect(ui->cbNativeFileDialog, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setUseNativeFileDialog);
|
||||||
|
#ifdef WINGHEX_USE_FRAMELESS
|
||||||
|
connect(ui->cbNativeTitile, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setUseNativeTitleBar);
|
||||||
|
#endif
|
||||||
|
connect(ui->cbCheckWhenStartup, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setCheckUpdate);
|
||||||
|
connect(ui->cbLogLevel, &QComboBox::currentIndexChanged, set,
|
||||||
|
&SettingManager::setLogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
OtherSettingsDialog::~OtherSettingsDialog() { delete ui; }
|
OtherSettingsDialog::~OtherSettingsDialog() { delete ui; }
|
||||||
|
@ -86,21 +100,7 @@ QString OtherSettingsDialog::name() const { return tr("Others"); }
|
||||||
|
|
||||||
QString OtherSettingsDialog::id() const { return QStringLiteral("Others"); }
|
QString OtherSettingsDialog::id() const { return QStringLiteral("Others"); }
|
||||||
|
|
||||||
void OtherSettingsDialog::apply() {
|
void OtherSettingsDialog::restore() {
|
||||||
auto &set = SettingManager::instance();
|
|
||||||
set.setDontUseSplash(ui->cbDontShowSplash->isChecked());
|
|
||||||
set.setUseNativeFileDialog(ui->cbNativeFileDialog->isChecked());
|
|
||||||
#ifdef WINGHEX_USE_FRAMELESS
|
|
||||||
set.setUseNativeTitleBar(ui->cbNativeTitile->isChecked());
|
|
||||||
#endif
|
|
||||||
set.setCheckUpdate(ui->cbCheckWhenStartup->isChecked());
|
|
||||||
set.setLogLevel(ui->cbLogLevel->currentIndex());
|
|
||||||
set.save(SettingManager::OTHER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OtherSettingsDialog::reset() {
|
|
||||||
SettingManager::instance().reset(SettingManager::SETTING::OTHER);
|
SettingManager::instance().reset(SettingManager::SETTING::OTHER);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OtherSettingsDialog::cancel() { reload(); }
|
|
||||||
|
|
|
@ -42,9 +42,8 @@ public:
|
||||||
virtual QIcon categoryIcon() const override;
|
virtual QIcon categoryIcon() const override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override;
|
||||||
virtual void apply() override;
|
|
||||||
virtual void reset() override;
|
virtual void restore() override;
|
||||||
virtual void cancel() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OTHERSETTINGSDIALOG_H
|
#endif // OTHERSETTINGSDIALOG_H
|
||||||
|
|
|
@ -14,6 +14,18 @@
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -117,7 +129,7 @@
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
|
|
@ -85,6 +85,12 @@ PluginSettingDialog::PluginSettingDialog(QWidget *parent)
|
||||||
} else {
|
} else {
|
||||||
ui->txtm->setText(tr("NoMonitorPlugin"));
|
ui->txtm->setText(tr("NoMonitorPlugin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto set = &SettingManager::instance();
|
||||||
|
connect(ui->cbEnablePlugin, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setEnablePlugin);
|
||||||
|
connect(ui->cbEnablePluginRoot, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setEnablePlgInRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginSettingDialog::~PluginSettingDialog() { delete ui; }
|
PluginSettingDialog::~PluginSettingDialog() { delete ui; }
|
||||||
|
@ -103,20 +109,11 @@ QString PluginSettingDialog::name() const { return tr("Plugin"); }
|
||||||
|
|
||||||
QString PluginSettingDialog::id() const { return QStringLiteral("Plugin"); }
|
QString PluginSettingDialog::id() const { return QStringLiteral("Plugin"); }
|
||||||
|
|
||||||
void PluginSettingDialog::apply() {
|
void PluginSettingDialog::restore() {
|
||||||
auto &set = SettingManager::instance();
|
|
||||||
set.setEnablePlugin(ui->cbEnablePlugin->isChecked());
|
|
||||||
set.setEnablePlgInRoot(ui->cbEnablePluginRoot->isChecked());
|
|
||||||
set.save(SettingManager::SETTING::PLUGIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginSettingDialog::reset() {
|
|
||||||
SettingManager::instance().reset(SettingManager::SETTING::PLUGIN);
|
SettingManager::instance().reset(SettingManager::SETTING::PLUGIN);
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginSettingDialog::cancel() { reload(); }
|
|
||||||
|
|
||||||
void PluginSettingDialog::on_devlist_currentRowChanged(int currentRow) {
|
void PluginSettingDialog::on_devlist_currentRowChanged(int currentRow) {
|
||||||
if (currentRow < 0) {
|
if (currentRow < 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -42,9 +42,8 @@ public:
|
||||||
virtual QIcon categoryIcon() const override;
|
virtual QIcon categoryIcon() const override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override;
|
||||||
virtual void apply() override;
|
|
||||||
virtual void reset() override;
|
virtual void restore() override;
|
||||||
virtual void cancel() override;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_devlist_currentRowChanged(int currentRow);
|
void on_devlist_currentRowChanged(int currentRow);
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
|
|
@ -173,70 +173,87 @@ QEditConfig::QEditConfig(bool isConsole, QWidget *w)
|
||||||
}
|
}
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
auto set = &ScriptSettings::instance();
|
||||||
|
if (m_isConsole) {
|
||||||
|
connect(ui->cbTheme, &QComboBox::currentIndexChanged, set, [this]() {
|
||||||
|
auto &set = ScriptSettings::instance();
|
||||||
|
if (ui->cbTheme->currentIndex() == 0) {
|
||||||
|
set.setConsoleTheme({});
|
||||||
|
} else {
|
||||||
|
set.setConsoleTheme(ui->cbTheme->currentText());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->cbFont, &QFontComboBox::currentFontChanged, set,
|
||||||
|
[](const QFont &font) {
|
||||||
|
ScriptSettings::instance().setConsoleFontFamily(
|
||||||
|
font.family());
|
||||||
|
});
|
||||||
|
connect(ui->spnFontSize, &QSpinBox::valueChanged, set,
|
||||||
|
&ScriptSettings::setConsoleFontSize);
|
||||||
|
connect(ui->spnTabWidth, &QSpinBox::valueChanged, set,
|
||||||
|
&ScriptSettings::setConsoleTabWidth);
|
||||||
|
connect(ui->cbIndentation, &QComboBox::currentIndexChanged, set,
|
||||||
|
[this](int index) {
|
||||||
|
auto data = ui->cbIndentation->itemData(index);
|
||||||
|
ScriptSettings::instance().setConsoleInden(data.toInt());
|
||||||
|
});
|
||||||
|
connect(ui->chkMatchBraces, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setConsoleMatchBraces);
|
||||||
|
connect(ui->chkShowWhitespace, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setConsoleShowWhiteSpace);
|
||||||
|
connect(ui->chkAutoCloseChar, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setConsoleAutoCloseChar);
|
||||||
|
} else {
|
||||||
|
connect(ui->cbTheme, &QComboBox::currentIndexChanged, set, [this]() {
|
||||||
|
auto &set = ScriptSettings::instance();
|
||||||
|
if (ui->cbTheme->currentIndex() == 0) {
|
||||||
|
set.setEditorTheme({});
|
||||||
|
} else {
|
||||||
|
set.setEditorTheme(ui->cbTheme->currentText());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->cbFont, &QFontComboBox::currentFontChanged, set,
|
||||||
|
[](const QFont &font) {
|
||||||
|
ScriptSettings::instance().setEditorFontFamily(
|
||||||
|
font.family());
|
||||||
|
});
|
||||||
|
connect(ui->spnFontSize, &QSpinBox::valueChanged, set,
|
||||||
|
&ScriptSettings::setEditorFontSize);
|
||||||
|
connect(ui->spnTabWidth, &QSpinBox::valueChanged, set,
|
||||||
|
&ScriptSettings::setEditorTabWidth);
|
||||||
|
connect(ui->cbIndentation, &QComboBox::currentIndexChanged, set,
|
||||||
|
[this](int index) {
|
||||||
|
auto data = ui->cbIndentation->itemData(index);
|
||||||
|
ScriptSettings::instance().setEditorInden(data.toInt());
|
||||||
|
});
|
||||||
|
connect(ui->chkMatchBraces, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorShowLineNumber);
|
||||||
|
connect(ui->chkShowFolding, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorFolding);
|
||||||
|
connect(ui->chkShowIndentGuides, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorShowGuideLine);
|
||||||
|
connect(ui->chkWordWrap, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorWordWrap);
|
||||||
|
connect(ui->chkLongLineEdge, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorShowLineEdges);
|
||||||
|
connect(ui->chkShowWhitespace, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorShowWhiteSpace);
|
||||||
|
connect(ui->chkAutoCloseChar, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorAutoCloseChar);
|
||||||
|
connect(ui->chkAutoIden, &QCheckBox::toggled, set,
|
||||||
|
&ScriptSettings::setEditorAutoIden);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QEditConfig::~QEditConfig() { delete ui; }
|
QEditConfig::~QEditConfig() { delete ui; }
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Apply changes
|
|
||||||
*/
|
|
||||||
void QEditConfig::apply() {
|
|
||||||
auto &set = ScriptSettings::instance();
|
|
||||||
if (m_isConsole) {
|
|
||||||
if (ui->cbTheme->currentIndex() == 0) {
|
|
||||||
set.setConsoleTheme({});
|
|
||||||
} else {
|
|
||||||
set.setConsoleTheme(ui->cbTheme->currentText());
|
|
||||||
}
|
|
||||||
|
|
||||||
set.setConsoleFontFamily(ui->cbFont->currentFont().family());
|
|
||||||
set.setConsoleFontSize(ui->spnFontSize->value());
|
|
||||||
set.setConsoleTabWidth(ui->spnTabWidth->value());
|
|
||||||
set.setConsoleInden(ui->cbIndentation->currentData().toInt());
|
|
||||||
|
|
||||||
set.setConsoleMatchBraces(ui->chkMatchBraces->isChecked());
|
|
||||||
set.setConsoleShowWhiteSpace(ui->chkShowWhitespace->isChecked());
|
|
||||||
set.setConsoleAutoCloseChar(ui->chkAutoCloseChar->isChecked());
|
|
||||||
} else {
|
|
||||||
if (ui->cbTheme->currentIndex() == 0) {
|
|
||||||
set.setEditorTheme({});
|
|
||||||
} else {
|
|
||||||
set.setEditorTheme(ui->cbTheme->currentText());
|
|
||||||
}
|
|
||||||
|
|
||||||
set.setEditorFontFamily(ui->cbFont->currentFont().family());
|
|
||||||
set.setEditorFontSize(ui->spnFontSize->value());
|
|
||||||
set.setEditorTabWidth(ui->spnTabWidth->value());
|
|
||||||
set.setEditorInden(ui->cbIndentation->currentData().toInt());
|
|
||||||
|
|
||||||
set.setEditorShowLineNumber(ui->chkShowLineNumber->isChecked());
|
|
||||||
set.setEditorFolding(ui->chkShowFolding->isChecked());
|
|
||||||
set.setEditorShowGuideLine(ui->chkShowIndentGuides->isChecked());
|
|
||||||
set.setEditorWordWrap(ui->chkWordWrap->isChecked());
|
|
||||||
set.setEditorShowLineEdges(ui->chkLongLineEdge->isChecked());
|
|
||||||
set.setEditorMatchBraces(ui->chkMatchBraces->isChecked());
|
|
||||||
set.setEditorShowWhiteSpace(ui->chkShowWhitespace->isChecked());
|
|
||||||
set.setEditorAutoCloseChar(ui->chkAutoCloseChar->isChecked());
|
|
||||||
set.setEditorAutoIden(ui->chkAutoIden->isChecked());
|
|
||||||
}
|
|
||||||
set.save(m_isConsole ? ScriptSettings::CONSOLE : ScriptSettings::EDITOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Reset the subcontrols to reflect the current settings
|
|
||||||
|
|
||||||
The name can be a bit misleading at first, it has been chosen
|
|
||||||
because it directly maps to the effect a "cancel" button would
|
|
||||||
have on the widget
|
|
||||||
*/
|
|
||||||
void QEditConfig::cancel() { reload(); }
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Restore default values for all subcontrols
|
\brief Restore default values for all subcontrols
|
||||||
|
|
||||||
\note The widgets are changed but these changes are NOT applied.
|
\note The widgets are changed but these changes are NOT applied.
|
||||||
*/
|
*/
|
||||||
void QEditConfig::reset() {
|
void QEditConfig::restore() {
|
||||||
auto &set = ScriptSettings::instance();
|
auto &set = ScriptSettings::instance();
|
||||||
set.reset(m_isConsole ? ScriptSettings::CONSOLE : ScriptSettings::EDITOR);
|
set.reset(m_isConsole ? ScriptSettings::CONSOLE : ScriptSettings::EDITOR);
|
||||||
reload();
|
reload();
|
||||||
|
|
|
@ -40,9 +40,8 @@ public:
|
||||||
virtual QIcon categoryIcon() const override;
|
virtual QIcon categoryIcon() const override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override;
|
||||||
virtual void apply() override;
|
|
||||||
virtual void cancel() override;
|
virtual void restore() override;
|
||||||
virtual void reset() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reload();
|
void reload();
|
||||||
|
|
|
@ -14,6 +14,18 @@
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SizeConstraint::SetMinAndMaxSize</enum>
|
<enum>QLayout::SizeConstraint::SetMinAndMaxSize</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
|
@ -38,6 +38,44 @@ ScriptSettingDialog::ScriptSettingDialog(QWidget *parent)
|
||||||
this, &ScriptSettingDialog::optionNeedRestartChanged);
|
this, &ScriptSettingDialog::optionNeedRestartChanged);
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
||||||
|
connect(ui->listWidget, &QListWidget::itemChanged, this,
|
||||||
|
[this](QListWidgetItem *item) {
|
||||||
|
auto var = item->data(Qt::UserRole);
|
||||||
|
if (var.isValid()) {
|
||||||
|
auto meta = var.value<ScriptManager::ScriptDirMeta>();
|
||||||
|
switch (item->checkState()) {
|
||||||
|
case Qt::Unchecked: {
|
||||||
|
if (meta.isSys) {
|
||||||
|
m_sysHideCats.append(meta.rawName);
|
||||||
|
} else {
|
||||||
|
m_usrHideCats.append(meta.rawName);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case Qt::Checked: {
|
||||||
|
if (meta.isSys) {
|
||||||
|
m_sysHideCats.removeOne(meta.rawName);
|
||||||
|
} else {
|
||||||
|
m_usrHideCats.removeOne(meta.rawName);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case Qt::PartiallyChecked:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &set = SettingManager::instance();
|
||||||
|
set.setUsrHideCats(m_sysHideCats);
|
||||||
|
set.setSysHideCats(m_usrHideCats);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto set = &SettingManager::instance();
|
||||||
|
connect(ui->cbEnable, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setScriptEnabled);
|
||||||
|
connect(ui->cbAllowUsrScript, &QCheckBox::toggled, set,
|
||||||
|
&SettingManager::setAllowUsrScriptInRoot);
|
||||||
|
connect(ui->sbTimeout, &QSpinBox::valueChanged, set,
|
||||||
|
&SettingManager::setScriptTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptSettingDialog::~ScriptSettingDialog() { delete ui; }
|
ScriptSettingDialog::~ScriptSettingDialog() { delete ui; }
|
||||||
|
@ -91,46 +129,12 @@ QString ScriptSettingDialog::name() const { return tr("Script"); }
|
||||||
|
|
||||||
QString ScriptSettingDialog::id() const { return QStringLiteral("Script"); }
|
QString ScriptSettingDialog::id() const { return QStringLiteral("Script"); }
|
||||||
|
|
||||||
void ScriptSettingDialog::apply() {
|
void ScriptSettingDialog::restore() {
|
||||||
QStringList usrHideCats;
|
|
||||||
QStringList sysHideCats;
|
|
||||||
|
|
||||||
auto total = ui->listWidget->count();
|
|
||||||
for (int i = 0; i < total; ++i) {
|
|
||||||
auto lw = ui->listWidget->item(i);
|
|
||||||
auto var = lw->data(Qt::UserRole);
|
|
||||||
if (var.isValid()) {
|
|
||||||
auto meta = var.value<ScriptManager::ScriptDirMeta>();
|
|
||||||
if (lw->checkState() == Qt::Unchecked) {
|
|
||||||
if (meta.isSys) {
|
|
||||||
sysHideCats << meta.rawName;
|
|
||||||
} else {
|
|
||||||
usrHideCats << meta.rawName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto &set = SettingManager::instance();
|
|
||||||
set.setScriptEnabled(ui->cbEnable->isChecked());
|
|
||||||
set.setAllowUsrScriptInRoot(ui->cbAllowUsrScript->isChecked());
|
|
||||||
set.setScriptTimeout(ui->sbTimeout->value());
|
|
||||||
set.setUsrHideCats(usrHideCats);
|
|
||||||
set.setSysHideCats(sysHideCats);
|
|
||||||
set.save(SettingManager::SCRIPT);
|
|
||||||
|
|
||||||
m_usrHideCats = usrHideCats;
|
|
||||||
m_sysHideCats = sysHideCats;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptSettingDialog::reset() {
|
|
||||||
auto &set = SettingManager::instance();
|
auto &set = SettingManager::instance();
|
||||||
set.reset(SettingManager::SCRIPT);
|
set.reset(SettingManager::SCRIPT);
|
||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptSettingDialog::cancel() { loadData(); }
|
|
||||||
|
|
||||||
void ScriptSettingDialog::on_btnRefresh_clicked() {
|
void ScriptSettingDialog::on_btnRefresh_clicked() {
|
||||||
ui->listWidget->clear();
|
ui->listWidget->clear();
|
||||||
ScriptManager::instance().refresh();
|
ScriptManager::instance().refresh();
|
||||||
|
|
|
@ -49,9 +49,8 @@ public:
|
||||||
virtual QIcon categoryIcon() const override;
|
virtual QIcon categoryIcon() const override;
|
||||||
virtual QString name() const override;
|
virtual QString name() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override;
|
||||||
virtual void apply() override;
|
|
||||||
virtual void reset() override;
|
virtual void restore() override;
|
||||||
virtual void cancel() override;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnRefresh_clicked();
|
void on_btnRefresh_clicked();
|
||||||
|
|
|
@ -14,6 +14,18 @@
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
Loading…
Reference in New Issue