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) GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread)
: QWidget(parent), child(nullptr), emu_thread(emu_thread) { : QWidget(parent), child(nullptr), emu_thread(emu_thread) {
std::string window_title = fmt::format("Citra {} | {}-{}", Common::g_build_name, setWindowTitle(QStringLiteral("Citra %1 | %2-%3")
Common::g_scm_branch, Common::g_scm_desc); .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
setWindowTitle(QString::fromStdString(window_title));
setAttribute(Qt::WA_AcceptTouchEvents); setAttribute(Qt::WA_AcceptTouchEvents);
InputCommon::Init(); 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. // 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"; qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini";
FileUtil::CreateFullPath(qt_config_loc); 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(); Reload();
} }
Config::~Config() {
Save();
}
const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { 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_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, 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() { void Config::Save() {
SaveValues(); SaveValues();
} }
Config::~Config() {
Save();
delete qt_config;
}

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <array> #include <array>
#include <memory>
#include <string> #include <string>
#include <QVariant> #include <QVariant>
#include "core/settings.h" #include "core/settings.h"
@ -12,16 +13,6 @@
class QSettings; class QSettings;
class Config { 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: public:
Config(); Config();
~Config(); ~Config();
@ -31,4 +22,15 @@ public:
static const std::array<int, Settings::NativeButton::NumButtons> default_buttons; static const std::array<int, Settings::NativeButton::NumButtons> default_buttons;
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs; 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); ui->setupUi(this);
connect(ui->combo_birthmonth, connect(ui->combo_birthmonth,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::updateBirthdayComboBox); &ConfigureSystem::UpdateBirthdayComboBox);
connect(ui->combo_init_clock, connect(ui->combo_init_clock,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::updateInitTime); &ConfigureSystem::UpdateInitTime);
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this, connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::refreshConsoleID); &ConfigureSystem::RefreshConsoleID);
for (u8 i = 0; i < country_names.size(); i++) { for (u8 i = 0; i < country_names.size(); i++) {
if (country_names.at(i) != "") { if (country_names.at(i) != "") {
ui->combo_country->addItem(tr(country_names.at(i)), i); ui->combo_country->addItem(tr(country_names.at(i)), i);
@ -270,7 +270,7 @@ void ConfigureSystem::ReadSystemSettings() {
// set birthday // set birthday
std::tie(birthmonth, birthday) = cfg->GetBirthday(); std::tie(birthmonth, birthday) = cfg->GetBirthday();
ui->combo_birthmonth->setCurrentIndex(birthmonth - 1); ui->combo_birthmonth->setCurrentIndex(birthmonth - 1);
updateBirthdayComboBox( UpdateBirthdayComboBox(
birthmonth - birthmonth -
1); // explicitly update it because the signal from setCurrentIndex is not reliable 1); // explicitly update it because the signal from setCurrentIndex is not reliable
ui->combo_birthday->setCurrentIndex(birthday - 1); ui->combo_birthday->setCurrentIndex(birthday - 1);
@ -358,7 +358,7 @@ void ConfigureSystem::applyConfiguration() {
Settings::Apply(); Settings::Apply();
} }
void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
if (birthmonth_index < 0 || birthmonth_index >= 12) if (birthmonth_index < 0 || birthmonth_index >= 12)
return; return;
@ -391,17 +391,17 @@ void ConfigureSystem::ConfigureTime() {
this->setConfiguration(); 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 = const bool is_fixed_time =
static_cast<Settings::InitClock>(init_clock) == Settings::InitClock::FixedTime; static_cast<Settings::InitClock>(init_clock) == Settings::InitClock::FixedTime;
ui->label_init_time->setVisible(is_fixed_time); ui->label_init_time->setVisible(is_fixed_time);
ui->edit_init_time->setVisible(is_fixed_time); ui->edit_init_time->setVisible(is_fixed_time);
} }
void ConfigureSystem::refreshConsoleID() { void ConfigureSystem::RefreshConsoleID() {
QMessageBox::StandardButton reply; QMessageBox::StandardButton reply;
QString warning_text = tr("This will replace your current virtual 3DS with a new one. " QString warning_text = tr("This will replace your current virtual 3DS with a new one. "
"Your current virtual 3DS will not be recoverable. " "Your current virtual 3DS will not be recoverable. "

View File

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

View File

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