forked from qt-creator/qt-creator
ADS: Integrate newest base repository commits
* Update to newest version of ADS * Fix memory leak in DockContainerWidget Base repository was merged until commit 59b4dfb89c0c9c0e6035fe580088432312ed2d09 Change-Id: I357b21888fe6f0ec2160c8688d84cb7ecdcad079 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
d0fccdc025
commit
e16a302a43
@@ -66,7 +66,8 @@ enum eTitleBarButton {
|
|||||||
TitleBarButtonTabsMenu,
|
TitleBarButtonTabsMenu,
|
||||||
TitleBarButtonUndock,
|
TitleBarButtonUndock,
|
||||||
TitleBarButtonClose,
|
TitleBarButtonClose,
|
||||||
TitleBarButtonAutoHide
|
TitleBarButtonAutoHide,
|
||||||
|
TitleBarButtonMinimize
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,6 +89,7 @@ enum eIcon {
|
|||||||
DockAreaMenuIcon, //!< DockAreaMenuIcon
|
DockAreaMenuIcon, //!< DockAreaMenuIcon
|
||||||
DockAreaUndockIcon, //!< DockAreaUndockIcon
|
DockAreaUndockIcon, //!< DockAreaUndockIcon
|
||||||
DockAreaCloseIcon, //!< DockAreaCloseIcon
|
DockAreaCloseIcon, //!< DockAreaCloseIcon
|
||||||
|
DockAreaMinimizeIcon,
|
||||||
FloatingWidgetCloseIcon, //!< FloatingWidgetCloseIcon
|
FloatingWidgetCloseIcon, //!< FloatingWidgetCloseIcon
|
||||||
FloatingWidgetNormalIcon, //!< FloatingWidgetNormalIcon
|
FloatingWidgetNormalIcon, //!< FloatingWidgetNormalIcon
|
||||||
FloatingWidgetMaximizeIcon, //!< FloatingWidgetMaximizeIcon
|
FloatingWidgetMaximizeIcon, //!< FloatingWidgetMaximizeIcon
|
||||||
|
@@ -48,10 +48,11 @@ public:
|
|||||||
QPointer<TitleBarButton> m_autoHideButton;
|
QPointer<TitleBarButton> m_autoHideButton;
|
||||||
QPointer<TitleBarButton> m_undockButton;
|
QPointer<TitleBarButton> m_undockButton;
|
||||||
QPointer<TitleBarButton> m_closeButton;
|
QPointer<TitleBarButton> m_closeButton;
|
||||||
|
QPointer<TitleBarButton> m_minimizeButton;
|
||||||
QBoxLayout *m_layout = nullptr;
|
QBoxLayout *m_layout = nullptr;
|
||||||
DockAreaWidget *m_dockArea = nullptr;
|
DockAreaWidget *m_dockArea = nullptr;
|
||||||
DockAreaTabBar *m_tabBar = nullptr;
|
DockAreaTabBar *m_tabBar = nullptr;
|
||||||
ElidingLabel *m_autoHideTitleLabel;
|
ElidingLabel *m_autoHideTitleLabel = nullptr;
|
||||||
bool m_menuOutdated = true;
|
bool m_menuOutdated = true;
|
||||||
QMenu *m_tabsMenu;
|
QMenu *m_tabsMenu;
|
||||||
QList<TitleBarButtonType *> m_dockWidgetActionsButtons;
|
QList<TitleBarButtonType *> m_dockWidgetActionsButtons;
|
||||||
@@ -202,6 +203,23 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
q,
|
q,
|
||||||
&DockAreaTitleBar::onAutoHideButtonClicked);
|
&DockAreaTitleBar::onAutoHideButtonClicked);
|
||||||
|
|
||||||
|
// Minimize button
|
||||||
|
m_minimizeButton = new TitleBarButton(
|
||||||
|
testAutoHideConfigFlag(DockManager::AutoHideHasMinimizeButton));
|
||||||
|
m_minimizeButton->setObjectName("dockAreaMinimizeButton");
|
||||||
|
//m_minimizeButton->setAutoRaise(true);
|
||||||
|
m_minimizeButton->setVisible(false);
|
||||||
|
internal::setButtonIcon(m_minimizeButton,
|
||||||
|
QStyle::SP_TitleBarMinButton,
|
||||||
|
ADS::DockAreaMinimizeIcon);
|
||||||
|
internal::setToolTip(m_minimizeButton, QObject::tr("Minimize"));
|
||||||
|
m_minimizeButton->setSizePolicy(sizePolicy);
|
||||||
|
m_layout->addWidget(m_minimizeButton, 0);
|
||||||
|
QObject::connect(m_minimizeButton,
|
||||||
|
&QToolButton::clicked,
|
||||||
|
q,
|
||||||
|
&DockAreaTitleBar::minimizeAutoHideContainer);
|
||||||
|
|
||||||
// Close button
|
// Close button
|
||||||
m_closeButton = new TitleBarButton(testConfigFlag(DockManager::DockAreaHasCloseButton));
|
m_closeButton = new TitleBarButton(testConfigFlag(DockManager::DockAreaHasCloseButton));
|
||||||
m_closeButton->setObjectName("dockAreaCloseButton");
|
m_closeButton->setObjectName("dockAreaCloseButton");
|
||||||
@@ -228,7 +246,10 @@ void DockAreaTitleBarPrivate::createAutoHideTitleLabel()
|
|||||||
{
|
{
|
||||||
m_autoHideTitleLabel = new ElidingLabel("");
|
m_autoHideTitleLabel = new ElidingLabel("");
|
||||||
m_autoHideTitleLabel->setObjectName("autoHideTitleLabel");
|
m_autoHideTitleLabel->setObjectName("autoHideTitleLabel");
|
||||||
m_layout->addWidget(m_autoHideTitleLabel);
|
// At position 0 is the tab bar - insert behind tab bar
|
||||||
|
m_layout->insertWidget(1, m_autoHideTitleLabel);
|
||||||
|
m_autoHideTitleLabel->setVisible(false); // Default hidden
|
||||||
|
m_layout->insertWidget(2, new SpacerWidget(q));
|
||||||
}
|
}
|
||||||
void DockAreaTitleBarPrivate::createTabBar()
|
void DockAreaTitleBarPrivate::createTabBar()
|
||||||
{
|
{
|
||||||
@@ -370,10 +391,8 @@ DockAreaTitleBar::DockAreaTitleBar(DockAreaWidget *parent)
|
|||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
|
|
||||||
d->createTabBar();
|
d->createTabBar();
|
||||||
d->createAutoHideTitleLabel();
|
|
||||||
d->m_autoHideTitleLabel->setVisible(false); // Default hidden
|
|
||||||
d->m_layout->addWidget(new SpacerWidget(this));
|
|
||||||
d->createButtons();
|
d->createButtons();
|
||||||
|
d->createAutoHideTitleLabel();
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,6 +471,18 @@ void DockAreaTitleBar::onCloseButtonClicked()
|
|||||||
d->m_dockArea->closeArea();
|
d->m_dockArea->closeArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockAreaTitleBar::onAutoHideCloseActionTriggered()
|
||||||
|
{
|
||||||
|
d->m_dockArea->closeArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockAreaTitleBar::minimizeAutoHideContainer()
|
||||||
|
{
|
||||||
|
auto autoHideContainer = d->m_dockArea->autoHideDockContainer();
|
||||||
|
if (autoHideContainer)
|
||||||
|
autoHideContainer->collapseView(true);
|
||||||
|
}
|
||||||
|
|
||||||
void DockAreaTitleBar::onUndockButtonClicked()
|
void DockAreaTitleBar::onUndockButtonClicked()
|
||||||
{
|
{
|
||||||
if (d->m_dockArea->features().testFlag(DockWidget::DockWidgetFloatable))
|
if (d->m_dockArea->features().testFlag(DockWidget::DockWidgetFloatable))
|
||||||
@@ -543,6 +574,8 @@ TitleBarButton *DockAreaTitleBar::button(eTitleBarButton which) const
|
|||||||
return d->m_closeButton;
|
return d->m_closeButton;
|
||||||
case TitleBarButtonAutoHide:
|
case TitleBarButtonAutoHide:
|
||||||
return d->m_autoHideButton;
|
return d->m_autoHideButton;
|
||||||
|
case TitleBarButtonMinimize:
|
||||||
|
return d->m_minimizeButton;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -686,12 +719,28 @@ void DockAreaTitleBar::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
}
|
}
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
}
|
||||||
QAction *closeAction = menu.addAction(isAutoHide ? Tr::tr("Close") : Tr::tr("Close Group"));
|
|
||||||
|
if (isAutoHide) {
|
||||||
|
QAction *minimizeAction = menu.addAction(Tr::tr("Minimize"));
|
||||||
|
minimizeAction->connect(minimizeAction,
|
||||||
|
&QAction::triggered,
|
||||||
|
this,
|
||||||
|
&DockAreaTitleBar::minimizeAutoHideContainer);
|
||||||
|
|
||||||
|
QAction *closeAction = menu.addAction(Tr::tr("Close"));
|
||||||
|
closeAction->connect(closeAction,
|
||||||
|
&QAction::triggered,
|
||||||
|
this,
|
||||||
|
&DockAreaTitleBar::onAutoHideCloseActionTriggered);
|
||||||
|
closeAction->setEnabled(d->m_dockArea->features().testFlag(DockWidget::DockWidgetClosable));
|
||||||
|
} else {
|
||||||
|
QAction *closeAction = menu.addAction(Tr::tr("Close Group"));
|
||||||
closeAction->connect(closeAction,
|
closeAction->connect(closeAction,
|
||||||
&QAction::triggered,
|
&QAction::triggered,
|
||||||
this,
|
this,
|
||||||
&DockAreaTitleBar::onCloseButtonClicked);
|
&DockAreaTitleBar::onCloseButtonClicked);
|
||||||
closeAction->setEnabled(d->m_dockArea->features().testFlag(DockWidget::DockWidgetClosable));
|
closeAction->setEnabled(d->m_dockArea->features().testFlag(DockWidget::DockWidgetClosable));
|
||||||
|
}
|
||||||
|
|
||||||
if (!isAutoHide && !isTopLevelArea) {
|
if (!isAutoHide && !isTopLevelArea) {
|
||||||
QAction *closeOthersAction = menu.addAction(Tr::tr("Close Other Groups"));
|
QAction *closeOthersAction = menu.addAction(Tr::tr("Close Other Groups"));
|
||||||
@@ -728,8 +777,11 @@ QString DockAreaTitleBar::titleBarButtonToolTip(eTitleBarButton button) const
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TitleBarButtonClose:
|
case TitleBarButtonClose:
|
||||||
if (d->m_dockArea->isAutoHide())
|
if (d->m_dockArea->isAutoHide()) {
|
||||||
return Tr::tr("Close");
|
bool minimize = DockManager::testAutoHideConfigFlag(
|
||||||
|
DockManager::AutoHideCloseButtonCollapsesDock);
|
||||||
|
return minimize ? Tr::tr("Minimize") : Tr::tr("Close");
|
||||||
|
}
|
||||||
|
|
||||||
if (DockManager::testConfigFlag(DockManager::DockAreaCloseButtonClosesTab))
|
if (DockManager::testConfigFlag(DockManager::DockAreaCloseButtonClosesTab))
|
||||||
return Tr::tr("Close Active Tab");
|
return Tr::tr("Close Active Tab");
|
||||||
@@ -758,4 +810,11 @@ void DockAreaTitleBar::setAreaFloating()
|
|||||||
d->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
|
d->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockAreaTitleBar::showAutoHideControls(bool show)
|
||||||
|
{
|
||||||
|
d->m_tabBar->setVisible(!show); // Auto hide toolbar never has tabs
|
||||||
|
d->m_minimizeButton->setVisible(show);
|
||||||
|
d->m_autoHideTitleLabel->setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ADS
|
} // namespace ADS
|
||||||
|
@@ -84,6 +84,8 @@ private:
|
|||||||
|
|
||||||
void onTabsMenuAboutToShow();
|
void onTabsMenuAboutToShow();
|
||||||
void onCloseButtonClicked();
|
void onCloseButtonClicked();
|
||||||
|
void onAutoHideCloseActionTriggered();
|
||||||
|
void minimizeAutoHideContainer();
|
||||||
void onUndockButtonClicked();
|
void onUndockButtonClicked();
|
||||||
void onTabsMenuActionTriggered(QAction *action);
|
void onTabsMenuActionTriggered(QAction *action);
|
||||||
void onCurrentTabChanged(int index);
|
void onCurrentTabChanged(int index);
|
||||||
@@ -191,6 +193,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setAreaFloating();
|
void setAreaFloating();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function, to create all the required auto hide controls
|
||||||
|
*/
|
||||||
|
void showAutoHideControls(bool show);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||||
|
@@ -295,13 +295,20 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool isTopLevel)
|
|||||||
if (!container)
|
if (!container)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isTopLevel) {
|
bool isAutoHide = q->isAutoHide();
|
||||||
|
if (isAutoHide) {
|
||||||
|
bool showCloseButton = DockManager::autoHideConfigFlags().testFlag(
|
||||||
|
DockManager::AutoHideHasCloseButton);
|
||||||
|
m_titleBar->button(TitleBarButtonClose)->setVisible(showCloseButton);
|
||||||
|
m_titleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||||
|
m_titleBar->button(TitleBarButtonUndock)->setVisible(false);
|
||||||
|
m_titleBar->button(TitleBarButtonTabsMenu)->setVisible(false);
|
||||||
|
} else if (isTopLevel) {
|
||||||
m_titleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
|
m_titleBar->button(TitleBarButtonClose)->setVisible(!container->isFloating());
|
||||||
m_titleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating());
|
m_titleBar->button(TitleBarButtonAutoHide)->setVisible(!container->isFloating());
|
||||||
// Undock and tabs should never show when auto hidden
|
// Undock and tabs should never show when auto hidden
|
||||||
m_titleBar->button(TitleBarButtonUndock)
|
m_titleBar->button(TitleBarButtonUndock)->setVisible(!container->isFloating());
|
||||||
->setVisible(!container->isFloating() && !q->isAutoHide());
|
m_titleBar->button(TitleBarButtonTabsMenu)->setVisible(true);
|
||||||
m_titleBar->button(TitleBarButtonTabsMenu)->setVisible(!q->isAutoHide());
|
|
||||||
} else {
|
} else {
|
||||||
m_titleBar->button(TitleBarButtonClose)->setVisible(true);
|
m_titleBar->button(TitleBarButtonClose)->setVisible(true);
|
||||||
m_titleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
m_titleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||||
@@ -650,10 +657,7 @@ void DockAreaWidget::updateTitleBarVisibility()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAutoHideFeatureEnabled()) {
|
if (isAutoHideFeatureEnabled()) {
|
||||||
auto tabBar = d->m_titleBar->tabBar();
|
d->m_titleBar->showAutoHideControls(autoHide);
|
||||||
tabBar->setVisible(!autoHide); // Never show tab bar when auto hidden
|
|
||||||
// Always show when auto hidden, never otherwise
|
|
||||||
d->m_titleBar->autoHideTitleLabel()->setVisible(autoHide);
|
|
||||||
updateTitleBarButtonVisibility(container->topLevelDockArea() == this);
|
updateTitleBarButtonVisibility(container->topLevelDockArea() == this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -484,9 +484,10 @@ void DockContainerWidgetPrivate::dropIntoSection(FloatingDockContainer *floating
|
|||||||
|
|
||||||
if (!targetAreaSplitter) {
|
if (!targetAreaSplitter) {
|
||||||
auto splitter = createSplitter(insertParam.orientation());
|
auto splitter = createSplitter(insertParam.orientation());
|
||||||
m_layout->replaceWidget(targetArea, splitter);
|
QLayoutItem *layoutItem = m_layout->replaceWidget(targetArea, splitter);
|
||||||
splitter->addWidget(targetArea);
|
splitter->addWidget(targetArea);
|
||||||
targetAreaSplitter = splitter;
|
targetAreaSplitter = splitter;
|
||||||
|
delete layoutItem;
|
||||||
}
|
}
|
||||||
int areaIndex = targetAreaSplitter->indexOf(targetArea);
|
int areaIndex = targetAreaSplitter->indexOf(targetArea);
|
||||||
auto floatingSplitter = floatingContainer->rootSplitter();
|
auto floatingSplitter = floatingContainer->rootSplitter();
|
||||||
@@ -1532,10 +1533,11 @@ bool DockContainerWidget::restoreState(DockingStateReader &stateReader, bool tes
|
|||||||
if (!newRootSplitter)
|
if (!newRootSplitter)
|
||||||
newRootSplitter = d->createSplitter(Qt::Horizontal);
|
newRootSplitter = d->createSplitter(Qt::Horizontal);
|
||||||
|
|
||||||
d->m_layout->replaceWidget(d->m_rootSplitter, newRootSplitter);
|
QLayoutItem *layoutItem = d->m_layout->replaceWidget(d->m_rootSplitter, newRootSplitter);
|
||||||
auto oldRoot = d->m_rootSplitter;
|
auto oldRoot = d->m_rootSplitter;
|
||||||
d->m_rootSplitter = qobject_cast<DockSplitter *>(newRootSplitter);
|
d->m_rootSplitter = qobject_cast<DockSplitter *>(newRootSplitter);
|
||||||
oldRoot->deleteLater();
|
oldRoot->deleteLater();
|
||||||
|
delete layoutItem;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -87,6 +87,11 @@ public:
|
|||||||
DockWidget *m_centralWidget = nullptr;
|
DockWidget *m_centralWidget = nullptr;
|
||||||
bool m_isLeavingMinimized = false;
|
bool m_isLeavingMinimized = false;
|
||||||
|
|
||||||
|
Qt::ToolButtonStyle m_toolBarStyleDocked = Qt::ToolButtonIconOnly;
|
||||||
|
Qt::ToolButtonStyle m_toolBarStyleFloating = Qt::ToolButtonTextUnderIcon;
|
||||||
|
QSize m_toolBarIconSizeDocked = QSize(16, 16);
|
||||||
|
QSize m_toolBarIconSizeFloating = QSize(24, 24);
|
||||||
|
|
||||||
QString m_workspacePresetsPath;
|
QString m_workspacePresetsPath;
|
||||||
QList<Workspace> m_workspaces;
|
QList<Workspace> m_workspaces;
|
||||||
Workspace m_workspace;
|
Workspace m_workspace;
|
||||||
@@ -769,6 +774,38 @@ QString DockManager::floatingContainersTitle()
|
|||||||
return g_floatingContainersTitle;
|
return g_floatingContainersTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockManager::setDockWidgetToolBarStyle(Qt::ToolButtonStyle style, DockWidget::eState state)
|
||||||
|
{
|
||||||
|
if (DockWidget::StateFloating == state)
|
||||||
|
d->m_toolBarStyleFloating = style;
|
||||||
|
else
|
||||||
|
d->m_toolBarStyleDocked = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ToolButtonStyle DockManager::dockWidgetToolBarStyle(DockWidget::eState state) const
|
||||||
|
{
|
||||||
|
if (DockWidget::StateFloating == state)
|
||||||
|
return d->m_toolBarStyleFloating;
|
||||||
|
else
|
||||||
|
return d->m_toolBarStyleDocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockManager::setDockWidgetToolBarIconSize(const QSize &iconSize, DockWidget::eState state)
|
||||||
|
{
|
||||||
|
if (DockWidget::StateFloating == state)
|
||||||
|
d->m_toolBarIconSizeFloating = iconSize;
|
||||||
|
else
|
||||||
|
d->m_toolBarIconSizeDocked = iconSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize DockManager::dockWidgetToolBarIconSize(DockWidget::eState state) const
|
||||||
|
{
|
||||||
|
if (DockWidget::StateFloating == state)
|
||||||
|
return d->m_toolBarIconSizeFloating;
|
||||||
|
else
|
||||||
|
return d->m_toolBarIconSizeDocked;
|
||||||
|
}
|
||||||
|
|
||||||
DockWidget *DockManager::centralWidget() const
|
DockWidget *DockManager::centralWidget() const
|
||||||
{
|
{
|
||||||
return d->m_centralWidget;
|
return d->m_centralWidget;
|
||||||
|
@@ -186,10 +186,13 @@ public:
|
|||||||
= 0x20, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container
|
= 0x20, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container
|
||||||
AutoHideCloseButtonCollapsesDock
|
AutoHideCloseButtonCollapsesDock
|
||||||
= 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
|
= 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
|
||||||
|
AutoHideHasCloseButton
|
||||||
|
= 0x80, //< If the flag is set an auto hide title bar has a close button
|
||||||
|
AutoHideHasMinimizeButton
|
||||||
|
= 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
|
||||||
|
|
||||||
DefaultAutoHideConfig
|
DefaultAutoHideConfig = AutoHideFeatureEnabled | DockAreaHasAutoHideButton
|
||||||
= AutoHideFeatureEnabled | DockAreaHasAutoHideButton
|
| AutoHideCloseButtonCollapsesDock | AutoHideHasCloseButton
|
||||||
| AutoHideCloseButtonCollapsesDock ///< the default configuration for left and right side bars
|
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
||||||
|
|
||||||
@@ -452,6 +455,31 @@ public:
|
|||||||
*/
|
*/
|
||||||
static QString floatingContainersTitle();
|
static QString floatingContainersTitle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function sets the tool button style for the given dock widget state. It is possible to
|
||||||
|
* switch the tool button style depending on the state. If a dock widget is floating, then here
|
||||||
|
* are more space and it is possible to select a style that requires more space like
|
||||||
|
* Qt::ToolButtonTextUnderIcon. For the docked state Qt::ToolButtonIconOnly might be better.
|
||||||
|
*/
|
||||||
|
void setDockWidgetToolBarStyle(Qt::ToolButtonStyle style, DockWidget::eState state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tool button style for the given docking state. \see setToolBarStyle()
|
||||||
|
*/
|
||||||
|
Qt::ToolButtonStyle dockWidgetToolBarStyle(DockWidget::eState state) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function sets the tool button icon size for the given state. If a dock widget is
|
||||||
|
* floating, there is more space and increasing the icon size is possible. For docked widgets,
|
||||||
|
* small icon sizes, eg. 16 x 16 might be better.
|
||||||
|
*/
|
||||||
|
void setDockWidgetToolBarIconSize(const QSize &iconSize, DockWidget::eState state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the icon size for a given docking state. \see setToolBarIconSize()
|
||||||
|
*/
|
||||||
|
QSize dockWidgetToolBarIconSize(DockWidget::eState state) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns managers central widget or nullptr if no central widget is set.
|
* This function returns managers central widget or nullptr if no central widget is set.
|
||||||
*/
|
*/
|
||||||
|
@@ -64,6 +64,7 @@ public:
|
|||||||
= DockWidget::MinimumSizeHintFromDockWidget;
|
= DockWidget::MinimumSizeHintFromDockWidget;
|
||||||
WidgetFactory *m_factory = nullptr;
|
WidgetFactory *m_factory = nullptr;
|
||||||
QPointer<AutoHideTab> m_sideTabWidget;
|
QPointer<AutoHideTab> m_sideTabWidget;
|
||||||
|
DockWidget::eToolBarStyleSource m_toolBarStyleSource = DockWidget::ToolBarStyleFromDockManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@@ -106,6 +107,11 @@ public:
|
|||||||
* Creates the content widget with the registered widget factory and returns true on success.
|
* Creates the content widget with the registered widget factory and returns true on success.
|
||||||
*/
|
*/
|
||||||
bool createWidgetFromFactory();
|
bool createWidgetFromFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the dock manager toolbar style and icon size for the different states
|
||||||
|
*/
|
||||||
|
void setToolBarStyleFromDockManager();
|
||||||
}; // class DockWidgetPrivate
|
}; // class DockWidgetPrivate
|
||||||
|
|
||||||
DockWidgetPrivate::DockWidgetPrivate(DockWidget *parent)
|
DockWidgetPrivate::DockWidgetPrivate(DockWidget *parent)
|
||||||
@@ -246,6 +252,19 @@ bool DockWidgetPrivate::createWidgetFromFactory()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockWidgetPrivate::setToolBarStyleFromDockManager()
|
||||||
|
{
|
||||||
|
if (!m_dockManager)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto state = DockWidget::StateDocked;
|
||||||
|
q->setToolBarIconSize(m_dockManager->dockWidgetToolBarIconSize(state), state);
|
||||||
|
q->setToolBarStyle(m_dockManager->dockWidgetToolBarStyle(state), state);
|
||||||
|
state = DockWidget::StateFloating;
|
||||||
|
q->setToolBarIconSize(m_dockManager->dockWidgetToolBarIconSize(state), state);
|
||||||
|
q->setToolBarStyle(m_dockManager->dockWidgetToolBarStyle(state), state);
|
||||||
|
}
|
||||||
|
|
||||||
DockWidget::DockWidget(const QString &uniqueId, QWidget *parent)
|
DockWidget::DockWidget(const QString &uniqueId, QWidget *parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
, d(new DockWidgetPrivate(this))
|
, d(new DockWidgetPrivate(this))
|
||||||
@@ -381,6 +400,12 @@ DockManager *DockWidget::dockManager() const
|
|||||||
void DockWidget::setDockManager(DockManager *dockManager)
|
void DockWidget::setDockManager(DockManager *dockManager)
|
||||||
{
|
{
|
||||||
d->m_dockManager = dockManager;
|
d->m_dockManager = dockManager;
|
||||||
|
|
||||||
|
if (!dockManager)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ToolBarStyleFromDockManager == d->m_toolBarStyleSource)
|
||||||
|
d->setToolBarStyleFromDockManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
DockContainerWidget *DockWidget::dockContainer() const
|
DockContainerWidget *DockWidget::dockContainer() const
|
||||||
@@ -491,6 +516,18 @@ QAction *DockWidget::toggleViewAction() const
|
|||||||
return d->m_toggleViewAction;
|
return d->m_toggleViewAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockWidget::setToggleViewAction(QAction *action)
|
||||||
|
{
|
||||||
|
if (!action)
|
||||||
|
return;
|
||||||
|
|
||||||
|
d->m_toggleViewAction->setParent(nullptr);
|
||||||
|
delete d->m_toggleViewAction;
|
||||||
|
d->m_toggleViewAction = action;
|
||||||
|
d->m_toggleViewAction->setParent(this);
|
||||||
|
connect(d->m_toggleViewAction, &QAction::triggered, this, &DockWidget::toggleView);
|
||||||
|
}
|
||||||
|
|
||||||
void DockWidget::setToggleViewActionMode(eToggleViewActionMode mode)
|
void DockWidget::setToggleViewActionMode(eToggleViewActionMode mode)
|
||||||
{
|
{
|
||||||
if (ActionModeToggle == mode) {
|
if (ActionModeToggle == mode) {
|
||||||
@@ -693,6 +730,18 @@ void DockWidget::setToolBar(QToolBar *toolBar)
|
|||||||
setToolbarFloatingStyle(isFloating());
|
setToolbarFloatingStyle(isFloating());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockWidget::setToolBarStyleSource(eToolBarStyleSource source)
|
||||||
|
{
|
||||||
|
d->m_toolBarStyleSource = source;
|
||||||
|
if (ToolBarStyleFromDockManager == d->m_toolBarStyleSource)
|
||||||
|
d->setToolBarStyleFromDockManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
DockWidget::eToolBarStyleSource DockWidget::toolBarStyleSource() const
|
||||||
|
{
|
||||||
|
return d->m_toolBarStyleSource;
|
||||||
|
}
|
||||||
|
|
||||||
void DockWidget::setToolBarStyle(Qt::ToolButtonStyle style, eState state)
|
void DockWidget::setToolBarStyle(Qt::ToolButtonStyle style, eState state)
|
||||||
{
|
{
|
||||||
if (StateFloating == state)
|
if (StateFloating == state)
|
||||||
|
@@ -154,6 +154,8 @@ public:
|
|||||||
|
|
||||||
enum eState { StateHidden, StateDocked, StateFloating };
|
enum eState { StateHidden, StateDocked, StateFloating };
|
||||||
|
|
||||||
|
enum eToolBarStyleSource { ToolBarStyleFromDockManager, ToolBarStyleFromDockWidget };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the widget for the dock widget to widget.
|
* Sets the widget for the dock widget to widget.
|
||||||
* The InsertMode defines how the widget is inserted into the dock widget.
|
* The InsertMode defines how the widget is inserted into the dock widget.
|
||||||
@@ -385,6 +387,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
QAction *toggleViewAction() const;
|
QAction *toggleViewAction() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use provided action to be the default toggle view action for this dock widget.
|
||||||
|
* This dock widget now owns the action.
|
||||||
|
*/
|
||||||
|
void setToggleViewAction(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the behavior of the toggle view action.
|
* Configures the behavior of the toggle view action.
|
||||||
* \see eToggleViewActionMode for a detailed description
|
* \see eToggleViewActionMode for a detailed description
|
||||||
@@ -443,6 +451,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setToolBar(QToolBar *toolBar);
|
void setToolBar(QToolBar *toolBar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures, if the dock widget uses the global tool bar styles from
|
||||||
|
* dock manager or if it uses its own tool bar style
|
||||||
|
*/
|
||||||
|
void setToolBarStyleSource(eToolBarStyleSource source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the configured tool bar style source
|
||||||
|
*/
|
||||||
|
eToolBarStyleSource toolBarStyleSource() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function sets the tool button style for the given dock widget state.
|
* This function sets the tool button style for the given dock widget state.
|
||||||
* It is possible to switch the tool button style depending on the state.
|
* It is possible to switch the tool button style depending on the state.
|
||||||
|
@@ -286,7 +286,8 @@ ADS--AutoHideDockContainer ADS--DockAreaWidget[focused="true"] ADS--DockAreaTitl
|
|||||||
|
|
||||||
/* AutoHideDockContainer titlebar buttons */
|
/* AutoHideDockContainer titlebar buttons */
|
||||||
#dockAreaAutoHideButton {
|
#dockAreaAutoHideButton {
|
||||||
/*qproperty-icon: url(:/ads/images/vs-pin-button.svg);*/
|
/*qproperty-icon: url(:/ads/images/vs-pin-button.svg),
|
||||||
|
url(:/ads/images/vs-pin-button-disabled.svg) disabled;*/
|
||||||
qproperty-iconSize: 16px;
|
qproperty-iconSize: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +296,11 @@ ADS--AutoHideDockContainer #dockAreaAutoHideButton {
|
|||||||
qproperty-iconSize: 16px;
|
qproperty-iconSize: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ADS--AutoHideDockContainer #dockAreaMinimizeButton {
|
||||||
|
/*qproperty-icon: url(:/ads/images/minimize-button-focused.svg);*/
|
||||||
|
qproperty-iconSize: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
ADS--AutoHideDockContainer #dockAreaCloseButton{
|
ADS--AutoHideDockContainer #dockAreaCloseButton{
|
||||||
/*qproperty-icon: url(:/ads/images/close-button-focused.svg)*/
|
/*qproperty-icon: url(:/ads/images/close-button-focused.svg)*/
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user