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 {
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;
}
......@@ -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;
}
......@@ -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;
......
#include <QDebug>
#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);
}
......@@ -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;
};
......
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