Skip to content
Extraits de code Groupes Projets
Vérifiée Valider c265e001 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

UI: Closing a document view permits to close the unclosable docks

parent 375403a3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!18Implement the VivyDocument specification
......@@ -15,14 +15,18 @@ AbstractDocumentView::AbstractDocumentView(AbstractDocumentView::Type type,
setTabPosition(Qt::RightDockWidgetArea, QTabWidget::East);
}
// A utility function to delete all the child widgets
void
AbstractDocumentView::deleteAllContent() noexcept
AbstractDocumentView::allowToCloseAllDocks() noexcept
{
// Allow to close all dock widgets
for (UnclosableDockWidget *const dock : dockWidgets)
dock->allowClose();
}
// A utility function to delete all the child widgets
void
AbstractDocumentView::deleteAllContent() noexcept
{
// Delete all widgets
if (layout() != nullptr) {
QLayoutItem *item;
......@@ -30,7 +34,7 @@ AbstractDocumentView::deleteAllContent() noexcept
delete item->widget();
delete item;
}
delete layout();
delete layout(); // XXX
}
}
......
......@@ -45,6 +45,7 @@ signals:
protected:
void deleteAllContent() noexcept;
void allowToCloseAllDocks() noexcept;
void delDockWidget(UnclosableDockWidget **) noexcept;
void addDockWidget(Qt::DockWidgetArea, UnclosableDockWidget *, Qt::Orientation) noexcept;
......
......@@ -164,7 +164,15 @@ MainWindow::MainWindow() noexcept
newDocument();
}
MainWindow::~MainWindow() noexcept { qDebug() << "Closing the main window!"; }
void
MainWindow::closeEvent(QCloseEvent *event) noexcept
{
qDebug() << "Closing the main window!";
forEachViews<VivyDocumentView>(
[](VivyDocumentView *view, int) { view->closeDocument(); }); // XXX
// event->accept();
QMainWindow::closeEvent(event);
}
void
MainWindow::updateFakeVimUsage(bool yes) noexcept
......
......@@ -25,7 +25,6 @@ class MainWindow final : public QMainWindow {
public:
explicit MainWindow() noexcept;
~MainWindow() noexcept override;
AbstractDocument *getCurrentDocument() const;
template <class Document> Document *getCurrentDocument() const
......@@ -91,6 +90,9 @@ private:
}
}
protected:
void closeEvent(QCloseEvent *) noexcept override;
private slots:
void newDocument() noexcept;
void openDocument() noexcept;
......
......@@ -21,6 +21,6 @@ UnclosableDockWidget::closeEvent(QCloseEvent *event) noexcept
void
UnclosableDockWidget::allowClose() noexcept
{
qDebug() << "Dock" << windowTitle() << "is now allowed to be closed";
// qDebug() << "Dock" << windowTitle() << "is now allowed to be closed";
allowedToClose = true;
}
......@@ -147,12 +147,13 @@ VivyDocumentView::closeDocument() noexcept
qDebug() << "Closing the document:" << document->getName() << "( ref count is"
<< document.use_count() << ")";
vivyApp->documentStore.closeDocument(document->getUuid());
allowToCloseAllDocks();
// Kubat: the visualizer pointer should have been deleted by the
// deleteAllContent() call if it was created.
deleteAllContent();
visualizer = nullptr;
property = nullptr;
// deleteAllContent();
// visualizer = nullptr;
// property = nullptr;
}
QIcon
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter