mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-28 01:49:33 -06:00
DolphinQt: Add utility function for creating label text with a standard icon.
This commit is contained in:
@ -13,6 +13,7 @@
|
|||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
|
|
||||||
|
#include "DolphinQt/QtUtils/QtUtils.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_required,
|
CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_required,
|
||||||
@ -33,28 +34,17 @@ CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_
|
|||||||
|
|
||||||
void CheatWarningWidget::CreateWidgets()
|
void CheatWarningWidget::CreateWidgets()
|
||||||
{
|
{
|
||||||
auto* icon = new QLabel;
|
|
||||||
|
|
||||||
const auto size = 1.5 * QFontMetrics(font()).height();
|
|
||||||
|
|
||||||
QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size);
|
|
||||||
|
|
||||||
icon->setPixmap(warning_icon);
|
|
||||||
|
|
||||||
m_text = new QLabel();
|
m_text = new QLabel();
|
||||||
m_config_button = new QPushButton(tr("Configure Dolphin"));
|
m_config_button = new QPushButton(tr("Configure Dolphin"));
|
||||||
|
|
||||||
m_config_button->setHidden(true);
|
m_config_button->setHidden(true);
|
||||||
|
|
||||||
auto* layout = new QHBoxLayout;
|
auto* const layout = new QHBoxLayout{this};
|
||||||
|
|
||||||
layout->addWidget(icon);
|
layout->addWidget(QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, m_text));
|
||||||
layout->addWidget(m_text, 1);
|
|
||||||
layout->addWidget(m_config_button);
|
layout->addWidget(m_config_button);
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
setLayout(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatWarningWidget::Update(bool running)
|
void CheatWarningWidget::Update(bool running)
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
|
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
|
||||||
#include "DolphinQt/Config/Graphics/GeneralWidget.h"
|
#include "DolphinQt/Config/Graphics/GeneralWidget.h"
|
||||||
#include "DolphinQt/Config/Graphics/HacksWidget.h"
|
#include "DolphinQt/Config/Graphics/HacksWidget.h"
|
||||||
|
#include "DolphinQt/QtUtils/QtUtils.h"
|
||||||
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
|
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
|
||||||
|
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
@ -259,18 +260,14 @@ void GameConfigWidget::CreateWidgets()
|
|||||||
"settings are disabled when the global graphics backend doesn't "
|
"settings are disabled when the global graphics backend doesn't "
|
||||||
"match the game setting.");
|
"match the game setting.");
|
||||||
|
|
||||||
auto help_icon = style()->standardIcon(QStyle::SP_MessageBoxQuestion);
|
auto* const help_label = new QLabel(tr("These settings override core Dolphin settings."));
|
||||||
auto* help_label = new QLabel(tr("These settings override core Dolphin settings."));
|
|
||||||
help_label->setToolTip(help_msg);
|
|
||||||
auto help_label_icon = new QLabel();
|
|
||||||
help_label_icon->setPixmap(help_icon.pixmap(12, 12));
|
|
||||||
help_label_icon->setToolTip(help_msg);
|
|
||||||
auto* help_layout = new QHBoxLayout();
|
|
||||||
help_layout->addWidget(help_label);
|
|
||||||
help_layout->addWidget(help_label_icon);
|
|
||||||
help_layout->addStretch();
|
|
||||||
|
|
||||||
layout->addLayout(help_layout);
|
auto* const help_widget =
|
||||||
|
QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxQuestion, help_label);
|
||||||
|
|
||||||
|
help_widget->setToolTip(help_msg);
|
||||||
|
|
||||||
|
layout->addWidget(help_widget);
|
||||||
layout->addWidget(tab_widget);
|
layout->addWidget(tab_widget);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
|
#include "DolphinQt/QtUtils/QtUtils.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
GraphicsModWarningWidget::GraphicsModWarningWidget(QWidget* parent) : QWidget(parent)
|
GraphicsModWarningWidget::GraphicsModWarningWidget(QWidget* parent) : QWidget(parent)
|
||||||
@ -23,28 +24,17 @@ GraphicsModWarningWidget::GraphicsModWarningWidget(QWidget* parent) : QWidget(pa
|
|||||||
|
|
||||||
void GraphicsModWarningWidget::CreateWidgets()
|
void GraphicsModWarningWidget::CreateWidgets()
|
||||||
{
|
{
|
||||||
auto* icon = new QLabel;
|
|
||||||
|
|
||||||
const auto size = 1.5 * QFontMetrics(font()).height();
|
|
||||||
|
|
||||||
QPixmap warning_icon = style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size);
|
|
||||||
|
|
||||||
icon->setPixmap(warning_icon);
|
|
||||||
|
|
||||||
m_text = new QLabel();
|
m_text = new QLabel();
|
||||||
m_config_button = new QPushButton(tr("Configure Dolphin"));
|
|
||||||
|
|
||||||
|
m_config_button = new QPushButton(tr("Configure Dolphin"));
|
||||||
m_config_button->setHidden(true);
|
m_config_button->setHidden(true);
|
||||||
|
|
||||||
auto* layout = new QHBoxLayout;
|
auto* const layout = new QHBoxLayout{this};
|
||||||
|
|
||||||
layout->addWidget(icon);
|
layout->addWidget(QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, m_text));
|
||||||
layout->addWidget(m_text, 1);
|
|
||||||
layout->addWidget(m_config_button);
|
layout->addWidget(m_config_button);
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
setLayout(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsModWarningWidget::Update()
|
void GraphicsModWarningWidget::Update()
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "Core/HW/GCKeyboard.h"
|
#include "Core/HW/GCKeyboard.h"
|
||||||
#include "Core/HW/GCKeyboardEmu.h"
|
#include "Core/HW/GCKeyboardEmu.h"
|
||||||
|
|
||||||
|
#include "DolphinQt/QtUtils/QtUtils.h"
|
||||||
|
|
||||||
GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
|
GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
|
||||||
{
|
{
|
||||||
CreateMainLayout();
|
CreateMainLayout();
|
||||||
@ -22,32 +24,24 @@ GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
|
|||||||
|
|
||||||
void GCKeyboardEmu::CreateMainLayout()
|
void GCKeyboardEmu::CreateMainLayout()
|
||||||
{
|
{
|
||||||
const auto vbox_layout = new QVBoxLayout;
|
auto* const vbox_layout = new QVBoxLayout{this};
|
||||||
|
|
||||||
const auto warning_layout = new QHBoxLayout;
|
auto* const warning_text =
|
||||||
vbox_layout->addLayout(warning_layout);
|
|
||||||
|
|
||||||
const auto warning_icon = new QLabel;
|
|
||||||
const auto size = QFontMetrics(font()).height() * 3 / 2;
|
|
||||||
warning_icon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(size, size));
|
|
||||||
warning_layout->addWidget(warning_icon);
|
|
||||||
|
|
||||||
const auto warning_text =
|
|
||||||
new QLabel(tr("You are configuring a \"Keyboard Controller\". "
|
new QLabel(tr("You are configuring a \"Keyboard Controller\". "
|
||||||
"This device is exclusively for \"Phantasy Star Online Episode I & II\". "
|
"This device is exclusively for \"Phantasy Star Online Episode I & II\". "
|
||||||
"If you are unsure, turn back now and configure a \"Standard Controller\"."));
|
"If you are unsure, turn back now and configure a \"Standard Controller\"."));
|
||||||
warning_text->setWordWrap(true);
|
warning_text->setWordWrap(true);
|
||||||
warning_layout->addWidget(warning_text, 1);
|
|
||||||
|
|
||||||
const auto layout = new QHBoxLayout;
|
vbox_layout->addWidget(
|
||||||
|
QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_text));
|
||||||
|
|
||||||
|
auto* const layout = new QHBoxLayout;
|
||||||
|
|
||||||
using KG = KeyboardGroup;
|
using KG = KeyboardGroup;
|
||||||
for (auto kbg : {KG::Kb0x, KG::Kb1x, KG::Kb2x, KG::Kb3x, KG::Kb4x, KG::Kb5x})
|
for (auto kbg : {KG::Kb0x, KG::Kb1x, KG::Kb2x, KG::Kb3x, KG::Kb4x, KG::Kb5x})
|
||||||
layout->addWidget(CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), kbg)));
|
layout->addWidget(CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), kbg)));
|
||||||
|
|
||||||
vbox_layout->addLayout(layout);
|
vbox_layout->addLayout(layout);
|
||||||
|
|
||||||
setLayout(vbox_layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCKeyboardEmu::LoadSettings()
|
void GCKeyboardEmu::LoadSettings()
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "DolphinQt/QtUtils/QtUtils.h"
|
#include "DolphinQt/QtUtils/QtUtils.h"
|
||||||
|
|
||||||
#include <QDateTimeEdit>
|
#include <QDateTimeEdit>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
namespace QtUtils
|
namespace QtUtils
|
||||||
{
|
{
|
||||||
@ -19,4 +21,18 @@ void ShowFourDigitYear(QDateTimeEdit* widget)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label)
|
||||||
|
{
|
||||||
|
const auto size = QFontMetrics(parent->font()).height() * 5 / 4;
|
||||||
|
|
||||||
|
auto* const icon = new QLabel{};
|
||||||
|
icon->setPixmap(parent->style()->standardIcon(standard_pixmap).pixmap(size, size));
|
||||||
|
|
||||||
|
auto* const widget = new QWidget;
|
||||||
|
auto* const layout = new QHBoxLayout{widget};
|
||||||
|
layout->addWidget(icon);
|
||||||
|
layout->addWidget(label, 1);
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QtUtils
|
} // namespace QtUtils
|
||||||
|
@ -3,11 +3,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
class QDateTimeEdit;
|
class QDateTimeEdit;
|
||||||
|
class QLabel;
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
namespace QtUtils
|
namespace QtUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
void ShowFourDigitYear(QDateTimeEdit* widget);
|
void ShowFourDigitYear(QDateTimeEdit* widget);
|
||||||
|
|
||||||
}
|
QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label);
|
||||||
|
|
||||||
|
} // namespace QtUtils
|
||||||
|
Reference in New Issue
Block a user