Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect Theme in Input Completion & Quick Switcher #4671

Merged
merged 9 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 0 additions & 15 deletions src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
65 changes: 51 additions & 14 deletions src/widgets/listview/GenericListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 QString selCol =
(theme.isLightTheme()
? "#68B1FF" // Copied from Theme::splits.input.styleSheet
: 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);
const auto textCol = theme.window.text.name(QColor::HexArgb);

auto accentColor = theme.accent;
accentColor.setAlpha(100);
const auto selCol = accentColor.name(QColor::HexArgb);

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);
}
Expand Down
9 changes: 9 additions & 0 deletions src/widgets/splits/InputCompletionPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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};
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/splits/InputCompletionPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class InputCompletionPopup : public BasePopup
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;

void themeChangedEvent() override;

private:
void initLayout();

Expand Down