Respect Theme in Input Completion & Quick Switcher (#4671)

This commit is contained in:
nerix 2023-06-10 14:38:23 +02:00 committed by GitHub
parent 65a14fb95b
commit 839ba60fd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 27 deletions

View file

@ -6,6 +6,7 @@
- Minor: Add an icon showing when streamer mode is enabled (#4410)
- Minor: Added `/shoutout <username>` commands to shoutout specified user. (#4638)
- Minor: Improved editing hotkeys. (#4628)
- Minor: The input completion and quick switcher are now styled to match your theme. (#4671)
- Bugfix: Fixed generation of crashdumps by the browser-extension process when the browser was closed. (#4667)
- Bugfix: Fixed a crash when opening and closing a reply thread and switching the user. (#4675)
- Dev: Added command to set Qt's logging filter/rules at runtime (`/c2-set-logging-rules`). (#4637)

View file

@ -143,21 +143,6 @@ void QuickSwitcherPopup::themeChangedEvent()
{
BasePopup::themeChangedEvent();
const QString textCol = this->theme->window.text.name();
const QString bgCol = this->theme->window.background.name();
const QString selCol =
(this->theme->isLightTheme()
? "#68B1FF" // Copied from Theme::splits.input.styleSheet
: this->theme->tabs.selected.backgrounds.regular.name());
const QString listStyle =
QString(
"color: %1; background-color: %2; selection-background-color: %3")
.arg(textCol)
.arg(bgCol)
.arg(selCol);
this->ui_.searchEdit->setStyleSheet(this->theme->splits.input.styleSheet);
this->ui_.list->refreshTheme(*this->theme);
}

View file

@ -103,20 +103,57 @@ bool GenericListView::eventFilter(QObject * /*watched*/, QEvent *event)
void GenericListView::refreshTheme(const Theme &theme)
{
const QString textCol = theme.window.text.name();
const QString bgCol = theme.window.background.name();
const auto textCol = theme.window.text.name(QColor::HexArgb);
const QString selCol =
(theme.isLightTheme()
? "#68B1FF" // Copied from Theme::splits.input.styleSheet
: theme.tabs.selected.backgrounds.regular.name());
auto accentColor = theme.accent;
accentColor.setAlpha(100);
const auto selCol = accentColor.name(QColor::HexArgb);
const QString listStyle =
QString(
"color: %1; background-color: %2; selection-background-color: %3")
.arg(textCol)
.arg(bgCol)
.arg(selCol);
const auto listStyle = QStringLiteral(R"(
QListView {
border: none;
color: %1;
background: transparent;
selection-background-color: %2;
}
QAbstractScrollArea::corner {
border: none;
}
QScrollBar {
background: transparent;
}
QScrollBar:vertical {
margin-left: 4;
}
QScrollBar:horizontal {
margin-top: 4;
}
QScrollBar::add-line,
QScrollBar::sub-line,
QScrollBar::left-arrow,
QScrollBar::right-arrow,
QScrollBar::down-arrow,
QScrollBar::up-arrow {
width: 0;
height: 0;
}
QScrollBar::handle {
background: %2;
border-radius: 4;
}
QScrollBar::handle:vertical {
min-height: 8;
width: 8;
}
QScrollBar::handle:horizontal {
min-width: 8;
height: 8;
})")
.arg(textCol, selCol);
this->setStyleSheet(listStyle);
}

View file

@ -10,6 +10,7 @@
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/listview/GenericListView.hpp"
#include "widgets/splits/InputCompletionItem.hpp"
@ -141,6 +142,7 @@ InputCompletionPopup::InputCompletionPopup(QWidget *parent)
, model_(this)
{
this->initLayout();
this->themeChangedEvent();
QObject::connect(&this->redrawTimer_, &QTimer::timeout, this, [this] {
if (this->isVisible())
@ -227,6 +229,13 @@ void InputCompletionPopup::hideEvent(QHideEvent * /*event*/)
this->redrawTimer_.stop();
}
void InputCompletionPopup::themeChangedEvent()
{
BasePopup::themeChangedEvent();
this->ui_.listView->refreshTheme(*getTheme());
}
void InputCompletionPopup::initLayout()
{
LayoutCreator creator = {this};

View file

@ -50,6 +50,8 @@ protected:
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
void themeChangedEvent() override;
private:
void initLayout();