- enhancement: auto save/load the default open folder in the configuration file

This commit is contained in:
royqh1979@gmail.com 2021-11-10 10:42:33 +08:00
parent 1549fe1aed
commit 4e7269cbf0
6 changed files with 31 additions and 1 deletions

View File

@ -1,3 +1,6 @@
Version 0.8.4 For Dev-C++ 7 Beta
- enhancement: auto save/load the default open folder in the configuration file
Version 0.8.3 For Dev-C++ 7 Beta Version 0.8.3 For Dev-C++ 7 Beta
- enhancement: View menu - enhancement: View menu
- enhancement: hide/show statusbar - enhancement: hide/show statusbar

View File

@ -124,6 +124,10 @@ int main(int argc, char *argv[])
QMessageBox::Ok); QMessageBox::Ok);
} }
//set default open folder
QDir::setCurrent(pSettings->environment().defaultOpenFolder());
MainWindow mainWindow; MainWindow mainWindow;
pMainWindow = &mainWindow; pMainWindow = &mainWindow;
if (app.arguments().count()>1) { if (app.arguments().count()>1) {

View File

@ -3254,6 +3254,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
settings.save(); settings.save();
//save current folder ( for files view ) //save current folder ( for files view )
pSettings->environment().setDefaultOpenFolder(QDir::currentPath());
pSettings->environment().save(); pSettings->environment().save();
try { try {
mBookmarkModel->save(includeTrailingPathDelimiter(pSettings->dirs().config()) mBookmarkModel->save(includeTrailingPathDelimiter(pSettings->dirs().config())

View File

@ -2658,10 +2658,15 @@ void Settings::Environment::doLoad()
mInterfaceFont = stringValue("interface font","Segoe UI"); mInterfaceFont = stringValue("interface font","Segoe UI");
mInterfaceFontSize = intValue("interface font size",10); mInterfaceFontSize = intValue("interface font size",10);
mLanguage = stringValue("language", QLocale::system().name()); mLanguage = stringValue("language", QLocale::system().name());
mCurrentFolder = stringValue("current_folder",QDir::currentPath()); mCurrentFolder = stringValue("current_folder",QDir::currentPath());
if (!fileExists(mCurrentFolder)) { if (!fileExists(mCurrentFolder)) {
mCurrentFolder = QDir::currentPath(); mCurrentFolder = QDir::currentPath();
} }
mDefaultOpenFolder = stringValue("default_open_folder",QDir::currentPath());
if (!fileExists(mDefaultOpenFolder)) {
mDefaultOpenFolder = QDir::currentPath();
}
} }
int Settings::Environment::interfaceFontSize() const int Settings::Environment::interfaceFontSize() const
@ -2694,6 +2699,16 @@ void Settings::Environment::setCurrentFolder(const QString &newCurrentFolder)
mCurrentFolder = newCurrentFolder; mCurrentFolder = newCurrentFolder;
} }
const QString &Settings::Environment::defaultOpenFolder() const
{
return mDefaultOpenFolder;
}
void Settings::Environment::setDefaultOpenFolder(const QString &newDefaultOpenFolder)
{
mDefaultOpenFolder = newDefaultOpenFolder;
}
void Settings::Environment::doSave() void Settings::Environment::doSave()
{ {
//Appearence //Appearence
@ -2701,7 +2716,9 @@ void Settings::Environment::doSave()
saveValue("interface font", mInterfaceFont); saveValue("interface font", mInterfaceFont);
saveValue("interface font size", mInterfaceFontSize); saveValue("interface font size", mInterfaceFontSize);
saveValue("language", mLanguage); saveValue("language", mLanguage);
saveValue("current_folder",mCurrentFolder); saveValue("current_folder",mCurrentFolder);
saveValue("default_open_folder",mDefaultOpenFolder);
} }
QString Settings::Environment::interfaceFont() const QString Settings::Environment::interfaceFont() const

View File

@ -468,6 +468,9 @@ public:
const QString &currentFolder() const; const QString &currentFolder() const;
void setCurrentFolder(const QString &newCurrentFolder); void setCurrentFolder(const QString &newCurrentFolder);
const QString &defaultOpenFolder() const;
void setDefaultOpenFolder(const QString &newDefaultOpenFolder);
private: private:
//Appearence //Appearence
@ -476,6 +479,8 @@ public:
int mInterfaceFontSize; int mInterfaceFontSize;
QString mLanguage; QString mLanguage;
QString mCurrentFolder; QString mCurrentFolder;
QString mDefaultOpenFolder;
// _Base interface // _Base interface
protected: protected:
void doSave() override; void doSave() override;

View File

@ -3,7 +3,7 @@
#include <QStringList> #include <QStringList>
#define DEVCPP_VERSION "beta.0.8.3" #define DEVCPP_VERSION "beta.0.8.4"
#define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN