From 1fb64ae54457d5d66f4bd79f8e6948d75621d105 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 23 Feb 2021 08:59:00 +0100 Subject: [PATCH] better dialog when cannot open url, ability to delete feedly accounts --- src/librssguard/miscellaneous/databasequeries.cpp | 9 +++++++++ src/librssguard/miscellaneous/databasequeries.h | 1 + src/librssguard/network-web/oauth2service.cpp | 15 +++++++++------ .../services/feedly/feedlyserviceroot.cpp | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/librssguard/miscellaneous/databasequeries.cpp b/src/librssguard/miscellaneous/databasequeries.cpp index 6b08102b0..20fafdf9d 100755 --- a/src/librssguard/miscellaneous/databasequeries.cpp +++ b/src/librssguard/miscellaneous/databasequeries.cpp @@ -2510,6 +2510,15 @@ QList DatabaseQueries::getStandardAccounts(const QSqlDatabase& db, return roots; } +bool DatabaseQueries::deleteFeedlyAccount(const QSqlDatabase& db, int account_id) { + QSqlQuery q(db); + + q.setForwardOnly(true); + q.prepare(QSL("DELETE FROM FeedlyAccounts WHERE id = :id;")); + q.bindValue(QSL(":id"), account_id); + return q.exec(); +} + bool DatabaseQueries::deleteGreaderAccount(const QSqlDatabase& db, int account_id) { QSqlQuery q(db); diff --git a/src/librssguard/miscellaneous/databasequeries.h b/src/librssguard/miscellaneous/databasequeries.h index fbc57e05c..5b7afc59d 100644 --- a/src/librssguard/miscellaneous/databasequeries.h +++ b/src/librssguard/miscellaneous/databasequeries.h @@ -153,6 +153,7 @@ class DatabaseQueries { static void fillFeedData(T* feed, const QSqlRecord& sql_record); // Feedly account. + static bool deleteFeedlyAccount(const QSqlDatabase& db, int account_id); static QList getFeedlyAccounts(const QSqlDatabase& db, bool* ok = nullptr); static bool createFeedlyAccount(const QSqlDatabase& db, const QString& username, diff --git a/src/librssguard/network-web/oauth2service.cpp b/src/librssguard/network-web/oauth2service.cpp index 33bb84b46..abb15c571 100644 --- a/src/librssguard/network-web/oauth2service.cpp +++ b/src/librssguard/network-web/oauth2service.cpp @@ -25,6 +25,7 @@ #include "network-web/oauth2service.h" #include "definitions/definitions.h" +#include "gui/messagebox.h" #include "miscellaneous/application.h" #include "network-web/networkfactory.h" #include "network-web/oauthhttphandler.h" @@ -331,11 +332,13 @@ void OAuth2Service::retrieveAuthCode() { m_id); // We run login URL in external browser, response is caught by light HTTP server. - if (!qApp->web()->openUrlInExternalBrowser(auth_url)) { - QInputDialog::getText(qApp->mainFormWidget(), - tr("Navigate to website"), - tr("To login, you need to navigate to this website:"), - QLineEdit::EchoMode::Normal, - auth_url); + if (qApp->web()->openUrlInExternalBrowser(auth_url)) { + MessageBox::show(qApp->mainFormWidget(), + QMessageBox::Icon::Question, + tr("Navigate to website"), + tr("To login, you need to navigate to the below website."), + {}, + auth_url, + QMessageBox::StandardButton::Ok); } } diff --git a/src/librssguard/services/feedly/feedlyserviceroot.cpp b/src/librssguard/services/feedly/feedlyserviceroot.cpp index 0eb4a88cf..95e9eedef 100755 --- a/src/librssguard/services/feedly/feedlyserviceroot.cpp +++ b/src/librssguard/services/feedly/feedlyserviceroot.cpp @@ -51,7 +51,7 @@ bool FeedlyServiceRoot::editViaGui() { bool FeedlyServiceRoot::deleteViaGui() { QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - if (DatabaseQueries::deleteGreaderAccount(database, accountId())) { + if (DatabaseQueries::deleteFeedlyAccount(database, accountId())) { return ServiceRoot::deleteViaGui(); } else {