Merge pull request #4374 from FearlessTobi/frontend-ports

Port various frontend cleanups from yuzu
This commit is contained in:
Weiyi Wang 2018-10-26 22:38:07 -04:00 committed by GitHub
commit f274340001
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 43 deletions

View file

@ -109,9 +109,8 @@ private:
GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread)
: QWidget(parent), child(nullptr), emu_thread(emu_thread) {
std::string window_title = fmt::format("Citra {} | {}-{}", Common::g_build_name,
Common::g_scm_branch, Common::g_scm_desc);
setWindowTitle(QString::fromStdString(window_title));
setWindowTitle(QStringLiteral("Citra %1 | %2-%3")
.arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
setAttribute(Qt::WA_AcceptTouchEvents);
InputCommon::Init();

View file

@ -16,11 +16,16 @@ Config::Config() {
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini";
FileUtil::CreateFullPath(qt_config_loc);
qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat);
qt_config =
std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat);
Reload();
}
Config::~Config() {
Save();
}
const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = {
Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H,
Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B,
@ -561,9 +566,3 @@ void Config::Reload() {
void Config::Save() {
SaveValues();
}
Config::~Config() {
Save();
delete qt_config;
}

View file

@ -5,6 +5,7 @@
#pragma once
#include <array>
#include <memory>
#include <string>
#include <QVariant>
#include "core/settings.h"
@ -12,16 +13,6 @@
class QSettings;
class Config {
QSettings* qt_config;
std::string qt_config_loc;
void ReadValues();
void SaveValues();
QVariant ReadSetting(const QString& name);
QVariant ReadSetting(const QString& name, const QVariant& default_value);
void WriteSetting(const QString& name, const QVariant& value);
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
public:
Config();
~Config();
@ -31,4 +22,15 @@ public:
static const std::array<int, Settings::NativeButton::NumButtons> default_buttons;
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs;
private:
void ReadValues();
void SaveValues();
QVariant ReadSetting(const QString& name);
QVariant ReadSetting(const QString& name, const QVariant& default_value);
void WriteSetting(const QString& name, const QVariant& value);
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
std::unique_ptr<QSettings> qt_config;
std::string qt_config_loc;
};

View file

@ -220,12 +220,12 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::
ui->setupUi(this);
connect(ui->combo_birthmonth,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::updateBirthdayComboBox);
&ConfigureSystem::UpdateBirthdayComboBox);
connect(ui->combo_init_clock,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::updateInitTime);
&ConfigureSystem::UpdateInitTime);
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::refreshConsoleID);
&ConfigureSystem::RefreshConsoleID);
for (u8 i = 0; i < country_names.size(); i++) {
if (country_names.at(i) != "") {
ui->combo_country->addItem(tr(country_names.at(i)), i);
@ -270,7 +270,7 @@ void ConfigureSystem::ReadSystemSettings() {
// set birthday
std::tie(birthmonth, birthday) = cfg->GetBirthday();
ui->combo_birthmonth->setCurrentIndex(birthmonth - 1);
updateBirthdayComboBox(
UpdateBirthdayComboBox(
birthmonth -
1); // explicitly update it because the signal from setCurrentIndex is not reliable
ui->combo_birthday->setCurrentIndex(birthday - 1);
@ -358,7 +358,7 @@ void ConfigureSystem::applyConfiguration() {
Settings::Apply();
}
void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
if (birthmonth_index < 0 || birthmonth_index >= 12)
return;
@ -391,17 +391,17 @@ void ConfigureSystem::ConfigureTime() {
this->setConfiguration();
updateInitTime(ui->combo_init_clock->currentIndex());
UpdateInitTime(ui->combo_init_clock->currentIndex());
}
void ConfigureSystem::updateInitTime(int init_clock) {
void ConfigureSystem::UpdateInitTime(int init_clock) {
const bool is_fixed_time =
static_cast<Settings::InitClock>(init_clock) == Settings::InitClock::FixedTime;
ui->label_init_time->setVisible(is_fixed_time);
ui->edit_init_time->setVisible(is_fixed_time);
}
void ConfigureSystem::refreshConsoleID() {
void ConfigureSystem::RefreshConsoleID() {
QMessageBox::StandardButton reply;
QString warning_text = tr("This will replace your current virtual 3DS with a new one. "
"Your current virtual 3DS will not be recoverable. "

View file

@ -23,29 +23,29 @@ class ConfigureSystem : public QWidget {
public:
explicit ConfigureSystem(QWidget* parent = nullptr);
~ConfigureSystem();
~ConfigureSystem() override;
void applyConfiguration();
void setConfiguration();
void retranslateUi();
public slots:
void updateBirthdayComboBox(int birthmonth_index);
void updateInitTime(int init_clock);
void refreshConsoleID();
private:
void ReadSystemSettings();
void ConfigureTime();
void UpdateBirthdayComboBox(int birthmonth_index);
void UpdateInitTime(int init_clock);
void RefreshConsoleID();
std::unique_ptr<Ui::ConfigureSystem> ui;
bool enabled;
bool enabled = false;
std::shared_ptr<Service::CFG::Module> cfg;
std::u16string username;
int birthmonth, birthday;
int language_index;
int sound_index;
int birthmonth = 0;
int birthday = 0;
int language_index = 0;
int sound_index = 0;
u8 country_code;
u16 play_coin;
};

View file

@ -289,11 +289,11 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} {
tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
item_model->insertColumns(0, COLUMN_COUNT);
item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, "Name");
item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, "Compatibility");
item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, "Region");
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type");
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size");
item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, tr("Region"));
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
item_model->setSortRole(GameListItemPath::TitleRole);
connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons);