mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #325, improved info area
* signal when tab bar is changed (goal: reload in components when info area changes) * tab bar locking (avoid unintended floating)
This commit is contained in:
@@ -57,6 +57,14 @@ namespace BlackGui
|
||||
menu->addAction(CIcons::dockTop16(), "Dock all", this, SLOT(dockAllWidgets()));
|
||||
menu->addAction(CIcons::floatAll16(), "Float all", this, SLOT(floatAllWidgets()));
|
||||
menu->addAction(CIcons::floatOne16(), "Dock / float info area", this, SLOT(toggleFloating()));
|
||||
QAction *lockTabBarMenuAction = new QAction(menu);
|
||||
lockTabBarMenuAction->setObjectName(this->objectName().append("LockTabBar"));
|
||||
lockTabBarMenuAction->setIconText("Lock tab bar");
|
||||
lockTabBarMenuAction->setIcon(CIcons::lockClosed16());
|
||||
lockTabBarMenuAction->setCheckable(true);
|
||||
lockTabBarMenuAction->setChecked(this->m_lockTabBar);
|
||||
menu->addAction(lockTabBarMenuAction);
|
||||
connect(lockTabBarMenuAction, &QAction::toggled, this, &CInfoArea::ps_toggleTabBarLocked);
|
||||
|
||||
bool c = false;
|
||||
if (!this->m_dockableWidgets.isEmpty())
|
||||
@@ -143,9 +151,9 @@ namespace BlackGui
|
||||
{
|
||||
if (!infoArea) return false;
|
||||
if (infoArea->isFloating()) return false;
|
||||
int i = getSelectedInfoAreaIndex();
|
||||
if (i < 0 || i >= this->m_dockableWidgets.size()) return false;
|
||||
return this->m_dockableWidgets.at(i) == infoArea;
|
||||
int tabBarIndex = getSelectedTabBarIndex();
|
||||
if (tabBarIndex < 0 || tabBarIndex >= this->m_dockableWidgets.size()) return false;
|
||||
return this->getDockableWidgetByTabBarIndex(tabBarIndex) == infoArea;
|
||||
}
|
||||
|
||||
void CInfoArea::dockAllWidgets()
|
||||
@@ -294,7 +302,10 @@ namespace BlackGui
|
||||
// East / West does not work (shown, but area itself empty)
|
||||
// South does not have any effect
|
||||
this->m_tabBar->setShape(QTabBar::TriangularSouth);
|
||||
|
||||
// signals
|
||||
connect(this->m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::ps_tabBarDoubleClicked);
|
||||
connect(this->m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::tabBarCurrentChanged);
|
||||
}
|
||||
|
||||
if (this->countDockedWidgets() > 0)
|
||||
@@ -393,7 +404,8 @@ namespace BlackGui
|
||||
|
||||
void CInfoArea::ps_tabBarDoubleClicked(int tabBarIndex)
|
||||
{
|
||||
CDockWidgetInfoArea *dw = this->getDockableWidgetByTabIndex(tabBarIndex);
|
||||
if (this->m_lockTabBar) return;
|
||||
CDockWidgetInfoArea *dw = this->getDockableWidgetByTabBarIndex(tabBarIndex);
|
||||
if (!dw) return;
|
||||
dw->toggleFloating();
|
||||
}
|
||||
@@ -449,6 +461,11 @@ namespace BlackGui
|
||||
this->adjustSizeForAllDockWidgets();
|
||||
}
|
||||
|
||||
void CInfoArea::ps_toggleTabBarLocked(bool locked)
|
||||
{
|
||||
this->m_lockTabBar = locked;
|
||||
}
|
||||
|
||||
void CInfoArea::ps_setTabBarPosition(QTabWidget::TabPosition position)
|
||||
{
|
||||
Q_ASSERT(position == QTabWidget::North || position == QTabWidget::South);
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Destructor
|
||||
virtual ~CInfoArea() {}
|
||||
|
||||
@@ -46,6 +45,10 @@ namespace BlackGui
|
||||
//! Is given widget selected. Means it is not floating, and the one selected
|
||||
bool isSelectedInfoArea(const CDockWidgetInfoArea *infoArea) const;
|
||||
|
||||
signals:
|
||||
//! Tab bar changed
|
||||
void tabBarCurrentChanged(int index);
|
||||
|
||||
public slots:
|
||||
//! Dock all widgets
|
||||
void dockAllWidgets();
|
||||
@@ -88,6 +91,7 @@ namespace BlackGui
|
||||
bool m_showTabTexts = true;
|
||||
bool m_infoAreaFloating = false; //!< whole info area floating
|
||||
bool m_showTabBar = true; //!< auto ajdust the floating widgets
|
||||
bool m_lockTabBar = false; //!< locked means no double clicks possible
|
||||
|
||||
//! Tabify the widgets
|
||||
void tabifyAllWidgets();
|
||||
@@ -144,6 +148,9 @@ namespace BlackGui
|
||||
//! Show tab bar
|
||||
void ps_showTabBar(bool show);
|
||||
|
||||
//! Toogle lock tabbar
|
||||
void ps_toggleTabBarLocked(bool locked);
|
||||
|
||||
//! Tab position for docked widgets tab
|
||||
//! \remarks North or South working, East / West not
|
||||
void ps_setTabBarPosition(QTabWidget::TabPosition position);
|
||||
|
||||
Reference in New Issue
Block a user