mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +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:
|
||||
//! 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
|
||||
void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast<int>(infoArea)); }
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace BlackGui
|
||||
|
||||
public slots:
|
||||
//! 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
|
||||
void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast<int>(infoArea)); }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_DOCKWIDGET_H
|
||||
|
||||
#include "managedstatusbar.h"
|
||||
#include "enableforframelesswindow.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTabWidget>
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -64,6 +64,9 @@ namespace BlackGui
|
||||
//! Status of info area changed
|
||||
void changedInfoAreaStatus(int currentTabIndex, QList<int> dockedAreas, QList<int> 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();
|
||||
|
||||
Reference in New Issue
Block a user