From 19fdfaef42ae278ec656b46e4e96ad44906be0a9 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 4 Jul 2018 13:05:54 +0200 Subject: [PATCH] reworked splitheader a bit --- resources/images/menu_black.png | Bin 0 -> 331 bytes resources/images/menu_white.png | Bin 0 -> 328 bytes resources/resources.qrc | 2 + src/widgets/BaseWindow.cpp | 23 ++- src/widgets/helper/RippleEffectButton.cpp | 18 ++ src/widgets/helper/RippleEffectButton.hpp | 4 + src/widgets/splits/SplitHeader.cpp | 207 +++++++++++----------- src/widgets/splits/SplitHeader.hpp | 22 ++- 8 files changed, 154 insertions(+), 122 deletions(-) create mode 100644 resources/images/menu_black.png create mode 100644 resources/images/menu_white.png diff --git a/resources/images/menu_black.png b/resources/images/menu_black.png new file mode 100644 index 0000000000000000000000000000000000000000..b718472d4078f67af25f3c069b9a75f35871f8a4 GIT binary patch literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NS%G}c0*}aI z1_s$y5N7-!ZS)2xC|TkfQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXJq(MA#*BF(Fso% z$B+p3t!E9nm>mUcMxf2vtMo-mIWL6!leqUuo{G`}*a1&A!6_g^#;-uBrg~iNVv=&t;uc GLK6TUZi(3d literal 0 HcmV?d00001 diff --git a/resources/images/menu_white.png b/resources/images/menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..42bdfb3e0261dd1b715f2f32ebfc2adc5f2c67a2 GIT binary patch literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmUKs7M+SzC{oH>NS%G}c0*}aI z1_s$C5N2EyKV>pdP_o1|q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&&cqjLgrMUqNAQJ zjv*25ThBUXF*^#dIR5>A`Ss)vK`l0!(Owimages/buttons/unmod.png images/emote_dark.svg tlds.txt + images/menu_black.png + images/menu_white.png qt.conf diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index ed56c3e0..af776185 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -417,25 +417,36 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r #ifdef USEWINSDK MSG *msg = reinterpret_cast(message); + bool returnValue = false; + switch (msg->message) { case WM_DPICHANGED: - return handleDPICHANGED(msg); + returnValue = handleDPICHANGED(msg); + break; case WM_SHOWWINDOW: - return this->handleSHOWWINDOW(msg); + returnValue = this->handleSHOWWINDOW(msg); + break; case WM_NCCALCSIZE: - return this->handleNCCALCSIZE(msg, result); + returnValue = this->handleNCCALCSIZE(msg, result); + break; case WM_SIZE: - return this->handleSIZE(msg); + returnValue = this->handleSIZE(msg); + break; case WM_NCHITTEST: - return this->handleNCHITTEST(msg, result); + returnValue = this->handleNCHITTEST(msg, result); + break; default: return QWidget::nativeEvent(eventType, message, result); } + + QWidget::nativeEvent(eventType, message, result); + + return returnValue; #else return QWidget::nativeEvent(eventType, message, result); #endif @@ -603,7 +614,7 @@ bool BaseWindow::handleSIZE(MSG *msg) } } } - return true; + return false; #else return false; #endif diff --git a/src/widgets/helper/RippleEffectButton.cpp b/src/widgets/helper/RippleEffectButton.cpp index 0bf6f50f..9c1ee66f 100644 --- a/src/widgets/helper/RippleEffectButton.cpp +++ b/src/widgets/helper/RippleEffectButton.cpp @@ -34,6 +34,18 @@ const QPixmap &RippleEffectButton::getPixmap() const return this->pixmap_; } +void RippleEffectButton::setDimPixmap(bool value) +{ + this->dimPixmap_ = value; + + this->update(); +} + +bool RippleEffectButton::getDimPixmap() const +{ + return this->dimPixmap_; +} + void RippleEffectButton::setBorderColor(const QColor &color) { this->borderColor_ = color; @@ -51,6 +63,10 @@ void RippleEffectButton::paintEvent(QPaintEvent *) painter.setRenderHint(QPainter::SmoothPixmapTransform); if (!this->pixmap_.isNull()) { + if (!this->mouseOver_ && this->dimPixmap_) { + painter.setOpacity(0.7); + } + QRect rect = this->rect(); int s = int(6 * this->getScale()); @@ -60,6 +76,8 @@ void RippleEffectButton::paintEvent(QPaintEvent *) rect.setBottom(rect.bottom() - s - s); painter.drawPixmap(rect, this->pixmap_); + + painter.setOpacity(1); } this->fancyPaint(painter); diff --git a/src/widgets/helper/RippleEffectButton.hpp b/src/widgets/helper/RippleEffectButton.hpp index 6fc4a2b1..ebe048df 100644 --- a/src/widgets/helper/RippleEffectButton.hpp +++ b/src/widgets/helper/RippleEffectButton.hpp @@ -33,6 +33,9 @@ public: void setPixmap(const QPixmap &pixmap_); const QPixmap &getPixmap() const; + void setDimPixmap(bool value); + bool getDimPixmap() const; + void setBorderColor(const QColor &color); const QColor &getBorderColor() const; @@ -56,6 +59,7 @@ protected: private: QColor borderColor_; QPixmap pixmap_; + bool dimPixmap_ = true; QPoint mousePos_; double hoverMultiplier_ = 0.0; QTimer effectTimer_; diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 9d138b21..dc7b7ce6 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -35,20 +35,8 @@ SplitHeader::SplitHeader(Split *_split) LayoutCreator layoutCreator(this); auto layout = layoutCreator.emplace().withoutMargin(); + layout->setSpacing(0); { - // dropdown label - auto dropdown = layout.emplace(this).assign(&this->dropdownButton); - dropdown->setMouseTracking(true); - dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap()); - this->addDropdownItems(dropdown.getElement()); - QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] { - QTimer::singleShot(80, [&, this] { - this->dropdownMenu.move( - this->dropdownButton->mapToGlobal(QPoint(0, this->dropdownButton->height()))); - this->dropdownMenu.show(); - }); - }); - // channel name label auto title = layout.emplace