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.
This commit is contained in:
Aneesh Maganti 2025-02-10 15:26:07 -05:00 committed by Admiral H. Curtiss
parent a9ebedbf7d
commit 276f043db8
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 29 additions and 0 deletions

View File

@ -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));

View File

@ -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;