Changeset View
Changeset View
Standalone View
Standalone View
part.cpp
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | 194 | { | |||
---|---|---|---|---|---|
199 | static bool supportBzip = false; | 199 | static bool supportBzip = false; | ||
200 | static bool supportXz = false; | 200 | static bool supportXz = false; | ||
201 | const QString app_gzip( QStringLiteral( "application/x-gzip" ) ); | 201 | const QString app_gzip( QStringLiteral( "application/x-gzip" ) ); | ||
202 | const QString app_bzip( QStringLiteral( "application/x-bzip" ) ); | 202 | const QString app_bzip( QStringLiteral( "application/x-bzip" ) ); | ||
203 | const QString app_xz( QStringLiteral( "application/x-xz" ) ); | 203 | const QString app_xz( QStringLiteral( "application/x-xz" ) ); | ||
204 | if ( compressedMimeMap.isEmpty() ) | 204 | if ( compressedMimeMap.isEmpty() ) | ||
205 | { | 205 | { | ||
206 | std::unique_ptr< KFilterBase > f; | 206 | std::unique_ptr< KFilterBase > f; | ||
207 | compressedMimeMap[ QLatin1String( "image/x-gzeps" ) ] = KFilterDev::GZip; | 207 | compressedMimeMap[ QStringLiteral( "image/x-gzeps" ) ] = KFilterDev::GZip; | ||
208 | // check we can read bzip2-compressed files | 208 | // check we can read bzip2-compressed files | ||
209 | f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::BZip2 ) ); | 209 | f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::BZip2 ) ); | ||
210 | if ( f.get() ) | 210 | if ( f.get() ) | ||
211 | { | 211 | { | ||
212 | supportBzip = true; | 212 | supportBzip = true; | ||
213 | compressedMimeMap[ QLatin1String( "application/x-bzpdf" ) ] = KFilterDev::BZip2; | 213 | compressedMimeMap[ QStringLiteral( "application/x-bzpdf" ) ] = KFilterDev::BZip2; | ||
214 | compressedMimeMap[ QLatin1String( "application/x-bzpostscript" ) ] = KFilterDev::BZip2; | 214 | compressedMimeMap[ QStringLiteral( "application/x-bzpostscript" ) ] = KFilterDev::BZip2; | ||
215 | compressedMimeMap[ QLatin1String( "application/x-bzdvi" ) ] = KFilterDev::BZip2; | 215 | compressedMimeMap[ QStringLiteral( "application/x-bzdvi" ) ] = KFilterDev::BZip2; | ||
216 | compressedMimeMap[ QLatin1String( "image/x-bzeps" ) ] = KFilterDev::BZip2; | 216 | compressedMimeMap[ QStringLiteral( "image/x-bzeps" ) ] = KFilterDev::BZip2; | ||
217 | } | 217 | } | ||
218 | // check if we can read XZ-compressed files | 218 | // check if we can read XZ-compressed files | ||
219 | f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::Xz ) ); | 219 | f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::Xz ) ); | ||
220 | if ( f.get() ) | 220 | if ( f.get() ) | ||
221 | { | 221 | { | ||
222 | supportXz = true; | 222 | supportXz = true; | ||
223 | } | 223 | } | ||
224 | } | 224 | } | ||
▲ Show 20 Lines • Show All 1336 Lines • ▼ Show 20 Line(s) | 1513 | { | |||
1561 | emit mimeTypeChanged( mime ); | 1561 | emit mimeTypeChanged( mime ); | ||
1562 | 1562 | | |||
1563 | // update one-time actions | 1563 | // update one-time actions | ||
1564 | const bool ok = openResult == Document::OpenSuccess; | 1564 | const bool ok = openResult == Document::OpenSuccess; | ||
1565 | emit enableCloseAction( ok ); | 1565 | emit enableCloseAction( ok ); | ||
1566 | m_find->setEnabled( ok && canSearch ); | 1566 | m_find->setEnabled( ok && canSearch ); | ||
1567 | m_findNext->setEnabled( ok && canSearch ); | 1567 | m_findNext->setEnabled( ok && canSearch ); | ||
1568 | m_findPrev->setEnabled( ok && canSearch ); | 1568 | m_findPrev->setEnabled( ok && canSearch ); | ||
1569 | if( m_save ) m_save->setEnabled( ok && !( isstdin || mime.inherits( "inode/directory" ) ) ); | 1569 | if( m_save ) m_save->setEnabled( ok && !( isstdin || mime.inherits( QStringLiteral("inode/directory") ) ) ); | ||
1570 | if( m_saveAs ) m_saveAs->setEnabled( ok && !( isstdin || mime.inherits( "inode/directory" ) ) ); | 1570 | if( m_saveAs ) m_saveAs->setEnabled( ok && !( isstdin || mime.inherits( QStringLiteral("inode/directory") ) ) ); | ||
1571 | emit enablePrintAction( ok && m_document->printingSupport() != Okular::Document::NoPrinting ); | 1571 | emit enablePrintAction( ok && m_document->printingSupport() != Okular::Document::NoPrinting ); | ||
1572 | m_printPreview->setEnabled( ok && m_document->printingSupport() != Okular::Document::NoPrinting ); | 1572 | m_printPreview->setEnabled( ok && m_document->printingSupport() != Okular::Document::NoPrinting ); | ||
1573 | m_showProperties->setEnabled( ok ); | 1573 | m_showProperties->setEnabled( ok ); | ||
1574 | bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0; | 1574 | bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0; | ||
1575 | if ( m_showEmbeddedFiles ) m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles ); | 1575 | if ( m_showEmbeddedFiles ) m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles ); | ||
1576 | m_topMessage->setVisible( hasEmbeddedFiles && Okular::Settings::showOSD() ); | 1576 | m_topMessage->setVisible( hasEmbeddedFiles && Okular::Settings::showOSD() ); | ||
1577 | m_migrationMessage->setVisible( m_document->isDocdataMigrationNeeded() ); | 1577 | m_migrationMessage->setVisible( m_document->isDocdataMigrationNeeded() ); | ||
1578 | 1578 | | |||
▲ Show 20 Lines • Show All 855 Lines • ▼ Show 20 Line(s) | |||||
2434 | 2434 | | |||
2435 | bool Part::aboutToShowContextMenu(QMenu * /*menu*/, QAction *action, QMenu *contextMenu) | 2435 | bool Part::aboutToShowContextMenu(QMenu * /*menu*/, QAction *action, QMenu *contextMenu) | ||
2436 | { | 2436 | { | ||
2437 | KBookmarkAction *ba = dynamic_cast<KBookmarkAction*>(action); | 2437 | KBookmarkAction *ba = dynamic_cast<KBookmarkAction*>(action); | ||
2438 | if (ba != nullptr) | 2438 | if (ba != nullptr) | ||
2439 | { | 2439 | { | ||
2440 | QAction *separatorAction = contextMenu->addSeparator(); | 2440 | QAction *separatorAction = contextMenu->addSeparator(); | ||
2441 | separatorAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | 2441 | separatorAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | ||
2442 | QAction *renameAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("edit-rename") ), i18n( "Rename this Bookmark" ), this, SLOT(slotRenameBookmarkFromMenu()) ); | 2442 | QAction *renameAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("edit-rename") ), i18n( "Rename this Bookmark" ), this, &Part::slotRenameBookmarkFromMenu ); | ||
2443 | renameAction->setData(ba->property("htmlRef").toString()); | 2443 | renameAction->setData(ba->property("htmlRef").toString()); | ||
2444 | renameAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | 2444 | renameAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | ||
2445 | QAction *deleteAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("list-remove") ), i18n("Remove this Bookmark"), this, SLOT(slotRemoveBookmarkFromMenu())); | 2445 | QAction *deleteAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("list-remove") ), i18n("Remove this Bookmark"), this, &Part::slotRemoveBookmarkFromMenu); | ||
2446 | deleteAction->setData(ba->property("htmlRef").toString()); | 2446 | deleteAction->setData(ba->property("htmlRef").toString()); | ||
2447 | deleteAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | 2447 | deleteAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | ||
2448 | } | 2448 | } | ||
2449 | return ba; | 2449 | return ba; | ||
2450 | } | 2450 | } | ||
2451 | 2451 | | |||
2452 | void Part::slotPreviousBookmark() | 2452 | void Part::slotPreviousBookmark() | ||
2453 | { | 2453 | { | ||
▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Line(s) | 2653 | { | |||
2662 | { | 2662 | { | ||
2663 | if ( saveUrl == url() ) | 2663 | if ( saveUrl == url() ) | ||
2664 | { | 2664 | { | ||
2665 | // Save | 2665 | // Save | ||
2666 | const QString warningMessage = i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the <i>Okular document archive</i> format to preserve them." ); | 2666 | const QString warningMessage = i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the <i>Okular document archive</i> format to preserve them." ); | ||
2667 | const int result = KMessageBox::warningYesNoList( widget(), | 2667 | const int result = KMessageBox::warningYesNoList( widget(), | ||
2668 | warningMessage, | 2668 | warningMessage, | ||
2669 | listOfwontSaves, i18n( "Warning" ), | 2669 | listOfwontSaves, i18n( "Warning" ), | ||
2670 | KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes | 2670 | KGuiItem( i18n( "Save as Okular document archive..." ), QStringLiteral("document-save-as") ), // <- KMessageBox::Yes | ||
2671 | KStandardGuiItem::cancel() ); | 2671 | KStandardGuiItem::cancel() ); | ||
2672 | 2672 | | |||
2673 | switch (result) | 2673 | switch (result) | ||
2674 | { | 2674 | { | ||
2675 | case KMessageBox::Yes: // -> Save as Okular document archive | 2675 | case KMessageBox::Yes: // -> Save as Okular document archive | ||
2676 | return slotSaveFileAs( true /* showOkularArchiveAsDefaultFormat */ ); | 2676 | return slotSaveFileAs( true /* showOkularArchiveAsDefaultFormat */ ); | ||
2677 | default: | 2677 | default: | ||
2678 | return false; | 2678 | return false; | ||
2679 | } | 2679 | } | ||
2680 | } | 2680 | } | ||
2681 | else | 2681 | else | ||
2682 | { | 2682 | { | ||
2683 | // Save as | 2683 | // Save as | ||
2684 | const QString warningMessage = m_document->canSwapBackingFile() ? | 2684 | const QString warningMessage = m_document->canSwapBackingFile() ? | ||
2685 | i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the <i>Okular document archive</i> format to preserve them. Click <i>Continue</i> to save the document and discard these elements." ) : | 2685 | i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the <i>Okular document archive</i> format to preserve them. Click <i>Continue</i> to save the document and discard these elements." ) : | ||
2686 | i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the <i>Okular document archive</i> format to preserve them. Click <i>Continue</i> to save, but you will lose these elements as well as the undo/redo history." ); | 2686 | i18n( "You are about to save changes, but the current file format does not support saving the following elements. Please use the <i>Okular document archive</i> format to preserve them. Click <i>Continue</i> to save, but you will lose these elements as well as the undo/redo history." ); | ||
2687 | const QString continueMessage = m_document->canSwapBackingFile() ? | 2687 | const QString continueMessage = m_document->canSwapBackingFile() ? | ||
2688 | i18n( "Continue" ) : | 2688 | i18n( "Continue" ) : | ||
2689 | i18n( "Continue losing changes" ); | 2689 | i18n( "Continue losing changes" ); | ||
2690 | const int result = KMessageBox::warningYesNoCancelList( widget(), | 2690 | const int result = KMessageBox::warningYesNoCancelList( widget(), | ||
2691 | warningMessage, | 2691 | warningMessage, | ||
2692 | listOfwontSaves, i18n( "Warning" ), | 2692 | listOfwontSaves, i18n( "Warning" ), | ||
2693 | KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes | 2693 | KGuiItem( i18n( "Save as Okular document archive..." ), QStringLiteral("document-save-as") ), // <- KMessageBox::Yes | ||
2694 | KGuiItem( continueMessage, "arrow-right" ) ); // <- KMessageBox::NO | 2694 | KGuiItem( continueMessage, QStringLiteral("arrow-right") ) ); // <- KMessageBox::NO | ||
2695 | 2695 | | |||
2696 | switch (result) | 2696 | switch (result) | ||
2697 | { | 2697 | { | ||
2698 | case KMessageBox::Yes: // -> Save as Okular document archive | 2698 | case KMessageBox::Yes: // -> Save as Okular document archive | ||
2699 | return slotSaveFileAs( true /* showOkularArchiveAsDefaultFormat */ ); | 2699 | return slotSaveFileAs( true /* showOkularArchiveAsDefaultFormat */ ); | ||
2700 | case KMessageBox::No: // -> Continue | 2700 | case KMessageBox::No: // -> Continue | ||
2701 | setModifiedAfterSave = m_document->canSwapBackingFile(); | 2701 | setModifiedAfterSave = m_document->canSwapBackingFile(); | ||
2702 | break; | 2702 | break; | ||
▲ Show 20 Lines • Show All 967 Lines • ▼ Show 20 Line(s) | |||||
3670 | 3670 | | |||
3671 | #if PURPOSE_FOUND | 3671 | #if PURPOSE_FOUND | ||
3672 | void Part::slotShareActionFinished(const QJsonObject &output, int error, const QString &message) | 3672 | void Part::slotShareActionFinished(const QJsonObject &output, int error, const QString &message) | ||
3673 | { | 3673 | { | ||
3674 | if (error) { | 3674 | if (error) { | ||
3675 | KMessageBox::error(widget(), i18n("There was a problem sharing the document: %1", message), | 3675 | KMessageBox::error(widget(), i18n("There was a problem sharing the document: %1", message), | ||
3676 | i18n("Share")); | 3676 | i18n("Share")); | ||
3677 | } else { | 3677 | } else { | ||
3678 | const QString url = output["url"].toString(); | 3678 | const QString url = output[QStringLiteral("url")].toString(); | ||
3679 | if (url.isEmpty()) { | 3679 | if (url.isEmpty()) { | ||
3680 | m_pageView->displayMessage(i18n("Document shared successfully")); | 3680 | m_pageView->displayMessage(i18n("Document shared successfully")); | ||
3681 | } else { | 3681 | } else { | ||
3682 | KMessageBox::information(widget(), i18n("You can find the shared document at: <a href=\"%1\">%1</a>", url), | 3682 | KMessageBox::information(widget(), i18n("You can find the shared document at: <a href=\"%1\">%1</a>", url), | ||
3683 | i18n("Share"), QString(), | 3683 | i18n("Share"), QString(), | ||
3684 | KMessageBox::Notify | KMessageBox::AllowLink); | 3684 | KMessageBox::Notify | KMessageBox::AllowLink); | ||
3685 | } | 3685 | } | ||
3686 | } | 3686 | } | ||
Show All 19 Lines |