mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
refactored BaseWidget
This commit is contained in:
parent
741c1f7820
commit
b639604a47
31 changed files with 121 additions and 134 deletions
|
@ -17,18 +17,19 @@ namespace chatterino {
|
|||
BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
|
||||
: QWidget(parent, f)
|
||||
{
|
||||
this->init();
|
||||
}
|
||||
this->theme = getApp()->themes;
|
||||
|
||||
BaseWidget::~BaseWidget()
|
||||
{
|
||||
this->themeConnection.disconnect();
|
||||
this->signalHolder_.managedConnect(this->theme->updated, [this]() {
|
||||
this->themeChangedEvent();
|
||||
|
||||
this->update();
|
||||
});
|
||||
}
|
||||
|
||||
float BaseWidget::getScale() const
|
||||
{
|
||||
if (this->overrideScale) {
|
||||
return this->overrideScale.get();
|
||||
if (this->overrideScale_) {
|
||||
return this->overrideScale_.get();
|
||||
}
|
||||
|
||||
BaseWidget *baseWidget = dynamic_cast<BaseWidget *>(this->window());
|
||||
|
@ -37,33 +38,44 @@ float BaseWidget::getScale() const
|
|||
return 1.f;
|
||||
}
|
||||
|
||||
return baseWidget->scale;
|
||||
return baseWidget->scale_;
|
||||
}
|
||||
|
||||
void BaseWidget::setScale(float value)
|
||||
{
|
||||
// update scale value
|
||||
this->scale_ = value;
|
||||
|
||||
this->scaleChangedEvent(this->getScale());
|
||||
this->scaleChanged.invoke(this->getScale());
|
||||
|
||||
this->setScaleIndependantSize(this->getScaleIndependantSize());
|
||||
}
|
||||
|
||||
void BaseWidget::setOverrideScale(boost::optional<float> value)
|
||||
{
|
||||
this->overrideScale = value;
|
||||
this->overrideScale_ = value;
|
||||
this->setScale(this->getScale());
|
||||
}
|
||||
|
||||
boost::optional<float> BaseWidget::getOverrideScale() const
|
||||
{
|
||||
return this->overrideScale;
|
||||
return this->overrideScale_;
|
||||
}
|
||||
|
||||
QSize BaseWidget::getScaleIndependantSize() const
|
||||
{
|
||||
return this->scaleIndependantSize;
|
||||
return this->scaleIndependantSize_;
|
||||
}
|
||||
|
||||
int BaseWidget::getScaleIndependantWidth() const
|
||||
{
|
||||
return this->scaleIndependantSize.width();
|
||||
return this->scaleIndependantSize_.width();
|
||||
}
|
||||
|
||||
int BaseWidget::getScaleIndependantHeight() const
|
||||
{
|
||||
return this->scaleIndependantSize.height();
|
||||
return this->scaleIndependantSize_.height();
|
||||
}
|
||||
|
||||
void BaseWidget::setScaleIndependantSize(int width, int height)
|
||||
|
@ -73,7 +85,7 @@ void BaseWidget::setScaleIndependantSize(int width, int height)
|
|||
|
||||
void BaseWidget::setScaleIndependantSize(QSize size)
|
||||
{
|
||||
this->scaleIndependantSize = size;
|
||||
this->scaleIndependantSize_ = size;
|
||||
|
||||
if (size.width() > 0) {
|
||||
this->setFixedWidth((int)(size.width() * this->getScale()));
|
||||
|
@ -85,24 +97,12 @@ void BaseWidget::setScaleIndependantSize(QSize size)
|
|||
|
||||
void BaseWidget::setScaleIndependantWidth(int value)
|
||||
{
|
||||
this->setScaleIndependantSize(QSize(value, this->scaleIndependantSize.height()));
|
||||
this->setScaleIndependantSize(QSize(value, this->scaleIndependantSize_.height()));
|
||||
}
|
||||
|
||||
void BaseWidget::setScaleIndependantHeight(int value)
|
||||
{
|
||||
this->setScaleIndependantSize(QSize(this->scaleIndependantSize.height(), value));
|
||||
}
|
||||
|
||||
void BaseWidget::init()
|
||||
{
|
||||
auto app = getApp();
|
||||
this->themeManager = app->themes;
|
||||
|
||||
this->themeConnection = this->themeManager->updated.connect([this]() {
|
||||
this->themeRefreshEvent();
|
||||
|
||||
this->update();
|
||||
});
|
||||
this->setScaleIndependantSize(QSize(this->scaleIndependantSize_.height(), value));
|
||||
}
|
||||
|
||||
void BaseWidget::childEvent(QChildEvent *event)
|
||||
|
@ -111,12 +111,12 @@ void BaseWidget::childEvent(QChildEvent *event)
|
|||
BaseWidget *widget = dynamic_cast<BaseWidget *>(event->child());
|
||||
|
||||
if (widget != nullptr) {
|
||||
this->widgets.push_back(widget);
|
||||
this->widgets_.push_back(widget);
|
||||
}
|
||||
} else if (event->removed()) {
|
||||
for (auto it = this->widgets.begin(); it != this->widgets.end(); it++) {
|
||||
for (auto it = this->widgets_.begin(); it != this->widgets_.end(); it++) {
|
||||
if (*it == event->child()) {
|
||||
this->widgets.erase(it);
|
||||
this->widgets_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -126,25 +126,14 @@ void BaseWidget::childEvent(QChildEvent *event)
|
|||
void BaseWidget::showEvent(QShowEvent *)
|
||||
{
|
||||
this->setScale(this->getScale());
|
||||
this->themeRefreshEvent();
|
||||
}
|
||||
|
||||
void BaseWidget::setScale(float value)
|
||||
{
|
||||
// update scale value
|
||||
this->scale = value;
|
||||
|
||||
this->scaleChangedEvent(this->getScale());
|
||||
this->scaleChanged.invoke(this->getScale());
|
||||
|
||||
this->setScaleIndependantSize(this->getScaleIndependantSize());
|
||||
this->themeChangedEvent();
|
||||
}
|
||||
|
||||
void BaseWidget::scaleChangedEvent(float newDpi)
|
||||
{
|
||||
}
|
||||
|
||||
void BaseWidget::themeRefreshEvent()
|
||||
void BaseWidget::themeChangedEvent()
|
||||
{
|
||||
// Do any color scheme updates here
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QWidget>
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
@ -15,7 +16,6 @@ class BaseWidget : public QWidget
|
|||
|
||||
public:
|
||||
explicit BaseWidget(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
virtual ~BaseWidget() override;
|
||||
|
||||
virtual float getScale() const;
|
||||
pajlada::Signals::Signal<float> scaleChanged;
|
||||
|
@ -32,26 +32,24 @@ public:
|
|||
void setScaleIndependantHeight(int value);
|
||||
|
||||
protected:
|
||||
void childEvent(QChildEvent *) override;
|
||||
virtual void childEvent(QChildEvent *) override;
|
||||
virtual void showEvent(QShowEvent *) override;
|
||||
|
||||
virtual void scaleChangedEvent(float newScale);
|
||||
virtual void themeRefreshEvent();
|
||||
|
||||
virtual void showEvent(QShowEvent *) override;
|
||||
virtual void themeChangedEvent();
|
||||
|
||||
void setScale(float value);
|
||||
|
||||
Theme *themeManager;
|
||||
Theme *theme;
|
||||
|
||||
private:
|
||||
void init();
|
||||
float scale = 1.f;
|
||||
boost::optional<float> overrideScale = boost::none;
|
||||
QSize scaleIndependantSize;
|
||||
float scale_ = 1.f;
|
||||
boost::optional<float> overrideScale_ = boost::none;
|
||||
QSize scaleIndependantSize_;
|
||||
|
||||
std::vector<BaseWidget *> widgets;
|
||||
std::vector<BaseWidget *> widgets_;
|
||||
|
||||
pajlada::Signals::Connection themeConnection;
|
||||
pajlada::Signals::SignalHolder signalHolder_;
|
||||
|
||||
friend class BaseWindow;
|
||||
};
|
||||
|
|
|
@ -66,7 +66,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
|||
|
||||
float BaseWindow::getScale() const
|
||||
{
|
||||
return this->getOverrideScale().value_or(this->scale);
|
||||
return this->getOverrideScale().value_or(this->scale_);
|
||||
}
|
||||
|
||||
BaseWindow::Flags BaseWindow::getFlags()
|
||||
|
@ -212,28 +212,28 @@ bool BaseWindow::hasCustomWindowFrame()
|
|||
#endif
|
||||
}
|
||||
|
||||
void BaseWindow::themeRefreshEvent()
|
||||
void BaseWindow::themeChangedEvent()
|
||||
{
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor(0, 0, 0, 0));
|
||||
palette.setColor(QPalette::Foreground, this->themeManager->window.text);
|
||||
palette.setColor(QPalette::Foreground, this->theme->window.text);
|
||||
this->setPalette(palette);
|
||||
|
||||
if (this->ui_.titleLabel) {
|
||||
QPalette palette_title;
|
||||
palette_title.setColor(QPalette::Foreground,
|
||||
this->themeManager->isLightTheme() ? "#333" : "#ccc");
|
||||
this->theme->isLightTheme() ? "#333" : "#ccc");
|
||||
this->ui_.titleLabel->setPalette(palette_title);
|
||||
}
|
||||
|
||||
for (RippleEffectButton *button : this->ui_.buttons) {
|
||||
button->setMouseEffectColor(this->themeManager->window.text);
|
||||
button->setMouseEffectColor(this->theme->window.text);
|
||||
}
|
||||
} else {
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, this->themeManager->window.background);
|
||||
palette.setColor(QPalette::Foreground, this->themeManager->window.text);
|
||||
palette.setColor(QPalette::Background, this->theme->window.background);
|
||||
palette.setColor(QPalette::Foreground, this->theme->window.text);
|
||||
this->setPalette(palette);
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ void BaseWindow::drawCustomWindowFrame(QPainter &painter)
|
|||
if (this->hasCustomWindowFrame()) {
|
||||
QPainter painter(this);
|
||||
|
||||
QColor bg = this->overrideBackgroundColor_.value_or(this->themeManager->window.background);
|
||||
QColor bg = this->overrideBackgroundColor_.value_or(this->theme->window.background);
|
||||
|
||||
painter.fillRect(QRect(0, 1, this->width() - 0, this->height() - 0), bg);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ protected:
|
|||
virtual void resizeEvent(QResizeEvent *) override;
|
||||
virtual void closeEvent(QCloseEvent *) override;
|
||||
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
virtual bool event(QEvent *event) override;
|
||||
virtual void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
void setHasOffset(bool hasOffset);
|
||||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float scale) override;
|
||||
virtual void scaleChangedEvent(float scale_) override;
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
|
||||
virtual QSize sizeHint() const override;
|
||||
|
|
|
@ -375,7 +375,7 @@ void Notebook::paintEvent(QPaintEvent *event)
|
|||
|
||||
QPainter painter(this);
|
||||
painter.fillRect(0, this->lineY, this->width(), (int)(3 * this->getScale()),
|
||||
this->themeManager->tabs.bottomLine);
|
||||
this->theme->tabs.bottomLine);
|
||||
}
|
||||
|
||||
NotebookButton *Notebook::getAddButton()
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
void performLayout(bool animate = false);
|
||||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float scale) override;
|
||||
virtual void scaleChangedEvent(float scale_) override;
|
||||
virtual void resizeEvent(QResizeEvent *) override;
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
|||
int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale());
|
||||
|
||||
QPainter painter(this);
|
||||
painter.fillRect(rect(), this->themeManager->scrollbars.background);
|
||||
painter.fillRect(rect(), this->theme->scrollbars.background);
|
||||
|
||||
// painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
|
||||
// this->themeManager->ScrollbarArrow);
|
||||
|
@ -229,11 +229,11 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
|||
|
||||
// mouse over thumb
|
||||
if (this->mouseDownIndex_ == 2) {
|
||||
painter.fillRect(this->thumbRect_, this->themeManager->scrollbars.thumbSelected);
|
||||
painter.fillRect(this->thumbRect_, this->theme->scrollbars.thumbSelected);
|
||||
}
|
||||
// mouse not over thumb
|
||||
else {
|
||||
painter.fillRect(this->thumbRect_, this->themeManager->scrollbars.thumb);
|
||||
painter.fillRect(this->thumbRect_, this->theme->scrollbars.thumb);
|
||||
}
|
||||
|
||||
// draw highlights
|
||||
|
|
|
@ -62,7 +62,7 @@ void TooltipWidget::raise()
|
|||
}
|
||||
#endif
|
||||
|
||||
void TooltipWidget::themeRefreshEvent()
|
||||
void TooltipWidget::themeChangedEvent()
|
||||
{
|
||||
this->setStyleSheet("color: #fff; background: #000");
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
protected:
|
||||
void changeEvent(QEvent *) override;
|
||||
void leaveEvent(QEvent *) override;
|
||||
void themeRefreshEvent() override;
|
||||
void themeChangedEvent() override;
|
||||
void scaleChangedEvent(float) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -267,11 +267,11 @@ void SelectChannelDialog::closeEvent(QCloseEvent *)
|
|||
this->closed.invoke();
|
||||
}
|
||||
|
||||
void SelectChannelDialog::themeRefreshEvent()
|
||||
void SelectChannelDialog::themeChangedEvent()
|
||||
{
|
||||
BaseWindow::themeRefreshEvent();
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
if (this->themeManager->isLightTheme()) {
|
||||
if (this->theme->isLightTheme()) {
|
||||
this->setStyleSheet("QRadioButton { color: #000 } QLabel { color: #000 }");
|
||||
} else {
|
||||
this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }");
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *) override;
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
|
||||
private:
|
||||
class EventFilter : public QObject
|
||||
|
|
|
@ -175,9 +175,9 @@ void SettingsDialog::scaleChangedEvent(float newDpi)
|
|||
this->ui_.tabContainerContainer->setFixedWidth(int(200 * newDpi));
|
||||
}
|
||||
|
||||
void SettingsDialog::themeRefreshEvent()
|
||||
void SettingsDialog::themeChangedEvent()
|
||||
{
|
||||
BaseWindow::themeRefreshEvent();
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Background, QColor("#444"));
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float newDpi) override;
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
|
|
@ -158,9 +158,9 @@ UserInfoPopup::UserInfoPopup()
|
|||
this->installEvents();
|
||||
}
|
||||
|
||||
void UserInfoPopup::themeRefreshEvent()
|
||||
void UserInfoPopup::themeChangedEvent()
|
||||
{
|
||||
BaseWindow::themeRefreshEvent();
|
||||
BaseWindow::themeChangedEvent();
|
||||
|
||||
this->setStyleSheet("background: #333");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
void setData(const QString &name, const ChannelPtr &channel);
|
||||
|
||||
protected:
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
|
||||
private:
|
||||
bool isMod_;
|
||||
|
|
|
@ -131,9 +131,9 @@ ChannelView::~ChannelView()
|
|||
{
|
||||
}
|
||||
|
||||
void ChannelView::themeRefreshEvent()
|
||||
void ChannelView::themeChangedEvent()
|
||||
{
|
||||
BaseWidget::themeRefreshEvent();
|
||||
BaseWidget::themeChangedEvent();
|
||||
|
||||
this->layoutMessages();
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
|||
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(rect(), this->themeManager->splits.background);
|
||||
painter.fillRect(rect(), this->theme->splits.background);
|
||||
|
||||
// draw messages
|
||||
this->drawMessages(painter);
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
pajlada::Signals::Signal<const Link &> linkClicked;
|
||||
|
||||
protected:
|
||||
void themeRefreshEvent() override;
|
||||
void themeChangedEvent() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ NotebookButton::Icon NotebookButton::getIcon() const
|
|||
return this->icon_;
|
||||
}
|
||||
|
||||
void NotebookButton::themeRefreshEvent()
|
||||
void NotebookButton::themeChangedEvent()
|
||||
{
|
||||
this->setMouseEffectColor(this->themeManager->tabs.regular.text);
|
||||
this->setMouseEffectColor(this->theme->tabs.regular.text);
|
||||
}
|
||||
|
||||
void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
|
@ -45,11 +45,11 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
|||
QColor foreground;
|
||||
|
||||
if (mouseDown_ || mouseOver_) {
|
||||
background = this->themeManager->tabs.regular.backgrounds.hover.color();
|
||||
foreground = this->themeManager->tabs.regular.text;
|
||||
background = this->theme->tabs.regular.backgrounds.hover.color();
|
||||
foreground = this->theme->tabs.regular.text;
|
||||
} else {
|
||||
background = this->themeManager->tabs.regular.backgrounds.regular.color();
|
||||
foreground = this->themeManager->tabs.regular.text;
|
||||
background = this->theme->tabs.regular.backgrounds.regular.color();
|
||||
foreground = this->theme->tabs.regular.text;
|
||||
}
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
Icon getIcon() const;
|
||||
|
||||
protected:
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *) override;
|
||||
virtual void dragEnterEvent(QDragEnterEvent *) override;
|
||||
|
|
|
@ -64,12 +64,12 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||
// });
|
||||
}
|
||||
|
||||
void NotebookTab::themeRefreshEvent()
|
||||
void NotebookTab::themeChangedEvent()
|
||||
{
|
||||
this->update();
|
||||
|
||||
// this->setMouseEffectColor(QColor("#999"));
|
||||
this->setMouseEffectColor(this->themeManager->tabs.regular.text);
|
||||
this->setMouseEffectColor(this->theme->tabs.regular.text);
|
||||
}
|
||||
|
||||
void NotebookTab::updateSize()
|
||||
|
@ -222,16 +222,16 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
|||
|
||||
// select the right tab colors
|
||||
Theme::TabColors colors;
|
||||
Theme::TabColors regular = this->themeManager->tabs.regular;
|
||||
Theme::TabColors regular = this->theme->tabs.regular;
|
||||
|
||||
if (this->selected_) {
|
||||
colors = this->themeManager->tabs.selected;
|
||||
colors = this->theme->tabs.selected;
|
||||
} else if (this->highlightState_ == HighlightState::Highlighted) {
|
||||
colors = this->themeManager->tabs.highlighted;
|
||||
colors = this->theme->tabs.highlighted;
|
||||
} else if (this->highlightState_ == HighlightState::NewMessage) {
|
||||
colors = this->themeManager->tabs.newMessage;
|
||||
colors = this->theme->tabs.newMessage;
|
||||
} else {
|
||||
colors = this->themeManager->tabs.regular;
|
||||
colors = this->theme->tabs.regular;
|
||||
}
|
||||
|
||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void hideTabXChanged(bool);
|
||||
|
||||
protected:
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
|||
if (this->mouseEffectColor_) {
|
||||
c = this->mouseEffectColor_.get();
|
||||
} else {
|
||||
c = this->themeManager->isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
||||
c = this->theme->isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
||||
}
|
||||
|
||||
if (this->hoverMultiplier_ > 0) {
|
||||
|
|
|
@ -26,8 +26,8 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
|||
|
||||
painter.setOpacity(this->getCurrentDimAmount());
|
||||
|
||||
QColor color = this->themeManager->window.text;
|
||||
QColor background = this->themeManager->window.background;
|
||||
QColor color = this->theme->window.text;
|
||||
QColor background = this->theme->window.background;
|
||||
|
||||
int xD = this->height() / 3;
|
||||
int centerX = this->width() / 2;
|
||||
|
@ -50,7 +50,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event)
|
|||
|
||||
painter.drawRect(centerX - xD / 2 + xD2, xD, xD3, xD3);
|
||||
painter.fillRect(centerX - xD / 2, xD + xD2, xD3, xD3,
|
||||
this->themeManager->window.background);
|
||||
this->theme->window.background);
|
||||
painter.drawRect(centerX - xD / 2, xD + xD2, xD3, xD3);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ void Split::paintEvent(QPaintEvent *)
|
|||
// color the background of the chat
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(this->rect(), this->themeManager->splits.background);
|
||||
painter.fillRect(this->rect(), this->theme->splits.background);
|
||||
}
|
||||
|
||||
void Split::mouseMoveEvent(QMouseEvent *event)
|
||||
|
@ -446,7 +446,7 @@ void Split::doOpenViewerList()
|
|||
QList<QListWidgetItem *> labelList;
|
||||
for (auto &x : labels) {
|
||||
auto label = new QListWidgetItem(x);
|
||||
label->setBackgroundColor(this->themeManager->splits.header.background);
|
||||
label->setBackgroundColor(this->theme->splits.header.background);
|
||||
labelList.append(label);
|
||||
}
|
||||
auto loadingLabel = new QLabel("Loading...");
|
||||
|
@ -503,7 +503,7 @@ void Split::doOpenViewerList()
|
|||
dockVbox->addWidget(resultList);
|
||||
resultList->hide();
|
||||
|
||||
multiWidget->setStyleSheet(this->themeManager->splits.input.styleSheet);
|
||||
multiWidget->setStyleSheet(this->theme->splits.input.styleSheet);
|
||||
multiWidget->setLayout(dockVbox);
|
||||
viewerDock->setWidget(multiWidget);
|
||||
viewerDock->show();
|
||||
|
|
|
@ -400,9 +400,9 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
|||
QPainter painter(this);
|
||||
|
||||
if (this->splits.size() == 0) {
|
||||
painter.fillRect(rect(), this->themeManager->splits.background);
|
||||
painter.fillRect(rect(), this->theme->splits.background);
|
||||
|
||||
painter.setPen(this->themeManager->splits.header.text);
|
||||
painter.setPen(this->theme->splits.header.text);
|
||||
|
||||
QString text = "Click to add a split";
|
||||
|
||||
|
@ -445,7 +445,7 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
|||
|
||||
int s = std::min<int>(dropRect.rect.width(), dropRect.rect.height()) - 12;
|
||||
|
||||
if (this->themeManager->isLightTheme()) {
|
||||
if (this->theme->isLightTheme()) {
|
||||
painter.setPen(QColor(0, 0, 0));
|
||||
} else {
|
||||
painter.setPen(QColor(255, 255, 255));
|
||||
|
@ -457,8 +457,8 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
|||
}
|
||||
|
||||
QBrush accentColor = (QApplication::activeWindow() == this->window()
|
||||
? this->themeManager->tabs.selected.backgrounds.regular
|
||||
: this->themeManager->tabs.selected.backgrounds.unfocused);
|
||||
? this->theme->tabs.selected.backgrounds.regular
|
||||
: this->theme->tabs.selected.backgrounds.unfocused);
|
||||
|
||||
painter.fillRect(0, 0, width(), 1, accentColor);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ SplitHeader::SplitHeader(Split *_split)
|
|||
: BaseWidget(_split)
|
||||
, split(_split)
|
||||
{
|
||||
this->split->focused.connect([this]() { this->themeRefreshEvent(); });
|
||||
this->split->focusLost.connect([this]() { this->themeRefreshEvent(); });
|
||||
this->split->focused.connect([this]() { this->themeChangedEvent(); });
|
||||
this->split->focusLost.connect([this]() { this->themeChangedEvent(); });
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
|
@ -374,8 +374,8 @@ void SplitHeader::paintEvent(QPaintEvent *)
|
|||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(rect(), this->themeManager->splits.header.background);
|
||||
painter.setPen(this->themeManager->splits.header.border);
|
||||
painter.fillRect(rect(), this->theme->splits.header.background);
|
||||
painter.setPen(this->theme->splits.header.border);
|
||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||
}
|
||||
|
||||
|
@ -468,17 +468,17 @@ void SplitHeader::rightButtonClicked()
|
|||
{
|
||||
}
|
||||
|
||||
void SplitHeader::themeRefreshEvent()
|
||||
void SplitHeader::themeChangedEvent()
|
||||
{
|
||||
QPalette palette;
|
||||
|
||||
if (this->split->hasFocus()) {
|
||||
palette.setColor(QPalette::Foreground, this->themeManager->splits.header.focusedText);
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.header.focusedText);
|
||||
} else {
|
||||
palette.setColor(QPalette::Foreground, this->themeManager->splits.header.text);
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.header.text);
|
||||
}
|
||||
|
||||
if (this->themeManager->isLightTheme()) {
|
||||
if (this->theme->isLightTheme()) {
|
||||
this->dropdownButton->setPixmap(QPixmap(":/images/menu_black.png"));
|
||||
} else {
|
||||
this->dropdownButton->setPixmap(QPixmap(":/images/menu_white.png"));
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float) override;
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void themeChangedEvent() override;
|
||||
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
|
|
|
@ -111,18 +111,18 @@ void SplitInput::scaleChangedEvent(float scale)
|
|||
this->ui_.textEdit->setFont(getApp()->fonts->getFont(FontStyle::ChatMedium, this->getScale()));
|
||||
}
|
||||
|
||||
void SplitInput::themeRefreshEvent()
|
||||
void SplitInput::themeChangedEvent()
|
||||
{
|
||||
QPalette palette;
|
||||
|
||||
palette.setColor(QPalette::Foreground, this->themeManager->splits.input.text);
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.input.text);
|
||||
|
||||
this->updateEmoteButton();
|
||||
this->ui_.textEditLength->setPalette(palette);
|
||||
|
||||
this->ui_.textEdit->setStyleSheet(this->themeManager->splits.input.styleSheet);
|
||||
this->ui_.textEdit->setStyleSheet(this->theme->splits.input.styleSheet);
|
||||
|
||||
this->ui_.hbox->setMargin(int((this->themeManager->isLightTheme() ? 4 : 2) * this->getScale()));
|
||||
this->ui_.hbox->setMargin(int((this->theme->isLightTheme() ? 4 : 2) * this->getScale()));
|
||||
|
||||
this->ui_.emoteButton->getLabel().setStyleSheet("color: #000");
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ void SplitInput::updateEmoteButton()
|
|||
QString text = "<img src=':/images/emote.svg' width='xD' height='xD' />";
|
||||
text.replace("xD", QString::number(int(12 * scale)));
|
||||
|
||||
if (this->themeManager->isLightTheme()) {
|
||||
if (this->theme->isLightTheme()) {
|
||||
text.replace("emote", "emote_dark");
|
||||
}
|
||||
|
||||
|
@ -322,11 +322,11 @@ void SplitInput::paintEvent(QPaintEvent *)
|
|||
{
|
||||
QPainter painter(this);
|
||||
|
||||
if (this->themeManager->isLightTheme()) {
|
||||
if (this->theme->isLightTheme()) {
|
||||
int s = int(3 * this->getScale());
|
||||
QRect rect = this->rect().marginsRemoved(QMargins(s, s, s, s));
|
||||
|
||||
painter.fillRect(rect, this->themeManager->splits.input.background);
|
||||
painter.fillRect(rect, this->theme->splits.input.background);
|
||||
|
||||
painter.setPen(QColor("#ccc"));
|
||||
painter.drawRect(rect);
|
||||
|
@ -334,7 +334,7 @@ void SplitInput::paintEvent(QPaintEvent *)
|
|||
int s = int(1 * this->getScale());
|
||||
QRect rect = this->rect().marginsRemoved(QMargins(s, s, s, s));
|
||||
|
||||
painter.fillRect(rect, this->themeManager->splits.input.background);
|
||||
painter.fillRect(rect, this->theme->splits.input.background);
|
||||
|
||||
painter.setPen(QColor("#333"));
|
||||
painter.drawRect(rect);
|
||||
|
|
|
@ -31,8 +31,8 @@ public:
|
|||
pajlada::Signals::Signal<const QString &> textChanged;
|
||||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float scale) override;
|
||||
virtual void themeRefreshEvent() override;
|
||||
virtual void scaleChangedEvent(float scale_) override;
|
||||
virtual void themeChangedEvent() override;
|
||||
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
virtual void resizeEvent(QResizeEvent *) override;
|
||||
|
|
|
@ -91,7 +91,7 @@ SplitOverlay::SplitOverlay(Split *parent)
|
|||
void SplitOverlay::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
if (this->themeManager->isLightTheme()) {
|
||||
if (this->theme->isLightTheme()) {
|
||||
painter.fillRect(this->rect(), QColor(255, 255, 255, 200));
|
||||
} else {
|
||||
painter.fillRect(this->rect(), QColor(0, 0, 0, 150));
|
||||
|
|
Loading…
Reference in a new issue