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

Fix: tabs move animation for duplicated tabs #5426

Merged
merged 7 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Minor: Colored usernames now update on the fly when changing the "Color @usernames" setting. (#5300)
- Minor: Added `flags.action` filter variable, allowing you to filter on `/me` messages. (#5397)
- Minor: Added the ability to duplicate tabs. (#5277)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed a crash that could occur when logging was enabled in IRC servers that were removed. (#5419)
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
Expand Down
23 changes: 13 additions & 10 deletions src/widgets/helper/NotebookTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "widgets/splits/SplitContainer.hpp"

#include <boost/bind/bind.hpp>
#include <QAbstractAnimation>
#include <QApplication>
#include <QDebug>
#include <QDialogButtonBox>
Expand Down Expand Up @@ -407,30 +408,32 @@ void NotebookTab::hideTabXChanged()
this->update();
}

void NotebookTab::moveAnimated(QPoint pos, bool animated)
void NotebookTab::moveAnimated(QPoint targetPos, bool animated)
kornes marked this conversation as resolved.
Show resolved Hide resolved
kornes marked this conversation as resolved.
Show resolved Hide resolved
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 "QPoint" is directly included [misc-include-cleaner]

src/widgets/helper/NotebookTab.cpp:26:

+ #include <qpoint.h>

{
this->positionAnimationDesiredPoint_ = pos;
this->positionAnimationDesiredPoint_ = targetPos;

QWidget *w = this->window();

if ((w != nullptr && !w->isVisible()) || !animated ||
!this->positionChangedAnimationRunning_)
if (this->pos() == targetPos)
{
this->move(pos);
return;
}

this->positionChangedAnimationRunning_ = true;
if (!animated || !this->notebook_->isVisible())
{
this->move(targetPos);
return;
}

if (this->positionChangedAnimation_.endValue() == pos)
if (this->positionChangedAnimation_.state() ==
QAbstractAnimation::Running &&
kornes marked this conversation as resolved.
Show resolved Hide resolved
kornes marked this conversation as resolved.
Show resolved Hide resolved
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 "QAbstractAnimation" is directly included [misc-include-cleaner]

src/widgets/helper/NotebookTab.cpp:26:

+ #include <qabstractanimation.h>

this->positionChangedAnimation_.endValue() == targetPos)
{
return;
}

this->positionChangedAnimation_.stop();
this->positionChangedAnimation_.setDuration(75);
this->positionChangedAnimation_.setStartValue(this->pos());
this->positionChangedAnimation_.setEndValue(pos);
this->positionChangedAnimation_.setEndValue(targetPos);
this->positionChangedAnimation_.start();
}

Expand Down
3 changes: 1 addition & 2 deletions src/widgets/helper/NotebookTab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class NotebookTab : public Button
void setHighlightsEnabled(const bool &newVal);
bool hasHighlightsEnabled() const;

void moveAnimated(QPoint pos, bool animated = true);
void moveAnimated(QPoint targetPos, bool animated = true);
kornes marked this conversation as resolved.
Show resolved Hide resolved
kornes marked this conversation as resolved.
Show resolved Hide resolved
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 "QPoint" is directly included [misc-include-cleaner]

src/widgets/helper/NotebookTab.hpp:10:

+ #include <qpoint.h>


QRect getDesiredRect() const;
void hideTabXChanged();
Expand Down Expand Up @@ -108,7 +108,6 @@ class NotebookTab : public Button
int normalTabWidthForHeight(int height) const;

QPropertyAnimation positionChangedAnimation_;
bool positionChangedAnimationRunning_ = false;
QPoint positionAnimationDesiredPoint_;

Notebook *notebook_;
Expand Down
Loading