mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-14 08:12:16 +00:00
Background image sized correctly (#2451)
This commit is contained in:
parent
2b9a8e5605
commit
e042710eaa
4 changed files with 35 additions and 4 deletions
|
@ -196,14 +196,28 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
||||||
void GameGridFrame::RefreshGridBackgroundImage() {
|
void GameGridFrame::RefreshGridBackgroundImage() {
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
||||||
palette.setBrush(QPalette::Base,
|
QSize widgetSize = size();
|
||||||
QBrush(backgroundImage.scaled(size(), Qt::IgnoreAspectRatio)));
|
QPixmap scaledPixmap =
|
||||||
|
QPixmap::fromImage(backgroundImage)
|
||||||
|
.scaled(widgetSize, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
|
int x = (widgetSize.width() - scaledPixmap.width()) / 2;
|
||||||
|
int y = (widgetSize.height() - scaledPixmap.height()) / 2;
|
||||||
|
QPixmap finalPixmap(widgetSize);
|
||||||
|
finalPixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&finalPixmap);
|
||||||
|
painter.drawPixmap(x, y, scaledPixmap);
|
||||||
|
palette.setBrush(QPalette::Base, QBrush(finalPixmap));
|
||||||
}
|
}
|
||||||
QColor transparentColor = QColor(135, 206, 235, 40);
|
QColor transparentColor = QColor(135, 206, 235, 40);
|
||||||
palette.setColor(QPalette::Highlight, transparentColor);
|
palette.setColor(QPalette::Highlight, transparentColor);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameGridFrame::resizeEvent(QResizeEvent* event) {
|
||||||
|
QTableWidget::resizeEvent(event);
|
||||||
|
RefreshGridBackgroundImage();
|
||||||
|
}
|
||||||
|
|
||||||
bool GameGridFrame::IsValidCellSelected() {
|
bool GameGridFrame::IsValidCellSelected() {
|
||||||
return validCellSelected;
|
return validCellSelected;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "background_music_player.h"
|
#include "background_music_player.h"
|
||||||
|
@ -21,6 +22,7 @@ Q_SIGNALS:
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void SetGridBackgroundImage(int row, int column);
|
void SetGridBackgroundImage(int row, int column);
|
||||||
void RefreshGridBackgroundImage();
|
void RefreshGridBackgroundImage();
|
||||||
|
void resizeEvent(QResizeEvent* event);
|
||||||
void PlayBackgroundMusic(QString path);
|
void PlayBackgroundMusic(QString path);
|
||||||
void onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
void onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
|
||||||
int previousColumn);
|
int previousColumn);
|
||||||
|
|
|
@ -200,14 +200,28 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||||
void GameListFrame::RefreshListBackgroundImage() {
|
void GameListFrame::RefreshListBackgroundImage() {
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
||||||
palette.setBrush(QPalette::Base,
|
QSize widgetSize = size();
|
||||||
QBrush(backgroundImage.scaled(size(), Qt::IgnoreAspectRatio)));
|
QPixmap scaledPixmap =
|
||||||
|
QPixmap::fromImage(backgroundImage)
|
||||||
|
.scaled(widgetSize, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
|
int x = (widgetSize.width() - scaledPixmap.width()) / 2;
|
||||||
|
int y = (widgetSize.height() - scaledPixmap.height()) / 2;
|
||||||
|
QPixmap finalPixmap(widgetSize);
|
||||||
|
finalPixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&finalPixmap);
|
||||||
|
painter.drawPixmap(x, y, scaledPixmap);
|
||||||
|
palette.setBrush(QPalette::Base, QBrush(finalPixmap));
|
||||||
}
|
}
|
||||||
QColor transparentColor = QColor(135, 206, 235, 40);
|
QColor transparentColor = QColor(135, 206, 235, 40);
|
||||||
palette.setColor(QPalette::Highlight, transparentColor);
|
palette.setColor(QPalette::Highlight, transparentColor);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameListFrame::resizeEvent(QResizeEvent* event) {
|
||||||
|
QTableWidget::resizeEvent(event);
|
||||||
|
RefreshListBackgroundImage();
|
||||||
|
}
|
||||||
|
|
||||||
void GameListFrame::SortNameAscending(int columnIndex) {
|
void GameListFrame::SortNameAscending(int columnIndex) {
|
||||||
std::sort(m_game_info->m_games.begin(), m_game_info->m_games.end(),
|
std::sort(m_game_info->m_games.begin(), m_game_info->m_games.end(),
|
||||||
[columnIndex](const GameInfo& a, const GameInfo& b) {
|
[columnIndex](const GameInfo& a, const GameInfo& b) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ Q_SIGNALS:
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void SetListBackgroundImage(QTableWidgetItem* item);
|
void SetListBackgroundImage(QTableWidgetItem* item);
|
||||||
void RefreshListBackgroundImage();
|
void RefreshListBackgroundImage();
|
||||||
|
void resizeEvent(QResizeEvent* event);
|
||||||
void SortNameAscending(int columnIndex);
|
void SortNameAscending(int columnIndex);
|
||||||
void SortNameDescending(int columnIndex);
|
void SortNameDescending(int columnIndex);
|
||||||
void PlayBackgroundMusic(QTableWidgetItem* item);
|
void PlayBackgroundMusic(QTableWidgetItem* item);
|
||||||
|
|
Loading…
Add table
Reference in a new issue