diff options
| author | Felix Ernst <[email protected]> | 2022-04-24 02:34:43 +0200 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2022-08-14 14:42:40 +0000 |
| commit | 402b4a5698f3d12d1848b298c38828d509abfd0d (patch) | |
| tree | 20ce1bccd0f1a92fcdeaef47c745f719b8840558 /src/selectionmode/selectionmodetopbar.cpp | |
| parent | 3b7c05b385dc56fbc0b9ffdd332f8d30e7624d0c (diff) | |
Keep working towards a reviewable state
- Various code improvements
- Smoother animations
- The bottom bar in General Mode only becomes visible if items are
currently selected
- Removed the selection mode action from the default toolbar since
it can already be toggled in various ways
- More documentation
- Some cleaning
Diffstat (limited to 'src/selectionmode/selectionmodetopbar.cpp')
| -rw-r--r-- | src/selectionmode/selectionmodetopbar.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/selectionmode/selectionmodetopbar.cpp b/src/selectionmode/selectionmodetopbar.cpp index 89a4aa03a..83aa8e849 100644 --- a/src/selectionmode/selectionmodetopbar.cpp +++ b/src/selectionmode/selectionmodetopbar.cpp @@ -1,6 +1,6 @@ /* This file is part of the KDE project - SPDX-FileCopyrightText: 2022 Felix Ernst <[email protected]> + SPDX-FileCopyrightText: 2022 Felix Ernst <[email protected]> SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -22,9 +22,6 @@ #include <QStyle> #include <QtGlobal> -#include <type_traits> -#include <iostream> - SelectionModeTopBar::SelectionModeTopBar(QWidget *parent) : QWidget{parent} { @@ -90,29 +87,26 @@ void SelectionModeTopBar::setVisible(bool visible, Animated animated) { Q_ASSERT_X(animated == WithAnimation, "SelectionModeTopBar::setVisible", "This wasn't implemented."); - if (!m_heightAnimation) { - m_heightAnimation = new QPropertyAnimation(this, "maximumHeight"); + if (m_heightAnimation) { + m_heightAnimation->stop(); // deletes because of QAbstractAnimation::DeleteWhenStopped. } - disconnect(m_heightAnimation, &QAbstractAnimation::finished, - this, &QWidget::hide); + m_heightAnimation = new QPropertyAnimation(this, "maximumHeight"); m_heightAnimation->setDuration(2 * style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) * GlobalConfig::animationDurationFactor()); + m_heightAnimation->setStartValue(height()); + m_heightAnimation->setEasingCurve(QEasingCurve::OutCubic); if (visible) { show(); - m_heightAnimation->setStartValue(0); m_heightAnimation->setEndValue(m_preferredHeight); - m_heightAnimation->setEasingCurve(QEasingCurve::OutCubic); } else { - m_heightAnimation->setStartValue(height()); m_heightAnimation->setEndValue(0); - m_heightAnimation->setEasingCurve(QEasingCurve::OutCubic); connect(m_heightAnimation, &QAbstractAnimation::finished, this, &QWidget::hide); } - m_heightAnimation->start(); + m_heightAnimation->start(QAbstractAnimation::DeleteWhenStopped); } void SelectionModeTopBar::resizeEvent(QResizeEvent */* resizeEvent */) |
