diff --git a/autotests/documenttest.cpp b/autotests/documenttest.cpp --- a/autotests/documenttest.cpp +++ b/autotests/documenttest.cpp @@ -73,7 +73,7 @@ // the document without migrating and that it does get wiped out after migrating void DocumentTest::testDocdataMigration() { - Okular::SettingsCore::instance( "documenttest" ); + Okular::SettingsCore::instance( QStringLiteral("documenttest") ); const QUrl testFileUrl = QUrl::fromLocalFile(KDESRCDIR "data/file1.pdf"); const QString testFilePath = testFileUrl.toLocalFile(); @@ -106,7 +106,7 @@ QCOMPARE( m_document->isDocdataMigrationNeeded(), true ); // Do the migration - QTemporaryFile migratedSaveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile migratedSaveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); QVERIFY( migratedSaveFile.open() ); migratedSaveFile.close(); QVERIFY( m_document->saveChanges( migratedSaveFile.fileName() ) ); diff --git a/autotests/mainshelltest.cpp b/autotests/mainshelltest.cpp --- a/autotests/mainshelltest.cpp +++ b/autotests/mainshelltest.cpp @@ -203,7 +203,7 @@ QTest::newRow("two files sequence with tabs") << file1 << QString() << true << tocReload << 0u << false << false << false << 0u << false << false << QString(); QTest::newRow("open file page number") << contentsEpub << optionsPage2 << false << QString() << 1u << false << false << false << 0u << false << false << QString(); QTest::newRow("open file page number and presentation") << contentsEpub << optionsPage2Presentation << false << QString() << 1u << true << false << false << 0u << false << false << QString(); - QTest::newRow("open file find") << file1 << optionsFind << false << QString() << 0u << false << false << false << 0u << false << false << QString("si:next-testing parameters!"); + QTest::newRow("open file find") << file1 << optionsFind << false << QString() << 0u << false << false << false << 0u << false << false << QStringLiteral("si:next-testing parameters!"); QTest::newRow("open file print") << file1 << optionsPrint << false << QString() << 0u << false << true << false << 0u << false << false << QString(); QTest::newRow("open two files unique") << file1 << optionsUnique << false << tocReload << 0u << false << false << true << 0u << false << false << QString(); QTest::newRow("open two files unique tabs") << file1 << optionsUnique << true << tocReload << 0u << false << false << true << 0u << false << false << QString(); diff --git a/autotests/parttest.cpp b/autotests/parttest.cpp --- a/autotests/parttest.cpp +++ b/autotests/parttest.cpp @@ -215,7 +215,7 @@ QProcess process; process.setWorkingDirectory(workDir.path()); - const QString pdflatexPath(QStandardPaths::findExecutable("pdflatex")); + const QString pdflatexPath(QStandardPaths::findExecutable(QStringLiteral("pdflatex"))); if (pdflatexPath.isEmpty()) { QFAIL("pdflatex executable not found, but needed for the test. Try installing the respective TeXLive packages."); } @@ -254,8 +254,8 @@ { QTest::addColumn("dir"); - QTest::newRow("non-utf8") << QString::fromUtf8("synctextest"); - QTest::newRow("utf8") << QString::fromUtf8("ßðđđŋßðđŋ"); + QTest::newRow("non-utf8") << QStringLiteral("synctextest"); + QTest::newRow("utf8") << QStringLiteral("ßðđđŋßðđŋ"); } void PartTest::testGeneratorPreferences() @@ -390,8 +390,8 @@ QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect")); // overwrite urlHandler for 'mailto' urls - QDesktopServices::setUrlHandler("mailto", this, "urlHandler"); - QSignalSpy openUrlSignalSpy(this, SIGNAL(urlHandler(QUrl))); + QDesktopServices::setUrlHandler(QStringLiteral("mailto"), this, "urlHandler"); + QSignalSpy openUrlSignalSpy(this, &PartTest::urlHandler); // click on url QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.250, height * 0.127)); @@ -488,8 +488,8 @@ simulateMouseSelection(mouseStartX, mouseY, mouseEndX, mouseY, part.m_pageView->viewport()); // overwrite urlHandler for 'mailto' urls - QDesktopServices::setUrlHandler("mailto", this, "urlHandler"); - QSignalSpy openUrlSignalSpy(this, SIGNAL(urlHandler(QUrl))); + QDesktopServices::setUrlHandler(QStringLiteral("mailto"), this, "urlHandler"); + QSignalSpy openUrlSignalSpy(this, &PartTest::urlHandler); // click on url const double mouseClickX = width * 0.2997; @@ -540,20 +540,20 @@ bool menuClosed = false; QTimer::singleShot(2000, [view, &menuClosed]() { // check if popup menu is active and visible - QMenu *menu = qobject_cast(view->findChild("PopupMenu")); + QMenu *menu = qobject_cast(view->findChild(QStringLiteral("PopupMenu"))); QVERIFY(menu); QVERIFY(menu->isVisible()); // check if the menu contains go-to link action - QAction *goToAction = qobject_cast(menu->findChild("GoToAction")); + QAction *goToAction = qobject_cast(menu->findChild(QStringLiteral("GoToAction"))); QVERIFY(goToAction); // check if the "follow this link" action is not visible - QAction *processLinkAction = qobject_cast(menu->findChild("ProcessLinkAction")); + QAction *processLinkAction = qobject_cast(menu->findChild(QStringLiteral("ProcessLinkAction"))); QVERIFY(!processLinkAction); // check if the "copy link address" action is not visible - QAction *copyLinkLocation = qobject_cast(menu->findChild("CopyLinkLocationAction")); + QAction *copyLinkLocation = qobject_cast(menu->findChild(QStringLiteral("CopyLinkLocationAction"))); QVERIFY(!copyLinkLocation); // close menu to continue test @@ -609,16 +609,16 @@ bool menuClosed = false; QTimer::singleShot(2000, [view, &menuClosed]() { // check if popup menu is active and visible - QMenu *menu = qobject_cast(view->findChild("PopupMenu")); + QMenu *menu = qobject_cast(view->findChild(QStringLiteral("PopupMenu"))); QVERIFY(menu); QVERIFY(menu->isVisible()); // check if the menu contains "follow this link" action - QAction *processLinkAction = qobject_cast(menu->findChild("ProcessLinkAction")); + QAction *processLinkAction = qobject_cast(menu->findChild(QStringLiteral("ProcessLinkAction"))); QVERIFY(processLinkAction); // check if the menu contains "copy link address" action - QAction *copyLinkLocation = qobject_cast(menu->findChild("CopyLinkLocationAction")); + QAction *copyLinkLocation = qobject_cast(menu->findChild(QStringLiteral("CopyLinkLocationAction"))); QVERIFY(copyLinkLocation); // close menu to continue test @@ -666,16 +666,16 @@ bool menuClosed = false; QTimer::singleShot(2000, [view, &menuClosed]() { // check if popup menu is active and visible - QMenu *menu = qobject_cast(view->findChild("PopupMenu")); + QMenu *menu = qobject_cast(view->findChild(QStringLiteral("PopupMenu"))); QVERIFY(menu); QVERIFY(menu->isVisible()); // check if the menu contains "Follow this link" action - QAction *processLink = qobject_cast(menu->findChild("ProcessLinkAction")); + QAction *processLink = qobject_cast(menu->findChild(QStringLiteral("ProcessLinkAction"))); QVERIFY(processLink); // chek if the menu contains "Copy Link Address" action - QAction *actCopyLinkLocation = qobject_cast(menu->findChild("CopyLinkLocationAction")); + QAction *actCopyLinkLocation = qobject_cast(menu->findChild(QStringLiteral("CopyLinkLocationAction"))); QVERIFY(actCopyLinkLocation); // close menu to continue test @@ -772,12 +772,12 @@ QApplication::clipboard()->clear(); // check if popup menu is active and visible - QMenu *menu = qobject_cast(view->findChild("PopupMenu")); + QMenu *menu = qobject_cast(view->findChild(QStringLiteral("PopupMenu"))); QVERIFY(menu); QVERIFY(menu->isVisible()); // check if the copy selected text to clipboard is present - QAction *copyAct = qobject_cast(menu->findChild("CopyTextToClipboard")); + QAction *copyAct = qobject_cast(menu->findChild(QStringLiteral("CopyTextToClipboard"))); QVERIFY(copyAct); menu->close(); @@ -820,7 +820,7 @@ QString saveFilePath; { - QTemporaryFile saveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); saveFile.open(); saveFilePath = saveFile.fileName(); // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares @@ -839,12 +839,12 @@ Okular::Part part(nullptr, nullptr, QVariantList()); part.openDocument( KDESRCDIR "data/file1.pdf" ); - QTemporaryFile newFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile newFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); newFile.open(); QString linkFilePath; { - QTemporaryFile linkFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile linkFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); linkFile.open(); linkFilePath = linkFile.fileName(); // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares @@ -869,7 +869,7 @@ QString newFilePath; { - QTemporaryFile newFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile newFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); newFile.open(); newFilePath = newFile.fileName(); // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares @@ -879,7 +879,7 @@ QString linkFilePath; { - QTemporaryFile linkFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile linkFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); linkFile.open(); linkFilePath = linkFile.fileName(); // QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares @@ -909,9 +909,9 @@ QScopedPointer closeDialogHelper; QString annotName; - QTemporaryFile archiveSave( QString( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) ); - QTemporaryFile nativeDirectSave( QString( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); - QTemporaryFile nativeFromArchiveFile( QString( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); + QTemporaryFile archiveSave( QStringLiteral( "%1/okrXXXXXX.okular" ).arg( QDir::tempPath() ) ); + QTemporaryFile nativeDirectSave( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); + QTemporaryFile nativeFromArchiveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QVERIFY( archiveSave.open() ); archiveSave.close(); QVERIFY( nativeDirectSave.open() ); @@ -929,7 +929,7 @@ Okular::Annotation *annot = new Okular::TextAnnotation(); annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); - annot->setContents( "annot contents" ); + annot->setContents( QStringLiteral("annot contents") ); part.m_document->addPageAnnotation( 0, annot ); annotName = annot->uniqueName(); @@ -1064,10 +1064,10 @@ // when saving to a file format not supporting those. However, this button is only sensible // and available for "Save As", but not for "Save". By alternately saving to saveFile1 and // saveFile2 we always force "Save As", so closeDialogHelper keeps working. - QTemporaryFile saveFile1( QString( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); + QTemporaryFile saveFile1( QStringLiteral( "%1/okrXXXXXX_1.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QVERIFY( saveFile1.open() ); saveFile1.close(); - QTemporaryFile saveFile2( QString( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); + QTemporaryFile saveFile2( QStringLiteral( "%1/okrXXXXXX_2.%2" ).arg( QDir::tempPath() ).arg ( extension ) ); QVERIFY( saveFile2.open() ); saveFile2.close(); @@ -1078,7 +1078,7 @@ Okular::Annotation *annot = new Okular::TextAnnotation(); annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); - annot->setContents( "annot contents" ); + annot->setContents( QStringLiteral("annot contents") ); part.m_document->addPageAnnotation( 0, annot ); QString annotName = annot->uniqueName(); @@ -1250,7 +1250,7 @@ const Part::SaveAsFlag saveFlags = saveToArchive ? Part::SaveAsOkularArchive : Part::NoSaveAsFlags; - QTemporaryFile saveFile( QString( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) ); + QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.%2" ).arg( QDir::tempPath(), extension ) ); QVERIFY( saveFile.open() ); saveFile.close(); @@ -1263,7 +1263,7 @@ { QCOMPARE( ff->type(), FormField::FormText ); FormFieldText *fft = static_cast( ff ); - part.m_document->editFormText( 0, fft, "BlaBla", 6, 0, 0 ); + part.m_document->editFormText( 0, fft, QStringLiteral("BlaBla"), 6, 0, 0 ); } else if ( ff->id() == 65538 ) { @@ -1284,7 +1284,7 @@ QCOMPARE( ff->type(), FormField::FormChoice ); FormFieldChoice *ffc = static_cast( ff ); QCOMPARE( ffc->choiceType(), FormFieldChoice::ComboBox ); - part.m_document->editFormCombo( 0, ffc, "combo2", 3, 0, 0); + part.m_document->editFormCombo( 0, ffc, QStringLiteral("combo2"), 3, 0, 0); } } @@ -1484,7 +1484,7 @@ btnStates << true << true; part.m_document->editFormButtons( 0, btns, btnStates ); - QTemporaryFile saveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); QVERIFY( saveFile.open() ); saveFile.close(); @@ -1525,7 +1525,7 @@ part.widget()->show(); QVERIFY(QTest::qWaitForWindowExposed(part.widget())); - part.widget()->findChild()->setText("HOLA"); + part.widget()->findChild()->setText(QStringLiteral("HOLA")); part.actionCollection()->action(QStringLiteral("view_toggle_forms"))->trigger(); } @@ -1574,16 +1574,16 @@ QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot1pt.x, height * annot1pt.y)); QTRY_COMPARE( part.m_pageView->findChildren("AnnotWindow").size(), 1 ); // Verify that the window is visible - QFrame* win1 = part.m_pageView->findChild("AnnotWindow"); + QFrame* win1 = part.m_pageView->findChild(QStringLiteral("AnnotWindow")); QVERIFY( !win1->visibleRegion().isEmpty() ); // Double click the second annotation to open its window (move mouse for visual feedback) const NormalizedPoint annot2pt = annot2->boundingRectangle().center(); QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * annot2pt.x, height * annot2pt.y)); QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot2pt.x, height * annot2pt.y)); QTRY_COMPARE( part.m_pageView->findChildren("AnnotWindow").size(), 2 ); // Verify that the first window is hidden covered by the second, which is visible - QList lstWin = part.m_pageView->findChildren("AnnotWindow"); + QList lstWin = part.m_pageView->findChildren(QStringLiteral("AnnotWindow")); QFrame * win2; if (lstWin[0] == win1) { win2 = lstWin[1]; @@ -1808,8 +1808,8 @@ qunsetenv("QT_MESSAGE_PATTERN"); QApplication app( argc, argv ); - app.setApplicationName(QLatin1String("okularparttest")); - app.setOrganizationDomain(QLatin1String("kde.org")); + app.setApplicationName(QStringLiteral("okularparttest")); + app.setOrganizationDomain(QStringLiteral("kde.org")); app.setQuitOnLastWindowClosed(false); qRegisterMetaType(); /*as done by kapplication*/ diff --git a/autotests/searchtest.cpp b/autotests/searchtest.cpp --- a/autotests/searchtest.cpp +++ b/autotests/searchtest.cpp @@ -168,7 +168,7 @@ { Okular::Document d(nullptr); SearchFinishedReceiver receiver; - QSignalSpy spy(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus))); + QSignalSpy spy(&d, &Okular::Document::searchFinished); QObject::connect(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)), &receiver, SLOT(searchFinished(int,Okular::Document::SearchStatus))); @@ -243,14 +243,14 @@ //the Unicode case-folding rules http://www.unicode.org/Public/6.2.0/ucd/CaseFolding.txt). QVector text; - text << QString::fromUtf8("İ"); + text << QStringLiteral("İ"); QVector rect; rect << Okular::NormalizedRect(1, 2, 3, 4); CREATE_PAGE; - Okular::RegularAreaRect* result = tp->findText(0, QString::fromUtf8("İ"), Okular::FromTop, Qt::CaseInsensitive, nullptr); + Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("İ"), Okular::FromTop, Qt::CaseInsensitive, nullptr); QVERIFY(result); delete result; diff --git a/autotests/visibilitytest.cpp b/autotests/visibilitytest.cpp --- a/autotests/visibilitytest.cpp +++ b/autotests/visibilitytest.cpp @@ -122,7 +122,7 @@ verifyTargetStates( false ); // Save the changed states - QTemporaryFile saveFile( QString( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); + QTemporaryFile saveFile( QStringLiteral( "%1/okrXXXXXX.pdf" ).arg( QDir::tempPath() ) ); QVERIFY( saveFile.open() ); saveFile.close(); diff --git a/core/document.cpp b/core/document.cpp --- a/core/document.cpp +++ b/core/document.cpp @@ -1113,7 +1113,7 @@ void DocumentPrivate::recalculateForms() { - const QVariant fco = m_parent->metaData(QLatin1String("FormCalculateOrder")); + const QVariant fco = m_parent->metaData(QStringLiteral("FormCalculateOrder")); const QVector formCalculateOrder = fco.value>(); foreach(int formId, formCalculateOrder) { for ( uint pageIdx = 0; pageIdx < m_parent->pages(); pageIdx++ ) @@ -1196,7 +1196,7 @@ // -> do this if there are not-yet-migrated annots or forms in docdata/ if ( m_docdataMigrationNeeded ) { - QDomElement pageList = doc.createElement( "pageList" ); + QDomElement pageList = doc.createElement( QStringLiteral("pageList") ); root.appendChild( pageList ); // OriginalAnnotationPageItems and OriginalFormFieldPageItems tell to // store the same unmodified annotation list and form contents that we @@ -2281,7 +2281,7 @@ static QVector result; if (result.isEmpty()) { - result = KPluginLoader::findPlugins( QLatin1String ( "okular/generators" ) ); + result = KPluginLoader::findPlugins( QStringLiteral ( "okular/generators" ) ); } return result; } @@ -2365,7 +2365,7 @@ if (url.scheme() == QLatin1String("fd")) { bool ok; - fd = url.path().mid(1).toInt(&ok); + fd = url.path().midRef(1).toInt(&ok); if (!ok) { return OpenError; @@ -4230,7 +4230,7 @@ const QUrl url = browse->url(); // fix for #100366, documents with relative links that are the form of http:foo.pdf - if ((url.scheme() == "http") && url.host().isEmpty() && url.fileName().endsWith("pdf")) + if ((url.scheme() == QLatin1String("http")) && url.host().isEmpty() && url.fileName().endsWith(QLatin1String("pdf"))) { d->openRelativeFile(url.fileName()); break; diff --git a/core/documentcommands.cpp b/core/documentcommands.cpp --- a/core/documentcommands.cpp +++ b/core/documentcommands.cpp @@ -156,8 +156,8 @@ ModifyAnnotationPropertiesCommand::ModifyAnnotationPropertiesCommand( DocumentPrivate* docPriv, Annotation* annotation, int pageNumber, - QDomNode oldProperties, - QDomNode newProperties ) + const QDomNode &oldProperties, + const QDomNode &newProperties ) : m_docPriv( docPriv ), m_annotation( annotation ), m_pageNumber( pageNumber ), diff --git a/core/documentcommands_p.h b/core/documentcommands_p.h --- a/core/documentcommands_p.h +++ b/core/documentcommands_p.h @@ -76,8 +76,8 @@ public: ModifyAnnotationPropertiesCommand( Okular::DocumentPrivate* docPriv, Okular::Annotation* annotation, int pageNumber, - QDomNode oldProperties, - QDomNode newProperties ); + const QDomNode &oldProperties, + const QDomNode &newProperties ); void undo() override; void redo() override; diff --git a/core/fileprinter.cpp b/core/fileprinter.cpp --- a/core/fileprinter.cpp +++ b/core/fileprinter.cpp @@ -31,15 +31,15 @@ using namespace Okular; -int FilePrinter::printFile( QPrinter &printer, const QString file, +int FilePrinter::printFile(QPrinter &printer, const QString file, QPrinter::Orientation documentOrientation, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange ) { return printFile( printer, file, documentOrientation, fileDeletePolicy, pageSelectPolicy, pageRange, ScaleMode::FitToPrintArea ); } -int FilePrinter::printFile( QPrinter &printer, const QString file, +int FilePrinter::printFile(QPrinter &printer, const QString file, QPrinter::Orientation documentOrientation, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, ScaleMode scaleMode ) @@ -49,7 +49,7 @@ documentOrientation, scaleMode ); } -int FilePrinter::doPrintFiles( QPrinter &printer, QStringList fileList, FileDeletePolicy fileDeletePolicy, +int FilePrinter::doPrintFiles(QPrinter &printer, const QStringList fileList, FileDeletePolicy fileDeletePolicy, PageSelectPolicy pageSelectPolicy, const QString &pageRange, QPrinter::Orientation documentOrientation ) { @@ -113,8 +113,8 @@ argList << fileList[0] << printer.outputFileName(); qCDebug(OkularCoreDebug) << "Executing" << exe << "with arguments" << argList; ret = KProcess::execute( exe, argList ); - } else if ( inputFileInfo.suffix() == "pdf" && printer.outputFormat() == QPrinter::NativeFormat && pdf2psAvailable() ) { - exe = "pdf2ps"; + } else if ( inputFileInfo.suffix() == QLatin1String("pdf") && printer.outputFormat() == QPrinter::NativeFormat && pdf2psAvailable() ) { + exe = QStringLiteral("pdf2ps"); argList << fileList[0] << printer.outputFileName(); qCDebug(OkularCoreDebug) << "Executing" << exe << "with arguments" << argList; ret = KProcess::execute( exe, argList ); diff --git a/core/script/kjs_app.cpp b/core/script/kjs_app.cpp --- a/core/script/kjs_app.cpp +++ b/core/script/kjs_app.cpp @@ -101,7 +101,7 @@ #elif defined(Q_OS_MAC) return KJSString( QString::fromLatin1( "MAC" ) ); #else - return KJSString( QLatin1String( "UNIX" ) ); + return KJSString( QStringLiteral( "UNIX" ) ); #endif } @@ -135,13 +135,13 @@ static KJSObject appGetViewerType( KJSContext *, void * ) { // faking a bit... - return KJSString( QLatin1String( "Reader" ) ); + return KJSString( QStringLiteral( "Reader" ) ); } static KJSObject appGetViewerVariation( KJSContext *, void * ) { // faking a bit... - return KJSString( QLatin1String( "Reader" ) ); + return KJSString( QStringLiteral( "Reader" ) ); } static KJSObject appGetViewerVersion( KJSContext *, void * ) diff --git a/core/scripter.cpp b/core/scripter.cpp --- a/core/scripter.cpp +++ b/core/scripter.cpp @@ -59,7 +59,7 @@ static QString builtInScript; if ( builtInScript.isNull() ) { - QFile builtInResource ( ":/script/builtin.js" ); + QFile builtInResource ( QStringLiteral(":/script/builtin.js") ); if (!builtInResource.open( QIODevice::ReadOnly )) { qCDebug(OkularCoreDebug) << "failed to load builtin script"; diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp --- a/generators/epub/converter.cpp +++ b/generators/epub/converter.cpp @@ -381,7 +381,7 @@ } else { // load missing resource char *data = 0; //epub_get_data can't handle whitespace url encodings - QByteArray ba = link.replace("%20", " ").toLatin1(); + QByteArray ba = link.replace(QLatin1String("%20"), QLatin1String(" ")).toLatin1(); const char *clinkClean = ba.data(); int size = epub_get_data(mTextDocument->getEpub(), clinkClean, &data); diff --git a/generators/markdown/generator_md.cpp b/generators/markdown/generator_md.cpp --- a/generators/markdown/generator_md.cpp +++ b/generators/markdown/generator_md.cpp @@ -28,7 +28,7 @@ { Okular::TextDocumentSettings *mdSettings = generalSettings(); - mdSettings->addItemBool( "SmartyPants", s_isFancyPantsEnabled, true ); + mdSettings->addItemBool( QStringLiteral("SmartyPants"), s_isFancyPantsEnabled, true ); mdSettings->load(); s_wasFancyPantsEnabled = s_isFancyPantsEnabled; } @@ -55,7 +55,7 @@ Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget(); QCheckBox *enableSmartyPants = new QCheckBox( dlg ); - enableSmartyPants->setObjectName( QString::fromUtf8( "kcfg_SmartyPants" ) ); + enableSmartyPants->setObjectName( QStringLiteral( "kcfg_SmartyPants" ) ); widget->addRow( i18n("Enable SmartyPants formatting"), enableSmartyPants ); dlg->addPage( widget, generalSettings(), i18n("Markdown"), QStringLiteral("text-markdown"), i18n("Markdown Backend Configuration") ); diff --git a/generators/mobipocket/mobidocument.cpp b/generators/mobipocket/mobidocument.cpp --- a/generators/mobipocket/mobidocument.cpp +++ b/generators/mobipocket/mobidocument.cpp @@ -55,7 +55,7 @@ { if (type!=QTextDocument::ImageResource || name.scheme()!=QString(QStringLiteral("pdbrec"))) return QVariant(); bool ok; - quint16 recnum=name.path().mid(1).toUShort(&ok); + quint16 recnum=name.path().midRef(1).toUShort(&ok); if (!ok || recnum>=doc->imageCount()) return QVariant(); QVariant resource; diff --git a/mobile/app/main.cpp b/mobile/app/main.cpp --- a/mobile/app/main.cpp +++ b/mobile/app/main.cpp @@ -69,7 +69,7 @@ paths[QStringLiteral("home")] = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); engine.rootContext()->setContextProperty(QStringLiteral("userPaths"), paths); - engine.setBaseUrl(QUrl("qrc:/package/contents/ui/")); - engine.load(QUrl("qrc:/package/contents/ui/main.qml")); + engine.setBaseUrl(QUrl(QStringLiteral("qrc:/package/contents/ui/"))); + engine.load(QUrl(QStringLiteral("qrc:/package/contents/ui/main.qml"))); return app.exec(); } diff --git a/mobile/components/documentitem.cpp b/mobile/components/documentitem.cpp --- a/mobile/components/documentitem.cpp +++ b/mobile/components/documentitem.cpp @@ -59,7 +59,7 @@ //TODO: password QMimeDatabase db; - const QString path = url.isLocalFile() ? url.toLocalFile() : QLatin1String("-"); + const QString path = url.isLocalFile() ? url.toLocalFile() : QStringLiteral("-"); m_document->openDocument(path, url, db.mimeTypeForUrl(url)); diff --git a/mobile/components/pageitem.cpp b/mobile/components/pageitem.cpp --- a/mobile/components/pageitem.cpp +++ b/mobile/components/pageitem.cpp @@ -39,7 +39,7 @@ PageItem::PageItem(QQuickItem *parent) : QQuickItem(parent), - Okular::View( QLatin1String( "PageView" ) ), + Okular::View( QStringLiteral( "PageView" ) ), m_page(nullptr), m_smooth(false), m_bookmarked(false), diff --git a/part.cpp b/part.cpp --- a/part.cpp +++ b/part.cpp @@ -204,16 +204,16 @@ if ( compressedMimeMap.isEmpty() ) { std::unique_ptr< KFilterBase > f; - compressedMimeMap[ QLatin1String( "image/x-gzeps" ) ] = KFilterDev::GZip; + compressedMimeMap[ QStringLiteral( "image/x-gzeps" ) ] = KFilterDev::GZip; // check we can read bzip2-compressed files f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::BZip2 ) ); if ( f.get() ) { supportBzip = true; - compressedMimeMap[ QLatin1String( "application/x-bzpdf" ) ] = KFilterDev::BZip2; - compressedMimeMap[ QLatin1String( "application/x-bzpostscript" ) ] = KFilterDev::BZip2; - compressedMimeMap[ QLatin1String( "application/x-bzdvi" ) ] = KFilterDev::BZip2; - compressedMimeMap[ QLatin1String( "image/x-bzeps" ) ] = KFilterDev::BZip2; + compressedMimeMap[ QStringLiteral( "application/x-bzpdf" ) ] = KFilterDev::BZip2; + compressedMimeMap[ QStringLiteral( "application/x-bzpostscript" ) ] = KFilterDev::BZip2; + compressedMimeMap[ QStringLiteral( "application/x-bzdvi" ) ] = KFilterDev::BZip2; + compressedMimeMap[ QStringLiteral( "image/x-bzeps" ) ] = KFilterDev::BZip2; } // check if we can read XZ-compressed files f.reset( KCompressionDevice::filterForCompressionType( KCompressionDevice::Xz ) ); @@ -1566,8 +1566,8 @@ m_find->setEnabled( ok && canSearch ); m_findNext->setEnabled( ok && canSearch ); m_findPrev->setEnabled( ok && canSearch ); - if( m_save ) m_save->setEnabled( ok && !( isstdin || mime.inherits( "inode/directory" ) ) ); - if( m_saveAs ) m_saveAs->setEnabled( ok && !( isstdin || mime.inherits( "inode/directory" ) ) ); + if( m_save ) m_save->setEnabled( ok && !( isstdin || mime.inherits( QStringLiteral("inode/directory") ) ) ); + if( m_saveAs ) m_saveAs->setEnabled( ok && !( isstdin || mime.inherits( QStringLiteral("inode/directory") ) ) ); emit enablePrintAction( ok && m_document->printingSupport() != Okular::Document::NoPrinting ); m_printPreview->setEnabled( ok && m_document->printingSupport() != Okular::Document::NoPrinting ); m_showProperties->setEnabled( ok ); @@ -2439,10 +2439,10 @@ { QAction *separatorAction = contextMenu->addSeparator(); separatorAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); - QAction *renameAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("edit-rename") ), i18n( "Rename this Bookmark" ), this, SLOT(slotRenameBookmarkFromMenu()) ); + QAction *renameAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("edit-rename") ), i18n( "Rename this Bookmark" ), this, &Part::slotRenameBookmarkFromMenu ); renameAction->setData(ba->property("htmlRef").toString()); renameAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); - QAction *deleteAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("list-remove") ), i18n("Remove this Bookmark"), this, SLOT(slotRemoveBookmarkFromMenu())); + QAction *deleteAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("list-remove") ), i18n("Remove this Bookmark"), this, &Part::slotRemoveBookmarkFromMenu); deleteAction->setData(ba->property("htmlRef").toString()); deleteAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); } @@ -2667,7 +2667,7 @@ const int result = KMessageBox::warningYesNoList( widget(), warningMessage, listOfwontSaves, i18n( "Warning" ), - KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes + KGuiItem( i18n( "Save as Okular document archive..." ), QStringLiteral("document-save-as") ), // <- KMessageBox::Yes KStandardGuiItem::cancel() ); switch (result) @@ -2690,8 +2690,8 @@ const int result = KMessageBox::warningYesNoCancelList( widget(), warningMessage, listOfwontSaves, i18n( "Warning" ), - KGuiItem( i18n( "Save as Okular document archive..." ), "document-save-as" ), // <- KMessageBox::Yes - KGuiItem( continueMessage, "arrow-right" ) ); // <- KMessageBox::NO + KGuiItem( i18n( "Save as Okular document archive..." ), QStringLiteral("document-save-as") ), // <- KMessageBox::Yes + KGuiItem( continueMessage, QStringLiteral("arrow-right") ) ); // <- KMessageBox::NO switch (result) { @@ -3675,7 +3675,7 @@ KMessageBox::error(widget(), i18n("There was a problem sharing the document: %1", message), i18n("Share")); } else { - const QString url = output["url"].toString(); + const QString url = output[QStringLiteral("url")].toString(); if (url.isEmpty()) { m_pageView->displayMessage(i18n("Document shared successfully")); } else { diff --git a/shell/shell.cpp b/shell/shell.cpp --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -572,16 +572,16 @@ { if (m_tabs.count() > 1) { - const QString dontAskAgainName = "ShowTabWarning"; + const QString dontAskAgainName = QStringLiteral("ShowTabWarning"); KMessageBox::ButtonCode dummy; if (shouldBeShownYesNo(dontAskAgainName, dummy)) { QDialog *dialog = new QDialog(this); dialog->setWindowTitle(i18n("Confirm Close")); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No); - KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), KGuiItem(i18n("Close Tabs"), "tab-close")); + KGuiItem::assign(buttonBox->button(QDialogButtonBox::Yes), KGuiItem(i18n("Close Tabs"), QStringLiteral("tab-close"))); KGuiItem::assign(buttonBox->button(QDialogButtonBox::No), KStandardGuiItem::cancel()); diff --git a/ui/annotwindow.h b/ui/annotwindow.h --- a/ui/annotwindow.h +++ b/ui/annotwindow.h @@ -64,7 +64,7 @@ void slotOptionBtn(); void slotsaveWindowText(); void renderLatex( bool render ); - void slotHandleContentsChangedByUndoRedo( Okular::Annotation* annot, QString contents, int cursorPos, int anchorPos); + void slotHandleContentsChangedByUndoRedo( Okular::Annotation* annot, const QString &contents, int cursorPos, int anchorPos); Q_SIGNALS: void containsLatex( bool ); diff --git a/ui/annotwindow.cpp b/ui/annotwindow.cpp --- a/ui/annotwindow.cpp +++ b/ui/annotwindow.cpp @@ -198,7 +198,7 @@ setAutoFillBackground( true ); setFrameStyle( Panel | Raised ); setAttribute( Qt::WA_DeleteOnClose ); - setObjectName("AnnotWindow"); + setObjectName(QStringLiteral("AnnotWindow")); const bool canEditAnnotation = m_document->canModifyPageAnnotation( annot ); @@ -421,7 +421,7 @@ } } -void AnnotWindow::slotHandleContentsChangedByUndoRedo(Okular::Annotation* annot, QString contents, int cursorPos, int anchorPos) +void AnnotWindow::slotHandleContentsChangedByUndoRedo(Okular::Annotation* annot, const QString &contents, int cursorPos, int anchorPos) { if ( annot != m_annot ) { diff --git a/ui/certificateviewer.cpp b/ui/certificateviewer.cpp --- a/ui/certificateviewer.cpp +++ b/ui/certificateviewer.cpp @@ -63,7 +63,7 @@ { for ( const QString &attribute : attributes ) { - const QRegularExpression re( QString( "(.*),\\s*(%1=.*)" ).arg( attribute ), QRegularExpression::DotMatchesEverythingOption ); + const QRegularExpression re( QStringLiteral( "(.*),\\s*(%1=.*)" ).arg( attribute ), QRegularExpression::DotMatchesEverythingOption ); const QRegularExpressionMatch match = re.match( t ); if ( match.hasMatch() ) { @@ -81,15 +81,15 @@ QStringList result = text; for ( QString &t : result ) { - t.replace( "\\,", "," ); + t.replace( QLatin1String("\\,"), QLatin1String(",") ); } // Clean up quoted attributes for ( QString &t : result ) { for ( const QString &attribute : attributes ) { - const QRegularExpression re( QString( "%1=\"(.*)\"" ).arg( attribute ) ); + const QRegularExpression re( QStringLiteral( "%1=\"(.*)\"" ).arg( attribute ) ); const QRegularExpressionMatch match = re.match( t ); if ( match.hasMatch() ) { diff --git a/ui/embeddedfilesdialog.cpp b/ui/embeddedfilesdialog.cpp --- a/ui/embeddedfilesdialog.cpp +++ b/ui/embeddedfilesdialog.cpp @@ -60,7 +60,7 @@ mUser2Button = new QPushButton; buttonBox->addButton(mUser2Button, QDialogButtonBox::ActionRole); - KGuiItem::assign(mUser2Button, KGuiItem(i18nc("@action:button", "View"), "document-open")); + KGuiItem::assign(mUser2Button, KGuiItem(i18nc("@action:button", "View"), QStringLiteral("document-open"))); mUser2Button->setEnabled(false); m_tw = new QTreeWidget(this); @@ -183,7 +183,7 @@ + QDir::separator() + fileInfo.baseName() + ".XXXXXX" - + (fileInfo.completeSuffix().isEmpty() ? QString("") : "." + fileInfo.completeSuffix()) // krazy:exclude=doublequote_chars + + (fileInfo.completeSuffix().isEmpty() ? QStringLiteral("") : "." + fileInfo.completeSuffix()) // krazy:exclude=doublequote_chars ); GuiUtils::writeEmbeddedFile( ef, this, *tmpFile ); diff --git a/ui/fileprinterpreview.cpp b/ui/fileprinterpreview.cpp --- a/ui/fileprinterpreview.cpp +++ b/ui/fileprinterpreview.cpp @@ -91,7 +91,7 @@ QStringLiteral("KParts/ReadOnlyPart"), QStringLiteral("[DesktopEntryName] == 'okularghostview'")); } else { - offers = KMimeTypeTrader::self()->query("application/pdf", "KParts/ReadOnlyPart"); + offers = KMimeTypeTrader::self()->query(QStringLiteral("application/pdf"), QStringLiteral("KParts/ReadOnlyPart")); } KService::List::ConstIterator it = offers.constBegin(); diff --git a/ui/pageview.cpp b/ui/pageview.cpp --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -299,7 +299,7 @@ */ PageView::PageView( QWidget *parent, Okular::Document *document ) : QAbstractScrollArea( parent ) - , Okular::View( QLatin1String( "PageView" ) ) + , Okular::View( QStringLiteral( "PageView" ) ) { // create and initialize private storage structure d = new PageViewPrivate( this ); @@ -2776,7 +2776,7 @@ // popup that ask to copy:text and copy/save:image QMenu menu( this ); - menu.setObjectName("PopupMenu"); + menu.setObjectName(QStringLiteral("PopupMenu")); QAction *textToClipboard = nullptr; #ifdef HAVE_SPEECH QAction *speakText = nullptr; @@ -2787,7 +2787,7 @@ { menu.addAction( new OKMenuTitle( &menu, i18np( "Text (1 character)", "Text (%1 characters)", selectedText.length() ) ) ); textToClipboard = menu.addAction( QIcon::fromTheme(QStringLiteral("edit-copy")), i18n( "Copy to Clipboard" ) ); - textToClipboard->setObjectName("CopyTextToClipboard"); + textToClipboard->setObjectName(QStringLiteral("CopyTextToClipboard")); bool copyAllowed = d->document->isAllowed( Okular::AllowCopy ); if ( !copyAllowed ) { @@ -3094,13 +3094,13 @@ { const QString squeezedText = KStringHandler::rsqueeze( url, 30 ); httpLink = menu->addAction( i18n( "Go to '%1'", squeezedText ) ); - httpLink->setObjectName("GoToAction"); + httpLink->setObjectName(QStringLiteral("GoToAction")); } } } if ( menu ) { - menu->setObjectName("PopupMenu"); + menu->setObjectName(QStringLiteral("PopupMenu")); QAction *choice = menu->exec( e->globalPos() ); // check if the user really selected an action @@ -4411,7 +4411,7 @@ const Okular::Action * link = static_cast< const Okular::Action * >( rect->object() ); // creating the menu and its actions QAction * processLink = menu->addAction( i18n( "Follow This Link" ) ); - processLink->setObjectName("ProcessLinkAction"); + processLink->setObjectName(QStringLiteral("ProcessLinkAction")); if ( link->actionType() == Okular::Action::Sound ) { processLink->setText( i18n( "Play this Sound" ) ); if ( Okular::AudioPlayer::instance()->state() == Okular::AudioPlayer::PlayingState ) { @@ -4426,7 +4426,7 @@ if ( dynamic_cast< const Okular::BrowseAction * >( link ) ) { QAction * actCopyLinkLocation = menu->addAction( QIcon::fromTheme( QStringLiteral("edit-copy") ), i18n( "Copy Link Address" ) ); - actCopyLinkLocation->setObjectName("CopyLinkLocationAction"); + actCopyLinkLocation->setObjectName(QStringLiteral("CopyLinkLocationAction")); connect( actCopyLinkLocation, &QAction::triggered, [ link ]() { const Okular::BrowseAction * browseLink = static_cast< const Okular::BrowseAction * >( link ); QClipboard *cb = QApplication::clipboard(); diff --git a/ui/pageviewannotator.cpp b/ui/pageviewannotator.cpp --- a/ui/pageviewannotator.cpp +++ b/ui/pageviewannotator.cpp @@ -141,7 +141,7 @@ } } - void addInPlaceTextAnnotation( Okular::Annotation * &ann, const QString summary, const QString content, Okular::TextAnnotation::InplaceIntent inplaceIntent ) + void addInPlaceTextAnnotation( Okular::Annotation * &ann, const QString &summary, const QString &content, Okular::TextAnnotation::InplaceIntent inplaceIntent ) { Okular::TextAnnotation * ta = new Okular::TextAnnotation(); ann = ta; @@ -1126,7 +1126,7 @@ // Load HiDPI variant on HiDPI screen QString imageVariant; if ( qApp->devicePixelRatio() > 1.05 ) { - imageVariant = "@2x"; + imageVariant = QStringLiteral("@2x"); } // Load base pixmap. We'll draw on top of it diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -1754,8 +1754,8 @@ QString reason = i18nc( "Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a presentation" ); if (!m_screenInhibitCookie) { - QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver", - "org.freedesktop.ScreenSaver", "Inhibit"); + QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), + QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("Inhibit")); message << QCoreApplication::applicationName(); message << reason; @@ -1800,8 +1800,8 @@ } if (m_screenInhibitCookie) { - QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver", - "org.freedesktop.ScreenSaver", "UnInhibit"); + QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), + QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("UnInhibit")); message << m_screenInhibitCookie; QDBusPendingReply reply = QDBusConnection::sessionBus().asyncCall(message);