Commit 65980cfb authored by Michael Carpenter's avatar Michael Carpenter

Fix for dock widget titlebars moving around when in advanced mode

parent ec18ee40
......@@ -372,7 +372,8 @@ HEADERS += src/MG.h \
src/ui/QGCHilXPlaneConfiguration.h \
src/ui/designer/QGCComboBox.h \
src/ui/designer/QGCTextLabel.h \
src/ui/submainwindow.h
src/ui/submainwindow.h \
src/ui/dockwidgettitlebareventfilter.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -537,7 +538,8 @@ SOURCES += src/main.cc \
src/ui/QGCHilXPlaneConfiguration.cc \
src/ui/designer/QGCComboBox.cc \
src/ui/designer/QGCTextLabel.cc \
src/ui/submainwindow.cpp
src/ui/submainwindow.cpp \
src/ui/dockwidgettitlebareventfilter.cpp
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -38,7 +38,7 @@ This file is part of the QGROUNDCONTROL project
#include <QGCHilLink.h>
#include <QGCHilConfiguration.h>
#include <QGCHilFlightGearConfiguration.h>
#include "dockwidgettitlebareventfilter.h"
#include "QGC.h"
#include "MAVLinkSimulationLink.h"
#include "SerialLink.h"
......@@ -613,6 +613,7 @@ void MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString title,Q
QLabel *label = new QLabel(this);
label->setText(title);
widget->setTitleBarWidget(label);
label->installEventFilter(new DockWidgetTitleBarEventFilter());
}
else
{
......@@ -625,6 +626,8 @@ void MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString title,Q
QLabel *label = new QLabel(this);
label->setText(title);
dockToTitleBarMap[widget] = label;
label->installEventFilter(new DockWidgetTitleBarEventFilter());
label->hide();
}
widget->setObjectName(objectname);
widget->setWidget(child);
......@@ -1007,29 +1010,30 @@ void MainWindow::saveScreen()
}
void MainWindow::enableDockWidgetTitleBars(bool enabled)
{
dockWidgetTitleBarEnabled = enabled;
QSettings settings;
settings.beginGroup("QGC_MAINWINDOW");
settings.setValue("DOCK_WIDGET_TITLEBARS",dockWidgetTitleBarEnabled);
settings.endGroup();
settings.sync();
if (!isAdvancedMode)
{
dockWidgetTitleBarEnabled = enabled;
QSettings settings;
settings.beginGroup("QGC_MAINWINDOW");
settings.setValue("DOCK_WIDGET_TITLEBARS",dockWidgetTitleBarEnabled);
settings.endGroup();
settings.sync();
if (enabled)
{
for (QMap<QDockWidget*,QWidget*>::const_iterator i=dockToTitleBarMap.constBegin();i!=dockToTitleBarMap.constEnd();i++)
{
QLabel *label = new QLabel(this);
label->setText(i.value()->windowTitle());
label->setText(i.key()->windowTitle());
i.key()->setTitleBarWidget(label);
label->setEnabled(false);
//label->setEnabled(false);
label->installEventFilter(new DockWidgetTitleBarEventFilter());
}
}
else
{
for (QMap<QDockWidget*,QWidget*>::const_iterator i=dockToTitleBarMap.constBegin();i!=dockToTitleBarMap.constEnd();i++)
{
i.key()->setTitleBarWidget(0);
i.key()->setTitleBarWidget(new QWidget(this));
}
}
}
......
......@@ -44,7 +44,7 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
//Dock widget title bars
ui->titleBarCheckBox->setChecked(MainWindow::instance()->dockWidgetTitleBarsEnabled());
ui->titleBarCheckBox,SIGNAL(clicked(bool)),MainWindow::instance(),SLOT(enableDockWidgetTitleBars(bool));
connect(ui->titleBarCheckBox,SIGNAL(clicked(bool)),MainWindow::instance(),SLOT(enableDockWidgetTitleBars(bool)));
// Style
MainWindow::QGC_MAINWINDOW_STYLE style = (MainWindow::QGC_MAINWINDOW_STYLE)MainWindow::instance()->getStyle();
......
......@@ -86,7 +86,7 @@
<string>Show Docked Widget title bars when NOT in advanced Mode.</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
......
#include "dockwidgettitlebareventfilter.h"
#include <QDebug>
#include <QEvent>
DockWidgetTitleBarEventFilter::DockWidgetTitleBarEventFilter(QObject *parent) : QObject(parent)
{
}
bool DockWidgetTitleBarEventFilter::eventFilter(QObject *object,QEvent *event)
{
qDebug() << event->type();
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
{
return true;
}
return QObject::eventFilter(object,event);
}
#ifndef DOCKWIDGETTITLEBAREVENTFILTER_H
#define DOCKWIDGETTITLEBAREVENTFILTER_H
#include <QObject>
class DockWidgetTitleBarEventFilter : public QObject
{
Q_OBJECT
public:
explicit DockWidgetTitleBarEventFilter(QObject *parent = 0);
protected:
bool eventFilter(QObject *object,QEvent *event);
signals:
public slots:
};
#endif // DOCKWIDGETTITLEBAREVENTFILTER_H
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