revert: remove OpacityHelper
- remove OpacityHelper - remove all related animation - now bottom toolbar and navigation view are always visible
This commit is contained in:
@@ -45,7 +45,6 @@ set (PPIC_CPP_FILES
|
|||||||
app/graphicsscene.cpp
|
app/graphicsscene.cpp
|
||||||
app/bottombuttongroup.cpp
|
app/bottombuttongroup.cpp
|
||||||
app/navigatorview.cpp
|
app/navigatorview.cpp
|
||||||
app/opacityhelper.cpp
|
|
||||||
app/settings.cpp
|
app/settings.cpp
|
||||||
app/settingsdialog.cpp
|
app/settingsdialog.cpp
|
||||||
app/aboutdialog.cpp
|
app/aboutdialog.cpp
|
||||||
@@ -65,7 +64,6 @@ set (PPIC_HEADER_FILES
|
|||||||
app/graphicsscene.h
|
app/graphicsscene.h
|
||||||
app/bottombuttongroup.h
|
app/bottombuttongroup.h
|
||||||
app/navigatorview.h
|
app/navigatorview.h
|
||||||
app/opacityhelper.h
|
|
||||||
app/settings.h
|
app/settings.h
|
||||||
app/settingsdialog.h
|
app/settingsdialog.h
|
||||||
app/aboutdialog.h
|
app/aboutdialog.h
|
||||||
|
|||||||
@@ -4,15 +4,12 @@
|
|||||||
|
|
||||||
#include "bottombuttongroup.h"
|
#include "bottombuttongroup.h"
|
||||||
|
|
||||||
#include "opacityhelper.h"
|
|
||||||
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
BottomButtonGroup::BottomButtonGroup(const std::vector<QAction *> &actionList, QWidget *parent)
|
BottomButtonGroup::BottomButtonGroup(const std::vector<QAction *> &actionList, QWidget *parent)
|
||||||
: QGroupBox (parent)
|
: QGroupBox (parent)
|
||||||
, m_opacityHelper(new OpacityHelper(this))
|
|
||||||
{
|
{
|
||||||
QHBoxLayout * mainLayout = new QHBoxLayout(this);
|
QHBoxLayout * mainLayout = new QHBoxLayout(this);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
@@ -45,11 +42,6 @@ BottomButtonGroup::BottomButtonGroup(const std::vector<QAction *> &actionList, Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BottomButtonGroup::setOpacity(qreal opacity, bool animated)
|
|
||||||
{
|
|
||||||
m_opacityHelper->setOpacity(opacity, animated);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BottomButtonGroup::addButton(QAbstractButton *button)
|
void BottomButtonGroup::addButton(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
layout()->addWidget(button);
|
layout()->addWidget(button);
|
||||||
|
|||||||
@@ -10,18 +10,13 @@
|
|||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
|
||||||
class OpacityHelper;
|
|
||||||
class BottomButtonGroup : public QGroupBox
|
class BottomButtonGroup : public QGroupBox
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit BottomButtonGroup(const std::vector<QAction *> & actionList, QWidget *parent = nullptr);
|
explicit BottomButtonGroup(const std::vector<QAction *> & actionList, QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setOpacity(qreal opacity, bool animated = true);
|
|
||||||
void addButton(QAbstractButton *button);
|
void addButton(QAbstractButton *button);
|
||||||
|
|
||||||
private:
|
|
||||||
OpacityHelper * m_opacityHelper;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOTTOMBUTTONGROUP_H
|
#endif // BOTTOMBUTTONGROUP_H
|
||||||
|
|||||||
@@ -95,9 +95,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
m_am->actionRotateClockwise
|
m_am->actionRotateClockwise
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
m_bottomButtonGroup->setOpacity(0, false);
|
|
||||||
m_gv->setOpacity(0, false);
|
|
||||||
|
|
||||||
connect(m_pm, &PlaylistManager::totalCountChanged, this, &MainWindow::updateGalleryButtonsVisibility);
|
connect(m_pm, &PlaylistManager::totalCountChanged, this, &MainWindow::updateGalleryButtonsVisibility);
|
||||||
|
|
||||||
connect(m_pm->model(), &PlaylistModel::modelReset, this, std::bind(&MainWindow::galleryCurrent, this, false, false));
|
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)
|
void MainWindow::enterEvent(QEnterEvent *event)
|
||||||
{
|
{
|
||||||
m_bottomButtonGroup->setOpacity(1);
|
|
||||||
m_gv->setOpacity(1);
|
|
||||||
|
|
||||||
return FramelessWindow::enterEvent(event);
|
return FramelessWindow::enterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::leaveEvent(QEvent *event)
|
void MainWindow::leaveEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
m_bottomButtonGroup->setOpacity(0);
|
|
||||||
m_gv->setOpacity(0);
|
|
||||||
|
|
||||||
return FramelessWindow::leaveEvent(event);
|
return FramelessWindow::leaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QGraphicsOpacityEffect;
|
|
||||||
class QGraphicsView;
|
class QGraphicsView;
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "navigatorview.h"
|
#include "navigatorview.h"
|
||||||
|
|
||||||
#include "graphicsview.h"
|
#include "graphicsview.h"
|
||||||
#include "opacityhelper.h"
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -14,7 +13,6 @@
|
|||||||
NavigatorView::NavigatorView(QWidget *parent)
|
NavigatorView::NavigatorView(QWidget *parent)
|
||||||
: QGraphicsView (parent)
|
: QGraphicsView (parent)
|
||||||
, m_viewportRegion(this->rect())
|
, m_viewportRegion(this->rect())
|
||||||
, m_opacityHelper(new OpacityHelper(this))
|
|
||||||
{
|
{
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@@ -28,11 +26,6 @@ void NavigatorView::setMainView(GraphicsView *mainView)
|
|||||||
m_mainView = mainView;
|
m_mainView = mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigatorView::setOpacity(qreal opacity, bool animated)
|
|
||||||
{
|
|
||||||
m_opacityHelper->setOpacity(opacity, animated);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigatorView::updateMainViewportRegion()
|
void NavigatorView::updateMainViewportRegion()
|
||||||
{
|
{
|
||||||
// Use QTimer::singleShot with lambda to delay the update
|
// Use QTimer::singleShot with lambda to delay the update
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
class OpacityHelper;
|
|
||||||
class GraphicsView;
|
class GraphicsView;
|
||||||
class NavigatorView : public QGraphicsView
|
class NavigatorView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@@ -16,7 +15,6 @@ public:
|
|||||||
NavigatorView(QWidget *parent = nullptr);
|
NavigatorView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setMainView(GraphicsView *mainView);
|
void setMainView(GraphicsView *mainView);
|
||||||
void setOpacity(qreal opacity, bool animated = true);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateMainViewportRegion();
|
void updateMainViewportRegion();
|
||||||
@@ -32,7 +30,6 @@ private:
|
|||||||
bool m_mouseDown = false;
|
bool m_mouseDown = false;
|
||||||
QPolygon m_viewportRegion;
|
QPolygon m_viewportRegion;
|
||||||
QGraphicsView *m_mainView = nullptr;
|
QGraphicsView *m_mainView = nullptr;
|
||||||
OpacityHelper *m_opacityHelper = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAVIGATORVIEW_H
|
#endif // NAVIGATORVIEW_H
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#include "opacityhelper.h"
|
|
||||||
|
|
||||||
#include <QGraphicsOpacityEffect>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#ifndef OPACITYHELPER_H
|
|
||||||
#define OPACITYHELPER_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
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
|
|
||||||
Reference in New Issue
Block a user