mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Implemented custom close handling for dynamically created image viewers
This commit is contained in:
parent
eda610409a
commit
be86a772ce
@ -873,6 +873,20 @@ void CMainWindow::onEditorCloseRequested()
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::onImageViewerCloseRequested()
|
||||
{
|
||||
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
||||
int Result = QMessageBox::question(this, "Close Image Viewer", QString("%1 "
|
||||
"contains unsaved changes? Would you like to close it?")
|
||||
.arg(DockWidget->windowTitle()));
|
||||
if (QMessageBox::Yes == Result)
|
||||
{
|
||||
DockWidget->closeDockWidget();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::createTable()
|
||||
{
|
||||
@ -931,9 +945,8 @@ void CMainWindow::createImageViewer()
|
||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetForceCloseWithArea, true);
|
||||
DockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
|
||||
DockWidget->resize(QSize(640, 480));
|
||||
connect(DockWidget, &ads::CDockWidget::closeRequested, [this](){
|
||||
qDebug() << "ImageViewer close requested";
|
||||
});
|
||||
connect(DockWidget, &ads::CDockWidget::closeRequested, this,
|
||||
&CMainWindow::onImageViewerCloseRequested);
|
||||
|
||||
if (a->text().startsWith("Floating"))
|
||||
{
|
||||
|
@ -63,6 +63,7 @@ private slots:
|
||||
void createEditor();
|
||||
void createTable();
|
||||
void onEditorCloseRequested();
|
||||
void onImageViewerCloseRequested();
|
||||
void showStatusDialog();
|
||||
void toggleDockWidgetWindowTitle();
|
||||
void applyVsStyle();
|
||||
|
Loading…
Reference in New Issue
Block a user