Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/KisDocument.cpp
Show First 20 Lines • Show All 1179 Lines • ▼ Show 20 Line(s) | 1139 | { | |||
---|---|---|---|---|---|
1180 | bool ret = openUrlInternal(url); | 1180 | bool ret = openUrlInternal(url); | ||
1181 | 1181 | | |||
1182 | if (autosaveOpened || flags & RecoveryFile) { | 1182 | if (autosaveOpened || flags & RecoveryFile) { | ||
1183 | setReadWrite(true); // enable save button | 1183 | setReadWrite(true); // enable save button | ||
1184 | setModified(true); | 1184 | setModified(true); | ||
1185 | setRecovered(true); | 1185 | setRecovered(true); | ||
1186 | } | 1186 | } | ||
1187 | else { | 1187 | else { | ||
1188 | if (!(flags & DontAddToRecent)) { | 1188 | if (ret) { | ||
1189 | | ||||
1190 | if ((flags & DontAddToRecent)) { | ||||
1189 | KisPart::instance()->addRecentURLToAllMainWindows(_url); | 1191 | KisPart::instance()->addRecentURLToAllMainWindows(_url); | ||
1190 | } | 1192 | } | ||
1191 | 1193 | | |||
1192 | if (ret) { | | |||
1193 | // Detect readonly local-files; remote files are assumed to be writable | 1194 | // Detect readonly local-files; remote files are assumed to be writable | ||
1194 | QFileInfo fi(url.toLocalFile()); | 1195 | QFileInfo fi(url.toLocalFile()); | ||
1195 | setReadWrite(fi.isWritable()); | 1196 | setReadWrite(fi.isWritable()); | ||
1196 | } | 1197 | } | ||
1197 | 1198 | | |||
1198 | setRecovered(false); | 1199 | setRecovered(false); | ||
1199 | } | 1200 | } | ||
1200 | 1201 | | |||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 1266 | if (!typeName.isEmpty()) { | |||
1266 | break; | 1267 | break; | ||
1267 | } | 1268 | } | ||
1268 | } | 1269 | } | ||
1269 | //qDebug() << "chopped" << filename << "to" << path << "Was trash, is" << typeName; | 1270 | //qDebug() << "chopped" << filename << "to" << path << "Was trash, is" << typeName; | ||
1270 | } | 1271 | } | ||
1271 | dbgUI << localFilePath() << "type:" << typeName; | 1272 | dbgUI << localFilePath() << "type:" << typeName; | ||
1272 | 1273 | | |||
1273 | KisMainWindow *window = KisPart::instance()->currentMainwindow(); | 1274 | KisMainWindow *window = KisPart::instance()->currentMainwindow(); | ||
1275 | KoUpdaterPtr updater; | ||||
1274 | if (window && window->viewManager()) { | 1276 | if (window && window->viewManager()) { | ||
1275 | KoUpdaterPtr updater = window->viewManager()->createUnthreadedUpdater(i18n("Opening document")); | 1277 | updater = window->viewManager()->createUnthreadedUpdater(i18n("Opening document")); | ||
1276 | d->importExportManager->setUpdater(updater); | 1278 | d->importExportManager->setUpdater(updater); | ||
1277 | } | 1279 | } | ||
1278 | 1280 | | |||
1279 | KisImportExportFilter::ConversionStatus status; | 1281 | KisImportExportFilter::ConversionStatus status; | ||
1280 | 1282 | | |||
1281 | status = d->importExportManager->importDocument(localFilePath(), typeName); | 1283 | status = d->importExportManager->importDocument(localFilePath(), typeName); | ||
1282 | 1284 | | |||
1283 | if (status != KisImportExportFilter::OK) { | 1285 | if (status != KisImportExportFilter::OK) { | ||
1286 | if (window && window->viewManager()) { | ||||
1287 | updater->cancel(); | ||||
1288 | } | ||||
1284 | QString msg = KisImportExportFilter::conversionStatusString(status); | 1289 | QString msg = KisImportExportFilter::conversionStatusString(status); | ||
1285 | if (!msg.isEmpty()) { | 1290 | if (!msg.isEmpty()) { | ||
1286 | DlgLoadMessages dlg(i18nc("@title:window", "Krita"), | 1291 | DlgLoadMessages dlg(i18nc("@title:window", "Krita"), | ||
1287 | i18n("Could not open %2.\nReason: %1.", msg, prettyPathOrUrl()), | 1292 | i18n("Could not open %2.\nReason: %1.", msg, prettyPathOrUrl()), | ||
1288 | errorMessage().split("\n") + warningMessage().split("\n")); | 1293 | errorMessage().split("\n") + warningMessage().split("\n")); | ||
1289 | dlg.exec(); | 1294 | dlg.exec(); | ||
1290 | } | 1295 | } | ||
1291 | return false; | 1296 | return false; | ||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Line(s) | |||||
1663 | 1668 | | |||
1664 | void KisDocument::setLocalFilePath( const QString &localFilePath ) | 1669 | void KisDocument::setLocalFilePath( const QString &localFilePath ) | ||
1665 | { | 1670 | { | ||
1666 | d->m_file = localFilePath; | 1671 | d->m_file = localFilePath; | ||
1667 | } | 1672 | } | ||
1668 | 1673 | | |||
1669 | bool KisDocument::openUrlInternal(const QUrl &url) | 1674 | bool KisDocument::openUrlInternal(const QUrl &url) | ||
1670 | { | 1675 | { | ||
1671 | if ( !url.isValid() ) | 1676 | if ( !url.isValid() ) { | ||
1672 | return false; | 1677 | return false; | ||
1678 | } | ||||
1673 | 1679 | | |||
1674 | if (d->m_bAutoDetectedMime) { | 1680 | if (d->m_bAutoDetectedMime) { | ||
1675 | d->mimeType = QByteArray(); | 1681 | d->mimeType = QByteArray(); | ||
1676 | d->m_bAutoDetectedMime = false; | 1682 | d->m_bAutoDetectedMime = false; | ||
1677 | } | 1683 | } | ||
1678 | 1684 | | |||
1679 | QByteArray mimetype = d->mimeType; | 1685 | QByteArray mimetype = d->mimeType; | ||
1680 | 1686 | | |||
1681 | if ( !closeUrl() ) | 1687 | if ( !closeUrl() ) { | ||
1682 | return false; | 1688 | return false; | ||
1689 | } | ||||
1683 | 1690 | | |||
1684 | d->mimeType = mimetype; | 1691 | d->mimeType = mimetype; | ||
1685 | setUrl(url); | 1692 | setUrl(url); | ||
1686 | 1693 | | |||
1687 | d->m_file.clear(); | 1694 | d->m_file.clear(); | ||
1688 | 1695 | | |||
1689 | if (d->m_url.isLocalFile()) { | 1696 | if (d->m_url.isLocalFile()) { | ||
1690 | d->m_file = d->m_url.toLocalFile(); | 1697 | d->m_file = d->m_url.toLocalFile(); | ||
▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines |