mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
refactor saveLastDir code
This commit is contained in:
parent
cd1e0571a5
commit
135e8419ae
@ -42,11 +42,8 @@ QString FileDialog::getOpenFileName(QWidget* parent, const QString& caption, QSt
|
||||
if (parent) {
|
||||
parent->activateWindow();
|
||||
}
|
||||
if (!result.isEmpty() && m_nextSaveLastDir) {
|
||||
config()->set("LastDir", QFileInfo(result).absolutePath());
|
||||
}
|
||||
|
||||
m_nextSaveLastDir = true;
|
||||
saveLastDir(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -73,11 +70,9 @@ QStringList FileDialog::getOpenFileNames(QWidget *parent, const QString &caption
|
||||
parent->activateWindow();
|
||||
}
|
||||
|
||||
if (!results.isEmpty() && m_nextSaveLastDir) {
|
||||
config()->set("LastDir", QFileInfo(results[0]).absolutePath());
|
||||
if (!results.isEmpty()) {
|
||||
saveLastDir(results[0]);
|
||||
}
|
||||
|
||||
m_nextSaveLastDir = true;
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@ -126,11 +121,7 @@ QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QSt
|
||||
parent->activateWindow();
|
||||
}
|
||||
|
||||
if (!result.isEmpty() && m_nextSaveLastDir) {
|
||||
config()->set("LastDir", QFileInfo(result).absolutePath());
|
||||
}
|
||||
|
||||
m_nextSaveLastDir = true;
|
||||
saveLastDir(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -155,11 +146,7 @@ QString FileDialog::getExistingDirectory(QWidget *parent, const QString &caption
|
||||
parent->activateWindow();
|
||||
}
|
||||
|
||||
if (!dir.isEmpty() && m_nextSaveLastDir) {
|
||||
config()->set("LastDir", QFileInfo(dir).absolutePath());
|
||||
}
|
||||
|
||||
m_nextSaveLastDir = true;
|
||||
saveLastDir(dir);
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
@ -181,13 +168,21 @@ void FileDialog::setNextDirName(const QString &dirName)
|
||||
|
||||
void FileDialog::setNextForgetDialog()
|
||||
{
|
||||
m_nextSaveLastDir = false;
|
||||
m_forgetLastDir = true;
|
||||
}
|
||||
|
||||
FileDialog::FileDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void FileDialog::saveLastDir(QString dir) {
|
||||
if (!dir.isEmpty() && !m_forgetLastDir) {
|
||||
config()->set("LastDir", QFileInfo(dir).absolutePath());
|
||||
}
|
||||
|
||||
m_forgetLastDir = false;
|
||||
}
|
||||
|
||||
FileDialog* FileDialog::instance()
|
||||
{
|
||||
if (!m_instance) {
|
||||
|
@ -52,7 +52,9 @@ private:
|
||||
QString m_nextFileName;
|
||||
QStringList m_nextFileNames;
|
||||
QString m_nextDirName;
|
||||
bool m_nextSaveLastDir = true;
|
||||
bool m_forgetLastDir = false;
|
||||
|
||||
void saveLastDir(QString);
|
||||
|
||||
static FileDialog* m_instance;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user