mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-01 07:05:13 +00:00
Unify gtk/xdp file dialog getters
This commit is contained in:
@@ -681,12 +681,15 @@ bool Get(
|
|||||||
}
|
}
|
||||||
dialog.selectFile(startFile);
|
dialog.selectFile(startFile);
|
||||||
|
|
||||||
int res = dialog.exec();
|
const auto res = dialog.exec();
|
||||||
|
|
||||||
QString path = dialog.directory().absolutePath();
|
if (type != Type::ReadFolder) {
|
||||||
if (path != cDialogLastPath()) {
|
// Save last used directory for all queries except directory choosing.
|
||||||
cSetDialogLastPath(path);
|
const auto path = dialog.directory().absolutePath();
|
||||||
Local::writeSettings();
|
if (!path.isEmpty() && path != cDialogLastPath()) {
|
||||||
|
cSetDialogLastPath(path);
|
||||||
|
Local::writeSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == QDialog::Accepted) {
|
if (res == QDialog::Accepted) {
|
||||||
|
@@ -592,6 +592,11 @@ void XDPFileDialog::gotResponse(
|
|||||||
if (const auto i = results.find("uris"); i != end(results)) {
|
if (const auto i = results.find("uris"); i != end(results)) {
|
||||||
_selectedFiles = base::Platform::GlibVariantCast<
|
_selectedFiles = base::Platform::GlibVariantCast<
|
||||||
std::vector<Glib::ustring>>(i->second);
|
std::vector<Glib::ustring>>(i->second);
|
||||||
|
|
||||||
|
_directory = _selectedFiles.empty()
|
||||||
|
? Glib::ustring()
|
||||||
|
: Glib::ustring(
|
||||||
|
Glib::path_get_dirname(_selectedFiles.back()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto i = results.find("current_filter");
|
if (const auto i = results.find("current_filter");
|
||||||
@@ -688,7 +693,18 @@ bool Get(
|
|||||||
dialog.setDirectory(QFileInfo(startFile).absoluteDir().absolutePath());
|
dialog.setDirectory(QFileInfo(startFile).absoluteDir().absolutePath());
|
||||||
dialog.selectFile(startFile);
|
dialog.selectFile(startFile);
|
||||||
|
|
||||||
int res = dialog.exec();
|
const auto res = dialog.exec();
|
||||||
|
|
||||||
|
if (type != Type::ReadFolder) {
|
||||||
|
// Save last used directory for all queries except directory choosing.
|
||||||
|
const auto path = dialog.directory().path();
|
||||||
|
if (!path.isEmpty()
|
||||||
|
&& !path.contains(docRegExp)
|
||||||
|
&& path != cDialogLastPath()) {
|
||||||
|
cSetDialogLastPath(path);
|
||||||
|
Local::writeSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (res == QDialog::Accepted) {
|
if (res == QDialog::Accepted) {
|
||||||
QStringList selectedFilesStrings;
|
QStringList selectedFilesStrings;
|
||||||
@@ -702,18 +718,6 @@ bool Get(
|
|||||||
} else {
|
} else {
|
||||||
files = selectedFilesStrings.mid(0, 1);
|
files = selectedFilesStrings.mid(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString path = files.isEmpty()
|
|
||||||
? QString()
|
|
||||||
: QFileInfo(files.back()).absoluteDir().absolutePath();
|
|
||||||
|
|
||||||
if (!path.isEmpty()
|
|
||||||
&& !path.contains(docRegExp)
|
|
||||||
&& path != cDialogLastPath()) {
|
|
||||||
cSetDialogLastPath(path);
|
|
||||||
Local::writeSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user