From 6377dab3f88abe27d76b4d89ac4331746d1bcf36 Mon Sep 17 00:00:00 2001 From: Bryant Date: Sun, 2 Jun 2013 10:14:34 -0700 Subject: [PATCH] The background color of the mission items is now controlled by stylesheets as well. This change also fixed restyling the mission lists when a style change occurred. --- files/styles/style-dark.css | 8 +++++++ files/styles/style-light.css | 8 +++++++ src/ui/WaypointEditableView.cc | 43 ++++++++++------------------------ src/ui/WaypointViewOnlyView.cc | 36 +++++++--------------------- 4 files changed, 37 insertions(+), 58 deletions(-) diff --git a/files/styles/style-dark.css b/files/styles/style-dark.css index e87f433a7..8039d2697 100644 --- a/files/styles/style-dark.css +++ b/files/styles/style-dark.css @@ -506,6 +506,14 @@ WaypointEditableView, WaypointViewOnlyView { margin-bottom: 3px; } +WaypointEditableView[RowColoring="odd"], WaypointViewOnlyView[RowColoring="odd"] { + background-color: #333; +} + +WaypointEditableView[RowColoring="even"], WaypointViewOnlyView[RowColoring="even"] { + background-color: #555; +} + WaypointEditableView QCheckBox, WaypointEditableView .QWidget, WaypointViewOnlyView QCheckBox, WaypointViewOnlyView .QWidget { background: none; } diff --git a/files/styles/style-light.css b/files/styles/style-light.css index 7853ecc82..21d9c3bcf 100644 --- a/files/styles/style-light.css +++ b/files/styles/style-light.css @@ -506,6 +506,14 @@ WaypointEditableView, WaypointViewOnlyView { margin-bottom: 3px; } +WaypointEditableView[RowColoring="odd"], WaypointViewOnlyView[RowColoring="odd"] { + background-color: #999; +} + +WaypointEditableView[RowColoring="even"], WaypointViewOnlyView[RowColoring="even"] { + background-color: #CCC; +} + WaypointEditableView QCheckBox, WaypointEditableView .QWidget, WaypointViewOnlyView QCheckBox, WaypointViewOnlyView .QWidget { background: none; } diff --git a/src/ui/WaypointEditableView.cc b/src/ui/WaypointEditableView.cc index f3976a4a5..602f4e04a 100644 --- a/src/ui/WaypointEditableView.cc +++ b/src/ui/WaypointEditableView.cc @@ -61,7 +61,7 @@ WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) : MissionNavTakeoffWidget = NULL; MissionNavSweepWidget = NULL; MissionConditionDelayWidget = NULL; - MissionDoJumpWidget = NULL; + MissionDoJumpWidget = NULL; MissionDoStartSearchWidget = NULL; MissionDoFinishSearchWidget = NULL; MissionOtherWidget = NULL; @@ -78,7 +78,7 @@ WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) : //m_ui->comboBox_action->addItem(tr("NAV: Target"),MAV_CMD_NAV_TARGET); m_ui->comboBox_action->addItem(tr("IF: Delay over"),MAV_CMD_CONDITION_DELAY); //m_ui->comboBox_action->addItem(tr("IF: Yaw angle is"),MAV_CMD_CONDITION_YAW); - m_ui->comboBox_action->addItem(tr("DO: Jump to Index"),MAV_CMD_DO_JUMP); + m_ui->comboBox_action->addItem(tr("DO: Jump to Index"),MAV_CMD_DO_JUMP); #ifdef MAVLINK_ENABLED_PIXHAWK m_ui->comboBox_action->addItem(tr("NAV: Sweep"),MAV_CMD_NAV_SWEEP); m_ui->comboBox_action->addItem(tr("Do: Start Search"),MAV_CMD_DO_START_SEARCH); @@ -141,7 +141,7 @@ void WaypointEditableView::changedAutoContinue(int state) } void WaypointEditableView::updateActionView(int action) -{ +{ //Hide all if(MissionNavWaypointWidget) MissionNavWaypointWidget->hide(); if(MissionNavLoiterUnlimWidget) MissionNavLoiterUnlimWidget->hide(); @@ -349,25 +349,25 @@ void WaypointEditableView::changedFrame(int index) } void WaypointEditableView::changedCurrent(int state) -{ +{ if (state == 0) { if (wp->getCurrent() == true) //User clicked on the waypoint, that is already current - { + { m_ui->selectedBox->setChecked(true); m_ui->selectedBox->setCheckState(Qt::Checked); } else - { + { m_ui->selectedBox->setChecked(false); - m_ui->selectedBox->setCheckState(Qt::Unchecked); + m_ui->selectedBox->setCheckState(Qt::Unchecked); } } else - { + { wp->setCurrent(true); emit changeCurrentWaypoint(wp->getId()); //the slot changeCurrentWaypoint() in WaypointList sets all other current flags to false - } + } } void WaypointEditableView::updateValues() @@ -449,7 +449,7 @@ void WaypointEditableView::updateValues() MAV_FRAME frame = wp->getFrame(); int frame_index = m_ui->comboBox_frame->findData(frame); if (m_ui->comboBox_frame->currentIndex() != frame_index) { - m_ui->comboBox_frame->setCurrentIndex(frame_index); + m_ui->comboBox_frame->setCurrentIndex(frame_index); } // Update action @@ -492,37 +492,18 @@ void WaypointEditableView::updateValues() m_ui->idLabel->setText(QString::number(wp->getId())); // Style alternating rows of Missions as lighter/darker. - QString backGroundColor; static int lastId = -1; int currId = wp->getId() % 2; if (currId != lastId) { if (currId == 1) { - if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) - { - backGroundColor = "#999"; - } - else - { - backGroundColor = "#333"; - } + this->setProperty("RowColoring", "odd"); } else { - if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) - { - backGroundColor = "#CCC"; - } - else - { - backGroundColor = "#555"; - } + this->setProperty("RowColoring", "even"); } - - QString newStyle = QString("WaypointEditableView {background-color: %1}").arg(backGroundColor); - - this->setStyleSheet(newStyle); lastId = currId; } diff --git a/src/ui/WaypointViewOnlyView.cc b/src/ui/WaypointViewOnlyView.cc index b245fdce2..63d5323de 100644 --- a/src/ui/WaypointViewOnlyView.cc +++ b/src/ui/WaypointViewOnlyView.cc @@ -17,13 +17,13 @@ WaypointViewOnlyView::WaypointViewOnlyView(Waypoint* wp, QWidget *parent) : } void WaypointViewOnlyView::changedAutoContinue(int state) -{ +{ bool new_value = false; if (state != 0) { new_value = true; } - wp->setAutocontinue(new_value); + wp->setAutocontinue(new_value); emit changeAutoContinue(wp->getId(),new_value); } @@ -32,7 +32,7 @@ void WaypointViewOnlyView::changedCurrent(int state) { Q_UNUSED(state); //qDebug() << "Trof: WaypointViewOnlyView::changedCurrent(" << state << ") ID:" << wp->getId(); - m_ui->current->blockSignals(true); + m_ui->current->blockSignals(true); if (m_ui->current->isChecked() == false) { @@ -60,7 +60,7 @@ void WaypointViewOnlyView::changedCurrent(int state) void WaypointViewOnlyView::setCurrent(bool state) //This is a slot receiving signals from UASWaypointManager. The state given here is the true representation of what the "current" waypoint on UAV is. { - m_ui->current->blockSignals(true); + m_ui->current->blockSignals(true); if (state == true) { wp->setCurrent(true); @@ -90,33 +90,15 @@ void WaypointViewOnlyView::updateValues() int currId = wp->getId() % 2; if (currId != lastId) { - QString backGroundColor; if (currId == 1) { - if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) - { - backGroundColor = "#999"; - } - else - { - backGroundColor = "#333"; - } + this->setProperty("RowColoring", "odd"); } else { - if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) - { - backGroundColor = "#CCC"; - } - else - { - backGroundColor = "#555"; - } + this->setProperty("RowColoring", "even"); } - QString newStyle = QString("WaypointViewOnlyView {background-color: %1}").arg(backGroundColor); - this->setStyleSheet(newStyle); - lastId = currId; } @@ -160,7 +142,7 @@ void WaypointViewOnlyView::updateValues() if (m_ui->current->isChecked() != wp->getCurrent()) { m_ui->current->blockSignals(true); - m_ui->current->setChecked(wp->getCurrent()); + m_ui->current->setChecked(wp->getCurrent()); m_ui->current->blockSignals(false); } if (m_ui->autoContinue->isChecked() != wp->getAutoContinue()) @@ -310,7 +292,7 @@ void WaypointViewOnlyView::updateValues() break; } case MAV_CMD_NAV_LAND: - { + { switch (wp->getFrame()) { case MAV_FRAME_GLOBAL_RELATIVE_ALT: @@ -329,7 +311,7 @@ void WaypointViewOnlyView::updateValues() break; } case MAV_CMD_NAV_TAKEOFF: - { + { switch (wp->getFrame()) { case MAV_FRAME_GLOBAL_RELATIVE_ALT: -- 2.22.0