Implemented custom close handling for dynamically created image viewers

This commit is contained in:
Uwe Kindler 2022-11-07 08:19:00 +01:00
parent eda610409a
commit be86a772ce
2 changed files with 17 additions and 3 deletions

View File

@ -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"))
{

View File

@ -63,6 +63,7 @@ private slots:
void createEditor();
void createTable();
void onEditorCloseRequested();
void onImageViewerCloseRequested();
void showStatusDialog();
void toggleDockWidgetWindowTitle();
void applyVsStyle();