Change header color when split is active

Colors might need to change but they work for now

Fix #495
This commit is contained in:
Rasmus Karlsson 2018-06-23 11:54:00 +00:00
parent 5ae671dc14
commit b2f454aca4
8 changed files with 24 additions and 4 deletions

View file

@ -72,7 +72,6 @@ std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
TwitchChannel *channel = new TwitchChannel(channelName, this->getReadConnection()); TwitchChannel *channel = new TwitchChannel(channelName, this->getReadConnection());
channel->sendMessageSignal.connect([this, channel](auto chan, auto msg, bool &sent) { channel->sendMessageSignal.connect([this, channel](auto chan, auto msg, bool &sent) {
{ {
std::lock_guard<std::mutex> guard(this->lastMessageMutex); std::lock_guard<std::mutex> guard(this->lastMessageMutex);

View file

@ -32,8 +32,6 @@ ThemeManager::ThemeManager()
: themeName("/appearance/theme/name", "Dark") : themeName("/appearance/theme/name", "Dark")
, themeHue("/appearance/theme/hue", 0.0) , themeHue("/appearance/theme/hue", 0.0)
{ {
qDebug() << "init ThemeManager";
this->update(); this->update();
this->themeName.connectSimple([this](auto) { this->update(); }, false); this->themeName.connectSimple([this](auto) { this->update(); }, false);
@ -168,6 +166,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9); this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9);
this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85); this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85);
this->splits.header.text = this->messages.textColors.regular; this->splits.header.text = this->messages.textColors.regular;
this->splits.header.activeText = isLight ? QColor(134, 79, 242) : QColor(242, 209, 79);
this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95); this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95);
this->splits.input.border = getColor(0, sat, flat ? 1 : 1); this->splits.input.border = getColor(0, sat, flat ? 1 : 1);

View file

@ -70,6 +70,7 @@ public:
QColor border; QColor border;
QColor background; QColor background;
QColor text; QColor text;
QColor activeText;
// int margin; // int margin;
} header; } header;

View file

@ -146,6 +146,15 @@ void ResizingTextEdit::focusInEvent(QFocusEvent *event)
} }
} }
void ResizingTextEdit::focusOutEvent(QFocusEvent *event)
{
QTextEdit::focusOutEvent(event);
if (event->lostFocus()) {
this->focusLost.invoke();
}
}
void ResizingTextEdit::setCompleter(QCompleter *c) void ResizingTextEdit::setCompleter(QCompleter *c)
{ {
if (this->completer) { if (this->completer) {

View file

@ -16,6 +16,7 @@ public:
pajlada::Signals::Signal<QKeyEvent *> keyPressed; pajlada::Signals::Signal<QKeyEvent *> keyPressed;
pajlada::Signals::NoArgSignal focused; pajlada::Signals::NoArgSignal focused;
pajlada::Signals::NoArgSignal focusLost;
void setCompleter(QCompleter *c); void setCompleter(QCompleter *c);
QCompleter *getCompleter() const; QCompleter *getCompleter() const;
@ -25,6 +26,7 @@ protected:
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
void focusInEvent(QFocusEvent *event) override; void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
private: private:
QCompleter *completer = nullptr; QCompleter *completer = nullptr;

View file

@ -30,6 +30,9 @@ SplitHeader::SplitHeader(Split *_split)
: BaseWidget(_split) : BaseWidget(_split)
, split(_split) , split(_split)
{ {
this->split->focused.connect([this]() { this->themeRefreshEvent(); });
this->split->focusLost.connect([this]() { this->themeRefreshEvent(); });
auto app = getApp(); auto app = getApp();
util::LayoutCreator<SplitHeader> layoutCreator(this); util::LayoutCreator<SplitHeader> layoutCreator(this);
@ -370,7 +373,12 @@ void SplitHeader::rightButtonClicked()
void SplitHeader::themeRefreshEvent() void SplitHeader::themeRefreshEvent()
{ {
QPalette palette; QPalette palette;
if (this->split->hasFocus()) {
palette.setColor(QPalette::Foreground, this->themeManager->splits.header.activeText);
} else {
palette.setColor(QPalette::Foreground, this->themeManager->splits.header.text); palette.setColor(QPalette::Foreground, this->themeManager->splits.header.text);
}
// this->dropdownButton->setPalette(palette); // this->dropdownButton->setPalette(palette);
this->titleLabel->setPalette(palette); this->titleLabel->setPalette(palette);

View file

@ -143,6 +143,7 @@ Split::Split(QWidget *parent)
}); });
this->input.ui_.textEdit->focused.connect([this] { this->focused.invoke(); }); this->input.ui_.textEdit->focused.connect([this] { this->focused.invoke(); });
this->input.ui_.textEdit->focusLost.connect([this] { this->focusLost.invoke(); });
} }
Split::~Split() Split::~Split()

View file

@ -47,6 +47,7 @@ public:
pajlada::Signals::NoArgSignal channelChanged; pajlada::Signals::NoArgSignal channelChanged;
pajlada::Signals::NoArgSignal focused; pajlada::Signals::NoArgSignal focused;
pajlada::Signals::NoArgSignal focusLost;
ChannelView &getChannelView(); ChannelView &getChannelView();
SplitContainer *getContainer(); SplitContainer *getContainer();