| 1 | // Copyright 2017 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Settings/AdvancedPane.h" |
| 5 | |
| 6 | #include <QCheckBox> |
| 7 | #include <QDateTimeEdit> |
| 8 | #include <QFontMetrics> |
| 9 | #include <QFormLayout> |
| 10 | #include <QGroupBox> |
| 11 | #include <QHBoxLayout> |
| 12 | #include <QLabel> |
| 13 | #include <QRadioButton> |
| 14 | #include <QSignalBlocker> |
| 15 | #include <QTimeZone> |
| 16 | #include <QVBoxLayout> |
| 17 | #include <cmath> |
| 18 | |
| 19 | #include "Common/Config/Config.h" |
| 20 | #include "Common/Config/Enums.h" |
| 21 | #include "Common/FileUtil.h" |
| 22 | #include "Core/Config/MainSettings.h" |
| 23 | #include "Core/ConfigManager.h" |
| 24 | #include "Core/Core.h" |
| 25 | #include "Core/HW/SystemTimers.h" |
| 26 | #include "Core/HW/VideoInterface.h" |
| 27 | #include "Core/PowerPC/PowerPC.h" |
| 28 | #include "Core/System.h" |
| 29 | |
| 30 | #include "DolphinQt/Config/ConfigControls/ConfigBool.h" |
| 31 | #include "DolphinQt/Config/ConfigControls/ConfigChoice.h" |
| 32 | #include "DolphinQt/Config/ConfigControls/ConfigFloatSlider.h" |
| 33 | #include "DolphinQt/Config/ConfigControls/ConfigSlider.h" |
| 34 | #include "DolphinQt/QtUtils/AnalyticsPrompt.h" |
| 35 | #include "DolphinQt/QtUtils/ModalMessageBox.h" |
| 36 | #include "DolphinQt/QtUtils/NonDefaultQPushButton.h" |
| 37 | #include "DolphinQt/QtUtils/QtUtils.h" |
| 38 | #include "DolphinQt/QtUtils/SignalBlocking.h" |
| 39 | #include "DolphinQt/Settings.h" |
| 40 | |
| 41 | #include "UICommon/UICommon.h" |
| 42 | |
| 43 | static const std::map<PowerPC::CPUCore, const char*> CPU_CORE_NAMES = { |
| 44 | {PowerPC::CPUCore::Interpreter, QT_TR_NOOP("Interpreter (slowest)")}, |
| 45 | {PowerPC::CPUCore::CachedInterpreter, QT_TR_NOOP("Cached Interpreter (slower)")}, |
| 46 | {PowerPC::CPUCore::JIT64, QT_TR_NOOP("JIT Recompiler for x86-64 (recommended)")}, |
| 47 | {PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Recompiler for ARM64 (recommended)")}, |
| 48 | }; |
| 49 | |
| 50 | AdvancedPane::AdvancedPane(QWidget* parent) : QWidget(parent) |
| 51 | { |
| 52 | CreateLayout(); |
| 53 | Update(); |
| 54 | |
| 55 | ConnectLayout(); |
| 56 | |
| 57 | connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &AdvancedPane::Update); |
| 58 | } |
| 59 | |
| 60 | void AdvancedPane::CreateLayout() |
| 61 | { |
| 62 | auto* main_layout = new QVBoxLayout(); |
| 63 | setLayout(main_layout); |
| 64 | |
| 65 | auto* cpu_options_group = new QGroupBox(tr("CPU Options")); |
| 66 | auto* cpu_options_group_layout = new QVBoxLayout(); |
| 67 | cpu_options_group->setLayout(cpu_options_group_layout); |
| 68 | main_layout->addWidget(cpu_options_group); |
| 69 | |
| 70 | auto* cpu_emulation_engine_layout = new QFormLayout; |
| 71 | cpu_emulation_engine_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 72 | cpu_emulation_engine_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); |
| 73 | cpu_options_group_layout->addLayout(cpu_emulation_engine_layout); |
| 74 | |
| 75 | std::vector<std::pair<QString, PowerPC::CPUCore>> emulation_engine_choices; |
| 76 | for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores()) |
| 77 | emulation_engine_choices.emplace_back(tr(CPU_CORE_NAMES.at(cpu_core)), cpu_core); |
| 78 | m_cpu_emulation_engine_combobox = |
| 79 | new ConfigChoiceMap<PowerPC::CPUCore>(emulation_engine_choices, Config::MAIN_CPU_CORE); |
| 80 | cpu_emulation_engine_layout->addRow(tr("CPU Emulation Engine:"), m_cpu_emulation_engine_combobox); |
| 81 | |
| 82 | m_enable_mmu_checkbox = new ConfigBool(tr("Enable MMU"), Config::MAIN_MMU); |
| 83 | m_enable_mmu_checkbox->SetDescription( |
| 84 | tr("Enables the Memory Management Unit, needed for some games. (ON = Compatible, OFF = " |
| 85 | "Fast)<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 86 | cpu_options_group_layout->addWidget(m_enable_mmu_checkbox); |
| 87 | |
| 88 | m_pause_on_panic_checkbox = new ConfigBool(tr("Pause on Panic"), Config::MAIN_PAUSE_ON_PANIC); |
| 89 | m_pause_on_panic_checkbox->SetDescription( |
| 90 | tr("Pauses the emulation if a Read/Write or Unknown Instruction panic occurs.<br>Enabling " |
| 91 | "will affect performance.<br>The performance impact is the same as having Enable MMU " |
| 92 | "on.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 93 | cpu_options_group_layout->addWidget(m_pause_on_panic_checkbox); |
| 94 | |
| 95 | m_accurate_cpu_cache_checkbox = |
| 96 | new ConfigBool(tr("Enable Write-Back Cache (slow)"), Config::MAIN_ACCURATE_CPU_CACHE); |
| 97 | m_accurate_cpu_cache_checkbox->SetDescription( |
| 98 | tr("Enables emulation of the CPU write-back cache.<br>Enabling will have a significant " |
| 99 | "impact on performance.<br>This should be left disabled unless absolutely " |
| 100 | "needed.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 101 | cpu_options_group_layout->addWidget(m_accurate_cpu_cache_checkbox); |
| 102 | |
| 103 | auto* const timing_group = new QGroupBox(tr("Timing")); |
| 104 | main_layout->addWidget(timing_group); |
| 105 | auto* timing_group_layout = new QVBoxLayout{timing_group}; |
| 106 | auto* const correct_time_drift = |
| 107 | // i18n: Correct is a verb |
| 108 | new ConfigBool{tr("Correct Time Drift"), Config::MAIN_CORRECT_TIME_DRIFT}; |
| 109 | correct_time_drift->SetDescription( |
| 110 | // i18n: Internet play refers to services like Wiimmfi, not the NetPlay feature in Dolphin |
| 111 | tr("Allow the emulated console to run fast after stutters," |
| 112 | "<br>pursuing accurate overall elapsed time unless paused or speed-adjusted." |
| 113 | "<br><br>This may be useful for internet play." |
| 114 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 115 | timing_group_layout->addWidget(correct_time_drift); |
| 116 | |
| 117 | auto* const rush_frame_presentation = |
| 118 | // i18n: "Rush" is a verb |
| 119 | new ConfigBool{tr("Rush Frame Presentation"), Config::MAIN_RUSH_FRAME_PRESENTATION}; |
| 120 | rush_frame_presentation->SetDescription( |
| 121 | tr("Limits throttling between input and frame output," |
| 122 | " speeding through emulation to reach presentation," |
| 123 | " displaying sooner, and thus reducing input latency." |
| 124 | "<br><br>This will generally make frame pacing worse." |
| 125 | "<br>This setting can work either with or without Immediately Present XFB." |
| 126 | "<br>An Audio Buffer Size of at least 80 ms is recommended to ensure full effect." |
| 127 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 128 | timing_group_layout->addWidget(rush_frame_presentation); |
| 129 | |
| 130 | auto* const smooth_early_presentation = |
| 131 | // i18n: "Smooth" is a verb |
| 132 | new ConfigBool{tr("Smooth Early Presentation"), Config::MAIN_SMOOTH_EARLY_PRESENTATION}; |
| 133 | smooth_early_presentation->SetDescription( |
| 134 | tr("Adaptively adjusts the timing of early frame presentation." |
| 135 | "<br><br>This can improve frame pacing with Immediately Present XFB" |
| 136 | " and/or Rush Frame Presentation," |
| 137 | " while still maintaining most of the input latency benefits." |
| 138 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 139 | timing_group_layout->addWidget(smooth_early_presentation); |
| 140 | |
| 141 | // Make all labels the same width, so that the sliders are aligned. |
| 142 | const QFontMetrics font_metrics{font()}; |
| 143 | const int label_width = font_metrics.boundingRect(QStringLiteral(" 500% (000.00 VPS)")).width(); |
| 144 | |
| 145 | auto* clock_override = new QGroupBox(tr("Clock Override")); |
| 146 | auto* clock_override_layout = new QVBoxLayout(); |
| 147 | clock_override->setLayout(clock_override_layout); |
| 148 | main_layout->addWidget(clock_override); |
| 149 | |
| 150 | m_cpu_clock_override_checkbox = |
| 151 | new ConfigBool(tr("Enable Emulated CPU Clock Override"), Config::MAIN_OVERCLOCK_ENABLE); |
| 152 | clock_override_layout->addWidget(m_cpu_clock_override_checkbox); |
| 153 | connect(m_cpu_clock_override_checkbox, &QCheckBox::toggled, this, &AdvancedPane::Update); |
| 154 | |
| 155 | auto* cpu_clock_override_slider_layout = new QHBoxLayout(); |
| 156 | cpu_clock_override_slider_layout->setContentsMargins(0, 0, 0, 0); |
| 157 | clock_override_layout->addLayout(cpu_clock_override_slider_layout); |
| 158 | |
| 159 | m_cpu_clock_override_slider = new ConfigFloatSlider(0.01f, 5.0f, Config::MAIN_OVERCLOCK, 0.01f); |
| 160 | cpu_clock_override_slider_layout->addWidget(m_cpu_clock_override_slider); |
| 161 | |
| 162 | m_cpu_label = new QLabel(); |
| 163 | m_cpu_label->setFixedWidth(label_width); |
| 164 | m_cpu_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 165 | cpu_clock_override_slider_layout->addWidget(m_cpu_label); |
| 166 | |
| 167 | std::function<void()> cpu_text = [this]() { |
| 168 | const float multi = Config::Get(Config::MAIN_OVERCLOCK); |
| 169 | const int percent = static_cast<int>(std::round(multi * 100.f)); |
| 170 | const int core_clock = |
| 171 | Core::System::GetInstance().GetSystemTimers().GetTicksPerSecond() / std::pow(10, 6); |
| 172 | const int clock = static_cast<int>(std::round(multi * core_clock)); |
| 173 | m_cpu_label->setText(tr("%1% (%2 MHz)").arg(QString::number(percent), QString::number(clock))); |
| 174 | }; |
| 175 | |
| 176 | cpu_text(); |
| 177 | connect(m_cpu_clock_override_slider, &QSlider::valueChanged, this, cpu_text); |
| 178 | |
| 179 | m_cpu_clock_override_checkbox->SetDescription( |
| 180 | tr("Adjusts the emulated CPU's clock rate.<br><br>" |
| 181 | "On games that have an unstable frame rate despite full emulation speed, " |
| 182 | "higher values can improve their performance, requiring a powerful device. " |
| 183 | "Lower values reduce the emulated console's performance, but improve the " |
| 184 | "emulation speed.<br><br>" |
| 185 | "WARNING: Changing this from the default (100%) can and will " |
| 186 | "break games and cause glitches. Do so at your own risk. " |
| 187 | "Please do not report bugs that occur with a non-default clock." |
| 188 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 189 | |
| 190 | auto* vi_rate_override = new QGroupBox(tr("VBI Frequency Override")); |
| 191 | auto* vi_rate_override_layout = new QVBoxLayout(); |
| 192 | vi_rate_override->setLayout(vi_rate_override_layout); |
| 193 | main_layout->addWidget(vi_rate_override); |
| 194 | |
| 195 | m_vi_rate_override_checkbox = |
| 196 | new ConfigBool(tr("Enable VBI Frequency Override"), Config::MAIN_VI_OVERCLOCK_ENABLE); |
| 197 | vi_rate_override_layout->addWidget(m_vi_rate_override_checkbox); |
| 198 | connect(m_vi_rate_override_checkbox, &QCheckBox::toggled, this, &AdvancedPane::Update); |
| 199 | |
| 200 | auto* vi_rate_override_slider_layout = new QHBoxLayout(); |
| 201 | vi_rate_override_slider_layout->setContentsMargins(0, 0, 0, 0); |
| 202 | vi_rate_override_layout->addLayout(vi_rate_override_slider_layout); |
| 203 | |
| 204 | m_vi_rate_override_slider = new ConfigFloatSlider(0.01f, 5.0f, Config::MAIN_VI_OVERCLOCK, 0.01f); |
| 205 | vi_rate_override_slider_layout->addWidget(m_vi_rate_override_slider); |
| 206 | |
| 207 | m_vi_label = new QLabel(); |
| 208 | m_vi_label->setFixedWidth(label_width); |
| 209 | m_vi_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 210 | vi_rate_override_slider_layout->addWidget(m_vi_label); |
| 211 | std::function<void()> vi_text = [this]() { |
| 212 | const int percent = |
| 213 | static_cast<int>(std::round(Config::Get(Config::MAIN_VI_OVERCLOCK) * 100.f)); |
| 214 | float vps = |
| 215 | static_cast<float>(Core::System::GetInstance().GetVideoInterface().GetTargetRefreshRate()); |
| 216 | if (vps == 0.0f || !Config::Get(Config::MAIN_VI_OVERCLOCK_ENABLE)) |
| 217 | vps = 59.94f * Config::Get(Config::MAIN_VI_OVERCLOCK); |
| 218 | m_vi_label->setText( |
| 219 | tr("%1% (%2 VPS)").arg(QString::number(percent), QString::number(vps, 'f', 2))); |
| 220 | }; |
| 221 | |
| 222 | vi_text(); |
| 223 | connect(m_vi_rate_override_slider, &QSlider::valueChanged, this, vi_text); |
| 224 | |
| 225 | m_vi_rate_override_checkbox->SetDescription( |
| 226 | tr("Adjusts the VBI frequency. Also adjusts the emulated CPU's " |
| 227 | "clock rate, to keep it relatively the same.<br><br>" |
| 228 | "Makes games run at a different frame rate, making the emulation less " |
| 229 | "demanding when lowered, or improving smoothness when increased. This may " |
| 230 | "affect gameplay speed, as it is often tied to the frame rate.<br><br>" |
| 231 | "WARNING: Changing this from the default (100%) can and will " |
| 232 | "break games and cause glitches. Do so at your own risk. " |
| 233 | "Please do not report bugs that occur with a non-default frequency." |
| 234 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 235 | |
| 236 | auto* ram_override = new QGroupBox(tr("Memory Override")); |
| 237 | auto* ram_override_layout = new QVBoxLayout(); |
| 238 | ram_override->setLayout(ram_override_layout); |
| 239 | main_layout->addWidget(ram_override); |
| 240 | |
| 241 | m_ram_override_checkbox = |
| 242 | new ConfigBool(tr("Enable Emulated Memory Size Override"), Config::MAIN_RAM_OVERRIDE_ENABLE); |
| 243 | ram_override_layout->addWidget(m_ram_override_checkbox); |
| 244 | connect(m_ram_override_checkbox, &QCheckBox::toggled, this, &AdvancedPane::Update); |
| 245 | |
| 246 | auto* mem1_override_slider_layout = new QHBoxLayout(); |
| 247 | mem1_override_slider_layout->setContentsMargins(0, 0, 0, 0); |
| 248 | ram_override_layout->addLayout(mem1_override_slider_layout); |
| 249 | |
| 250 | m_mem1_override_slider = new ConfigSliderU32(24, 64, Config::MAIN_MEM1_SIZE, 0x100000); |
| 251 | mem1_override_slider_layout->addWidget(m_mem1_override_slider); |
| 252 | |
| 253 | m_mem1_label = |
| 254 | new QLabel(tr("%1 MB (MEM1)").arg(QString::number(m_mem1_override_slider->value()))); |
| 255 | m_mem1_label->setFixedWidth(label_width); |
| 256 | m_mem1_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 257 | mem1_override_slider_layout->addWidget(m_mem1_label); |
| 258 | connect(m_mem1_override_slider, &QSlider::valueChanged, this, [this](int value) { |
| 259 | m_mem1_label->setText(tr("%1 MB (MEM1)").arg(QString::number(value))); |
| 260 | }); |
| 261 | |
| 262 | auto* mem2_override_slider_layout = new QHBoxLayout(); |
| 263 | mem2_override_slider_layout->setContentsMargins(0, 0, 0, 0); |
| 264 | ram_override_layout->addLayout(mem2_override_slider_layout); |
| 265 | |
| 266 | m_mem2_override_slider = new ConfigSliderU32(64, 128, Config::MAIN_MEM2_SIZE, 0x100000); |
| 267 | mem2_override_slider_layout->addWidget(m_mem2_override_slider); |
| 268 | |
| 269 | m_mem2_label = |
| 270 | new QLabel(tr("%1 MB (MEM2)").arg(QString::number(m_mem2_override_slider->value()))); |
| 271 | m_mem2_label->setFixedWidth(label_width); |
| 272 | m_mem2_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 273 | mem2_override_slider_layout->addWidget(m_mem2_label); |
| 274 | connect(m_mem2_override_slider, &QSlider::valueChanged, this, [this](int value) { |
| 275 | m_mem2_label->setText(tr("%1 MB (MEM2)").arg(QString::number(value))); |
| 276 | }); |
| 277 | |
| 278 | m_ram_override_checkbox->SetDescription( |
| 279 | tr("Adjusts the amount of RAM in the emulated console.<br><br>" |
| 280 | "<b>WARNING</b>: Enabling this will completely break many games.<br>Only a small " |
| 281 | "number " |
| 282 | "of games can benefit from this." |
| 283 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 284 | |
| 285 | auto* rtc_options = new QGroupBox(tr("Custom RTC Options")); |
| 286 | rtc_options->setLayout(new QVBoxLayout()); |
| 287 | main_layout->addWidget(rtc_options); |
| 288 | |
| 289 | m_custom_rtc_checkbox = new ConfigBool(tr("Enable Custom RTC"), Config::MAIN_CUSTOM_RTC_ENABLE); |
| 290 | rtc_options->layout()->addWidget(m_custom_rtc_checkbox); |
| 291 | connect(m_custom_rtc_checkbox, &QCheckBox::toggled, this, &AdvancedPane::Update); |
| 292 | |
| 293 | m_custom_rtc_datetime = new QDateTimeEdit(); |
| 294 | |
| 295 | // Show seconds |
| 296 | m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace( |
| 297 | QStringLiteral("mm"), QStringLiteral("mm:ss"))); |
| 298 | |
| 299 | QtUtils::ShowFourDigitYear(m_custom_rtc_datetime); |
| 300 | #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) |
| 301 | m_custom_rtc_datetime->setDateTimeRange(QDateTime({2000, 1, 1}, {0, 0, 0}, QTimeZone::UTC), |
| 302 | QDateTime({2099, 12, 31}, {23, 59, 59}, QTimeZone::UTC)); |
| 303 | #else |
| 304 | m_custom_rtc_datetime->setDateTimeRange(QDateTime({2000, 1, 1}, {0, 0, 0}, Qt::UTC), |
| 305 | QDateTime({2099, 12, 31}, {23, 59, 59}, Qt::UTC)); |
| 306 | #endif |
| 307 | #if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) |
| 308 | m_custom_rtc_datetime->setTimeZone(QTimeZone::UTC); |
| 309 | #else |
| 310 | m_custom_rtc_datetime->setTimeSpec(Qt::UTC); |
| 311 | #endif |
| 312 | rtc_options->layout()->addWidget(m_custom_rtc_datetime); |
| 313 | |
| 314 | m_custom_rtc_checkbox->SetDescription( |
| 315 | tr("This setting allows you to set a custom real time clock (RTC) separate from " |
| 316 | "your current system time." |
| 317 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>")); |
| 318 | |
| 319 | auto* reset_group = new QGroupBox(tr("Reset Dolphin Settings")); |
| 320 | reset_group->setLayout(new QVBoxLayout()); |
| 321 | main_layout->addWidget(reset_group); |
| 322 | |
| 323 | m_reset_button = new NonDefaultQPushButton(tr("Reset All Settings")); |
| 324 | connect(m_reset_button, &QPushButton::clicked, this, &AdvancedPane::OnResetButtonClicked); |
| 325 | |
| 326 | reset_group->layout()->addWidget(m_reset_button); |
| 327 | |
| 328 | main_layout->addStretch(1); |
| 329 | } |
| 330 | |
| 331 | void AdvancedPane::ConnectLayout() |
| 332 | { |
| 333 | m_ram_override_checkbox->setChecked(Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE)); |
| 334 | connect(m_ram_override_checkbox, &QCheckBox::toggled, [this](bool enable_ram_override) { |
| 335 | Config::SetBaseOrCurrent(Config::MAIN_RAM_OVERRIDE_ENABLE, enable_ram_override); |
| 336 | Update(); |
| 337 | }); |
| 338 | |
| 339 | connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, |
| 340 | [this](const QDateTime& date_time) { |
| 341 | Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_VALUE, |
| 342 | static_cast<u32>(date_time.toSecsSinceEpoch())); |
| 343 | Update(); |
| 344 | }); |
| 345 | } |
| 346 | |
| 347 | void AdvancedPane::Update() |
| 348 | { |
| 349 | const bool is_uninitialized = Core::IsUninitialized(Core::System::GetInstance()); |
| 350 | const bool enable_cpu_clock_override_widgets = Config::Get(Config::MAIN_OVERCLOCK_ENABLE); |
| 351 | const bool enable_vi_rate_override_widgets = Config::Get(Config::MAIN_VI_OVERCLOCK_ENABLE); |
| 352 | const bool enable_ram_override_widgets = Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE); |
| 353 | const bool enable_custom_rtc_widgets = |
| 354 | Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE) && is_uninitialized; |
| 355 | |
| 356 | m_cpu_emulation_engine_combobox->setEnabled(is_uninitialized); |
| 357 | m_enable_mmu_checkbox->setEnabled(is_uninitialized); |
| 358 | m_pause_on_panic_checkbox->setEnabled(is_uninitialized); |
| 359 | |
| 360 | { |
| 361 | QFont bf = font(); |
| 362 | bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) != |
| 363 | Config::LayerType::Base); |
| 364 | |
| 365 | const QSignalBlocker blocker(m_cpu_clock_override_checkbox); |
| 366 | m_cpu_clock_override_checkbox->setFont(bf); |
| 367 | m_cpu_clock_override_checkbox->setChecked(enable_cpu_clock_override_widgets); |
| 368 | } |
| 369 | |
| 370 | m_cpu_clock_override_slider->setEnabled(enable_cpu_clock_override_widgets); |
| 371 | m_cpu_label->setEnabled(enable_cpu_clock_override_widgets); |
| 372 | |
| 373 | QFont vi_bf = font(); |
| 374 | vi_bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_VI_OVERCLOCK_ENABLE) != |
| 375 | Config::LayerType::Base); |
| 376 | m_vi_rate_override_checkbox->setFont(vi_bf); |
| 377 | m_vi_rate_override_checkbox->setChecked(enable_vi_rate_override_widgets); |
| 378 | |
| 379 | m_vi_rate_override_slider->setEnabled(enable_vi_rate_override_widgets); |
| 380 | m_vi_label->setEnabled(enable_vi_rate_override_widgets); |
| 381 | |
| 382 | m_ram_override_checkbox->setEnabled(is_uninitialized); |
| 383 | SignalBlocking(m_ram_override_checkbox)->setChecked(enable_ram_override_widgets); |
| 384 | |
| 385 | m_mem1_override_slider->setEnabled(enable_ram_override_widgets && is_uninitialized); |
| 386 | m_mem1_label->setEnabled(enable_ram_override_widgets && is_uninitialized); |
| 387 | |
| 388 | m_mem2_override_slider->setEnabled(enable_ram_override_widgets && is_uninitialized); |
| 389 | m_mem2_label->setEnabled(enable_ram_override_widgets && is_uninitialized); |
| 390 | |
| 391 | m_custom_rtc_checkbox->setEnabled(is_uninitialized); |
| 392 | SignalBlocking(m_custom_rtc_checkbox)->setChecked(Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)); |
| 393 | |
| 394 | QDateTime initial_date_time; |
| 395 | initial_date_time.setSecsSinceEpoch(Config::Get(Config::MAIN_CUSTOM_RTC_VALUE)); |
| 396 | m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets); |
| 397 | SignalBlocking(m_custom_rtc_datetime)->setDateTime(initial_date_time); |
| 398 | |
| 399 | m_reset_button->setEnabled(is_uninitialized); |
| 400 | } |
| 401 | |
| 402 | void AdvancedPane::OnResetButtonClicked() |
| 403 | { |
| 404 | if (ModalMessageBox::question( |
| 405 | this, tr("Reset Dolphin Settings"), |
| 406 | tr("Are you sure you want to restore all Dolphin settings to their default " |
| 407 | "values? This action cannot be undone!\n" |
| 408 | "All customizations or changes you have made will be lost.\n\n" |
| 409 | "Do you want to proceed?"), |
| 410 | ModalMessageBox::StandardButtons(ModalMessageBox::Yes | ModalMessageBox::No), |
| 411 | ModalMessageBox::No, Qt::WindowModality::WindowModal) == ModalMessageBox::No) |
| 412 | { |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | SConfig::ResetAllSettings(); |
| 417 | UICommon::SetUserDirectory(File::GetUserPath(D_USER_IDX)); |
| 418 | |
| 419 | emit Settings::Instance().ConfigChanged(); |
| 420 | |
| 421 | #if defined(USE_ANALYTICS) && USE_ANALYTICS |
| 422 | ShowAnalyticsPrompt(this); |
| 423 | #endif |
| 424 | } |