better dialog when cannot open url, ability to delete feedly accounts

This commit is contained in:
Martin Rotter 2021-02-23 08:59:00 +01:00
parent 016a0f9a3a
commit 1fb64ae544
4 changed files with 20 additions and 7 deletions

View File

@ -2510,6 +2510,15 @@ QList<ServiceRoot*> 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);

View File

@ -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<ServiceRoot*> getFeedlyAccounts(const QSqlDatabase& db, bool* ok = nullptr);
static bool createFeedlyAccount(const QSqlDatabase& db,
const QString& username,

View File

@ -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);
}
}

View File

@ -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 {