From 7c57e2e575740830635c005d92d33d2b25970aa9 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 13 May 2013 00:09:36 +0200 Subject: [PATCH] Fixed visual bug on status bar --- src/ui/MainWindow.cc | 11 ++++++----- src/ui/QGCStatusBar.cc | 9 +++++++-- src/ui/QGCToolBar.cc | 12 ++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index ae7c673..4bf3b44 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -104,9 +104,14 @@ MainWindow::MainWindow(QWidget *parent): lowPowerMode(false) { hide(); + isAdvancedMode = false; emit initStatusChanged("Loading UI Settings.."); loadSettings(); + + emit initStatusChanged("Loading Style."); + loadStyle(currentStyle); + if (settings.contains("ADVANCED_MODE")) { isAdvancedMode = settings.value("ADVANCED_MODE").toBool(); @@ -132,9 +137,6 @@ MainWindow::MainWindow(QWidget *parent): settings.sync(); - emit initStatusChanged("Loading Style."); - loadStyle(currentStyle); - emit initStatusChanged("Setting up user interface."); // Setup user interface @@ -175,12 +177,12 @@ MainWindow::MainWindow(QWidget *parent): advancedActions << ui.actionEngineersView; toolBar->setPerspectiveChangeAdvancedActions(advancedActions); - customStatusBar = new QGCStatusBar(this); setStatusBar(customStatusBar); statusBar()->setSizeGripEnabled(true); + emit initStatusChanged("Building common widgets."); buildCommonWidgets(); @@ -394,7 +396,6 @@ void MainWindow::buildCommonWidgets() logPlayer = new QGCMAVLinkLogPlayer(mavlink, customStatusBar); customStatusBar->setLogPlayer(logPlayer); - // Center widgets if (!plannerView) { diff --git a/src/ui/QGCStatusBar.cc b/src/ui/QGCStatusBar.cc index 76cd685..04f77de 100644 --- a/src/ui/QGCStatusBar.cc +++ b/src/ui/QGCStatusBar.cc @@ -44,12 +44,17 @@ QGCStatusBar::QGCStatusBar(QWidget *parent) : loadSettings(); - setStyleSheet("QWidget {border-color: transparent; } QStatusBar {border-color: transparent; border: 0px; border-bottom: 1px solid #101010; border-top: 1px solid #4F4F4F; background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #4B4B4B, stop:0.3 #404040, stop:0.34 #383838, stop:1 #181818);}"); + setStyleSheet("QStatusBar { border: 0px; border-bottom: 1px solid #101010; border-top: 1px solid #4F4F4F; background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #4B4B4B, stop:0.3 #404040, stop:0.34 #383838, stop:1 #181818); } "); } void QGCStatusBar::paintEvent(QPaintEvent * event) { -// if (currentMessage().length() != 0) { + QPainter p(this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_PanelStatusBar, &opt, &p, this); + //QStatusBar::paintEvent(event); +// if (currentMessage().length() == 0) { // QStatusBar::paintEvent(event); // } else { diff --git a/src/ui/QGCToolBar.cc b/src/ui/QGCToolBar.cc index 4649766..8f1e579 100644 --- a/src/ui/QGCToolBar.cc +++ b/src/ui/QGCToolBar.cc @@ -54,11 +54,11 @@ void QGCToolBar::heartbeatTimeout(bool timeout, unsigned int ms) // Alternate colors to increase visibility if ((ms / 1000) % 2 == 0) { - toolBarTimeoutLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.name())); + toolBarTimeoutLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; padding: 2px; padding-left: 4px; padding-right: 4px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.name())); } else { - toolBarTimeoutLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.dark(250).name())); + toolBarTimeoutLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; padding: 2px; padding-left: 4px; padding-right: 4px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.dark(250).name())); } toolBarTimeoutLabel->setText(tr("CONNECTION LOST: %1 s").arg((ms / 1000.0f), 2, 'f', 1, ' ')); } @@ -91,12 +91,12 @@ void QGCToolBar::createUI() toolBarTimeoutLabel = new QLabel("UNCONNECTED", this); toolBarTimeoutLabel->setToolTip(tr("System timed out, interval since last message")); - toolBarTimeoutLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.name())); + toolBarTimeoutLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; padding: 2px; padding-left: 4px; padding-right: 4px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorDarkWhite.name()).arg(QGC::colorMagenta.name())); toolBarTimeoutLabel->setAlignment(Qt::AlignCenter); addWidget(toolBarTimeoutLabel); toolBarSafetyLabel = new QLabel("SAFE", this); - toolBarSafetyLabel->setStyleSheet("QLabel { margin: 3px 2px; font: 14px; color: #14C814; }"); + toolBarSafetyLabel->setStyleSheet("QLabel { margin: 3px 2px; padding: 2px; padding-left: 4px; padding-right: 4px; font: 14px; color: #14C814; }"); toolBarSafetyLabel->setToolTip(tr("Vehicle safety state")); toolBarSafetyLabel->setAlignment(Qt::AlignCenter); addWidget(toolBarSafetyLabel); @@ -353,12 +353,12 @@ void QGCToolBar::updateView() if (systemArmed) { - toolBarSafetyLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorRed.name()).arg(QGC::colorYellow.name())); + toolBarSafetyLabel->setStyleSheet(QString("QLabel { margin: 3px 2px; padding: 2px; padding-left: 4px; padding-right: 4px; font: 14px; color: %1; background-color: %2; border-radius: 4px;}").arg(QGC::colorRed.name()).arg(QGC::colorYellow.name())); toolBarSafetyLabel->setText(tr("ARMED")); } else { - toolBarSafetyLabel->setStyleSheet("QLabel { margin: 3px 2px; font: 14px; color: #14C814; }"); + toolBarSafetyLabel->setStyleSheet("QLabel { margin: 3px 2px; padding: 2px; padding-left: 4px; padding-right: 4px; font: 14px; color: #14C814; }"); toolBarSafetyLabel->setText(tr("SAFE")); }