mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
refs #347, improvements in CInfoArea and CDockWidget
* renamed to toggleFloatingWholeInfoArea() for whole info area (in contrast to toggleInfoArea for individual areas) * signal for changedWholeInfoAreaFloating (allows the main GUI to hide this area if empty) * add. flag to understand m_resetedFloating * prepared for frameless dock widget (not yet implemented)
This commit is contained in:
committed by
Roland Winklmeier
parent
edaf1fba89
commit
bd2bf0d3ba
@@ -45,7 +45,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Toggle floating of given area
|
//! Toggle floating of given area
|
||||||
void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloating(static_cast<int>(infoArea)); }
|
void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast<int>(infoArea)); }
|
||||||
|
|
||||||
//! Select area
|
//! Select area
|
||||||
void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast<int>(infoArea)); }
|
void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast<int>(infoArea)); }
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Toggle floating of given area
|
//! Toggle floating of given area
|
||||||
void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloating(static_cast<int>(infoArea)); }
|
void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast<int>(infoArea)); }
|
||||||
|
|
||||||
//! Select area
|
//! Select area
|
||||||
void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast<int>(infoArea)); }
|
void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast<int>(infoArea)); }
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
CDockWidget::CDockWidget(QWidget *parent) : QDockWidget(parent)
|
CDockWidget::CDockWidget(QWidget *parent) :
|
||||||
|
QDockWidget(parent),
|
||||||
|
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this)
|
||||||
{
|
{
|
||||||
|
|
||||||
this->ps_onStyleSheetsChanged();
|
this->ps_onStyleSheetsChanged();
|
||||||
@@ -117,8 +119,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDockWidget::paintEvent(QPaintEvent *event)
|
void CDockWidget::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
CStyleSheetUtility::useStyleSheetInDerivedWidget(this, QStyle::PE_FrameDockWidget);
|
||||||
CStyleSheetUtility::useStyleSheetInDerivedWidget(this);
|
QDockWidget::paintEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::addToContextMenu(QMenu *contextMenu) const
|
void CDockWidget::addToContextMenu(QMenu *contextMenu) const
|
||||||
@@ -168,6 +170,13 @@ namespace BlackGui
|
|||||||
this->setContentsMargins(this->m_marginsWhenFloating);
|
this->setContentsMargins(this->m_marginsWhenFloating);
|
||||||
if (!this->m_wasAlreadyFloating) { this->initialFloating(); }
|
if (!this->m_wasAlreadyFloating) { this->initialFloating(); }
|
||||||
this->m_statusBar.show();
|
this->m_statusBar.show();
|
||||||
|
|
||||||
|
if (this->m_wasAlreadyFloating || this->m_resetedFloating)
|
||||||
|
{
|
||||||
|
//! \todo dock widget frameless
|
||||||
|
// this->setFrameless(topLevel);
|
||||||
|
}
|
||||||
|
|
||||||
this->m_wasAlreadyFloating = true;
|
this->m_wasAlreadyFloating = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -182,7 +191,12 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->setMinimumSize(this->m_initialDockedMinimumSize);
|
this->setMinimumSize(this->m_initialDockedMinimumSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// frameless
|
||||||
|
this->setFrameless(topLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// relay
|
||||||
emit this->widgetTopLevelChanged(this, topLevel);
|
emit this->widgetTopLevelChanged(this, topLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define BLACKGUI_DOCKWIDGET_H
|
#define BLACKGUI_DOCKWIDGET_H
|
||||||
|
|
||||||
#include "managedstatusbar.h"
|
#include "managedstatusbar.h"
|
||||||
|
#include "enableforframelesswindow.h"
|
||||||
|
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
@@ -31,7 +32,9 @@ namespace BlackGui
|
|||||||
//! \sa CInfoArea
|
//! \sa CInfoArea
|
||||||
//! \sa CDockWidgetInfoArea
|
//! \sa CDockWidgetInfoArea
|
||||||
//! \sa CDockWidgetInfoBar
|
//! \sa CDockWidgetInfoBar
|
||||||
class CDockWidget : public QDockWidget
|
class CDockWidget :
|
||||||
|
public QDockWidget,
|
||||||
|
public CEnableForFramelessWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ namespace BlackGui
|
|||||||
void showTitleWhenDocked(bool show);
|
void showTitleWhenDocked(bool show);
|
||||||
|
|
||||||
//! Reset first time floating, marked as never floated before
|
//! Reset first time floating, marked as never floated before
|
||||||
void resetWasAlreadyFLoating() { this->m_wasAlreadyFloating = false; }
|
void resetWasAlreadyFloating() { this->m_wasAlreadyFloating = false; this->m_resetedFloating = true; }
|
||||||
|
|
||||||
//! Was widget already floating?
|
//! Was widget already floating?
|
||||||
bool wasAlreadyFloating() const { return this->m_wasAlreadyFloating; }
|
bool wasAlreadyFloating() const { return this->m_wasAlreadyFloating; }
|
||||||
@@ -118,6 +121,12 @@ namespace BlackGui
|
|||||||
//! \copydoc QWidget::paintEvent
|
//! \copydoc QWidget::paintEvent
|
||||||
virtual void paintEvent(QPaintEvent *event) override;
|
virtual void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
|
//! \copy QMainWindow::mouseMoveEvent
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ; }
|
||||||
|
|
||||||
|
//! \copy QMainWindow::mousePressEvent
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); } }
|
||||||
|
|
||||||
//! Contribute to menu
|
//! Contribute to menu
|
||||||
virtual void addToContextMenu(QMenu *contextMenu) const;
|
virtual void addToContextMenu(QMenu *contextMenu) const;
|
||||||
|
|
||||||
@@ -153,6 +162,7 @@ namespace BlackGui
|
|||||||
bool m_allowStatusBar = true;
|
bool m_allowStatusBar = true;
|
||||||
bool m_windowTitleWhenDocked = true;
|
bool m_windowTitleWhenDocked = true;
|
||||||
bool m_wasAlreadyFloating = false;
|
bool m_wasAlreadyFloating = false;
|
||||||
|
bool m_resetedFloating = false;
|
||||||
bool m_selected = false; //!< selected when tabbed
|
bool m_selected = false; //!< selected when tabbed
|
||||||
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace BlackGui
|
|||||||
CInfoArea::CInfoArea(QWidget *parent) :
|
CInfoArea::CInfoArea(QWidget *parent) :
|
||||||
QMainWindow(parent), CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this)
|
QMainWindow(parent), CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this)
|
||||||
{
|
{
|
||||||
this->ps_setInfoAreaFloating(this->m_infoAreaFloating);
|
this->ps_setWholeInfoAreaFloating(this->m_infoAreaFloating);
|
||||||
this->setWindowIcon(CIcons::swift24());
|
this->setWindowIcon(CIcons::swift24());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
menu->addAction(CIcons::dockTop16(), "Dock all", this, SLOT(dockAllWidgets()));
|
menu->addAction(CIcons::dockTop16(), "Dock all", this, SLOT(dockAllWidgets()));
|
||||||
menu->addAction(CIcons::floatAll16(), "Float all", this, SLOT(floatAllWidgets()));
|
menu->addAction(CIcons::floatAll16(), "Float all", this, SLOT(floatAllWidgets()));
|
||||||
menu->addAction(CIcons::floatOne16(), QString("Dock / float '%1'").arg(this->windowTitle()), this, SLOT(toggleFloating()));
|
menu->addAction(CIcons::floatOne16(), QString("Dock / float '%1'").arg(this->windowTitle()), this, SLOT(toggleFloatingWholeInfoArea()));
|
||||||
QAction *lockTabBarMenuAction = new QAction(menu);
|
QAction *lockTabBarMenuAction = new QAction(menu);
|
||||||
lockTabBarMenuAction->setObjectName(this->objectName().append("LockTabBar"));
|
lockTabBarMenuAction->setObjectName(this->objectName().append("LockTabBar"));
|
||||||
lockTabBarMenuAction->setIconText("Lock tab bar");
|
lockTabBarMenuAction->setIconText("Lock tab bar");
|
||||||
@@ -257,12 +257,12 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoArea::toggleFloating()
|
void CInfoArea::toggleFloatingWholeInfoArea()
|
||||||
{
|
{
|
||||||
this->ps_setInfoAreaFloating(!this->m_infoAreaFloating);
|
this->ps_setWholeInfoAreaFloating(!this->m_infoAreaFloating);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoArea::toggleFloating(int areaIndex)
|
void CInfoArea::toggleFloatingByIndex(int areaIndex)
|
||||||
{
|
{
|
||||||
if (!this->isValidAreaIndex(areaIndex)) { return; }
|
if (!this->isValidAreaIndex(areaIndex)) { return; }
|
||||||
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex);
|
CDockWidgetInfoArea *dw = this->m_dockWidgetInfoAreas.at(areaIndex);
|
||||||
@@ -363,7 +363,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoArea::ps_setInfoAreaFloating(bool floating)
|
void CInfoArea::ps_setWholeInfoAreaFloating(bool floating)
|
||||||
{
|
{
|
||||||
// float whole info area
|
// float whole info area
|
||||||
this->m_infoAreaFloating = floating;
|
this->m_infoAreaFloating = floating;
|
||||||
@@ -384,6 +384,8 @@ namespace BlackGui
|
|||||||
this->setWindowFlags(this->windowFlags() & ~Qt::Window);
|
this->setWindowFlags(this->windowFlags() & ~Qt::Window);
|
||||||
this->setVisible(true); // after redocking this is required
|
this->setVisible(true); // after redocking this is required
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit changedWholeInfoAreaFloating(floating);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInfoArea::tabifyAllWidgets()
|
void CInfoArea::tabifyAllWidgets()
|
||||||
@@ -414,8 +416,8 @@ namespace BlackGui
|
|||||||
after->setFloating(false);
|
after->setFloating(false);
|
||||||
after->setVisible(true);
|
after->setVisible(true);
|
||||||
|
|
||||||
// reset floating flag
|
// reset floating flag, we want new resizing and position for first real floating
|
||||||
after->resetWasAlreadyFLoating();
|
after->resetWasAlreadyFloating();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -714,7 +716,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (this->isFloating())
|
if (this->isFloating())
|
||||||
{
|
{
|
||||||
this->toggleFloating();
|
this->toggleFloatingWholeInfoArea();
|
||||||
event->setAccepted(false); // refuse -> do not close
|
event->setAccepted(false); // refuse -> do not close
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ namespace BlackGui
|
|||||||
//! Status of info area changed
|
//! Status of info area changed
|
||||||
void changedInfoAreaStatus(int currentTabIndex, QList<int> dockedAreas, QList<int> floatingAreas);
|
void changedInfoAreaStatus(int currentTabIndex, QList<int> dockedAreas, QList<int> floatingAreas);
|
||||||
|
|
||||||
|
//! Whole info area floating
|
||||||
|
void changedWholeInfoAreaFloating(bool floating);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Dock all widgets
|
//! Dock all widgets
|
||||||
void dockAllWidgets();
|
void dockAllWidgets();
|
||||||
@@ -75,10 +78,10 @@ namespace BlackGui
|
|||||||
void floatAllWidgets();
|
void floatAllWidgets();
|
||||||
|
|
||||||
//! Toggle dock / floating of the whole info area
|
//! Toggle dock / floating of the whole info area
|
||||||
virtual void toggleFloating();
|
virtual void toggleFloatingWholeInfoArea();
|
||||||
|
|
||||||
//! Toggle floating of index
|
//! Toggle floating of index
|
||||||
void toggleFloating(int areaIndex);
|
void toggleFloatingByIndex(int areaIndex);
|
||||||
|
|
||||||
//! Toggle visibilty
|
//! Toggle visibilty
|
||||||
void toggleVisibility(int areaIndex);
|
void toggleVisibility(int areaIndex);
|
||||||
@@ -218,7 +221,7 @@ namespace BlackGui
|
|||||||
void ps_setDockArea(Qt::DockWidgetArea area);
|
void ps_setDockArea(Qt::DockWidgetArea area);
|
||||||
|
|
||||||
//! Dock / floating of the whole info area
|
//! Dock / floating of the whole info area
|
||||||
void ps_setInfoAreaFloating(bool floating);
|
void ps_setWholeInfoAreaFloating(bool floating);
|
||||||
|
|
||||||
//! Emit current status, \sa changedInfoAreaStatus
|
//! Emit current status, \sa changedInfoAreaStatus
|
||||||
void ps_emitInfoAreaStatus();
|
void ps_emitInfoAreaStatus();
|
||||||
|
|||||||
Reference in New Issue
Block a user