diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-09-18 00:22:33 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-09-18 00:45:50 +0200 |
commit | cfca7157b98c9dc8e0852fe6484bc3f75008af7d (patch) | |
tree | 32b92340908a9374214ec7b84c1fac7ea338f56d /src/ui/FloatingButton.cpp | |
parent | Merge pull request #728 from Thulinma/goto (diff) | |
download | nheko-cfca7157b98c9dc8e0852fe6484bc3f75008af7d.tar.xz |
Change indentation to 4 spaces
Diffstat (limited to 'src/ui/FloatingButton.cpp')
-rw-r--r-- | src/ui/FloatingButton.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/ui/FloatingButton.cpp b/src/ui/FloatingButton.cpp index 95b6ae1d..3f88e313 100644 --- a/src/ui/FloatingButton.cpp +++ b/src/ui/FloatingButton.cpp @@ -10,91 +10,91 @@ FloatingButton::FloatingButton(const QIcon &icon, QWidget *parent) : RaisedButton(parent) { - setFixedSize(DIAMETER, DIAMETER); - setGeometry(buttonGeometry()); + setFixedSize(DIAMETER, DIAMETER); + setGeometry(buttonGeometry()); - if (parentWidget()) - parentWidget()->installEventFilter(this); + if (parentWidget()) + parentWidget()->installEventFilter(this); - setFixedRippleRadius(50); - setIcon(icon); - raise(); + setFixedRippleRadius(50); + setIcon(icon); + raise(); } QRect FloatingButton::buttonGeometry() const { - QWidget *parent = parentWidget(); + QWidget *parent = parentWidget(); - if (!parent) - return QRect(); + if (!parent) + return QRect(); - return QRect(parent->width() - (OFFSET_X + DIAMETER), - parent->height() - (OFFSET_Y + DIAMETER), - DIAMETER, - DIAMETER); + 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; - } - + 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(); + const QEvent::Type type = event->type(); - if (QEvent::Move == type || QEvent::Resize == type) - setGeometry(buttonGeometry()); + if (QEvent::Move == type || QEvent::Resize == type) + setGeometry(buttonGeometry()); - return RaisedButton::eventFilter(obj, event); + return RaisedButton::eventFilter(obj, event); } void FloatingButton::paintEvent(QPaintEvent *event) { - Q_UNUSED(event); + Q_UNUSED(event); - QRect square = QRect(0, 0, DIAMETER, DIAMETER); - square.moveCenter(rect().center()); + QRect square = QRect(0, 0, DIAMETER, DIAMETER); + square.moveCenter(rect().center()); - QPainter p(this); - p.setRenderHints(QPainter::Antialiasing); + QPainter p(this); + p.setRenderHints(QPainter::Antialiasing); - QBrush brush; - brush.setStyle(Qt::SolidPattern); - brush.setColor(backgroundColor()); + QBrush brush; + brush.setStyle(Qt::SolidPattern); + brush.setColor(backgroundColor()); - p.setBrush(brush); - p.setPen(Qt::NoPen); - p.drawEllipse(square); + p.setBrush(brush); + p.setPen(Qt::NoPen); + p.drawEllipse(square); - QRect iconGeometry(0, 0, ICON_SIZE, ICON_SIZE); - iconGeometry.moveCenter(square.center()); + 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()); + 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); + p.drawPixmap(iconGeometry, pixmap); } |