mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-10-11 22:49:56 +00:00
Qt: Use QHeaderView::Stretch for the game list title columns
This commit is contained in:
committed by
lightningterror
parent
bac5dcf5d4
commit
f0a02d308b
@@ -328,13 +328,15 @@ void GameListWidget::initialize()
|
||||
applyTableHeaderDefaults();
|
||||
}
|
||||
|
||||
// Set after the header state is loaded, because restoreState() carries the resize modes with it.
|
||||
m_table_view->horizontalHeader()->setSectionResizeMode(GameListModel::Column_Title, QHeaderView::Stretch);
|
||||
m_table_view->horizontalHeader()->setSectionResizeMode(GameListModel::Column_FileTitle, QHeaderView::Stretch);
|
||||
|
||||
// After header state load to account for user-specified sort.
|
||||
m_table_view->setSortingEnabled(true);
|
||||
|
||||
// Safety Fallback: Ensure the header is actually visible and
|
||||
// force it to stretch correctly on the first launch. This is an edgecase in case it already broke for some people or broke on older versions
|
||||
// Safety Fallback: Ensure the header is actually visible. This is an edgecase in case it already broke for some people or broke on older versions
|
||||
m_table_view->horizontalHeader()->show();
|
||||
resizeTableViewColumnsToFit();
|
||||
|
||||
m_ui.stack->insertWidget(0, m_table_view);
|
||||
|
||||
@@ -379,7 +381,6 @@ void GameListWidget::initialize()
|
||||
setFocusProxy(m_ui.stack->currentWidget());
|
||||
|
||||
updateToolbar();
|
||||
resizeTableViewColumnsToFit();
|
||||
setCustomBackground();
|
||||
}
|
||||
|
||||
@@ -748,7 +749,6 @@ void GameListWidget::showGameList()
|
||||
|
||||
m_ui.stack->setCurrentIndex(0);
|
||||
setFocusProxy(m_ui.stack->currentWidget());
|
||||
resizeTableViewColumnsToFit();
|
||||
updateToolbar();
|
||||
emit layoutChange();
|
||||
}
|
||||
@@ -845,7 +845,6 @@ void GameListWidget::hideEvent(QHideEvent* event)
|
||||
void GameListWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
resizeTableViewColumnsToFit();
|
||||
m_model->updateCacheSize(width(), height());
|
||||
processBackgroundFrames();
|
||||
}
|
||||
@@ -879,27 +878,6 @@ bool GameListWidget::eventFilter(QObject* watched, QEvent* event)
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void GameListWidget::resizeTableViewColumnsToFit()
|
||||
{
|
||||
const auto column_width = [this](int column) {
|
||||
return (DEFAULT_COLUMN_WIDTHS[column] < 0) ? DEFAULT_COLUMN_WIDTHS[column] :
|
||||
m_table_view->columnWidth(column);
|
||||
};
|
||||
|
||||
QtUtils::ResizeColumnsForTableView(m_table_view, {
|
||||
column_width(GameListModel::Column_Type),
|
||||
column_width(GameListModel::Column_Serial),
|
||||
column_width(GameListModel::Column_Title),
|
||||
column_width(GameListModel::Column_FileTitle),
|
||||
column_width(GameListModel::Column_CRC),
|
||||
column_width(GameListModel::Column_TimePlayed),
|
||||
column_width(GameListModel::Column_LastPlayed),
|
||||
column_width(GameListModel::Column_Size),
|
||||
column_width(GameListModel::Column_Region),
|
||||
column_width(GameListModel::Column_Compatibility),
|
||||
});
|
||||
}
|
||||
|
||||
void GameListWidget::loadTableHeaderState()
|
||||
{
|
||||
QHeaderView* header = m_table_view->horizontalHeader();
|
||||
@@ -1015,9 +993,6 @@ void GameListWidget::resetTableHeaderToDefault()
|
||||
|
||||
Host::SetBaseStringSettingValue("GameListTableView", "HeaderState", header->saveState().toBase64());
|
||||
Host::CommitBaseSettingChanges();
|
||||
|
||||
// This makes the columns expand to fill the window right now.
|
||||
resizeTableViewColumnsToFit();
|
||||
}
|
||||
|
||||
void GameListWidget::saveSortSettings(const int column, const Qt::SortOrder sort_order)
|
||||
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
__fi GameListModel* getModel() const { return m_model; }
|
||||
|
||||
void initialize();
|
||||
void resizeTableViewColumnsToFit();
|
||||
|
||||
void refresh(bool invalidate_cache, bool popup_on_error);
|
||||
void cancelRefresh();
|
||||
|
||||
@@ -2626,12 +2626,6 @@ void MainWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QMainWindow::showEvent(event);
|
||||
|
||||
// This is a bit silly, but for some reason resizing *before* the window is shown
|
||||
// gives the incorrect sizes for columns, if you set the style before setting up
|
||||
// the rest of the window... so, instead, let's just force it to be resized on show.
|
||||
if (isShowingGameList())
|
||||
m_game_list_widget->resizeTableViewColumnsToFit();
|
||||
|
||||
#ifdef ENABLE_RAINTEGRATION
|
||||
if (Achievements::IsUsingRAIntegration())
|
||||
Achievements::RAIntegration::MainWindowChanged((void*)winId());
|
||||
@@ -3182,7 +3176,6 @@ void MainWindow::destroyDisplayWidget(bool show_game_list)
|
||||
if (show_game_list)
|
||||
{
|
||||
m_ui.mainContainer->setCurrentIndex(0);
|
||||
m_game_list_widget->resizeTableViewColumnsToFit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user