mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Remove unused button class
This commit is contained in:
parent
5ca98829f7
commit
409ff22d80
3 changed files with 0 additions and 133 deletions
|
@ -335,7 +335,6 @@ set(SRC_FILES
|
|||
src/ui/Badge.cpp
|
||||
src/ui/DropShadow.cpp
|
||||
src/ui/FlatButton.cpp
|
||||
src/ui/FloatingButton.cpp
|
||||
src/ui/InfoMessage.cpp
|
||||
src/ui/Label.cpp
|
||||
src/ui/LoadingIndicator.cpp
|
||||
|
@ -545,7 +544,6 @@ qt5_wrap_cpp(MOC_HEADERS
|
|||
# UI components
|
||||
src/ui/Badge.h
|
||||
src/ui/FlatButton.h
|
||||
src/ui/FloatingButton.h
|
||||
src/ui/InfoMessage.h
|
||||
src/ui/Label.h
|
||||
src/ui/LoadingIndicator.h
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
#include "FloatingButton.h"
|
||||
|
||||
FloatingButton::FloatingButton(const QIcon &icon, QWidget *parent)
|
||||
: RaisedButton(parent)
|
||||
{
|
||||
setFixedSize(DIAMETER, DIAMETER);
|
||||
setGeometry(buttonGeometry());
|
||||
|
||||
if (parentWidget())
|
||||
parentWidget()->installEventFilter(this);
|
||||
|
||||
setFixedRippleRadius(50);
|
||||
setIcon(icon);
|
||||
raise();
|
||||
}
|
||||
|
||||
QRect
|
||||
FloatingButton::buttonGeometry() const
|
||||
{
|
||||
QWidget *parent = parentWidget();
|
||||
|
||||
if (!parent)
|
||||
return QRect();
|
||||
|
||||
return QRect(parent->width() - (OFFSET_X + DIAMETER),
|
||||
parent->height() - (OFFSET_Y + DIAMETER),
|
||||
DIAMETER,
|
||||
DIAMETER);
|
||||
}
|
||||
|
||||
bool
|
||||
FloatingButton::event(QEvent *event)
|
||||
{
|
||||
if (!parent())
|
||||
return RaisedButton::event(event);
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ParentChange: {
|
||||
parent()->installEventFilter(this);
|
||||
setGeometry(buttonGeometry());
|
||||
break;
|
||||
}
|
||||
case QEvent::ParentAboutToChange: {
|
||||
parent()->installEventFilter(this);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RaisedButton::event(event);
|
||||
}
|
||||
|
||||
bool
|
||||
FloatingButton::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
const QEvent::Type type = event->type();
|
||||
|
||||
if (QEvent::Move == type || QEvent::Resize == type)
|
||||
setGeometry(buttonGeometry());
|
||||
|
||||
return RaisedButton::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void
|
||||
FloatingButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QRect square = QRect(0, 0, DIAMETER, DIAMETER);
|
||||
square.moveCenter(rect().center());
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
brush.setColor(backgroundColor());
|
||||
|
||||
p.setBrush(brush);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(square);
|
||||
|
||||
QRect iconGeometry(0, 0, ICON_SIZE, ICON_SIZE);
|
||||
iconGeometry.moveCenter(square.center());
|
||||
|
||||
QPixmap pixmap = icon().pixmap(QSize(ICON_SIZE, ICON_SIZE));
|
||||
QPainter icon(&pixmap);
|
||||
icon.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
icon.fillRect(pixmap.rect(), foregroundColor());
|
||||
|
||||
p.drawPixmap(iconGeometry, pixmap);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RaisedButton.h"
|
||||
|
||||
constexpr int DIAMETER = 40;
|
||||
constexpr int ICON_SIZE = 18;
|
||||
|
||||
constexpr int OFFSET_X = 30;
|
||||
constexpr int OFFSET_Y = 20;
|
||||
|
||||
class FloatingButton : public RaisedButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FloatingButton(const QIcon &icon, QWidget *parent = nullptr);
|
||||
|
||||
QSize sizeHint() const override { return QSize(DIAMETER, DIAMETER); };
|
||||
QRect buttonGeometry() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
};
|
Loading…
Reference in a new issue