summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2017-08-30 21:00:59 +0200
committerspycrab <spycrab@users.noreply.github.com>2017-09-15 19:01:23 +0200
commit5aecd61ede39efab8adfe228615da76176cfaaa5 (patch)
treea595b752118cad3acefd98e1389b5103d1e6a95b /Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp
parent8687f6aae7928d4fc2268c1c0251f051503612af (diff)
Qt/Settings: Implement cheat settings
Diffstat (limited to 'Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp')
-rw-r--r--Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp b/Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp
index c47bb93bd4..b365e3048b 100644
--- a/Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp
+++ b/Source/Core/DolphinQt2/Config/CheatWarningWidget.cpp
@@ -6,35 +6,34 @@
#include <QHBoxLayout>
#include <QLabel>
-#include <QMessageBox>
#include <QPixmap>
#include <QPushButton>
#include <QStyle>
-#include <QTimer>
#include "Core/ConfigManager.h"
#include "Core/Core.h"
+#include "DolphinQt2/Settings.h"
CheatWarningWidget::CheatWarningWidget(const std::string& game_id) : m_game_id(game_id)
{
CreateWidgets();
ConnectWidgets();
- setHidden(true);
+ connect(&Settings::Instance(), &Settings::EnableCheatsChanged,
+ [this] { Update(Core::IsRunning()); });
+ connect(this, &CheatWarningWidget::EmulationStarted, [this] { Update(true); });
+ connect(this, &CheatWarningWidget::EmulationStopped, [this] { Update(false); });
- connect(this, &CheatWarningWidget::CheatEnableToggled, this,
- &CheatWarningWidget::CheatEnableToggled);
- connect(this, &CheatWarningWidget::EmulationStarted, this,
- &CheatWarningWidget::CheatEnableToggled);
- connect(this, &CheatWarningWidget::EmulationStopped, this,
- &CheatWarningWidget::CheatEnableToggled);
+ Update(Core::IsRunning());
}
void CheatWarningWidget::CreateWidgets()
{
auto* icon = new QLabel;
- QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(24, 24);
+ const auto size = 1.5 * QFontMetrics(font()).height();
+
+ QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size);
icon->setPixmap(warning_icon);
@@ -46,34 +45,38 @@ void CheatWarningWidget::CreateWidgets()
auto* layout = new QHBoxLayout;
layout->addWidget(icon);
- layout->addWidget(m_text);
+ layout->addWidget(m_text, 1);
layout->addWidget(m_config_button);
+ layout->setContentsMargins(0, 0, 0, 0);
+
setLayout(layout);
}
-void CheatWarningWidget::Update()
+void CheatWarningWidget::Update(bool running)
{
- bool cheats_enabled = SConfig::GetInstance().bEnableCheats;
-
- bool hide = true;
+ bool hide_widget = true;
+ bool hide_config_button = true;
- if (Core::IsRunning() && SConfig::GetInstance().GetGameID() == m_game_id)
+ if (running && SConfig::GetInstance().GetGameID() == m_game_id)
{
- hide = false;
+ hide_widget = false;
m_text->setText(tr("Changing cheats will only take effect when the game is restarted."));
}
- if (!cheats_enabled)
+ if (!Settings::Instance().GetCheatsEnabled())
{
- hide = false;
+ hide_widget = false;
+ hide_config_button = false;
m_text->setText(tr("Dolphin's cheat system is currently disabled."));
}
- m_config_button->setHidden(hide);
+ setHidden(hide_widget);
+ m_config_button->setHidden(hide_config_button);
}
void CheatWarningWidget::ConnectWidgets()
{
- connect(m_config_button, &QPushButton::pressed, [this] { emit OpenCheatEnableSettings(); });
+ connect(m_config_button, &QPushButton::pressed, this,
+ &CheatWarningWidget::OpenCheatEnableSettings);
}