- enhancement: auto load last open files at start
This commit is contained in:
parent
356db1349f
commit
0424f7cf45
1
NEWS.md
1
NEWS.md
|
@ -1,6 +1,7 @@
|
||||||
Version 0.2
|
Version 0.2
|
||||||
- fix : header file completion stop work when input '.'
|
- fix : header file completion stop work when input '.'
|
||||||
- change: continue to run / debug if there are compiling warnings (but no errors)
|
- change: continue to run / debug if there are compiling warnings (but no errors)
|
||||||
|
- enhancement: auto load last open files at start
|
||||||
- enhancement: class browser syntax colors and icons
|
- enhancement: class browser syntax colors and icons
|
||||||
- enhancement: function tips
|
- enhancement: function tips
|
||||||
- enhancement: project support
|
- enhancement: project support
|
||||||
|
|
|
@ -95,6 +95,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
pMainWindow = &mainWindow;
|
pMainWindow = &mainWindow;
|
||||||
|
if (pSettings->editor().autoLoadLastFiles())
|
||||||
|
pMainWindow->loadLastOpens();
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
int retCode = app.exec();
|
int retCode = app.exec();
|
||||||
// save settings
|
// save settings
|
||||||
|
|
|
@ -169,6 +169,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
buildContextMenus();
|
buildContextMenus();
|
||||||
|
|
||||||
updateEditorColorSchemes();
|
updateEditorColorSchemes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -1447,12 +1448,96 @@ void MainWindow::scanActiveProject(bool parse)
|
||||||
|
|
||||||
void MainWindow::saveLastOpens()
|
void MainWindow::saveLastOpens()
|
||||||
{
|
{
|
||||||
|
QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_LASTOPENS_FILE;
|
||||||
|
if (fileExists(filename)) {
|
||||||
|
if (!QFile::remove(filename)) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Save last open info error"),
|
||||||
|
tr("Can't remove old last open information file '%1'")
|
||||||
|
.arg(filename),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
SimpleIni lastOpenIni;
|
||||||
|
lastOpenIni.SetLongValue("LastOpens","Count", mEditorList->pageCount());
|
||||||
|
if (mProject) {
|
||||||
|
lastOpenIni.SetValue("LastOpens","Project",mProject->filename().toLocal8Bit());
|
||||||
|
}
|
||||||
|
for (int i=0;i<mEditorList->pageCount();i++) {
|
||||||
|
Editor * editor = (*mEditorList)[i];
|
||||||
|
QByteArray sectionName = QString("Editor_%1").arg(i).toLocal8Bit();
|
||||||
|
lastOpenIni.SetValue(sectionName,"FileName", editor->filename().toLocal8Bit());
|
||||||
|
lastOpenIni.SetBoolValue(sectionName, "OnLeft",editor->pageControl() != ui->EditorTabsRight);
|
||||||
|
lastOpenIni.SetBoolValue(sectionName, "Focused",editor->hasFocus());
|
||||||
|
lastOpenIni.SetLongValue(sectionName, "CursorCol", editor->caretX());
|
||||||
|
lastOpenIni.SetLongValue(sectionName, "CursorRow", editor->caretY());
|
||||||
|
lastOpenIni.SetLongValue(sectionName, "TopLine", editor->topLine());
|
||||||
|
lastOpenIni.SetLongValue(sectionName, "LeftChar", editor->leftChar());
|
||||||
|
}
|
||||||
|
if (lastOpenIni.SaveFile(filename.toLocal8Bit())!=SI_Error::SI_OK) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Save last open info error"),
|
||||||
|
tr("Can't save last open info file '%1'")
|
||||||
|
.arg(filename),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadLastOpens()
|
void MainWindow::loadLastOpens()
|
||||||
{
|
{
|
||||||
|
QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_LASTOPENS_FILE;
|
||||||
|
if (!fileExists(filename))
|
||||||
|
return;
|
||||||
|
SimpleIni lastOpenIni;
|
||||||
|
if (lastOpenIni.LoadFile(filename.toLocal8Bit())!=SI_Error::SI_OK) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Load last open info error"),
|
||||||
|
tr("Can't load last open info file '%1'")
|
||||||
|
.arg(filename),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Editor * focusedEditor = nullptr;
|
||||||
|
int count = lastOpenIni.GetLongValue("LastOpens","Count",0);
|
||||||
|
for (int i=0;i<count;i++) {
|
||||||
|
QByteArray sectionName = QString("Editor_%1").arg(i).toLocal8Bit();
|
||||||
|
QString editorFilename = lastOpenIni.GetValue(sectionName,"FileName","");
|
||||||
|
if (!fileExists(editorFilename))
|
||||||
|
continue;
|
||||||
|
bool onLeft = lastOpenIni.GetBoolValue(sectionName,"OnLeft",true);
|
||||||
|
// if onLeft then
|
||||||
|
// page := EditorList.LeftPageControl
|
||||||
|
// else
|
||||||
|
// page := EditorList.RightPageControl;
|
||||||
|
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,false,false);
|
||||||
|
if (!editor)
|
||||||
|
continue;
|
||||||
|
BufferCoord pos;
|
||||||
|
pos.Char = lastOpenIni.GetLongValue(sectionName,"CursorCol", 1);
|
||||||
|
pos.Line = lastOpenIni.GetLongValue(sectionName,"CursorRow", 1);
|
||||||
|
editor->setCaretXY(pos);
|
||||||
|
editor->setTopLine(
|
||||||
|
lastOpenIni.GetLongValue(sectionName,"TopLine", 1)
|
||||||
|
);
|
||||||
|
editor->setLeftChar(
|
||||||
|
lastOpenIni.GetLongValue(sectionName,"LeftChar", 1)
|
||||||
|
);
|
||||||
|
if (lastOpenIni.GetBoolValue(sectionName,"Focused",false))
|
||||||
|
focusedEditor = editor;
|
||||||
|
pSettings->history().removeFile(editorFilename);
|
||||||
|
}
|
||||||
|
QString projectFilename = lastOpenIni.GetValue("LastOpens", "Project","");
|
||||||
|
if (fileExists(projectFilename)) {
|
||||||
|
openProject(filename);
|
||||||
|
} else {
|
||||||
|
updateEditorActions();
|
||||||
|
updateForEncodingInfo();
|
||||||
|
}
|
||||||
|
if (!focusedEditor)
|
||||||
|
focusedEditor->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::buildContextMenus()
|
void MainWindow::buildContextMenus()
|
||||||
|
@ -2240,8 +2325,13 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
settings.setLeftPanelOpenned(mLeftPanelOpenned);
|
settings.setLeftPanelOpenned(mLeftPanelOpenned);
|
||||||
settings.save();
|
settings.save();
|
||||||
|
|
||||||
if (mProject) {
|
if (pSettings->editor().autoLoadLastFiles()) {
|
||||||
closeProject(false);
|
saveLastOpens();
|
||||||
|
} else {
|
||||||
|
//if don't save last open files, close project before editors, to save project openned editors;
|
||||||
|
if (mProject) {
|
||||||
|
closeProject(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mEditorList->closeAll(false)) {
|
if (!mEditorList->closeAll(false)) {
|
||||||
|
@ -2249,6 +2339,12 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pSettings->editor().autoLoadLastFiles()) {
|
||||||
|
if (mProject) {
|
||||||
|
closeProject(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mCompilerManager->stopCompile();
|
mCompilerManager->stopCompile();
|
||||||
mCompilerManager->stopRun();
|
mCompilerManager->stopRun();
|
||||||
|
|
|
@ -81,13 +81,14 @@ public:
|
||||||
void addDebugOutput(const QString& text);
|
void addDebugOutput(const QString& text);
|
||||||
void changeDebugOutputLastline(const QString& text);
|
void changeDebugOutputLastline(const QString& text);
|
||||||
void updateDebugEval(const QString& value);
|
void updateDebugEval(const QString& value);
|
||||||
|
|
||||||
void rebuildOpenedFileHisotryMenu();
|
void rebuildOpenedFileHisotryMenu();
|
||||||
|
|
||||||
void updateClassBrowserForEditor(Editor* editor);
|
void updateClassBrowserForEditor(Editor* editor);
|
||||||
|
|
||||||
void resetAutoSaveTimer();
|
void resetAutoSaveTimer();
|
||||||
|
|
||||||
|
void saveLastOpens();
|
||||||
|
void loadLastOpens();
|
||||||
|
|
||||||
|
|
||||||
QPlainTextEdit* txtLocals();
|
QPlainTextEdit* txtLocals();
|
||||||
|
|
||||||
CPUDialog *cpuDialog() const;
|
CPUDialog *cpuDialog() const;
|
||||||
|
@ -154,8 +155,6 @@ private:
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
QKeySequence shortcut=QKeySequence());
|
QKeySequence shortcut=QKeySequence());
|
||||||
void scanActiveProject(bool parse=false);
|
void scanActiveProject(bool parse=false);
|
||||||
void saveLastOpens();
|
|
||||||
void loadLastOpens();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAutoSaveTimeout();
|
void onAutoSaveTimeout();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#define ICON_EXT "ico"
|
#define ICON_EXT "ico"
|
||||||
#define TEMPLATE_EXT "template"
|
#define TEMPLATE_EXT "template"
|
||||||
#define DEV_INTERNAL_OPEN "$__DEV_INTERNAL_OPEN"
|
#define DEV_INTERNAL_OPEN "$__DEV_INTERNAL_OPEN"
|
||||||
|
#define DEV_LASTOPENS_FILE "lastopens.ini"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
||||||
|
|
Loading…
Reference in New Issue