DolphinQt: Adjust panel-specific colors and syntax highlighting for dark theme.

This commit is contained in:
Admiral H. Curtiss
2023-08-01 20:47:17 +02:00
parent c2e29153e9
commit 24012cfc7f
8 changed files with 97 additions and 28 deletions

View File

@ -612,6 +612,8 @@ void SkylanderPortalWindow::UpdateCurrentIDs()
void SkylanderPortalWindow::RefreshList()
{
const bool is_dark_theme = Settings::Instance().IsThemeDark();
const int row = m_skylander_list->currentRow();
m_skylander_list->clear();
if (m_only_show_collection->isChecked())
@ -635,8 +637,16 @@ void SkylanderPortalWindow::RefreshList()
{
const uint qvar = (ids.first << 16) | ids.second;
QListWidgetItem* skylander = new QListWidgetItem(file.baseName());
skylander->setBackground(GetBaseColor(ids));
skylander->setForeground(QBrush(QColor(0, 0, 0, 255)));
if (is_dark_theme)
{
skylander->setBackground(GetBaseColor(ids, true));
skylander->setForeground(QBrush(QColor(220, 220, 220)));
}
else
{
skylander->setBackground(GetBaseColor(ids, false));
skylander->setForeground(QBrush(QColor(0, 0, 0)));
}
skylander->setData(1, qvar);
m_skylander_list->addItem(skylander);
}
@ -652,8 +662,16 @@ void SkylanderPortalWindow::RefreshList()
{
const uint qvar = (entry.first.first << 16) | entry.first.second;
QListWidgetItem* skylander = new QListWidgetItem(tr(entry.second.name));
skylander->setBackground(GetBaseColor(entry.first));
skylander->setForeground(QBrush(QColor(0, 0, 0, 255)));
if (is_dark_theme)
{
skylander->setBackground(GetBaseColor(entry.first, true));
skylander->setForeground(QBrush(QColor(220, 220, 220)));
}
else
{
skylander->setBackground(GetBaseColor(entry.first, false));
skylander->setForeground(QBrush(QColor(0, 0, 0)));
}
skylander->setData(1, qvar);
m_skylander_list->addItem(skylander);
}
@ -897,27 +915,27 @@ int SkylanderPortalWindow::GetElementRadio()
return -1;
}
QBrush SkylanderPortalWindow::GetBaseColor(std::pair<const u16, const u16> ids)
QBrush SkylanderPortalWindow::GetBaseColor(std::pair<const u16, const u16> ids, bool dark_theme)
{
auto skylander = IOS::HLE::USB::list_skylanders.find(ids);
if (skylander == IOS::HLE::USB::list_skylanders.end())
return QBrush(QColor(255, 255, 255, 255));
return QBrush(dark_theme ? QColor(32, 32, 32) : QColor(255, 255, 255));
switch ((*skylander).second.game)
{
case IOS::HLE::USB::Game::SpyrosAdv:
return QBrush(QColor(240, 255, 240, 255));
return QBrush(dark_theme ? QColor(10, 42, 90) : QColor(240, 255, 240));
case IOS::HLE::USB::Game::Giants:
return QBrush(QColor(255, 240, 215, 255));
return QBrush(dark_theme ? QColor(120, 16, 12) : QColor(255, 240, 215));
case IOS::HLE::USB::Game::SwapForce:
return QBrush(QColor(240, 245, 255, 255));
return QBrush(dark_theme ? QColor(28, 45, 12) : QColor(240, 245, 255));
case IOS::HLE::USB::Game::TrapTeam:
return QBrush(QColor(255, 240, 240, 255));
return QBrush(dark_theme ? QColor(0, 56, 76) : QColor(255, 240, 240));
case IOS::HLE::USB::Game::Superchargers:
return QBrush(QColor(247, 228, 215, 255));
return QBrush(dark_theme ? QColor(90, 12, 12) : QColor(247, 228, 215));
default:
return QBrush(QColor(255, 255, 255, 255));
return QBrush(dark_theme ? QColor(32, 32, 32) : QColor(255, 255, 255));
}
}

View File

@ -37,6 +37,8 @@ public:
explicit SkylanderPortalWindow(QWidget* parent = nullptr);
~SkylanderPortalWindow() override;
void RefreshList();
protected:
std::array<QLineEdit*, MAX_SKYLANDERS> m_edit_skylanders;
std::array<std::optional<Skylander>, MAX_SKYLANDERS> m_sky_slots;
@ -60,7 +62,6 @@ private:
// Behind the scenes
void OnEmulationStateChanged(Core::State state);
void OnCollectionPathChanged();
void RefreshList();
void UpdateCurrentIDs();
void CreateSkyfile(const QString& path, bool load_after);
void LoadSkyfilePath(u8 slot, const QString& path);
@ -71,7 +72,7 @@ private:
QString GetFilePath(u16 id, u16 var);
u8 GetCurrentSlot();
int GetElementRadio();
QBrush GetBaseColor(std::pair<const u16, const u16> ids);
QBrush GetBaseColor(std::pair<const u16, const u16> ids, bool dark_theme);
int GetGameID(IOS::HLE::USB::Game game);
int GetElementID(IOS::HLE::USB::Element elem);