Commit 78e89fa5 authored by Lorenz Meier's avatar Lorenz Meier

Map toolbar: Ensure status label does not lead to screen flickering

parent d4e5dabf
......@@ -12,7 +12,8 @@ QGCMapToolBar::QGCMapToolBar(QWidget *parent) :
mapTypesMenu(this),
trailSettingsGroup(new QActionGroup(this)),
updateTimesGroup(new QActionGroup(this)),
mapTypesGroup(new QActionGroup(this))
mapTypesGroup(new QActionGroup(this)),
statusMaxLen(15)
{
ui->setupUi(this);
}
......@@ -168,11 +169,16 @@ void QGCMapToolBar::setUAVTrailTime()
if (ok)
{
(map->setTrailModeTimed(trailTime));
ui->posLabel->setText(tr("Trail mode: Every %1 second%2").arg(trailTime).arg((trailTime > 1) ? "s" : ""));
setStatusLabelText(tr("Trail mode: Every %1 second%2").arg(trailTime).arg((trailTime > 1) ? "s" : ""));
}
}
}
void QGCMapToolBar::setStatusLabelText(const QString &text)
{
ui->posLabel->setText(text.leftJustified(statusMaxLen, QChar('.'), true));
}
void QGCMapToolBar::setUAVTrailDistance()
{
QObject* sender = QObject::sender();
......@@ -185,7 +191,7 @@ void QGCMapToolBar::setUAVTrailDistance()
if (ok)
{
map->setTrailModeDistance(trailDistance);
ui->posLabel->setText(tr("Trail mode: Every %1 meter%2").arg(trailDistance).arg((trailDistance == 1) ? "s" : ""));
setStatusLabelText(tr("Trail mode: Every %1 meter%2").arg(trailDistance).arg((trailDistance == 1) ? "s" : ""));
}
}
}
......@@ -202,7 +208,7 @@ void QGCMapToolBar::setUpdateInterval()
if (ok)
{
map->setUpdateRateLimit(time);
ui->posLabel->setText(tr("Limit: %1 second%2").arg(time).arg((time != 1.0f) ? "s" : ""));
setStatusLabelText(tr("Limit: %1 second%2").arg(time).arg((time != 1.0f) ? "s" : ""));
}
}
}
......@@ -219,30 +225,30 @@ void QGCMapToolBar::setMapType()
if (ok)
{
map->SetMapType((MapType::Types)mapType);
ui->posLabel->setText(tr("Map: %1").arg(mapType));
setStatusLabelText(tr("Map: %1").arg(mapType));
}
}
}
void QGCMapToolBar::tileLoadStart()
{
ui->posLabel->setText(tr("Loading.."));
setStatusLabelText(tr("Loading"));
}
void QGCMapToolBar::tileLoadEnd()
{
ui->posLabel->setText(tr("Finished"));
setStatusLabelText(tr("Finished"));
}
void QGCMapToolBar::tileLoadProgress(int progress)
{
if (progress == 1)
{
ui->posLabel->setText(tr("1 tile"));
setStatusLabelText(tr("1 tile"));
}
else if (progress > 0)
{
ui->posLabel->setText(tr("%1 tile").arg(progress));
setStatusLabelText(tr("%1 tile").arg(progress));
}
else
{
......
......@@ -29,6 +29,7 @@ public slots:
void setUAVTrailDistance();
void setUpdateInterval();
void setMapType();
void setStatusLabelText(const QString &text);
private:
Ui::QGCMapToolBar *ui;
......@@ -43,6 +44,8 @@ protected:
QActionGroup* trailSettingsGroup;
QActionGroup* updateTimesGroup;
QActionGroup* mapTypesGroup;
unsigned statusMaxLen;
};
#endif // QGCMAPTOOLBAR_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment