From e536522e6469736556fa2a143b99b50c18498db1 Mon Sep 17 00:00:00 2001 From: Bryant Date: Mon, 27 May 2013 12:26:44 -0700 Subject: [PATCH] The View Only waypoint view is now styled similarly to the editable view. Same caveats apply where the widgets don't update their style if QGC has its styles changed. --- files/styles/style-dark.css | 4 +- files/styles/style-light.css | 4 +- src/ui/WaypointEditableView.cc | 3 + src/ui/WaypointViewOnlyView.cc | 89 ++- src/ui/WaypointViewOnlyView.h | 13 +- src/ui/WaypointViewOnlyView.ui | 1099 +++++++++++++++----------------- 6 files changed, 572 insertions(+), 640 deletions(-) diff --git a/files/styles/style-dark.css b/files/styles/style-dark.css index f389978b6..d218add52 100644 --- a/files/styles/style-dark.css +++ b/files/styles/style-dark.css @@ -392,12 +392,12 @@ QToolTip { color: #DDD; } -WaypointEditableView { +WaypointEditableView, WaypointViewOnlyView { border: 1px solid #777; border-radius: 5px; margin-bottom: 3px; } -WaypointEditableView QCheckBox, WaypointEditableView .QWidget { +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 5e9c41c86..fde4a6db8 100644 --- a/files/styles/style-light.css +++ b/files/styles/style-light.css @@ -396,12 +396,12 @@ QToolTip { color: #000; } -WaypointEditableView { +WaypointEditableView, WaypointViewOnlyView { border: 1px solid #333; border-radius: 5px; margin-bottom: 3px; } -WaypointEditableView QCheckBox, WaypointEditableView .QWidget { +WaypointEditableView QCheckBox, WaypointEditableView .QWidget, WaypointViewOnlyView QCheckBox, WaypointViewOnlyView .QWidget { background: none; } diff --git a/src/ui/WaypointEditableView.cc b/src/ui/WaypointEditableView.cc index 803829521..f3976a4a5 100644 --- a/src/ui/WaypointEditableView.cc +++ b/src/ui/WaypointEditableView.cc @@ -652,6 +652,9 @@ void WaypointEditableView::changeEvent(QEvent *e) } } +/** + * Implement paintEvent() so that stylesheets work for our custom widget. + */ void WaypointEditableView::paintEvent(QPaintEvent *) { QStyleOption opt; diff --git a/src/ui/WaypointViewOnlyView.cc b/src/ui/WaypointViewOnlyView.cc index 3ae64851b..b245fdce2 100644 --- a/src/ui/WaypointViewOnlyView.cc +++ b/src/ui/WaypointViewOnlyView.cc @@ -1,4 +1,6 @@ #include + +#include "MainWindow.h" #include "WaypointViewOnlyView.h" #include "ui_WaypointViewOnlyView.h" @@ -47,7 +49,6 @@ void WaypointViewOnlyView::changedCurrent(int state) } else { - hightlightDesiredCurrent(true); m_ui->current->setCheckState(Qt::Unchecked); //qDebug() << "Trof: WaypointViewOnlyView::changedCurrent. Checked new. Sending set_current request to Manager " << m_ui->current->isChecked(); emit changeCurrentWaypoint(wp->getId()); //the slot changeCurrentWaypoint() in WaypointList sets all other current flags to false @@ -63,13 +64,11 @@ void WaypointViewOnlyView::setCurrent(bool state) if (state == true) { wp->setCurrent(true); - hightlightDesiredCurrent(true); m_ui->current->setCheckState(Qt::Checked); } else { wp->setCurrent(false); - hightlightDesiredCurrent(false); m_ui->current->setCheckState(Qt::Unchecked); } m_ui->current->blockSignals(false); @@ -86,37 +85,38 @@ void WaypointViewOnlyView::updateValues() return; } - // Update style - - QColor backGroundColor = QGC::colorBackground; - + // Style alternating rows of Missions as lighter/darker. static int lastId = -1; int currId = wp->getId() % 2; - if (currId != lastId) { - - // qDebug() << "COLOR ID: " << currId; + QString backGroundColor; if (currId == 1) { - backGroundColor = QColor("#252528").lighter(150); + if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) + { + backGroundColor = "#999"; + } + else + { + backGroundColor = "#333"; + } } else { - backGroundColor = QColor("#252528").lighter(250); + if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT) + { + backGroundColor = "#CCC"; + } + else + { + backGroundColor = "#555"; + } } - // Update color based on id - QString groupBoxStyle = QString("QGroupBox {padding: 0px; margin: 0px; border: 0px; background-color: %1; min-height: 12px; }").arg(backGroundColor.name()); - QString labelStyle = QString("QWidget {background-color: %1; color: #DDDDDF; border-color: #EEEEEE; }").arg(backGroundColor.name()); - QString displayBarStyle = QString("QWidget {background-color: %1; color: #DDDDDF; border: none; }").arg(backGroundColor.name()); - QString checkBoxStyle = QString("QCheckBox {background-color: %1; color: #454545; border-color: #EEEEEE; }").arg(backGroundColor.name()); + QString newStyle = QString("WaypointViewOnlyView {background-color: %1}").arg(backGroundColor); + this->setStyleSheet(newStyle); - m_ui->autoContinue->setStyleSheet(checkBoxStyle); - m_ui->current->setStyleSheet(checkBoxStyle); - m_ui->idLabel->setStyleSheet(labelStyle); - m_ui->displayBar->setStyleSheet(displayBarStyle); - m_ui->groupBox->setStyleSheet(groupBoxStyle); lastId = currId; } @@ -157,7 +157,6 @@ void WaypointViewOnlyView::updateValues() } } - hightlightDesiredCurrent(wp->getCurrent()); if (m_ui->current->isChecked() != wp->getCurrent()) { m_ui->current->blockSignals(true); @@ -405,31 +404,29 @@ void WaypointViewOnlyView::updateValues() } } -void WaypointViewOnlyView::hightlightDesiredCurrent(bool hightlight_on) +WaypointViewOnlyView::~WaypointViewOnlyView() { - QColor backGroundColor = QGC::colorBackground; - QString checkBoxStyle; - if (wp->getId() % 2 == 1) - { - backGroundColor = QColor("#252528").lighter(150); - } - else - { - backGroundColor = QColor("#252528").lighter(250); - } - - if (hightlight_on) - { - checkBoxStyle = QString("QCheckBox {background-color: %1; color: #454545; border-color: #EEEEEE; } QCheckBox::indicator { border-color: #FFFFFF}").arg(backGroundColor.name()); - } - else - { - checkBoxStyle = QString("QCheckBox {background-color: %1; color: #454545; border-color: #EEEEEE; } QCheckBox::indicator { border-color: QGC::colorBackground}").arg(backGroundColor.name()); - } - m_ui->current->setStyleSheet(checkBoxStyle); + delete m_ui; } -WaypointViewOnlyView::~WaypointViewOnlyView() +void WaypointViewOnlyView::changeEvent(QEvent *e) { - delete m_ui; + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } } + +/** + * Implement paintEvent() so that stylesheets work for our custom widget. + */ +void WaypointViewOnlyView::paintEvent(QPaintEvent *) + { + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + } diff --git a/src/ui/WaypointViewOnlyView.h b/src/ui/WaypointViewOnlyView.h index 81f3e9a02..c50056541 100644 --- a/src/ui/WaypointViewOnlyView.h +++ b/src/ui/WaypointViewOnlyView.h @@ -18,20 +18,21 @@ public: ~WaypointViewOnlyView(); public slots: -void changedCurrent(int state); -void changedAutoContinue(int state); -void updateValues(void); -void setCurrent(bool state); + void changedCurrent(int state); + void changedAutoContinue(int state); + void updateValues(void); + void setCurrent(bool state); signals: void changeCurrentWaypoint(quint16); void changeAutoContinue(quint16, bool); protected: -Waypoint* wp; + Waypoint* wp; + virtual void changeEvent(QEvent *e); + virtual void paintEvent(QPaintEvent *); private: - void hightlightDesiredCurrent(bool hightlight_on); Ui::WaypointViewOnlyView *m_ui; }; diff --git a/src/ui/WaypointViewOnlyView.ui b/src/ui/WaypointViewOnlyView.ui index df46423fc..99b5c70e1 100644 --- a/src/ui/WaypointViewOnlyView.ui +++ b/src/ui/WaypointViewOnlyView.ui @@ -26,610 +26,541 @@ Form - QGroupBox { - border: 1px solid #EEEEEE; - border-radius: 5px; - padding: 0px 0px 0px 0px; -margin-top: 1ex; /* leave space at the top for the title */ - margin: 0px; -} - - QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top center; /* position at the top center */ - margin: 0 3px 0px 3px; - padding: 0 3px 0px 0px; - font: bold 8px; - } + - + - 0 + 6 - - 0 - - - - - true + + + + + 0 + 0 + + + + + 25 + 0 + + + + 1 + + + ID + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 25 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + Currently executed waypoint + + + Currently executed waypoint + + + + + + + 0 0 - - + + Mission element description - + + Mission element description + + + + Mission element description + + + + + + + Coordinate Frame + + + Coordinate Frame + + + + + + Frame + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + + + + + false + + + 0 + 0 + + + + Automatically continue after this waypoint + + + Automatically continue after this waypoint + + + + - false + true - - - 2 - - - 4 - - - - - - 0 - 0 - - - - - 25 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - Currently executed waypoint - - - Currently executed waypoint - - - - - - - - - - - 0 - 0 - - - - - 25 - 0 - - - - 1 - - - ID - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Mission element description - - - Mission element description - - - - - - Mission element description - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 79 - 17 - - - - - - - - Coordinate Frame - - - Coordinate Frame - - - - - - Frame - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - false - - - - 0 - 0 - - - - Automatically continue after this waypoint - - - Automatically continue after this waypoint - - - - - - true - - - - -- 2.22.0