refactor: fully remove ToolButton because no one require it.
- fully remove ToolButton. - make loadHidpiIcon as a static function in ActionManager because no outside function may call it.
This commit is contained in:
@@ -46,7 +46,6 @@ set (PPIC_CPP_FILES
|
||||
app/bottombuttongroup.cpp
|
||||
app/navigatorview.cpp
|
||||
app/opacityhelper.cpp
|
||||
app/toolbutton.cpp
|
||||
app/settings.cpp
|
||||
app/settingsdialog.cpp
|
||||
app/aboutdialog.cpp
|
||||
@@ -67,7 +66,6 @@ set (PPIC_HEADER_FILES
|
||||
app/bottombuttongroup.h
|
||||
app/navigatorview.h
|
||||
app/opacityhelper.h
|
||||
app/toolbutton.h
|
||||
app/settings.h
|
||||
app/settingsdialog.h
|
||||
app/aboutdialog.h
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
|
||||
QIcon ActionManager::loadHidpiIcon(const QString &resp, QSize sz)
|
||||
static QIcon loadHidpiIcon(const QString &resp, QSize sz = QSize(32, 32))
|
||||
{
|
||||
QSvgRenderer r(resp);
|
||||
QPixmap pm = QPixmap(sz * qApp->devicePixelRatio());
|
||||
@@ -34,7 +34,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
||||
auto create_action = [] (QWidget *w, QAction **a, QString i, QString an, bool iconFromTheme = false) {
|
||||
*a = new QAction(w);
|
||||
if (!i.isNull())
|
||||
(*a)->setIcon(iconFromTheme ? QIcon::fromTheme(i) : ActionManager::loadHidpiIcon(i));
|
||||
(*a)->setIcon(iconFromTheme ? QIcon::fromTheme(i) : loadHidpiIcon(i));
|
||||
(*a)->setObjectName(an);
|
||||
w->addAction(*a);
|
||||
};
|
||||
|
||||
@@ -21,8 +21,6 @@ public:
|
||||
void setupShortcuts();
|
||||
void enablePrevNextPictureAction(bool enablePrevPictureAction, bool enableNextPictureAction);
|
||||
|
||||
static QIcon loadHidpiIcon(const QString &resp, QSize sz = QSize(32, 32));
|
||||
|
||||
public:
|
||||
QAction *actionOpen;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "toolbutton.h"
|
||||
#include "bottombuttongroup.h"
|
||||
#include "graphicsview.h"
|
||||
#include "navigatorview.h"
|
||||
|
||||
@@ -19,7 +19,6 @@ QT_END_NAMESPACE
|
||||
|
||||
class ActionManager;
|
||||
class PlaylistManager;
|
||||
class ToolButton;
|
||||
class GraphicsView;
|
||||
class NavigatorView;
|
||||
class BottomButtonGroup;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "toolbutton.h"
|
||||
|
||||
#include "actionmanager.h"
|
||||
#include "opacityhelper.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
ToolButton::ToolButton(bool hoverColor, QWidget *parent)
|
||||
: QPushButton(parent)
|
||||
, m_opacityHelper(new OpacityHelper(this))
|
||||
{
|
||||
setFlat(true);
|
||||
QString qss = "QPushButton {"
|
||||
"background: transparent;"
|
||||
"}";
|
||||
if (hoverColor) {
|
||||
qss += "QPushButton:hover {"
|
||||
"background: red;"
|
||||
"}";
|
||||
}
|
||||
setStyleSheet(qss);
|
||||
}
|
||||
|
||||
void ToolButton::setIconResourcePath(const QString &iconp)
|
||||
{
|
||||
this->setIcon(ActionManager::loadHidpiIcon(iconp, this->iconSize()));
|
||||
}
|
||||
|
||||
void ToolButton::setOpacity(qreal opacity, bool animated)
|
||||
{
|
||||
m_opacityHelper->setOpacity(opacity, animated);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#ifndef TOOLBUTTON_H
|
||||
#define TOOLBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
class OpacityHelper;
|
||||
class ToolButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ToolButton(bool hoverColor = false, QWidget * parent = nullptr);
|
||||
void setIconResourcePath(const QString &iconp);
|
||||
|
||||
public slots:
|
||||
void setOpacity(qreal opacity, bool animated = true);
|
||||
|
||||
private:
|
||||
OpacityHelper * m_opacityHelper;
|
||||
};
|
||||
|
||||
#endif // TOOLBUTTON_H
|
||||
Reference in New Issue
Block a user