Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSA: support dark themes #1173

Merged
merged 7 commits into from Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions moveit_setup_assistant/src/tools/rotated_header_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include "rotated_header_view.h"
#include <QPainter>
#include <QDebug>

namespace moveit_setup_assistant
{
Expand Down Expand Up @@ -125,7 +124,6 @@ int RotatedHeaderView::sectionSizeHint(int logicalIndex) const
else
size = sectionSizeFromContents(logicalIndex);
int hint = size.height();
qDebug() << logicalIndex << size << hint;
return qMax(minimumSectionSize(), hint);
}
}
54 changes: 19 additions & 35 deletions moveit_setup_assistant/src/widgets/navigation_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* Author: Dave Coleman */

#include "navigation_widget.h"
#include <QDebug>
#include <QApplication>
#include <iostream>

namespace moveit_setup_assistant
Expand Down Expand Up @@ -124,64 +124,48 @@ QSize NavDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelInde
void NavDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
const bool isSelected = option.state & QStyle::State_Selected;
const QPalette& palette = QApplication::palette();

// NavScreen tp = index.data().value<NavScreen>();
QString nav_name = index.data().value<QString>();
QString nav_name = displayText(index.data(), option.locale);

painter->save();

QLinearGradient backgroundGradient(QPoint(option.rect.x(), option.rect.y()),
QPoint(option.rect.x(), option.rect.y() + option.rect.height()));
// draw background gradient
QLinearGradient backgroundGradient(option.rect.topLeft(), option.rect.bottomLeft());
if (isSelected)
{
backgroundGradient.setColorAt(0, QColor(109, 164, 219));
backgroundGradient.setColorAt(1, QColor(61, 138, 212));
backgroundGradient.setColorAt(0, palette.color(QPalette::Highlight).lighter(125));
backgroundGradient.setColorAt(1, palette.color(QPalette::Highlight));
painter->fillRect(option.rect, QBrush(backgroundGradient));
}
else
{
backgroundGradient.setColorAt(0, QColor(245, 245, 245));
backgroundGradient.setColorAt(1, QColor(240, 240, 240));
backgroundGradient.setColorAt(0, palette.color(QPalette::Light));
backgroundGradient.setColorAt(1, palette.color(QPalette::Light).darker(105));
painter->fillRect(option.rect, QBrush(backgroundGradient));
}

painter->setPen(QColor(225, 225, 225));
if (isSelected)
{
painter->setPen(QColor(37, 105, 169));
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
painter->setPen(Qt::transparent);
}
painter->drawLine(option.rect.topLeft(), option.rect.topRight());
if (!isSelected)
if (!isSelected) // draw shadow
{
painter->setPen(QColor(248, 248, 248));
painter->drawLine(QPoint(option.rect.x(), option.rect.y() + 1),
QPoint(option.rect.x() + option.rect.width(), option.rect.y() + 1));
painter->setPen(palette.color(QPalette::Button));
painter->drawLine(option.rect.topLeft(), option.rect.topRight());
painter->setPen(palette.color(QPalette::Light));
const QPoint offset(0, 1);
painter->drawLine(option.rect.topLeft() + offset, option.rect.topRight() + offset);
}

QRect textRect(option.rect.x() + 10, option.rect.y(), option.rect.width() - 10, option.rect.height());

QFont textFont(painter->font());
textFont.setPixelSize(14); // Set font size
painter->setFont(textFont);

// Font color
if (isSelected)
{
// Selected
painter->setPen(QColor(229, 229, 229));
}
else if (index.flags().testFlag(Qt::NoItemFlags))
{
// Disabled font color if disabled
painter->setPen(QColor(170, 170, 170)); // TODO: make this work
}
painter->setPen(palette.color(QPalette::HighlightedText));
else if (!option.state.testFlag(QStyle::State_Enabled))
painter->setPen(palette.color(QPalette::Dark));
else
{
// Normal
painter->setPen(QColor(69, 69, 69));
}
painter->setPen(palette.color(QPalette::ButtonText));

painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, nav_name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ void PlanningGroupsWidget::saveChainScreen()

for (std::vector<std::string>::const_iterator link_it = links.begin(); link_it != links.end(); ++link_it)
{
// Check if string matches either of user specefied links
// Check if string matches either of user specified links
if (link_it->compare(tip) == 0) // they are same
found_tip = true;
else if (link_it->compare(base) == 0) // they are same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <QStackedLayout>
#include <QListWidget>
#include <QListWidgetItem>
#include <QDebug>
#include <QFont>
#include <QLabel>
#include <QPushButton>
Expand Down
19 changes: 5 additions & 14 deletions moveit_setup_assistant/src/widgets/start_screen_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ bool StartScreenWidget::loadNewFiles()
// Check that box is filled out
if (config_data_->urdf_path_.empty())
{
QMessageBox::warning(this, "Error Loading Files", "No robot model file specefied");
QMessageBox::warning(this, "Error Loading Files", "No robot model file specified");
return false;
}

Expand Down Expand Up @@ -822,25 +822,16 @@ SelectModeWidget::SelectModeWidget(QWidget* parent) : QFrame(parent)
layout->setAlignment(widget_title, Qt::AlignTop);

// Widget Instructions
widget_instructions_ = new QTextEdit(this);
widget_instructions_ = new QLabel(this);
widget_instructions_->setAlignment(Qt::AlignLeft | Qt::AlignTop);
widget_instructions_->setWordWrap(true);
widget_instructions_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
widget_instructions_->setText(
"All settings for MoveIt! are stored in the MoveIt! configuration package. Here you have "
"the option to create a new configuration package or load an existing one. Note: "
"changes to a MoveIt! configuration package outside this Setup Assistant are likely to be "
"overwritten by this tool.");

// Change color of TextEdit
QPalette p = widget_instructions_->palette();
p.setColor(QPalette::Active, QPalette::Base, this->palette().color(QWidget::backgroundRole()));
p.setColor(QPalette::Inactive, QPalette::Base, this->palette().color(QWidget::backgroundRole()));
widget_instructions_->setPalette(p);

// Make TextEdit behave like QLabel
widget_instructions_->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
widget_instructions_->setReadOnly(true);
widget_instructions_->setFrameShape(QFrame::NoFrame);
widget_instructions_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

layout->addWidget(widget_instructions_);
layout->setAlignment(widget_instructions_, Qt::AlignTop);

Expand Down
2 changes: 1 addition & 1 deletion moveit_setup_assistant/src/widgets/start_screen_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private Q_SLOTS:
// Load file button
QPushButton* btn_new_;
QPushButton* btn_exist_;
QTextEdit* widget_instructions_;
QLabel* widget_instructions_;
};
}

Expand Down