configuration: Setup UI to config screenshot path and saving

This adds two options to the General -> UI tab. The first disables picking a place to save the file. The second chooses a default directory for saving screenshots.
This commit is contained in:
lat9nq 2020-07-20 23:03:49 -04:00
parent 11fb3d5d12
commit 3db1abfcbc
5 changed files with 93 additions and 5 deletions

View file

@ -4,9 +4,11 @@
#include <array>
#include <utility>
#include <QFileDialog>
#include <QDirIterator>
#include "common/common_types.h"
#include "common/file_util.h"
#include "core/settings.h"
#include "ui_configure_ui.h"
#include "yuzu/configuration/configure_ui.h"
@ -55,6 +57,14 @@ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::Configur
[=]() { ConfigureUi::UpdateSecondRowComboBox(); });
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated),
[=]() { ConfigureUi::UpdateFirstRowComboBox(); });
// Set screenshot path to user specification.
connect(ui->screenshot_path_button, &QToolButton::pressed, this, [this] {
const QString& filename = QFileDialog::getExistingDirectory(
this, tr("Select Screenshots Path..."),
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir)));
ui->screenshot_path_edit->setText(filename);
});
}
ConfigureUi::~ConfigureUi() = default;
@ -66,6 +76,10 @@ void ConfigureUi::ApplyConfiguration() {
UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt();
UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt();
UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt();
UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked();
FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir,
ui->screenshot_path_edit->text().toStdString());
Settings::Apply();
}
@ -80,6 +94,10 @@ void ConfigureUi::SetConfiguration() {
ui->show_add_ons->setChecked(UISettings::values.show_add_ons);
ui->icon_size_combobox->setCurrentIndex(
ui->icon_size_combobox->findData(UISettings::values.icon_size));
ui->enable_screenshot_save_as->setChecked(UISettings::values.enable_screenshot_save_as);
ui->screenshot_path_edit->setText(
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ScreenshotsDir)));
}
void ConfigureUi::changeEvent(QEvent* event) {