Changeset View
Changeset View
Standalone View
Standalone View
kate/katedocmanager.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
46 | #include <QProgressDialog> | 46 | #include <QProgressDialog> | ||
47 | #include <QFileDialog> | 47 | #include <QFileDialog> | ||
48 | 48 | | |||
49 | KateDocManager::KateDocManager(QObject *parent) | 49 | KateDocManager::KateDocManager(QObject *parent) | ||
50 | : QObject(parent) | 50 | : QObject(parent) | ||
51 | , m_metaInfos(QStringLiteral("katemetainfos"), KConfig::NoGlobals) | 51 | , m_metaInfos(QStringLiteral("katemetainfos"), KConfig::NoGlobals) | ||
52 | , m_saveMetaInfos(true) | 52 | , m_saveMetaInfos(true) | ||
53 | , m_daysMetaInfos(0) | 53 | , m_daysMetaInfos(0) | ||
54 | , m_documentStillToRestore(0) | | |||
55 | { | 54 | { | ||
56 | // set our application wrapper | 55 | // set our application wrapper | ||
57 | KTextEditor::Editor::instance()->setApplication(KateApp::self()->wrapper()); | 56 | KTextEditor::Editor::instance()->setApplication(KateApp::self()->wrapper()); | ||
58 | 57 | | |||
59 | // create one doc, we always have at least one around! | 58 | // create one doc, we always have at least one around! | ||
60 | createDoc(); | 59 | createDoc(); | ||
61 | } | 60 | } | ||
62 | 61 | | |||
▲ Show 20 Lines • Show All 378 Lines • ▼ Show 20 Line(s) | 433 | { | |||
441 | 440 | | |||
442 | QProgressDialog progress; | 441 | QProgressDialog progress; | ||
443 | progress.setWindowTitle(i18n("Starting Up")); | 442 | progress.setWindowTitle(i18n("Starting Up")); | ||
444 | progress.setLabelText(i18n("Reopening files from the last session...")); | 443 | progress.setLabelText(i18n("Reopening files from the last session...")); | ||
445 | progress.setModal(true); | 444 | progress.setModal(true); | ||
446 | progress.setCancelButton(nullptr); | 445 | progress.setCancelButton(nullptr); | ||
447 | progress.setRange(0, count); | 446 | progress.setRange(0, count); | ||
448 | 447 | | |||
449 | m_documentStillToRestore = count; | | |||
450 | m_openingErrors.clear(); | | |||
451 | for (unsigned int i = 0; i < count; i++) { | 448 | for (unsigned int i = 0; i < count; i++) { | ||
452 | KConfigGroup cg(config, QStringLiteral("Document %1").arg(i)); | 449 | KConfigGroup cg(config, QStringLiteral("Document %1").arg(i)); | ||
453 | KTextEditor::Document *doc = nullptr; | 450 | KTextEditor::Document *doc = nullptr; | ||
454 | 451 | | |||
455 | if (i == 0) { | 452 | if (i == 0) { | ||
456 | doc = m_docList.first(); | 453 | doc = m_docList.first(); | ||
457 | } else { | 454 | } else { | ||
458 | doc = createDoc(); | 455 | doc = createDoc(); | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 575 | { | |||
579 | KColorScheme colors(QPalette::Active); | 576 | KColorScheme colors(QPalette::Active); | ||
580 | 577 | | |||
581 | KTextEditor::Document *doc = qobject_cast<KTextEditor::Document *>(sender()); | 578 | KTextEditor::Document *doc = qobject_cast<KTextEditor::Document *>(sender()); | ||
582 | if (!doc) { | 579 | if (!doc) { | ||
583 | return; // should never happen, but who knows | 580 | return; // should never happen, but who knows | ||
584 | } | 581 | } | ||
585 | disconnect(doc, SIGNAL(completed()), this, SLOT(documentOpened())); | 582 | disconnect(doc, SIGNAL(completed()), this, SLOT(documentOpened())); | ||
586 | disconnect(doc, &KParts::ReadOnlyPart::canceled, this, &KateDocManager::documentOpened); | 583 | disconnect(doc, &KParts::ReadOnlyPart::canceled, this, &KateDocManager::documentOpened); | ||
587 | if (doc->openingError()) { | 584 | | ||
588 | m_openingErrors += QLatin1Char('\n') + doc->openingErrorMessage() + QStringLiteral("\n\n"); | 585 | // Only set "no success" when doc is empty to avoid close of files | ||
586 | // with other trouble when do closeOrphaned() | ||||
587 | if (doc->openingError() && doc->isEmpty()) { | ||||
589 | KateDocumentInfo *info = documentInfo(doc); | 588 | KateDocumentInfo *info = documentInfo(doc); | ||
590 | if (info) { | 589 | if (info) { | ||
591 | info->openSuccess = false; | 590 | info->openSuccess = false; | ||
592 | } | 591 | } | ||
593 | } | 592 | } | ||
594 | --m_documentStillToRestore; | | |||
595 | | ||||
596 | if (m_documentStillToRestore == 0) { | | |||
597 | QTimer::singleShot(0, this, &KateDocManager::showRestoreErrors); | | |||
598 | } | | |||
599 | } | 593 | } | ||
600 | | ||||
601 | void KateDocManager::showRestoreErrors() | | |||
602 | { | | |||
603 | if (!m_openingErrors.isEmpty()) { | | |||
604 | KMessageBox::information(nullptr, | | |||
605 | m_openingErrors, | | |||
606 | i18n("Errors/Warnings while opening documents")); | | |||
607 | | ||||
608 | // clear errors | | |||
609 | m_openingErrors.clear(); | | |||
610 | } | | |||
611 | } | | |||
612 | |