mirror of
https://github.com/stenzek/duckstation.git
synced 2025-07-19 00:20:12 +00:00
Qt: Don't draw a frame if there are no patches
This commit is contained in:
parent
d0c3f7d5a2
commit
7eb2b07e39
@ -6,7 +6,6 @@
|
|||||||
#include "qthost.h"
|
#include "qthost.h"
|
||||||
#include "qtutils.h"
|
#include "qtutils.h"
|
||||||
#include "settingswindow.h"
|
#include "settingswindow.h"
|
||||||
#include "settingwidgetbinder.h"
|
|
||||||
|
|
||||||
#include "core/cheats.h"
|
#include "core/cheats.h"
|
||||||
|
|
||||||
@ -17,15 +16,15 @@
|
|||||||
GamePatchDetailsWidget::GamePatchDetailsWidget(std::string name, const std::string& author,
|
GamePatchDetailsWidget::GamePatchDetailsWidget(std::string name, const std::string& author,
|
||||||
const std::string& description, bool disallowed_for_achievements,
|
const std::string& description, bool disallowed_for_achievements,
|
||||||
bool enabled, SettingsWindow* dialog, QWidget* parent)
|
bool enabled, SettingsWindow* dialog, QWidget* parent)
|
||||||
: QWidget(parent), m_dialog(dialog), m_name(name)
|
: QWidget(parent), m_dialog(dialog), m_name(std::move(name))
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
QFont title_font(m_ui.name->font());
|
QFont title_font(m_ui.name->font());
|
||||||
title_font.setPointSizeF(title_font.pointSizeF() + 4.0f);
|
title_font.setPointSizeF(title_font.pointSizeF() + 4.0f);
|
||||||
title_font.setBold(true);
|
title_font.setBold(true);
|
||||||
m_ui.name->setText(QString::fromStdString(name));
|
|
||||||
m_ui.name->setFont(title_font);
|
m_ui.name->setFont(title_font);
|
||||||
|
m_ui.name->setText(QString::fromStdString(m_name));
|
||||||
m_ui.description->setText(
|
m_ui.description->setText(
|
||||||
tr("<strong>Author: </strong>%1%2<br>%3")
|
tr("<strong>Author: </strong>%1%2<br>%3")
|
||||||
.arg(author.empty() ? tr("Unknown") : QString::fromStdString(author))
|
.arg(author.empty() ? tr("Unknown") : QString::fromStdString(author))
|
||||||
@ -40,7 +39,7 @@ GamePatchDetailsWidget::GamePatchDetailsWidget(std::string name, const std::stri
|
|||||||
|
|
||||||
GamePatchDetailsWidget::~GamePatchDetailsWidget() = default;
|
GamePatchDetailsWidget::~GamePatchDetailsWidget() = default;
|
||||||
|
|
||||||
void GamePatchDetailsWidget::onEnabledStateChanged(int state)
|
void GamePatchDetailsWidget::onEnabledStateChanged(Qt::CheckState state)
|
||||||
{
|
{
|
||||||
INISettingsInterface* si = m_dialog->getSettingsInterface();
|
INISettingsInterface* si = m_dialog->getSettingsInterface();
|
||||||
if (state == Qt::Checked)
|
if (state == Qt::Checked)
|
||||||
@ -55,8 +54,6 @@ void GamePatchDetailsWidget::onEnabledStateChanged(int state)
|
|||||||
GamePatchSettingsWidget::GamePatchSettingsWidget(SettingsWindow* dialog, QWidget* parent) : m_dialog(dialog)
|
GamePatchSettingsWidget::GamePatchSettingsWidget(SettingsWindow* dialog, QWidget* parent) : m_dialog(dialog)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
m_ui.scrollArea->setFrameShape(QFrame::WinPanel);
|
|
||||||
m_ui.scrollArea->setFrameShadow(QFrame::Sunken);
|
|
||||||
|
|
||||||
connect(m_ui.reload, &QPushButton::clicked, this, &GamePatchSettingsWidget::onReloadClicked);
|
connect(m_ui.reload, &QPushButton::clicked, this, &GamePatchSettingsWidget::onReloadClicked);
|
||||||
connect(m_ui.disableAllPatches, &QPushButton::clicked, this, &GamePatchSettingsWidget::disableAllPatches);
|
connect(m_ui.disableAllPatches, &QPushButton::clicked, this, &GamePatchSettingsWidget::disableAllPatches);
|
||||||
@ -89,26 +86,22 @@ void GamePatchSettingsWidget::reloadList()
|
|||||||
std::vector<std::string> enabled_list =
|
std::vector<std::string> enabled_list =
|
||||||
m_dialog->getSettingsInterface()->GetStringList(Cheats::PATCHES_CONFIG_SECTION, Cheats::PATCH_ENABLE_CONFIG_KEY);
|
m_dialog->getSettingsInterface()->GetStringList(Cheats::PATCHES_CONFIG_SECTION, Cheats::PATCH_ENABLE_CONFIG_KEY);
|
||||||
|
|
||||||
delete m_ui.scrollArea->takeWidget();
|
QWidget* container = new QWidget;
|
||||||
|
|
||||||
QWidget* container = new QWidget(m_ui.scrollArea);
|
|
||||||
m_ui.scrollArea->setWidget(container);
|
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(container);
|
QVBoxLayout* layout = new QVBoxLayout(container);
|
||||||
|
m_ui.scrollArea->setWidget(container);
|
||||||
|
|
||||||
if (!patches.empty())
|
if (!patches.empty())
|
||||||
{
|
{
|
||||||
|
m_ui.scrollArea->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
for (Cheats::CodeInfo& pi : patches)
|
for (Cheats::CodeInfo& pi : patches)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
QFrame* frame = new QFrame(container);
|
QFrame* frame = new QFrame(container);
|
||||||
frame->setFrameShape(QFrame::HLine);
|
frame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||||
frame->setFrameShadow(QFrame::Sunken);
|
|
||||||
layout->addWidget(frame);
|
layout->addWidget(frame);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -124,6 +117,8 @@ void GamePatchSettingsWidget::reloadList()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_ui.scrollArea->setFrameStyle(QFrame::NoFrame);
|
||||||
|
|
||||||
QLabel* label = new QLabel(tr("No patches are available for this game."), container);
|
QLabel* label = new QLabel(tr("No patches are available for this game."), container);
|
||||||
QFont font(label->font());
|
QFont font(label->font());
|
||||||
font.setPointSizeF(font.pointSizeF() + 2.0f);
|
font.setPointSizeF(font.pointSizeF() + 2.0f);
|
||||||
@ -132,5 +127,5 @@ void GamePatchSettingsWidget::reloadList()
|
|||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
layout->addStretch();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
~GamePatchDetailsWidget();
|
~GamePatchDetailsWidget();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onEnabledStateChanged(int state);
|
void onEnabledStateChanged(Qt::CheckState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::GamePatchDetailsWidget m_ui;
|
Ui::GamePatchDetailsWidget m_ui;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user