diff --git a/src/Lib/Document/VivyDocument.cc b/src/Lib/Document/VivyDocument.cc index 0bc030af292f13e54b2c5d419c37551f7f2195ce..377425dee10d6b8c08b443e48289d6260c628e99 100644 --- a/src/Lib/Document/VivyDocument.cc +++ b/src/Lib/Document/VivyDocument.cc @@ -237,7 +237,7 @@ VivyDocument::copy(const QString &newName) // Rename + create the disk on disk as it's a memory document if (documentOptions & MemoryDocumentCreation) - return saveMemoryFile(newPath); + saveMemoryFile(newPath); // Compute new paths, the document is really on disk initially else { @@ -247,6 +247,8 @@ VivyDocument::copy(const QString &newName) documentName = newPath.baseName(); }); } + + emit documentChanged(); } void @@ -256,7 +258,7 @@ VivyDocument::rename(const QString &newName) // Rename + create the disk on disk as it's a memory document if (documentOptions & MemoryDocumentCreation) - return saveMemoryFile(newPath); + saveMemoryFile(newPath); // Compute new paths, the document is really on disk initially else { @@ -266,6 +268,8 @@ VivyDocument::rename(const QString &newName) documentName = newPath.baseName(); }); } + + emit documentChanged(); } QFileInfo diff --git a/src/Lib/Script/ScriptDocument.cc b/src/Lib/Script/ScriptDocument.cc index 715451b6dd7e4b8a46b60e9c5f11bad3d2f913ef..6294656caf585053e565d7926239742f00dd9926 100644 --- a/src/Lib/Script/ScriptDocument.cc +++ b/src/Lib/Script/ScriptDocument.cc @@ -20,6 +20,7 @@ ScriptDocument::copy(const QString &newName) /* Compute new paths */ const QFileInfo newPath(newName); copyWith(newPath, [=, this]() noexcept { name = newName; }); + emit documentChanged(); } void @@ -28,6 +29,7 @@ ScriptDocument::rename(const QString &newName) /* Compute new paths */ const QFileInfo newPath(newName); renameWith(newPath, [=, this]() noexcept { name = newName; }); + emit documentChanged(); } void diff --git a/src/UI/MainWindow.cc b/src/UI/MainWindow.cc index f4d0af808c4784b94e422618cab11a471917aab1..7430255d9a231291e2e6e37806bff4e83dd0fcec 100644 --- a/src/UI/MainWindow.cc +++ b/src/UI/MainWindow.cc @@ -261,10 +261,8 @@ MainWindow::renameFile() noexcept if (filename.isEmpty()) throw std::runtime_error("No filename passed"); - else { + else document->rename(filename); // Kubat: Save is called by rename! - emit docView->documentPropertyChanged(); - } } catch (const std::runtime_error &e) { @@ -285,10 +283,8 @@ MainWindow::saveFileAs() noexcept if (filename.isEmpty()) throw std::runtime_error("No filename passed"); - else { + else document->copy(filename); // Kubat: Save is called by copy! - emit docView->documentPropertyChanged(); - } } catch (const std::runtime_error &e) { @@ -434,9 +430,14 @@ MainWindow::addTab(AbstractDocumentView *const tab) &MainWindow::documentViewActionsChanged); connect(tab, &AbstractDocumentView::documentPropertyChanged, this, [this, tab]() noexcept -> void { - int tabIndex = documents->indexOf(tab); - documents->setTabToolTip(tabIndex, tab->getDocumentTabToolTip()); - documents->setTabText(tabIndex, tab->getDocumentTabName()); + int tabIndex = getIndexOfTab(tab); + if (tabIndex < 0) { + qDebug() << "Tab was not found!"; + } else { + qDebug() << "Tab was found at index" << tabIndex; + documents->setTabToolTip(tabIndex, tab->getDocumentTabToolTip()); + documents->setTabText(tabIndex, tab->getDocumentTabName()); + } }); documentViewActionsChanged(); qDebug() << "View constructed successfully"; diff --git a/src/UI/ScriptDocumentView.cc b/src/UI/ScriptDocumentView.cc index a7ab4938c8d2e3275589286d17ad07692415950a..e1b50cc3ad4f480f4d5d850696ec06eedba36cbc 100644 --- a/src/UI/ScriptDocumentView.cc +++ b/src/UI/ScriptDocumentView.cc @@ -26,6 +26,8 @@ ScriptDocumentView::ScriptDocumentView(std::shared_ptr<ScriptDocument> ptr, QWid setUseFakeVimEditor(vivyApp->getUseFakeVimEditor()); connect(this, &ScriptDocumentView::luaErrorFound, editor, &ScriptEditor::updateLastLuaError); + connect(document.get(), &AbstractDocument::documentChanged, this, + [=, this]() noexcept -> void { emit documentPropertyChanged(); }); // Same style as the editor setStyleSheet(QStringLiteral("* {" diff --git a/src/UI/VivyDocumentView.cc b/src/UI/VivyDocumentView.cc index 0962ecff3417024bef60efee5d23026bef7b0cec..0f36c52bfb19c9d89b96de7a350eba505b5ffe16 100644 --- a/src/UI/VivyDocumentView.cc +++ b/src/UI/VivyDocumentView.cc @@ -35,6 +35,7 @@ VivyDocumentView::VivyDocumentView(std::shared_ptr<VivyDocument> doc, QWidget *p connect(document.get(), &AbstractDocument::documentChanged, this, [=, this]() noexcept -> void { if (property) openProperties(); + emit documentPropertyChanged(); }); viewsActions.append(openPropertiesAct);