work save

This commit is contained in:
royqh1979 2021-08-31 19:15:11 +08:00
parent acbb7c06b8
commit 633f4f73ee
11 changed files with 412 additions and 0 deletions

View File

@ -14,6 +14,7 @@ QMAKE_CXXFLAGS_DEBUG += -Werror=return-type
SOURCES += \
HighlighterManager.cpp \
codeformatter.cpp \
colorscheme.cpp \
compiler/compiler.cpp \
compiler/compilermanager.cpp \
@ -32,6 +33,8 @@ SOURCES += \
settingsdialog/editorautosavewidget.cpp \
settingsdialog/editorcodecompletionwidget.cpp \
settingsdialog/editormiscwidget.cpp \
settingsdialog/formattergeneralwidget.cpp \
settingsdialog/formatteridentationwidget.cpp \
widgets/classbrowser.cpp \
widgets/codecompletionlistview.cpp \
widgets/codecompletionpopup.cpp \
@ -83,6 +86,7 @@ SOURCES += \
HEADERS += \
HighlighterManager.h \
codeformatter.h \
colorscheme.h \
compiler/compiler.h \
compiler/compilermanager.h \
@ -101,6 +105,8 @@ HEADERS += \
settingsdialog/editorautosavewidget.h \
settingsdialog/editorcodecompletionwidget.h \
settingsdialog/editormiscwidget.h \
settingsdialog/formattergeneralwidget.h \
settingsdialog/formatteridentationwidget.h \
widgets/classbrowser.h \
widgets/codecompletionlistview.h \
widgets/codecompletionpopup.h \
@ -156,6 +162,8 @@ FORMS += \
settingsdialog/editorautosavewidget.ui \
settingsdialog/editorcodecompletionwidget.ui \
settingsdialog/editormiscwidget.ui \
settingsdialog/formattergeneralwidget.ui \
settingsdialog/formatteridentationwidget.ui \
widgets/cpudialog.ui \
mainwindow.ui \
settingsdialog/compilersetdirectorieswidget.ui \

View File

@ -0,0 +1,6 @@
#include "codeformatter.h"
CodeFormatter::CodeFormatter()
{
}

View File

@ -0,0 +1,11 @@
#ifndef CODEFORMATTER_H
#define CODEFORMATTER_H
class CodeFormatter
{
public:
CodeFormatter();
};
#endif // CODEFORMATTER_H

View File

@ -2690,3 +2690,9 @@ void Settings::CodeCompletion::doLoad()
mAppendFunc = boolValue("append_func",true);
mShowCodeIns = boolValue("show_code_ins",true);
}
Settings::CodeFormatter::CodeFormatter(Settings *settings):
_Base(settings,SETTING_CODE_FORMATTER)
{
}

View File

@ -19,6 +19,7 @@
#define SETTING_DEBUGGER "Debugger"
#define SETTING_HISTORY "History"
#define SETTING_CODE_COMPLETION "CodeCompletion"
#define SETTING_CODE_FORMATTER "CodeFormatter"
#define SETTING_COMPILTER_SETS "CompilerSets"
#define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex"
#define SETTING_COMPILTER_SETS_COUNT "count"
@ -464,6 +465,94 @@ public:
};
class CodeFormatter: public _Base {
public:
explicit CodeFormatter(Settings* settings);
private:
int mBraceStyle;
int mIndentStyle;
int mTabWidth;
bool mAttachNamespaces;
bool mAttachClasses;
bool mAttachInlines;
bool mAttachExternC;
bool mAttachClosingWhile;
bool mIndentClasses;
bool mIndentModifiers;
bool mIndentCases;
bool mIndentNamespaces;
bool mIndentContinuation;
bool mIndentLabels;
bool mIndentPreprocBlock;
bool mIndentPreprocCond;
bool mIndentPreprocDefine;
bool mIndentCollComments;
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;
bool mBreakRetureType;
bool mBreakReturnTypeDecl;
bool mAttachReturnType;
bool mAttachReturnTypeDecl;
bool mKeepOneLineBlocks;
bool mKeepOneLineStatements;
bool mConvertTabs;
bool mCloseTemplates;
bool mRemoveCommentPrefix;
int maxCodeLength;
bool mBreakAfterLogical;
int mBracketStyle;
int mIndentStyle;
int mTabWidth;
int mMaxLineLength;
bool mModifyMaxLineLength;
//Indentation options:
bool mIndentClasses; // --indent-classes
bool mIndentSwitches; //-indent-switches
bool mIndentCases; // --indent-cases
bool mIndentNamespaces; // --indent-namespaces
bool mIndentLabels; // --indent-labels
fIndentPreprocessor: Boolean; // --indent-preprocessor
//Padding options
fPadOper: boolean; // --pad-oper; add spaces around an operator
fPadHeader: boolean; // --pad-header; add spaces after 'if','for',etc.
fPointerAlign: integer; // --align-pointer=none/type/middle/name
fReferenceAlign: integer; // --align-reference=none/type/middle/name
fDeleteEmptyLines: boolean;
fDeleteMultipleEmptyLines: boolean;
fCustomCommand: AnsiString;
fFullCommand: AnsiString; // includes customizations
fAStyleDir: AnsiString;
fAStyleFile: AnsiString;
};
class History: public _Base {
public:
explicit History(Settings *settings);

View File

@ -0,0 +1,14 @@
#include "formattergeneralwidget.h"
#include "ui_formattergeneralwidget.h"
FormatterGeneralWidget::FormatterGeneralWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormatterGeneralWidget)
{
ui->setupUi(this);
}
FormatterGeneralWidget::~FormatterGeneralWidget()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef FORMATTERGENERALWIDGET_H
#define FORMATTERGENERALWIDGET_H
#include <QWidget>
namespace Ui {
class FormatterGeneralWidget;
}
class FormatterGeneralWidget : public QWidget
{
Q_OBJECT
public:
explicit FormatterGeneralWidget(QWidget *parent = nullptr);
~FormatterGeneralWidget();
private:
Ui::FormatterGeneralWidget *ui;
};
#endif // FORMATTERGENERALWIDGET_H

View File

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FormatterGeneralWidget</class>
<widget class="QWidget" name="FormatterGeneralWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>430</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<widget class="QLabel" name="label">
<property name="text">
<string>Default brace style</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>sdafasdf&lt;br/&gt;dsafd</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Brace modifications</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Attach spaces to namespace statements</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>Attach spaces to classes</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>Attach spaces to class inline function definitions</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>Attach spaces to extern &quot;C&quot; statements</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>Attach the closing while of do-while to the close brace</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Indent with:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="toolTip">
<string>Indent using spaces</string>
</property>
<property name="text">
<string>Spaces</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="toolTip">
<string>Indent using tabs</string>
</property>
<property name="text">
<string>Tabs</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<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>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tab Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,14 @@
#include "formatteridentationwidget.h"
#include "ui_formatteridentationwidget.h"
FormatterIdentationWidget::FormatterIdentationWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormatterIdentationWidget)
{
ui->setupUi(this);
}
FormatterIdentationWidget::~FormatterIdentationWidget()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef FORMATTERIDENTATIONWIDGET_H
#define FORMATTERIDENTATIONWIDGET_H
#include <QWidget>
namespace Ui {
class FormatterIdentationWidget;
}
class FormatterIdentationWidget : public QWidget
{
Q_OBJECT
public:
explicit FormatterIdentationWidget(QWidget *parent = nullptr);
~FormatterIdentationWidget();
private:
Ui::FormatterIdentationWidget *ui;
};
#endif // FORMATTERIDENTATIONWIDGET_H

View File

@ -0,0 +1,21 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>FormatterIdentationWidget</class>
<widget name="FormatterIdentationWidget" class="QWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>