diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 42a71c23..9ad3c7ee 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -7,7 +7,7 @@ + + + diff --git a/android/res/drawable/splash.xml b/android/res/drawable/splash.xml new file mode 100644 index 00000000..a74c8427 --- /dev/null +++ b/android/res/drawable/splash.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/logo.png b/logo.png new file mode 100644 index 00000000..492459d3 Binary files /dev/null and b/logo.png differ diff --git a/org.kde.mobile.alligator.appdata.xml b/org.kde.mobile.alligator.appdata.xml index 8fc11529..ca5d1ae9 100644 --- a/org.kde.mobile.alligator.appdata.xml +++ b/org.kde.mobile.alligator.appdata.xml @@ -2,12 +2,32 @@ org.kde.mobile.alligator Alligator + Alligator + Alligator + Alligator + Alligator + xxAlligatorxx Feed reader for mobile devices + Lector de fonts per a dispositius mòbils + Mobiilseadmete uudistelugeja + Feedlezer voor mobiele apparaten + Програма для читання подач на мобільних пристроях + xxFeed reader for mobile devicesxx CC0-1.0 GPL-2.0+ KDE Community - + La comunitat KDE + KDE kogukond + KDE gemeenschap + Спільнота KDE + xxKDE Communityxx +

Alligator is a mobile feed reader

+

L'Alligator és un lector de fonts per a mòbil

+

Alligator on mobiilide uudistelugeja

+

Alligator is een mobiele feedlezer

+

Alligator — програма для читання подач на мобільних пристроях

+

xxAlligator is a mobile feed readerxx

alligator diff --git a/org.kde.mobile.alligator.desktop b/org.kde.mobile.alligator.desktop index 4bf452f8..dc34a2e4 100755 --- a/org.kde.mobile.alligator.desktop +++ b/org.kde.mobile.alligator.desktop @@ -1,9 +1,24 @@ [Desktop Entry] Name=Alligator +Name[ca]=Alligator +Name[et]=Alligator +Name[nl]=Alligator +Name[uk]=Alligator +Name[x-test]=xxAlligatorxx Comment=Mobile Feed Reader +Comment[ca]=Lector de fonts per a mòbil +Comment[et]=Mobiili uudistelugeja +Comment[nl]=Mobiele feedlezer +Comment[uk]=Програма для читання подач на мобільному +Comment[x-test]=xxMobile Feed Readerxx GenericName=Feed Reader +GenericName[ca]=Lector de fonts +GenericName[et]=Uudistelugeja +GenericName[nl]=Feedlezer +GenericName[uk]=Читання подач +GenericName[x-test]=xxFeed Readerxx Encoding=UTF-8 -Icon=org.kde.mobile.alligator +Icon=alligator Exec=alligator Type=Application Categories=Qt;KDE;RSS; diff --git a/src/database.cpp b/src/database.cpp index d607cb16..bfab4fa6 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -18,16 +18,18 @@ * along with this program. If not, see . */ -#include -#include -#include -#include #include +#include +#include +#include +#include -#include "database.h" #include "alligatorsettings.h" +#include "database.h" -#define TRUE_OR_RETURN(x) if(!x) return false; +#define TRUE_OR_RETURN(x) \ + if (!x) \ + return false; Database::Database() { @@ -37,19 +39,22 @@ Database::Database() db.setDatabaseName(databasePath + QStringLiteral("/database.db3")); db.open(); - if(!migrate()) { + if (!migrate()) { qCritical() << "Failed to migrate the database"; } cleanup(); } -bool Database::migrate() { - if(version() < 1) TRUE_OR_RETURN(migrateTo1()); +bool Database::migrate() +{ + if (version() < 1) + TRUE_OR_RETURN(migrateTo1()); return true; } -bool Database::migrateTo1() { +bool Database::migrateTo1() +{ qDebug() << "Migrating database to version 1"; QSqlQuery query(QSqlDatabase::database()); TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Feeds (name TEXT, url TEXT, image TEXT);"))); @@ -59,14 +64,16 @@ bool Database::migrateTo1() { return true; } -bool Database::execute(QString query) { +bool Database::execute(QString query) +{ QSqlQuery q; q.prepare(query); return execute(q); } -bool Database::execute(QSqlQuery &query) { - if(!query.exec()) { +bool Database::execute(QSqlQuery &query) +{ + if (!query.exec()) { qWarning() << "Failed to execute SQL Query"; qWarning() << query.lastQuery(); qWarning() << query.lastError(); @@ -75,33 +82,39 @@ bool Database::execute(QSqlQuery &query) { return true; } -int Database::version() { +int Database::version() +{ QSqlQuery query; query.prepare(QStringLiteral("PRAGMA user_version;")); execute(query); - if(query.next()) { + if (query.next()) { bool ok; int value = query.value(0).toInt(&ok); qDebug() << "Database version " << value; - if(ok) return value; + if (ok) + return value; } else { qCritical() << "Failed to check database version"; } return -1; } -void Database::cleanup() { +void Database::cleanup() +{ AlligatorSettings settings; int count = settings.deleteAfterCount(); int type = settings.deleteAfterType(); - if(type == 0) { // Delete after posts per feed - //TODO + if (type == 0) { // Delete after posts per feed + // TODO } else { QDateTime dateTime = QDateTime::currentDateTime(); - if(type == 1) dateTime = dateTime.addDays(-count); - else if(type == 2) dateTime = dateTime.addDays(-7*count); - else if(type == 3) dateTime = dateTime.addMonths(-count); + if (type == 1) + dateTime = dateTime.addDays(-count); + else if (type == 2) + dateTime = dateTime.addDays(-7 * count); + else if (type == 3) + dateTime = dateTime.addMonths(-count); qint64 sinceEpoch = dateTime.toSecsSinceEpoch(); QSqlQuery query; diff --git a/src/entryListModel.cpp b/src/entryListModel.cpp index 5679e31c..672e4950 100644 --- a/src/entryListModel.cpp +++ b/src/entryListModel.cpp @@ -18,12 +18,12 @@ * along with this program. If not, see . */ -#include #include +#include +#include "database.h" #include "entryListModel.h" #include "fetcher.h" -#include "database.h" EntryListModel::EntryListModel(QObject *parent) : QSqlTableModel(parent) @@ -36,12 +36,12 @@ EntryListModel::EntryListModel(QObject *parent) QVariant EntryListModel::data(const QModelIndex &index, int role) const { - if(role == Updated || role == Created) { + if (role == Updated || role == Created) { QDateTime updated; updated.setSecsSinceEpoch(QSqlQueryModel::data(createIndex(index.row(), role), 0).toInt()); return updated; } - return QSqlQueryModel::data(createIndex(index.row(), role), 0); + return QSqlQueryModel::data(createIndex(index.row(), role), 0); } QHash EntryListModel::roleNames() const diff --git a/src/entryListModel.h b/src/entryListModel.h index d41797f5..d36a7d38 100644 --- a/src/entryListModel.h +++ b/src/entryListModel.h @@ -20,8 +20,8 @@ #pragma once -#include #include +#include #include class EntryListModel : public QSqlTableModel diff --git a/src/feedListModel.cpp b/src/feedListModel.cpp index 38d26b0e..c78794ac 100644 --- a/src/feedListModel.cpp +++ b/src/feedListModel.cpp @@ -18,15 +18,15 @@ * along with this program. If not, see . */ -#include -#include #include #include #include +#include +#include +#include "database.h" #include "feedListModel.h" #include "fetcher.h" -#include "database.h" FeedListModel::FeedListModel(QObject *parent) : QSqlTableModel(parent) @@ -49,7 +49,7 @@ QHash FeedListModel::roleNames() const void FeedListModel::addFeed(QString url) { qDebug() << "Adding feed"; - if(feedExists(url)) { + if (feedExists(url)) { qDebug() << "Feed already exists"; return; } @@ -75,7 +75,8 @@ QVariant FeedListModel::data(const QModelIndex &index, int role) const return QSqlTableModel::data(createIndex(index.row(), role), 0); } -bool FeedListModel::feedExists(QString url) { +bool FeedListModel::feedExists(QString url) +{ QSqlQuery query; query.prepare(QStringLiteral("SELECT COUNT (url) FROM Feeds WHERE url=:url;")); query.bindValue(QStringLiteral(":url"), url); @@ -95,7 +96,7 @@ void FeedListModel::removeFeed(int index) query.bindValue(QStringLiteral(":feed"), data(createIndex(index, 0), 1).toString()); Database::instance().execute(query); - //Workaround... + // Workaround... query.prepare(QStringLiteral("DELETE FROM Feeds WHERE url=:url;")); query.bindValue(QStringLiteral(":url"), data(createIndex(index, 0), 1).toString()); Database::instance().execute(query); diff --git a/src/fetcher.cpp b/src/fetcher.cpp index 84320134..ff9ba111 100644 --- a/src/fetcher.cpp +++ b/src/fetcher.cpp @@ -23,10 +23,11 @@ #include -#include "fetcher.h" #include "database.h" +#include "fetcher.h" -Fetcher::Fetcher() { +Fetcher::Fetcher() +{ } void Fetcher::fetch(QUrl url) @@ -44,7 +45,8 @@ void Fetcher::fetch(QUrl url) Syndication::DocumentSource *document = new Syndication::DocumentSource(data, url.toString()); Syndication::FeedPtr feed = Syndication::parserCollection()->parse(*document, QStringLiteral("Atom")); - if(feed.isNull()) return; + if (feed.isNull()) + return; QSqlQuery query; @@ -61,14 +63,15 @@ void Fetcher::fetch(QUrl url) query.bindValue(QStringLiteral(":id"), entry->id()); Database::instance().execute(query); query.next(); - if(query.value(0).toInt() != 0) continue; + if (query.value(0).toInt() != 0) + continue; query.prepare(QStringLiteral("INSERT INTO Entries VALUES (:feed, :id, :title, :content, :created, :updated);")); query.bindValue(QStringLiteral(":feed"), url.toString()); query.bindValue(QStringLiteral(":id"), entry->id()); query.bindValue(QStringLiteral(":title"), entry->title()); query.bindValue(QStringLiteral(":created"), static_cast(entry->datePublished())); query.bindValue(QStringLiteral(":updated"), static_cast(entry->dateUpdated())); - if(!entry->content().isEmpty()) + if (!entry->content().isEmpty()) query.bindValue(QStringLiteral(":content"), entry->content()); else query.bindValue(QStringLiteral(":content"), entry->description()); diff --git a/src/main.cpp b/src/main.cpp index 5b4e9010..d4ba1f5d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,18 +25,18 @@ #endif #include -#include #include +#include #include -#include #include +#include -#include "entryListModel.h" -#include "feedListModel.h" -#include "database.h" #include "alligatorsettings.h" +#include "database.h" +#include "entryListModel.h" #include "feed.h" +#include "feedListModel.h" #ifdef Q_OS_ANDROID Q_DECL_EXPORT @@ -60,8 +60,7 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); - KAboutData about(QStringLiteral("alligator"), i18n("Alligator"), QStringLiteral("0.1"), i18n("Feed Reader"), - KAboutLicense::GPL, i18n("© 2020 KDE Community")); + KAboutData about(QStringLiteral("alligator"), i18n("Alligator"), QStringLiteral("0.1"), i18n("Feed Reader"), KAboutLicense::GPL, i18n("© 2020 KDE Community")); about.addAuthor(i18n("Tobias Fella"), QString(), QStringLiteral("fella@posteo.de")); KAboutData::setApplicationData(about); diff --git a/src/qml/SettingsPage.qml b/src/qml/SettingsPage.qml index 4d7d07c4..7ef7968d 100644 --- a/src/qml/SettingsPage.qml +++ b/src/qml/SettingsPage.qml @@ -1,3 +1,23 @@ +/** + * Copyright 2020 Tobias Fella + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + import QtQuick 2.14 import QtQuick.Controls 2.14 as Controls