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