feat(emote-popup): save size of popup (#5415)

* fix: remove added margins from emote window position

* chore: add changelog entry

* feat: store size of emote window

* chore: update changelog entry

* fix: disable layout save

* fix: PCH moment

* fix: multiply by scale
This commit is contained in:
nerix
2024-06-01 12:38:39 +02:00
committed by GitHub
parent c3bb99eb01
commit 65bfec963b
12 changed files with 138 additions and 45 deletions
+6 -3
View File
@@ -29,7 +29,9 @@
# pragma comment(lib, "Dwmapi.lib")
# include <QHBoxLayout>
# include <QMargins>
# include <QOperatingSystemVersion>
# include <QWindow>
#endif
#include "widgets/helper/TitlebarButton.hpp"
@@ -251,8 +253,9 @@ BaseWindow::~BaseWindow()
DebugCount::decrease("BaseWindow");
}
void BaseWindow::setInitialBounds(const QRect &bounds)
void BaseWindow::setInitialBounds(QRect bounds, widgets::BoundsChecking mode)
{
bounds = widgets::checkInitialBounds(bounds, mode);
#ifdef USEWINSDK
this->initalBounds_ = bounds;
#else
@@ -260,7 +263,7 @@ void BaseWindow::setInitialBounds(const QRect &bounds)
#endif
}
QRect BaseWindow::getBounds()
QRect BaseWindow::getBounds() const
{
#ifdef USEWINSDK
return this->currentBounds_;
@@ -444,7 +447,7 @@ QWidget *BaseWindow::getLayoutContainer()
}
}
bool BaseWindow::hasCustomWindowFrame()
bool BaseWindow::hasCustomWindowFrame() const
{
return BaseWindow::supportsCustomWindowFrame() && this->enableCustomFrame_;
}
+3 -3
View File
@@ -45,11 +45,11 @@ public:
QWidget *parent = nullptr);
~BaseWindow() override;
void setInitialBounds(const QRect &bounds);
QRect getBounds();
void setInitialBounds(QRect bounds, widgets::BoundsChecking mode);
QRect getBounds() const;
QWidget *getLayoutContainer();
bool hasCustomWindowFrame();
bool hasCustomWindowFrame() const;
TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style,
std::function<void()> onClicked);
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
+27 -5
View File
@@ -203,13 +203,18 @@ EmoteMap filterEmoteMap(const QString &text,
namespace chatterino {
EmotePopup::EmotePopup(QWidget *parent)
: BasePopup(BaseWindow::EnableCustomFrame, parent)
: BasePopup({BaseWindow::EnableCustomFrame, BaseWindow::DisableLayoutSave},
parent)
, search_(new QLineEdit())
, notebook_(new Notebook(this))
{
// this->setStayInScreenRect(true);
this->moveTo(getIApp()->getWindows()->emotePopupPos(),
widgets::BoundsChecking::DesiredPosition);
auto bounds = getIApp()->getWindows()->emotePopupBounds();
if (bounds.size().isEmpty())
{
bounds.setSize(QSize{300, 500} * this->scale());
}
this->setInitialBounds(bounds, widgets::BoundsChecking::DesiredPosition);
auto *layout = new QVBoxLayout();
this->getLayoutContainer()->setLayout(layout);
@@ -594,10 +599,27 @@ void EmotePopup::filterEmotes(const QString &searchText)
this->searchView_->show();
}
void EmotePopup::saveBounds() const
{
getIApp()->getWindows()->setEmotePopupBounds(this->getBounds());
}
void EmotePopup::resizeEvent(QResizeEvent *event)
{
this->saveBounds();
BasePopup::resizeEvent(event);
}
void EmotePopup::moveEvent(QMoveEvent *event)
{
this->saveBounds();
BasePopup::moveEvent(event);
}
void EmotePopup::closeEvent(QCloseEvent *event)
{
getIApp()->getWindows()->setEmotePopupPos(this->pos());
BaseWindow::closeEvent(event);
this->saveBounds();
BasePopup::closeEvent(event);
}
} // namespace chatterino
+6
View File
@@ -25,6 +25,10 @@ public:
pajlada::Signals::Signal<Link> linkClicked;
protected:
void resizeEvent(QResizeEvent *event) override;
void moveEvent(QMoveEvent *event) override;
private:
ChannelView *globalEmotesView_{};
ChannelView *channelEmotesView_{};
@@ -47,6 +51,8 @@ private:
void filterEmotes(const QString &text);
void addShortcuts() override;
bool eventFilter(QObject *object, QEvent *event) override;
void saveBounds() const;
};
} // namespace chatterino
-2
View File
@@ -309,8 +309,6 @@ void SplitInput::openEmotePopup()
});
}
this->emotePopup_->resize(int(300 * this->emotePopup_->scale()),
int(500 * this->emotePopup_->scale()));
this->emotePopup_->loadChannel(this->split_->getChannel());
this->emotePopup_->show();
this->emotePopup_->raise();