Skip to content

Commit

Permalink
Qt: Fix horizontal scrollbar showing in summary track list
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 3, 2024
1 parent 03eb4a6 commit 9a5ee3a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/duckstation-qt/gamesummarywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<uint>(position.minute), 2, 10, static_cast<QChar>('0'))
.arg(static_cast<uint>(position.second), 2, 10, static_cast<QChar>('0'))
.arg(static_cast<uint>(position.frame), 2, 10, static_cast<QChar>('0'))
.arg(static_cast<ulong>(position.ToLBA()));
.arg(static_cast<uint>(position.frame), 2, 10, static_cast<QChar>('0'));
}

void GameSummaryWidget::populateTracksInfo()
Expand All @@ -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<CDImage> image = CDImage::Open(m_path.c_str(), false, nullptr);
if (!image)
Expand All @@ -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<u32>(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("<not computed>")));

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);
Expand Down
5 changes: 5 additions & 0 deletions src/duckstation-qt/gamesummarywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class GameSummaryWidget : public QWidget

void reloadGameSettings();

protected:
void resizeEvent(QResizeEvent* event) override;
void showEvent(QShowEvent* event) override;

private Q_SLOTS:
void onCustomLanguageChanged(int language);
void onCompatibilityCommentsClicked();
Expand All @@ -43,6 +47,7 @@ private Q_SLOTS:
void setRevisionText(const QString& text);

void populateTracksInfo();
void updateTracksInfoColumnSizes();

Ui::GameSummaryWidget m_ui;
SettingsWindow* m_dialog;
Expand Down

0 comments on commit 9a5ee3a

Please sign in to comment.