summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-01-31 06:12:02 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-01-31 15:11:21 +0100
commit4cd260bfcfcbf88a6efb8bf5a1abf3d37fb06463 (patch)
tree2d39fbdb1acdf678fa9d28f054ac08d44c91a4cf /src/ui
parentAdd next/prev room shortcuts (diff)
downloadnheko-4cd260bfcfcbf88a6efb8bf5a1abf3d37fb06463.tar.xz
Optimize includes a bit
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/DropShadow.cpp110
-rw-r--r--src/ui/DropShadow.h100
-rw-r--r--src/ui/FlatButton.cpp2
-rw-r--r--src/ui/FlatButton.h2
-rw-r--r--src/ui/FloatingButton.cpp1
-rw-r--r--src/ui/LoadingIndicator.cpp5
-rw-r--r--src/ui/LoadingIndicator.h6
-rw-r--r--src/ui/OverlayWidget.cpp4
-rw-r--r--src/ui/OverlayWidget.h4
9 files changed, 127 insertions, 107 deletions
diff --git a/src/ui/DropShadow.cpp b/src/ui/DropShadow.cpp
new file mode 100644
index 00000000..93baa02d
--- /dev/null
+++ b/src/ui/DropShadow.cpp
@@ -0,0 +1,110 @@
+#include "DropShadow.h"
+
+#include <QLinearGradient>
+#include <QPainter>
+
+
+        void DropShadow::draw(QPainter &painter,
+                         qint16 margin,
+                         qreal radius,
+                         QColor start,
+                         QColor end,
+                         qreal startPosition,
+                         qreal endPosition0,
+                         qreal endPosition1,
+                         qreal width,
+                         qreal height)
+        {
+                painter.setPen(Qt::NoPen);
+
+                QLinearGradient gradient;
+                gradient.setColorAt(startPosition, start);
+                gradient.setColorAt(endPosition0, end);
+
+                // Right
+                QPointF right0(width - margin, height / 2);
+                QPointF right1(width, height / 2);
+                gradient.setStart(right0);
+                gradient.setFinalStop(right1);
+                painter.setBrush(QBrush(gradient));
+                // Deprecated in 5.13: painter.drawRoundRect(
+                //  QRectF(QPointF(width - margin * radius, margin), QPointF(width, height -
+                //  margin)), 0.0, 0.0);
+                painter.drawRoundedRect(
+                  QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
+                  0.0,
+                  0.0);
+
+                // Left
+                QPointF left0(margin, height / 2);
+                QPointF left1(0, height / 2);
+                gradient.setStart(left0);
+                gradient.setFinalStop(left1);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(
+                  QRectF(QPointF(margin * radius, margin), QPointF(0, height - margin)), 0.0, 0.0);
+
+                // Top
+                QPointF top0(width / 2, margin);
+                QPointF top1(width / 2, 0);
+                gradient.setStart(top0);
+                gradient.setFinalStop(top1);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(
+                  QRectF(QPointF(width - margin, 0), QPointF(margin, margin)), 0.0, 0.0);
+
+                // Bottom
+                QPointF bottom0(width / 2, height - margin);
+                QPointF bottom1(width / 2, height);
+                gradient.setStart(bottom0);
+                gradient.setFinalStop(bottom1);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(
+                  QRectF(QPointF(margin, height - margin), QPointF(width - margin, height)),
+                  0.0,
+                  0.0);
+
+                // BottomRight
+                QPointF bottomright0(width - margin, height - margin);
+                QPointF bottomright1(width, height);
+                gradient.setStart(bottomright0);
+                gradient.setFinalStop(bottomright1);
+                gradient.setColorAt(endPosition1, end);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(QRectF(bottomright0, bottomright1), 0.0, 0.0);
+
+                // BottomLeft
+                QPointF bottomleft0(margin, height - margin);
+                QPointF bottomleft1(0, height);
+                gradient.setStart(bottomleft0);
+                gradient.setFinalStop(bottomleft1);
+                gradient.setColorAt(endPosition1, end);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0);
+
+                // TopLeft
+                QPointF topleft0(margin, margin);
+                QPointF topleft1(0, 0);
+                gradient.setStart(topleft0);
+                gradient.setFinalStop(topleft1);
+                gradient.setColorAt(endPosition1, end);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(QRectF(topleft0, topleft1), 0.0, 0.0);
+
+                // TopRight
+                QPointF topright0(width - margin, margin);
+                QPointF topright1(width, 0);
+                gradient.setStart(topright0);
+                gradient.setFinalStop(topright1);
+                gradient.setColorAt(endPosition1, end);
+                painter.setBrush(QBrush(gradient));
+                painter.drawRoundedRect(QRectF(topright0, topright1), 0.0, 0.0);
+
+                // Widget
+                painter.setBrush(QBrush("#FFFFFF"));
+                painter.setRenderHint(QPainter::Antialiasing);
+                painter.drawRoundedRect(
+                  QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)),
+                  radius,
+                  radius);
+        }
diff --git a/src/ui/DropShadow.h b/src/ui/DropShadow.h
index 60fc697b..6997e1a0 100644
--- a/src/ui/DropShadow.h
+++ b/src/ui/DropShadow.h
@@ -1,8 +1,8 @@
 #pragma once
 
 #include <QColor>
-#include <QLinearGradient>
-#include <QPainter>
+
+class QPainter;
 
 class DropShadow
 {
@@ -16,99 +16,5 @@ public:
                          qreal endPosition0,
                          qreal endPosition1,
                          qreal width,
-                         qreal height)
-        {
-                painter.setPen(Qt::NoPen);
-
-                QLinearGradient gradient;
-                gradient.setColorAt(startPosition, start);
-                gradient.setColorAt(endPosition0, end);
-
-                // Right
-                QPointF right0(width - margin, height / 2);
-                QPointF right1(width, height / 2);
-                gradient.setStart(right0);
-                gradient.setFinalStop(right1);
-                painter.setBrush(QBrush(gradient));
-                // Deprecated in 5.13: painter.drawRoundRect(
-                //  QRectF(QPointF(width - margin * radius, margin), QPointF(width, height -
-                //  margin)), 0.0, 0.0);
-                painter.drawRoundedRect(
-                  QRectF(QPointF(width - margin * radius, margin), QPointF(width, height - margin)),
-                  0.0,
-                  0.0);
-
-                // Left
-                QPointF left0(margin, height / 2);
-                QPointF left1(0, height / 2);
-                gradient.setStart(left0);
-                gradient.setFinalStop(left1);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(
-                  QRectF(QPointF(margin * radius, margin), QPointF(0, height - margin)), 0.0, 0.0);
-
-                // Top
-                QPointF top0(width / 2, margin);
-                QPointF top1(width / 2, 0);
-                gradient.setStart(top0);
-                gradient.setFinalStop(top1);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(
-                  QRectF(QPointF(width - margin, 0), QPointF(margin, margin)), 0.0, 0.0);
-
-                // Bottom
-                QPointF bottom0(width / 2, height - margin);
-                QPointF bottom1(width / 2, height);
-                gradient.setStart(bottom0);
-                gradient.setFinalStop(bottom1);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(
-                  QRectF(QPointF(margin, height - margin), QPointF(width - margin, height)),
-                  0.0,
-                  0.0);
-
-                // BottomRight
-                QPointF bottomright0(width - margin, height - margin);
-                QPointF bottomright1(width, height);
-                gradient.setStart(bottomright0);
-                gradient.setFinalStop(bottomright1);
-                gradient.setColorAt(endPosition1, end);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(QRectF(bottomright0, bottomright1), 0.0, 0.0);
-
-                // BottomLeft
-                QPointF bottomleft0(margin, height - margin);
-                QPointF bottomleft1(0, height);
-                gradient.setStart(bottomleft0);
-                gradient.setFinalStop(bottomleft1);
-                gradient.setColorAt(endPosition1, end);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(QRectF(bottomleft0, bottomleft1), 0.0, 0.0);
-
-                // TopLeft
-                QPointF topleft0(margin, margin);
-                QPointF topleft1(0, 0);
-                gradient.setStart(topleft0);
-                gradient.setFinalStop(topleft1);
-                gradient.setColorAt(endPosition1, end);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(QRectF(topleft0, topleft1), 0.0, 0.0);
-
-                // TopRight
-                QPointF topright0(width - margin, margin);
-                QPointF topright1(width, 0);
-                gradient.setStart(topright0);
-                gradient.setFinalStop(topright1);
-                gradient.setColorAt(endPosition1, end);
-                painter.setBrush(QBrush(gradient));
-                painter.drawRoundedRect(QRectF(topright0, topright1), 0.0, 0.0);
-
-                // Widget
-                painter.setBrush(QBrush("#FFFFFF"));
-                painter.setRenderHint(QPainter::Antialiasing);
-                painter.drawRoundedRect(
-                  QRectF(QPointF(margin, margin), QPointF(width - margin, height - margin)),
-                  radius,
-                  radius);
-        }
+                         qreal height);
 };
diff --git a/src/ui/FlatButton.cpp b/src/ui/FlatButton.cpp
index a828f582..6660c58d 100644
--- a/src/ui/FlatButton.cpp
+++ b/src/ui/FlatButton.cpp
@@ -2,6 +2,8 @@
 #include <QFontDatabase>
 #include <QIcon>
 #include <QMouseEvent>
+#include <QPaintEvent>
+#include <QPainter>
 #include <QPainterPath>
 #include <QResizeEvent>
 #include <QSignalTransition>
diff --git a/src/ui/FlatButton.h b/src/ui/FlatButton.h
index 9c2bf425..d29903c2 100644
--- a/src/ui/FlatButton.h
+++ b/src/ui/FlatButton.h
@@ -1,7 +1,5 @@
 #pragma once
 
-#include <QPaintEvent>
-#include <QPainter>
 #include <QPushButton>
 #include <QStateMachine>
 
diff --git a/src/ui/FloatingButton.cpp b/src/ui/FloatingButton.cpp
index 74dcd482..f3a09ccd 100644
--- a/src/ui/FloatingButton.cpp
+++ b/src/ui/FloatingButton.cpp
@@ -1,3 +1,4 @@
+#include <QPainter>
 #include <QPainterPath>
 
 #include "FloatingButton.h"
diff --git a/src/ui/LoadingIndicator.cpp b/src/ui/LoadingIndicator.cpp
index c8337089..d2b1240d 100644
--- a/src/ui/LoadingIndicator.cpp
+++ b/src/ui/LoadingIndicator.cpp
@@ -1,7 +1,8 @@
 #include "LoadingIndicator.h"
 
-#include <QPoint>
-#include <QtGlobal>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QTimer>
 
 LoadingIndicator::LoadingIndicator(QWidget *parent)
   : QWidget(parent)
diff --git a/src/ui/LoadingIndicator.h b/src/ui/LoadingIndicator.h
index e8de0aec..1585098e 100644
--- a/src/ui/LoadingIndicator.h
+++ b/src/ui/LoadingIndicator.h
@@ -1,11 +1,11 @@
 #pragma once
 
 #include <QColor>
-#include <QPaintEvent>
-#include <QPainter>
-#include <QTimer>
 #include <QWidget>
 
+class QPainter;
+class QTimer;
+class QPaintEvent;
 class LoadingIndicator : public QWidget
 {
         Q_OBJECT
diff --git a/src/ui/OverlayWidget.cpp b/src/ui/OverlayWidget.cpp
index ccac0116..a32d86b6 100644
--- a/src/ui/OverlayWidget.cpp
+++ b/src/ui/OverlayWidget.cpp
@@ -1,5 +1,7 @@
 #include "OverlayWidget.h"
-#include <QEvent>
+
+#include <QPainter>
+#include <QStyleOption>
 
 OverlayWidget::OverlayWidget(QWidget *parent)
   : QWidget(parent)
diff --git a/src/ui/OverlayWidget.h b/src/ui/OverlayWidget.h
index 6662479d..ed3ef52d 100644
--- a/src/ui/OverlayWidget.h
+++ b/src/ui/OverlayWidget.h
@@ -1,10 +1,10 @@
 #pragma once
 
 #include <QEvent>
-#include <QPainter>
-#include <QStyleOption>
 #include <QWidget>
 
+class QPainter;
+
 class OverlayWidget : public QWidget
 {
         Q_OBJECT