diff --git a/src/widgets/helper/notebookbutton.cpp b/src/widgets/helper/notebookbutton.cpp index 05ebb273..30184b97 100644 --- a/src/widgets/helper/notebookbutton.cpp +++ b/src/widgets/helper/notebookbutton.cpp @@ -115,8 +115,9 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event) void NotebookButton::dragEnterEvent(QDragEnterEvent *event) { - if (!event->mimeData()->hasFormat("chatterino/split")) + if (!event->mimeData()->hasFormat("chatterino/split")) { return; + } event->acceptProposedAction(); diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index fb48ffd6..1b8ca9e2 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -22,7 +22,7 @@ namespace chatterino { namespace widgets { NotebookTab::NotebookTab(Notebook *notebook) - : BaseWidget(notebook) + : RippleEffectButton(notebook) , positionChangedAnimation_(this, "pos") , notebook_(notebook) , menu_(this) @@ -68,6 +68,9 @@ NotebookTab::NotebookTab(Notebook *notebook) void NotebookTab::themeRefreshEvent() { this->update(); + + // this->setMouseEffectColor(QColor("#999")); + this->setMouseEffectColor(this->themeManager->tabs.regular.text); } void NotebookTab::updateSize() @@ -234,9 +237,9 @@ void NotebookTab::paintEvent(QPaintEvent *) bool windowFocused = this->window() == QApplication::activeWindow(); // || SettingsDialog::getHandle() == QApplication::activeWindow(); - QBrush tabBackground = this->mouseOver_ ? colors.backgrounds.hover - : (windowFocused ? colors.backgrounds.regular - : colors.backgrounds.unfocused); + QBrush tabBackground = /*this->mouseOver_ ? colors.backgrounds.hover + :*/ (windowFocused ? colors.backgrounds.regular + : colors.backgrounds.unfocused); // painter.fillRect(rect(), this->mouseOver_ ? regular.backgrounds.hover // : (windowFocused ? regular.backgrounds.regular @@ -312,6 +315,8 @@ void NotebookTab::paintEvent(QPaintEvent *) // draw line at bottom if (!this->selected_) { painter.fillRect(0, this->height() - 1, this->width(), 1, app->themes->window.background); + + this->fancyPaint(painter); } } @@ -373,19 +378,23 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event) } } -void NotebookTab::enterEvent(QEvent *) +void NotebookTab::enterEvent(QEvent *event) { this->mouseOver_ = true; this->update(); + + RippleEffectButton::enterEvent(event); } -void NotebookTab::leaveEvent(QEvent *) +void NotebookTab::leaveEvent(QEvent *event) { this->mouseOverX_ = false; this->mouseOver_ = false; this->update(); + + RippleEffectButton::leaveEvent(event); } void NotebookTab::dragEnterEvent(QDragEnterEvent *event) @@ -429,6 +438,8 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event) this->notebook_->rearrangePage(this->page, index); } } + + RippleEffectButton::mouseMoveEvent(event); } QRect NotebookTab::getXRect() diff --git a/src/widgets/helper/notebooktab.hpp b/src/widgets/helper/notebooktab.hpp index 93cb971f..1069f61a 100644 --- a/src/widgets/helper/notebooktab.hpp +++ b/src/widgets/helper/notebooktab.hpp @@ -2,6 +2,7 @@ #include "common.hpp" #include "widgets/basewidget.hpp" +#include "widgets/helper/rippleeffectbutton.hpp" #include #include @@ -17,7 +18,7 @@ namespace widgets { class Notebook; class SplitContainer; -class NotebookTab : public BaseWidget +class NotebookTab : public RippleEffectButton { Q_OBJECT diff --git a/src/widgets/helper/rippleeffectbutton.cpp b/src/widgets/helper/rippleeffectbutton.cpp index 18d91e19..0dffe7ea 100644 --- a/src/widgets/helper/rippleeffectbutton.cpp +++ b/src/widgets/helper/rippleeffectbutton.cpp @@ -88,7 +88,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter) QRadialGradient gradient(QPointF(mousePos_), this->width() / 2); gradient.setColorAt(0, - QColor(c.red(), c.green(), c.blue(), int(60 * this->hoverMultiplier_))); + QColor(c.red(), c.green(), c.blue(), int(50 * this->hoverMultiplier_))); gradient.setColorAt(1, QColor(c.red(), c.green(), c.blue(), int(40 * this->hoverMultiplier_))); @@ -97,7 +97,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter) for (auto effect : this->clickEffects_) { QRadialGradient gradient(effect.position.x(), effect.position.y(), - effect.progress * float(width()) * 2, effect.position.x(), + effect.progress * qreal(width()) * 2, effect.position.x(), effect.position.y()); gradient.setColorAt(0, diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp index 2fb0a815..ba8e35f6 100644 --- a/src/widgets/label.cpp +++ b/src/widgets/label.cpp @@ -91,7 +91,7 @@ void Label::paintEvent(QPaintEvent *) painter.setFont( app->fonts->getFont(this->getFontStyle(), this->getScale() * this->devicePixelRatioF())); - int offset = this->hasOffset_ ? int(8 * this->getScale()) : 0; + int offset = this->getOffset(); // draw text QRect textRect(offset, 0, this->width() - offset - offset, this->height()); @@ -112,10 +112,17 @@ void Label::updateSize() QFontMetrics metrics = app->fonts->getFontMetrics(this->fontStyle_, this->getScale()); - this->preferedSize_ = QSize(metrics.width(this->text_), metrics.height()); + int width = metrics.width(this->text_) + (2 * this->getOffset()); + int height = metrics.height(); + this->preferedSize_ = QSize(width, height); this->updateGeometry(); } +int Label::getOffset() +{ + return this->hasOffset_ ? int(8 * this->getScale()) : 0; +} + } // namespace widgets } // namespace chatterino diff --git a/src/widgets/label.hpp b/src/widgets/label.hpp index c023effe..455b0f80 100644 --- a/src/widgets/label.hpp +++ b/src/widgets/label.hpp @@ -40,6 +40,7 @@ private: bool hasOffset_ = true; void updateSize(); + int getOffset(); }; } // namespace widgets diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index 7a9eb763..9e69bacd 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -340,7 +340,7 @@ void Notebook::performLayout(bool animated) x += i->tab->width(); } - x += int(scale * 2); + x += int(scale * 1); first = false; } diff --git a/src/widgets/userinfopopup.cpp b/src/widgets/userinfopopup.cpp index 532fba45..2ef5a1f6 100644 --- a/src/widgets/userinfopopup.cpp +++ b/src/widgets/userinfopopup.cpp @@ -8,6 +8,7 @@ #include "util/urlfetch.hpp" #include "widgets/helper/line.hpp" #include "widgets/helper/rippleeffectlabel.hpp" +#include "widgets/label.hpp" #include #include @@ -32,9 +33,8 @@ UserInfoPopup::UserInfoPopup() auto head = layout.emplace().withoutMargin(); { // avatar - // auto avatar = head.emplace("Avatar").assign(&this->ui_.avatarButtoAn); auto avatar = head.emplace(nullptr).assign(&this->ui_.avatarButton); - avatar->setFixedSize(100, 100); + avatar->setScaleIndependantSize(100, 100); QObject::connect(*avatar, &RippleEffectButton::clicked, [this] { QDesktopServices::openUrl(QUrl("https://twitch.tv/" + this->userName_)); }); @@ -42,14 +42,14 @@ UserInfoPopup::UserInfoPopup() // items on the right auto vbox = head.emplace(); { - auto name = vbox.emplace().assign(&this->ui_.nameLabel); + auto name = vbox.emplace