#include <QSettings>
#include "indicatorbuttonpanel.h"
-
#include "common.h"
#include "panelcommon.h"
#include "indicatorbutton.h"
-const int ROUNDING_RADIUS = 9; ///< Roundness of the background edges
+const int ROUNDING_RADIUS = 9; ///< Roundness of the background edges
+const qreal OPACITY = 0.50; ///< Opacity of the background in percents
IndicatorButtonPanel::IndicatorButtonPanel(QWidget *parent)
: QWidget(parent),
m_isDraggable(false),
- m_indicatorButton(0)
+ m_indicatorButton(0),
+ m_distanceText("")
{
qDebug() << __PRETTY_FUNCTION__;
- QGridLayout *gridLayout = new QGridLayout(this);
-
+ QVBoxLayout *verticalLayout = new QVBoxLayout;
+ setLayout(verticalLayout);
+ verticalLayout->setContentsMargins(0, 0, 0, 0);
+ verticalLayout->setSpacing(5);
m_indicatorButton = new IndicatorButton(this);
m_distanceTextLabel = new QLabel();
- m_distanceTextLabel->setFixedWidth(85);
- m_distanceTextLabel->setFrameStyle(QFrame::Panel | QFrame::Raised);
m_distanceTextLabel->setFont(QFont(NOKIA_FONT_SMALL));
- m_distanceTextLabel->setText("<font color='black'> 88888 km");
+ m_distanceTextLabel->setText(m_distanceText);
+ m_distanceTextLabel->setAlignment(Qt::AlignHCenter);
+ m_distanceTextLabel->setContentsMargins(0, 0, 0, 0);
- gridLayout->addWidget(m_indicatorButton, 0, 0);
- gridLayout->addWidget(m_distanceTextLabel, 1, 0);
- setFixedSize(85, 100);
+ m_normalColor = new QColor(Qt::black);
+ m_normalColor->setAlpha(OPACITY * 255);
- setLayout(gridLayout);
+ verticalLayout->addWidget(m_indicatorButton, 0, Qt::AlignHCenter);
+ verticalLayout->addWidget(m_distanceTextLabel, 0, Qt::AlignHCenter);
+ verticalLayout->addStretch();
+ setFixedSize(90, 100);
QSettings settings(DIRECTORY_NAME, FILE_NAME);
QPoint savedLocation = settings.value(DIRECTION_INDICATOR_BUTTON_POSITION,
this, SLOT(timerExpired()));
connect(m_forceReleaseTimer, SIGNAL(timeout()),
this, SLOT(forceMouseRelease()));
+
+ connect(this, SIGNAL(directionIndicatorValuesUpdate(qreal, qreal, bool)),
+ m_indicatorButton, SLOT(updateValues(qreal, qreal, bool)));
+
+ connect(m_indicatorButton, SIGNAL(autoCenteringTriggered(bool)),
+ this, SIGNAL(autoCenteringTriggered(bool)));
+
+ connect(this, SIGNAL(draggingModeTriggered()),
+ this, SIGNAL(draggingModeTriggered()));
}
void IndicatorButtonPanel::mouseMoveEvent(QMouseEvent *event)
if(m_isDraggable) {
setDraggable(false);
-// QSettings settings(DIRECTORY_NAME, FILE_NAME);
-// settings.setValue(DIRECTION_INDICATOR_BUTTON_POSITION, pos());
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ settings.setValue(ZOOMPANEL_POSITION, pos());
releaseMouse();
- m_indicatorButton->setDown(false);
+// m_indicatorButton->setDown();
}
}
Q_UNUSED(event);
QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+
+ QPainterPath backgroundPath;
+ QRect distanceLabelRect = m_distanceTextLabel->rect();
+
+ distanceLabelRect.translate(m_distanceTextLabel->pos());
+ distanceLabelRect.adjust(-5, 0, +5, 0);
+ backgroundPath.addRoundedRect(distanceLabelRect, 5, 5);
+ painter.fillPath(backgroundPath, QBrush(*m_normalColor));
if(m_isDraggable) {
QPainterPath backgroundPath;
painter.fillPath(backgroundPath, QBrush(Qt::Dense4Pattern));
painter.setPen(Qt::black);
}
-
-// painter.setFont(QFont(NOKIA_FONT_SMALL));
-// painter.setPen(Qt::black);
-// painter.drawText(m_distanceTextLabel);
}
void IndicatorButtonPanel::setDraggable(bool mode, QPoint eventPosition)
m_forceReleaseTimer->start();
m_dragPosition = eventPosition;
} else {
+ releaseMouse();
m_forceReleaseTimer->stop();
+ m_indicatorButton->setDown(false);
}
update();
}
{
qDebug() << __PRETTY_FUNCTION__;
+ if(m_indicatorButton->isDown())
+ m_dragPosition = m_indicatorButton->eventPosition();
+
setDraggable(true, m_dragPosition);
}
+QString IndicatorButtonPanel::countDistance(qreal m_distance)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+// QString m_distanceText;
+
+// if(m_distance < 0.01)
+// {
+// m_distanceText.setNum(10);
+// m_distanceText.prepend("< ");
+// m_distanceText.append(" m");
+// }
+// else if((m_distance >= 0.01) && (m_distance <= 0.999999))
+// {
+// m_distanceText.setNum(m_distance * 1000,1,1);
+// m_distanceText.append(" m");
+// }
+// else if((m_distance >= 1) && (m_distance <= 100))
+// {
+// m_distanceText.setNum(m_distance,1,1);
+// m_distanceText.append(" km");
+// }
+// else {
+// m_distanceText.setNum(m_distance,0,0);
+// m_distanceText.append(" km");
+// }
+
+// return m_distanceText;
+// qWarning() << m_distanceText;
+
+}
+