Browse Source

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

QGC4.4
Lorenz Meier 11 years ago
parent
commit
78e89fa574
  1. 24
      src/ui/map/QGCMapToolBar.cc
  2. 3
      src/ui/map/QGCMapToolBar.h

24
src/ui/map/QGCMapToolBar.cc

@ -12,7 +12,8 @@ QGCMapToolBar::QGCMapToolBar(QWidget *parent) : @@ -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() @@ -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() @@ -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() @@ -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() @@ -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
{

3
src/ui/map/QGCMapToolBar.h

@ -29,6 +29,7 @@ public slots: @@ -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: @@ -43,6 +44,8 @@ protected:
QActionGroup* trailSettingsGroup;
QActionGroup* updateTimesGroup;
QActionGroup* mapTypesGroup;
unsigned statusMaxLen;
};
#endif // QGCMAPTOOLBAR_H

Loading…
Cancel
Save