From 402b4a5698f3d12d1848b298c38828d509abfd0d Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Sun, 24 Apr 2022 02:34:43 +0200 Subject: 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 --- src/selectionmode/selectionmodetopbar.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/selectionmode/selectionmodetopbar.cpp') 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 + SPDX-FileCopyrightText: 2022 Felix Ernst SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -22,9 +22,6 @@ #include #include -#include -#include - 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 */) -- cgit v1.3