From 9a18a41b8fcf5a4a30eab740d635423e2f52c1ac Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 3 Jul 2026 16:40:04 +0800 Subject: [PATCH] revert: remove OpacityHelper - remove OpacityHelper - remove all related animation - now bottom toolbar and navigation view are always visible --- CMakeLists.txt | 2 -- app/bottombuttongroup.cpp | 8 -------- app/bottombuttongroup.h | 5 ----- app/mainwindow.cpp | 9 --------- app/mainwindow.h | 1 - app/navigatorview.cpp | 7 ------- app/navigatorview.h | 3 --- app/opacityhelper.cpp | 31 ------------------------------- app/opacityhelper.h | 27 --------------------------- 9 files changed, 93 deletions(-) delete mode 100644 app/opacityhelper.cpp delete mode 100644 app/opacityhelper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2221461..3a4b132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ set (PPIC_CPP_FILES app/graphicsscene.cpp app/bottombuttongroup.cpp app/navigatorview.cpp - app/opacityhelper.cpp app/settings.cpp app/settingsdialog.cpp app/aboutdialog.cpp @@ -65,7 +64,6 @@ set (PPIC_HEADER_FILES app/graphicsscene.h app/bottombuttongroup.h app/navigatorview.h - app/opacityhelper.h app/settings.h app/settingsdialog.h app/aboutdialog.h diff --git a/app/bottombuttongroup.cpp b/app/bottombuttongroup.cpp index 22eb26b..2e5dd49 100644 --- a/app/bottombuttongroup.cpp +++ b/app/bottombuttongroup.cpp @@ -4,15 +4,12 @@ #include "bottombuttongroup.h" -#include "opacityhelper.h" - #include #include #include BottomButtonGroup::BottomButtonGroup(const std::vector &actionList, QWidget *parent) : QGroupBox (parent) - , m_opacityHelper(new OpacityHelper(this)) { QHBoxLayout * mainLayout = new QHBoxLayout(this); mainLayout->setSizeConstraint(QLayout::SetFixedSize); @@ -45,11 +42,6 @@ BottomButtonGroup::BottomButtonGroup(const std::vector &actionList, Q } } -void BottomButtonGroup::setOpacity(qreal opacity, bool animated) -{ - m_opacityHelper->setOpacity(opacity, animated); -} - void BottomButtonGroup::addButton(QAbstractButton *button) { layout()->addWidget(button); diff --git a/app/bottombuttongroup.h b/app/bottombuttongroup.h index 3e84aff..c024598 100644 --- a/app/bottombuttongroup.h +++ b/app/bottombuttongroup.h @@ -10,18 +10,13 @@ #include #include -class OpacityHelper; class BottomButtonGroup : public QGroupBox { Q_OBJECT public: explicit BottomButtonGroup(const std::vector & actionList, QWidget *parent = nullptr); - void setOpacity(qreal opacity, bool animated = true); void addButton(QAbstractButton *button); - -private: - OpacityHelper * m_opacityHelper; }; #endif // BOTTOMBUTTONGROUP_H diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 18351ca..070f342 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -95,9 +95,6 @@ MainWindow::MainWindow(QWidget *parent) m_am->actionRotateClockwise }, this); - m_bottomButtonGroup->setOpacity(0, false); - m_gv->setOpacity(0, false); - connect(m_pm, &PlaylistManager::totalCountChanged, this, &MainWindow::updateGalleryButtonsVisibility); connect(m_pm->model(), &PlaylistModel::modelReset, this, std::bind(&MainWindow::galleryCurrent, this, false, false)); @@ -273,17 +270,11 @@ void MainWindow::showEvent(QShowEvent *event) void MainWindow::enterEvent(QEnterEvent *event) { - m_bottomButtonGroup->setOpacity(1); - m_gv->setOpacity(1); - return FramelessWindow::enterEvent(event); } void MainWindow::leaveEvent(QEvent *event) { - m_bottomButtonGroup->setOpacity(0); - m_gv->setOpacity(0); - return FramelessWindow::leaveEvent(event); } diff --git a/app/mainwindow.h b/app/mainwindow.h index bb4aca2..ae391bc 100644 --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -12,7 +12,6 @@ #include QT_BEGIN_NAMESPACE -class QGraphicsOpacityEffect; class QGraphicsView; class QFileSystemWatcher; QT_END_NAMESPACE diff --git a/app/navigatorview.cpp b/app/navigatorview.cpp index e0e7e12..9a3cef7 100644 --- a/app/navigatorview.cpp +++ b/app/navigatorview.cpp @@ -5,7 +5,6 @@ #include "navigatorview.h" #include "graphicsview.h" -#include "opacityhelper.h" #include #include @@ -14,7 +13,6 @@ NavigatorView::NavigatorView(QWidget *parent) : QGraphicsView (parent) , m_viewportRegion(this->rect()) - , m_opacityHelper(new OpacityHelper(this)) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -28,11 +26,6 @@ void NavigatorView::setMainView(GraphicsView *mainView) m_mainView = mainView; } -void NavigatorView::setOpacity(qreal opacity, bool animated) -{ - m_opacityHelper->setOpacity(opacity, animated); -} - void NavigatorView::updateMainViewportRegion() { // Use QTimer::singleShot with lambda to delay the update diff --git a/app/navigatorview.h b/app/navigatorview.h index 96b7a6b..e3b894e 100644 --- a/app/navigatorview.h +++ b/app/navigatorview.h @@ -7,7 +7,6 @@ #include -class OpacityHelper; class GraphicsView; class NavigatorView : public QGraphicsView { @@ -16,7 +15,6 @@ public: NavigatorView(QWidget *parent = nullptr); void setMainView(GraphicsView *mainView); - void setOpacity(qreal opacity, bool animated = true); public slots: void updateMainViewportRegion(); @@ -32,7 +30,6 @@ private: bool m_mouseDown = false; QPolygon m_viewportRegion; QGraphicsView *m_mainView = nullptr; - OpacityHelper *m_opacityHelper = nullptr; }; #endif // NAVIGATORVIEW_H diff --git a/app/opacityhelper.cpp b/app/opacityhelper.cpp deleted file mode 100644 index f81efe0..0000000 --- a/app/opacityhelper.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Gary Wang -// -// SPDX-License-Identifier: MIT - -#include "opacityhelper.h" - -#include -#include - -OpacityHelper::OpacityHelper(QWidget *parent) - : QObject(parent) - , m_opacityFx(new QGraphicsOpacityEffect(parent)) - , m_opacityAnimation(new QPropertyAnimation(m_opacityFx, "opacity")) -{ - parent->setGraphicsEffect(m_opacityFx); - - m_opacityAnimation->setDuration(300); -} - -void OpacityHelper::setOpacity(qreal opacity, bool animated) -{ - if (!animated) { - m_opacityFx->setOpacity(opacity); - return; - } - - m_opacityAnimation->stop(); - m_opacityAnimation->setStartValue(m_opacityFx->opacity()); - m_opacityAnimation->setEndValue(opacity); - m_opacityAnimation->start(); -} diff --git a/app/opacityhelper.h b/app/opacityhelper.h deleted file mode 100644 index 7e4647b..0000000 --- a/app/opacityhelper.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Gary Wang -// -// SPDX-License-Identifier: MIT - -#ifndef OPACITYHELPER_H -#define OPACITYHELPER_H - -#include - -QT_BEGIN_NAMESPACE -class QGraphicsOpacityEffect; -class QPropertyAnimation; -QT_END_NAMESPACE - -class OpacityHelper : QObject -{ -public: - OpacityHelper(QWidget * parent); - - void setOpacity(qreal opacity, bool animated = true); - -protected: - QGraphicsOpacityEffect * m_opacityFx; - QPropertyAnimation * m_opacityAnimation; -}; - -#endif // OPACITYHELPER_H