From dc62e8248b649570a03c0738f672245d9764b021 Mon Sep 17 00:00:00 2001 From: nerix Date: Sun, 17 Sep 2023 13:27:20 +0200 Subject: [PATCH] Add (invisible) resize handle to frameless usercards and reply threads (#4795) * feat: add resize handle to usercards&reply threads * Add changelog entry --------- Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/CMakeLists.txt | 2 ++ src/widgets/dialogs/ReplyThreadPopup.cpp | 14 ++++++++++++-- src/widgets/dialogs/UserInfoPopup.cpp | 14 ++++++++++++-- src/widgets/helper/InvisibleSizeGrip.cpp | 16 ++++++++++++++++ src/widgets/helper/InvisibleSizeGrip.hpp | 16 ++++++++++++++++ 6 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 src/widgets/helper/InvisibleSizeGrip.cpp create mode 100644 src/widgets/helper/InvisibleSizeGrip.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index c3e84749..5802ee83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Minor: Migrate to the new Get Channel Followers Helix endpoint, fixing follower count not showing up in usercards. (#4809) - Minor: The account switcher is now styled to match your theme. (#4817) +- Minor: Add an invisible resize handle to the bottom of frameless user info popups and reply thread popups. (#4795) - Bugfix: Fixed a performance issue when displaying replies to certain messages. (#4807) - Bugfix: Fixed a data race when disconnecting from Twitch PubSub. (#4771) - Bugfix: Fixed `/shoutout` command not working with usernames starting with @'s (e.g. `/shoutout @forsen`). (#4800) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 416b7996..5e30ffd2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -538,6 +538,8 @@ set(SOURCE_FILES widgets/helper/EditableModelView.hpp widgets/helper/EffectLabel.cpp widgets/helper/EffectLabel.hpp + widgets/helper/InvisibleSizeGrip.cpp + widgets/helper/InvisibleSizeGrip.hpp widgets/helper/NotebookButton.cpp widgets/helper/NotebookButton.hpp widgets/helper/NotebookTab.cpp diff --git a/src/widgets/dialogs/ReplyThreadPopup.cpp b/src/widgets/dialogs/ReplyThreadPopup.cpp index a9c95aae..8026c7ef 100644 --- a/src/widgets/dialogs/ReplyThreadPopup.cpp +++ b/src/widgets/dialogs/ReplyThreadPopup.cpp @@ -13,6 +13,7 @@ #include "util/LayoutCreator.hpp" #include "widgets/helper/Button.hpp" #include "widgets/helper/ChannelView.hpp" +#include "widgets/helper/InvisibleSizeGrip.hpp" #include "widgets/Scrollbar.hpp" #include "widgets/splits/Split.hpp" #include "widgets/splits/SplitInput.hpp" @@ -120,8 +121,10 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, QWidget *parent, } }); - auto layout = LayoutCreator(this->getLayoutContainer()) - .setLayoutType(); + auto layers = LayoutCreator(this->getLayoutContainer()) + .setLayoutType() + .withoutMargin(); + auto layout = layers.emplace(); layout->setSpacing(0); // provide draggable margin if frameless @@ -174,6 +177,13 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, QWidget *parent, layout->addWidget(this->ui_.threadView, 1); layout->addWidget(this->ui_.replyInput); + + // size grip + if (closeAutomatically) + { + layers->addWidget(new InvisibleSizeGrip(this), 0, 0, + Qt::AlignRight | Qt::AlignBottom); + } } void ReplyThreadPopup::setThread(std::shared_ptr thread) diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 701f427c..a34b00bf 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -26,6 +26,7 @@ #include "util/StreamerMode.hpp" #include "widgets/helper/ChannelView.hpp" #include "widgets/helper/EffectLabel.hpp" +#include "widgets/helper/InvisibleSizeGrip.hpp" #include "widgets/helper/Line.hpp" #include "widgets/Label.hpp" #include "widgets/Scrollbar.hpp" @@ -246,8 +247,10 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent, this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( HotkeyCategory::PopupWindow, actions, this); - auto layout = LayoutCreator(this->getLayoutContainer()) - .setLayoutType(); + auto layers = LayoutCreator(this->getLayoutContainer()) + .setLayoutType() + .withoutMargin(); + auto layout = layers.emplace(); // first line auto head = layout.emplace().withoutMargin(); @@ -552,6 +555,13 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent, logs->setAlignment(this->ui_.noMessagesLabel, Qt::AlignHCenter); } + // size grip + if (closeAutomatically) + { + layers->addWidget(new InvisibleSizeGrip(this), 0, 0, + Qt::AlignRight | Qt::AlignBottom); + } + this->installEvents(); this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Policy::Ignored); } diff --git a/src/widgets/helper/InvisibleSizeGrip.cpp b/src/widgets/helper/InvisibleSizeGrip.cpp new file mode 100644 index 00000000..71b68538 --- /dev/null +++ b/src/widgets/helper/InvisibleSizeGrip.cpp @@ -0,0 +1,16 @@ +#include "widgets/helper/InvisibleSizeGrip.hpp" + +namespace chatterino { + +InvisibleSizeGrip::InvisibleSizeGrip(QWidget *parent) + : QSizeGrip(parent) +{ + // required on Windows to prevent this from being ignored when dragging + this->setMouseTracking(true); +} + +void InvisibleSizeGrip::paintEvent(QPaintEvent *event) +{ +} + +} // namespace chatterino diff --git a/src/widgets/helper/InvisibleSizeGrip.hpp b/src/widgets/helper/InvisibleSizeGrip.hpp new file mode 100644 index 00000000..15ffdd3c --- /dev/null +++ b/src/widgets/helper/InvisibleSizeGrip.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace chatterino { + +class InvisibleSizeGrip : public QSizeGrip +{ +public: + explicit InvisibleSizeGrip(QWidget *parent = nullptr); + +protected: + void paintEvent(QPaintEvent *event) override; +}; + +} // namespace chatterino