Merge branch 'master' of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System
This commit is contained in:
BIN
doc/cfg_flag_TabsAtBottom.png
Normal file
BIN
doc/cfg_flag_TabsAtBottom.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -1,5 +1,6 @@
|
||||
# User Guide
|
||||
|
||||
- [User Guide](#user-guide)
|
||||
- [Configuration Flags](#configuration-flags)
|
||||
- [Setting Configuration Flags](#setting-configuration-flags)
|
||||
- [`ActiveTabHasCloseButton`](#activetabhasclosebutton)
|
||||
@@ -30,6 +31,7 @@
|
||||
- [`DisableTabTextEliding`](#disabletabtexteliding)
|
||||
- [`ShowTabTextOnlyForActiveTab`](#showtabtextonlyforactivetab)
|
||||
- [`DoubleClickUndocksWidget`](#doubleclickundockswidget)
|
||||
- [`TabsAtBottom`](#tabsatbottom)
|
||||
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
|
||||
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
|
||||
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
|
||||
@@ -510,6 +512,12 @@ for active tabs. Inactive tabs only show their icon:
|
||||
If the flag is set (default), a double click on a tab undocks the dock widget.
|
||||
If you would like to disable undocking, just clear this flag.
|
||||
|
||||
### `TabsAtBottom`
|
||||
|
||||
If the flag is set, tabs will be shown at the bottom instead of in the title bar.
|
||||
|
||||

|
||||
|
||||
## Auto Hide Dock Widgets
|
||||
|
||||
The Advanced Docking System supports "Auto-Hide" functionality for **all**
|
||||
|
||||
@@ -27,6 +27,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
||||
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
CDockManager::setConfigFlag(CDockManager::TabsAtBottom, true);
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover, true);
|
||||
CDockManager::setConfigParam(CDockManager::AutoHideOpenOnDragHoverDelay_ms, 500);
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
/**
|
||||
* Virtual Destructor
|
||||
*/
|
||||
virtual ~CAutoHideTab();
|
||||
~CAutoHideTab() override;
|
||||
|
||||
/**
|
||||
* Update stylesheet style if a property changes
|
||||
|
||||
@@ -94,7 +94,7 @@ target_link_libraries(${library_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
if(QT_VERSION_MAJOR STREQUAL "6")
|
||||
if(UNIX AND NOT APPLE AND QT_VERSION_MAJOR STREQUAL "6")
|
||||
target_link_libraries(${library_name} PRIVATE Qt6::GuiPrivate) #needed for <qpa/qplatformnativeinterface.h>
|
||||
endif()
|
||||
|
||||
|
||||
@@ -260,10 +260,10 @@ void DockAreaTitleBarPrivate::createAutoHideTitleLabel()
|
||||
{
|
||||
AutoHideTitleLabel = new CElidingLabel("");
|
||||
AutoHideTitleLabel->setObjectName("autoHideTitleLabel");
|
||||
// At position 0 is the tab bar - insert behind tab bar
|
||||
Layout->insertWidget(1, AutoHideTitleLabel);
|
||||
AutoHideTitleLabel->setVisible(false); // Default hidden
|
||||
Layout->insertWidget(2 ,new CSpacerWidget(_this));
|
||||
// When the tabs are at the top, they will be at position 0, insert the label behind them, and hide it.
|
||||
Layout->addWidget(AutoHideTitleLabel);
|
||||
AutoHideTitleLabel->setVisible(CDockManager::testConfigFlag(CDockManager::TabsAtBottom));
|
||||
Layout->addWidget(new CSpacerWidget(_this));
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +272,9 @@ void DockAreaTitleBarPrivate::createTabBar()
|
||||
{
|
||||
TabBar = componentsFactory()->createDockAreaTabBar(DockArea);
|
||||
TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
if (!CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
Layout->addWidget(TabBar);
|
||||
|
||||
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
|
||||
_this->connect(TabBar, SIGNAL(tabOpened(int)), SLOT(markTabsMenuOutdated()));
|
||||
_this->connect(TabBar, SIGNAL(tabInserted(int)), SLOT(markTabsMenuOutdated()));
|
||||
@@ -351,8 +353,8 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
|
||||
d->createTabBar();
|
||||
d->createButtons();
|
||||
d->createAutoHideTitleLabel();
|
||||
d->createButtons();
|
||||
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
@@ -900,8 +902,11 @@ QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::showAutoHideControls(bool Show)
|
||||
{
|
||||
d->TabBar->setVisible(!Show); // Auto hide toolbar never has tabs
|
||||
if (Show)
|
||||
d->TabBar->setVisible(false); // Auto hide toolbar never has tabs
|
||||
|
||||
d->MinimizeButton->setVisible(Show);
|
||||
if (!CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
d->AutoHideTitleLabel->setVisible(Show);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,14 +179,17 @@ public:
|
||||
parent->setUpdatesEnabled(false);
|
||||
}
|
||||
|
||||
if (m_CurrentWidget)
|
||||
{
|
||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||
if (LayoutItem)
|
||||
{
|
||||
LayoutItem->widget()->setParent(nullptr);
|
||||
}
|
||||
delete LayoutItem;
|
||||
}
|
||||
|
||||
m_ParentLayout->addWidget(next);
|
||||
m_ParentLayout->insertWidget(1, next);
|
||||
if (prev)
|
||||
{
|
||||
prev->hide();
|
||||
@@ -362,6 +365,14 @@ void DockAreaWidgetPrivate::createTitleBar()
|
||||
{
|
||||
TitleBar = componentsFactory()->createDockAreaTitleBar(_this);
|
||||
Layout->addWidget(TitleBar);
|
||||
if (CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
{
|
||||
// Title bar will be index 0, container widgets will be index 1,
|
||||
// so tabs will always be at the end of the layout.
|
||||
Layout->addWidget(tabBar());
|
||||
tabBar()->setVisible(CDockManager::testConfigFlag(CDockManager::AlwaysShowTabs));
|
||||
}
|
||||
|
||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
|
||||
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
|
||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget);
|
||||
@@ -726,6 +737,7 @@ void CDockAreaWidget::setCurrentIndex(int index)
|
||||
TabBar->setCurrentIndex(index);
|
||||
d->ContentsLayout->setCurrentIndex(index);
|
||||
d->ContentsLayout->currentWidget()->show();
|
||||
d->TitleBar->autoHideTitleLabel()->setText(d->ContentsLayout->currentWidget()->windowTitle());
|
||||
Q_EMIT currentChanged(index);
|
||||
}
|
||||
|
||||
@@ -879,8 +891,23 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
{
|
||||
// Always show title bar if it contains title bar actions
|
||||
if (CDockWidget* TopLevelWidget = Container->topLevelDockWidget())
|
||||
{
|
||||
Hidden |= TopLevelWidget->titleBarActions().empty();
|
||||
}
|
||||
else if (CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
{
|
||||
Hidden = true;
|
||||
|
||||
for (CDockWidget* DockWidget : Container->openedDockWidgets())
|
||||
{
|
||||
if (!DockWidget->titleBarActions().empty())
|
||||
{
|
||||
Hidden = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Hidden && d->Flags.testFlag(HideSingleWidgetTitleBar))
|
||||
{
|
||||
// Always show title bar if it contains title bar actions
|
||||
@@ -889,6 +916,8 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
}
|
||||
}
|
||||
d->TitleBar->setVisible(!Hidden);
|
||||
if (CDockManager::testConfigFlag(CDockManager::TabsAtBottom))
|
||||
d->TitleBar->tabBar()->setVisible(openDockWidgetsCount() > 1);
|
||||
}
|
||||
|
||||
if (isAutoHideFeatureEnabled())
|
||||
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
/**
|
||||
* Virtual Destructor
|
||||
*/
|
||||
virtual ~CDockAreaWidget();
|
||||
~CDockAreaWidget() override;
|
||||
|
||||
/**
|
||||
* Returns the dock manager object this dock area belongs to
|
||||
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
/**
|
||||
* Virtual Destructor
|
||||
*/
|
||||
virtual ~CDockContainerWidget();
|
||||
~CDockContainerWidget() override;
|
||||
|
||||
/**
|
||||
* Adds dockwidget into the given area.
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <QVariant>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDialog>
|
||||
#include <QAction>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QSettings>
|
||||
@@ -530,15 +531,30 @@ CDockManager::CDockManager(QWidget *parent) :
|
||||
window()->installEventFilter(this);
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
connect(qApp, &QApplication::focusWindowChanged, [this](QWindow* focusWindow)
|
||||
connect(qApp, &QApplication::focusWindowChanged, this, [this](QWindow* focusWindow)
|
||||
{
|
||||
if (!focusWindow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// bring the main application window that hosts the dock manager and all floating
|
||||
// widgets in front of any other application
|
||||
auto widget = QWidget::find(focusWindow->winId());
|
||||
if (!widget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user clicks the main window or drags a floating widget or works with a
|
||||
// dialog, then raise the main window, all floating widgets and the focus window
|
||||
// itself to bring it into foregreound of any other application
|
||||
bool raise = qobject_cast<QMainWindow*>(widget)
|
||||
|| qobject_cast<QDialog*>(widget)
|
||||
|| qobject_cast<ads::CFloatingDockContainer*>(widget);
|
||||
if (!raise)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->raise();
|
||||
for (auto FloatingWidget : d->FloatingWidgets)
|
||||
{
|
||||
|
||||
@@ -216,6 +216,7 @@ public:
|
||||
DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs
|
||||
ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs
|
||||
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget
|
||||
TabsAtBottom = 0x20000000, //!< If the flag is set, tabs will be shown at the bottom instead of in the title bar.
|
||||
|
||||
|
||||
DefaultDockAreaButtons = DockAreaHasCloseButton
|
||||
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
/**
|
||||
* Virtual Destructor
|
||||
*/
|
||||
virtual ~CDockWidget();
|
||||
~CDockWidget() override;
|
||||
|
||||
/**
|
||||
* We return a fixed minimum size hint or the size hint of the content
|
||||
|
||||
@@ -539,7 +539,7 @@ QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu)
|
||||
Menu = new QMenu(this);
|
||||
}
|
||||
|
||||
qDebug() << "CDockWidgetTab::buildContextMenu";
|
||||
ADS_PRINT("CDockWidgetTab::buildContextMenu");
|
||||
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
|
||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
const bool isFloating = d->DockWidget->isFloating();
|
||||
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
/**
|
||||
* Virtual Destructor
|
||||
*/
|
||||
virtual ~CFloatingDockContainer();
|
||||
~CFloatingDockContainer() override;
|
||||
|
||||
/**
|
||||
* Access function for the internal dock container
|
||||
|
||||
@@ -82,6 +82,10 @@ ads--CDockWidgetTab[activeTab="true"] QLabel {
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
#tabCloseButton {
|
||||
margin-top: 2px;
|
||||
@@ -278,7 +282,7 @@ ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaT
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
ads--CAutoHideDockContainer #autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(light);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@ ads--CTitleBarButton {
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
|
||||
#tabsMenuButton {
|
||||
qproperty-icon: url(:/ads/images/tabs-menu-button.svg);
|
||||
qproperty-iconSize: 16px;
|
||||
@@ -88,6 +94,12 @@ ads--CDockWidgetTab[activeTab="true"] QLabel {
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
|
||||
#tabCloseButton {
|
||||
margin-top: 2px;
|
||||
background: none;
|
||||
@@ -314,7 +326,7 @@ ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaT
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
ads--CAutoHideDockContainer #autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(light);
|
||||
}
|
||||
|
||||
@@ -95,6 +95,10 @@ ads--CDockWidgetTab[activeTab="true"] QLabel {
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
#tabCloseButton {
|
||||
margin-top: 2px;
|
||||
@@ -316,7 +320,7 @@ ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaT
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
ads--CAutoHideDockContainer #autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(light);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ ads--CTitleBarButton {
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
|
||||
#tabsMenuButton {
|
||||
qproperty-icon: url(:/ads/images/tabs-menu-button.svg);
|
||||
qproperty-iconSize: 16px;
|
||||
@@ -391,7 +397,7 @@ ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaT
|
||||
}
|
||||
|
||||
|
||||
#autoHideTitleLabel {
|
||||
ads--CAutoHideDockContainer #autoHideTitleLabel {
|
||||
padding-left: 4px;
|
||||
color: palette(light);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user