From 9a5ee3aae63a5f78e8ca5083d3e05dbef89b4d6c Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 3 Dec 2024 16:16:35 +1000 Subject: [PATCH] Qt: Fix horizontal scrollbar showing in summary track list --- src/duckstation-qt/gamesummarywidget.cpp | 34 +++++++++++++++++++----- src/duckstation-qt/gamesummarywidget.h | 5 ++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/duckstation-qt/gamesummarywidget.cpp b/src/duckstation-qt/gamesummarywidget.cpp index 31f005b42..8fcf6f5f7 100644 --- a/src/duckstation-qt/gamesummarywidget.cpp +++ b/src/duckstation-qt/gamesummarywidget.cpp @@ -106,6 +106,25 @@ void GameSummaryWidget::reloadGameSettings() m_ui.editInputProfile->setEnabled(m_ui.inputProfile->currentIndex() >= 1); } +void GameSummaryWidget::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + updateTracksInfoColumnSizes(); +} + +void GameSummaryWidget::showEvent(QShowEvent* event) +{ + QWidget::showEvent(event); + + // Need to put this on show as well, otherwise it lags behind the vertical scrollbar being enabled. + updateTracksInfoColumnSizes(); +} + +void GameSummaryWidget::updateTracksInfoColumnSizes() +{ + QtUtils::ResizeColumnsForTableView(m_ui.tracks, {70, 75, 70, 70, -1, 40}); +} + void GameSummaryWidget::populateUi(const std::string& path, const std::string& serial, DiscRegion region, const GameDatabase::Entry* entry) { @@ -287,13 +306,12 @@ void GameSummaryWidget::setRevisionText(const QString& text) m_ui.revision->setVisible(true); } -static QString MSFTotString(const CDImage::Position& position) +static QString MSFToString(const CDImage::Position& position) { - return QStringLiteral("%1:%2:%3 (LBA %4)") + return QStringLiteral("%1:%2:%3") .arg(static_cast(position.minute), 2, 10, static_cast('0')) .arg(static_cast(position.second), 2, 10, static_cast('0')) - .arg(static_cast(position.frame), 2, 10, static_cast('0')) - .arg(static_cast(position.ToLBA())); + .arg(static_cast(position.frame), 2, 10, static_cast('0')); } void GameSummaryWidget::populateTracksInfo() @@ -302,7 +320,6 @@ void GameSummaryWidget::populateTracksInfo() {"Audio", "Mode 1", "Mode 1/Raw", "Mode 2", "Mode 2/Form 1", "Mode 2/Form 2", "Mode 2/Mix", "Mode 2/Raw"}}; m_ui.tracks->clearContents(); - QtUtils::ResizeColumnsForTableView(m_ui.tracks, {70, 75, 95, 95, 215, 40}); std::unique_ptr image = CDImage::Open(m_path.c_str(), false, nullptr); if (!image) @@ -327,10 +344,13 @@ void GameSummaryWidget::populateTracksInfo() m_ui.tracks->insertRow(row); m_ui.tracks->setItem(row, 0, num); m_ui.tracks->setItem(row, 1, new QTableWidgetItem(track_mode_strings[static_cast(mode)])); - m_ui.tracks->setItem(row, 2, new QTableWidgetItem(MSFTotString(position))); - m_ui.tracks->setItem(row, 3, new QTableWidgetItem(MSFTotString(length))); + m_ui.tracks->setItem(row, 2, new QTableWidgetItem(MSFToString(position))); + m_ui.tracks->setItem(row, 3, new QTableWidgetItem(MSFToString(length))); m_ui.tracks->setItem(row, 4, new QTableWidgetItem(tr(""))); + for (int i = 1; i <= 4; i++) + m_ui.tracks->item(row, i)->setTextAlignment(Qt::AlignCenter); + QTableWidgetItem* status = new QTableWidgetItem(QString()); status->setTextAlignment(Qt::AlignCenter); m_ui.tracks->setItem(row, 5, status); diff --git a/src/duckstation-qt/gamesummarywidget.h b/src/duckstation-qt/gamesummarywidget.h index a96fa4404..15718f4ca 100644 --- a/src/duckstation-qt/gamesummarywidget.h +++ b/src/duckstation-qt/gamesummarywidget.h @@ -26,6 +26,10 @@ public: void reloadGameSettings(); +protected: + void resizeEvent(QResizeEvent* event) override; + void showEvent(QShowEvent* event) override; + private Q_SLOTS: void onCustomLanguageChanged(int language); void onCompatibilityCommentsClicked(); @@ -43,6 +47,7 @@ private: void setRevisionText(const QString& text); void populateTracksInfo(); + void updateTracksInfoColumnSizes(); Ui::GameSummaryWidget m_ui; SettingsWindow* m_dialog;