Qt: Resize fixed columns on theme change

Fixes columns being too small after change on MacOS.
pull/3575/head
Stenzek 2 months ago
parent 3724a38d38
commit 6caf2d567b
No known key found for this signature in database

@ -1469,6 +1469,9 @@ void GameListWidget::cancelRefresh()
void GameListWidget::onThemeChanged() void GameListWidget::onThemeChanged()
{ {
m_model->reloadThemeSpecificImages(); m_model->reloadThemeSpecificImages();
// Resize columns, since the text size can change with themes.
m_list_view->updateFixedColumnWidths();
} }
void GameListWidget::setBackgroundPath(const std::string_view path) void GameListWidget::setBackgroundPath(const std::string_view path)
@ -1856,7 +1859,7 @@ GameListListView::GameListListView(GameListModel* model, GameListSortModel* sort
QHeaderView* const horizontal_header = horizontalHeader(); QHeaderView* const horizontal_header = horizontalHeader();
horizontal_header->setHighlightSections(false); horizontal_header->setHighlightSections(false);
horizontal_header->setContextMenuPolicy(Qt::CustomContextMenu); horizontal_header->setContextMenuPolicy(Qt::CustomContextMenu);
setFixedColumnWidths(); updateFixedColumnWidths();
horizontal_header->setSectionResizeMode(GameListModel::Column_Title, QHeaderView::Stretch); horizontal_header->setSectionResizeMode(GameListModel::Column_Title, QHeaderView::Stretch);
horizontal_header->setSectionResizeMode(GameListModel::Column_FileTitle, QHeaderView::Stretch); horizontal_header->setSectionResizeMode(GameListModel::Column_FileTitle, QHeaderView::Stretch);
@ -1921,7 +1924,7 @@ void GameListListView::setFixedColumnWidth(const QFontMetrics& fm, int column, i
setFixedColumnWidth(column, width); setFixedColumnWidth(column, width);
} }
void GameListListView::setFixedColumnWidths() void GameListListView::updateFixedColumnWidths()
{ {
const QFontMetrics fm = fontMetricsForHorizontalHeader(); const QFontMetrics fm = fontMetricsForHorizontalHeader();
const auto width_for = [&fm](const QString& text) { return fm.size(0, text).width(); }; const auto width_for = [&fm](const QString& text) { return fm.size(0, text).width(); };

@ -176,6 +176,7 @@ public:
QFontMetrics fontMetricsForHorizontalHeader() const; QFontMetrics fontMetricsForHorizontalHeader() const;
void setFixedColumnWidth(const QFontMetrics& fm, int column, int str_width); void setFixedColumnWidth(const QFontMetrics& fm, int column, int str_width);
void setAndSaveColumnHidden(int column, bool hidden); void setAndSaveColumnHidden(int column, bool hidden);
void updateFixedColumnWidths();
void adjustIconSize(int delta); void adjustIconSize(int delta);
@ -184,7 +185,6 @@ protected:
private: private:
void setFixedColumnWidth(int column, int width); void setFixedColumnWidth(int column, int width);
void setFixedColumnWidths();
void loadColumnVisibilitySettings(); void loadColumnVisibilitySettings();
void loadColumnSortSettings(); void loadColumnSortSettings();

Loading…
Cancel
Save