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:
parent
13262c187c
commit
b20607dfc6
16 changed files with 220 additions and 61 deletions
|
@ -168,6 +168,9 @@ void Config::ReadValues() {
|
|||
Settings::values.is_new_3ds = ReadSetting("is_new_3ds", false).toBool();
|
||||
Settings::values.region_value =
|
||||
ReadSetting("region_value", Settings::REGION_VALUE_AUTO_SELECT).toInt();
|
||||
Settings::values.init_clock = static_cast<Settings::InitClock>(
|
||||
ReadSetting("init_clock", static_cast<u32>(Settings::InitClock::SystemTime)).toInt());
|
||||
Settings::values.init_time = ReadSetting("init_time", 946681277ULL).toULongLong();
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Miscellaneous");
|
||||
|
@ -409,6 +412,10 @@ void Config::SaveValues() {
|
|||
qt_config->beginGroup("System");
|
||||
WriteSetting("is_new_3ds", Settings::values.is_new_3ds, false);
|
||||
WriteSetting("region_value", Settings::values.region_value, Settings::REGION_VALUE_AUTO_SELECT);
|
||||
WriteSetting("init_clock", static_cast<u32>(Settings::values.init_clock),
|
||||
static_cast<u32>(Settings::InitClock::SystemTime));
|
||||
WriteSetting("init_time", static_cast<unsigned long long>(Settings::values.init_time),
|
||||
946681277ULL);
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Miscellaneous");
|
||||
|
|
|
@ -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. "
|
||||
|
|
|
@ -31,10 +31,12 @@ public:
|
|||
|
||||
public slots:
|
||||
void updateBirthdayComboBox(int birthmonth_index);
|
||||
void updateInitTime(int init_clock);
|
||||
void refreshConsoleID();
|
||||
|
||||
private:
|
||||
void ReadSystemSettings();
|
||||
void ConfigureTime();
|
||||
|
||||
std::unique_ptr<Ui::ConfigureSystem> ui;
|
||||
bool enabled;
|
||||
|
|
|
@ -232,13 +232,45 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_init_clock">
|
||||
<property name="text">
|
||||
<string>Clock</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="combo_init_clock">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>System Clock</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Fixed Time</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_init_time">
|
||||
<property name="text">
|
||||
<string>Startup time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDateTimeEdit" name="edit_init_time">
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_console_id">
|
||||
<property name="text">
|
||||
<string>Console ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QPushButton" name="button_regenerate_console_id">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue