Verified Commit ee5ec9c5 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Use QStringLiteral everywhere

parent 787c2289
......@@ -14,6 +14,7 @@ set(angelfish_webapp_SRCS
add_executable(angelfish-webapp ${angelfish_webapp_SRCS} ${RESOURCES} ${WEBAPP_RESOURCES})
target_include_directories(angelfish-webapp PRIVATE ../src/)
target_compile_definitions(angelfish-webapp PRIVATE -DQT_NO_CAST_FROM_ASCII)
target_link_libraries(angelfish-webapp
Qt5::Core
Qt5::Qml
......
......@@ -57,7 +57,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// Command line parser
QCommandLineParser parser;
parser.addPositionalArgument("desktopfile", i18n("desktop file to open"), "[file]");
parser.addPositionalArgument(QStringLiteral("desktopfile"), i18n("desktop file to open"), QStringLiteral("[file]"));
parser.addHelpOption();
parser.process(app);
......@@ -85,7 +85,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
KAboutLicense::GPL,
i18n("Copyright 2020 Angelfish developers"));
QApplication::setWindowIcon(QIcon::fromTheme(desktopFile.readIcon()));
aboutData.addAuthor(i18n("Marco Martin"), QString(), "mart@kde.org");
aboutData.addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org"));
KAboutData::setApplicationData(aboutData);
......
......@@ -14,6 +14,7 @@ set(angelfish_SRCS
qt5_add_resources(RESOURCES resources.qrc)
add_executable(angelfish ${angelfish_SRCS} ${RESOURCES})
target_compile_definitions(angelfish PRIVATE -DQT_NO_CAST_FROM_ASCII)
target_link_libraries(angelfish
Qt5::Core
Qt5::Qml
......
......@@ -78,20 +78,20 @@ void BrowserManager::setHomepage(const QString &homepage)
{
if (this->homepage() == homepage)
return;
m_settings->setValue("browser/homepage", homepage);
m_settings->setValue(QStringLiteral("browser/homepage"), homepage);
emit homepageChanged();
}
QString BrowserManager::homepage()
{
return m_settings->value("browser/homepage", "https://start.duckduckgo.com").toString();
return m_settings->value(QStringLiteral("browser/homepage"), QStringLiteral("https://start.duckduckgo.com")).toString();
}
void BrowserManager::setSearchBaseUrl(const QString &searchBaseUrl)
{
if (this->searchBaseUrl() == searchBaseUrl)
return;
m_settings->setValue("browser/searchBaseUrl", searchBaseUrl);
m_settings->setValue(QStringLiteral("browser/searchBaseUrl"), searchBaseUrl);
emit searchBaseUrlChanged();
}
......@@ -112,7 +112,7 @@ QSettings *BrowserManager::settings() const
QString BrowserManager::searchBaseUrl()
{
return m_settings->value("browser/searchBaseUrl", "https://start.duckduckgo.com/?q=").toString();
return m_settings->value(QStringLiteral("browser/searchBaseUrl"), QStringLiteral("https://start.duckduckgo.com/?q=")).toString();
}
BrowserManager *BrowserManager::instance()
......
......@@ -155,12 +155,12 @@ void DBManager::trimIcons()
void DBManager::addRecord(const QString &table, const QVariantMap &pagedata)
{
QString url = pagedata.value("url").toString();
QString title = pagedata.value("title").toString();
QString icon = pagedata.value("icon").toString();
QString url = pagedata.value(QStringLiteral("url")).toString();
QString title = pagedata.value(QStringLiteral("title")).toString();
QString icon = pagedata.value(QStringLiteral("icon")).toString();
qint64 lastVisited = QDateTime::currentSecsSinceEpoch();
if (url.isEmpty() || url == "about:blank")
if (url.isEmpty() || url == QStringLiteral("about:blank"))
return;
QSqlQuery query;
......
......@@ -42,7 +42,7 @@ void DesktopFileGenerator::createDesktopFile(const QString &name, const QString
{
QString location = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
QString filename = name.toLower();
filename.replace(" ", "_");
filename.replace(QStringLiteral(" "), QStringLiteral("_"));
QString path = QStringLiteral("%1/%2.desktop").arg(location, filename);
KConfig desktopFile(path, KConfig::SimpleConfig);
......@@ -59,7 +59,7 @@ void DesktopFileGenerator::createDesktopFile(const QString &name, const QString
void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName)
{
auto *provider = static_cast<QQuickImageProvider *>(m_engine->imageProvider("favicon"));
auto *provider = static_cast<QQuickImageProvider *>(m_engine->imageProvider(QStringLiteral("favicon")));
QLatin1String prefix_favicon = QLatin1String("image://favicon/");
QString providerIconName = url.mid(prefix_favicon.size());
......@@ -68,11 +68,11 @@ void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName
QSize szObtained;
QString iconLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ "/icons/hicolor/16x16/apps/";
+ QStringLiteral("/icons/hicolor/16x16/apps/");
QDir().mkpath(iconLocation);
auto imageFile = new QFile(iconLocation + fileName + ".png");
auto imageFile = new QFile(iconLocation + fileName + QStringLiteral(".png"));
if (!imageFile->open(QIODevice::WriteOnly)) {
qDebug() << Q_FUNC_INFO << "Failed to open image file";
......
......@@ -45,7 +45,7 @@ IconImageProvider::IconImageProvider(QQmlApplicationEngine *engine)
QString IconImageProvider::providerId()
{
return "angelfish-favicon";
return QStringLiteral("angelfish-favicon");
}
QString IconImageProvider::storeImage(const QString &iconSource)
......@@ -79,7 +79,7 @@ QString IconImageProvider::storeImage(const QString &iconSource)
query_check.finish();
// Store new icon
QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(s_engine->imageProvider("favicon"));
QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(s_engine->imageProvider(QStringLiteral("favicon")));
if (provider == nullptr) {
qWarning() << Q_FUNC_INFO << "Failed to load image provider" << url;
return iconSource; // as something is wrong
......
......@@ -46,9 +46,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
#endif
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("KDE");
QCoreApplication::setOrganizationDomain("mobile.kde.org");
QCoreApplication::setApplicationName("angelfish");
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
QCoreApplication::setOrganizationDomain(QStringLiteral("mobile.kde.org"));
QCoreApplication::setApplicationName(QStringLiteral("angelfish"));
#if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
QtWebEngine::initialize();
......@@ -56,7 +56,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// Command line parser
QCommandLineParser parser;
parser.addPositionalArgument("url", i18n("URL to open"), "[url]");
parser.addPositionalArgument(QStringLiteral("url"), i18n("URL to open"), QStringLiteral("[url]"));
parser.addHelpOption();
parser.process(app);
......
......@@ -189,7 +189,7 @@ bool TabsModel::saveTabs() const
QString outputDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/angelfish/");
QFile outputFile(outputDir + QStringLiteral("tabs.json"));
if (!QDir(outputDir).mkpath(".")) {
if (!QDir(outputDir).mkpath(QStringLiteral("."))) {
qDebug() << "Destdir doesn't exist and I can't create it: " << outputDir;
return false;
}
......
......@@ -14,7 +14,7 @@ QString UserAgent::userAgent() const
"Mozilla/5.0 (%1) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/%2 "
"Chrome/75.0.3770.116 %3 Safari/537.36")
.arg(m_isMobile ? QStringLiteral("Linux; Plasma Mobile, like Android 9.0") : QStringLiteral("X11; Linux x86_64"))
.arg(QTWEBENGINE_VERSION_STR)
.arg(QStringLiteral(QTWEBENGINE_VERSION_STR))
.arg(m_isMobile ? QStringLiteral("Mobile") : QStringLiteral("Desktop"));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment