Set palette globally

master
Nicolas Werner 5 years ago
parent d35cc3dda4
commit 8bf25f3d80
  1. 28
      resources/styles/nheko-dark.qss
  2. 29
      resources/styles/nheko.qss
  3. 35
      src/UserSettingsPage.cpp
  4. 35
      src/timeline/TimelineViewManager.cpp

@ -32,7 +32,6 @@ UserMentionsWidget > * {
QLineEdit,
QListWidget,
QToolTip,
WelcomePage,
LoginPage,
RegisterPage,
@ -178,12 +177,33 @@ UserInfoWidget {
border-bottom: 1px solid #202228;
}
#UserSettingScrollWidget > QComboBox {
QToolTip,
QPushButton,
QComboBox,
QAbstractItemView,
QMenu,
QComboBox > * {
background: white;
color: #202228;
}
#UserSettingScrollWidget > QComboBox {
color: #202228;
QComboBox:hover,
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 {

@ -184,11 +184,33 @@ TopSection {
WelcomePage,
LoginPage,
QToolTip,
QComboBox,
QPushButton,
RegisterPage {
background-color: white;
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 > * {
background-color: #eee;
@ -222,6 +244,13 @@ TextField {
qproperty-labelColor: #333;
}
TextInputWidget,
QTextEdit,
QLineEdit {
background-color: white;
color: #333;
}
TextInputWidget {
border: none;
border-top: 1px solid #dcdcdc;

@ -103,12 +103,43 @@ UserSettings::applyTheme()
{
QFile stylefile;
if (theme() == "light") {
static QPalette original;
if (this->theme() == "light") {
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");
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 {
stylefile.setFileName(":/styles/styles/system.qss");
QApplication::setPalette(original);
}
stylefile.open(QFile::ReadOnly);

@ -22,38 +22,11 @@ TimelineViewManager::updateColorPalette()
userColors.clear();
if (settings->theme() == "light") {
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"));
view->rootContext()->setContextProperty("currentActivePalette", lightActive);
view->rootContext()->setContextProperty("currentInactivePalette", lightActive);
view->rootContext()->setContextProperty("currentActivePalette", QPalette());
view->rootContext()->setContextProperty("currentInactivePalette", QPalette());
} else if (settings->theme() == "dark") {
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("#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);
view->rootContext()->setContextProperty("currentActivePalette", QPalette());
view->rootContext()->setContextProperty("currentInactivePalette", QPalette());
} else {
view->rootContext()->setContextProperty("currentActivePalette", QPalette());
view->rootContext()->setContextProperty("currentInactivePalette", nullptr);

Loading…
Cancel
Save