-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0660c9
commit 4ea839b
Showing
25 changed files
with
328 additions
and
246 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// For license of this file, see <project-root-folder>/LICENSE.md. | ||
|
||
#include "gui/dialogs/filedialog.h" | ||
|
||
#include "miscellaneous/settings.h" | ||
|
||
#include <QFileInfo> | ||
|
||
QString FileDialog::existingDirectory(QWidget* parent, | ||
const QString& caption, | ||
const QString& dir, | ||
const QString& id, | ||
QFileDialog::Options options) { | ||
QString initial_dir_file = id.isEmpty() ? dir : qApp->settings()->value(GROUP(FileDialogPaths), id, dir).toString(); | ||
QFileInfo initial_dir_file_info(initial_dir_file); | ||
QString fldr = QFileDialog::getExistingDirectory(parent, | ||
caption.isEmpty() ? QObject::tr("Select existing folder") : caption, | ||
initial_dir_file_info.absolutePath(), | ||
options); | ||
|
||
if (!fldr.isEmpty() && !id.isEmpty()) { | ||
qApp->settings()->setValue(GROUP(FileDialogPaths), id, fldr); | ||
} | ||
|
||
return fldr; | ||
} | ||
|
||
QString FileDialog::saveFileName(QWidget* parent, | ||
const QString& caption, | ||
const QString& dir, | ||
const QString& filter, | ||
QString* selected_filter, | ||
const QString& id, | ||
QFileDialog::Options options) { | ||
QString initial_dir_file = id.isEmpty() ? dir : qApp->settings()->value(GROUP(FileDialogPaths), id, dir).toString(); | ||
QString file = QFileDialog::getSaveFileName(parent, | ||
caption.isEmpty() ? QObject::tr("Save file") : caption, | ||
initial_dir_file, | ||
filter, | ||
selected_filter, | ||
options); | ||
|
||
if (!file.isEmpty() && !id.isEmpty()) { | ||
qApp->settings()->setValue(GROUP(FileDialogPaths), id, QFileInfo(file).absolutePath()); | ||
} | ||
|
||
return file; | ||
} | ||
|
||
QString FileDialog::openFileName(QWidget* parent, | ||
const QString& caption, | ||
const QString& dir, | ||
const QString& filter, | ||
QString* selected_filter, | ||
const QString& id, | ||
QFileDialog::Options options) { | ||
QString initial_dir_file = id.isEmpty() ? dir : qApp->settings()->value(GROUP(FileDialogPaths), id, dir).toString(); | ||
QString file = QFileDialog::getOpenFileName(parent, | ||
caption.isEmpty() ? QObject::tr("Select existing file") : caption, | ||
initial_dir_file, | ||
filter, | ||
selected_filter, | ||
options); | ||
|
||
if (!file.isEmpty() && !id.isEmpty()) { | ||
qApp->settings()->setValue(GROUP(FileDialogPaths), id, QFileInfo(file).absolutePath()); | ||
} | ||
|
||
return file; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// For license of this file, see <project-root-folder>/LICENSE.md. | ||
|
||
#ifndef FILEDIALOG_H | ||
#define FILEDIALOG_H | ||
|
||
#include <QFileDialog> | ||
#include <QString> | ||
|
||
#define GENERAL_REMEMBERED_PATH QSL("general") | ||
|
||
class QWidget; | ||
|
||
class RSSGUARD_DLLSPEC FileDialog { | ||
public: | ||
static QString saveFileName(QWidget* parent = nullptr, | ||
const QString& caption = QString(), | ||
const QString& dir = QString(), | ||
const QString& filter = QString(), | ||
QString* selected_filter = nullptr, | ||
const QString& id = QString(), | ||
QFileDialog::Options options = QFileDialog::Options()); | ||
|
||
static QString existingDirectory(QWidget* parent = nullptr, | ||
const QString& caption = QString(), | ||
const QString& dir = QString(), | ||
const QString& id = QString(), | ||
QFileDialog::Options options = QFileDialog::Option::ShowDirsOnly); | ||
|
||
static QString openFileName(QWidget* parent = nullptr, | ||
const QString& caption = QString(), | ||
const QString& dir = QString(), | ||
const QString& filter = QString(), | ||
QString* selected_filter = nullptr, | ||
const QString& id = QString(), | ||
QFileDialog::Options options = QFileDialog::Options()); | ||
|
||
private: | ||
FileDialog() {} | ||
}; | ||
|
||
#endif // FILEDIALOG_H |
Oops, something went wrong.