- fix: editor auto save settings not saved and applied
- fix: only auto save files that has new modifications - fix: correctly auto save files with it's own name
This commit is contained in:
parent
58ba490f32
commit
d28805ea55
3
NEWS.md
3
NEWS.md
|
@ -1,6 +1,9 @@
|
||||||
Version 0.8.6 For Dev-C++ 7 Beta
|
Version 0.8.6 For Dev-C++ 7 Beta
|
||||||
- enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+)
|
- enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+)
|
||||||
- fix: currect compiler set not correctly updated when switch between normal file and project file
|
- fix: currect compiler set not correctly updated when switch between normal file and project file
|
||||||
|
- fix: editor auto save settings not saved and applied
|
||||||
|
- fix: only auto save files that has new modifications
|
||||||
|
- fix: correctly auto save files with it's own name
|
||||||
|
|
||||||
Version 0.8.5 For Dev-C++ 7 Beta
|
Version 0.8.5 For Dev-C++ 7 Beta
|
||||||
- enhancement: use lighter color to draw menu seperators
|
- enhancement: use lighter color to draw menu seperators
|
||||||
|
|
|
@ -151,10 +151,12 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
connect(this, &QWidget::customContextMenuRequested,
|
connect(this, &QWidget::customContextMenuRequested,
|
||||||
pMainWindow, &MainWindow::onEditorContextMenu);
|
pMainWindow, &MainWindow::onEditorContextMenu);
|
||||||
|
|
||||||
|
mCanAutoSave = false;
|
||||||
if (isNew && parentPageControl!=nullptr) {
|
if (isNew && parentPageControl!=nullptr) {
|
||||||
QString fileTemplate = pMainWindow->codeSnippetManager()->newFileTemplate();
|
QString fileTemplate = pMainWindow->codeSnippetManager()->newFileTemplate();
|
||||||
if (!fileTemplate.isEmpty()) {
|
if (!fileTemplate.isEmpty()) {
|
||||||
insertCodeSnippet(fileTemplate);
|
insertCodeSnippet(fileTemplate);
|
||||||
|
mCanAutoSave = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isNew && parentPageControl!=nullptr) {
|
if (!isNew && parentPageControl!=nullptr) {
|
||||||
|
@ -1390,6 +1392,8 @@ void Editor::onStatusChanged(SynStatusChanges changes)
|
||||||
}
|
}
|
||||||
if (changes.testFlag(scModified)) {
|
if (changes.testFlag(scModified)) {
|
||||||
mCurrentLineModified = true;
|
mCurrentLineModified = true;
|
||||||
|
if (mParentPageControl!=nullptr)
|
||||||
|
mCanAutoSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changes.testFlag(SynStatusChange::scCaretX)
|
if (changes.testFlag(SynStatusChange::scCaretX)
|
||||||
|
@ -3120,6 +3124,16 @@ void Editor::onExportedFormatToken(PSynHighlighter syntaxHighlighter, int Line,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Editor::canAutoSave() const
|
||||||
|
{
|
||||||
|
return mCanAutoSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Editor::setCanAutoSave(bool newCanAutoSave)
|
||||||
|
{
|
||||||
|
mCanAutoSave = newCanAutoSave;
|
||||||
|
}
|
||||||
|
|
||||||
const QDateTime &Editor::hideTime() const
|
const QDateTime &Editor::hideTime() const
|
||||||
{
|
{
|
||||||
return mHideTime;
|
return mHideTime;
|
||||||
|
|
|
@ -269,6 +269,7 @@ private:
|
||||||
int mTabStopBegin;
|
int mTabStopBegin;
|
||||||
int mTabStopEnd;
|
int mTabStopEnd;
|
||||||
int mTabStopY;
|
int mTabStopY;
|
||||||
|
bool mCanAutoSave;
|
||||||
QString mLineBeforeTabStop;
|
QString mLineBeforeTabStop;
|
||||||
QString mLineAfterTabStop;
|
QString mLineAfterTabStop;
|
||||||
QList<PTabStop> mUserCodeInTabStops;
|
QList<PTabStop> mUserCodeInTabStops;
|
||||||
|
@ -312,6 +313,9 @@ public:
|
||||||
const QDateTime &hideTime() const;
|
const QDateTime &hideTime() const;
|
||||||
void setHideTime(const QDateTime &newHideTime);
|
void setHideTime(const QDateTime &newHideTime);
|
||||||
|
|
||||||
|
bool canAutoSave() const;
|
||||||
|
void setCanAutoSave(bool newCanAutoSave);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
|
|
@ -799,8 +799,10 @@ void MainWindow::updateClassBrowserForEditor(Editor *editor)
|
||||||
void MainWindow::resetAutoSaveTimer()
|
void MainWindow::resetAutoSaveTimer()
|
||||||
{
|
{
|
||||||
if (pSettings->editor().enableAutoSave()) {
|
if (pSettings->editor().enableAutoSave()) {
|
||||||
|
mAutoSaveTimer.stop();
|
||||||
//minute to milliseconds
|
//minute to milliseconds
|
||||||
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
|
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
|
||||||
|
onAutoSaveTimeout();
|
||||||
} else {
|
} else {
|
||||||
mAutoSaveTimer.stop();
|
mAutoSaveTimer.stop();
|
||||||
}
|
}
|
||||||
|
@ -1547,18 +1549,19 @@ void MainWindow::prepareDebugger()
|
||||||
|
|
||||||
void MainWindow::doAutoSave(Editor *e)
|
void MainWindow::doAutoSave(Editor *e)
|
||||||
{
|
{
|
||||||
if (!e)
|
|
||||||
return;
|
if (!e || !e->canAutoSave())
|
||||||
if (!e->modified())
|
|
||||||
return;
|
return;
|
||||||
QString filename = e->filename();
|
QString filename = e->filename();
|
||||||
|
try {
|
||||||
QFileInfo fileInfo(filename);
|
QFileInfo fileInfo(filename);
|
||||||
QDir parent = fileInfo.absoluteDir();
|
QDir parent = fileInfo.absoluteDir();
|
||||||
QString baseName = fileInfo.completeBaseName();
|
QString baseName = fileInfo.completeBaseName();
|
||||||
QString suffix = fileInfo.suffix();
|
QString suffix = fileInfo.suffix();
|
||||||
switch(pSettings->editor().autoSaveStrategy()) {
|
switch(pSettings->editor().autoSaveStrategy()) {
|
||||||
case assOverwrite:
|
case assOverwrite:
|
||||||
break;
|
e->save();
|
||||||
|
return;
|
||||||
case assAppendUnixTimestamp:
|
case assAppendUnixTimestamp:
|
||||||
filename = parent.filePath(
|
filename = parent.filePath(
|
||||||
QString("%1.%2.%3")
|
QString("%1.%2.%3")
|
||||||
|
@ -1575,7 +1578,18 @@ void MainWindow::doAutoSave(Editor *e)
|
||||||
.arg(suffix));
|
.arg(suffix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e->isNew()) {
|
||||||
|
e->saveAs();
|
||||||
|
} else {
|
||||||
e->saveFile(filename);
|
e->saveFile(filename);
|
||||||
|
e->setCanAutoSave(false);
|
||||||
|
}
|
||||||
|
} catch (FileError& error) {
|
||||||
|
QMessageBox::critical(e,
|
||||||
|
tr("Auto Save Error"),
|
||||||
|
tr("Auto save \"%1\" to \"%2\" failed:%3")
|
||||||
|
.arg(e->filename(), filename, error.reason()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void limitActionShortCutScope(QAction* action,QWidget* scopeWidget) {
|
//static void limitActionShortCutScope(QAction* action,QWidget* scopeWidget) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ void EditorAutoSaveWidget::doLoad()
|
||||||
{
|
{
|
||||||
//pSettings->editor().load();
|
//pSettings->editor().load();
|
||||||
//font
|
//font
|
||||||
ui->chkEnableAutoSave->setChecked(pSettings->editor().enableAutoSave());
|
ui->grpEnableAutoSave->setChecked(pSettings->editor().enableAutoSave());
|
||||||
ui->spinInterval->setValue(pSettings->editor().autoSaveInterval());
|
ui->spinInterval->setValue(pSettings->editor().autoSaveInterval());
|
||||||
switch(pSettings->editor().autoSaveTarget()) {
|
switch(pSettings->editor().autoSaveTarget()) {
|
||||||
case astCurrentFile:
|
case astCurrentFile:
|
||||||
|
@ -60,7 +60,7 @@ void EditorAutoSaveWidget::doLoad()
|
||||||
|
|
||||||
void EditorAutoSaveWidget::doSave()
|
void EditorAutoSaveWidget::doSave()
|
||||||
{
|
{
|
||||||
pSettings->editor().setEnableAutoSave(ui->chkEnableAutoSave->isChecked());
|
pSettings->editor().setEnableAutoSave(ui->grpEnableAutoSave->isChecked());
|
||||||
pSettings->editor().setAutoSaveInterval(ui->spinInterval->value());
|
pSettings->editor().setAutoSaveInterval(ui->spinInterval->value());
|
||||||
if (ui->rbCurrentFile->isChecked())
|
if (ui->rbCurrentFile->isChecked())
|
||||||
pSettings->editor().setAutoSaveTarget(astCurrentFile);
|
pSettings->editor().setAutoSaveTarget(astCurrentFile);
|
||||||
|
@ -74,6 +74,8 @@ void EditorAutoSaveWidget::doSave()
|
||||||
pSettings->editor().setAutoSaveStrategy(assAppendUnixTimestamp);
|
pSettings->editor().setAutoSaveStrategy(assAppendUnixTimestamp);
|
||||||
else
|
else
|
||||||
pSettings->editor().setAutoSaveStrategy(assAppendFormatedTimeStamp);
|
pSettings->editor().setAutoSaveStrategy(assAppendFormatedTimeStamp);
|
||||||
|
pSettings->editor().save();
|
||||||
|
pMainWindow->resetAutoSaveTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorAutoSaveWidget::on_rbOverwrite_toggled(bool)
|
void EditorAutoSaveWidget::on_rbOverwrite_toggled(bool)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="chkEnableAutoSave">
|
<widget class="QGroupBox" name="grpEnableAutoSave">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Enable auto save</string>
|
<string>Enable auto save</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -805,12 +805,12 @@ void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *op
|
||||||
|
|
||||||
switch (element) {
|
switch (element) {
|
||||||
case CE_MenuItem:
|
case CE_MenuItem:
|
||||||
painter->save();
|
|
||||||
// Draws one item in a popup menu.
|
// Draws one item in a popup menu.
|
||||||
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||||
QColor highlightOutline = highlightedOutline;
|
QColor highlightOutline = highlightedOutline;
|
||||||
QColor highlight = option->palette.highlight().color();
|
QColor highlight = option->palette.highlight().color();
|
||||||
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
||||||
|
painter->save();
|
||||||
int w = 0;
|
int w = 0;
|
||||||
const int margin = int(QStyleHelper::dpiScaled(5, option));
|
const int margin = int(QStyleHelper::dpiScaled(5, option));
|
||||||
if (!menuItem->text.isEmpty()) {
|
if (!menuItem->text.isEmpty()) {
|
||||||
|
|
Loading…
Reference in New Issue