Add system time configuration (#4043)

* Add setting to switch between a fixed start time and the system time

Add clock settings to SDL

Make clock configureable in qt

Add a SharedPage handler class

Init shared_page_handler for tests
This commit is contained in:
Ben 2018-08-26 19:47:45 +02:00 committed by James Rowe
parent 13262c187c
commit b20607dfc6
16 changed files with 220 additions and 61 deletions

View file

@ -8,6 +8,7 @@
#include "core/core.h"
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/fs/archive.h"
#include "core/settings.h"
#include "ui_configure_system.h"
static const std::array<int, 12> days_in_month = {{
@ -220,6 +221,9 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::
connect(ui->combo_birthmonth,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::updateBirthdayComboBox);
connect(ui->combo_init_clock,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::updateInitTime);
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::refreshConsoleID);
for (u8 i = 0; i < country_names.size(); i++) {
@ -228,7 +232,7 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) : QWidget(parent), ui(new Ui::
}
}
this->setConfiguration();
ConfigureTime();
}
ConfigureSystem::~ConfigureSystem() {}
@ -236,6 +240,11 @@ ConfigureSystem::~ConfigureSystem() {}
void ConfigureSystem::setConfiguration() {
enabled = !Core::System::GetInstance().IsPoweredOn();
ui->combo_init_clock->setCurrentIndex(static_cast<u8>(Settings::values.init_clock));
QDateTime date_time;
date_time.setTime_t(Settings::values.init_time);
ui->edit_init_time->setDateTime(date_time);
if (!enabled) {
cfg = Service::CFG::GetCurrentModule();
ReadSystemSettings();
@ -334,6 +343,11 @@ void ConfigureSystem::applyConfiguration() {
// update the config savegame if any item is modified.
if (modified)
cfg->UpdateConfigNANDSavegame();
Settings::values.init_clock =
static_cast<Settings::InitClock>(ui->combo_init_clock->currentIndex());
Settings::values.init_time = ui->edit_init_time->dateTime().toTime_t();
Settings::Apply();
}
void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
@ -361,6 +375,24 @@ void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
ui->combo_birthday->setCurrentIndex(birthday_index);
}
void ConfigureSystem::ConfigureTime() {
ui->edit_init_time->setCalendarPopup(true);
QDateTime dt;
dt.fromString("2000-01-01 00:00:01", "yyyy-MM-dd hh:mm:ss");
ui->edit_init_time->setMinimumDateTime(dt);
this->setConfiguration();
updateInitTime(ui->combo_init_clock->currentIndex());
}
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() {
QMessageBox::StandardButton reply;
QString warning_text = tr("This will replace your current virtual 3DS with a new one. "