mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-17 21:04:19 -05: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) {
|
if (parent) {
|
||||||
parent->activateWindow();
|
parent->activateWindow();
|
||||||
}
|
}
|
||||||
if (!result.isEmpty() && m_nextSaveLastDir) {
|
|
||||||
config()->set("LastDir", QFileInfo(result).absolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_nextSaveLastDir = true;
|
saveLastDir(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,11 +70,9 @@ QStringList FileDialog::getOpenFileNames(QWidget *parent, const QString &caption
|
|||||||
parent->activateWindow();
|
parent->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!results.isEmpty() && m_nextSaveLastDir) {
|
if (!results.isEmpty()) {
|
||||||
config()->set("LastDir", QFileInfo(results[0]).absolutePath());
|
saveLastDir(results[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nextSaveLastDir = true;
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,11 +121,7 @@ QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QSt
|
|||||||
parent->activateWindow();
|
parent->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.isEmpty() && m_nextSaveLastDir) {
|
saveLastDir(result);
|
||||||
config()->set("LastDir", QFileInfo(result).absolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_nextSaveLastDir = true;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,11 +146,7 @@ QString FileDialog::getExistingDirectory(QWidget *parent, const QString &caption
|
|||||||
parent->activateWindow();
|
parent->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dir.isEmpty() && m_nextSaveLastDir) {
|
saveLastDir(dir);
|
||||||
config()->set("LastDir", QFileInfo(dir).absolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_nextSaveLastDir = true;
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,13 +168,21 @@ void FileDialog::setNextDirName(const QString &dirName)
|
|||||||
|
|
||||||
void FileDialog::setNextForgetDialog()
|
void FileDialog::setNextForgetDialog()
|
||||||
{
|
{
|
||||||
m_nextSaveLastDir = false;
|
m_forgetLastDir = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDialog::FileDialog()
|
FileDialog::FileDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileDialog::saveLastDir(QString dir) {
|
||||||
|
if (!dir.isEmpty() && !m_forgetLastDir) {
|
||||||
|
config()->set("LastDir", QFileInfo(dir).absolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_forgetLastDir = false;
|
||||||
|
}
|
||||||
|
|
||||||
FileDialog* FileDialog::instance()
|
FileDialog* FileDialog::instance()
|
||||||
{
|
{
|
||||||
if (!m_instance) {
|
if (!m_instance) {
|
||||||
|
@ -52,7 +52,9 @@ private:
|
|||||||
QString m_nextFileName;
|
QString m_nextFileName;
|
||||||
QStringList m_nextFileNames;
|
QStringList m_nextFileNames;
|
||||||
QString m_nextDirName;
|
QString m_nextDirName;
|
||||||
bool m_nextSaveLastDir = true;
|
bool m_forgetLastDir = false;
|
||||||
|
|
||||||
|
void saveLastDir(QString);
|
||||||
|
|
||||||
static FileDialog* m_instance;
|
static FileDialog* m_instance;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user