|
From: <cn...@us...> - 2022-11-29 01:20:51
|
Revision: 1298
http://sourceforge.net/p/seq/svn/1298
Author: cn187
Date: 2022-11-29 01:20:49 +0000 (Tue, 29 Nov 2022)
Log Message:
-----------
Fixes for dark mode color propagation
Modified Paths:
--------------
showeq/branches/cn187_devel/src/interface.cpp
showeq/branches/cn187_devel/src/interface.h
showeq/branches/cn187_devel/src/spawnlist.cpp
showeq/branches/cn187_devel/src/spawnlist.h
showeq/branches/cn187_devel/src/spawnlist2.cpp
showeq/branches/cn187_devel/src/spawnlist2.h
showeq/branches/cn187_devel/src/spawnlistcommon.cpp
Modified: showeq/branches/cn187_devel/src/interface.cpp
===================================================================
--- showeq/branches/cn187_devel/src/interface.cpp 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/interface.cpp 2022-11-29 01:20:49 UTC (rev 1298)
@@ -5744,11 +5744,14 @@
QStringList availableStyles = QStyleFactory::keys();
- if (!availableStyles.contains(name, Qt::CaseInsensitive))
- return currentStyleName;
+ if (!availableStyles.contains(name, Qt::CaseInsensitive))
+ return currentStyleName;
- qApp->setStyle(QStyleFactory::create(name));
+ qApp->setPalette(OrigPalette);
+ QStyle* newStyle = QStyleFactory::create(name);
+ qApp->setStyle(newStyle);
+
MenuActionList::Iterator iter;
for ( iter = ActionList_StyleMenu.begin(); iter != ActionList_StyleMenu.end(); ++iter)
@@ -5764,6 +5767,8 @@
}
}
+ emit styleChanged();
+
return currentStyleName;
}
@@ -5956,6 +5961,8 @@
connect(this, SIGNAL(restoreFonts(void)),
m_spawnList, SLOT(restoreFont(void)));
+ connect(this, SIGNAL(styleChanged()), m_spawnList, SLOT(styleChanged()));
+
// insert its menu into the window menu
insertWindowMenu(m_spawnList);
}
@@ -5993,6 +6000,8 @@
connect(this, SIGNAL(restoreFonts(void)),
m_spawnList2, SLOT(restoreFont(void)));
+ connect(this, SIGNAL(styleChanged()), m_spawnList2, SLOT(styleChanged()));
+
// insert its menu into the window menu
insertWindowMenu(m_spawnList2);
}
Modified: showeq/branches/cn187_devel/src/interface.h
===================================================================
--- showeq/branches/cn187_devel/src/interface.h 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/interface.h 2022-11-29 01:20:49 UTC (rev 1298)
@@ -237,6 +237,8 @@
void spellMessage(QString&);
void restoreFonts();
+ void styleChanged();
+
// Decoder signals
void theKey(uint64_t);
void backfillPlayer(charProfileStruct *);
Modified: showeq/branches/cn187_devel/src/spawnlist.cpp
===================================================================
--- showeq/branches/cn187_devel/src/spawnlist.cpp 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/spawnlist.cpp 2022-11-29 01:20:49 UTC (rev 1298)
@@ -50,6 +50,7 @@
#include <cmath>
#include <regex.h>
#include <QMenu>
+#include <QApplication>
// ------------------------------------------------------
SpawnList::SpawnList(Player* player,
@@ -1106,6 +1107,29 @@
}
}
+void SpawnList::styleChanged()
+{
+ QColor fg = qApp->palette().color(QPalette::WindowText);
+
+ SEQListViewItemIterator it(this);
+ while (*it)
+ {
+ SpawnListItem* litem = (SpawnListItem*)*it;
+ litem->pickTextColor(litem->item(), m_player, fg);
+ ++it;
+ }
+
+ //go back and do the categories, so we keep their configured colors
+ QHash<void*, SpawnListItem*>::iterator cit;
+ for (cit = m_categoryListItems.begin(); cit != m_categoryListItems.end(); ++cit)
+ {
+ Category* cat = (Category*)cit.key();
+ SpawnListItem* litem = (SpawnListItem*)cit.value();
+ fg = cat->color();
+ litem->pickTextColor(litem->item(), m_player, fg);
+ }
+}
+
QString SpawnList::filterString(const Item* item, int flags)
{
if (item == NULL)
Modified: showeq/branches/cn187_devel/src/spawnlist.h
===================================================================
--- showeq/branches/cn187_devel/src/spawnlist.h 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/spawnlist.h 2022-11-29 01:20:49 UTC (rev 1298)
@@ -116,10 +116,12 @@
void delCategory(const Category* cat);
void clearedCategories(void);
void loadedCategories(void);
-
+
void rebuildSpawnList();
void playerLevelChanged(uint8_t);
-
+
+ void styleChanged();
+
private slots:
void selChanged();
@@ -138,6 +140,7 @@
Player *m_player;
SpawnShell* m_spawnShell;
+private:
// category pointer used as keys to look up the associated SpawnListItem
QHash<void*, SpawnListItem*> m_categoryListItems;
@@ -158,11 +161,13 @@
virtual QMenu* menu();
SpawnList* spawnList() { return m_spawnList; }
+ protected:
+ SpawnList* m_spawnList;
+
public slots:
virtual void savePrefs(void);
+ void styleChanged() { m_spawnList->styleChanged(); }
- protected:
- SpawnList* m_spawnList;
};
#endif // SPAWNLIST_H
Modified: showeq/branches/cn187_devel/src/spawnlist2.cpp
===================================================================
--- showeq/branches/cn187_devel/src/spawnlist2.cpp 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/spawnlist2.cpp 2022-11-29 01:20:49 UTC (rev 1298)
@@ -1017,6 +1017,22 @@
#endif
}
+void SpawnListWindow2::styleChanged()
+{
+ SEQListViewItemIterator it(m_spawnList);
+
+ QColor fg = palette().color(QPalette::WindowText);
+
+ while (*it)
+ {
+ SpawnListItem* litem = (SpawnListItem*)*it;
+ litem->pickTextColor(litem->item(), m_player, fg);
+
+ ++it;
+ }
+}
+
+
#ifndef QMAKEBUILD
#include "spawnlist2.moc"
#endif
Modified: showeq/branches/cn187_devel/src/spawnlist2.h
===================================================================
--- showeq/branches/cn187_devel/src/spawnlist2.h 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/spawnlist2.h 2022-11-29 01:20:49 UTC (rev 1298)
@@ -91,6 +91,10 @@
void rebuildSpawnList(void);
void refresh(void);
virtual void savePrefs(void);
+
+
+ void styleChanged();
+
private slots:
// category combo box signals
void categorySelected(int index);
Modified: showeq/branches/cn187_devel/src/spawnlistcommon.cpp
===================================================================
--- showeq/branches/cn187_devel/src/spawnlistcommon.cpp 2022-11-27 23:36:11 UTC (rev 1297)
+++ showeq/branches/cn187_devel/src/spawnlistcommon.cpp 2022-11-29 01:20:49 UTC (rev 1298)
@@ -38,6 +38,7 @@
#include <cstring>
+#include <QApplication>
#include <QFontDialog>
#include <QInputDialog>
#include <QMessageBox>
@@ -47,7 +48,8 @@
SpawnListItem::SpawnListItem(SEQListViewItem *parent) : SEQListViewItem(parent)
{
- m_textColor = Qt::black;
+ m_textColor = qApp->palette().color(QPalette::WindowText);
+
m_item = NULL;
m_npc = 0;
}
@@ -54,7 +56,8 @@
SpawnListItem::SpawnListItem(SEQListView *parent) : SEQListViewItem(parent)
{
- m_textColor = Qt::black;
+ m_textColor = qApp->palette().color(QPalette::WindowText);
+
m_item = NULL;
m_npc = 0;
}
@@ -352,12 +355,22 @@
Player* player,
QColor def)
{
+
+ QColor fg = qApp->palette().color(QPalette::WindowText);
+ QColor bg = qApp->palette().color(QPalette::Base);
+
+ //Black is the parameter default, so if it's black, we should use the
+ //foreground color instead. That way we won't wind up with black text by
+ //default when using dark themesf
+ if (def == Qt::black)
+ def = fg;
+
if (item == NULL)
{
m_textColor = def;
return;
}
-
+
const Spawn* spawn = NULL;
if ((item->type() == tSpawn) || (item->type() == tPlayer))
spawn = (const Spawn*)item;
@@ -367,7 +380,7 @@
m_textColor = def;
return;
}
-
+
switch (spawn->typeflag())
{
case 65:
@@ -417,8 +430,8 @@
// color by consider difficulty
m_textColor = player->pickConColor(spawn->level());
- if (m_textColor == Qt::white)
- m_textColor = Qt::black;
+ if (m_textColor == Qt::white || m_textColor == Qt::black)
+ m_textColor = def;
if (m_textColor == Qt::yellow)
m_textColor = QColor(206,151,33);
} // end pickTextColor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|