Set palette globally

This commit is contained in:
Nicolas Werner 2020-03-30 21:48:28 +02:00
parent d35cc3dda4
commit 8bf25f3d80
4 changed files with 90 additions and 37 deletions

View file

@ -32,7 +32,6 @@ UserMentionsWidget > * {
QLineEdit, QLineEdit,
QListWidget, QListWidget,
QToolTip,
WelcomePage, WelcomePage,
LoginPage, LoginPage,
RegisterPage, RegisterPage,
@ -178,12 +177,33 @@ UserInfoWidget {
border-bottom: 1px solid #202228; border-bottom: 1px solid #202228;
} }
#UserSettingScrollWidget > QComboBox { QToolTip,
QPushButton,
QComboBox,
QAbstractItemView,
QMenu,
QComboBox > * {
background: white;
color: #202228; color: #202228;
} }
#UserSettingScrollWidget > QComboBox { QComboBox:hover,
color: #202228; QAbstractItemView::item:hover,
QMenu::item:hover,
QPushButton:hover {
background: #38a3d8;
selection-background-color: #38a3d8;
}
QMenu::item {
border: 1px solid transparent; /* reserve space for selection border */
}
QAbstractItemView::item:selected,
QMenu::item:selected {
border-color: darkblue;
background: grey;
} }
Avatar { Avatar {

View file

@ -184,11 +184,33 @@ TopSection {
WelcomePage, WelcomePage,
LoginPage, LoginPage,
QToolTip, QToolTip,
QComboBox,
QPushButton,
RegisterPage { RegisterPage {
background-color: white; background-color: white;
color: #333; color: #333;
} }
QMenu {
background-color: white;
color: #333;
border: 1px solid darkblue;
}
QComboBox:hover,
QAbstractItemView::item:hover,
QMenu::item:hover,
QPushButton:hover {
background: #38a3d8;
selection-background-color: #38a3d8;
}
QAbstractItemView::item:selected,
QMenu::item:selected {
border-color: darkblue;
background: grey;
}
emoji--Panel, emoji--Panel,
emoji--Panel > * { emoji--Panel > * {
background-color: #eee; background-color: #eee;
@ -222,6 +244,13 @@ TextField {
qproperty-labelColor: #333; qproperty-labelColor: #333;
} }
TextInputWidget,
QTextEdit,
QLineEdit {
background-color: white;
color: #333;
}
TextInputWidget { TextInputWidget {
border: none; border: none;
border-top: 1px solid #dcdcdc; border-top: 1px solid #dcdcdc;

View file

@ -103,12 +103,43 @@ UserSettings::applyTheme()
{ {
QFile stylefile; QFile stylefile;
if (theme() == "light") { static QPalette original;
if (this->theme() == "light") {
stylefile.setFileName(":/styles/styles/nheko.qss"); stylefile.setFileName(":/styles/styles/nheko.qss");
} else if (theme() == "dark") { QPalette lightActive(/*windowText*/ QColor("#333"),
/*button*/ QColor("#333"),
/*light*/ QColor(),
/*dark*/ QColor(220, 220, 220),
/*mid*/ QColor(),
/*text*/ QColor("#333"),
/*bright_text*/ QColor(),
/*base*/ QColor(220, 220, 220),
/*window*/ QColor("white"));
lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color());
lightActive.setColor(QPalette::ToolTipText, lightActive.text().color());
lightActive.setColor(QPalette::Link, QColor("#0077b5"));
lightActive.setColor(QPalette::ButtonText, QColor("gray"));
QApplication::setPalette(lightActive);
} else if (this->theme() == "dark") {
stylefile.setFileName(":/styles/styles/nheko-dark.qss"); stylefile.setFileName(":/styles/styles/nheko-dark.qss");
QPalette darkActive(/*windowText*/ QColor("#caccd1"),
/*button*/ QColor("#caccd1"),
/*light*/ QColor(),
/*dark*/ QColor("#2d3139"),
/*mid*/ QColor(),
/*text*/ QColor("#caccd1"),
/*bright_text*/ QColor(0xff, 0xff, 0xff),
/*base*/ QColor("#2d3139"),
/*window*/ QColor("#202228"));
darkActive.setColor(QPalette::Highlight, QColor("#38a3d8"));
darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color());
darkActive.setColor(QPalette::ToolTipText, darkActive.text().color());
darkActive.setColor(QPalette::Link, QColor("#38a3d8"));
darkActive.setColor(QPalette::ButtonText, QColor("gray"));
QApplication::setPalette(darkActive);
} else { } else {
stylefile.setFileName(":/styles/styles/system.qss"); stylefile.setFileName(":/styles/styles/system.qss");
QApplication::setPalette(original);
} }
stylefile.open(QFile::ReadOnly); stylefile.open(QFile::ReadOnly);

View file

@ -22,38 +22,11 @@ TimelineViewManager::updateColorPalette()
userColors.clear(); userColors.clear();
if (settings->theme() == "light") { if (settings->theme() == "light") {
QPalette lightActive(/*windowText*/ QColor("#333"), view->rootContext()->setContextProperty("currentActivePalette", QPalette());
/*button*/ QColor("#333"), view->rootContext()->setContextProperty("currentInactivePalette", QPalette());
/*light*/ QColor(),
/*dark*/ QColor(220, 220, 220),
/*mid*/ QColor(),
/*text*/ QColor("#333"),
/*bright_text*/ QColor(),
/*base*/ QColor(220, 220, 220),
/*window*/ QColor("white"));
lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color());
lightActive.setColor(QPalette::ToolTipText, lightActive.text().color());
lightActive.setColor(QPalette::Link, QColor("#0077b5"));
lightActive.setColor(QPalette::ButtonText, QColor("gray"));
view->rootContext()->setContextProperty("currentActivePalette", lightActive);
view->rootContext()->setContextProperty("currentInactivePalette", lightActive);
} else if (settings->theme() == "dark") { } else if (settings->theme() == "dark") {
QPalette darkActive(/*windowText*/ QColor("#caccd1"), view->rootContext()->setContextProperty("currentActivePalette", QPalette());
/*button*/ QColor("#caccd1"), view->rootContext()->setContextProperty("currentInactivePalette", QPalette());
/*light*/ QColor(),
/*dark*/ QColor("#2d3139"),
/*mid*/ QColor(),
/*text*/ QColor("#caccd1"),
/*bright_text*/ QColor(0xff, 0xff, 0xff),
/*base*/ QColor("#2d3139"),
/*window*/ QColor("#202228"));
darkActive.setColor(QPalette::Highlight, QColor("#e7e7e9"));
darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color());
darkActive.setColor(QPalette::ToolTipText, darkActive.text().color());
darkActive.setColor(QPalette::Link, QColor("#38a3d8"));
darkActive.setColor(QPalette::ButtonText, QColor("gray"));
view->rootContext()->setContextProperty("currentActivePalette", darkActive);
view->rootContext()->setContextProperty("currentInactivePalette", darkActive);
} else { } else {
view->rootContext()->setContextProperty("currentActivePalette", QPalette()); view->rootContext()->setContextProperty("currentActivePalette", QPalette());
view->rootContext()->setContextProperty("currentInactivePalette", nullptr); view->rootContext()->setContextProperty("currentInactivePalette", nullptr);