diff --git a/shell/mainwindow.h b/shell/mainwindow.h --- a/shell/mainwindow.h +++ b/shell/mainwindow.h @@ -98,6 +98,7 @@ private Q_SLOTS: void updateCaption(); + void updateActiveDocumentConnection(IDocument* document); void updateTabColor(IDocument* doc); void updateAllTabColors(); diff --git a/shell/mainwindow.cpp b/shell/mainwindow.cpp --- a/shell/mainwindow.cpp +++ b/shell/mainwindow.cpp @@ -325,8 +325,9 @@ Core::self()->sessionController()->plugActions(); d->setupGui(); - //Queued so we process it with some delay, to make sure the rest of the UI has already adapted + //Queued so we process it with some delay, to make sure the rest of the UI has already adapted connect(Core::self()->documentController(), &IDocumentController::documentActivated, this, &MainWindow::updateCaption, Qt::QueuedConnection); + connect(Core::self()->documentController(), &IDocumentController::documentActivated, this, &MainWindow::updateActiveDocumentConnection, Qt::QueuedConnection); connect(Core::self()->documentController(), &IDocumentController::documentClosed, this, &MainWindow::updateCaption, Qt::QueuedConnection); connect(Core::self()->documentController(), &IDocumentController::documentUrlChanged, this, &MainWindow::updateCaption, Qt::QueuedConnection); connect(Core::self()->sessionController()->activeSession(), &ISession::sessionUpdated, this, &MainWindow::updateCaption); @@ -357,6 +358,12 @@ return Sublime::MainWindow::queryClose(); } +void MainWindow::updateActiveDocumentConnection(IDocument* document) +{ + disconnect(d->activeDocumentReadWriteConnection); + d->activeDocumentReadWriteConnection = connect(document->textDocument(), &KTextEditor::Document::readWriteChanged, this, &MainWindow::updateCaption); +} + void MainWindow::updateCaption() { const auto activeSession = Core::self()->sessionController()->activeSession(); @@ -369,11 +376,13 @@ Sublime::Document* doc = area()->activeView()->document(); Sublime::UrlDocument* urlDoc = dynamic_cast(doc); + KTextEditor::Document * kTextDocument = Core::self()->documentController()->activeDocument()->textDocument(); if(urlDoc) title += Core::self()->projectController()->prettyFileName(urlDoc->url(), KDevelop::IProjectController::FormatPlain); else title += doc->title(); - + if(kTextDocument && !kTextDocument->isReadWrite()) + title += i18n(" (read only)"); title += QLatin1String(" ]"); } diff --git a/shell/mainwindow_p.h b/shell/mainwindow_p.h --- a/shell/mainwindow_p.h +++ b/shell/mainwindow_p.h @@ -63,6 +63,7 @@ ~MainWindowPrivate() override; QPointer centralPlugin; + QMetaObject::Connection activeDocumentReadWriteConnection; void setupActions(); void setupGui();