MCPcopy Create free account
hub / github.com/KDE/kdevelop / updateCaption

Method updateCaption

kdevplatform/shell/mainwindow.cpp:454–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454void MainWindow::updateCaption()
455{
456 QString title;
457 QString localFilePath;
458 bool isDocumentModified = false;
459
460 if(area()->activeView())
461 {
462 Sublime::Document* doc = area()->activeView()->document();
463 auto* urlDoc = qobject_cast<Sublime::UrlDocument*>(doc);
464 if(urlDoc)
465 {
466 if (urlDoc->url().isLocalFile()) {
467 localFilePath = urlDoc->url().toLocalFile();
468 }
469 title += Core::self()->projectController()->prettyFileName(urlDoc->url(), KDevelop::IProjectController::FormatPlain);
470 }
471 else
472 title += doc->title();
473
474 auto iDoc = qobject_cast<IDocument*>(doc);
475 if (iDoc && iDoc->textDocument() && !iDoc->textDocument()->isReadWrite()) {
476 title += i18n(" (read only)");
477 }
478
479 title += QLatin1String(" [*]"); // [*] is placeholder for modified state, cmp. QWidget::windowModified
480
481 isDocumentModified = iDoc && (iDoc->state() != IDocument::Clean);
482 }
483
484 const auto activeSession = Core::self()->sessionController()->activeSession();
485 const QString sessionTitle = activeSession ? activeSession->description() : QString();
486 if (!sessionTitle.isEmpty()) {
487 if (title.isEmpty()) {
488 title = sessionTitle;
489 } else {
490 title = sessionTitle + QLatin1String(" - [ ") + title + QLatin1Char(']');
491 }
492 }
493
494 // Workaround for a bug observed on macOS with Qt 5.9.8 (TODO: test with newer Qt, report bug):
495 // Ensure to call setCaption() (thus implicitly setWindowTitle()) before
496 // setWindowModified() & setWindowFilePath().
497 // Otherwise, if the state will change "modified" from true to false as well change the title string,
498 // calling setWindowTitle() last results in the "modified" indicator==asterisk becoming part of the
499 // displayed window title somehow.
500 // Other platforms so far not known to be affected, any order of calls seems fine.
501 setCaption(title);
502 setWindowModified(isDocumentModified);
503 setWindowFilePath(localFilePath);
504}
505
506void MainWindow::updateAllTabColors()
507{

Callers

nothing calls this directly

Calls 15

isLocalFileMethod · 0.80
toLocalFileMethod · 0.80
projectControllerMethod · 0.80
sessionControllerMethod · 0.80
QStringClass · 0.70
activeViewMethod · 0.45
documentMethod · 0.45
urlMethod · 0.45
prettyFileNameMethod · 0.45
titleMethod · 0.45
textDocumentMethod · 0.45
stateMethod · 0.45

Tested by

no test coverage detected