RedPanda-CPP/RedPandaIDE/settings.h

1050 lines
33 KiB
C
Raw Normal View History

#ifndef SETTINGS_H
#define SETTINGS_H
#include <QSettings>
#include <vector>
#include <memory>
2021-06-07 11:02:03 +08:00
#include <QColor>
#include "qsynedit/SynEdit.h"
2021-04-15 11:18:14 +08:00
/**
* use the following command to get gcc's default bin/library folders:
* gcc -print-search-dirs
*/
2021-04-15 21:32:45 +08:00
#define SETTING_DIRS "Dirs"
#define SETTING_EDITOR "Editor"
2021-06-18 21:48:40 +08:00
#define SETTING_ENVIRONMENT "Environment"
2021-07-01 19:44:38 +08:00
#define SETTING_EXECUTOR "Executor"
2021-07-26 11:47:54 +08:00
#define SETTING_DEBUGGER "Debugger"
#define SETTING_HISTORY "History"
#define SETTING_UI "UI"
#define SETTING_CODE_COMPLETION "CodeCompletion"
2021-08-31 19:15:11 +08:00
#define SETTING_CODE_FORMATTER "CodeFormatter"
2021-04-15 21:32:45 +08:00
#define SETTING_COMPILTER_SETS "CompilerSets"
#define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex"
#define SETTING_COMPILTER_SETS_COUNT "count"
#define SETTING_COMPILTER_SET "CompilerSet_%1"
2021-04-13 11:23:37 +08:00
#define SETTING_EDITOR_DEFAULT_ENCODING "default_encoding"
#define SETTING_EDITOR_AUTO_INDENT "default_auto_indent"
2021-04-09 17:48:25 +08:00
2021-04-15 11:18:14 +08:00
extern const char ValueToChar[28];
class Settings;
typedef struct {
2021-04-15 11:18:14 +08:00
QString name; // language table index of "Generate debugging info"
QString section; // language table index of "C options"
bool isC;
bool isCpp; // True (C++ option?) - can be both C and C++ option...
bool isLinker; // Is it a linker param
int value; // True
2021-04-15 11:18:14 +08:00
QString setting; // "-g3"
QStringList choices; // replaces "Yes/No" standard choices (max 30 different choices)
} CompilerOption;
using PCompilerOption = std::shared_ptr<CompilerOption>;
2021-09-09 11:47:04 +08:00
using CompilerOptionList=QVector<std::shared_ptr<CompilerOption>>;
class Settings
{
2021-04-13 11:23:37 +08:00
private:
2021-04-15 11:18:14 +08:00
2021-04-13 11:23:37 +08:00
class _Base {
public:
explicit _Base(Settings* settings, const QString& groupName);
2021-06-07 11:02:03 +08:00
void beginGroup();
void endGroup();
void saveValue(const QString &key, const QVariant &value);
QVariant value(const QString &key, const QVariant& defaultValue);
bool boolValue(const QString &key, bool defaultValue);
int intValue(const QString &key, int defaultValue);
2021-08-01 23:24:37 +08:00
QStringList stringListValue(const QString &key, const QStringList& defaultValue=QStringList());
2021-06-07 11:02:03 +08:00
QColor colorValue(const QString &key, const QColor& defaultValue);
QString stringValue(const QString &key, const QString& defaultValue);
void save();
void load();
protected:
virtual void doSave() = 0;
virtual void doLoad() = 0;
2021-04-13 11:23:37 +08:00
protected:
Settings* mSettings;
QString mGroup;
};
2021-04-13 11:23:37 +08:00
public:
class Dirs: public _Base {
public:
2021-06-17 10:39:46 +08:00
enum class DataType {
None,
ColorSheme
};
2021-04-13 11:23:37 +08:00
explicit Dirs(Settings * settings);
QString app() const;
2021-09-16 12:03:10 +08:00
QString templateDir() const;
QString projectDir() const;
2021-06-17 10:39:46 +08:00
QString data(DataType dataType = DataType::None) const;
QString config(DataType dataType = DataType::None) const;
2021-06-07 11:02:03 +08:00
// _Base interface
protected:
void doSave() override;
void doLoad() override;
2021-04-13 11:23:37 +08:00
};
class Editor: public _Base {
public:
explicit Editor(Settings * settings);
QByteArray defaultEncoding();
2021-06-07 11:02:03 +08:00
void setDefaultEncoding(const QByteArray& value);
2021-04-13 11:23:37 +08:00
bool autoIndent();
2021-06-07 11:02:03 +08:00
void setAutoIndent(bool value);
bool addIndent() const;
void setAddIndent(bool addIndent);
bool tabToSpaces() const;
void setTabToSpaces(bool tabToSpaces);
int tabWidth() const;
void setTabWidth(int tabWidth);
bool showIndentLines() const;
void setShowIndentLines(bool showIndentLines);
QColor indentLineColor() const;
void setIndentLineColor(const QColor &indentLineColor);
bool enhanceHomeKey() const;
void setEnhanceHomeKey(bool enhanceHomeKey);
bool enhanceEndKey() const;
void setEnhanceEndKey(bool enhanceEndKey);
SynEditCaretType caretForInsert() const;
void setCaretForInsert(const SynEditCaretType &caretForInsert);
SynEditCaretType caretForOverwrite() const;
void setCaretForOverwrite(const SynEditCaretType &caretForOverwrite);
QColor caretColor() const;
void setCaretColor(const QColor &caretColor);
bool keepCaretX() const;
void setKeepCaretX(bool keepCaretX);
bool autoHideScrollbar() const;
void setAutoHideScrollbar(bool autoHideScrollbar);
bool scrollPastEof() const;
void setScrollPastEof(bool scrollPastEof);
bool scrollPastEol() const;
void setScrollPastEol(bool scrollPastEol);
bool scrollByOneLess() const;
void setScrollByOneLess(bool scrollByOneLess);
bool halfPageScroll() const;
void setHalfPageScroll(bool halfPageScroll);
QString fontName() const;
void setFontName(const QString &fontName);
int fontSize() const;
void setFontSize(int fontSize);
bool fontOnlyMonospaced() const;
void setFontOnlyMonospaced(bool fontOnlyMonospaced);
bool gutterVisible() const;
void setGutterVisible(bool gutterVisible);
bool gutterAutoSize() const;
void setGutterAutoSize(bool gutterAutoSize);
int gutterDigitsCount() const;
void setGutterDigitsCount(int gutterDigitsCount);
bool gutterShowLineNumbers() const;
void setGutterShowLineNumbers(bool gutterShowLineNumbers);
bool gutterAddLeadingZero() const;
void setGutterAddLeadingZero(bool gutterAddLeadingZero);
bool gutterLineNumbersStartZero() const;
void setGutterLineNumbersStartZero(bool gutterLineNumbersStartZero);
bool gutterUseCustomFont() const;
void setGutterUseCustomFont(bool gutterUseCustomFont);
QString gutterFontName() const;
void setGutterFontName(const QString &gutterFontName);
int gutterFontSize() const;
void setGutterFontSize(int gutterFontSize);
bool gutterFontOnlyMonospaced() const;
void setGutterFontOnlyMonospaced(bool gutterFontOnlyMonospaced);
int gutterLeftOffset() const;
void setGutterLeftOffset(int gutterLeftOffset);
int gutterRightOffset() const;
void setGutterRightOffset(int gutterRightOffset);
bool copySizeLimit() const;
void setCopySizeLimit(bool copyLimit);
int copyCharLimits() const;
void setCopyCharLimits(int copyCharLimits);
int copyLineLimits() const;
void setCopyLineLimits(int copyLineLimits);
bool copyRTFUseBackground() const;
void setCopyRTFUseBackground(bool copyRTFUseBackground);
bool copyRTFUseEditorColor() const;
void setCopyRTFUseEditorColor(bool copyRTFUseEditorColor);
2021-06-20 14:30:47 +08:00
QString copyRTFColorScheme() const;
void setCopyRTFColorScheme(const QString &copyRTFColorScheme);
bool copyHTMLUseBackground() const;
void setCopyHTMLUseBackground(bool copyHTMLUseBackground);
bool copyHTMLUseEditorColor() const;
void setCopyHTMLUseEditorColor(bool copyHTMLUseEditorColor);
2021-06-20 14:30:47 +08:00
QString copyHTMLColorScheme() const;
void setCopyHTMLColorScheme(const QString &copyHTMLColorScheme);
int copyWithFormatAs() const;
void setCopyWithFormatAs(int copyWithFormatAs);
2021-06-20 14:30:47 +08:00
QString colorScheme() const;
void setColorScheme(const QString &colorScheme);
bool completeSymbols() const;
void setCompleteSymbols(bool completeSymbols);
bool completeParenthese() const;
void setCompleteParenthese(bool completeParenthese);
bool completeBracket() const;
void setCompleteBracket(bool completeBracket);
bool completeBrace() const;
void setCompleteBrace(bool completeBrace);
bool completeComment() const;
void setCompleteComment(bool completeComment);
bool completeSingleQuote() const;
void setCompleteSingleQuote(bool completeSingleQuote);
bool completeDoubleQuote() const;
void setCompleteDoubleQuote(bool completeDoubleQuote);
bool completeGlobalInclude() const;
void setCompleteGlobalInclude(bool completeGlobalInclude);
bool overwriteSymbols() const;
void setOverwriteSymbols(bool overwriteSymbols);
bool removeSymbolPairs() const;
void setRemoveSymbolPairs(bool value);
2021-06-25 12:40:11 +08:00
bool syntaxCheck() const;
void setSyntaxCheck(bool syntaxCheck);
bool syntaxCheckWhenSave() const;
void setSyntaxCheckWhenSave(bool syntaxCheckWhenSave);
bool syntaxCheckWhenLineChanged() const;
void setSyntaxCheckWhenLineChanged(bool syntaxCheckWhenLineChanged);
bool readOnlySytemHeader() const;
void setReadOnlySytemHeader(bool newReadOnlySytemHeader);
bool autoLoadLastFiles() const;
void setAutoLoadLastFiles(bool newAutoLoadLastFiles);
bool defaultFileCpp() const;
void setDefaultFileCpp(bool newDefaultFileCpp);
2021-08-30 22:05:45 +08:00
bool enableAutoSave() const;
void setEnableAutoSave(bool newEnableAutoSave);
int autoSaveInterval() const;
void setAutoSaveInterval(int newInterval);
AutoSaveTarget autoSaveTarget() const;
void setAutoSaveTarget(AutoSaveTarget newAutoSaveTarget);
AutoSaveStrategy autoSaveStrategy() const;
void setAutoSaveStrategy(AutoSaveStrategy newAutoSaveStrategy);
2021-09-04 16:34:14 +08:00
bool enableAutolink() const;
void setEnableAutolink(bool newEnableAutolink);
2021-09-04 19:27:44 +08:00
bool showRightEdgeLine() const;
void setShowRightEdgeLine(bool newShowRightMarginLine);
int rightEdgeWidth() const;
void setRightEdgeWidth(int newRightMarginWidth);
const QColor &rightEdgeLineColor() const;
void setRightEdgeLineColor(const QColor &newRightMarginLineColor);
bool caretUseTextColor() const;
void setCaretUseTextColor(bool newUseIdentifierColor);
bool rainbowParenthesis() const;
void setRainbowParenthesis(bool newRainbowParenthesis);
bool enableTooltips() const;
void setEnableTooltips(bool newEnableTooltips);
bool enableDebugTooltips() const;
void setEnableDebugTooltips(bool newEnableDebugTooltips);
bool enableIdentifierToolTips() const;
void setEnableIdentifierToolTips(bool newEnableIdentifierToolTips);
bool enableHeaderToolTips() const;
void setEnableHeaderToolTips(bool newEnableHeaderToolTips);
bool enableIssueToolTips() const;
void setEnableIssueToolTips(bool newEnableIssueToolTips);
bool showFunctionTips() const;
void setShowFunctionTips(bool newShowFunctionTips);
2021-06-07 11:02:03 +08:00
private:
//General
2021-06-07 11:02:03 +08:00
// indents
bool mAutoIndent;
bool mAddIndent;
bool mTabToSpaces;
int mTabWidth;
bool mShowIndentLines;
QColor mIndentLineColor;
// caret
bool mEnhanceHomeKey;
bool mEnhanceEndKey;
bool mKeepCaretX;
SynEditCaretType mCaretForInsert;
SynEditCaretType mCaretForOverwrite;
2021-09-04 19:27:44 +08:00
bool mCaretUseTextColor;
2021-06-07 11:02:03 +08:00
QColor mCaretColor;
2021-09-04 19:27:44 +08:00
//scroll
bool mAutoHideScrollbar;
bool mScrollPastEof;
bool mScrollPastEol;
bool mScrollByOneLess;
bool mHalfPageScroll;
2021-06-07 11:02:03 +08:00
2021-09-04 19:27:44 +08:00
//right margin
bool mShowRightEdgeLine;
int mRightEdgeWidth;
QColor mRightEdgeLineColor;
//Font
//font
QString mFontName;
int mFontSize;
bool mFontOnlyMonospaced;
//gutter
bool mGutterVisible;
bool mGutterAutoSize;
int mGutterLeftOffset;
int mGutterRightOffset;
int mGutterDigitsCount;
bool mGutterShowLineNumbers;
bool mGutterAddLeadingZero;
bool mGutterLineNumbersStartZero;
bool mGutterUseCustomFont;
QString mGutterFontName;
int mGutterFontSize;
bool mGutterFontOnlyMonospaced;
//copy
bool mCopySizeLimit;
int mCopyCharLimits;
int mCopyLineLimits;
int mCopyWithFormatAs;
bool mCopyRTFUseBackground;
bool mCopyRTFUseEditorColor;
2021-06-20 14:30:47 +08:00
QString mCopyRTFColorScheme;
bool mCopyHTMLUseBackground;
bool mCopyHTMLUseEditorColor;
2021-06-20 14:30:47 +08:00
QString mCopyHTMLColorScheme;
//Color
QString mColorScheme;
bool mRainbowParenthesis;
//Symbol Completion
bool mCompleteSymbols;
bool mCompleteParenthese;
bool mCompleteBracket;
bool mCompleteBrace;
bool mCompleteComment;
bool mCompleteSingleQuote;
bool mCompleteDoubleQuote;
bool mCompleteGlobalInclude;
bool mOverwriteSymbols;
bool mRemoveSymbolPairs;
2021-06-25 12:40:11 +08:00
//Auto Syntax Check
bool mSyntaxCheck;
bool mSyntaxCheckWhenSave;
bool mSyntaxCheckWhenLineChanged;
2021-08-30 22:05:45 +08:00
//auto save
bool mEnableAutoSave;
int mAutoSaveInterval;
enum AutoSaveTarget mAutoSaveTarget;
enum AutoSaveStrategy mAutoSaveStrategy;
2021-09-04 16:34:14 +08:00
//auto link
bool mEnableAutolink;
//Misc
QByteArray mDefaultEncoding;
bool mReadOnlySytemHeader;
bool mAutoLoadLastFiles;
bool mDefaultFileCpp;
//hints tooltip
bool mEnableTooltips;
bool mEnableDebugTooltips;
bool mEnableIdentifierToolTips;
bool mEnableHeaderToolTips;
bool mEnableIssueToolTips;
bool mShowFunctionTips;
2021-06-07 11:02:03 +08:00
// _Base interface
protected:
void doSave() override;
void doLoad() override;
2021-04-13 11:23:37 +08:00
};
2021-06-18 21:48:40 +08:00
class Environment: public _Base {
public:
explicit Environment(Settings * settings);
QString theme() const;
void setTheme(const QString &theme);
QString interfaceFont() const;
void setInterfaceFont(const QString &interfaceFont);
int interfaceFontSize() const;
void setInterfaceFontSize(int interfaceFontSize);
2021-06-20 09:27:37 +08:00
QString language() const;
void setLanguage(const QString &language);
2021-06-18 21:48:40 +08:00
private:
//Appearence
QString mTheme;
QString mInterfaceFont;
int mInterfaceFontSize;
2021-06-20 09:27:37 +08:00
QString mLanguage;
2021-06-18 21:48:40 +08:00
// _Base interface
protected:
void doSave() override;
void doLoad() override;
};
class CodeCompletion: public _Base {
public:
explicit CodeCompletion(Settings *settings);
int width() const;
void setWidth(int newWidth);
int height() const;
void setHeight(int newHeight);
bool enabled() const;
void setEnabled(bool newEnabled);
bool parseLocalHeaders() const;
void setParseLocalHeaders(bool newParseLocalHeaders);
bool parseGlobalHeaders() const;
void setParseGlobalHeaders(bool newParseGlobalHeaders);
bool showCompletionWhileInput() const;
void setShowCompletionWhileInput(bool newShowCompletionWhileInput);
bool recordUsage() const;
void setRecordUsage(bool newRecordUsage);
bool sortByScope() const;
void setSortByScope(bool newSortByScope);
bool showKeywords() const;
void setShowKeywords(bool newShowKeywords);
bool ignoreCase() const;
void setIgnoreCase(bool newIgnoreCase);
bool appendFunc() const;
void setAppendFunc(bool newAppendFunc);
bool showCodeIns() const;
void setShowCodeIns(bool newShowCodeIns);
private:
int mWidth;
int mHeight;
bool mEnabled;
bool mParseLocalHeaders;
bool mParseGlobalHeaders;
bool mShowCompletionWhileInput;
bool mRecordUsage;
bool mSortByScope;
bool mShowKeywords;
bool mIgnoreCase;
bool mAppendFunc;
bool mShowCodeIns;
// _Base interface
protected:
void doSave() override;
void doLoad() override;
};
2021-08-31 19:15:11 +08:00
class CodeFormatter: public _Base {
public:
explicit CodeFormatter(Settings* settings);
2021-09-01 22:40:58 +08:00
QStringList getArguments();
2021-09-01 00:05:46 +08:00
int braceStyle() const;
void setBraceStyle(int newBraceStyle);
int indentStyle() const;
void setIndentStyle(int newIndentStyle);
int tabWidth() const;
void setTabWidth(int newTabWidth);
bool attachNamespaces() const;
void setAttachNamespaces(bool newAttachNamespaces);
bool attachClasses() const;
void setAttachClasses(bool newAttachClasses);
bool attachInlines() const;
void setAttachInlines(bool newAttachInlines);
bool attachExternC() const;
void setAttachExternC(bool newAttachExternC);
bool attachClosingWhile() const;
void setAttachClosingWhile(bool newAttachClosingWhile);
bool indentClasses() const;
void setIndentClasses(bool newIndentClasses);
bool indentModifiers() const;
void setIndentModifiers(bool newIndentModifiers);
bool indentCases() const;
void setIndentCases(bool newIndentCases);
bool indentNamespaces() const;
void setIndentNamespaces(bool newIndentNamespaces);
int indentContinuation() const;
void setIndentContinuation(int newIndentContinuation);
2021-09-01 00:05:46 +08:00
bool indentLabels() const;
void setIndentLabels(bool newIndentLabels);
bool indentPreprocBlock() const;
void setIndentPreprocBlock(bool newIndentPreprocBlock);
bool indentPreprocCond() const;
void setIndentPreprocCond(bool newIndentPreprocCond);
bool indentPreprocDefine() const;
void setIndentPreprocDefine(bool newIndentPreprocDefine);
bool indentCol1Comments() const;
void setIndentCol1Comments(bool newIndentCol1Comments);
int minConditionalIndent() const;
void setMinConditionalIndent(int newMinConditionalIndent);
int maxContinuationIndent() const;
void setMaxContinuationIndent(int newMaxContinuationIndent);
bool breakBlocks() const;
void setBreakBlocks(bool newBreakBlocks);
bool breakBlocksAll() const;
void setBreakBlocksAll(bool newBreakBlocksAll);
bool padOper() const;
void setPadOper(bool newPadOper);
bool padComma() const;
void setPadComma(bool newPadComma);
bool padParen() const;
void setPadParen(bool newPadParen);
bool padParenOut() const;
void setPadParenOut(bool newPadParenOut);
bool padFirstParenOut() const;
void setPadFirstParenOut(bool newPadFirstParenOut);
bool padParenIn() const;
void setPadParenIn(bool newPadParenIn);
bool padHeader() const;
void setPadHeader(bool newPadHeader);
bool unpadParen() const;
void setUnpadParen(bool newUnpadParen);
bool deleteEmptyLines() const;
void setDeleteEmptyLines(bool newDeleteEmptyLines);
bool deleteMultipleEmptyLines() const;
void setDeleteMultipleEmptyLines(bool newDeleteMultipleEmptyLines);
bool fillEmptyLines() const;
void setFillEmptyLines(bool newFillEmptyLines);
int alignPointerStyle() const;
void setAlignPointerStyle(int newAlignPointerStyle);
int alignReferenceStyle() const;
void setAlignReferenceStyle(int newAlignReferenceStyle);
bool breakClosingBraces() const;
void setBreakClosingBraces(bool newBreakClosingBraces);
bool breakElseIf() const;
void setBreakElseIf(bool newBreakElseIf);
bool breakOneLineHeaders() const;
void setBreakOneLineHeaders(bool newBreakOneLineHeaders);
bool addBraces() const;
void setAddBraces(bool newAddBraces);
bool addOneLineBraces() const;
void setAddOneLineBraces(bool newAddOneLineBraces);
bool removeBraces() const;
void setRemoveBraces(bool newRemoveBraces);
bool breakReturnTypeDecl() const;
void setBreakReturnTypeDecl(bool newBreakReturnTypeDecl);
bool attachReturnType() const;
void setAttachReturnType(bool newAttachReturnType);
bool attachReturnTypeDecl() const;
void setAttachReturnTypeDecl(bool newAttachReturnTypeDecl);
bool keepOneLineBlocks() const;
void setKeepOneLineBlocks(bool newKeepOneLineBlocks);
bool keepOneLineStatements() const;
void setKeepOneLineStatements(bool newKeepOneLineStatements);
bool convertTabs() const;
void setConvertTabs(bool newConvertTabs);
bool closeTemplates() const;
void setCloseTemplates(bool newCloseTemplates);
bool removeCommentPrefix() const;
void setRemoveCommentPrefix(bool newRemoveCommentPrefix);
int maxCodeLength() const;
2021-09-01 00:05:46 +08:00
void setMaxCodeLength(int newMaxCodeLength);
bool breakAfterLogical() const;
void setBreakAfterLogical(bool newBreakAfterLogical);
bool breakReturnType() const;
void setBreakReturnType(bool newBreakReturnType);
bool breakMaxCodeLength() const;
void setBreakMaxCodeLength(bool newBreakMaxCodeLength);
bool indentSwitches() const;
void setIndentSwitches(bool newIndentSwitches);
bool indentAfterParens() const;
void setIndentAfterParens(bool newIndentAfterParens);
2021-08-31 19:15:11 +08:00
private:
int mBraceStyle;
int mIndentStyle;
int mTabWidth;
bool mAttachNamespaces;
bool mAttachClasses;
bool mAttachInlines;
bool mAttachExternC;
bool mAttachClosingWhile;
bool mIndentClasses;
bool mIndentModifiers;
bool mIndentSwitches;
2021-08-31 19:15:11 +08:00
bool mIndentCases;
bool mIndentNamespaces;
bool mIndentAfterParens;
int mIndentContinuation;
2021-08-31 19:15:11 +08:00
bool mIndentLabels;
bool mIndentPreprocBlock;
bool mIndentPreprocCond;
bool mIndentPreprocDefine;
2021-09-01 00:05:46 +08:00
bool mIndentCol1Comments;
2021-08-31 19:15:11 +08:00
int mMinConditionalIndent;
int mMaxContinuationIndent;
bool mBreakBlocks;
bool mBreakBlocksAll;
bool mPadOper;
bool mPadComma;
bool mPadParen;
bool mPadParenOut;
bool mPadFirstParenOut;
bool mPadParenIn;
bool mPadHeader;
bool mUnpadParen;
bool mDeleteEmptyLines;
bool mDeleteMultipleEmptyLines;
bool mFillEmptyLines;
int mAlignPointerStyle;
int mAlignReferenceStyle;
bool mBreakClosingBraces;
bool mBreakElseIf;
bool mBreakOneLineHeaders;
bool mAddBraces;
bool mAddOneLineBraces;
bool mRemoveBraces;
2021-09-01 00:05:46 +08:00
bool mBreakReturnType;
2021-08-31 19:15:11 +08:00
bool mBreakReturnTypeDecl;
bool mAttachReturnType;
bool mAttachReturnTypeDecl;
bool mKeepOneLineBlocks;
bool mKeepOneLineStatements;
bool mConvertTabs;
bool mCloseTemplates;
bool mRemoveCommentPrefix;
2021-09-01 00:05:46 +08:00
bool mBreakMaxCodeLength;
int mMaxCodeLength;
2021-08-31 19:15:11 +08:00
bool mBreakAfterLogical;
2021-09-01 00:05:46 +08:00
// _Base interface
protected:
void doSave() override;
void doLoad() override;
2021-08-31 19:15:11 +08:00
};
2021-08-01 23:24:37 +08:00
class History: public _Base {
public:
explicit History(Settings *settings);
const QStringList& openedFiles() const;
const QStringList& openedProjects() const;
2021-08-01 23:24:37 +08:00
bool addToOpenedFiles(const QString& filename);
2021-09-11 11:42:20 +08:00
void removeFile(const QString& filename);
2021-09-11 18:42:49 +08:00
bool addToOpenedProjects(const QString& filename);
void removeProject(const QString& filename);
2021-08-01 23:24:37 +08:00
private:
QStringList mOpenedFiles;
QStringList mOpenedProjects;
// _Base interface
protected:
void doSave() override;
void doLoad() override;
};
2021-07-01 19:44:38 +08:00
class Executor: public _Base {
public:
explicit Executor(Settings * settings);
bool pauseConsole() const;
void setPauseConsole(bool pauseConsole);
bool minimizeOnRun() const;
void setMinimizeOnRun(bool minimizeOnRun);
bool useParams() const;
void setUseParams(bool newUseParams);
const QString &params() const;
void setParams(const QString &newParams);
bool redirectInput() const;
void setRedirectInput(bool newRedirectInput);
const QString &inputFilename() const;
void setInputFilename(const QString &newInputFilename);
2021-07-01 19:44:38 +08:00
private:
// general
bool mPauseConsole;
bool mMinimizeOnRun;
bool mUseParams;
QString mParams;
bool mRedirectInput;
QString mInputFilename;
2021-07-01 19:44:38 +08:00
protected:
void doSave() override;
void doLoad() override;
};
class UI: public _Base {
public:
explicit UI(Settings *settings);
const QByteArray &mainWindowState() const;
void setMainWindowState(const QByteArray &newMainWindowState);
const QByteArray &mainWindowGeometry() const;
void setMainWindowGeometry(const QByteArray &newMainWindowGeometry);
2021-09-02 16:46:53 +08:00
bool bottomPanelOpenned() const;
void setBottomPanelOpenned(bool newBottomPanelOpenned);
int bottomPanelHeight() const;
void setBottomPanelHeight(int newBottomPanelHeight);
int bottomPanelIndex() const;
void setBottomPanelIndex(int newBottomPanelIndex);
bool leftPanelOpenned() const;
void setLeftPanelOpenned(bool newLeftPanelOpenned);
int leftPanelWidth() const;
void setLeftPanelWidth(int newLeftPanelWidth);
int leftPanelIndex() const;
void setLeftPanelIndex(int newLeftPanelIndex);
private:
QByteArray mMainWindowState;
QByteArray mMainWindowGeometry;
2021-09-02 16:46:53 +08:00
bool mBottomPanelOpenned;
int mBottomPanelHeight;
int mBottomPanelIndex;
bool mLeftPanelOpenned;
int mLeftPanelWidth;
int mLeftPanelIndex;
protected:
void doSave() override;
void doLoad() override;
};
2021-07-26 11:47:54 +08:00
class Debugger: public _Base {
public:
explicit Debugger(Settings* settings);
bool showCommandLog() const;
void setShowCommandLog(bool showCommandLog);
bool showAnnotations() const;
void setShowAnnotations(bool showAnnotations);
2021-08-01 23:24:37 +08:00
bool onlyShowMono() const;
void setOnlyShowMono(bool onlyShowMono);
int fontSize() const;
void setFontSize(int fontSize);
bool useIntelStyle() const;
void setUseIntelStyle(bool useIntelStyle);
QString fontName() const;
void setFontName(const QString &fontName);
bool blendMode() const;
void setBlendMode(bool blendMode);
2021-07-26 11:47:54 +08:00
private:
bool mShowCommandLog;
bool mShowAnnotations;
2021-08-01 23:24:37 +08:00
QString mFontName;
bool mOnlyShowMono;
int mFontSize;
bool mUseIntelStyle;
bool mBlendMode;
2021-07-26 11:47:54 +08:00
// _Base interface
protected:
void doSave() override;
void doLoad() override;
};
2021-07-01 19:44:38 +08:00
2021-04-15 11:18:14 +08:00
class CompilerSet {
public:
2021-04-15 11:18:14 +08:00
explicit CompilerSet(const QString& compilerFolder = QString());
explicit CompilerSet(const CompilerSet& set);
CompilerSet& operator= (const CompilerSet& ) = delete;
CompilerSet& operator= (const CompilerSet&& ) = delete;
2021-04-16 22:04:48 +08:00
2021-04-15 11:18:14 +08:00
void addOption(const QString& name, const QString section, bool isC,
bool isCpp, bool isLinker,
int value, const QString& setting,
const QStringList& choices = QStringList());
2021-04-15 21:32:45 +08:00
PCompilerOption findOption(const QString& setting);
2021-09-09 11:47:04 +08:00
int findOptionIndex(const QString& setting);
2021-04-15 11:18:14 +08:00
char getOptionValue(const QString& setting);
void setOption(const QString& setting, char valueChar);
void setOption(PCompilerOption& option, char valueChar);
void setProperties(const QString& binDir);
2021-09-04 21:20:30 +08:00
void setDirectories(const QString& binDir);
2021-04-15 11:18:14 +08:00
2021-04-16 22:04:48 +08:00
bool dirsValid(QString& msg);
bool validateExes(QString& msg);
2021-04-16 22:04:48 +08:00
//properties
const QString& CCompiler() const;
void setCCompiler(const QString& name);
const QString& cppCompiler() const;
void setCppCompiler(const QString& name);
const QString& make() const;
void setMake(const QString& name);
const QString& debugger() const;
void setDebugger(const QString& name);
const QString& profiler() const;
void setProfiler(const QString& name);
const QString& resourceCompiler() const;
void setResourceCompiler(const QString& name);
2021-04-15 11:18:14 +08:00
QStringList& binDirs();
QStringList& CIncludeDirs();
QStringList& CppIncludeDirs();
2021-04-17 22:38:46 +08:00
QStringList& libDirs();
QStringList& defaultCIncludeDirs();
QStringList& defaultCppIncludeDirs();
QStringList& defaultLibDirs();
2021-04-15 11:18:14 +08:00
const QString& dumpMachine() const;
2021-04-15 11:18:14 +08:00
void setDumpMachine(const QString& value);
const QString& version() const;
2021-04-15 11:18:14 +08:00
void setVersion(const QString& value);
const QString& type() const;
2021-04-15 11:18:14 +08:00
void setType(const QString& value);
const QString& name() const;
2021-04-15 21:32:45 +08:00
void setName(const QString& value);
const QStringList& defines() const;
const QString& target() const;
2021-04-15 11:18:14 +08:00
void setTarget(const QString& value);
bool useCustomCompileParams() const;
2021-04-15 11:18:14 +08:00
void setUseCustomCompileParams(bool value);
bool useCustomLinkParams() const;
2021-04-15 11:18:14 +08:00
void setUseCustomLinkParams(bool value);
const QString& customCompileParams() const;
2021-04-15 11:18:14 +08:00
void setCustomCompileParams(const QString& value);
const QString& customLinkParams() const;
2021-04-15 11:18:14 +08:00
void setCustomLinkParams(const QString& value);
bool autoAddCharsetParams() const;
2021-04-15 11:18:14 +08:00
void setAutoAddCharsetParams(bool value);
CompilerOptionList& options();
2021-04-15 21:32:45 +08:00
//Converts options to and from memory format
QByteArray iniOptions() const;
void setIniOptions(const QByteArray& value);
//load hard defines
void setDefines();
2021-09-02 21:01:23 +08:00
bool staticLink() const;
void setStaticLink(bool newStaticLink);
2021-04-15 11:18:14 +08:00
2021-09-13 10:48:44 +08:00
static int charToValue(char valueChar);
static char valueToChar(int val);
2021-09-13 10:48:44 +08:00
private:
2021-04-15 11:18:14 +08:00
// Initialization
void setExecutables();
void setUserInput();
void setOptions();
QString findProgramInBinDirs(const QString name);
2021-04-15 11:18:14 +08:00
QByteArray getCompilerOutput(const QString& binDir, const QString& binFile,
const QStringList& arguments);
private:
// Executables, most are hardcoded
QString mCCompiler;
QString mCppCompiler;
QString mMake;
QString mDebugger;
QString mProfiler;
QString mResourceCompiler;
// Directories, mostly hardcoded too
QStringList mBinDirs;
QStringList mCIncludeDirs;
2021-04-15 11:18:14 +08:00
QStringList mCppIncludeDirs;
QStringList mLibDirs;
QStringList mDefaultLibDirs;
QStringList mDefaultCIncludeDirs;
QStringList mDefaultCppIncludeDirs;
// Misc. properties
QString mDumpMachine; // "x86_64-w64-mingw32", "mingw32" etc
QString mVersion; // "4.7.1"
QString mType; // "TDM-GCC", "MinGW"
QString mName; // "TDM-GCC 4.7.1 Release"
2021-04-15 11:18:14 +08:00
QStringList mDefines; // list of predefined constants
QString mTarget; // 'X86_64' / 'i686'
// User settings
2021-04-15 11:18:14 +08:00
bool mUseCustomCompileParams;
bool mUseCustomLinkParams;
QString mCustomCompileParams;
QString mCustomLinkParams;
2021-04-15 11:18:14 +08:00
bool mAutoAddCharsetParams;
2021-09-02 21:01:23 +08:00
bool mStaticLink;
// Options
2021-04-15 11:18:14 +08:00
CompilerOptionList mOptions;
};
2021-04-15 21:32:45 +08:00
typedef std::shared_ptr<CompilerSet> PCompilerSet;
typedef std::vector<PCompilerSet> CompilerSetList;
class CompilerSets {
public:
explicit CompilerSets(Settings* settings);
PCompilerSet addSet(const CompilerSet& set);
PCompilerSet addSet(const QString& folder=QString());
void addSets(const QString& folder);
void clearSets();
void findSets();
void saveSets();
void loadSets();
2021-04-18 11:41:41 +08:00
void saveDefaultIndex();
2021-04-16 22:04:48 +08:00
void deleteSet(int index);
2021-07-23 13:22:05 +08:00
void saveSet(int index);
2021-04-15 21:32:45 +08:00
//properties
CompilerSetList& list();
int size() const;
int defaultIndex() const;
void setDefaultIndex(int value);
2021-04-16 22:04:48 +08:00
PCompilerSet defaultSet();
2021-09-09 11:47:04 +08:00
PCompilerSet getSet(int index);
2021-04-15 21:32:45 +08:00
private:
void savePath(const QString& name, const QString& path);
void savePathList(const QString& name, const QStringList& pathList);
2021-07-23 13:22:05 +08:00
QString loadPath(const QString& name);
void loadPathList(const QString& name, QStringList& list);
2021-04-15 21:32:45 +08:00
PCompilerSet loadSet(int index);
CompilerSetList mList;
int mDefaultIndex;
Settings* mSettings;
};
public:
explicit Settings(const QString& filename);
explicit Settings(Settings&& settings) = delete;
explicit Settings(const Settings& settings) = delete;
~Settings();
Settings& operator= (const Settings& settings) = delete;
Settings& operator= (const Settings&& settings) = delete;
2021-06-07 11:02:03 +08:00
void beginGroup(const QString& group);
void endGroup();
void saveValue(const QString& group, const QString &key, const QVariant &value);
void saveValue(const QString &key, const QVariant &value);
QVariant value(const QString& group, const QString &key, const QVariant& defaultValue);
QVariant value(const QString &key, const QVariant& defaultValue);
2021-08-07 18:02:57 +08:00
void load();
2021-04-13 11:23:37 +08:00
Dirs& dirs();
Editor& editor();
2021-04-15 21:32:45 +08:00
CompilerSets& compilerSets();
2021-06-18 21:48:40 +08:00
Environment& environment();
2021-07-01 19:44:38 +08:00
Executor& executor();
2021-07-26 18:22:09 +08:00
Debugger& debugger();
2021-08-01 23:24:37 +08:00
History& history();
CodeCompletion &codeCompletion();
2021-09-01 00:05:46 +08:00
CodeFormatter &codeFormatter();
UI &ui();
2021-06-17 10:39:46 +08:00
QString filename() const;
private:
2021-06-17 10:39:46 +08:00
QString mFilename;
QSettings mSettings;
2021-04-13 11:23:37 +08:00
Dirs mDirs;
Editor mEditor;
2021-06-18 21:48:40 +08:00
Environment mEnvironment;
2021-04-15 21:32:45 +08:00
CompilerSets mCompilerSets;
2021-07-01 19:44:38 +08:00
Executor mExecutor;
2021-07-26 11:47:54 +08:00
Debugger mDebugger;
CodeCompletion mCodeCompletion;
2021-09-01 00:05:46 +08:00
CodeFormatter mCodeFormatter;
2021-08-01 23:24:37 +08:00
History mHistory;
UI mUI;
};
2021-04-13 11:23:37 +08:00
extern Settings* pSettings;
#endif // SETTINGS_H