mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
Fixed setting of tab widget visibility and toggleViewAction() state when dragging dock areas with closed dock widgets
This commit is contained in:
parent
67199a81f4
commit
c9123c3640
@ -348,7 +348,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
||||
DockWidget->tabWidget()->setDockAreaWidget(this);
|
||||
auto TabWidget = DockWidget->tabWidget();
|
||||
d->TabsLayout->insertWidget(index, TabWidget);
|
||||
TabWidget->show();
|
||||
TabWidget->setVisible(!DockWidget->isClosed());
|
||||
connect(TabWidget, SIGNAL(clicked()), this, SLOT(onDockWidgetTitleClicked()));
|
||||
DockWidget->setProperty(INDEX_PROPERTY, index);
|
||||
if (Activate)
|
||||
@ -421,7 +421,7 @@ CDockWidget* CDockAreaWidget::currentDockWidget() const
|
||||
//============================================================================
|
||||
void CDockAreaWidget::setCurrentDockWidget(CDockWidget* DockWidget)
|
||||
{
|
||||
int Index = tabIndex(DockWidget);
|
||||
int Index = index(DockWidget);
|
||||
if (Index < 0)
|
||||
{
|
||||
return;
|
||||
@ -497,12 +497,19 @@ QRect CDockAreaWidget::contentAreaGeometry() const
|
||||
|
||||
|
||||
//============================================================================
|
||||
int CDockAreaWidget::tabIndex(CDockWidget* DockWidget)
|
||||
int CDockAreaWidget::index(CDockWidget* DockWidget)
|
||||
{
|
||||
return d->ContentsLayout->indexOf(DockWidget);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
int CDockAreaWidget::tabIndex(CDockWidget* DockWidget)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QList<CDockWidget*> CDockAreaWidget::dockWidgets() const
|
||||
{
|
||||
|
@ -113,6 +113,16 @@ protected:
|
||||
*/
|
||||
CDockWidget* nextOpenDockWidget(CDockWidget* DockWidget) const;
|
||||
|
||||
/**
|
||||
* Returns the index of the given DockWidget in the internal layout
|
||||
*/
|
||||
int index(CDockWidget* DockWidget);
|
||||
|
||||
/**
|
||||
* Returns the tab index for the given dock widget
|
||||
*/
|
||||
int tabIndex(CDockWidget* DockWidget);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default Constructor
|
||||
@ -145,11 +155,6 @@ public:
|
||||
*/
|
||||
QRect contentAreaGeometry() const;
|
||||
|
||||
/**
|
||||
* Returns the tab index of the given DockWidget
|
||||
*/
|
||||
int tabIndex(CDockWidget* DockWidget);
|
||||
|
||||
/**
|
||||
* Returns a list of all dock widgets in this dock area.
|
||||
* This list contains open and closed dock widgets.
|
||||
|
@ -49,6 +49,8 @@
|
||||
#include "DockSplitter.h"
|
||||
#include "ads_globals.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
/**
|
||||
@ -121,7 +123,7 @@ void DockWidgetPrivate::showDockWidget()
|
||||
else
|
||||
{
|
||||
DockArea->show();
|
||||
DockArea->setCurrentIndex(DockArea->tabIndex(_this));
|
||||
DockArea->setCurrentDockWidget(_this);
|
||||
QSplitter* Splitter = internal::findParent<QSplitter*>(_this);
|
||||
while (Splitter && !Splitter->isVisible())
|
||||
{
|
||||
@ -380,6 +382,8 @@ void CDockWidget::setToggleViewActionMode(eToggleViewActionMode Mode)
|
||||
//============================================================================
|
||||
void CDockWidget::toggleView(bool Open)
|
||||
{
|
||||
std::cout << "CDockWidget::toggleView " << objectName().toStdString()
|
||||
<< " " << Open << std::endl;
|
||||
QAction* Sender = qobject_cast<QAction*>(sender());
|
||||
if (Sender == d->ToggleViewAction && !d->ToggleViewAction->isCheckable())
|
||||
{
|
||||
@ -412,7 +416,7 @@ void CDockWidget::toggleView(bool Open)
|
||||
void CDockWidget::setDockArea(CDockAreaWidget* DockArea)
|
||||
{
|
||||
d->DockArea = DockArea;
|
||||
d->ToggleViewAction->setChecked(DockArea != nullptr);
|
||||
d->ToggleViewAction->setChecked(DockArea != nullptr && !this->isClosed());
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,14 +244,14 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
|
||||
{
|
||||
// Find tab under mouse
|
||||
QPoint pos = d->DockArea->mapFromGlobal(ev->globalPos());
|
||||
int fromIndex = d->DockArea->tabIndex(d->DockWidget);
|
||||
int fromIndex = d->DockArea->index(d->DockWidget);
|
||||
int toIndex = d->DockArea->indexOfContentByTitlePos(pos, this);
|
||||
if (-1 == toIndex)
|
||||
{
|
||||
toIndex = d->DockArea->count() - 1;
|
||||
}
|
||||
qDebug() << "Move tab from " << fromIndex << " to " << toIndex;
|
||||
d->DockArea->reorderDockWidget(fromIndex, toIndex);
|
||||
//d->DockArea->reorderDockWidget(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
if (!d->DragStartMousePosition.isNull())
|
||||
|
Loading…
Reference in New Issue
Block a user