Commit e62dd21c authored by LM's avatar LM

Fixed a number of small persistence bugs, made color assignment on click only;

parent f27e3b7a
......@@ -12,14 +12,14 @@
#define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 0.9.1 (Alpha RC1)"
#define QGC_APPLICATION_VERSION "v. 0.9.2 (Alpha RC1)"
namespace QGC
{
const QString APPNAME = "QGROUNDCONTROL";
const QString COMPANYNAME = "QGROUNDCONTROL";
const int APPLICATIONVERSION = 91; // 0.9.0
const int APPLICATIONVERSION = 92; // 0.9.0
}
#endif // QGC_CONFIGURATION_H
......@@ -691,6 +691,7 @@ void MainWindow::loadCustomWidget(const QString& fileName, bool singleinstance)
QDockWidget* dock = new QDockWidget(tool->getTitle(), this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
dock->setWidget(tool);
// dock->setObjectName();
tool->setParent(dock);
QAction* showAction = new QAction(tool->getTitle(), this);
......
......@@ -19,6 +19,7 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent) :
QWidget(parent),
mav(NULL),
mainMenuAction(NULL),
widgetTitle(title),
ui(new Ui::QGCToolWidget)
{
ui->setupUi(this);
......@@ -60,6 +61,18 @@ QGCToolWidget::~QGCToolWidget()
delete ui;
}
void QGCToolWidget::setParent(QWidget *parent)
{
QWidget::setParent(parent);
// Try with parent
QDockWidget* dock = dynamic_cast<QDockWidget*>(parent);
if (dock)
{
dock->setWindowTitle(getTitle());
dock->setObjectName(getTitle()+"DOCK");
}
}
/**
* @param parent Object later holding these widgets, usually the main window
* @return List of all widgets
......@@ -367,15 +380,9 @@ void QGCToolWidget::importWidget()
const QString QGCToolWidget::getTitle()
{
QDockWidget* parent = dynamic_cast<QDockWidget*>(this->parentWidget());
if (parent) {
return parent->windowTitle();
} else {
return this->windowTitle();
}
return widgetTitle;
}
void QGCToolWidget::setTitle()
{
QDockWidget* parent = dynamic_cast<QDockWidget*>(this->parentWidget());
......@@ -401,6 +408,7 @@ void QGCToolWidget::setTitle()
void QGCToolWidget::setTitle(QString title)
{
widgetTitle = title;
QDockWidget* parent = dynamic_cast<QDockWidget*>(this->parentWidget());
if (parent) {
QSettings settings;
......
......@@ -33,6 +33,7 @@ public:
int isVisible(int view) { return viewVisible.value(view, false); }
Qt::DockWidgetArea getDockWidgetArea(int view) { return dockWidgetArea.value(view, Qt::BottomDockWidgetArea); }
void setParent(QWidget *parent);
public slots:
void addUAS(UASInterface* uas);
......@@ -71,6 +72,7 @@ protected:
QAction* mainMenuAction; ///< Main menu action
QMap<int, Qt::DockWidgetArea> dockWidgetArea; ///< Dock widget area desired by this widget
QMap<int, bool> viewVisible; ///< Visibility in one view
QString widgetTitle;
void contextMenuEvent(QContextMenuEvent* event);
void createActions();
......
......@@ -417,9 +417,12 @@ void LinechartPlot::setVisible(QString id, bool visible)
{
if(curves.contains(id)) {
curves.value(id)->setVisible(visible);
if(visible) {
if(visible)
{
curves.value(id)->attach(this);
} else {
}
else
{
curves.value(id)->detach();
}
}
......@@ -639,7 +642,7 @@ void LinechartPlot::paintRealtime()
windowLock.unlock();
// Defined both on windows 32- and 64 bit
#ifndef _WIN32
#if !(defined Q_OS_WIN)
// const bool cacheMode =
// canvas()->testPaintAttribute(QwtPlotCanvas::PaintCached);
......@@ -648,11 +651,11 @@ void LinechartPlot::paintRealtime()
const QPaintEngine *pe = canvas()->paintEngine();
bool directPaint = pe->hasFeature(QPaintEngine::PaintOutsidePaintEvent);
if ( pe->type() == QPaintEngine::X11 ) {
//if ( pe->type() == QPaintEngine::X11 ) {
// Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
// works on X11. This has an tremendous effect on the performance..
directPaint = true;
}
//}
canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, directPaint);
#endif
......@@ -665,7 +668,7 @@ void LinechartPlot::paintRealtime()
replot();
}
#ifndef _WIN32
#if !(defined Q_OS_WIN)
canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, oldDirectPaint);
#endif
......
......@@ -566,6 +566,7 @@ void LinechartWidget::addCurve(const QString& curve, const QString& unit)
curvesWidgetLayout->addWidget(checkBox, labelRow, 0);
QWidget* colorIcon = new QWidget(this);
colorIcons.insert(curve+unit, colorIcon);
colorIcon->setMinimumSize(QSize(5, 14));
colorIcon->setMaximumSize(4, 14);
......@@ -576,13 +577,11 @@ void LinechartWidget::addCurve(const QString& curve, const QString& unit)
//checkBox->setText(QString());
label->setText(curve);
QColor color = plot->getColorForCurve(curve+unit);
if(color.isValid()) {
QString colorstyle;
colorstyle = colorstyle.sprintf("QWidget { background-color: #%X%X%X; }", color.red(), color.green(), color.blue());
colorIcon->setStyleSheet(colorstyle);
colorIcon->setAutoFillBackground(true);
}
QColor color(Qt::gray);// = plot->getColorForCurve(curve+unit);
QString colorstyle;
colorstyle = colorstyle.sprintf("QWidget { background-color: #%X%X%X; }", color.red(), color.green(), color.blue());
colorIcon->setStyleSheet(colorstyle);
colorIcon->setAutoFillBackground(true);
// Value
value = new QLabel(this);
......@@ -794,8 +793,22 @@ void LinechartWidget::takeButtonClick(bool checked)
QCheckBox* button = qobject_cast<QCheckBox*>(QObject::sender());
if(button != NULL) {
if(button != NULL)
{
activePlot->setVisible(button->objectName(), checked);
QColor color = activePlot->getColorForCurve(button->objectName());
if(color.isValid())
{
QString colorstyle;
colorstyle = colorstyle.sprintf("QWidget { background-color: #%X%X%X; }", color.red(), color.green(), color.blue());
QWidget* colorIcon = colorIcons.value(button->objectName(), 0);
if (colorIcon)
{
colorIcon->setStyleSheet(colorstyle);
colorIcon->setAutoFillBackground(true);
}
}
}
}
......
......@@ -123,6 +123,7 @@ protected:
QMap<QString, QLabel*>* curveMedians; ///< References to the curve medians
QMap<QString, QLabel*>* curveVariances; ///< References to the curve variances
QMap<QString, int> intData; ///< Current values for integer-valued curves
QMap<QString, QWidget*> colorIcons; ///< Reference to color icons
QWidget* curvesWidget; ///< The QWidget containing the curve selection button
QGridLayout* curvesWidgetLayout; ///< The layout for the curvesWidget QWidget
......
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