mirror of
https://github.com/stenzek/duckstation.git
synced 2025-12-28 05:24:19 +00:00
Qt: Use Roboto for cover captions too
Some checks are pending
Automated Builds / 💻 Windows (push) Waiting to run
Automated Builds / 🐧 Linux AppImage (push) Waiting to run
Automated Builds / 🐧 Linux Cross-Compiled AppImage (push) Waiting to run
Automated Builds / 📦 Linux Flatpak (push) Waiting to run
Automated Builds / 🍎 MacOS (push) Waiting to run
Automated Builds / 📤 Create Release (push) Blocked by required conditions
Some checks are pending
Automated Builds / 💻 Windows (push) Waiting to run
Automated Builds / 🐧 Linux AppImage (push) Waiting to run
Automated Builds / 🐧 Linux Cross-Compiled AppImage (push) Waiting to run
Automated Builds / 📦 Linux Flatpak (push) Waiting to run
Automated Builds / 🍎 MacOS (push) Waiting to run
Automated Builds / 📤 Create Release (push) Blocked by required conditions
And don't do a full refresh when scale changes.
This commit is contained in:
parent
e2142419e1
commit
aca4e6be42
@ -270,7 +270,7 @@ void GameListModel::updateCoverScale()
|
||||
}
|
||||
|
||||
emit coverScaleChanged(m_cover_scale);
|
||||
refresh();
|
||||
emit dataChanged(index(0, Column_Cover), index(rowCount() - 1, Column_Cover), {Qt::DecorationRole, Qt::FontRole});
|
||||
}
|
||||
|
||||
void GameListModel::refreshCovers()
|
||||
@ -673,6 +673,17 @@ QVariant GameListModel::data(const QModelIndex& index, int role, const GameList:
|
||||
}
|
||||
}
|
||||
|
||||
case Qt::FontRole:
|
||||
{
|
||||
if (index.column() != Column_Cover || !m_show_titles_for_covers)
|
||||
return {};
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(std::max(static_cast<int>(30.0f * m_cover_scale), 1));
|
||||
font.setFamilies(QtHost::GetRobotoFontFamilies());
|
||||
return font;
|
||||
}
|
||||
|
||||
case Qt::TextAlignmentRole:
|
||||
{
|
||||
switch (index.column())
|
||||
@ -2011,9 +2022,8 @@ GameListGridView::GameListGridView(GameListModel* model, GameListSortModel* sort
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
verticalScrollBar()->setSingleStep(15);
|
||||
|
||||
connect(m_model, &GameListModel::coverScaleChanged, this, &GameListGridView::onCoverScaleChanged);
|
||||
onCoverScaleChanged(m_model->getCoverScale());
|
||||
connect(m_model, &GameListModel::coverScaleChanged, this, &GameListGridView::updateLayout);
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
GameListGridView::~GameListGridView() = default;
|
||||
@ -2043,15 +2053,6 @@ void GameListGridView::resizeEvent(QResizeEvent* e)
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
void GameListGridView::onCoverScaleChanged(float scale)
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(std::max(static_cast<int>(30.0f * scale), 1));
|
||||
setFont(font);
|
||||
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
void GameListGridView::adjustZoom(float delta)
|
||||
{
|
||||
const float new_scale = std::clamp(m_model->getCoverScale() + delta, MIN_COVER_SCALE, MAX_COVER_SCALE);
|
||||
|
||||
@ -205,7 +205,6 @@ public:
|
||||
GameListGridView(GameListModel* model, GameListSortModel* sort_model, QWidget* parent);
|
||||
~GameListGridView() override;
|
||||
|
||||
void updateLayout();
|
||||
int horizontalOffset() const override;
|
||||
int verticalOffset() const override;
|
||||
|
||||
@ -213,13 +212,13 @@ public Q_SLOTS:
|
||||
void zoomOut();
|
||||
void zoomIn();
|
||||
void setZoomPct(int int_scale);
|
||||
void updateLayout();
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent* e) override;
|
||||
void resizeEvent(QResizeEvent* e) override;
|
||||
|
||||
private:
|
||||
void onCoverScaleChanged(float scale);
|
||||
void adjustZoom(float delta);
|
||||
|
||||
GameListModel* m_model = nullptr;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user