Add a few definitions that will come with ECM 5.85

Better enforce them now, so that the work to port doesn't increase over
time

Not a super fan of this for regular applications, but oh well the ship
has sailed
This commit is contained in:
Albert Astals Cid 2022-04-02 23:21:33 +02:00
parent 9eb404c337
commit 0d40301d50
33 changed files with 180 additions and 139 deletions

View File

@ -258,6 +258,9 @@ set_package_properties("Discount" PROPERTIES
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_definitions(-DTRANSLATION_DOMAIN="okular")
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
add_definitions(-DQT_NO_CAST_TO_ASCII)
add_definitions(-DQT_DEPRECATED_WARNINGS_SINCE=0x050C00)
add_definitions(-DKF_DEPRECATED_WARNINGS_SINCE=0x054400)
add_definitions(-DQT_NO_KEYWORDS)

View File

@ -72,14 +72,14 @@ void DocumentTest::testDocdataMigration()
{
Okular::SettingsCore::instance(QStringLiteral("documenttest"));
const QUrl testFileUrl = QUrl::fromLocalFile(KDESRCDIR "data/file1.pdf");
const QUrl testFileUrl = QUrl::fromLocalFile(QStringLiteral(KDESRCDIR "data/file1.pdf"));
const QString testFilePath = testFileUrl.toLocalFile();
const qint64 testFileSize = QFileInfo(testFilePath).size();
// Copy XML file to the docdata/ directory
const QString docDataPath = Okular::DocumentPrivate::docDataFileName(testFileUrl, testFileSize);
QFile::remove(docDataPath);
QVERIFY(QFile::copy(KDESRCDIR "data/file1-docdata.xml", docDataPath));
QVERIFY(QFile::copy(QStringLiteral(KDESRCDIR "data/file1-docdata.xml"), docDataPath));
// Open our document
Okular::Document *m_document = new Okular::Document(nullptr);

View File

@ -444,7 +444,7 @@ void PartTest::testClickUrlLinkWhileInSelectionMode()
// expect that the urlHandler signal was called
QTRY_COMPARE(openUrlSignalSpy.count(), 1);
QList<QVariant> arguments = openUrlSignalSpy.takeFirst();
QCOMPARE(arguments.at(0).value<QUrl>(), QUrl("mailto:foo@foo.bar"));
QCOMPARE(arguments.at(0).value<QUrl>(), QUrl(QStringLiteral("mailto:foo@foo.bar")));
}
void PartTest::testeTextSelectionOverAndAcrossLinks_data()
@ -541,7 +541,7 @@ void PartTest::testClickUrlLinkWhileLinkTextIsSelected()
// expect that the urlHandler signal was called
QTRY_COMPARE(openUrlSignalSpy.count(), 1);
QList<QVariant> arguments = openUrlSignalSpy.takeFirst();
QCOMPARE(arguments.at(0).value<QUrl>(), QUrl("mailto:foo@foo.bar"));
QCOMPARE(arguments.at(0).value<QUrl>(), QUrl(QStringLiteral("mailto:foo@foo.bar")));
}
// r-click on the selected text gives the "Go To:" content menu option
@ -846,7 +846,7 @@ void PartTest::simulateMouseSelection(double startX, double startY, double endX,
void PartTest::testSaveAsToNonExistingPath()
{
Okular::Part part(nullptr, nullptr, QVariantList());
part.openDocument(KDESRCDIR "data/file1.pdf");
part.openDocument(QStringLiteral(KDESRCDIR "data/file1.pdf"));
QString saveFilePath;
{
@ -867,7 +867,7 @@ void PartTest::testSaveAsToSymlink()
{
#ifdef Q_OS_UNIX
Okular::Part part(nullptr, nullptr, QVariantList());
part.openDocument(KDESRCDIR "data/file1.pdf");
part.openDocument(QStringLiteral(KDESRCDIR "data/file1.pdf"));
QTemporaryFile newFile(QStringLiteral("%1/okrXXXXXX.pdf").arg(QDir::tempPath()));
newFile.open();
@ -905,7 +905,7 @@ void PartTest::testSaveIsSymlink()
// QTemporaryFile is destroyed and the file it created is gone, this is a TOCTOU but who cares
}
QFile::copy(KDESRCDIR "data/file1.pdf", newFilePath);
QFile::copy(QStringLiteral(KDESRCDIR "data/file1.pdf"), newFilePath);
QString linkFilePath;
{
@ -1609,7 +1609,7 @@ void PartTest::testAnnotWindow()
part.m_document->addPageAnnotation(0, annot2);
QVERIFY(part.m_document->page(0)->annotations().size() == 2);
QTimer *delayResizeEventTimer = part.m_pageView->findChildren<QTimer *>("delayResizeEventTimer").at(0);
QTimer *delayResizeEventTimer = part.m_pageView->findChildren<QTimer *>(QStringLiteral("delayResizeEventTimer")).at(0);
QVERIFY(delayResizeEventTimer->isActive());
QTest::qWait(delayResizeEventTimer->interval() * 2);
@ -1623,7 +1623,7 @@ void PartTest::testAnnotWindow()
const NormalizedPoint annot1pt = annot1->boundingRectangle().center();
QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * annot1pt.x, height * annot1pt.y));
QTest::mouseDClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * annot1pt.x, height * annot1pt.y));
QTRY_COMPARE(part.m_pageView->findChildren<QFrame *>("AnnotWindow").size(), 1);
QTRY_COMPARE(part.m_pageView->findChildren<QFrame *>(QStringLiteral("AnnotWindow")).size(), 1);
// Verify that the window is visible
QFrame *win1 = part.m_pageView->findChild<QFrame *>(QStringLiteral("AnnotWindow"));
QVERIFY(!win1->visibleRegion().isEmpty());
@ -1632,7 +1632,7 @@ void PartTest::testAnnotWindow()
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<QFrame *>("AnnotWindow").size(), 2);
QTRY_COMPARE(part.m_pageView->findChildren<QFrame *>(QStringLiteral("AnnotWindow")).size(), 2);
// Verify that the first window is hidden covered by the second, which is visible
QList<QFrame *> lstWin = part.m_pageView->findChildren<QFrame *>(QStringLiteral("AnnotWindow"));
QFrame *win2;
@ -1691,7 +1691,7 @@ void PartTest::testAdditionalActionTriggers()
part.widget()->show();
QVERIFY(QTest::qWaitForWindowExposed(part.widget()));
QTimer *delayResizeEventTimer = part.m_pageView->findChildren<QTimer *>("delayResizeEventTimer").at(0);
QTimer *delayResizeEventTimer = part.m_pageView->findChildren<QTimer *>(QStringLiteral("delayResizeEventTimer")).at(0);
QVERIFY(delayResizeEventTimer->isActive());
QTest::qWait(delayResizeEventTimer->interval() * 2);
@ -1873,7 +1873,7 @@ void PartTest::testOpenAtPage()
// 'page=<pagenum>' param as specified in RFC 3778
const uint targetPageNumB = 15;
const uint expectedPageB = targetPageNumB - 1;
url.setFragment("page=" + QString::number(targetPageNumB));
url.setFragment(QStringLiteral("page=") + QString::number(targetPageNumB));
part.openUrl(url);
QCOMPARE(part.m_document->currentPage(), expectedPageB);
}
@ -2047,7 +2047,7 @@ void PartTest::testZoomInFacingPages()
part.widget()->show();
QVERIFY(QTest::qWaitForWindowExposed(part.widget()));
facingAction->trigger();
while (zoomSelectAction->currentText() != "12%") {
while (zoomSelectAction->currentText() != QStringLiteral("12%")) {
QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotZoomOut"));
}
QTRY_VERIFY(part.m_document->page(0)->hasPixmap(part.m_pageView));
@ -2091,10 +2091,25 @@ void PartTest::testZoomWithCrop()
for (int i = 0; i < 20; i++) {
QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotZoomOut"));
}
QCOMPARE(zoomSelectAction->currentText(), "12%");
QCOMPARE(zoomSelectAction->currentText(), QStringLiteral("12%"));
// Zoom in and out and check that all zoom levels appear
QSet<QString> zooms_ref {"12%", "25%", "33%", "50%", "66%", "75%", "100%", "125%", "150%", "200%", "400%", "800%", "1,600%", "2,500%", "5,000%", "10,000%"};
QSet<QString> zooms_ref {QStringLiteral("12%"),
QStringLiteral("25%"),
QStringLiteral("33%"),
QStringLiteral("50%"),
QStringLiteral("66%"),
QStringLiteral("75%"),
QStringLiteral("100%"),
QStringLiteral("125%"),
QStringLiteral("150%"),
QStringLiteral("200%"),
QStringLiteral("400%"),
QStringLiteral("800%"),
QStringLiteral("1,600%"),
QStringLiteral("2,500%"),
QStringLiteral("5,000%"),
QStringLiteral("10,000%")};
for (int j = 0; j < 2; j++) {
QSet<QString> zooms;
@ -2161,7 +2176,7 @@ void PartTest::testLinkWithCrop()
QTest::mouseMove(part.m_pageView->viewport(), click);
QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, click);
QTRY_VERIFY2_WITH_TIMEOUT(qAbs(part.m_document->viewport().rePos.normalizedY - 0.167102333237) < 0.01, qPrintable(QString("We are at %1").arg(part.m_document->viewport().rePos.normalizedY)), 500);
QTRY_VERIFY2_WITH_TIMEOUT(qAbs(part.m_document->viewport().rePos.normalizedY - 0.167102333237) < 0.01, qPrintable(QStringLiteral("We are at %1").arg(part.m_document->viewport().rePos.normalizedY)), 500);
// Deactivate "Trim Margins"
cropAction->trigger();

View File

@ -115,7 +115,7 @@ void SignUnsignedFieldTest::testSignUnsignedField()
QCOMPARE(newForms.count(), 1);
ffs = dynamic_cast<Okular::FormFieldSignature *>(newForms.first());
QCOMPARE(ffs->signatureType(), Okular::FormFieldSignature::AdbePkcs7detached);
QCOMPARE(ffs->signatureInfo().signerName(), "FakeOkular");
QCOMPARE(ffs->signatureInfo().signerName(), QStringLiteral("FakeOkular"));
}
}

View File

@ -52,19 +52,19 @@
<code>
QStringList drawingTools;
// load the default tool list from the 'xml tools definition' file
QFile infoDrawingFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/drawingtools.xml") );
QFile infoDrawingFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/drawingtools.xml")) );
if ( infoDrawingFile.exists() &amp;&amp; infoDrawingFile.open( QIODevice::ReadOnly ) )
{
QDomDocument doc;
if ( doc.setContent( &amp;infoDrawingFile ) )
{
const QDomElement toolsDefinition = doc.elementsByTagName("drawingTools").item( 0 ).toElement();
const QDomElement toolsDefinition = doc.elementsByTagName(QStringLiteral("drawingTools")).item( 0 ).toElement();
// create the annotationTools list from the XML dom tree
QDomNode toolDescription = toolsDefinition.firstChild();
while ( toolDescription.isElement() )
{
const QDomElement toolElement = toolDescription.toElement();
if ( toolElement.tagName() == "tool" )
if ( toolElement.tagName() == QStringLiteral("tool") )
{
QDomDocument temp;
temp.appendChild( temp.importNode( toolElement, true) );
@ -90,19 +90,19 @@
<code>
QStringList builtinAnnotationTools;
// load the default tool list from the 'xml tools definition' file
QFile infoFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/tools.xml") );
QFile infoFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/tools.xml")) );
if ( infoFile.exists() &amp;&amp; infoFile.open( QIODevice::ReadOnly ) )
{
QDomDocument doc;
if ( doc.setContent( &amp;infoFile ) )
{
QDomElement toolsDefinition = doc.elementsByTagName("annotatingTools").item( 0 ).toElement();
QDomElement toolsDefinition = doc.elementsByTagName(QStringLiteral("annotatingTools")).item( 0 ).toElement();
// create the builtinAnnotationTools list from the XML dom tree
QDomNode toolDescription = toolsDefinition.firstChild();
while ( toolDescription.isElement() )
{
QDomElement toolElement = toolDescription.toElement();
if ( toolElement.tagName() == "tool" )
if ( toolElement.tagName() == QStringLiteral("tool") )
{
QDomDocument temp;
temp.appendChild( temp.importNode( toolElement, true) );
@ -129,19 +129,19 @@
<code>
QStringList quickAnnotationTools;
// load the default tool list from the 'xml tools definition' file
QFile quickAnnFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/toolsQuick.xml") );
QFile quickAnnFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/toolsQuick.xml")) );
if ( quickAnnFile.exists() &amp;&amp; quickAnnFile.open( QIODevice::ReadOnly ) )
{
QDomDocument doc;
if ( doc.setContent( &amp;quickAnnFile ) )
{
QDomElement toolsDefinition = doc.elementsByTagName("quickAnnotatingTools").item( 0 ).toElement();
QDomElement toolsDefinition = doc.elementsByTagName(QStringLiteral("quickAnnotatingTools")).item( 0 ).toElement();
// create the quickAnnotationTools list from the XML dom tree
QDomNode toolDescription = toolsDefinition.firstChild();
while ( toolDescription.isElement() )
{
QDomElement toolElement = toolDescription.toElement();
if ( toolElement.tagName() == "tool" )
if ( toolElement.tagName() == QStringLiteral("tool") )
{
QDomDocument temp;
temp.appendChild( temp.importNode( toolElement, true) );

View File

@ -336,13 +336,14 @@ EditTextCommand::EditTextCommand(const QString &newContents, int newCursorPos, c
if (m_prevCursorPos != m_prevAnchorPos) {
qCDebug(OkularCoreDebug) << "OtherEdit, selection";
m_editType = OtherEdit;
} else if (newContentsRightOfCursor() == oldContentsRightOfCursor() && newContentsLeftOfCursor() == oldContentsLeftOfCursor().left(oldContentsLeftOfCursor().length() - 1) && oldContentsLeftOfCursor().rightRef(1) != "\n") {
} else if (newContentsRightOfCursor() == oldContentsRightOfCursor() && newContentsLeftOfCursor() == oldContentsLeftOfCursor().left(oldContentsLeftOfCursor().length() - 1) && oldContentsLeftOfCursor().rightRef(1) != QLatin1Char('\n')) {
qCDebug(OkularCoreDebug) << "CharBackspace";
m_editType = CharBackspace;
} else if (newContentsLeftOfCursor() == oldContentsLeftOfCursor() && newContentsRightOfCursor() == oldContentsRightOfCursor().right(oldContentsRightOfCursor().length() - 1) && oldContentsRightOfCursor().leftRef(1) != "\n") {
} else if (newContentsLeftOfCursor() == oldContentsLeftOfCursor() && newContentsRightOfCursor() == oldContentsRightOfCursor().right(oldContentsRightOfCursor().length() - 1) &&
oldContentsRightOfCursor().leftRef(1) != QLatin1Char('\n')) {
qCDebug(OkularCoreDebug) << "CharDelete";
m_editType = CharDelete;
} else if (newContentsRightOfCursor() == oldContentsRightOfCursor() && newContentsLeftOfCursor().left(newContentsLeftOfCursor().length() - 1) == oldContentsLeftOfCursor() && newContentsLeftOfCursor().rightRef(1) != "\n") {
} else if (newContentsRightOfCursor() == oldContentsRightOfCursor() && newContentsLeftOfCursor().left(newContentsLeftOfCursor().length() - 1) == oldContentsLeftOfCursor() && newContentsLeftOfCursor().rightRef(1) != QLatin1Char('\n')) {
qCDebug(OkularCoreDebug) << "CharInsert";
m_editType = CharInsert;
} else {

View File

@ -323,7 +323,7 @@ static KJSObject appGoForward(KJSContext *, void *object, const KJSArguments &)
static KJSObject appSetInterval(KJSContext *ctx, void *object, const KJSArguments &arguments)
{
DocumentPrivate *doc = reinterpret_cast<DocumentPrivate *>(object);
const QString function = arguments.at(0).toString(ctx) + ';';
const QString function = arguments.at(0).toString(ctx) + QLatin1Char(';');
const int interval = arguments.at(1).toInt32(ctx);
QTimer *timer = new QTimer();
@ -354,7 +354,7 @@ static KJSObject appClearInterval(KJSContext *ctx, void *, const KJSArguments &a
static KJSObject appSetTimeOut(KJSContext *ctx, void *object, const KJSArguments &arguments)
{
DocumentPrivate *doc = reinterpret_cast<DocumentPrivate *>(object);
const QString function = arguments.at(0).toString(ctx) + ';';
const QString function = arguments.at(0).toString(ctx) + QLatin1Char(';');
const int interval = arguments.at(1).toInt32(ctx);
QTimer *timer = new QTimer();

View File

@ -84,12 +84,12 @@ static KJSObject printd(KJSContext *context, void *, const KJSArguments &argumen
}
} else {
format = arguments.at(0).toString(context).replace(QLatin1String("tt"), QLatin1String("ap"));
format.replace('t', 'a');
format.replace(QLatin1Char('t'), QLatin1Char('a'));
for (QChar &formatChar : format) {
if (formatChar == 'M') {
formatChar = 'm';
} else if (formatChar == 'm') {
formatChar = 'M';
if (formatChar == QLatin1Char('M')) {
formatChar = QLatin1Char('m');
} else if (formatChar == QLatin1Char('m')) {
formatChar = QLatin1Char('M');
}
}
}

View File

@ -65,11 +65,11 @@ bool Okular::extractLilyPondSourceReference(const QUrl &url, QString *file, int
}
// There can be more, in case the filename contains :
if (url.fileName().count(':') < 3) {
if (url.fileName().count(QLatin1Char(':')) < 3) {
return false;
}
QStringList parts(url.path().split(':'));
QStringList parts(url.path().split(QLatin1Char(':')));
bool ok;
// Take out the things we need
@ -90,7 +90,7 @@ bool Okular::extractLilyPondSourceReference(const QUrl &url, QString *file, int
}
// In case the path itself contains :, we need to reconstruct it after removing all the numbers
*file = parts.join(':');
*file = parts.join(QLatin1Char(':'));
return (!file->isEmpty());
}

View File

@ -24,12 +24,12 @@
//#define DEBUGPARSER(A) qDebug A
#define DEBUGPARSER(A)
static const char *URL_SCHEME_CHM = "ms-its";
#define URL_SCHEME_CHM QStringLiteral("ms-its")
EBook_CHM::EBook_CHM()
: EBook()
{
m_envOptions = qgetenv("KCHMVIEWEROPTS");
m_envOptions = QString::fromLatin1(qgetenv("KCHMVIEWEROPTS"));
m_chmFile = nullptr;
m_filename = m_font = QString();
@ -72,7 +72,7 @@ QString EBook_CHM::title() const
QUrl EBook_CHM::homeUrl() const
{
return pathToUrl(m_home);
return pathToUrl(QString::fromUtf8(m_home));
}
bool EBook_CHM::hasFeature(EBook::Feature code) const
@ -100,7 +100,7 @@ bool EBook_CHM::getTableOfContents(QList<EBookTocEntry> &toc) const
// Parse the plain text TOC
QList<ParsedEntry> parsed;
if (!parseFileAndFillArray(m_topicsFile, parsed, false)) {
if (!parseFileAndFillArray(QString::fromUtf8(m_topicsFile), parsed, false)) {
return false;
}
@ -135,7 +135,7 @@ bool EBook_CHM::getIndex(QList<EBookIndexEntry> &index) const
// Parse the plain text index
QList<ParsedEntry> parsed;
if (!parseFileAndFillArray(m_indexFile, parsed, true)) {
if (!parseFileAndFillArray(QString::fromUtf8(m_indexFile), parsed, true)) {
return false;
}
@ -219,7 +219,7 @@ bool EBook_CHM::getTextContent(QString &str, const QString &url, bool internal_e
buf.resize(length + 1);
buf[length] = '\0';
str = internal_encoding ? (QString)(buf.constData()) : encodeWithCurrentCodec(buf.constData());
str = internal_encoding ? QString::fromUtf8(buf.constData()) : encodeWithCurrentCodec(buf.constData());
return true;
}
}
@ -256,7 +256,7 @@ bool EBook_CHM::load(const QString &archiveName)
#if defined(WIN32)
m_chmFile = chm_open((BSTR)QFile::encodeName(filename).constData());
#else
m_chmFile = chm_open(QFile::encodeName(filename));
m_chmFile = chm_open(QFile::encodeName(filename).constData());
#endif
if (m_chmFile == nullptr) {
@ -312,13 +312,13 @@ bool EBook_CHM::load(const QString &archiveName)
int EBook_CHM::findStringInQuotes(const QString &tag, int offset, QString &value, bool firstquote, bool decodeentities) const
{
int qbegin = tag.indexOf('"', offset);
int qbegin = tag.indexOf(QLatin1Char('"'), offset);
if (qbegin == -1) {
qFatal("EBook_CHMImpl::findStringInQuotes: cannot find first quote in <param> tag: '%s'", qPrintable(tag));
}
int qend = firstquote ? tag.indexOf('"', qbegin + 1) : tag.lastIndexOf('"');
int qend = firstquote ? tag.indexOf(QLatin1Char('"'), qbegin + 1) : tag.lastIndexOf(QLatin1Char('"'));
if (qend == -1 || qend <= qbegin) {
qFatal("EBook_CHMImpl::findStringInQuotes: cannot find last quote in <param> tag: '%s'", qPrintable(tag));
@ -333,13 +333,13 @@ int EBook_CHM::findStringInQuotes(const QString &tag, int offset, QString &value
for (int i = qbegin + 1; i < qend; i++) {
if (!fill_entity) {
if (tag[i] == '&') { // HTML entity starts
if (tag[i] == QLatin1Char('&')) { // HTML entity starts
fill_entity = true;
} else {
value.append(tag[i]);
}
} else {
if (tag[i] == ';') // HTML entity ends
if (tag[i] == QLatin1Char(';')) // HTML entity ends
{
// If entity is an ASCII code, just decode it
QString decode = m_htmlEntityDecoder.decode(htmlentity);
@ -394,23 +394,23 @@ bool EBook_CHM::parseFileAndFillArray(const QString &file, QList<ParsedEntry> &d
// Split the HHC file by HTML tags
int stringlen = src.length();
while (pos < stringlen && (pos = src.indexOf('<', pos)) != -1) {
while (pos < stringlen && (pos = src.indexOf(QLatin1Char('<'), pos)) != -1) {
int i, word_end = 0;
for (i = ++pos; i < stringlen; i++) {
// If a " or ' is found, skip to the next one.
if ((src[i] == '"' || src[i] == '\'')) {
if ((src[i] == QLatin1Char('"') || src[i] == QLatin1Char('\''))) {
// find where quote ends, either by another quote, or by '>' symbol (some people don't know HTML)
int nextpos = src.indexOf(src[i], i + 1);
if (nextpos == -1 && (nextpos = src.indexOf('>', i + 1)) == -1) {
if (nextpos == -1 && (nextpos = src.indexOf(QLatin1Char('>'), i + 1)) == -1) {
qWarning("EBook_CHMImpl::ParseHhcAndFillTree: corrupted TOC: %s", qPrintable(src.mid(i)));
return false;
}
i = nextpos;
} else if (src[i] == '>') {
} else if (src[i] == QLatin1Char('>')) {
break;
} else if (!src[i].isLetterOrNumber() && src[i] != '/' && !word_end) {
} else if (!src[i].isLetterOrNumber() && src[i] != QLatin1Char('/') && !word_end) {
word_end = i;
}
}
@ -721,15 +721,15 @@ bool EBook_CHM::getInfoFromSystem()
if (m_topicsFile.isEmpty()) {
QString topicAttempt = QStringLiteral("/");
topicAttempt += QString((const char *)buffer + index + 2);
topicAttempt += QString(QString::fromUtf8((const char *)buffer + index + 2));
QString tmp = topicAttempt + ".hhc";
QString tmp = topicAttempt + QStringLiteral(".hhc");
if (ResolveObject(tmp, &ui)) {
m_topicsFile = qPrintable(tmp);
}
tmp = topicAttempt + ".hhk";
tmp = topicAttempt + QStringLiteral(".hhk");
if (ResolveObject(tmp, &ui)) {
m_indexFile = qPrintable(tmp);
@ -741,7 +741,7 @@ bool EBook_CHM::getInfoFromSystem()
index += 2;
cursor = buffer + index;
m_font = QString((const char *)buffer + index + 2);
m_font = QString(QString::fromUtf8((const char *)buffer + index + 2));
break;
default:
@ -770,7 +770,7 @@ QString EBook_CHM::getTopicByUrl(const QUrl &url)
static int chm_enumerator_callback(struct chmFile *, struct chmUnitInfo *ui, void *context)
{
EBook_CHM tmp;
((QList<QUrl> *)context)->push_back(tmp.pathToUrl(ui->path));
((QList<QUrl> *)context)->push_back(tmp.pathToUrl(QString::fromUtf8(ui->path)));
return CHM_ENUMERATOR_CONTINUE;
}
@ -787,8 +787,8 @@ QString EBook_CHM::currentEncoding() const
bool EBook_CHM::setCurrentEncoding(const char *encoding)
{
m_currentEncoding = encoding;
return changeFileEncoding(encoding);
m_currentEncoding = QString::fromUtf8(encoding);
return changeFileEncoding(m_currentEncoding);
}
bool EBook_CHM::isSupportedUrl(const QUrl &url)
@ -817,7 +817,7 @@ bool EBook_CHM::changeFileEncoding(const QString &qtencoding)
{
// Encoding could be either simple Qt codepage, or set like CP1251/KOI8, which allows to
// set up encodings separately for text (first) and internal files (second)
int p = qtencoding.indexOf('/');
int p = qtencoding.indexOf(QLatin1Char('/'));
if (p != -1) {
QString global = qtencoding.left(p);
@ -868,7 +868,7 @@ void EBook_CHM::fillTopicsUrlMap()
unsigned int off_url = get_int32_le(reinterpret_cast<unsigned int *>(topics.data() + i + 8));
off_url = get_int32_le(reinterpret_cast<unsigned int *>(urltbl.data() + off_url + 8)) + 8;
QUrl url = pathToUrl((const char *)urlstr.data() + off_url);
QUrl url = pathToUrl(QString::fromUtf8((const char *)urlstr.data() + off_url));
if (off_title < (unsigned int)strings.size()) {
m_url2topics[url] = encodeWithCurrentCodec((const char *)strings.data() + off_title);
@ -1019,7 +1019,7 @@ QUrl EBook_CHM::pathToUrl(const QString &link) const
url.setHost(URL_SCHEME_CHM);
// Does the link contain the fragment as well?
int off = link.indexOf('#');
int off = link.indexOf(QLatin1Char('#'));
QString path;
if (off != -1) {
@ -1029,8 +1029,8 @@ QUrl EBook_CHM::pathToUrl(const QString &link) const
path = link;
}
if (!path.startsWith('/')) {
path.prepend('/');
if (!path.startsWith(QLatin1Char('/'))) {
path.prepend(QLatin1Char('/'));
}
url.setPath(QUrl::fromPercentEncoding(path.toUtf8()));
@ -1041,7 +1041,7 @@ QString EBook_CHM::urlToPath(const QUrl &link) const
{
if (link.scheme() == URL_SCHEME_CHM) {
if (link.path() == QLatin1String("/") || link.path().isEmpty()) {
return m_home;
return QString::fromUtf8(m_home);
}
return link.path();

View File

@ -199,13 +199,13 @@ private:
//! Encode the string with the currently selected text codec, if possible. Or return as-is, if not.
inline QString encodeWithCurrentCodec(const QByteArray &str) const
{
return (m_textCodec ? m_textCodec->toUnicode(str.constData()) : str);
return (m_textCodec ? m_textCodec->toUnicode(str.constData()) : QString::fromUtf8(str));
}
//! Encode the string with the currently selected text codec, if possible. Or return as-is, if not.
inline QString encodeWithCurrentCodec(const char *str) const
{
return (m_textCodec ? m_textCodec->toUnicode(str) : (QString)str);
return (m_textCodec ? m_textCodec->toUnicode(str) : QString::fromUtf8(str));
}
//! Encode the string from internal files with the currently selected text codec, if possible.
@ -219,7 +219,7 @@ private:
//! Or return as-is, if not.
inline QString encodeInternalWithCurrentCodec(const char *str) const
{
return (m_textCodecForSpecialFiles ? m_textCodecForSpecialFiles->toUnicode(str) : (QString)str);
return (m_textCodecForSpecialFiles ? m_textCodecForSpecialFiles->toUnicode(str) : QString::fromUtf8(str));
}
//! Helper. Translates from Win32 encodings to generic wxWidgets ones.

View File

@ -123,7 +123,7 @@ QString Ebook_CHM_Encoding::guessByLCID(unsigned short lcid)
for (const EbookChmTextEncodingEntry *t = text_encoding_table; t->qtcodec; ++t) {
for (const short *lcids = t->lcids; *lcids; lcids++) {
if (*lcids == lcid) {
return t->qtcodec;
return QString::fromLatin1(t->qtcodec);
}
}
}

View File

@ -20,7 +20,7 @@
#include "helperxmlhandler_epubcontent.h"
#include "helperxmlhandler_epubtoc.h"
static const char *URL_SCHEME_EPUB = "epub";
#define URL_SCHEME_EPUB QStringLiteral("epub")
EBook_EPUB::EBook_EPUB()
: EBook()
@ -203,7 +203,7 @@ bool EBook_EPUB::parseBookinfo()
// All the files, including TOC, are relative to the container_parser.contentPath
m_documentRoot.clear();
int sep = container_parser.contentPath.lastIndexOf('/');
int sep = container_parser.contentPath.lastIndexOf(QLatin1Char('/'));
if (sep != -1) {
m_documentRoot = container_parser.contentPath.left(sep + 1); // Keep the trailing slash
@ -266,7 +266,7 @@ QUrl EBook_EPUB::pathToUrl(const QString &link) const
url.setHost(URL_SCHEME_EPUB);
// Does the link contain the fragment as well?
int off = link.indexOf('#');
int off = link.indexOf(QLatin1Char('#'));
QString path;
if (off != -1) {
@ -276,8 +276,8 @@ QUrl EBook_EPUB::pathToUrl(const QString &link) const
path = link;
}
if (!path.startsWith('/')) {
path.prepend('/');
if (!path.startsWith(QLatin1Char('/'))) {
path.prepend(QLatin1Char('/'));
}
url.setPath(QUrl::fromPercentEncoding(path.toUtf8()));
@ -323,7 +323,7 @@ bool EBook_EPUB::getFileAsBinary(QByteArray &data, const QString &path) const
struct zip_stat fileinfo;
QString completeUrl;
if (!path.isEmpty() && path[0] == '/') {
if (!path.isEmpty() && path[0] == QLatin1Char('/')) {
completeUrl = m_documentRoot + path.mid(1);
} else {
completeUrl = m_documentRoot + path;

View File

@ -160,7 +160,7 @@ bool EBookSearch::searchQuery(const QString &query, QList<QUrl> *results, EBook
const QChar ch = iChar.toLower();
// a quote either begins or ends the phrase
if (ch == '"') {
if (ch == QLatin1Char('"')) {
keeper.addTerm(term);
if (keeper.isInPhrase()) {

View File

@ -16,7 +16,7 @@ HelperEntityDecoder::HelperEntityDecoder(QTextCodec *encoder)
static inline QString encodeWithCodec(QTextCodec *encoder, const QByteArray &str)
{
return (encoder ? encoder->toUnicode(str.constData()) : str);
return (encoder ? encoder->toUnicode(str.constData()) : QString::fromUtf8(str));
}
void HelperEntityDecoder::changeEncoding(QTextCodec *encoder)
@ -188,7 +188,7 @@ QString HelperEntityDecoder::decode(const QString &entity) const
// If entity is an ASCII code like &#12349; - just decode it
if (entity.isEmpty()) {
return QLatin1String("");
} else if (entity[0] == '#') {
} else if (entity[0] == QLatin1Char('#')) {
bool valid;
unsigned int ascode = entity.midRef(1).toUInt(&valid);

View File

@ -19,10 +19,10 @@ namespace QtAs
// Those characters are splitters (i.e. split the word), but added themselves into dictionary too.
// This makes the dictionary MUCH larger, but ensure that for the piece of "window->print" both
// search for "print" and "->print" will find it.
static const char SPLIT_CHARACTERS[] = "!()*&^%#@[]{}':;,.?/|/?<>\\-+=~`";
#define SPLIT_CHARACTERS QStringLiteral("!()*&^%#@[]{}':;,.?/|/?<>\\-+=~`")
// Those characters are parts of word - for example, '_' is here, and search for _debug will find only _debug.
static const char WORD_CHARACTERS[] = "$_";
#define WORD_CHARACTERS QStringLiteral("$_")
struct Term {
Term()
@ -169,10 +169,10 @@ bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl &filename, QStr
if (state == STATE_IN_HTML_TAG) {
// We are inside HTML tag.
// Ignore everything until we see '>' (end of HTML tag) or quote char (quote start)
if (ch == '"' || ch == '\'') {
if (ch == QLatin1Char('"') || ch == QLatin1Char('\'')) {
state = STATE_IN_QUOTES;
QuoteChar = ch;
} else if (ch == '>') {
} else if (ch == QLatin1Char('>')) {
state = STATE_OUTSIDE_TAGS;
}
@ -198,7 +198,7 @@ bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl &filename, QStr
state = STATE_OUTSIDE_TAGS;
// Some shitty HTML does not terminate entities correctly. Screw it.
if (ch != ';' && ch != '<') {
if (ch != QLatin1Char(';') && ch != QLatin1Char('<')) {
if (parseentity.isEmpty()) {
// straight '&' symbol. Add and continue.
parsedbuf += QLatin1String("&");
@ -223,7 +223,7 @@ bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl &filename, QStr
parsedbuf += entity;
continue;
} else {
ch = ' '; // We got a space, so treat it like it, and not add it to parsebuf
ch = QLatin1Char(' '); // We got a space, so treat it like it, and not add it to parsebuf
}
}
@ -232,21 +232,21 @@ bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl &filename, QStr
//
// Check for start of HTML tag, and switch to STATE_IN_HTML_TAG if it is
if (ch == '<') {
if (ch == QLatin1Char('<')) {
state = STATE_IN_HTML_TAG;
goto tokenize_buf;
}
// Check for start of HTML entity
if (ch == '&') {
if (ch == QLatin1Char('&')) {
state = STATE_IN_HTML_ENTITY;
parseentity = QString();
continue;
}
// Replace quote by ' - quotes are used in search window to set the phrase
if (ch == '"') {
ch = '\'';
if (ch == QLatin1Char('"')) {
ch = QLatin1Char('\'');
}
// Ok, we have a valid character outside HTML tags, and probably some in buffer already.
@ -437,7 +437,7 @@ bool Index::searchForPhrases(const QStringList &phrases, const QStringList &word
QList<uint> first_word_positions;
for (QStringList::ConstIterator phrase_it = phrases.constBegin(); phrase_it != phrases.constEnd(); phrase_it++) {
QStringList phrasewords = phrase_it->split(' ');
QStringList phrasewords = phrase_it->split(QLatin1Char(' '));
first_word_positions = miniDict[phrasewords[0]]->positions;
for (int j = 1; j < phrasewords.count(); ++j) {

View File

@ -59,7 +59,7 @@ bool HelperXmlHandler_EpubContent::characters(const QString &ch)
if (m_state == STATE_IN_METADATA && !m_tagname.isEmpty() && !ch.trimmed().isEmpty()) {
// Some metadata may be duplicated; we concantenate them with |
if (metadata.contains(m_tagname)) {
metadata[m_tagname].append("|");
metadata[m_tagname].append(QStringLiteral("|"));
metadata[m_tagname].append(ch.trimmed());
} else {
metadata[m_tagname] = ch.trimmed();

View File

@ -49,7 +49,7 @@ struct epub *EpubDocument::getEpub()
void EpubDocument::setCurrentSubDocument(const QString &doc)
{
mCurrentSubDocument.clear();
int index = doc.indexOf('/');
int index = doc.indexOf(QLatin1Char('/'));
if (index > 0) {
mCurrentSubDocument = QUrl::fromLocalFile(doc.left(index + 1));
}

View File

@ -57,13 +57,13 @@ Converter::~Converter()
QTextDocument *Converter::convert(const QString &fileName)
{
m_markdownFile = fopen(fileName.toLocal8Bit(), "rb");
m_markdownFile = fopen(fileName.toLocal8Bit().constData(), "rb");
if (!m_markdownFile) {
Q_EMIT error(i18n("Failed to open the document"), -1);
return nullptr;
}
m_fileDir = QDir(fileName.left(fileName.lastIndexOf('/')));
m_fileDir = QDir(fileName.left(fileName.lastIndexOf(QLatin1Char('/'))));
QTextDocument *doc = convertOpenFile();
QHash<QString, QTextFragment> internalLinks;
@ -151,7 +151,7 @@ void Converter::extractLinks(const QTextBlock &parent, QHash<QString, QTextFragm
const QTextCharFormat textCharFormat = textFragment.charFormat();
if (textCharFormat.isAnchor()) {
const QString href = textCharFormat.anchorHref();
if (href.startsWith('#')) { // It's an internal link, store it and we'll resolve it at the end
if (href.startsWith(QLatin1Char('#'))) { // It's an internal link, store it and we'll resolve it at the end
internalLinks.insert(href.mid(1), textFragment);
} else {
Okular::BrowseAction *action = new Okular::BrowseAction(QUrl(textCharFormat.anchorHref()));

View File

@ -1572,7 +1572,7 @@ QVariant PDFGenerator::metaData(const QString &key, const QVariant &option) cons
if (Poppler::Version::string() == QStringLiteral(POPPLER_VERSION)) {
return i18n("Using Poppler %1", Poppler::Version::string());
} else {
return i18n("Using Poppler %1\n\nBuilt against Poppler %2", Poppler::Version::string(), POPPLER_VERSION);
return i18n("Using Poppler %1\n\nBuilt against Poppler %2", Poppler::Version::string(), QStringLiteral(POPPLER_VERSION));
}
} else if (key == QLatin1String("ShowStampsWarning")) {
#ifdef HAVE_POPPLER_21_10

View File

@ -86,7 +86,8 @@ bool PDFSettingsWidget::event(QEvent *e)
m_pdfsw.loadSignaturesButton->setVisible(userCancelled);
for (auto cert : certs) {
new QTreeWidgetItem(m_tree, {cert->subjectInfo(Okular::CertificateInfo::EntityInfoKey::CommonName), cert->subjectInfo(Okular::CertificateInfo::EntityInfoKey::EmailAddress), cert->validityEnd().toString("yyyy-MM-dd")});
new QTreeWidgetItem(m_tree,
{cert->subjectInfo(Okular::CertificateInfo::EntityInfoKey::CommonName), cert->subjectInfo(Okular::CertificateInfo::EntityInfoKey::EmailAddress), cert->validityEnd().toString(QStringLiteral("yyyy-MM-dd"))});
}
qDeleteAll(certs);

View File

@ -272,7 +272,7 @@ QList<Okular::CertificateInfo *> PopplerCertificateStore::signingCertificates(bo
*userCancelled = false;
auto PDFGeneratorNSSPasswordCallback = [&userCancelled](const char *element) -> char * {
bool ok;
const QString pwd = QInputDialog::getText(nullptr, i18n("Enter Password"), i18n("Enter password to open %1:", element), QLineEdit::Password, QString(), &ok);
const QString pwd = QInputDialog::getText(nullptr, i18n("Enter Password"), i18n("Enter password to open %1:", QString::fromUtf8(element)), QLineEdit::Password, QString(), &ok);
*userCancelled = !ok;
return ok ? strdup(pwd.toUtf8().constData()) : nullptr;
};

View File

@ -238,19 +238,19 @@ Okular::DocumentInfo GSGenerator::generateDocumentInfo(const QSet<Okular::Docume
{
Okular::DocumentInfo docInfo;
if (keys.contains(Okular::DocumentInfo::Title)) {
docInfo.set(Okular::DocumentInfo::Title, spectre_document_get_title(m_internalDocument));
docInfo.set(Okular::DocumentInfo::Title, QString::fromUtf8(spectre_document_get_title(m_internalDocument)));
}
if (keys.contains(Okular::DocumentInfo::Author)) {
docInfo.set(Okular::DocumentInfo::Author, spectre_document_get_for(m_internalDocument));
docInfo.set(Okular::DocumentInfo::Author, QString::fromUtf8(spectre_document_get_for(m_internalDocument)));
}
if (keys.contains(Okular::DocumentInfo::Creator)) {
docInfo.set(Okular::DocumentInfo::Creator, spectre_document_get_creator(m_internalDocument));
docInfo.set(Okular::DocumentInfo::Creator, QString::fromUtf8(spectre_document_get_creator(m_internalDocument)));
}
if (keys.contains(Okular::DocumentInfo::CreationDate)) {
docInfo.set(Okular::DocumentInfo::CreationDate, spectre_document_get_creation_date(m_internalDocument));
docInfo.set(Okular::DocumentInfo::CreationDate, QString::fromUtf8(spectre_document_get_creation_date(m_internalDocument)));
}
if (keys.contains(Okular::DocumentInfo::CustomKeys)) {
docInfo.set(QStringLiteral("dscversion"), spectre_document_get_format(m_internalDocument), i18n("Document version"));
docInfo.set(QStringLiteral("dscversion"), QString::fromUtf8(spectre_document_get_format(m_internalDocument)), i18n("Document version"));
}
if (keys.contains(Okular::DocumentInfo::MimeType)) {

View File

@ -71,7 +71,7 @@ QString CertificateModel::propertyVisibleValue(CertificateModel::Property p) con
case CertificateModel::Version:
return i18n("V%1", QString::number(m_certificateInfo.version()));
case CertificateModel::SerialNumber:
return m_certificateInfo.serialNumber().toHex(' ');
return QString::fromLatin1(m_certificateInfo.serialNumber().toHex(' '));
case CertificateModel::Issuer:
return m_certificateInfo.issuerInfo(Okular::CertificateInfo::DistinguishedName);
case CertificateModel::IssuedOn:
@ -97,9 +97,9 @@ QString CertificateModel::propertyVisibleValue(CertificateModel::Property p) con
case CertificateModel::SubjectOrganization:
return m_certificateInfo.subjectInfo(Okular::CertificateInfo::Organization);
case CertificateModel::Sha1:
return QCryptographicHash::hash(m_certificateInfo.certificateData(), QCryptographicHash::Sha1).toHex(' ');
return QString::fromLatin1(QCryptographicHash::hash(m_certificateInfo.certificateData(), QCryptographicHash::Sha1).toHex(' '));
case CertificateModel::Sha256:
return QCryptographicHash::hash(m_certificateInfo.certificateData(), QCryptographicHash::Sha256).toHex(' ');
return QString::fromLatin1(QCryptographicHash::hash(m_certificateInfo.certificateData(), QCryptographicHash::Sha256).toHex(' '));
}
return QString();
}

View File

@ -26,7 +26,7 @@ void AndroidInstance::openFile(const QString &title, const QStringList &mimes)
"(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;)V",
activity.object<jobject>(),
QAndroidJniObject::fromString(title).object<jstring>(),
QAndroidJniObject::fromString(mimes.join(';')).object<jstring>());
QAndroidJniObject::fromString(mimes.join(QLatin1Char(';'))).object<jstring>());
if (_env->ExceptionCheck()) {
_env->ExceptionClear();
qWarning() << "couldn't launch intent";

View File

@ -54,7 +54,22 @@
// This is a poor man's attempt at parsing DN, if it fails it is not a problem since it's only for display in a list
static QString splitDNAttributes(const QStringList &text)
{
const QStringList attributes = {"C", "CN", "DC", "E", "EMAIL", "EMAILADDRESS", "L", "O", "OU", "PC", "S", "SN", "SP", "ST", "STREET", "T"};
static const QStringList attributes = {QStringLiteral("C"),
QStringLiteral("CN"),
QStringLiteral("DC"),
QStringLiteral("E"),
QStringLiteral("EMAIL"),
QStringLiteral("EMAILADDRESS"),
QStringLiteral("L"),
QStringLiteral("O"),
QStringLiteral("OU"),
QStringLiteral("PC"),
QStringLiteral("S"),
QStringLiteral("SN"),
QStringLiteral("SP"),
QStringLiteral("ST"),
QStringLiteral("STREET"),
QStringLiteral("T")};
for (const QString &t : text) {
for (const QString &attribute : attributes) {
@ -83,7 +98,7 @@ static QString splitDNAttributes(const QStringList &text)
const QRegularExpression re(QStringLiteral("%1=\"(.*)\"").arg(attribute));
const QRegularExpressionMatch match = re.match(t);
if (match.hasMatch()) {
t = attribute + '=' + match.captured(1);
t = attribute + QLatin1Char('=') + match.captured(1);
}
}
}
@ -138,9 +153,9 @@ CertificateViewer::CertificateViewer(const Okular::CertificateInfo &certInfo, QW
auto fingerprintFormLayout = new QFormLayout(fingerprintBox);
fingerprintFormLayout->setLabelAlignment(Qt::AlignLeft);
QByteArray certData = m_certificateInfo.certificateData();
auto sha1Label = new QLabel(QString(QCryptographicHash::hash(certData, QCryptographicHash::Sha1).toHex(' ')));
auto sha1Label = new QLabel(QString::fromLatin1(QCryptographicHash::hash(certData, QCryptographicHash::Sha1).toHex(' ')));
sha1Label->setWordWrap(true);
auto sha256Label = new QLabel(QString(QCryptographicHash::hash(certData, QCryptographicHash::Sha256).toHex(' ')));
auto sha256Label = new QLabel(QString::fromLatin1(QCryptographicHash::hash(certData, QCryptographicHash::Sha256).toHex(' ')));
sha256Label->setWordWrap(true);
fingerprintFormLayout->addRow(i18n("SHA-1 Fingerprint"), sha1Label);
fingerprintFormLayout->addRow(i18n("SHA-256 Fingerprint"), sha256Label);
@ -193,7 +208,7 @@ void CertificateViewer::updateText(const QModelIndex &index)
text = splitDNAttributes(m_certificateModel->data(index, CertificateModel::PropertyVisibleValueRole).toString());
break;
case CertificateModel::PublicKey:
text = m_certificateInfo.publicKey().toHex(' ');
text = QString::fromLatin1(m_certificateInfo.publicKey().toHex(' '));
break;
case CertificateModel::KeyUsage:
text = SignatureGuiUtils::getReadableKeyUsageNewLineSeparated(m_certificateInfo.keyUsageExtensions());

View File

@ -171,7 +171,8 @@ void EmbeddedFilesDialog::viewFile(Okular::EmbeddedFile *ef)
// save in temporary directory with a unique name resembling the attachment name,
// using QTemporaryFile's XXXXXX placeholder
QTemporaryFile *tmpFile = new QTemporaryFile(QDir::tempPath() + '/' + fileInfo.baseName() + ".XXXXXX" + (fileInfo.completeSuffix().isEmpty() ? QLatin1String("") : QString('.' + fileInfo.completeSuffix())));
QTemporaryFile *tmpFile =
new QTemporaryFile(QDir::tempPath() + QLatin1Char('/') + fileInfo.baseName() + QStringLiteral(".XXXXXX") + (fileInfo.completeSuffix().isEmpty() ? QLatin1String("") : QString(QLatin1Char('.') + fileInfo.completeSuffix())));
GuiUtils::writeEmbeddedFile(ef, this, *tmpFile);
// set readonly to prevent the viewer application from modifying it

View File

@ -122,7 +122,7 @@ LatexRenderer::Error LatexRenderer::handleLatex(QString &fileName, const QString
tempFile->open();
QString tempFileName = tempFile->fileName();
QFileInfo *tempFileInfo = new QFileInfo(tempFileName);
QString tempFileNameNS = tempFileInfo->absolutePath() + '/' + tempFileInfo->baseName();
QString tempFileNameNS = tempFileInfo->absolutePath() + QLatin1Char('/') + tempFileInfo->baseName();
QString tempFilePath = tempFileInfo->absolutePath();
delete tempFileInfo;
QTextStream tempStream(tempFile);

View File

@ -1033,7 +1033,7 @@ QString PageViewPrivate::selectedText() const
text.append(pg->text(pg->textSelection(), Okular::TextPage::CentralPixelTextAreaInclusionBehaviour));
}
if (text.endsWith('\n')) {
if (text.endsWith(QLatin1Char('\n'))) {
text.chop(1);
}
return text;
@ -5296,7 +5296,7 @@ void PageView::slotSpeakDocument()
for (const PageViewItem *item : qAsConst(d->items)) {
Okular::RegularAreaRect *area = textSelectionForItem(item);
text.append(item->page()->text(area));
text.append('\n');
text.append(QLatin1Char('\n'));
delete area;
}

View File

@ -1348,7 +1348,7 @@ QPixmap PageViewAnnotator::makeToolPixmap(const QDomElement &toolElement)
}
// Load base pixmap. We'll draw on top of it
pixmap.load(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-base-okular" + imageVariant + ".png")));
pixmap.load(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/tool-base-okular") + imageVariant + QStringLiteral(".png")));
/* Parse color, innerColor and icon (if present) */
QColor engineColor, innerColor, textColor, annotColor;
@ -1389,7 +1389,7 @@ QPixmap PageViewAnnotator::makeToolPixmap(const QDomElement &toolElement)
p.setPen(QPen(engineColor, 2));
p.drawEllipse(2, 7, 21, 14);
} else if (annotType == QLatin1String("highlight")) {
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-highlighter-okular-colorizable" + imageVariant + ".png")));
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/tool-highlighter-okular-colorizable") + imageVariant + QStringLiteral(".png")));
QImage colorizedOverlay = overlay;
GuiUtils::colorizeImage(colorizedOverlay, engineColor);
@ -1397,7 +1397,7 @@ QPixmap PageViewAnnotator::makeToolPixmap(const QDomElement &toolElement)
p.drawImage(QPoint(0, -32), overlay); // Text + Shadow (uncolorized)
p.drawImage(QPoint(0, -64), colorizedOverlay); // Pen
} else if (annotType == QLatin1String("ink")) {
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-ink-okular-colorizable" + imageVariant + ".png")));
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/tool-ink-okular-colorizable") + imageVariant + QStringLiteral(".png")));
QImage colorizedOverlay = overlay;
GuiUtils::colorizeImage(colorizedOverlay, engineColor);
@ -1405,11 +1405,11 @@ QPixmap PageViewAnnotator::makeToolPixmap(const QDomElement &toolElement)
p.drawImage(QPoint(0, -32), overlay); // Shadow (uncolorized)
p.drawImage(QPoint(0, -64), colorizedOverlay); // Pen
} else if (annotType == QLatin1String("note-inline")) {
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-note-inline-okular-colorizable" + imageVariant + ".png")));
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/tool-note-inline-okular-colorizable") + imageVariant + QStringLiteral(".png")));
GuiUtils::colorizeImage(overlay, engineColor);
p.drawImage(QPoint(0, 0), overlay);
} else if (annotType == QLatin1String("note-linked")) {
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-note-okular-colorizable" + imageVariant + ".png")));
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/tool-note-okular-colorizable") + imageVariant + QStringLiteral(".png")));
GuiUtils::colorizeImage(overlay, engineColor);
p.drawImage(QPoint(0, 0), overlay);
} else if (annotType == QLatin1String("polygon")) {
@ -1462,7 +1462,7 @@ QPixmap PageViewAnnotator::makeToolPixmap(const QDomElement &toolElement)
p.drawLine(1, 13, 16, 13);
p.drawLine(0, 20, 19, 20);
} else if (annotType == QLatin1String("typewriter")) {
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("okular/pics/tool-typewriter-okular-colorizable" + imageVariant + ".png")));
QImage overlay(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/tool-typewriter-okular-colorizable") + imageVariant + QStringLiteral(".png")));
GuiUtils::colorizeImage(overlay, textColor);
p.drawImage(QPoint(-2, 2), overlay);
} else {

View File

@ -188,6 +188,11 @@ static QAction *actionForExportFormat(const Okular::ExportFormat &format, QObjec
return act;
}
static QString KStandardActionName(KStandardAction::StandardAction id)
{
return QString::fromLatin1(KStandardAction::name(id));
}
static KFilterDev::CompressionType compressionTypeFor(const QString &mime_to_check)
{
// The compressedMimeMap is here in case you have a very old shared mime database
@ -1781,7 +1786,7 @@ bool Part::openUrl(const QUrl &_url, bool swapInsteadOfOpening)
int page = dest.toInt(&ok);
if (!ok) {
const QStringList parameters = dest.split(QChar('&'));
const QStringList parameters = dest.split(QLatin1Char('&'));
for (const QString &parameter : parameters) {
if (parameter.startsWith(QStringLiteral("page="), Qt::CaseInsensitive)) {
page = dest.midRef(5).toInt(&ok);
@ -2598,7 +2603,7 @@ bool Part::slotSaveFileAs(bool showOkularArchiveAsDefaultFormat)
// and that's bad because it is *not* an .md file so tell the user to fix it
Q_ASSERT(okularArchiveMimeType.suffixes().count() == 1);
Q_ASSERT(okularArchiveMimeType.suffixes().at(0) == okularArchiveMimeType.preferredSuffix());
const QString wantedExtension = '.' + okularArchiveMimeType.preferredSuffix();
const QString wantedExtension = QLatin1Char('.') + okularArchiveMimeType.preferredSuffix();
if (!saveUrl.path().endsWith(wantedExtension)) {
const auto button = KMessageBox::questionYesNo(
widget(), i18n("You have chosen to save an Okular Archive without the file name ending with the '%1' extension. That is not allowed, do you want to choose a new name?", wantedExtension), i18n("Unsupported extension"));
@ -3074,10 +3079,10 @@ void Part::showMenu(const Okular::Page *page, const QPoint point, const QString
const bool currentPage = page && page->number() == m_document->viewport().pageNumber;
if (!m_showMenuBarAction) {
m_showMenuBarAction = findActionInKPartHierarchy<KToggleAction>(KStandardAction::name(KStandardAction::ShowMenubar));
m_showMenuBarAction = findActionInKPartHierarchy<KToggleAction>(KStandardActionName(KStandardAction::ShowMenubar));
}
if (!m_showFullScreenAction) {
m_showFullScreenAction = findActionInKPartHierarchy<KToggleFullScreenAction>(KStandardAction::name(KStandardAction::FullScreen));
m_showFullScreenAction = findActionInKPartHierarchy<KToggleFullScreenAction>(KStandardActionName(KStandardAction::FullScreen));
}
QMenu *popup = new QMenu(widget());
@ -3220,7 +3225,7 @@ void Part::slotUpdateHamburgerMenu()
menu = new QMenu(widget());
m_hamburgerMenuAction->setMenu(menu);
if (!m_showMenuBarAction) {
m_showMenuBarAction = findActionInKPartHierarchy<KToggleAction>(KStandardAction::name(KStandardAction::ShowMenubar));
m_showMenuBarAction = findActionInKPartHierarchy<KToggleAction>(KStandardActionName(KStandardAction::ShowMenubar));
}
m_hamburgerMenuAction->setShowMenuBarAction(m_showMenuBarAction);
} else {
@ -3257,8 +3262,8 @@ void Part::slotUpdateHamburgerMenu()
// To retrieve an action, it is fastest to use a direct pointer if available (m_action), otherwise use
// ac->action(actionName) and if the action isn't in the actionCollection() of this part,
// use findActionInKPartHierarchy(actionName).
menu->addAction(findActionInKPartHierarchy(KStandardAction::name(KStandardAction::Open)));
menu->addAction(findActionInKPartHierarchy(KStandardAction::name(KStandardAction::OpenRecent)));
menu->addAction(findActionInKPartHierarchy(KStandardActionName(KStandardAction::Open)));
menu->addAction(findActionInKPartHierarchy(KStandardActionName(KStandardAction::OpenRecent)));
menu->addAction(m_save);
menu->addAction(m_saveAs);
menu->addSeparator();
@ -3272,11 +3277,11 @@ void Part::slotUpdateHamburgerMenu()
if (!visibleMainToolbar || (visibleMainToolbar && !visibleMainToolbar->actions().contains(ac->action(QStringLiteral("annotation_favorites"))))) {
menu->addAction(ac->action(QStringLiteral("mouse_toggle_annotate")));
}
menu->addAction(ac->action(KStandardAction::name(KStandardAction::Undo)));
menu->addAction(ac->action(KStandardAction::name(KStandardAction::Redo)));
menu->addAction(ac->action(KStandardActionName(KStandardAction::Undo)));
menu->addAction(ac->action(KStandardActionName(KStandardAction::Redo)));
menu->addSeparator();
menu->addAction(findActionInKPartHierarchy(KStandardAction::name(KStandardAction::Print)));
menu->addAction(findActionInKPartHierarchy(KStandardActionName(KStandardAction::Print)));
menu->addAction(m_printPreview);
menu->addAction(m_showProperties);
menu->addAction(m_openContainingFolder);
@ -3292,7 +3297,7 @@ void Part::slotUpdateHamburgerMenu()
}
auto curatedViewMenu = menu->addMenu(QIcon::fromTheme(QStringLiteral("page-2sides")), menuBar ? menuBar->actions().at(1)->text() : QStringLiteral("View"));
if (!m_showFullScreenAction) {
m_showFullScreenAction = findActionInKPartHierarchy<KToggleFullScreenAction>(KStandardAction::name(KStandardAction::FullScreen));
m_showFullScreenAction = findActionInKPartHierarchy<KToggleFullScreenAction>(KStandardActionName(KStandardAction::FullScreen));
}
curatedViewMenu->addAction(m_showFullScreenAction);
curatedViewMenu->addAction(m_showPresentation);
@ -3350,7 +3355,7 @@ void Part::enableExitAfterPrint()
m_cliPrintAndExit = true;
}
static const char *kKPlugin = "KPlugin";
#define kKPlugin QStringLiteral("KPlugin")
void Part::slotAboutBackend()
{

View File

@ -101,9 +101,9 @@ void removeRCFileIfVersionSmallerThan(const QString &filePath, int version)
const QByteArray contents = f.readAll();
f.close();
#if KXMLGUI_VERSION < QT_VERSION_CHECK(5, 73, 0)
const QString fileVersion = findVersionNumber(contents);
const QString fileVersion = findVersionNumber(QString::fromUtf8(contents));
#else
const QString fileVersion = KXMLGUIClient::findVersionNumber(contents);
const QString fileVersion = KXMLGUIClient::findVersionNumber(QString::fromUtf8(contents));
#endif
if (fileVersion.toInt() < version) {
QFile::remove(filePath);

View File

@ -493,7 +493,7 @@ void Shell::fileOpen()
// that's solvable by choosing "All Files" and it's not that common while it's more convenient to
// only get shown the files that the application can open by default instead of all of them
#if KIO_VERSION >= QT_VERSION_CHECK(5, 73, 0)
const bool useMimeTypeFilters = qgetenv("XDG_CURRENT_DESKTOP").toLower() == QStringLiteral("kde");
const bool useMimeTypeFilters = qgetenv("XDG_CURRENT_DESKTOP").toLower() == "kde";
#else
const bool useMimeTypeFilters = false;
#endif