mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #335, support for status bar for dock widgets
* status bar when floating * improved info area status * removed ui parts from infoarea
This commit is contained in:
committed by
Roland Winklmeier
parent
718965d78d
commit
8acf8e2ed0
@@ -67,10 +67,8 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->m_sizeFloatingShown.isValid())
|
||||
{
|
||||
// minimumSizeHint() not as good as expected
|
||||
// manually setting size, all other approaches failed
|
||||
QSize m(300, 400);
|
||||
this->setMinimumSize(m);
|
||||
this->window()->setMinimumSize(m);
|
||||
this->window()->resize(m);
|
||||
this->m_sizeFloatingShown = this->window()->size();
|
||||
}
|
||||
@@ -78,6 +76,7 @@ namespace BlackGui
|
||||
{
|
||||
this->window()->resize(m_sizeFloatingShown);
|
||||
}
|
||||
|
||||
if (this->m_sizeFloatingHidden.isValid())
|
||||
{
|
||||
// was already initialized, override
|
||||
@@ -88,17 +87,18 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->m_sizeFloatingHidden.isValid())
|
||||
{
|
||||
// minimumSizeHint() not as good as expected
|
||||
QSize m(300, 125);
|
||||
this->setMinimumSize(m);
|
||||
// manually setting size, all other approaches failed
|
||||
QSize m(300, 150);
|
||||
this->window()->setMinimumSize(m);
|
||||
this->window()->resize(m);
|
||||
this->m_sizeFloatingHidden = this->window()->size();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->window()->setMinimumSize(m_sizeFloatingHidden);
|
||||
this->window()->resize(m_sizeFloatingHidden);
|
||||
}
|
||||
|
||||
if (this->m_sizeFloatingShown.isValid())
|
||||
{
|
||||
// was already initialized, override
|
||||
|
||||
@@ -6,10 +6,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>200</width>
|
||||
<height>129</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
@@ -54,7 +60,7 @@
|
||||
<item alignment="Qt::AlignTop">
|
||||
<widget class="BlackGui::CShowHideBar" name="wip_CockpitComPanelShowHideBar" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -62,7 +68,13 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>10</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_CockpitVoiceRooms">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_CockpitVoiceRooms">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -58,7 +58,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_CockpitVoiceRooms">
|
||||
<widget class="QWidget" name="qw_CockpitVoiceRoomsInner">
|
||||
<layout class="QVBoxLayout" name="vl_CockpitVoiceRooms">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
@@ -88,7 +88,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Audio">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Audio">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -110,7 +110,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_Audio">
|
||||
<widget class="QWidget" name="qw_AudioInner">
|
||||
<layout class="QVBoxLayout" name="vl_Audio">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
|
||||
@@ -276,6 +276,7 @@ namespace BlackGui
|
||||
{
|
||||
CFlightPlan flightPlan;
|
||||
CStatusMessageList messages = this->validateAndInitializeFlightPlan(flightPlan);
|
||||
CLogMessage(this).validations(messages);
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::ps_resetFlightPlan()
|
||||
|
||||
@@ -96,9 +96,11 @@ namespace BlackGui
|
||||
case InfoAreaMappings:
|
||||
case InfoAreaSettings:
|
||||
case InfoAreaTextMessages:
|
||||
case InfoAreaFlightPlan:
|
||||
return QSize(600, 400);
|
||||
break;
|
||||
case InfoAreaFlightPlan:
|
||||
return QSize(625, 500);
|
||||
break;
|
||||
default:
|
||||
return QSize(400, 300);
|
||||
break;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<set>QMainWindow::AllowTabbedDocks|QMainWindow::ForceTabbedDocks</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="qw_centralWidgetEmpty"/>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Cockpit">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Cockpit">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>524287</width>
|
||||
@@ -55,7 +55,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_CockpitInner">
|
||||
<widget class="QWidget" name="qw_CockpitInner">
|
||||
<layout class="QVBoxLayout" name="vl_Cockpit">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -78,7 +78,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Aircrafts">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Aircrafts">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -97,7 +97,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_AircraftsInner">
|
||||
<widget class="QWidget" name="qw_AircraftsInner">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -139,7 +139,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_AtcStations">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_AtcStations">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -158,7 +158,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_AtcStationsInner">
|
||||
<widget class="QWidget" name="qw_AtcStationsInner">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -200,7 +200,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Users">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Users">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -216,7 +216,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_UsersInner">
|
||||
<widget class="QWidget" name="qw_UsersInner">
|
||||
<layout class="QVBoxLayout" name="vl_Users">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -246,7 +246,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_TextMessages">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_TextMessages">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -262,7 +262,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_TextMessagesInner">
|
||||
<widget class="QWidget" name="qw_TextMessagesInner">
|
||||
<layout class="QVBoxLayout" name="vl_TextMessages">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -292,7 +292,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Simulator">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Simulator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -308,7 +308,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_SimulatorInner">
|
||||
<widget class="QWidget" name="qw_SimulatorInner">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -338,7 +338,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_FlightPlan">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_FlightPlan">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -354,7 +354,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_FlightPlanInner">
|
||||
<widget class="QWidget" name="qw_FlightPlanInner">
|
||||
<layout class="QVBoxLayout" name="vl_FlightPlan">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -384,7 +384,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Weather">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Weather">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
@@ -400,7 +400,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_WeatherInner">
|
||||
<widget class="QWidget" name="qw_WeatherInner">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -433,7 +433,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Mappings">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Mappings">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -449,7 +449,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_MappingsInner">
|
||||
<widget class="QWidget" name="qw_MappingsInner">
|
||||
<layout class="QVBoxLayout" name="vl_Mappings">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -479,7 +479,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Log">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Log">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
@@ -495,7 +495,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_LogInner">
|
||||
<widget class="QWidget" name="qw_LogInner">
|
||||
<layout class="QVBoxLayout" name="vl_Log">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -525,7 +525,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dw_Settings">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Settings">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -541,7 +541,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dw_SettingsInner">
|
||||
<widget class="QWidget" name="qw_SettingsInner">
|
||||
<layout class="QVBoxLayout" name="vl_Settings">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
|
||||
@@ -14,36 +14,39 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QStyleOption>
|
||||
#include <QPainter>
|
||||
#include <QLayout>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
CDockWidget::CDockWidget(QWidget *parent) : QDockWidget(parent)
|
||||
{
|
||||
|
||||
this->ps_onStyleSheetsChanged();
|
||||
this->initTitleBarWidgets();
|
||||
|
||||
// context menu
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::ps_showContextMenu);
|
||||
|
||||
// connect
|
||||
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::ps_onTopLevelChanged);
|
||||
connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CDockWidget::ps_onStyleSheetsChanged);
|
||||
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::ps_onVisibilityChanged);
|
||||
|
||||
// context menu
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::ps_showContextMenu);
|
||||
}
|
||||
|
||||
void CDockWidget::setOriginalTitleBar()
|
||||
{
|
||||
if (!this->m_titleBarOriginal) { this->initTitleBarWidgets(); }
|
||||
if (this->titleBarWidget() == this->m_titleBarOriginal) return; // on purpose, as I do not know what happens when I call setTitleBar
|
||||
this->setTitleBarWidget(this->m_titleBarOriginal);
|
||||
if (!this->m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
|
||||
if (this->titleBarWidget() == this->m_titleBarWidgetOriginal) return; // on purpose, as I do not know what happens when I call setTitleBar
|
||||
this->setTitleBarWidget(this->m_titleBarWidgetOriginal);
|
||||
}
|
||||
|
||||
void CDockWidget::setEmptyTitleBar()
|
||||
{
|
||||
if (!this->m_titleBarOriginal) { this->initTitleBarWidgets(); }
|
||||
if (this->titleBarWidget() == this->m_emptyTitleBar) return; // on purpose, as I do not know what happens when I call setTitleBar
|
||||
this->setTitleBarWidget(this->m_emptyTitleBar);
|
||||
if (!this->m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
|
||||
if (this->titleBarWidget() == this->m_titleBarWidgetEmpty) return; // on purpose, as I do not know what happens when I call setTitleBar
|
||||
this->setTitleBarWidget(this->m_titleBarWidgetEmpty);
|
||||
}
|
||||
|
||||
void CDockWidget::setNullTitleBar()
|
||||
@@ -57,6 +60,18 @@ namespace BlackGui
|
||||
QDockWidget::setWindowTitle(title);
|
||||
}
|
||||
|
||||
void CDockWidget::displayStatusMessage(const BlackMisc::CStatusMessage &statusMessage)
|
||||
{
|
||||
if (!this->isFloating()) { return; }
|
||||
this->m_statusBar.displayStatusMessage(statusMessage);
|
||||
}
|
||||
|
||||
void CDockWidget::displayStatusMessages(const BlackMisc::CStatusMessageList &statusMessages)
|
||||
{
|
||||
if (!this->isFloating()) { return; }
|
||||
this->m_statusBar.displayStatusMessages(statusMessages);
|
||||
}
|
||||
|
||||
void CDockWidget::showTitleWhenDocked(bool show)
|
||||
{
|
||||
this->m_windowTitleWhenDocked = show;
|
||||
@@ -121,6 +136,9 @@ namespace BlackGui
|
||||
void CDockWidget::initialFloating()
|
||||
{
|
||||
|
||||
// init status bar, as we have now all structure set
|
||||
this->initStatusBar();
|
||||
|
||||
// for the first time resize
|
||||
if (!this->m_preferredSizeWhenFloating.isNull())
|
||||
{
|
||||
@@ -149,8 +167,9 @@ namespace BlackGui
|
||||
this->setContentsMargins(this->m_marginsWhenFloating);
|
||||
if (!this->m_wasAlreadyFloating)
|
||||
{
|
||||
this->initalFloating();
|
||||
this->initialFloating();
|
||||
}
|
||||
this->m_statusBar.show();
|
||||
this->m_wasAlreadyFloating = true;
|
||||
}
|
||||
else
|
||||
@@ -160,6 +179,7 @@ namespace BlackGui
|
||||
QDockWidget::setWindowTitle("");
|
||||
}
|
||||
|
||||
this->m_statusBar.hide();
|
||||
this->setEmptyTitleBar();
|
||||
this->setContentsMargins(this->m_marginsWhenDocked);
|
||||
}
|
||||
@@ -168,9 +188,33 @@ namespace BlackGui
|
||||
|
||||
void CDockWidget::initTitleBarWidgets()
|
||||
{
|
||||
this->m_titleBarOriginal = this->titleBarWidget();
|
||||
this->m_emptyTitleBar = new QWidget(this);
|
||||
this->setTitleBarWidget(this->m_emptyTitleBar);
|
||||
this->m_titleBarWidgetOriginal = this->titleBarWidget();
|
||||
this->m_titleBarWidgetEmpty = new QWidget(this);
|
||||
this->setTitleBarWidget(this->m_titleBarWidgetEmpty);
|
||||
}
|
||||
|
||||
void CDockWidget::initStatusBar()
|
||||
{
|
||||
if (this->m_statusBar.getStatusBar()) { return; }
|
||||
if (!this->m_allowStatusBar) { return; }
|
||||
this->m_statusBar.initStatusBar();
|
||||
|
||||
QWidget *innerDockWidget = this->widget(); // the inner widget containing the layout
|
||||
Q_ASSERT(innerDockWidget);
|
||||
if (!innerDockWidget) { return; }
|
||||
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(innerDockWidget->layout());
|
||||
Q_ASSERT(vLayout);
|
||||
if (!vLayout) { return; }
|
||||
vLayout->addWidget(this->m_statusBar.getStatusBar(), 0, Qt::AlignBottom);
|
||||
|
||||
// adjust stretching of the original widget. It was the only widget so far
|
||||
// and should occupy maximum space
|
||||
QWidget *compWidget = innerDockWidget->findChild<QWidget *>(QString(), Qt::FindDirectChildrenOnly);
|
||||
Q_ASSERT(compWidget);
|
||||
if (!compWidget) { return; }
|
||||
QSizePolicy sizePolicy = compWidget->sizePolicy();
|
||||
sizePolicy.setVerticalStretch(1);
|
||||
compWidget->setSizePolicy(sizePolicy);
|
||||
}
|
||||
|
||||
void CDockWidget::ps_showContextMenu(const QPoint &pos)
|
||||
@@ -191,4 +235,4 @@ namespace BlackGui
|
||||
{
|
||||
// void, for further extensions
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
#ifndef BLACKGUI_DOCKWIDGET_H
|
||||
#define BLACKGUI_DOCKWIDGET_H
|
||||
|
||||
#include "components/enableforruntime.h"
|
||||
#include "managedstatusbar.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QStatusBar>
|
||||
#include <QMenu>
|
||||
#include <QLabel>
|
||||
|
||||
@@ -68,6 +70,9 @@ namespace BlackGui
|
||||
//! \remarks Logical vsibility as in \sa QDockWidget::visibilityChanged
|
||||
bool isWidgetVisible() const { return this->m_dockWidgetVisible && this->isVisible(); }
|
||||
|
||||
//! Allow a status bar to be displayed
|
||||
void allowStatusBar(bool allow) { this->m_allowStatusBar = allow; }
|
||||
|
||||
//! Show the window title when docked
|
||||
void showTitleWhenDocked(bool show);
|
||||
|
||||
@@ -93,6 +98,12 @@ namespace BlackGui
|
||||
//! Set title and internally keep a backup
|
||||
void setWindowTitle(const QString &title);
|
||||
|
||||
//! Display status message
|
||||
void displayStatusMessage(const BlackMisc::CStatusMessage &statusMessage);
|
||||
|
||||
//! Display status messages
|
||||
void displayStatusMessages(const BlackMisc::CStatusMessageList &statusMessages);
|
||||
|
||||
signals:
|
||||
//! Top level has changed for given widget
|
||||
void widgetTopLevelChanged(CDockWidget *, bool topLevel);
|
||||
@@ -130,21 +141,25 @@ namespace BlackGui
|
||||
virtual void ps_onVisibilityChanged(bool visible);
|
||||
|
||||
private:
|
||||
QWidget *m_emptyTitleBar = nullptr; //!< replacing default title bar
|
||||
QWidget *m_titleBarOriginal = nullptr; //!< the original title bar
|
||||
QMargins m_marginsWhenFloating; //!< Offsets when window is floating
|
||||
QMargins m_marginsWhenDocked; //!< Offsets when window is floating
|
||||
QString m_windowTitleBackup; //!< original title, even if the widget title is deleted for layout purposes
|
||||
QSize m_preferredSizeWhenFloating; //!< preferred size men floating 1st time
|
||||
QPoint m_offsetWhenFloating; //!< initial offset to main window when floating first time
|
||||
QWidget *m_titleBarWidgetEmpty = nullptr; //!< replacing default title bar
|
||||
QWidget *m_titleBarWidgetOriginal = nullptr; //!< the original title bar
|
||||
QMargins m_marginsWhenFloating; //!< Offsets when window is floating
|
||||
QMargins m_marginsWhenDocked; //!< Offsets when window is docked
|
||||
CManagedStatusBar m_statusBar; //!< Status bar when floating
|
||||
QString m_windowTitleBackup; //!< original title, even if the widget title is deleted for layout purposes
|
||||
QSize m_preferredSizeWhenFloating; //!< preferred size when floating 1st time
|
||||
QPoint m_offsetWhenFloating; //!< initial offset to main window when floating first time
|
||||
bool m_allowStatusBar = true;
|
||||
bool m_windowTitleWhenDocked = true;
|
||||
bool m_wasAlreadyFloating = false;
|
||||
bool m_selected = false; //!< selected when tabbed
|
||||
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
||||
bool m_selected = false; //!< selected when tabbed
|
||||
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
||||
|
||||
//! Empty widget with no size
|
||||
void initTitleBarWidgets();
|
||||
|
||||
//! Init status bar
|
||||
void initStatusBar();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -152,7 +152,8 @@ namespace BlackGui
|
||||
{
|
||||
// we assume that there can only be 1, non floating info area,
|
||||
// which is the only visible one
|
||||
if (this->m_tabBar->count() < 1) { return nullptr; }
|
||||
// selecting is tab text independent (can be hidden)
|
||||
if (!this->m_tabBar || this->m_tabBar->count() < 1) { return nullptr; }
|
||||
foreach(const CDockWidgetInfoArea * ia, m_dockWidgetInfoAreas)
|
||||
{
|
||||
if (ia->isFloating()) { continue; }
|
||||
@@ -161,6 +162,15 @@ namespace BlackGui
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int CInfoArea::getSelectedDockInfoAreaIndex() const
|
||||
{
|
||||
const CDockWidgetInfoArea *sel = getSelectedDockInfoArea();
|
||||
if (!sel) { return -1; }
|
||||
const QString t(sel->windowTitleBackup());
|
||||
int ia = getAreaIndexByWindowTitle(t);
|
||||
return ia;
|
||||
}
|
||||
|
||||
QList<const CDockWidgetInfoArea *> CInfoArea::getDockWidgetInfoAreas() const
|
||||
{
|
||||
QList<const CDockWidgetInfoArea *> constDockWidgets;
|
||||
@@ -187,6 +197,19 @@ namespace BlackGui
|
||||
return actions;
|
||||
}
|
||||
|
||||
QList<int> CInfoArea::getAreaIndexesDockedOrFloating(bool floating) const
|
||||
{
|
||||
QList<int> indexes;
|
||||
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
|
||||
{
|
||||
if (this->m_dockWidgetInfoAreas.at(i)->isFloating() == floating)
|
||||
{
|
||||
indexes.append(i);
|
||||
}
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
void CInfoArea::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
@@ -258,9 +281,9 @@ namespace BlackGui
|
||||
{
|
||||
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex);
|
||||
Q_ASSERT(dw);
|
||||
if (!dw) return;
|
||||
if (!dw) { return; }
|
||||
Q_ASSERT(this->m_tabBar);
|
||||
if (m_tabBar->count() < 1) return;
|
||||
if (m_tabBar->count() < 1) { return; }
|
||||
|
||||
if (dw->isFloating())
|
||||
{
|
||||
@@ -309,6 +332,21 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoArea::displayStatusMessage(const CStatusMessage &statusMessage)
|
||||
{
|
||||
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas)
|
||||
{
|
||||
dw->displayStatusMessage(statusMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoArea::displayStatusMessages(const CStatusMessageList &statusMessages)
|
||||
{
|
||||
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas)
|
||||
{
|
||||
dw->displayStatusMessages(statusMessages);
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoArea::ps_setDockArea(Qt::DockWidgetArea area)
|
||||
{
|
||||
@@ -316,7 +354,7 @@ namespace BlackGui
|
||||
{
|
||||
Qt::DockWidgetAreas newAreas = static_cast<Qt::DockWidgetAreas>(area);
|
||||
Qt::DockWidgetAreas oldAreas = dw->allowedAreas();
|
||||
if (oldAreas == newAreas) continue;
|
||||
if (oldAreas == newAreas) { continue; }
|
||||
dw->setAllowedAreas(newAreas);
|
||||
this->addDockWidget(area, dw);
|
||||
}
|
||||
@@ -398,7 +436,7 @@ namespace BlackGui
|
||||
|
||||
// signals
|
||||
connect(this->m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::ps_tabBarDoubleClicked);
|
||||
connect(this->m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::tabBarCurrentChanged);
|
||||
connect(this->m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::ps_onTabBarIndexChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -481,6 +519,20 @@ namespace BlackGui
|
||||
return infoAreas;
|
||||
}
|
||||
|
||||
void CInfoArea::ps_emitInfoAreaStatus()
|
||||
{
|
||||
int sia = this->getSelectedDockInfoAreaIndex();
|
||||
QList<int> floating = this->getAreaIndexesDockedOrFloating(true);
|
||||
QList<int> docked = this->getAreaIndexesDockedOrFloating(false);
|
||||
emit changedInfoAreaStatus(sia, docked, floating);
|
||||
}
|
||||
|
||||
void CInfoArea::ps_onTabBarIndexChanged(int tabBarIndex)
|
||||
{
|
||||
emit changedInfoAreaTabBarIndex(tabBarIndex);
|
||||
ps_emitInfoAreaStatus();
|
||||
}
|
||||
|
||||
int CInfoArea::countDockedWidgetInfoAreas() const
|
||||
{
|
||||
if (!this->m_tabBar) return 0;
|
||||
@@ -503,7 +555,7 @@ namespace BlackGui
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int CInfoArea::getAreaIndexByWindowTitle(const QString &title)
|
||||
int CInfoArea::getAreaIndexByWindowTitle(const QString &title) const
|
||||
{
|
||||
Q_ASSERT(!title.isEmpty());
|
||||
for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++)
|
||||
@@ -567,7 +619,7 @@ namespace BlackGui
|
||||
{
|
||||
if (this->m_lockTabBar) return;
|
||||
CDockWidgetInfoArea *dw = this->getDockWidgetInfoAreaByTabBarIndex(tabBarIndex);
|
||||
if (!dw) return;
|
||||
if (!dw) { return; }
|
||||
dw->toggleFloating();
|
||||
}
|
||||
|
||||
@@ -575,15 +627,21 @@ namespace BlackGui
|
||||
{
|
||||
Q_ASSERT(dockWidget);
|
||||
Q_UNUSED(topLevel);
|
||||
if (!dockWidget) return;
|
||||
if (!dockWidget) { return; }
|
||||
|
||||
// fix pixmaps
|
||||
this->setTabPixmaps();
|
||||
|
||||
// select index
|
||||
if (topLevel) { return; }
|
||||
CDockWidgetInfoArea *dwia = dynamic_cast<CDockWidgetInfoArea *>(dockWidget);
|
||||
this->setCurrentTabIndex(dwia);
|
||||
if (!topLevel)
|
||||
{
|
||||
CDockWidgetInfoArea *dwia = dynamic_cast<CDockWidgetInfoArea *>(dockWidget);
|
||||
this->setCurrentTabIndex(dwia);
|
||||
}
|
||||
|
||||
// when toplevel is changed, I need a round in the event loop until
|
||||
// current tab bar widget is visible
|
||||
QTimer::singleShot(250, this, SLOT(ps_emitInfoAreaStatus()));
|
||||
}
|
||||
|
||||
void CInfoArea::ps_onStyleSheetChanged()
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
#include <QMainWindow>
|
||||
#include <QTabBar>
|
||||
#include <QPixmap>
|
||||
|
||||
namespace Ui { class CInfoArea; }
|
||||
#include <QList>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -43,17 +42,26 @@ namespace BlackGui
|
||||
//! Get the selected info area (non floating, selected in tabbar)
|
||||
const CDockWidgetInfoArea *getSelectedDockInfoArea() const;
|
||||
|
||||
//! Get the selected info area (non floating, selected in tabbar)
|
||||
int getSelectedDockInfoAreaIndex() const;
|
||||
|
||||
//! Own dockable widgets
|
||||
QList<const CDockWidgetInfoArea *> getDockWidgetInfoAreas() const;
|
||||
|
||||
//! Create a list of actions to select the info areas. This could be used in a menu
|
||||
//! or somewhere else.
|
||||
//! Create a list of actions to select the info areas.
|
||||
//! This could be used in a menu or somewhere else.
|
||||
//! \param parent which will own the action (deletion)
|
||||
QList<QAction *> getInfoAreaSelectActions(QWidget *parent) const;
|
||||
|
||||
//! Docked area indexes
|
||||
QList<int> getAreaIndexesDockedOrFloating(bool floating) const;
|
||||
|
||||
signals:
|
||||
//! Tab bar changed
|
||||
void tabBarCurrentChanged(int index);
|
||||
void changedInfoAreaTabBarIndex(int index);
|
||||
|
||||
//! Status of info area changed
|
||||
void changedInfoAreaStatus(int currentTabIndex, QList<int> dockedAreas, QList<int> floatingAreas);
|
||||
|
||||
public slots:
|
||||
//! Dock all widgets
|
||||
@@ -86,6 +94,12 @@ namespace BlackGui
|
||||
//! Select next right tab
|
||||
void selectRightTab();
|
||||
|
||||
//! Display status message
|
||||
void displayStatusMessage(const BlackMisc::CStatusMessage &statusMessage);
|
||||
|
||||
//! Display status messages
|
||||
void displayStatusMessages(const BlackMisc::CStatusMessageList &statusMessages);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
explicit CInfoArea(QWidget *parent = nullptr);
|
||||
@@ -98,7 +112,7 @@ namespace BlackGui
|
||||
|
||||
//! \copydoc QWidget::keyPressEvent
|
||||
//! \remarks nor fully sufficient, as the info area is hardly having focus
|
||||
virtual void keyPressEvent(QKeyEvent * event) override;
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
//! Preferred size when floating (size hint)
|
||||
virtual QSize getPreferredSizeWhenFloating(int areaIndex) const = 0;
|
||||
@@ -115,7 +129,6 @@ namespace BlackGui
|
||||
void ps_setTabBarPosition(QTabWidget::TabPosition position);
|
||||
|
||||
private:
|
||||
Ui::CInfoArea *ui = nullptr;
|
||||
QList<CDockWidgetInfoArea *> m_dockWidgetInfoAreas ;
|
||||
QTabBar *m_tabBar = nullptr;
|
||||
bool m_showTabTexts = true; //!< texts for tabs
|
||||
@@ -139,7 +152,7 @@ namespace BlackGui
|
||||
CDockWidgetInfoArea *getDockWidgetInfoAreaByWindowTitle(const QString &title);
|
||||
|
||||
//! Corresponding dockable widget for given window title
|
||||
int getAreaIndexByWindowTitle(const QString &title);
|
||||
int getAreaIndexByWindowTitle(const QString &title) const;
|
||||
|
||||
//! Tab bar index by title
|
||||
int getTabBarIndexByTitle(const QString &title) const;
|
||||
@@ -206,6 +219,12 @@ namespace BlackGui
|
||||
//! Dock / floating of the whole info area
|
||||
void ps_setInfoAreaFloating(bool floating);
|
||||
|
||||
//! Emit current status, \sa changedInfoAreaStatus
|
||||
void ps_emitInfoAreaStatus();
|
||||
|
||||
//! Tab bar index changed
|
||||
void ps_onTabBarIndexChanged(int tabBarIndex);
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user