mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Porperly moved title bar context menu code from DockAreaTabBar into DockAreaTitleBar
This commit is contained in:
parent
b61f50982a
commit
d10d59a8e2
@ -259,10 +259,6 @@ void DockAreaTitleBarPrivate::createTabBar()
|
||||
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
|
||||
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
|
||||
_this->connect(TabBar, SIGNAL(elidedChanged(bool)), SLOT(markTabsMenuOutdated()));
|
||||
|
||||
TabBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
_this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
SLOT(showContextMenu(const QPoint&)));
|
||||
}
|
||||
|
||||
|
||||
@ -519,25 +515,6 @@ void CDockAreaTitleBar::setVisible(bool Visible)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
|
||||
{
|
||||
if (d->DragState == DraggingFloatingWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu Menu(this);
|
||||
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
Menu.addSeparator();
|
||||
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
Menu.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
@ -637,6 +614,26 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
ev->accept();
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu Menu(this);
|
||||
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
Menu.addSeparator();
|
||||
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
Menu.exec(ev->globalPos());
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
#include "DockAreaTitleBar.moc"
|
||||
|
@ -60,7 +60,6 @@ private slots:
|
||||
void onUndockButtonClicked();
|
||||
void onTabsMenuActionTriggered(QAction* Action);
|
||||
void onCurrentTabChanged(int Index);
|
||||
void showContextMenu(const QPoint& pos);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -84,6 +83,11 @@ protected:
|
||||
*/
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
/**
|
||||
* Show context menu
|
||||
*/
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Call this slot to tell the title bar that it should update the tabs menu
|
||||
|
Loading…
Reference in New Issue
Block a user