| 452 | } |
| 453 | |
| 454 | void 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 | |
| 506 | void MainWindow::updateAllTabColors() |
| 507 | { |
nothing calls this directly
no test coverage detected