Qt: Fix sizing of patch detail widgets

This commit is contained in:
Stenzek 2025-05-18 13:33:21 +10:00
parent 0ee3f235b6
commit 54444475f5
No known key found for this signature in database
3 changed files with 65 additions and 73 deletions

View File

@ -6,82 +6,44 @@
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>112</height>
<width>480</width>
<height>92</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="name">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Patch Title</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="enabled">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
<property name="minimumSize">
<size>
<width>480</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QCheckBox" name="enabled">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
<item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="description">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Author: &lt;/span&gt;Patch Author&lt;/p&gt;&lt;p&gt;Description would go here&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
@ -93,6 +55,22 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="name">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Patch Title</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -21,7 +21,11 @@ GamePatchDetailsWidget::GamePatchDetailsWidget(std::string name, const std::stri
{
m_ui.setupUi(this);
QFont title_font(m_ui.name->font());
title_font.setPointSizeF(title_font.pointSizeF() + 4.0f);
title_font.setBold(true);
m_ui.name->setText(QString::fromStdString(name));
m_ui.name->setFont(title_font);
m_ui.description->setText(
tr("<strong>Author: </strong>%1%2<br>%3")
.arg(author.empty() ? tr("Unknown") : QString::fromStdString(author))
@ -88,11 +92,14 @@ void GamePatchSettingsWidget::reloadList()
delete m_ui.scrollArea->takeWidget();
QWidget* container = new QWidget(m_ui.scrollArea);
m_ui.scrollArea->setWidget(container);
QVBoxLayout* layout = new QVBoxLayout(container);
layout->setContentsMargins(0, 0, 0, 0);
if (!patches.empty())
{
layout->setContentsMargins(0, 0, 0, 0);
bool first = true;
for (Cheats::CodeInfo& pi : patches)
@ -117,9 +124,13 @@ void GamePatchSettingsWidget::reloadList()
}
else
{
QLabel* label = new QLabel(tr("There are no patches available for this game."), container);
QLabel* label = new QLabel(tr("No patches are available for this game."), container);
QFont font(label->font());
font.setPointSizeF(font.pointSizeF() + 2.0f);
font.setBold(true);
label->setFont(font);
layout->addWidget(label);
}
m_ui.scrollArea->setWidget(container);
layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>766</width>
<height>392</height>
<height>200</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -28,6 +28,9 @@
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
@ -49,8 +52,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>