diff --git a/src/blackgui/components/cockpitinfoareacomponent.h b/src/blackgui/components/cockpitinfoareacomponent.h index a48dfc6a6..a9b77d8d4 100644 --- a/src/blackgui/components/cockpitinfoareacomponent.h +++ b/src/blackgui/components/cockpitinfoareacomponent.h @@ -45,7 +45,7 @@ namespace BlackGui public slots: //! Toggle floating of given area - void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloating(static_cast(infoArea)); } + void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast(infoArea)); } //! Select area void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast(infoArea)); } diff --git a/src/blackgui/components/maininfoareacomponent.h b/src/blackgui/components/maininfoareacomponent.h index 0f80854f8..9954098e0 100644 --- a/src/blackgui/components/maininfoareacomponent.h +++ b/src/blackgui/components/maininfoareacomponent.h @@ -82,7 +82,7 @@ namespace BlackGui public slots: //! Toggle floating of given area - void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloating(static_cast(infoArea)); } + void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast(infoArea)); } //! Select area void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast(infoArea)); } diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index 41d7f2cbb..3fc686e4d 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -18,7 +18,9 @@ namespace BlackGui { - CDockWidget::CDockWidget(QWidget *parent) : QDockWidget(parent) + CDockWidget::CDockWidget(QWidget *parent) : + QDockWidget(parent), + CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this) { this->ps_onStyleSheetsChanged(); @@ -117,8 +119,8 @@ namespace BlackGui void CDockWidget::paintEvent(QPaintEvent *event) { - Q_UNUSED(event); - CStyleSheetUtility::useStyleSheetInDerivedWidget(this); + CStyleSheetUtility::useStyleSheetInDerivedWidget(this, QStyle::PE_FrameDockWidget); + QDockWidget::paintEvent(event); } void CDockWidget::addToContextMenu(QMenu *contextMenu) const @@ -168,6 +170,13 @@ namespace BlackGui this->setContentsMargins(this->m_marginsWhenFloating); if (!this->m_wasAlreadyFloating) { this->initialFloating(); } this->m_statusBar.show(); + + if (this->m_wasAlreadyFloating || this->m_resetedFloating) + { + //! \todo dock widget frameless + // this->setFrameless(topLevel); + } + this->m_wasAlreadyFloating = true; } else @@ -182,7 +191,12 @@ namespace BlackGui { this->setMinimumSize(this->m_initialDockedMinimumSize); } + + // frameless + this->setFrameless(topLevel); } + + // relay emit this->widgetTopLevelChanged(this, topLevel); } diff --git a/src/blackgui/dockwidget.h b/src/blackgui/dockwidget.h index ad8281d3c..19aa96ea7 100644 --- a/src/blackgui/dockwidget.h +++ b/src/blackgui/dockwidget.h @@ -13,6 +13,7 @@ #define BLACKGUI_DOCKWIDGET_H #include "managedstatusbar.h" +#include "enableforframelesswindow.h" #include #include @@ -31,7 +32,9 @@ namespace BlackGui //! \sa CInfoArea //! \sa CDockWidgetInfoArea //! \sa CDockWidgetInfoBar - class CDockWidget : public QDockWidget + class CDockWidget : + public QDockWidget, + public CEnableForFramelessWindow { Q_OBJECT @@ -77,7 +80,7 @@ namespace BlackGui void showTitleWhenDocked(bool show); //! 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? bool wasAlreadyFloating() const { return this->m_wasAlreadyFloating; } @@ -118,6 +121,12 @@ namespace BlackGui //! \copydoc QWidget::paintEvent 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 virtual void addToContextMenu(QMenu *contextMenu) const; @@ -153,6 +162,7 @@ namespace BlackGui bool m_allowStatusBar = true; bool m_windowTitleWhenDocked = true; bool m_wasAlreadyFloating = false; + bool m_resetedFloating = false; bool m_selected = false; //!< selected when tabbed bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible() diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index 4fc1aa792..3f6f9c2a6 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -28,7 +28,7 @@ namespace BlackGui CInfoArea::CInfoArea(QWidget *parent) : QMainWindow(parent), CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this) { - this->ps_setInfoAreaFloating(this->m_infoAreaFloating); + this->ps_setWholeInfoAreaFloating(this->m_infoAreaFloating); this->setWindowIcon(CIcons::swift24()); } @@ -75,7 +75,7 @@ namespace BlackGui { menu->addAction(CIcons::dockTop16(), "Dock all", this, SLOT(dockAllWidgets())); 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); lockTabBarMenuAction->setObjectName(this->objectName().append("LockTabBar")); 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; } 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 this->m_infoAreaFloating = floating; @@ -384,6 +384,8 @@ namespace BlackGui this->setWindowFlags(this->windowFlags() & ~Qt::Window); this->setVisible(true); // after redocking this is required } + + emit changedWholeInfoAreaFloating(floating); } void CInfoArea::tabifyAllWidgets() @@ -414,8 +416,8 @@ namespace BlackGui after->setFloating(false); after->setVisible(true); - // reset floating flag - after->resetWasAlreadyFLoating(); + // reset floating flag, we want new resizing and position for first real floating + after->resetWasAlreadyFloating(); } else { @@ -714,7 +716,7 @@ namespace BlackGui { if (this->isFloating()) { - this->toggleFloating(); + this->toggleFloatingWholeInfoArea(); event->setAccepted(false); // refuse -> do not close } else diff --git a/src/blackgui/infoarea.h b/src/blackgui/infoarea.h index fb2f62669..379e81baf 100644 --- a/src/blackgui/infoarea.h +++ b/src/blackgui/infoarea.h @@ -64,6 +64,9 @@ namespace BlackGui //! Status of info area changed void changedInfoAreaStatus(int currentTabIndex, QList dockedAreas, QList floatingAreas); + //! Whole info area floating + void changedWholeInfoAreaFloating(bool floating); + public slots: //! Dock all widgets void dockAllWidgets(); @@ -75,10 +78,10 @@ namespace BlackGui void floatAllWidgets(); //! Toggle dock / floating of the whole info area - virtual void toggleFloating(); + virtual void toggleFloatingWholeInfoArea(); //! Toggle floating of index - void toggleFloating(int areaIndex); + void toggleFloatingByIndex(int areaIndex); //! Toggle visibilty void toggleVisibility(int areaIndex); @@ -218,7 +221,7 @@ namespace BlackGui void ps_setDockArea(Qt::DockWidgetArea area); //! Dock / floating of the whole info area - void ps_setInfoAreaFloating(bool floating); + void ps_setWholeInfoAreaFloating(bool floating); //! Emit current status, \sa changedInfoAreaStatus void ps_emitInfoAreaStatus();