2018-11-05 19:00:56 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
** Qt Advanced Docking System
|
|
|
|
** Copyright (C) 2017 Uwe Kindler
|
|
|
|
**
|
|
|
|
** This library is free software; you can redistribute it and/or
|
|
|
|
** modify it under the terms of the GNU Lesser General Public
|
|
|
|
** License as published by the Free Software Foundation; either
|
|
|
|
** version 2.1 of the License, or (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This library is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
** Lesser General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU Lesser General Public
|
|
|
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
2018-10-12 19:37:37 +08:00
|
|
|
//============================================================================
|
|
|
|
/// \file DockAreaTitleBar.cpp
|
|
|
|
/// \author Uwe Kindler
|
|
|
|
/// \date 12.10.2018
|
|
|
|
/// \brief Implementation of CDockAreaTitleBar class
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
|
|
|
#include "DockAreaTitleBar.h"
|
|
|
|
|
|
|
|
#include <QPushButton>
|
2018-10-31 06:45:59 +08:00
|
|
|
#include <QToolButton>
|
2018-10-12 19:37:37 +08:00
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QScrollArea>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QDebug>
|
2020-02-02 18:16:38 +08:00
|
|
|
#include <QPointer>
|
2018-10-12 19:37:37 +08:00
|
|
|
|
2018-11-08 17:04:29 +08:00
|
|
|
#include "ads_globals.h"
|
2018-10-12 19:37:37 +08:00
|
|
|
#include "FloatingDockContainer.h"
|
|
|
|
#include "DockAreaWidget.h"
|
|
|
|
#include "DockOverlay.h"
|
|
|
|
#include "DockManager.h"
|
|
|
|
#include "DockWidget.h"
|
|
|
|
#include "DockWidgetTab.h"
|
|
|
|
#include "DockAreaTabBar.h"
|
2019-10-18 14:31:26 +08:00
|
|
|
#include "IconProvider.h"
|
2018-10-12 19:37:37 +08:00
|
|
|
|
2018-12-20 22:29:38 +08:00
|
|
|
#include <iostream>
|
2018-10-12 19:37:37 +08:00
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
2020-02-02 18:16:38 +08:00
|
|
|
using tTitleBarButton = QToolButton;
|
|
|
|
|
|
|
|
|
2018-10-12 19:37:37 +08:00
|
|
|
/**
|
|
|
|
* Private data class of CDockAreaTitleBar class (pimpl)
|
|
|
|
*/
|
|
|
|
struct DockAreaTitleBarPrivate
|
|
|
|
{
|
|
|
|
CDockAreaTitleBar* _this;
|
2020-02-02 18:16:38 +08:00
|
|
|
QPointer<tTitleBarButton> TabsMenuButton;
|
|
|
|
QPointer<tTitleBarButton> UndockButton;
|
|
|
|
QPointer<tTitleBarButton> CloseButton;
|
2018-10-12 19:37:37 +08:00
|
|
|
QBoxLayout* TopLayout;
|
|
|
|
CDockAreaWidget* DockArea;
|
|
|
|
CDockAreaTabBar* TabBar;
|
|
|
|
bool MenuOutdated = true;
|
|
|
|
QMenu* TabsMenu;
|
2020-02-06 07:31:57 +08:00
|
|
|
QList<tTitleBarButton*> DockWidgetActionsButtons;
|
2018-10-12 19:37:37 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Private data constructor
|
|
|
|
*/
|
|
|
|
DockAreaTitleBarPrivate(CDockAreaTitleBar* _public);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the title bar close and menu buttons
|
|
|
|
*/
|
|
|
|
void createButtons();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the internal TabBar
|
|
|
|
*/
|
|
|
|
void createTabBar();
|
2018-11-08 19:57:25 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience function for DockManager access
|
|
|
|
*/
|
|
|
|
CDockManager* dockManager() const
|
|
|
|
{
|
|
|
|
return DockArea->dockManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the given config flag is set
|
|
|
|
*/
|
2020-02-05 15:04:27 +08:00
|
|
|
static bool testConfigFlag(CDockManager::eConfigFlag Flag)
|
2018-11-08 19:57:25 +08:00
|
|
|
{
|
2019-09-13 03:15:35 +08:00
|
|
|
return CDockManager::configFlags().testFlag(Flag);
|
2018-11-08 19:57:25 +08:00
|
|
|
}
|
2018-10-12 19:37:37 +08:00
|
|
|
};// struct DockAreaTitleBarPrivate
|
|
|
|
|
|
|
|
|
2020-02-05 15:04:27 +08:00
|
|
|
/**
|
|
|
|
* Title bar button of a dock area that customizes tTitleBarButton appearance/behaviour
|
|
|
|
* according to various config flags such as:
|
|
|
|
* CDockManager::DockAreaHas_xxx_Button - if set to 'false' keeps the button always invisible
|
|
|
|
* CDockManager::DockAreaHideDisabledButtons - if set to 'true' hides button when it is disabled
|
|
|
|
*/
|
|
|
|
class CTitleBarButton : public tTitleBarButton
|
|
|
|
{
|
2020-02-06 16:15:13 +08:00
|
|
|
Q_OBJECT
|
2020-02-05 15:04:27 +08:00
|
|
|
bool Visible = true;
|
|
|
|
bool HideWhenDisabled = false;
|
|
|
|
public:
|
2020-02-05 15:57:57 +08:00
|
|
|
using Super = tTitleBarButton;
|
2020-02-05 15:04:27 +08:00
|
|
|
CTitleBarButton(bool visible = true, QWidget* parent = nullptr)
|
2020-02-05 15:57:57 +08:00
|
|
|
: tTitleBarButton(parent),
|
|
|
|
Visible(visible),
|
|
|
|
HideWhenDisabled(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
|
|
|
|
{}
|
2020-02-05 15:04:27 +08:00
|
|
|
|
|
|
|
|
2020-02-05 15:57:57 +08:00
|
|
|
/**
|
|
|
|
* Adjust this visibility change request with our internal settings:
|
|
|
|
*/
|
2020-02-05 15:04:27 +08:00
|
|
|
virtual void setVisible(bool visible) override
|
|
|
|
{
|
|
|
|
// 'visible' can stay 'true' if and only if this button is configured to generaly visible:
|
|
|
|
visible = visible && this->Visible;
|
|
|
|
|
|
|
|
// 'visible' can stay 'true' unless: this button is configured to be invisible when it is disabled and it is currently disabled:
|
|
|
|
if(visible && HideWhenDisabled)
|
|
|
|
{
|
|
|
|
visible = isEnabled();
|
|
|
|
}
|
|
|
|
|
2020-02-05 15:57:57 +08:00
|
|
|
Super::setVisible(visible);
|
2020-02-05 15:04:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-02-05 15:57:57 +08:00
|
|
|
/**
|
|
|
|
* Handle EnabledChanged signal to set button invisible if the configured
|
|
|
|
*/
|
2020-02-05 15:04:27 +08:00
|
|
|
bool event(QEvent *ev) override
|
|
|
|
{
|
|
|
|
if(QEvent::EnabledChange == ev->type() && HideWhenDisabled)
|
|
|
|
{
|
|
|
|
// force setVisible() call
|
|
|
|
setVisible(isEnabled());
|
|
|
|
}
|
|
|
|
|
2020-02-05 15:57:57 +08:00
|
|
|
return Super::event(ev);;
|
2020-02-05 15:04:27 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-12 19:37:37 +08:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
|
|
|
_this(_public)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void DockAreaTitleBarPrivate::createButtons()
|
|
|
|
{
|
2019-09-13 16:25:33 +08:00
|
|
|
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
2020-02-02 23:22:05 +08:00
|
|
|
|
2020-02-05 15:04:27 +08:00
|
|
|
// Tabs menu button
|
|
|
|
TabsMenuButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasTabsMenuButton));
|
|
|
|
TabsMenuButton->setObjectName("tabsMenuButton");
|
|
|
|
TabsMenuButton->setAutoRaise(true);
|
|
|
|
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
|
2020-02-05 15:57:57 +08:00
|
|
|
internal::setButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
|
2020-02-05 15:04:27 +08:00
|
|
|
QMenu* TabsMenu = new QMenu(TabsMenuButton);
|
2019-08-26 13:58:56 +08:00
|
|
|
#ifndef QT_NO_TOOLTIP
|
2020-02-05 15:04:27 +08:00
|
|
|
TabsMenu->setToolTipsVisible(true);
|
2019-08-26 13:58:56 +08:00
|
|
|
#endif
|
2020-02-05 15:04:27 +08:00
|
|
|
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
|
|
|
|
TabsMenuButton->setMenu(TabsMenu);
|
2020-02-05 15:33:40 +08:00
|
|
|
internal::setToolTip(TabsMenuButton, QObject::tr("List all tabs"));
|
2020-02-05 15:04:27 +08:00
|
|
|
TabsMenuButton->setSizePolicy(ButtonSizePolicy);
|
|
|
|
TopLayout->addWidget(TabsMenuButton, 0);
|
|
|
|
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
|
|
|
SLOT(onTabsMenuActionTriggered(QAction*)));
|
2018-10-12 19:37:37 +08:00
|
|
|
|
2020-02-05 15:04:27 +08:00
|
|
|
// Undock button
|
|
|
|
UndockButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasUndockButton));
|
|
|
|
UndockButton->setObjectName("undockButton");
|
|
|
|
UndockButton->setAutoRaise(true);
|
2020-02-05 15:33:40 +08:00
|
|
|
internal::setToolTip(UndockButton, QObject::tr("Detach Group"));
|
2020-02-05 15:57:57 +08:00
|
|
|
internal::setButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
|
2020-02-05 15:04:27 +08:00
|
|
|
UndockButton->setSizePolicy(ButtonSizePolicy);
|
|
|
|
TopLayout->addWidget(UndockButton, 0);
|
|
|
|
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
|
2018-11-04 03:51:02 +08:00
|
|
|
|
2020-02-05 15:04:27 +08:00
|
|
|
// Close button
|
|
|
|
CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton));
|
|
|
|
CloseButton->setObjectName("closeButton");
|
|
|
|
CloseButton->setAutoRaise(true);
|
2020-02-05 15:57:57 +08:00
|
|
|
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
2020-02-05 15:04:27 +08:00
|
|
|
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
|
|
|
{
|
2020-02-05 15:33:40 +08:00
|
|
|
internal::setToolTip(CloseButton, QObject::tr("Close Active Tab"));
|
2018-11-09 17:07:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-05 15:33:40 +08:00
|
|
|
internal::setToolTip(CloseButton, QObject::tr("Close Group"));
|
2019-09-13 03:24:48 +08:00
|
|
|
}
|
2020-02-05 15:04:27 +08:00
|
|
|
CloseButton->setSizePolicy(ButtonSizePolicy);
|
|
|
|
CloseButton->setIconSize(QSize(16, 16));
|
|
|
|
TopLayout->addWidget(CloseButton, 0);
|
|
|
|
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
2018-10-12 19:37:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void DockAreaTitleBarPrivate::createTabBar()
|
|
|
|
{
|
|
|
|
TabBar = new CDockAreaTabBar(DockArea);
|
|
|
|
TopLayout->addWidget(TabBar);
|
2018-10-12 20:51:57 +08:00
|
|
|
_this->connect(TabBar, SIGNAL(tabClosed(int)), SLOT(markTabsMenuOutdated()));
|
|
|
|
_this->connect(TabBar, SIGNAL(tabOpened(int)), SLOT(markTabsMenuOutdated()));
|
|
|
|
_this->connect(TabBar, SIGNAL(tabInserted(int)), SLOT(markTabsMenuOutdated()));
|
|
|
|
_this->connect(TabBar, SIGNAL(removingTab(int)), SLOT(markTabsMenuOutdated()));
|
|
|
|
_this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(markTabsMenuOutdated()));
|
|
|
|
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
|
2018-10-15 21:09:59 +08:00
|
|
|
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
|
2018-12-20 22:29:38 +08:00
|
|
|
|
|
|
|
TabBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
_this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)),
|
|
|
|
SLOT(showContextMenu(const QPoint&)));
|
2018-10-12 19:37:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
|
|
|
|
QFrame(parent),
|
|
|
|
d(new DockAreaTitleBarPrivate(this))
|
|
|
|
{
|
|
|
|
d->DockArea = parent;
|
|
|
|
|
|
|
|
setObjectName("dockAreaTitleBar");
|
|
|
|
d->TopLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
|
|
|
d->TopLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
d->TopLayout->setSpacing(0);
|
|
|
|
setLayout(d->TopLayout);
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
d->createTabBar();
|
|
|
|
d->createButtons();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CDockAreaTitleBar::~CDockAreaTitleBar()
|
|
|
|
{
|
2020-02-02 18:16:38 +08:00
|
|
|
if (!d->CloseButton.isNull())
|
|
|
|
{
|
|
|
|
delete d->CloseButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!d->TabsMenuButton.isNull())
|
|
|
|
{
|
|
|
|
delete d->TabsMenuButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!d->UndockButton.isNull())
|
|
|
|
{
|
|
|
|
delete d->UndockButton;
|
|
|
|
}
|
2018-10-12 19:37:37 +08:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
|
|
|
|
{
|
|
|
|
return d->TabBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::markTabsMenuOutdated()
|
|
|
|
{
|
|
|
|
d->MenuOutdated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::onTabsMenuAboutToShow()
|
|
|
|
{
|
|
|
|
if (!d->MenuOutdated)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMenu* menu = d->TabsMenuButton->menu();
|
|
|
|
menu->clear();
|
|
|
|
for (int i = 0; i < d->TabBar->count(); ++i)
|
|
|
|
{
|
|
|
|
if (!d->TabBar->isTabOpen(i))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
auto Tab = d->TabBar->tab(i);
|
|
|
|
QAction* Action = menu->addAction(Tab->icon(), Tab->text());
|
2020-02-05 15:33:40 +08:00
|
|
|
internal::setToolTip(Action, Tab->toolTip());
|
2018-10-12 19:37:37 +08:00
|
|
|
Action->setData(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
d->MenuOutdated = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::onCloseButtonClicked()
|
|
|
|
{
|
2019-07-21 15:53:24 +08:00
|
|
|
ADS_PRINT("CDockAreaTitleBar::onCloseButtonClicked");
|
2018-11-08 19:57:25 +08:00
|
|
|
if (d->testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
|
|
|
{
|
|
|
|
d->TabBar->closeTab(d->TabBar->currentIndex());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d->DockArea->closeArea();
|
|
|
|
}
|
2018-10-12 19:37:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-04 03:51:02 +08:00
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::onUndockButtonClicked()
|
|
|
|
{
|
2019-07-11 21:12:39 +08:00
|
|
|
if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
|
|
|
{
|
|
|
|
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
|
|
|
|
}
|
2018-11-04 03:51:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-12 19:37:37 +08:00
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::onTabsMenuActionTriggered(QAction* Action)
|
|
|
|
{
|
|
|
|
int Index = Action->data().toInt();
|
|
|
|
d->TabBar->setCurrentIndex(Index);
|
2018-10-15 21:09:59 +08:00
|
|
|
emit tabBarClicked(Index);
|
2018-10-12 19:37:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-12 20:51:57 +08:00
|
|
|
//============================================================================
|
2020-02-06 16:15:13 +08:00
|
|
|
void CDockAreaTitleBar::updateDockWidgetActionsButtons()
|
2018-10-12 20:51:57 +08:00
|
|
|
{
|
2020-02-06 16:15:13 +08:00
|
|
|
CDockWidget* DockWidget = d->TabBar->currentTab()->dockWidget();
|
2020-02-06 07:31:57 +08:00
|
|
|
if (!d->DockWidgetActionsButtons.isEmpty())
|
|
|
|
{
|
|
|
|
for (auto Button : d->DockWidgetActionsButtons)
|
|
|
|
{
|
|
|
|
d->TopLayout->removeWidget(Button);
|
|
|
|
delete Button;
|
|
|
|
}
|
|
|
|
d->DockWidgetActionsButtons.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Actions = DockWidget->titleBarActions();
|
|
|
|
if (Actions.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int InsertIndex = 2;
|
|
|
|
for (auto Action : Actions)
|
|
|
|
{
|
|
|
|
auto Button = new CTitleBarButton(true, this);
|
|
|
|
Button->setDefaultAction(Action);
|
|
|
|
Button->setAutoRaise(true);
|
|
|
|
Button->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
Button->setObjectName(Action->objectName());
|
|
|
|
d->TopLayout->insertWidget(InsertIndex++, Button, 0);
|
|
|
|
d->DockWidgetActionsButtons.append(Button);
|
|
|
|
}
|
2018-10-12 20:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-06 16:15:13 +08:00
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::onCurrentTabChanged(int Index)
|
|
|
|
{
|
|
|
|
if (Index < 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d->testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
|
|
|
{
|
|
|
|
CDockWidget* DockWidget = d->TabBar->tab(Index)->dockWidget();
|
|
|
|
d->CloseButton->setEnabled(DockWidget->features().testFlag(CDockWidget::DockWidgetClosable));
|
|
|
|
}
|
|
|
|
|
|
|
|
updateDockWidgetActionsButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-04 03:51:02 +08:00
|
|
|
//============================================================================
|
|
|
|
QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const
|
|
|
|
{
|
|
|
|
switch (which)
|
|
|
|
{
|
|
|
|
case TitleBarButtonTabsMenu: return d->TabsMenuButton;
|
|
|
|
case TitleBarButtonUndock: return d->UndockButton;
|
|
|
|
case TitleBarButtonClose: return d->CloseButton;
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::setVisible(bool Visible)
|
|
|
|
{
|
|
|
|
Super::setVisible(Visible);
|
2019-01-23 14:43:07 +08:00
|
|
|
markTabsMenuOutdated();
|
2018-11-04 03:51:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-20 22:29:38 +08:00
|
|
|
//============================================================================
|
|
|
|
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
|
|
|
|
{
|
2019-12-16 20:56:20 +08:00
|
|
|
if (d->TabBar->dragState() == DraggingFloatingWidget)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-20 22:29:38 +08:00
|
|
|
QMenu Menu(this);
|
2019-07-11 21:12:39 +08:00
|
|
|
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
|
|
|
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
2018-12-20 22:29:38 +08:00
|
|
|
Menu.addSeparator();
|
2019-07-11 21:12:39 +08:00
|
|
|
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
|
2018-12-20 22:29:38 +08:00
|
|
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
|
|
|
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
|
|
|
|
Menu.exec(mapToGlobal(pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-12 19:37:37 +08:00
|
|
|
} // namespace ads
|
|
|
|
|
2020-02-06 16:15:13 +08:00
|
|
|
#include "DockAreaTitleBar.moc"
|
|
|
|
|
2018-10-12 19:37:37 +08:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// EOF DockAreaTitleBar.cpp
|