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 <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix 2023-09-17 13:27:20 +02:00 committed by GitHub
parent f13a3b9685
commit dc62e8248b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 4 deletions

View file

@ -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)

View file

@ -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

View file

@ -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<QWidget>(this->getLayoutContainer())
.setLayoutType<QVBoxLayout>();
auto layers = LayoutCreator<QWidget>(this->getLayoutContainer())
.setLayoutType<QGridLayout>()
.withoutMargin();
auto layout = layers.emplace<QVBoxLayout>();
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<MessageThread> thread)

View file

@ -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<QWidget>(this->getLayoutContainer())
.setLayoutType<QVBoxLayout>();
auto layers = LayoutCreator<QWidget>(this->getLayoutContainer())
.setLayoutType<QGridLayout>()
.withoutMargin();
auto layout = layers.emplace<QVBoxLayout>();
// first line
auto head = layout.emplace<QHBoxLayout>().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);
}

View file

@ -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

View file

@ -0,0 +1,16 @@
#pragma once
#include <QSizeGrip>
namespace chatterino {
class InvisibleSizeGrip : public QSizeGrip
{
public:
explicit InvisibleSizeGrip(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *event) override;
};
} // namespace chatterino