Skip to content

Commit c4c6357

Browse files
committed
Qt: Improve column width behaviour in cheat list
Prevent long cheats being truncated after addition/editing.
1 parent 286f9dd commit c4c6357

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/duckstation-qt/gamecheatsettingswidget.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ GameCheatSettingsWidget::GameCheatSettingsWidget(SettingsWindow* dialog, QWidget
192192
m_sort_model->sort(sorting_enabled ? 0 : -1, Qt::AscendingOrder);
193193
m_ui.cheatList->setModel(m_sort_model);
194194
m_ui.cheatList->setItemDelegate(new CheatListOptionDelegate(this, m_ui.cheatList));
195-
196195
reloadList();
197-
QtUtils::SetColumnWidthsForTreeView(m_ui.cheatList, {-1, 150});
198196

199197
// We don't use the binder here, because they're binary - either enabled, or not in the file.
200198
m_ui.enableCheats->setChecked(sif->GetBoolValue("Cheats", "EnableCheats", false));
@@ -555,6 +553,16 @@ void GameCheatSettingsWidget::reloadList()
555553

556554
// Expand all items, and ensure the size is correct. Otherwise editing codes resizes it.
557555
expandAllItems();
556+
557+
// Set column sizes, option dropdown gets less space.
558+
// Qt asserts if we do this without any data.
559+
if (m_codes.empty())
560+
return;
561+
562+
QHeaderView* const cheat_list_header = m_ui.cheatList->header();
563+
cheat_list_header->setSectionResizeMode(0, QHeaderView::Stretch);
564+
cheat_list_header->setSectionResizeMode(1, QHeaderView::Fixed);
565+
cheat_list_header->resizeSection(1, 150);
558566
}
559567

560568
void GameCheatSettingsWidget::expandAllItems()

src/duckstation-qt/gamecheatsettingswidget.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@
138138
<property name="expandsOnDoubleClick">
139139
<bool>true</bool>
140140
</property>
141+
<attribute name="headerStretchLastSection">
142+
<bool>false</bool>
143+
</attribute>
141144
</widget>
142145
</item>
143146
<item>

0 commit comments

Comments
 (0)