mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Added support for automatically saving and opening recent folder (#1149)
This commit is contained in:
parent
410eb7aba4
commit
339d1328c3
@ -95,6 +95,18 @@ void Configuration::setDirProjects(const QString &dir)
|
||||
s.setValue("dir.projects", QDir::toNativeSeparators(dir));
|
||||
}
|
||||
|
||||
QString Configuration::getRecentFolder()
|
||||
{
|
||||
QString recentFolder = s.value("dir.recentFolder", QDir::homePath()).toString();
|
||||
|
||||
return QDir::toNativeSeparators(recentFolder);
|
||||
}
|
||||
|
||||
void Configuration::setRecentFolder(const QString &dir)
|
||||
{
|
||||
s.setValue("dir.recentFolder", QDir::toNativeSeparators(dir));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configuration::setFilesTabLastClicked
|
||||
* Set the new file dialog last clicked tab
|
||||
|
@ -72,6 +72,9 @@ public:
|
||||
QString getDirProjects();
|
||||
void setDirProjects(const QString &dir);
|
||||
|
||||
QString getRecentFolder();
|
||||
void setRecentFolder(const QString &dir);
|
||||
|
||||
void setNewFileLastClicked(int lastClicked);
|
||||
int getNewFileLastClicked();
|
||||
|
||||
|
@ -84,11 +84,13 @@ void NewFileDialog::on_loadFileButton_clicked()
|
||||
|
||||
void NewFileDialog::on_selectFileButton_clicked()
|
||||
{
|
||||
const QString &fileName = QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, tr("Select file"), QDir::homePath()));
|
||||
QString currentDir = Config()->getRecentFolder();
|
||||
const QString &fileName = QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, tr("Select file"), currentDir));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
ui->newFileEdit->setText(fileName);
|
||||
ui->loadFileButton->setFocus();
|
||||
Config()->setRecentFolder(QFileInfo(fileName).absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "OpenFileDialog.h"
|
||||
#include "ui_OpenFileDialog.h"
|
||||
|
||||
#include "common/Configuration.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
OpenFileDialog::OpenFileDialog(QWidget *parent):
|
||||
@ -14,10 +16,12 @@ OpenFileDialog::~OpenFileDialog() {}
|
||||
|
||||
void OpenFileDialog::on_selectFileButton_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select file"), QDir::homePath());
|
||||
QString currentDir = Config()->getRecentFolder();
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select file"), currentDir);
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
ui->filenameLineEdit->setText(fileName);
|
||||
Config()->setRecentFolder(QFileInfo(fileName).absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user