Debian Codegraph @

Source/Core/DolphinQt/Config/HardcoreWarningWidget.cpp

raw symbols SCIP
1 // Copyright 2023 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #ifdef USE_RETRO_ACHIEVEMENTS
5 #include "DolphinQt/Config/HardcoreWarningWidget.h"
6
7 #include <QHBoxLayout>
8 #include <QLabel>
9 #include <QPushButton>
10 #include <QStyle>
11
12 #include "Core/AchievementManager.h"
13
14 #include "DolphinQt/QtUtils/QtUtils.h"
15 #include "DolphinQt/Settings.h"
16
17 HardcoreWarningWidget::HardcoreWarningWidget(QWidget* parent) : QWidget(parent)
18 {
19 CreateWidgets();
20 ConnectWidgets();
21
22 connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] { Update(); });
23
24 Update();
25 }
26
27 void HardcoreWarningWidget::CreateWidgets()
28 {
29 auto* const text = new QLabel(tr("Only approved codes will be applied in hardcore mode."));
30 auto* const icon_warning = QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, text);
31
32 m_settings_button = new QPushButton(tr("Achievement Settings"));
33
34 auto* const layout = new QHBoxLayout{this};
35
36 layout->addWidget(icon_warning, 1);
37 layout->addWidget(m_settings_button);
38
39 layout->setContentsMargins(0, 0, 0, 0);
40 }
41
42 void HardcoreWarningWidget::ConnectWidgets()
43 {
44 connect(m_settings_button, &QPushButton::clicked, this,
45 &HardcoreWarningWidget::OpenAchievementSettings);
46 }
47
48 void HardcoreWarningWidget::Update()
49 {
50 setHidden(!AchievementManager::GetInstance().IsHardcoreModeActive());
51 }
52 #endif // USE_RETRO_ACHIEVEMENTS