diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro
index 09fd3eb6..13405036 100644
--- a/RedPandaIDE/RedPandaIDE.pro
+++ b/RedPandaIDE/RedPandaIDE.pro
@@ -29,6 +29,7 @@ SOURCES += \
qsynedit/SearchBase.cpp \
qsynedit/SearchRegex.cpp \
settingsdialog/debuggeneralwidget.cpp \
+ settingsdialog/editorautosavewidget.cpp \
settingsdialog/editorcodecompletionwidget.cpp \
settingsdialog/editormiscwidget.cpp \
widgets/classbrowser.cpp \
@@ -97,6 +98,7 @@ HEADERS += \
qsynedit/SearchBase.h \
qsynedit/SearchRegex.h \
settingsdialog/debuggeneralwidget.h \
+ settingsdialog/editorautosavewidget.h \
settingsdialog/editorcodecompletionwidget.h \
settingsdialog/editormiscwidget.h \
widgets/classbrowser.h \
@@ -151,6 +153,7 @@ HEADERS += \
FORMS += \
settingsdialog/debuggeneralwidget.ui \
+ settingsdialog/editorautosavewidget.ui \
settingsdialog/editorcodecompletionwidget.ui \
settingsdialog/editormiscwidget.ui \
widgets/cpudialog.ui \
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm
index 692cc2fc..16c3f272 100644
Binary files a/RedPandaIDE/RedPandaIDE_zh_CN.qm and b/RedPandaIDE/RedPandaIDE_zh_CN.qm differ
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts
index 14cbe4a2..2ff3b925 100644
--- a/RedPandaIDE/RedPandaIDE_zh_CN.ts
+++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts
@@ -532,59 +532,140 @@ Are you really want to continue?
失败
-
-
-
-
-
-
-
+
+
+
+
+
+
+
错误
-
+
无法写入文件"%1"
-
+
另存为
-
+
要复制的内容超过了行数限制!
-
+
要复制的内容超过了字符数限制!
-
+
要剪切的内容超过了行数限制!
-
+
要剪切的内容超过了字符数限制!
-
-
-
+
+
+
Ctrl+单击以获取更多信息
-
+
+
+
+ 未找到符号'%1'!
+
+
+
只读
+
+ EditorAutoSaveWidget
+
+
+
+ 表单
+
+
+
+
+ 启用自动保存
+
+
+
+
+ 时间间隔
+
+
+
+
+ 分钟
+
+
+
+
+ 保存对象
+
+
+
+
+ 当前文件
+
+
+
+
+ 所有打开的文件
+
+
+
+
+ 项目文件
+
+
+
+
+ 保存策略
+
+
+
+
+ 自动覆盖
+
+
+
+
+ 添加Unix时间戳
+
+
+
+
+ 添加格式化世时间戳
+
+
+
+
+ 示例文件名
+
+
+
+
+
+
+ 示例文件名
+
+
EditorClipboardWidget
@@ -1256,7 +1337,7 @@ Are you really want to continue?
-
+
编译器
@@ -1449,8 +1530,8 @@ Are you really want to continue?
-
-
+
+
编译
@@ -1742,20 +1823,20 @@ Are you really want to continue?
文件历史
-
-
+
+
正在调试
-
-
+
+
正在运行
-
-
+
+
正在编译
@@ -1764,145 +1845,150 @@ Are you really want to continue?
行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5
-
+
行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5
-
+
只读
-
+
插入
-
+
覆写
-
-
+
+
确认
-
-
-
+
+
+
源文件尚未编译。
-
-
+
+
现在编译?
-
-
+
+
源文件比可执行程序新。
-
+
重新编译?
-
+
无编译器设置
-
+
没有配置编译器设置。
-
+
无法启动调试器
-
+
启用调试参数
-
+
当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题?
-
+
重新编译?
-
-
-
-
-
-
+
+
+ 已自动保存%1个文件
+
+
+
+
+
+
+
+
错误
-
+
打开
-
+
编译失败
-
+
运行失败
-
-
+
+
确认转换
-
-
+
+
当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗?
-
+
新监视表达式
-
+
输入监视表达式
-
+
(%1/%2)正在解析文件"%3"
-
-
+
+
- 完成1%个文件的解析,用时%2秒
+ 完成%1个文件的解析,用时%2秒
-
+
(每秒%1个文件)
@@ -1974,216 +2060,216 @@ Are you really want to continue?
无法写入配置文件夹"%1"
-
-
-
-
+
+
+
+
下列%1文件夹不存在:
-
-
+
+
二进制
-
+
未指定%1文件夹
-
+
C包含
-
-
+
+
C++包含
-
-
-
-
+
+
+
+
无法找到%1程序"%2"
-
+
C语言选项
-
+
支持所有ANSI标准C程序(-ansi)
-
+
不支持将asm、inline和typeof作为关键字(-fno-asm)
-
+
模仿传统C预处理器行为(-traditional-cpp)
-
+
代码生成
-
+
生成特定机器的专用指令(-march)
-
+
完整兼容特定机器,较少优化(-tune)
-
+
启用特定指令集(-mx)
-
+
优化级别(-Ox)
-
+
使用下列指针大小编译(-mx)
-
+
语言标准(-std)
-
+
生成调试信息(-g3)
-
+
生成性能分析信息(-pg)
-
+
代码警告
-
+
忽略所有警告信息(-w)
-
+
启用常见问题警告(-Wall)
-
+
启用更多问题警告(-Wextra)
-
+
检查ISO C/C++/C++0x语法一致性(-pedantic)
-
+
只进行语法检查(不编译)(-fsyntax-only)
-
+
将警告作为错误处理(-Werror)
-
+
遇到第一个错误后立即中止编译(-Wfatal-errors)
-
+
链接器
-
+
-
+
不使用标准库和系统启动文件(-nostdlib)
-
+
不产生控制台窗口(-mwindows)
-
+
剥除附加信息(-s)
-
+
链接Ojbective C程序(-lobjc)
-
+
输出
-
+
在生成的汇编代码中加入注释(-fverbose-asm)
-
+
编译时使用管道而不是临时文件(-pipe)
-
+
只生成汇编代码(-S)
-
-
+
+
确认
-
+
在验证编译器设置"%1"时遇到了下列问题:
-
+
未配置编译器设置。
-
+
您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2
@@ -2836,90 +2922,102 @@ Are you really want to continue?
取消
-
+
外观
-
+
环境
-
+
编译器配置集
-
+
编译器
-
-
-
+
+
+
通用
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
编辑器
-
+
字体
-
+
复制/导出
-
+
配色
-
+
代码补全
-
+
符号补全
-
+
自动语法检查
-
+
+
+ 自动保存
+
+
+
+
+ 杂项
+
+
+
程序运行
-
+
调试器
-
+
保存修改
-
+
本页中有尚未保存的设置修改,是否保存后再切换到其他页?
diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp
index 293aefbd..fb55d627 100644
--- a/RedPandaIDE/editor.cpp
+++ b/RedPandaIDE/editor.cpp
@@ -161,16 +161,6 @@ void Editor::saveFile(const QString &filename) {
pMainWindow->updateForEncodingInfo();
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
pMainWindow->checkSyntaxInBack(this);
- switch(getFileType(mFilename)) {
- case FileType::CppSource:
- mUseCppSyntax = true;
- break;
- case FileType::CSource:
- mUseCppSyntax = false;
- break;
- default:
- mUseCppSyntax = pSettings->editor().defaultFileCpp();
- }
}
void Editor::convertToEncoding(const QByteArray &encoding)
@@ -235,6 +225,16 @@ bool Editor::saveAs(){
exception.reason());
return false;
}
+ switch(getFileType(mFilename)) {
+ case FileType::CppSource:
+ mUseCppSyntax = true;
+ break;
+ case FileType::CSource:
+ mUseCppSyntax = false;
+ break;
+ default:
+ mUseCppSyntax = pSettings->editor().defaultFileCpp();
+ }
//todo: update (reassign highlighter)
//todo: remove old file from parser and reparse file
@@ -2093,7 +2093,7 @@ void Editor::gotoDeclaration(const BufferCoord &pos)
mFilename,phrase,pos.Line);
if (!statement) {
- pMainWindow->updateStatusBarMessage(tr("Symbol '%1' not found!").arg(phrase));
+ pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;
@@ -2123,7 +2123,7 @@ void Editor::gotoDefinition(const BufferCoord &pos)
mFilename,phrase,pos.Line);
if (!statement) {
- pMainWindow->updateStatusBarMessage(tr("Symbol '%1' not found!").arg(phrase));
+ pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;
diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp
index 95cc6c5a..79512425 100644
--- a/RedPandaIDE/mainwindow.cpp
+++ b/RedPandaIDE/mainwindow.cpp
@@ -126,6 +126,10 @@ MainWindow::MainWindow(QWidget *parent)
mHeaderCompletionPopup = std::make_shared();
updateAppTitle();
+
+ connect(&mAutoSaveTimer, &QTimer::timeout,
+ this, &MainWindow::onAutoSaveTimeout);
+ resetAutoSaveTimer();
}
MainWindow::~MainWindow()
@@ -426,6 +430,16 @@ void MainWindow::updateClassBrowserForEditor(Editor *editor)
}
}
+void MainWindow::resetAutoSaveTimer()
+{
+ if (pSettings->editor().enableAutoSave()) {
+ //minute to milliseconds
+ mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
+ } else {
+ mAutoSaveTimer.stop();
+ }
+}
+
QPlainTextEdit *MainWindow::txtLocals()
{
return ui->txtLocals;
@@ -466,7 +480,7 @@ void MainWindow::updateForStatusbarModeInfo()
}
}
-void MainWindow::updateStatusBarMessage(const QString &s)
+void MainWindow::updateStatusbarMessage(const QString &s)
{
ui->statusbar->showMessage(s);
}
@@ -948,6 +962,65 @@ void MainWindow::prepareDebugger()
// mDebugger->deleteWatchVars(false);
}
+void MainWindow::doAutoSave(Editor *e)
+{
+ if (!e)
+ return;
+ if (!e->modified())
+ return;
+ QString filename = e->filename();
+ QFileInfo fileInfo(filename);
+ QDir parent = fileInfo.absoluteDir();
+ QString baseName = fileInfo.completeBaseName();
+ QString suffix = fileInfo.suffix();
+ switch(pSettings->editor().autoSaveStrategy()) {
+ case assOverwrite:
+ break;
+ case assAppendUnixTimestamp:
+ filename = parent.filePath(
+ QString("%1.%2.%3")
+ .arg(baseName)
+ .arg(QDateTime::currentSecsSinceEpoch())
+ .arg(suffix));
+ break;
+ case assAppendFormatedTimeStamp: {
+ QDateTime time = QDateTime::currentDateTime();
+ filename = parent.filePath(
+ QString("%1.%2.%3")
+ .arg(baseName)
+ .arg(time.toString("yyyy.MM.dd.hh.mm.ss"))
+ .arg(suffix));
+ }
+ }
+ e->saveFile(filename);
+}
+
+void MainWindow::onAutoSaveTimeout()
+{
+ if (!pSettings->editor().enableAutoSave())
+ return;
+ int updateCount = 0;
+ switch (pSettings->editor().autoSaveTarget()) {
+ case astCurrentFile: {
+ Editor *e = mEditorList->getEditor();
+ doAutoSave(e);
+ updateCount++;
+ }
+ break;
+ case astAllOpennedFiles:
+ for (int i=0;ipageCount();i++) {
+ Editor *e = (*mEditorList)[i];
+ doAutoSave(e);
+ updateCount++;
+ }
+ break;
+ case astAllProjectFiles:
+ //todo: auto save project files
+ break;
+ }
+ updateStatusbarMessage(tr("%1 files autosaved").arg(updateCount));
+}
+
const std::shared_ptr &MainWindow::headerCompletionPopup() const
{
return mHeaderCompletionPopup;
@@ -1611,7 +1684,7 @@ void MainWindow::onParserProgress(const QString &fileName, int total, int curren
// Only show if needed (it's a very slow operation)
if (current ==1 || current % showStep==0) {
- updateStatusBarMessage(tr("Parsing file %1 of %2: \"%3\"")
+ updateStatusbarMessage(tr("Parsing file %1 of %2: \"%3\"")
.arg(current).arg(total).arg(fileName));
}
}
@@ -1633,13 +1706,13 @@ void MainWindow::onEndParsing(int total, int)
} else {
parsingFrequency = 999;
}
- updateStatusBarMessage(tr("Done parsing %1 files in %2 seconds")
+ updateStatusbarMessage(tr("Done parsing %1 files in %2 seconds")
.arg(total).arg(parseTime)
+ " "
+ tr("(%1 files per second)")
.arg(parsingFrequency));
} else {
- updateStatusBarMessage(tr("Done parsing %1 files in %2 seconds")
+ updateStatusbarMessage(tr("Done parsing %1 files in %2 seconds")
.arg(total).arg(parseTime));
}
}
diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h
index 9b49d7f2..97a6f459 100644
--- a/RedPandaIDE/mainwindow.h
+++ b/RedPandaIDE/mainwindow.h
@@ -2,6 +2,7 @@
#define MAINWINDOW_H
#include
+#include
#include "common.h"
#include "widgets/searchresultview.h"
#include "widgets/classbrowser.h"
@@ -52,7 +53,7 @@ public:
void updateForEncodingInfo();
void updateStatusbarForLineCol();
void updateForStatusbarModeInfo();
- void updateStatusBarMessage(const QString& s);
+ void updateStatusbarMessage(const QString& s);
void updateEditorSettings();
void updateEditorActions();
void updateCompileActions();
@@ -79,6 +80,8 @@ public:
void updateClassBrowserForEditor(Editor* editor);
+ void resetAutoSaveTimer();
+
QPlainTextEdit* txtLocals();
CPUDialog *cpuDialog() const;
@@ -91,16 +94,39 @@ public:
SearchResultModel* searchResultModel();
-
-
const std::shared_ptr &completionPopup() const;
const std::shared_ptr &headerCompletionPopup() const;
+public slots:
+ void onCompileLog(const QString& msg);
+ void onCompileIssue(PCompileIssue issue);
+ void onCompileFinished();
+ void onCompileErrorOccured(const QString& reason);
+ void onRunErrorOccured(const QString& reason);
+ void onRunFinished();
+ void cleanUpCPUDialog();
+ void onDebugCommandInput(const QString& command);
+ void onDebugEvaluateInput();
+ void onParserProgress(const QString& fileName, int total, int current);
+ void onStartParsing();
+ void onEndParsing(int total, int updateView);
+ void onEvalValueReady(const QString& value);
protected:
void openFiles(const QStringList& files);
void openFile(const QString& filename);
+
+private:
+ CompileTarget getCompileTarget();
+ bool debugInferiorhasBreakpoint();
+ void setupActions();
+ void openCloseMessageSheet(bool open);
+ void prepareDebugger();
+ void doAutoSave(Editor *e);
+
private slots:
+ void onAutoSaveTimeout();
+
void on_actionNew_triggered();
void on_EditorTabsLeft_tabCloseRequested(int index);
@@ -168,9 +194,6 @@ private slots:
void on_actionDebug_triggered();
- CompileTarget getCompileTarget();
- bool debugInferiorhasBreakpoint();
-
void on_actionStep_Over_triggered();
void on_actionStep_Into_triggered();
@@ -200,27 +223,6 @@ private slots:
void on_cbSearchHistory_currentIndexChanged(int index);
void on_btnSearchAgin_clicked();
-
-public slots:
- void onCompileLog(const QString& msg);
- void onCompileIssue(PCompileIssue issue);
- void onCompileFinished();
- void onCompileErrorOccured(const QString& reason);
- void onRunErrorOccured(const QString& reason);
- void onRunFinished();
- void cleanUpCPUDialog();
- void onDebugCommandInput(const QString& command);
- void onDebugEvaluateInput();
- void onParserProgress(const QString& fileName, int total, int current);
- void onStartParsing();
- void onEndParsing(int total, int updateView);
- void onEvalValueReady(const QString& value);
-
-private:
- void setupActions();
- void openCloseMessageSheet(bool open);
- void prepareDebugger();
-
private:
Ui::MainWindow *ui;
EditorList *mEditorList;
@@ -254,6 +256,8 @@ private:
int mPreviousHeight;
PCompileSuccessionTask mCompileSuccessionTask;
+ QTimer mAutoSaveTimer;
+
// QWidget interface
protected:
diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp
index 83826c79..27701b8f 100644
--- a/RedPandaIDE/settings.cpp
+++ b/RedPandaIDE/settings.cpp
@@ -376,6 +376,46 @@ void Settings::Editor::setDefaultFileCpp(bool newDefaultFileCpp)
mDefaultFileCpp = newDefaultFileCpp;
}
+bool Settings::Editor::enableAutoSave() const
+{
+ return mEnableAutoSave;
+}
+
+void Settings::Editor::setEnableAutoSave(bool newEnableAutoSave)
+{
+ mEnableAutoSave = newEnableAutoSave;
+}
+
+int Settings::Editor::autoSaveInterval() const
+{
+ return mAutoSaveInterval;
+}
+
+void Settings::Editor::setAutoSaveInterval(int newInterval)
+{
+ mAutoSaveInterval = newInterval;
+}
+
+AutoSaveStrategy Settings::Editor::autoSaveStrategy() const
+{
+ return mAutoSaveStrategy;
+}
+
+void Settings::Editor::setAutoSaveStrategy(AutoSaveStrategy newAutoSaveStrategy)
+{
+ mAutoSaveStrategy = newAutoSaveStrategy;
+}
+
+AutoSaveTarget Settings::Editor::autoSaveTarget() const
+{
+ return mAutoSaveTarget;
+}
+
+void Settings::Editor::setAutoSaveTarget(AutoSaveTarget newAutoSaveTarget)
+{
+ mAutoSaveTarget = newAutoSaveTarget;
+}
+
bool Settings::Editor::autoLoadLastFiles() const
{
return mAutoLoadLastFiles;
@@ -831,6 +871,12 @@ void Settings::Editor::doSave()
saveValue("check_syntax_when_save",mSyntaxCheckWhenSave);
saveValue("check_syntax_when_line_changed",mSyntaxCheckWhenLineChanged);
+ //auto save
+ saveValue("enable_auto_save",mEnableAutoSave);
+ saveValue("auto_save_interal",mAutoSaveInterval);
+ saveValue("auto_save_target",mAutoSaveTarget);
+ saveValue("auto_save_strategy",mAutoSaveStrategy);
+
//misc
saveValue("default_encoding",mDefaultEncoding);
saveValue("readonly_system_header",mReadOnlySytemHeader);
@@ -915,6 +961,14 @@ void Settings::Editor::doLoad()
mSyntaxCheckWhenSave = boolValue("check_syntax_when_save",true);
mSyntaxCheckWhenLineChanged = boolValue("check_syntax_when_line_changed",true);
+ //auto save
+ mEnableAutoSave = boolValue("enable_auto_save",false);
+ mAutoSaveInterval = intValue("auto_save_interal",10);
+ mAutoSaveTarget = static_cast(
+ intValue("auto_save_target",AutoSaveTarget::astCurrentFile));
+ mAutoSaveStrategy = static_cast(
+ intValue("auto_save_strategy",AutoSaveStrategy::assOverwrite));
+
//misc
mDefaultEncoding = value("default_encoding", ENCODING_SYSTEM_DEFAULT).toByteArray();
mReadOnlySytemHeader = boolValue("readonly_system_header",true);
@@ -1602,7 +1656,7 @@ void Settings::CompilerSet::setDefines() {
arguments.append("-std=c++17");
arguments.append(NULL_FILE);
QFileInfo ccompiler(mCCompiler);
- QByteArray output = getCompilerOutput(ccompiler.absolutePath(),ccompiler.baseName(),arguments);
+ QByteArray output = getCompilerOutput(ccompiler.absolutePath(),ccompiler.fileName(),arguments);
// 'cpp.exe -dM -E -x c++ -std=c++17 NUL'
mDefines.clear();
diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h
index 751ecd27..49a9532b 100644
--- a/RedPandaIDE/settings.h
+++ b/RedPandaIDE/settings.h
@@ -271,6 +271,18 @@ public:
bool defaultFileCpp() const;
void setDefaultFileCpp(bool newDefaultFileCpp);
+ 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);
+
private:
//General
// indents
@@ -346,6 +358,12 @@ public:
bool mSyntaxCheckWhenSave;
bool mSyntaxCheckWhenLineChanged;
+ //auto save
+ bool mEnableAutoSave;
+ int mAutoSaveInterval;
+ enum AutoSaveTarget mAutoSaveTarget;
+ enum AutoSaveStrategy mAutoSaveStrategy;
+
//Misc
QByteArray mDefaultEncoding;
bool mReadOnlySytemHeader;
diff --git a/RedPandaIDE/settingsdialog/editorautosavewidget.cpp b/RedPandaIDE/settingsdialog/editorautosavewidget.cpp
new file mode 100644
index 00000000..1a9fad19
--- /dev/null
+++ b/RedPandaIDE/settingsdialog/editorautosavewidget.cpp
@@ -0,0 +1,94 @@
+#include "editorautosavewidget.h"
+#include "ui_editorautosavewidget.h"
+#include "../settings.h"
+#include "../mainwindow.h"
+
+EditorAutoSaveWidget::EditorAutoSaveWidget(const QString& name, const QString& group,
+ QWidget *parent) :
+ SettingsWidget(name,group,parent),
+ ui(new Ui::EditorAutoSaveWidget)
+{
+ ui->setupUi(this);
+}
+
+EditorAutoSaveWidget::~EditorAutoSaveWidget()
+{
+ delete ui;
+}
+
+void EditorAutoSaveWidget::onAutoSaveStrategyChanged()
+{
+ if (ui->rbOverwrite->isChecked()) {
+ ui->lblFilename->setText(tr("Demo file name: ") + "main.cpp");
+ } else if (ui->rbAppendUNIXTimestamp->isChecked()) {
+ ui->lblFilename->setText(tr("Demo file name: ") +
+ QString("main.%1.cpp").arg(QDateTime::currentSecsSinceEpoch()));
+ } else if (ui->rbAppendFormattedTimestamp->isChecked()) {
+ QDateTime time = QDateTime::currentDateTime();
+ ui->lblFilename->setText(tr("Demo file name: ") +
+ QString("main.%1.cpp").arg(time.toString("yyyy.MM.dd.hh.mm.ss")));
+ }
+}
+
+void EditorAutoSaveWidget::doLoad()
+{
+ //pSettings->editor().load();
+ //font
+ ui->chkEnableAutoSave->setChecked(pSettings->editor().enableAutoSave());
+ ui->spinInterval->setValue(pSettings->editor().autoSaveInterval());
+ switch(pSettings->editor().autoSaveTarget()) {
+ case astCurrentFile:
+ ui->rbCurrentFile->setChecked(true);
+ break;
+ case astAllOpennedFiles:
+ ui->rbAllOpennedFiles->setChecked(true);
+ default:
+ ui->rbProjectFiles->setChecked(true);
+ }
+ switch(pSettings->editor().autoSaveStrategy()) {
+ case assOverwrite:
+ ui->rbOverwrite->setChecked(true);
+ break;
+ case assAppendUnixTimestamp:
+ ui->rbAppendUNIXTimestamp->setChecked(true);
+ break;
+ default:
+ ui->rbAppendFormattedTimestamp->setChecked(true);
+ }
+}
+
+void EditorAutoSaveWidget::doSave()
+{
+ pSettings->editor().setEnableAutoSave(ui->chkEnableAutoSave->isChecked());
+ pSettings->editor().setAutoSaveInterval(ui->spinInterval->value());
+ if (ui->rbCurrentFile->isChecked())
+ pSettings->editor().setAutoSaveTarget(astCurrentFile);
+ else if (ui->rbAllOpennedFiles->isChecked())
+ pSettings->editor().setAutoSaveTarget(astAllOpennedFiles);
+ else
+ pSettings->editor().setAutoSaveTarget(astAllProjectFiles);
+ if (ui->rbOverwrite->isChecked())
+ pSettings->editor().setAutoSaveStrategy(assOverwrite);
+ else if (ui->rbAppendUNIXTimestamp->isChecked())
+ pSettings->editor().setAutoSaveStrategy(assAppendUnixTimestamp);
+ else
+ pSettings->editor().setAutoSaveStrategy(assAppendFormatedTimeStamp);
+}
+
+void EditorAutoSaveWidget::on_rbOverwrite_toggled(bool)
+{
+ onAutoSaveStrategyChanged();
+}
+
+
+void EditorAutoSaveWidget::on_rbAppendUNIXTimestamp_toggled(bool)
+{
+ onAutoSaveStrategyChanged();
+}
+
+
+void EditorAutoSaveWidget::on_rbAppendFormattedTimestamp_toggled(bool)
+{
+ onAutoSaveStrategyChanged();
+}
+
diff --git a/RedPandaIDE/settingsdialog/editorautosavewidget.h b/RedPandaIDE/settingsdialog/editorautosavewidget.h
new file mode 100644
index 00000000..9fc289dc
--- /dev/null
+++ b/RedPandaIDE/settingsdialog/editorautosavewidget.h
@@ -0,0 +1,34 @@
+#ifndef EDITORAUTOSAVEWIDGET_H
+#define EDITORAUTOSAVEWIDGET_H
+
+#include
+#include "settingswidget.h"
+
+namespace Ui {
+class EditorAutoSaveWidget;
+}
+
+class EditorAutoSaveWidget : public SettingsWidget
+{
+ Q_OBJECT
+
+public:
+ explicit EditorAutoSaveWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
+ ~EditorAutoSaveWidget();
+
+private:
+ void onAutoSaveStrategyChanged();
+private:
+ Ui::EditorAutoSaveWidget *ui;
+
+ // SettingsWidget interface
+protected:
+ void doLoad() override;
+ void doSave() override;
+private slots:
+ void on_rbOverwrite_toggled(bool checked);
+ void on_rbAppendUNIXTimestamp_toggled(bool checked);
+ void on_rbAppendFormattedTimestamp_toggled(bool checked);
+};
+
+#endif // EDITORAUTOSAVEWIDGET_H
diff --git a/RedPandaIDE/settingsdialog/editorautosavewidget.ui b/RedPandaIDE/settingsdialog/editorautosavewidget.ui
new file mode 100644
index 00000000..5f36b260
--- /dev/null
+++ b/RedPandaIDE/settingsdialog/editorautosavewidget.ui
@@ -0,0 +1,164 @@
+
+
+ EditorAutoSaveWidget
+
+
+
+ 0
+ 0
+ 469
+ 459
+
+
+
+ Form
+
+
+ -
+
+
+ Enable auto save
+
+
+ true
+
+
+
-
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Time interval:
+
+
+
+ -
+
+
+ minutes
+
+
+ 1
+
+
+ 60
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+ -
+
+
+ Objects to save
+
+
+
-
+
+
+ Current File
+
+
+
+ -
+
+
+ All files openned
+
+
+
+ -
+
+
+ Project files
+
+
+
+
+
+
+ -
+
+
+ Save strategy
+
+
+
-
+
+
+ Overwrite
+
+
+
+ -
+
+
+ Append UNIX timestamp
+
+
+
+ -
+
+
+ Append formatted timestamp
+
+
+
+
+
+
+ -
+
+
+ Demo file name:
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp
index 0d3526b2..51b274e1 100644
--- a/RedPandaIDE/settingsdialog/settingsdialog.cpp
+++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp
@@ -9,6 +9,7 @@
#include "editorcodecompletionwidget.h"
#include "editorsyntaxcheckwidget.h"
#include "editorsymbolcompletionwidget.h"
+#include "editorautosavewidget.h"
#include "editormiscwidget.h"
#include "environmentappearencewidget.h"
#include "executorgeneralwidget.h"
@@ -65,6 +66,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
pEditorSyntaxCheckWidget->init();
addWidget(pEditorSyntaxCheckWidget);
+ pEditorAutoSaveWidget = new EditorAutoSaveWidget(tr("Auto save"),tr("Editor"));
+ pEditorAutoSaveWidget->init();
+ addWidget(pEditorAutoSaveWidget);
+
pEditorMiscWidget = new EditorMiscWidget(tr("Misc"),tr("Editor"));
pEditorMiscWidget->init();
addWidget(pEditorMiscWidget);
diff --git a/RedPandaIDE/settingsdialog/settingsdialog.h b/RedPandaIDE/settingsdialog/settingsdialog.h
index d44bf449..080db4af 100644
--- a/RedPandaIDE/settingsdialog/settingsdialog.h
+++ b/RedPandaIDE/settingsdialog/settingsdialog.h
@@ -18,6 +18,7 @@ class EditorSymbolCompletionWidget;
class EditorColorSchemeWidget;
class EditorSyntaxCheckWidget;
class EditorCodeCompletionWidget;
+class EditorAutoSaveWidget;
class EditorMiscWidget;
class EnvironmentAppearenceWidget;
class ExecutorGeneralWidget;
@@ -60,6 +61,7 @@ private:
EditorSymbolCompletionWidget *pEditorSymbolCompletionWidget;
EditorCodeCompletionWidget *pEditorCodeCompletionWidget;
EditorSyntaxCheckWidget *pEditorSyntaxCheckWidget;
+ EditorAutoSaveWidget *pEditorAutoSaveWidget;
EditorMiscWidget *pEditorMiscWidget;
ExecutorGeneralWidget *pExecutorGeneralWidget;
DebugGeneralWidget *pDebugGeneralWidget;
diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h
index 88ef4426..95a4f12e 100644
--- a/RedPandaIDE/utils.h
+++ b/RedPandaIDE/utils.h
@@ -40,6 +40,18 @@ enum class SearchFileScope {
openedFiles
};
+enum AutoSaveTarget {
+ astCurrentFile,
+ astAllOpennedFiles,
+ astAllProjectFiles
+};
+
+enum AutoSaveStrategy {
+ assOverwrite,
+ assAppendUnixTimestamp,
+ assAppendFormatedTimeStamp
+};
+
class BaseError{
public:
explicit BaseError(const QString& reason);