Commit ec18ee40 authored by Michael Carpenter's avatar Michael Carpenter

New titlebar widgets to give dock windows titles when not in advanced mode

parent 2a794534
......@@ -104,6 +104,7 @@ MainWindow::MainWindow(QWidget *parent):
lowPowerMode(false)
{
hide();
dockWidgetTitleBarEnabled = true;
isAdvancedMode = false;
emit initStatusChanged("Loading UI Settings..");
loadSettings();
......@@ -606,12 +607,24 @@ void MainWindow::createDockWidget(QWidget *parent,QWidget *child,QString title,Q
QDockWidget *widget = new QDockWidget(title,this);
if (!isAdvancedMode)
{
dockToTitleBarMap[widget] = widget->titleBarWidget();
widget->setTitleBarWidget(new QWidget(this));
if (dockWidgetTitleBarEnabled)
{
dockToTitleBarMap[widget] = widget->titleBarWidget();
QLabel *label = new QLabel(this);
label->setText(title);
widget->setTitleBarWidget(label);
}
else
{
dockToTitleBarMap[widget] = widget->titleBarWidget();
widget->setTitleBarWidget(new QWidget(this));
}
}
else
{
dockToTitleBarMap[widget] = new QWidget(this);
QLabel *label = new QLabel(this);
label->setText(title);
dockToTitleBarMap[widget] = label;
}
widget->setObjectName(objectname);
widget->setWidget(child);
......@@ -903,7 +916,9 @@ void MainWindow::loadSettings()
autoReconnect = settings.value("AUTO_RECONNECT", autoReconnect).toBool();
currentStyle = (QGC_MAINWINDOW_STYLE)settings.value("CURRENT_STYLE", currentStyle).toInt();
lowPowerMode = settings.value("LOW_POWER_MODE", lowPowerMode).toBool();
dockWidgetTitleBarEnabled = settings.value("DOCK_WIDGET_TITLEBARS",dockWidgetTitleBarEnabled).toBool();
settings.endGroup();
enableDockWidgetTitleBars(dockWidgetTitleBarEnabled);
}
void MainWindow::storeSettings()
......@@ -990,6 +1005,35 @@ void MainWindow::saveScreen()
window.save(screenFileName, format.toAscii());
}
}
void MainWindow::enableDockWidgetTitleBars(bool enabled)
{
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());
i.key()->setTitleBarWidget(label);
label->setEnabled(false);
}
}
else
{
for (QMap<QDockWidget*,QWidget*>::const_iterator i=dockToTitleBarMap.constBegin();i!=dockToTitleBarMap.constEnd();i++)
{
i.key()->setTitleBarWidget(0);
}
}
}
}
void MainWindow::enableAutoReconnect(bool enabled)
{
......@@ -1745,7 +1789,6 @@ void MainWindow::setAdvancedMode()
QWidget *widget = i.key()->titleBarWidget();
i.key()->setTitleBarWidget(i.value());
dockToTitleBarMap[i.key()] = widget;
}
}
}
......
......@@ -119,6 +119,12 @@ public:
return autoReconnect;
}
/** @brief Get title bar mode setting */
bool dockWidgetTitleBarsEnabled()
{
return dockWidgetTitleBarEnabled;
}
/** @brief Get low power mode setting */
bool lowPowerModeEnabled()
{
......@@ -186,6 +192,8 @@ public slots:
void reloadStylesheet();
/** @brief Let the user select the CSS style sheet */
void selectStylesheet();
/** @breif Enable title bars on dock widgets when no in advanced mode */
void enableDockWidgetTitleBars(bool enabled);
/** @brief Automatically reconnect last link */
void enableAutoReconnect(bool enabled);
/** @brief Save power by reducing update rates */
......@@ -436,6 +444,7 @@ private:
QMap<QDockWidget*,QWidget*> dockToTitleBarMap;
QMap<VIEW_SECTIONS,QMap<QString,QWidget*> > centralWidgetToDockWidgetsMap;
bool isAdvancedMode;
bool dockWidgetTitleBarEnabled;
Ui::MainWindow ui;
QString getWindowStateKey();
......
......@@ -42,6 +42,10 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
ui->lowPowerCheckBox->setChecked(MainWindow::instance()->lowPowerModeEnabled());
connect(ui->lowPowerCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableLowPowerMode(bool)));
//Dock widget title bars
ui->titleBarCheckBox->setChecked(MainWindow::instance()->dockWidgetTitleBarsEnabled());
ui->titleBarCheckBox,SIGNAL(clicked(bool)),MainWindow::instance(),SLOT(enableDockWidgetTitleBars(bool));
// Style
MainWindow::QGC_MAINWINDOW_STYLE style = (MainWindow::QGC_MAINWINDOW_STYLE)MainWindow::instance()->getStyle();
switch (style) {
......
......@@ -46,7 +46,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QRadioButton" name="nativeStyle">
<property name="text">
<string>Use native platform look and feel (Windows/Linux/Mac OS)</string>
......@@ -56,14 +56,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QRadioButton" name="indoorStyle">
<property name="text">
<string>Use indoor mission style (black background)</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QRadioButton" name="outdoorStyle">
<property name="text">
<string>Use outdoor mission style (light background)</string>
......@@ -80,6 +80,16 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="titleBarCheckBox">
<property name="text">
<string>Show Docked Widget title bars when NOT in advanced Mode.</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
......
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