refactored BaseWidget

This commit is contained in:
fourtf
2018-07-06 17:11:37 +02:00
parent 741c1f7820
commit b639604a47
31 changed files with 121 additions and 134 deletions
+3 -3
View File
@@ -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();
+5 -5
View File
@@ -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);
}
+8 -8
View File
@@ -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"));
+1 -1
View File
@@ -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;
+8 -8
View File
@@ -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);
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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));