diff options
| author | Aneesh Maganti <28660350+aminoa@users.noreply.github.com> | 2025-02-10 15:26:07 -0500 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2025-02-16 23:15:11 +0100 |
| commit | 276f043db8f8615b45ca84ebacf84d3bb9bc3aad (patch) | |
| tree | 88b8735c41d42c03c91e82fa3a831dfe4eb98f9c | |
| parent | a9ebedbf7dcce6234f4355e4111acf1ce69d6fa6 (diff) | |
DolphinQt: Create toggle for enabling/disabling time tracking
Introduce a new "Enable Time Tracking" checkbox in the InterfacePane UI. The checkbox is dynamically enabled or disabled based on the emulation state, preventing changes while emulation is active.
| -rw-r--r-- | Source/Core/DolphinQt/Settings/InterfacePane.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Settings/InterfacePane.h | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index e52fb69200..71a044d658 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -22,6 +22,8 @@ #include "Core/AchievementManager.h" #include "Core/Config/MainSettings.h" #include "Core/Config/UISettings.h" +#include "Core/Core.h" +#include "Core/System.h" #include "DolphinQt/Config/ConfigControls/ConfigBool.h" #include "DolphinQt/Config/ConfigControls/ConfigChoice.h" @@ -95,6 +97,10 @@ InterfacePane::InterfacePane(QWidget* parent) : QWidget(parent) connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &InterfacePane::UpdateShowDebuggingCheckbox); + connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, + &InterfacePane::OnEmulationStateChanged); + + OnEmulationStateChanged(Core::GetState(Core::System::GetInstance())); } void InterfacePane::CreateLayout() @@ -168,12 +174,15 @@ void InterfacePane::CreateUI() new ConfigBool(tr("Hotkeys Require Window Focus"), Config::MAIN_FOCUSED_HOTKEYS); m_checkbox_disable_screensaver = new ConfigBool(tr("Inhibit Screensaver During Emulation"), Config::MAIN_DISABLE_SCREENSAVER); + m_checkbox_time_tracking = + new ConfigBool(tr("Enable Play Time Tracking"), Config::MAIN_TIME_TRACKING); groupbox_layout->addWidget(m_checkbox_use_builtin_title_database); groupbox_layout->addWidget(m_checkbox_use_covers); groupbox_layout->addWidget(m_checkbox_show_debugging_ui); groupbox_layout->addWidget(m_checkbox_focused_hotkeys); groupbox_layout->addWidget(m_checkbox_disable_screensaver); + groupbox_layout->addWidget(m_checkbox_time_tracking); } void InterfacePane::CreateInGame() @@ -313,6 +322,12 @@ void InterfacePane::OnLanguageChanged() tr("You must restart Dolphin in order for the change to take effect.")); } +void InterfacePane::OnEmulationStateChanged(Core::State state) +{ + const bool uninitialized = state == Core::State::Uninitialized; + m_checkbox_time_tracking->setEnabled(uninitialized); +} + void InterfacePane::AddDescriptions() { static constexpr char TR_TITLE_DATABASE_DESCRIPTION[] = QT_TR_NOOP( @@ -341,6 +356,10 @@ void InterfacePane::AddDescriptions() static constexpr char TR_DISABLE_SCREENSAVER_DESCRIPTION[] = QT_TR_NOOP("Disables your screensaver while running a game." "<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>"); + static constexpr char TR_TIME_TRACKING[] = QT_TR_NOOP( + "Tracks the time you spend playing games and shows it in the List View (as hours/minutes)." + "<br><br>This setting cannot be changed while emulation is active." + "<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>"); static constexpr char TR_CONFIRM_ON_STOP_DESCRIPTION[] = QT_TR_NOOP("Prompts you to confirm that you want to end emulation when you press Stop." "<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>"); @@ -394,6 +413,8 @@ void InterfacePane::AddDescriptions() m_checkbox_disable_screensaver->SetDescription(tr(TR_DISABLE_SCREENSAVER_DESCRIPTION)); + m_checkbox_time_tracking->SetDescription(tr(TR_TIME_TRACKING)); + m_checkbox_confirm_on_stop->SetDescription(tr(TR_CONFIRM_ON_STOP_DESCRIPTION)); m_checkbox_use_panic_handlers->SetDescription(tr(TR_USE_PANIC_HANDLERS_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.h b/Source/Core/DolphinQt/Settings/InterfacePane.h index 90a81d2114..ffe1efa087 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.h +++ b/Source/Core/DolphinQt/Settings/InterfacePane.h @@ -13,6 +13,11 @@ class QVBoxLayout; class ToolTipCheckBox; class ToolTipComboBox; +namespace Core +{ +enum class State; +} + class InterfacePane final : public QWidget { Q_OBJECT @@ -30,6 +35,8 @@ private: void OnUserStyleChanged(); void OnLanguageChanged(); + void OnEmulationStateChanged(Core::State state); + QVBoxLayout* m_main_layout; ConfigStringChoice* m_combobox_language; @@ -42,6 +49,7 @@ private: ConfigBool* m_checkbox_focused_hotkeys; ConfigBool* m_checkbox_use_covers; ConfigBool* m_checkbox_disable_screensaver; + ConfigBool* m_checkbox_time_tracking; ConfigBool* m_checkbox_confirm_on_stop; ConfigBool* m_checkbox_use_panic_handlers; |
