Merge pull request #79 from karora/dark_theme_is_usable

Dark theme is usable
This commit is contained in:
Sirius Bakke 2021-01-03 23:45:06 +01:00 committed by GitHub
commit 234035b706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 5 deletions

View File

@ -957,13 +957,25 @@ void ProjectPanel::loadStandardObjects()
objdb->load( Constants::getStandardObjectsFilePath(),
&upgrade_predicate, Constants::getDTDDirectory());
objdb->setFileName("");
if ( qGray(palette().color(QPalette::Window).rgba()) < 100) {
FWObject *stdLib = objdb->findObjectByName(Library::TYPENAME, "Standard");
stdLib->setReadOnly(false);
stdLib->setStr("color", "#0a0f1f");
objdb->setDirty(false);
}
if (fwbdebug) qDebug("ProjectPanel::load(): create User library");
FWObject *userLib = FWBTree().createNewLibrary(objdb);
userLib->setName("User");
userLib->setStr("color","#d2ffd0");
if ( qGray(palette().color(QPalette::Window).rgba()) < 100) {
// Window is using a dark palette, so we default to a very dark green for background
userLib->setStr("color","#0a1f08");
} else {
// Window is using a light palette, so we default to a light green background
userLib->setStr("color","#d2ffd0");
}
objdb->setDirty(false);
objdb->setFileName("");
@ -1036,6 +1048,12 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
objdb->load( Constants::getStandardObjectsFilePath(),
&upgrade_predicate, Constants::getDTDDirectory());
objdb->setFileName("");
if ( qGray(palette().color(QPalette::Window).rgba()) < 100) {
FWObject *stdLib = objdb->findObjectByName(Library::TYPENAME, "Standard");
stdLib->setReadOnly(false);
stdLib->setStr("color", "#0a0f1f");
objdb->setDirty(false);
}
// objects from a data file are in database ndb

View File

@ -167,7 +167,12 @@ void RuleSetView::init()
* RuleSetViewDelegate when I paint individual cells.
*/
QPalette updated_palette = palette();
updated_palette.setColor(QPalette::Highlight, QColor("silver"));
if ( qGray(updated_palette.color(QPalette::Window).rgba()) < 100) {
// Window is using a dark palette, so we just lighten a little for the highlight
updated_palette.setColor(QPalette::Highlight, updated_palette.color(QPalette::Window).lighter(150));
} else {
updated_palette.setColor(QPalette::Highlight, QColor("silver"));
}
setPalette(updated_palette);

View File

@ -308,14 +308,21 @@ void setDisabledPalette(QWidget *w)
{
QPalette pal=w->palette();
pal.setCurrentColorGroup( QPalette::Normal );
QColor textColor = Qt::black;
if ( qGray(pal.color(QPalette::Window).rgba()) < 100) {
textColor = Qt::white;
}
pal.setCurrentColorGroup( QPalette::Active );
pal.setColor( QPalette::Text, Qt::black );
pal.setColor( QPalette::Text, textColor );
pal.setCurrentColorGroup( QPalette::Inactive );
pal.setColor( QPalette::Text, Qt::black );
pal.setColor( QPalette::Text, textColor );
pal.setCurrentColorGroup( QPalette::Disabled );
pal.setColor( QPalette::Text, Qt::black );
pal.setColor( QPalette::Text, textColor );
w->setPalette( pal );
}