mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[FileDialogs] All file dialogs now remember last directory.
This commit is contained in:
parent
5828d57277
commit
f28eb82fb2
@ -92,9 +92,9 @@ void FileSchemeHandler::handleUrl(const QUrl &url)
|
||||
}
|
||||
else if (status == 2) {
|
||||
// Save
|
||||
const QString &savePath = QFileDialog::getSaveFileName(mApp->getWindow(),
|
||||
const QString &savePath = QzTools::getSaveFileName("FileSchemeHandler-Save", mApp->getWindow(),
|
||||
QObject::tr("Save file as..."),
|
||||
QDir::homePath() + "/" + QzTools::getFileNameFromUrl(url));
|
||||
QDir::homePath() + QDir::separator() + QzTools::getFileNameFromUrl(url));
|
||||
|
||||
if (!savePath.isEmpty()) {
|
||||
file.copy(savePath);
|
||||
|
@ -95,7 +95,7 @@ void PageScreen::changeLocation()
|
||||
{
|
||||
const QString &suggestedPath = QString("%1/%2.%3").arg(QDir::homePath(), QzTools::filterCharsFromFilename(m_pageTitle),
|
||||
m_formats[ui->formats->currentIndex()].toLower());
|
||||
const QString &path = QFileDialog::getOpenFileName(this, tr("Choose location..."), suggestedPath);
|
||||
const QString &path = QzTools::getOpenFileName("PageScreen-ChangeLocation", this, tr("Choose location..."), suggestedPath);
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
ui->location->setText(path);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "passwordbackends/passwordbackend.h"
|
||||
#include "mainapplication.h"
|
||||
#include "settings.h"
|
||||
#include "qztools.h"
|
||||
|
||||
#include <QUrl>
|
||||
#include <QMenu>
|
||||
@ -274,7 +275,7 @@ void AutoFillManager::showExceptions()
|
||||
|
||||
void AutoFillManager::importPasswords()
|
||||
{
|
||||
m_fileName = QFileDialog::getOpenFileName(this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml");
|
||||
m_fileName = QzTools::getOpenFileName("AutoFill-ImportPasswords", this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml");
|
||||
|
||||
if (m_fileName.isEmpty()) {
|
||||
return;
|
||||
@ -285,7 +286,7 @@ void AutoFillManager::importPasswords()
|
||||
|
||||
void AutoFillManager::exportPasswords()
|
||||
{
|
||||
m_fileName = QFileDialog::getSaveFileName(this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml");
|
||||
m_fileName = QzTools::getSaveFileName("AutoFill-ExportPasswords", this, tr("Choose file..."), QDir::homePath() + "/passwords.xml", "*.xml");
|
||||
|
||||
if (m_fileName.isEmpty()) {
|
||||
return;
|
||||
|
@ -581,7 +581,7 @@ void Preferences::chooseDownPath()
|
||||
|
||||
void Preferences::chooseUserStyleClicked()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Choose stylesheet location..."), QDir::homePath(), "*.css");
|
||||
QString file = QzTools::getOpenFileName("Preferences-UserStyle", this, tr("Choose stylesheet location..."), QDir::homePath(), "*.css");
|
||||
if (file.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -530,6 +530,7 @@ QString QzTools::getExistingDirectory(const QString &name, QWidget* parent, cons
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("FileDialogPaths");
|
||||
|
||||
QString lastDir = settings.value(name, dir).toString();
|
||||
|
||||
QString path = QFileDialog::getExistingDirectory(parent, caption, lastDir, options);
|
||||
@ -538,6 +539,7 @@ QString QzTools::getExistingDirectory(const QString &name, QWidget* parent, cons
|
||||
settings.setValue(name, QFileInfo(path).absolutePath());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -545,7 +547,16 @@ QString QzTools::getOpenFileName(const QString &name, QWidget* parent, const QSt
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("FileDialogPaths");
|
||||
QString lastDir = settings.value(name, dir).toString();
|
||||
|
||||
QString lastDir = settings.value(name, QString()).toString();
|
||||
QString fileName = QFileInfo(dir).isFile() ? QFileInfo(dir).fileName() : QString();
|
||||
|
||||
if (lastDir.isEmpty()) {
|
||||
lastDir = dir;
|
||||
}
|
||||
else {
|
||||
lastDir.append(QDir::separator() + fileName);
|
||||
}
|
||||
|
||||
QString path = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, selectedFilter, options);
|
||||
|
||||
@ -553,6 +564,7 @@ QString QzTools::getOpenFileName(const QString &name, QWidget* parent, const QSt
|
||||
settings.setValue(name, QFileInfo(path).absolutePath());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -560,7 +572,16 @@ QStringList QzTools::getOpenFileNames(const QString &name, QWidget* parent, cons
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("FileDialogPaths");
|
||||
QString lastDir = settings.value(name, dir).toString();
|
||||
|
||||
QString lastDir = settings.value(name, QString()).toString();
|
||||
QString fileName = QFileInfo(dir).isFile() ? QFileInfo(dir).fileName() : QString();
|
||||
|
||||
if (lastDir.isEmpty()) {
|
||||
lastDir = dir;
|
||||
}
|
||||
else {
|
||||
lastDir.append(QDir::separator() + fileName);
|
||||
}
|
||||
|
||||
QStringList paths = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, selectedFilter, options);
|
||||
|
||||
@ -568,6 +589,7 @@ QStringList QzTools::getOpenFileNames(const QString &name, QWidget* parent, cons
|
||||
settings.setValue(name, QFileInfo(paths.first()).absolutePath());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
return paths;
|
||||
}
|
||||
|
||||
@ -575,7 +597,16 @@ QString QzTools::getSaveFileName(const QString &name, QWidget* parent, const QSt
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("FileDialogPaths");
|
||||
QString lastDir = settings.value(name, dir).toString();
|
||||
|
||||
QString lastDir = settings.value(name, QString()).toString();
|
||||
QString fileName = QFileInfo(dir).isFile() ? QFileInfo(dir).fileName() : QString();
|
||||
|
||||
if (lastDir.isEmpty()) {
|
||||
lastDir = dir;
|
||||
}
|
||||
else {
|
||||
lastDir.append(QDir::separator() + fileName);
|
||||
}
|
||||
|
||||
QString path = QFileDialog::getSaveFileName(parent, caption, lastDir, filter, selectedFilter, options);
|
||||
|
||||
@ -583,6 +614,7 @@ QString QzTools::getSaveFileName(const QString &name, QWidget* parent, const QSt
|
||||
settings.setValue(name, QFileInfo(path).absolutePath());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ void SiteInfo::downloadImage()
|
||||
|
||||
QString imageFileName = QzTools::getFileNameFromUrl(QUrl(item->text(1)));
|
||||
|
||||
QString filePath = QFileDialog::getSaveFileName(this, tr("Save image..."), QDir::homePath() + "/" + imageFileName);
|
||||
QString filePath = QzTools::getSaveFileName("SiteInfo-DownloadImage", this, tr("Save image..."), QDir::homePath() + QDir::separator() + imageFileName);
|
||||
if (filePath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user