Commit e536522e authored by Bryant's avatar Bryant

The View Only waypoint view is now styled similarly to the editable view. Same...

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.
parent f2fd73b3
...@@ -392,12 +392,12 @@ QToolTip { ...@@ -392,12 +392,12 @@ QToolTip {
color: #DDD; color: #DDD;
} }
WaypointEditableView { WaypointEditableView, WaypointViewOnlyView {
border: 1px solid #777; border: 1px solid #777;
border-radius: 5px; border-radius: 5px;
margin-bottom: 3px; margin-bottom: 3px;
} }
WaypointEditableView QCheckBox, WaypointEditableView .QWidget { WaypointEditableView QCheckBox, WaypointEditableView .QWidget, WaypointViewOnlyView QCheckBox, WaypointViewOnlyView .QWidget {
background: none; background: none;
} }
...@@ -396,12 +396,12 @@ QToolTip { ...@@ -396,12 +396,12 @@ QToolTip {
color: #000; color: #000;
} }
WaypointEditableView { WaypointEditableView, WaypointViewOnlyView {
border: 1px solid #333; border: 1px solid #333;
border-radius: 5px; border-radius: 5px;
margin-bottom: 3px; margin-bottom: 3px;
} }
WaypointEditableView QCheckBox, WaypointEditableView .QWidget { WaypointEditableView QCheckBox, WaypointEditableView .QWidget, WaypointViewOnlyView QCheckBox, WaypointViewOnlyView .QWidget {
background: none; background: none;
} }
...@@ -652,6 +652,9 @@ void WaypointEditableView::changeEvent(QEvent *e) ...@@ -652,6 +652,9 @@ void WaypointEditableView::changeEvent(QEvent *e)
} }
} }
/**
* Implement paintEvent() so that stylesheets work for our custom widget.
*/
void WaypointEditableView::paintEvent(QPaintEvent *) void WaypointEditableView::paintEvent(QPaintEvent *)
{ {
QStyleOption opt; QStyleOption opt;
......
#include <QDebug> #include <QDebug>
#include "MainWindow.h"
#include "WaypointViewOnlyView.h" #include "WaypointViewOnlyView.h"
#include "ui_WaypointViewOnlyView.h" #include "ui_WaypointViewOnlyView.h"
...@@ -47,7 +49,6 @@ void WaypointViewOnlyView::changedCurrent(int state) ...@@ -47,7 +49,6 @@ void WaypointViewOnlyView::changedCurrent(int state)
} }
else else
{ {
hightlightDesiredCurrent(true);
m_ui->current->setCheckState(Qt::Unchecked); m_ui->current->setCheckState(Qt::Unchecked);
//qDebug() << "Trof: WaypointViewOnlyView::changedCurrent. Checked new. Sending set_current request to Manager " << m_ui->current->isChecked(); //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 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) ...@@ -63,13 +64,11 @@ void WaypointViewOnlyView::setCurrent(bool state)
if (state == true) if (state == true)
{ {
wp->setCurrent(true); wp->setCurrent(true);
hightlightDesiredCurrent(true);
m_ui->current->setCheckState(Qt::Checked); m_ui->current->setCheckState(Qt::Checked);
} }
else else
{ {
wp->setCurrent(false); wp->setCurrent(false);
hightlightDesiredCurrent(false);
m_ui->current->setCheckState(Qt::Unchecked); m_ui->current->setCheckState(Qt::Unchecked);
} }
m_ui->current->blockSignals(false); m_ui->current->blockSignals(false);
...@@ -86,37 +85,38 @@ void WaypointViewOnlyView::updateValues() ...@@ -86,37 +85,38 @@ void WaypointViewOnlyView::updateValues()
return; return;
} }
// Update style // Style alternating rows of Missions as lighter/darker.
QColor backGroundColor = QGC::colorBackground;
static int lastId = -1; static int lastId = -1;
int currId = wp->getId() % 2; int currId = wp->getId() % 2;
if (currId != lastId) if (currId != lastId)
{ {
QString backGroundColor;
// qDebug() << "COLOR ID: " << currId;
if (currId == 1) if (currId == 1)
{ {
backGroundColor = QColor("#252528").lighter(150); if (MainWindow::instance()->getStyle() == MainWindow::QGC_MAINWINDOW_STYLE_LIGHT)
{
backGroundColor = "#999";
}
else
{
backGroundColor = "#333";
}
} }
else 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 newStyle = QString("WaypointViewOnlyView {background-color: %1}").arg(backGroundColor);
QString groupBoxStyle = QString("QGroupBox {padding: 0px; margin: 0px; border: 0px; background-color: %1; min-height: 12px; }").arg(backGroundColor.name()); this->setStyleSheet(newStyle);
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());
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; lastId = currId;
} }
...@@ -157,7 +157,6 @@ void WaypointViewOnlyView::updateValues() ...@@ -157,7 +157,6 @@ void WaypointViewOnlyView::updateValues()
} }
} }
hightlightDesiredCurrent(wp->getCurrent());
if (m_ui->current->isChecked() != wp->getCurrent()) if (m_ui->current->isChecked() != wp->getCurrent())
{ {
m_ui->current->blockSignals(true); m_ui->current->blockSignals(true);
...@@ -405,31 +404,29 @@ void WaypointViewOnlyView::updateValues() ...@@ -405,31 +404,29 @@ void WaypointViewOnlyView::updateValues()
} }
} }
void WaypointViewOnlyView::hightlightDesiredCurrent(bool hightlight_on) WaypointViewOnlyView::~WaypointViewOnlyView()
{ {
QColor backGroundColor = QGC::colorBackground; delete m_ui;
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);
} }
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);
}
...@@ -18,20 +18,21 @@ public: ...@@ -18,20 +18,21 @@ public:
~WaypointViewOnlyView(); ~WaypointViewOnlyView();
public slots: public slots:
void changedCurrent(int state); void changedCurrent(int state);
void changedAutoContinue(int state); void changedAutoContinue(int state);
void updateValues(void); void updateValues(void);
void setCurrent(bool state); void setCurrent(bool state);
signals: signals:
void changeCurrentWaypoint(quint16); void changeCurrentWaypoint(quint16);
void changeAutoContinue(quint16, bool); void changeAutoContinue(quint16, bool);
protected: protected:
Waypoint* wp; Waypoint* wp;
virtual void changeEvent(QEvent *e);
virtual void paintEvent(QPaintEvent *);
private: private:
void hightlightDesiredCurrent(bool hightlight_on);
Ui::WaypointViewOnlyView *m_ui; Ui::WaypointViewOnlyView *m_ui;
}; };
......
This diff is collapsed.
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