Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 10 commits into from
Jun 1, 2024

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented May 21, 2024

I don't know if this PR completely resolves #5414, but it does fix some bugs related to Qt's frameMargins that are added even though we're a frameless window (probably a Qt bug - I'll try to reproduce and report it). As mentioned in #5414, the emote-popup doesn't remember its position if the main window is closed while the popup is open. This PR fixes that bug as well.

As mentioned in #5414 (comment), saving the width and height of the popup in addition to its position is reasonable. The position is now remembered correctly without Qt's invisible margins (geometry doesn't have that "bug"). The only tiny issue I can see is closing Chatterino with the popup open can cause the position to be off by a few pixels because of the delayed bounds on Windows, however, I don't really think this is a major issue.

Fixes #5414.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
@Nerixyz Nerixyz changed the title fix(emote-popup): account for Qt's frameMargins and save when moving feat(emote-popup): save size of popup May 21, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/common/WindowDescriptors.hpp Show resolved Hide resolved
src/singletons/WindowManager.cpp Show resolved Hide resolved
src/singletons/WindowManager.hpp Show resolved Hide resolved
src/util/WidgetHelpers.cpp Show resolved Hide resolved
src/util/WidgetHelpers.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/common/WindowDescriptors.hpp Show resolved Hide resolved
src/singletons/WindowManager.cpp Show resolved Hide resolved
src/singletons/WindowManager.hpp Show resolved Hide resolved
src/util/WidgetHelpers.cpp Show resolved Hide resolved
src/util/WidgetHelpers.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the emote popup is created (SplitInput.cpp), we call resize - that call needs to be removed now

src/widgets/dialogs/EmotePopup.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/common/WindowDescriptors.hpp Show resolved Hide resolved
src/singletons/WindowManager.cpp Show resolved Hide resolved
src/singletons/WindowManager.hpp Show resolved Hide resolved
src/util/WidgetHelpers.cpp Show resolved Hide resolved
src/util/WidgetHelpers.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.cpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
src/widgets/dialogs/EmotePopup.hpp Show resolved Hide resolved
@pajlada pajlada enabled auto-merge (squash) June 1, 2024 10:16
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

@@ -98,7 +98,7 @@ class WindowLayout
{
public:
// A complete window layout has a single emote popup position that is shared among all windows
QPoint emotePopupPos_;
QRect emotePopupBounds_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for member 'emotePopupBounds_' [readability-identifier-naming]

Suggested change
QRect emotePopupBounds_;
QRect emotePopupBounds;

@@ -328,14 +328,18 @@ void WindowManager::scrollToMessage(const MessagePtr &message)
this->scrollToMessageSignal.invoke(message);
}

QPoint WindowManager::emotePopupPos()
QRect WindowManager::emotePopupBounds() const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QRect" is directly included [misc-include-cleaner]

src/singletons/WindowManager.cpp:5:

- #include "debug/AssertInGuiThread.hpp"
+ #include "common/WindowDescriptors.hpp"
+ #include "debug/AssertInGuiThread.hpp"

@@ -99,8 +99,8 @@ class WindowManager final : public Singleton
*/
void scrollToMessage(const MessagePtr &message);

QPoint emotePopupPos();
void setEmotePopupPos(QPoint pos);
QRect emotePopupBounds() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QRect" is directly included [misc-include-cleaner]

src/singletons/WindowManager.hpp:4:

- #include "widgets/splits/SplitContainer.hpp"
+ #include "common/WindowDescriptors.hpp"
+ #include "widgets/splits/SplitContainer.hpp"

@@ -8,8 +8,7 @@

namespace {

/// Move the `window` into the `screen` geometry if it's not already in there.
void moveWithinScreen(QWidget *window, QScreen *screen, QPoint point)
QPoint applyBounds(QScreen *screen, QPoint point, QSize frameSize, int height)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QSize" is directly included [misc-include-cleaner]

src/util/WidgetHelpers.cpp:7:

+ #include <qsize.h>

}
break;
default:
assert(false && "Invalid bounds checking mode");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "assert" is directly included [misc-include-cleaner]

src/util/WidgetHelpers.cpp:7:

+ #include <cassert>

{
bounds.setSize(QSize{300, 500} * this->scale());
}
this->setInitialBounds(bounds, widgets::BoundsChecking::DesiredPosition);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "chatterino::widgets::BoundsChecking" is directly included [misc-include-cleaner]

src/widgets/dialogs/EmotePopup.cpp:20:

- #include "widgets/helper/ChannelView.hpp"
+ #include "util/WidgetHelpers.hpp"
+ #include "widgets/helper/ChannelView.hpp"

getIApp()->getWindows()->setEmotePopupBounds(this->getBounds());
}

void EmotePopup::resizeEvent(QResizeEvent *event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QResizeEvent" is directly included [misc-include-cleaner]

void EmotePopup::resizeEvent(QResizeEvent *event)
                             ^

BasePopup::resizeEvent(event);
}

void EmotePopup::moveEvent(QMoveEvent *event)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QMoveEvent" is directly included [misc-include-cleaner]

void EmotePopup::moveEvent(QMoveEvent *event)
                           ^

@@ -25,6 +25,10 @@ class EmotePopup : public BasePopup

pajlada::Signals::Signal<Link> linkClicked;

protected:
void resizeEvent(QResizeEvent *event) override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QResizeEvent" is directly included [misc-include-cleaner]

    void resizeEvent(QResizeEvent *event) override;
                     ^

@@ -25,6 +25,10 @@

pajlada::Signals::Signal<Link> linkClicked;

protected:
void resizeEvent(QResizeEvent *event) override;
void moveEvent(QMoveEvent *event) override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "QMoveEvent" is directly included [misc-include-cleaner]

    void moveEvent(QMoveEvent *event) override;
                   ^

@pajlada pajlada merged commit 65bfec9 into Chatterino:master Jun 1, 2024
17 checks passed
@Nerixyz Nerixyz deleted the fix/emote-window-slide branch June 1, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emote window position isnt saved after restarting Chatterino
2 participants