Experimental implementation of close request

This commit is contained in:
Uwe Kindler 2020-01-03 18:13:34 +01:00
parent 25e8d8691f
commit 0305d8a221
4 changed files with 53 additions and 2 deletions

View File

@ -494,7 +494,8 @@ void CDockAreaWidget::onTabCloseRequested(int Index)
auto* DockWidget = dockWidget(Index); auto* DockWidget = dockWidget(Index);
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose)) if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{ {
DockWidget->deleteDockWidget(); //DockWidget->deleteDockWidget();
DockWidget->closeDockWidget();
} }
else else
{ {

View File

@ -31,6 +31,8 @@
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "DockWidget.h" #include "DockWidget.h"
#include <iostream>
#include <QBoxLayout> #include <QBoxLayout>
#include <QAction> #include <QAction>
#include <QSplitter> #include <QSplitter>
@ -745,6 +747,42 @@ void CDockWidget::deleteDockWidget()
} }
//============================================================================
bool CDockWidget::handleCloseRequest()
{
std::cout << "CDockWidget::handleCloseRequest()" << std::endl;
return true;
}
//============================================================================
void CDockWidget::closeDockWidget()
{
closeDockWidgetInternal();
}
//============================================================================
bool CDockWidget::closeDockWidgetInternal()
{
if (features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
{
if (handleCloseRequest())
{
deleteDockWidget();
return true;
}
}
else
{
toggleView(false);
return true;
}
return false;
}
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -135,6 +135,12 @@ protected:
*/ */
void toggleViewInternal(bool Open); void toggleViewInternal(bool Open);
/**
* Internal close dock widget implementation.
* The function returns true if the dock widget has been closed or hidden
*/
bool closeDockWidgetInternal();
public: public:
using Super = QFrame; using Super = QFrame;
@ -426,6 +432,12 @@ public slots:
*/ */
void deleteDockWidget(); void deleteDockWidget();
/**
* Closes the dock widget
*/
void closeDockWidget();
signals: signals:
/** /**
* This signal is emitted if the dock widget is opened or closed * This signal is emitted if the dock widget is opened or closed

View File

@ -133,7 +133,7 @@ public:
void setText(const QString& title); void setText(const QString& title);
/** /**
* This function returns true if the assigned dock widget is closeable * This function returns true if the assigned dock widget is closable
*/ */
bool isClosable() const; bool isClosable() const;