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

clazy fixes

parent ee5ec9c5
......@@ -71,14 +71,14 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
return 1;
}
const QString fileName = parser.positionalArguments().first();
const QString fileName = parser.positionalArguments().constFirst();
KDesktopFile desktopFile(fileName);
if (desktopFile.readUrl().isEmpty()) {
return 2;
}
const QString initialUrl = QUrl::fromUserInput(desktopFile.readUrl()).toString();
const QString appName = desktopFile.readName().toLower().replace(QLatin1Char(' '), QLatin1Char('-')) + QLatin1String("-angelfish-webapp");
const QString appName = desktopFile.readName().toLower().replace(QLatin1Char(' '), QLatin1Char('-')) + QStringLiteral("-angelfish-webapp");
KAboutData aboutData(appName.toLower(), desktopFile.readName(),
QStringLiteral("0.1"),
i18n("Angelfish Web App runtime"),
......
......@@ -36,9 +36,7 @@ BrowserManager::BrowserManager(QObject *parent)
connect(m_dbmanager, &DBManager::databaseTableChanged, this, &BrowserManager::databaseTableChanged);
}
BrowserManager::~BrowserManager()
{
}
BrowserManager::~BrowserManager() = default;
void BrowserManager::addBookmark(const QVariantMap &bookmarkdata)
{
......
......@@ -48,7 +48,7 @@ DBManager::DBManager(QObject *parent)
throw std::runtime_error("Database directory does not exist and cannot be created: " + dbpath.toStdString());
}
QSqlDatabase database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"));
QSqlDatabase database = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
database.setDatabaseName(dbname);
if (!database.open()) {
qCritical() << "Failed to open database" << dbname;
......@@ -66,7 +66,7 @@ DBManager::DBManager(QObject *parent)
int DBManager::version()
{
QSqlQuery query(QLatin1String("PRAGMA user_version"));
QSqlQuery query(QStringLiteral("PRAGMA user_version"));
if (query.next()) {
bool ok;
int value = query.value(0).toInt(&ok);
......
......@@ -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(QStringLiteral("favicon")));
auto *provider = dynamic_cast<QQuickImageProvider *>(m_engine->imageProvider(QStringLiteral("favicon")));
QLatin1String prefix_favicon = QLatin1String("image://favicon/");
QString providerIconName = url.mid(prefix_favicon.size());
......@@ -102,7 +102,7 @@ void DesktopFileGenerator::storeIcon(const QString &url, const QString &fileName
QString DesktopFileGenerator::webappCommand()
{
if (!QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty()) {
if (!QStandardPaths::locate(QStandardPaths::RuntimeLocation, QStringLiteral("flatpak-info")).isEmpty()) {
return QStringLiteral("flatpak run "
"--command=angelfish-webapp "
"--filesystem=%1 "
......
......@@ -58,7 +58,7 @@ QString IconImageProvider::storeImage(const QString &iconSource)
}
// new uri for image
QString url = QStringLiteral("image://%1/%2").arg(providerId()).arg(iconSource.mid(prefix_favicon.size()));
QString url = QStringLiteral("image://%1/%2").arg(providerId(), iconSource.mid(prefix_favicon.size()));
// check if we have that image already
QSqlQuery query_check;
......@@ -79,7 +79,7 @@ QString IconImageProvider::storeImage(const QString &iconSource)
query_check.finish();
// Store new icon
QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(s_engine->imageProvider(QStringLiteral("favicon")));
QQuickImageProvider *provider = dynamic_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
......@@ -132,7 +132,7 @@ QImage IconImageProvider::requestImage(const QString &id, QSize *size, const QSi
{
QSqlQuery query;
query.prepare(QStringLiteral("SELECT icon FROM icons WHERE url LIKE :url LIMIT 1"));
query.bindValue(QStringLiteral(":url"), QStringLiteral("image://%1/%2%").arg(providerId()).arg(id));
query.bindValue(QStringLiteral(":url"), QStringLiteral("image://%1/%2%").arg(providerId(), id));
if (!query.exec()) {
qWarning() << Q_FUNC_INFO << "Failed to execute SQL statement";
qWarning() << query.lastQuery();
......
......@@ -69,7 +69,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
// initial url command line parameter
QString initialUrl;
if (!parser.positionalArguments().isEmpty())
initialUrl = QUrl::fromUserInput(parser.positionalArguments().first()).toString();
initialUrl = QUrl::fromUserInput(parser.positionalArguments().constFirst()).toString();
// Exported types
qmlRegisterType<BookmarksHistoryModel>("org.kde.mobile.angelfish", 1, 0, "BookmarksHistoryModel");
......
......@@ -127,7 +127,7 @@ void TabsModel::setCurrentTab(int index)
return;
m_currentTab = index;
currentTabChanged();
emit currentTabChanged();
saveTabs();
}
......@@ -157,7 +157,8 @@ bool TabsModel::loadTabs()
const auto tabsStorage = QJsonDocument::fromJson(inputFile.readAll()).object();
m_tabs.clear();
for (const auto tab : tabsStorage.value(QLatin1String("tabs")).toArray()) {
const auto tabs = tabsStorage.value(QLatin1String("tabs")).toArray();
for (const auto tab : tabs) {
m_tabs.append(TabState::fromJson(tab.toObject()));
}
......@@ -170,7 +171,7 @@ bool TabsModel::loadTabs()
createEmptyTab();
}
endResetModel();
emit endResetModel();
currentTabChanged();
return true;
......@@ -225,7 +226,7 @@ bool TabsModel::isMobileDefault() const
void TabsModel::setIsMobileDefault(bool def)
{
m_isMobileDefault = def;
isMobileDefaultChanged();
emit isMobileDefaultChanged();
// used in initialization of the tab
if (m_tabs.count() == 1) {
......@@ -241,7 +242,7 @@ bool TabsModel::privateMode() const
void TabsModel::setPrivateMode(bool privateMode)
{
m_privateMode = privateMode;
privateModeChanged();
emit privateModeChanged();
}
/**
......@@ -267,7 +268,7 @@ void TabsModel::newTab(const QString &url)
// Switch to last tab
m_currentTab = m_tabs.count() - 1;
currentTabChanged();
emit currentTabChanged();
saveTabs();
}
......@@ -309,7 +310,7 @@ void TabsModel::closeTab(int index)
m_tabs.removeAt(index);
endRemoveRows();
currentTabChanged();
emit currentTabChanged();
saveTabs();
}
......@@ -322,7 +323,7 @@ void TabsModel::setIsMobile(int index, bool isMobile)
m_tabs[index].setIsMobile(isMobile);
QModelIndex mindex = createIndex(index, index);
dataChanged(mindex, mindex, {RoleNames::IsMobileRole});
emit dataChanged(mindex, mindex, {RoleNames::IsMobileRole});
saveTabs();
}
......@@ -335,7 +336,7 @@ void TabsModel::setUrl(int index, const QString &url)
m_tabs[index].setUrl(url);
QModelIndex mindex = createIndex(index, index);
dataChanged(mindex, mindex, {RoleNames::UrlRole});
emit dataChanged(mindex, mindex, {RoleNames::UrlRole});
saveTabs();
}
......
......@@ -34,9 +34,7 @@ UrlUtils::UrlUtils(QObject *parent)
{
}
UrlUtils::~UrlUtils()
{
}
UrlUtils::~UrlUtils() = default;
QString UrlUtils::urlFromUserInput(const QString &input)
{
......
......@@ -13,9 +13,9 @@ QString UserAgent::userAgent() const
return QStringLiteral(
"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(QStringLiteral(QTWEBENGINE_VERSION_STR))
.arg(m_isMobile ? QStringLiteral("Mobile") : QStringLiteral("Desktop"));
.arg(m_isMobile ? QStringLiteral("Linux; Plasma Mobile, like Android 9.0") : QStringLiteral("X11; Linux x86_64"),
QStringLiteral(QTWEBENGINE_VERSION_STR),
m_isMobile ? QStringLiteral("Mobile") : QStringLiteral("Desktop"));
}
bool UserAgent::isMobile() const
......
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