Fixing defects found in the review
[situare] / src / ui / indicatorbutton.cpp
index 6312965..e392bef 100644 (file)
    USA.
 */
 
-#include <QSettings>
-#include <QPainter>
 #include <QDebug>
+#include <QPainter>
+#include <QSettings>
 
-#include "indicatorbutton.h"
-#include "panelcommon.h"
 #include "common.h"
 #include "math.h"
+#include "panelcommon.h"
 
-enum State {OFF, ON};                           ///< Enumerator for led state
-
-const qreal OPACITY = 0.50;                     ///< Opacity of the background in percents
-const int ROUNDING_RADIUS = 9;                  ///< Roundness of the rounded edge
-const int BUTTON_WIDTH = 66;                    ///< Button width
-const int BUTTON_HEIGHT = 66;                   ///< Button height
+#include "indicatorbutton.h"
 
-const qreal M_TO_KM = 1000;                     ///< Meters to kilometers conversion
+enum State {OFF, ON};                       ///< Enumerator for led state
 
 IndicatorButton::IndicatorButton(QWidget *parent)
     : QToolButton(parent),
       m_drawTriangle(false),
       m_direction(0)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
+    const qreal OPACITY = 0.50;
+    const int BUTTON_WIDTH = 66;
+    const int BUTTON_HEIGHT = 66;
+
     m_indicatorLeds[OFF].load(":res/images/gps_position.png");
     m_indicatorLeds[ON].load(":res/images/gps_position_s.png");
+
     setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
 
     // Normal background
     m_normalColor = new QColor(Qt::black);
     m_normalColor->setAlpha(floor(OPACITY * 255));
 
-    // Selected bakcground
+    // Selected background
     m_selectedGradient = new QLinearGradient(0, 0, 0, this->height());
     m_selectedGradient->setColorAt(0.02, QColor(0, 113, 181));
     m_selectedGradient->setColorAt(0.25, QColor(24, 142, 214));
@@ -74,14 +75,11 @@ IndicatorButton::~IndicatorButton()
     delete m_selectedGradient;
 }
 
-void IndicatorButton::setDirection(qreal direction, bool draw)
+const QPoint& IndicatorButton::eventPosition()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_direction = direction;
-    m_drawTriangle = draw;
-
-    update();
+    return m_eventPosition;
 }
 
 void IndicatorButton::mouseMoveEvent(QMouseEvent *event)
@@ -111,17 +109,12 @@ void IndicatorButton::mouseReleaseEvent(QMouseEvent *event)
     event->ignore();
 }
 
-const QPoint& IndicatorButton::eventPosition()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    return m_eventPosition;
-}
-
 void IndicatorButton::paintEvent(QPaintEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const int ROUNDING_RADIUS = 9;
+
     Q_UNUSED(event);
 
     QPainterPath backgroundPath;
@@ -182,3 +175,13 @@ void IndicatorButton::paintEvent(QPaintEvent *event)
     }
 }
 
+void IndicatorButton::setDirection(qreal direction, bool draw)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_direction = direction;
+    m_drawTriangle = draw;
+
+    update();
+}
+