Qt: Use memory card icon as window icon
This commit is contained in:
parent
9143116616
commit
addadbabc6
|
@ -249,7 +249,7 @@ QString GameListModel::formatTimespan(time_t timespan)
|
||||||
return qApp->translate("GameList", "%n minutes", "", minutes);
|
return qApp->translate("GameList", "%n minutes", "", minutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap& GameListModel::getIconForEntry(const GameList::Entry* ge) const
|
const QPixmap& GameListModel::getPixmapForEntry(const GameList::Entry* ge) const
|
||||||
{
|
{
|
||||||
// We only do this for discs/disc sets for now.
|
// We only do this for discs/disc sets for now.
|
||||||
if (m_show_game_icons && (!ge->serial.empty() && (ge->IsDisc() || ge->IsDiscSet())))
|
if (m_show_game_icons && (!ge->serial.empty() && (ge->IsDisc() || ge->IsDiscSet())))
|
||||||
|
@ -274,6 +274,30 @@ const QPixmap& GameListModel::getIconForEntry(const GameList::Entry* ge) const
|
||||||
return m_type_pixmaps[static_cast<u32>(ge->type)];
|
return m_type_pixmaps[static_cast<u32>(ge->type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon GameListModel::getIconForGame(const QString& path)
|
||||||
|
{
|
||||||
|
QIcon ret;
|
||||||
|
|
||||||
|
if (m_show_game_icons)
|
||||||
|
{
|
||||||
|
const auto lock = GameList::GetLock();
|
||||||
|
const GameList::Entry* entry = GameList::GetEntryForPath(path.toStdString());
|
||||||
|
|
||||||
|
// See above.
|
||||||
|
if (entry && !entry->serial.empty() && (entry->IsDisc() || entry->IsDiscSet()))
|
||||||
|
{
|
||||||
|
const MemoryCardImage::IconFrame* icon = m_memcard_icon_cache.Lookup(entry->serial, entry->path);
|
||||||
|
if (icon)
|
||||||
|
{
|
||||||
|
ret = QIcon(QPixmap::fromImage(QImage(reinterpret_cast<const uchar*>(icon->pixels), MemoryCardImage::ICON_WIDTH,
|
||||||
|
MemoryCardImage::ICON_HEIGHT, QImage::Format_RGBA8888)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int GameListModel::getCoverArtWidth() const
|
int GameListModel::getCoverArtWidth() const
|
||||||
{
|
{
|
||||||
return std::max(static_cast<int>(static_cast<float>(COVER_ART_WIDTH) * m_cover_scale), 1);
|
return std::max(static_cast<int>(static_cast<float>(COVER_ART_WIDTH) * m_cover_scale), 1);
|
||||||
|
@ -457,7 +481,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
case Column_Type:
|
case Column_Type:
|
||||||
{
|
{
|
||||||
return getIconForEntry(ge);
|
return getPixmapForEntry(ge);
|
||||||
}
|
}
|
||||||
|
|
||||||
case Column_Region:
|
case Column_Region:
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
|
|
||||||
bool getShowGameIcons() const { return m_show_game_icons; }
|
bool getShowGameIcons() const { return m_show_game_icons; }
|
||||||
void setShowGameIcons(bool enabled);
|
void setShowGameIcons(bool enabled);
|
||||||
|
QIcon getIconForGame(const QString& path);
|
||||||
|
|
||||||
float getCoverScale() const { return m_cover_scale; }
|
float getCoverScale() const { return m_cover_scale; }
|
||||||
void setCoverScale(float scale);
|
void setCoverScale(float scale);
|
||||||
|
@ -88,7 +89,7 @@ private:
|
||||||
void loadOrGenerateCover(const GameList::Entry* ge);
|
void loadOrGenerateCover(const GameList::Entry* ge);
|
||||||
void invalidateCoverForPath(const std::string& path);
|
void invalidateCoverForPath(const std::string& path);
|
||||||
|
|
||||||
const QPixmap& getIconForEntry(const GameList::Entry* ge) const;
|
const QPixmap& getPixmapForEntry(const GameList::Entry* ge) const;
|
||||||
|
|
||||||
static QString formatTimespan(time_t timespan);
|
static QString formatTimespan(time_t timespan);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "coverdownloaddialog.h"
|
#include "coverdownloaddialog.h"
|
||||||
#include "debuggerwindow.h"
|
#include "debuggerwindow.h"
|
||||||
#include "displaywidget.h"
|
#include "displaywidget.h"
|
||||||
|
#include "gamelistmodel.h"
|
||||||
#include "gamelistsettingswidget.h"
|
#include "gamelistsettingswidget.h"
|
||||||
#include "gamelistwidget.h"
|
#include "gamelistwidget.h"
|
||||||
#include "interfacesettingswidget.h"
|
#include "interfacesettingswidget.h"
|
||||||
|
@ -90,6 +91,7 @@ static bool s_system_paused = false;
|
||||||
static QString s_current_game_title;
|
static QString s_current_game_title;
|
||||||
static QString s_current_game_serial;
|
static QString s_current_game_serial;
|
||||||
static QString s_current_game_path;
|
static QString s_current_game_path;
|
||||||
|
static QIcon s_current_game_icon;
|
||||||
|
|
||||||
bool QtHost::IsSystemPaused()
|
bool QtHost::IsSystemPaused()
|
||||||
{
|
{
|
||||||
|
@ -615,6 +617,7 @@ void MainWindow::onRunningGameChanged(const QString& filename, const QString& ga
|
||||||
s_current_game_path = filename;
|
s_current_game_path = filename;
|
||||||
s_current_game_title = game_title;
|
s_current_game_title = game_title;
|
||||||
s_current_game_serial = game_serial;
|
s_current_game_serial = game_serial;
|
||||||
|
s_current_game_icon = m_game_list_widget->getModel()->getIconForGame(filename);
|
||||||
|
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
}
|
}
|
||||||
|
@ -1883,6 +1886,7 @@ void MainWindow::updateWindowTitle()
|
||||||
|
|
||||||
if (windowTitle() != main_title)
|
if (windowTitle() != main_title)
|
||||||
setWindowTitle(main_title);
|
setWindowTitle(main_title);
|
||||||
|
setWindowIcon(s_current_game_icon.isNull() ? QtHost::GetAppIcon() : s_current_game_icon);
|
||||||
|
|
||||||
if (m_display_widget && !isRenderingToMain())
|
if (m_display_widget && !isRenderingToMain())
|
||||||
{
|
{
|
||||||
|
@ -1890,6 +1894,7 @@ void MainWindow::updateWindowTitle()
|
||||||
m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget);
|
m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget);
|
||||||
if (container->windowTitle() != display_title)
|
if (container->windowTitle() != display_title)
|
||||||
container->setWindowTitle(display_title);
|
container->setWindowTitle(display_title);
|
||||||
|
container->setWindowIcon(s_current_game_icon.isNull() ? QtHost::GetAppIcon() : s_current_game_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_log_window)
|
if (g_log_window)
|
||||||
|
|
Loading…
Reference in New Issue