From 44ee50ab76d534e290a08439d029f689db5cb316 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 25 Feb 2021 09:30:46 +0100 Subject: [PATCH] some refactorings, tray icon test --- .../desktop/com.github.rssguard.appdata.xml | 2 +- src/librssguard/gui/dialogs/formmain.cpp | 11 ++++---- .../gui/dialogs/formmessagefiltersmanager.cpp | 2 +- src/librssguard/gui/guiutilities.cpp | 4 +-- src/librssguard/gui/messagepreviewer.cpp | 8 +++--- src/librssguard/gui/messagepreviewer.h | 6 ++--- .../gui/settings/settingsfeedsmessages.cpp | 2 +- src/librssguard/gui/settings/settingsgui.cpp | 13 ++++------ src/librssguard/gui/systemtrayicon.cpp | 10 +++---- src/librssguard/gui/systemtrayicon.h | 9 +++---- src/librssguard/gui/tabwidget.cpp | 4 +-- src/librssguard/miscellaneous/application.cpp | 26 ++++++++++++++----- .../miscellaneous/databasequeries.cpp | 2 +- src/librssguard/miscellaneous/settings.cpp | 4 +-- src/librssguard/miscellaneous/settings.h | 2 +- src/librssguard/network-web/webfactory.cpp | 6 ++--- src/librssguard/network-web/webfactory.h | 8 +++--- .../services/feedly/feedlynetwork.cpp | 10 +++---- .../services/feedly/feedlynetwork.h | 6 ++--- .../services/feedly/feedlyserviceroot.cpp | 6 ++--- .../feedly/gui/feedlyaccountdetails.cpp | 8 +++--- .../feedly/gui/feedlyaccountdetails.h | 6 ++--- .../feedly/gui/formeditfeedlyaccount.cpp | 6 ++--- src/rssguard/main.cpp | 6 ++--- 24 files changed, 88 insertions(+), 79 deletions(-) diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml index 7047e8696..ae9a30e06 100644 --- a/resources/desktop/com.github.rssguard.appdata.xml +++ b/resources/desktop/com.github.rssguard.appdata.xml @@ -30,7 +30,7 @@ https://martinrotter.github.io/donate/ - + none diff --git a/src/librssguard/gui/dialogs/formmain.cpp b/src/librssguard/gui/dialogs/formmain.cpp index bc5c4c9d7..1c1cafb44 100755 --- a/src/librssguard/gui/dialogs/formmain.cpp +++ b/src/librssguard/gui/dialogs/formmain.cpp @@ -34,7 +34,7 @@ #include "services/owncloud/network/owncloudnetworkfactory.h" #include "services/standard/gui/formstandardimportexport.h" -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) #include "network-web/adblock/adblockicon.h" #include "network-web/adblock/adblockmanager.h" #endif @@ -62,7 +62,7 @@ FormMain::FormMain(QWidget* parent, Qt::WindowFlags f) setWindowIcon(qApp->desktopAwareIcon()); setWindowTitle(APP_LONG_NAME); -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) m_ui->m_menuWebBrowserTabs->addAction(qApp->web()->adBlock()->adBlockIcon()); m_ui->m_menuWebBrowserTabs->addAction(qApp->web()->engineSettingsAction()); #endif @@ -204,7 +204,7 @@ QList FormMain::allActions() const { void FormMain::prepareMenus() { // Setup menu for tray icon. - if (SystemTrayIcon::isSystemTrayAvailable()) { + if (SystemTrayIcon::isSystemTrayAreaAvailable()) { #if defined(Q_OS_WIN) m_trayMenu = new TrayIconMenu(APP_NAME, this); #else @@ -449,7 +449,7 @@ void FormMain::updateFeedButtonsAvailability() { void FormMain::switchVisibility(bool force_hide) { if (force_hide || isVisible()) { - if (SystemTrayIcon::isSystemTrayActivated()) { + if (SystemTrayIcon::isSystemTrayDesired() && SystemTrayIcon::isSystemTrayAreaAvailable()) { hide(); } else { @@ -813,7 +813,8 @@ void FormMain::changeEvent(QEvent* event) { switch (event->type()) { case QEvent::WindowStateChange: { if ((windowState() & Qt::WindowState::WindowMinimized) == Qt::WindowState::WindowMinimized && - SystemTrayIcon::isSystemTrayActivated() && + SystemTrayIcon::isSystemTrayDesired() && + SystemTrayIcon::isSystemTrayAreaAvailable() && qApp->settings()->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool()) { event->ignore(); QTimer::singleShot(CHANGE_EVENT_DELAY, this, [this]() { diff --git a/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp b/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp index ef7f2cf78..a1d0aed88 100644 --- a/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp +++ b/src/librssguard/gui/dialogs/formmessagefiltersmanager.cpp @@ -515,7 +515,7 @@ void FormMessageFiltersManager::beautifyScript() { proc_clang_format.setInputChannelMode(QProcess::InputChannelMode::ManagedInputChannel); proc_clang_format.setArguments({ "--assume-filename=script.js", "--style=Chromium" }); -#if defined (Q_OS_WIN) +#if defined(Q_OS_WIN) proc_clang_format.setProgram(qApp->applicationDirPath() + QDir::separator() + QSL("clang-format") + QDir::separator() + QSL("clang-format.exe")); diff --git a/src/librssguard/gui/guiutilities.cpp b/src/librssguard/gui/guiutilities.cpp index 0e6df13e3..b470962ac 100644 --- a/src/librssguard/gui/guiutilities.cpp +++ b/src/librssguard/gui/guiutilities.cpp @@ -4,7 +4,7 @@ #include "definitions/definitions.h" -#if defined (Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) #include #include #include @@ -31,7 +31,7 @@ void GuiUtilities::applyDialogProperties(QWidget& widget, const QIcon& icon, con } void GuiUtilities::applyResponsiveDialogResize(QWidget& widget, double factor) { -#if defined (Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) auto desktop_geom = QApplication::desktop()->screenGeometry(); auto ratio = double(widget.size().height()) / widget.size().width(); int widt = desktop_geom.width() * factor; diff --git a/src/librssguard/gui/messagepreviewer.cpp b/src/librssguard/gui/messagepreviewer.cpp index 4ca3ad866..27ebe6d17 100755 --- a/src/librssguard/gui/messagepreviewer.cpp +++ b/src/librssguard/gui/messagepreviewer.cpp @@ -13,7 +13,7 @@ #include "services/abstract/labelsnode.h" #include "services/abstract/serviceroot.h" -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) #include "gui/webbrowser.h" #include "gui/webviewer.h" #else @@ -48,7 +48,7 @@ void MessagePreviewer::createConnections() { MessagePreviewer::MessagePreviewer(bool should_resize_to_fit, QWidget* parent) : QWidget(parent), m_layout(new QGridLayout(this)), m_toolBar(new QToolBar(this)), m_verticalScrollBarPosition(0.0), m_separator(nullptr), m_btnLabels(QList>()) { -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) m_txtMessage = new WebBrowser(this); if (should_resize_to_fit) { @@ -82,14 +82,14 @@ void MessagePreviewer::reloadFontSettings() { void MessagePreviewer::setToolbarsVisible(bool visible) { m_toolBar->setVisible(visible); -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) m_txtMessage->setNavigationBarVisible(visible); #endif qApp->settings()->setValue(GROUP(GUI), GUI::MessageViewerToolbarsVisible, visible); } -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) WebBrowser* MessagePreviewer::webBrowser() const { return m_txtMessage; diff --git a/src/librssguard/gui/messagepreviewer.h b/src/librssguard/gui/messagepreviewer.h index ee89ff864..c71c62ff3 100644 --- a/src/librssguard/gui/messagepreviewer.h +++ b/src/librssguard/gui/messagepreviewer.h @@ -14,7 +14,7 @@ class QGridLayout; class QToolBar; -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) class WebBrowser; #else class MessageBrowser; @@ -41,7 +41,7 @@ class MessagePreviewer : public QWidget { void reloadFontSettings(); -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) WebBrowser* webBrowser() const; #endif @@ -72,7 +72,7 @@ class MessagePreviewer : public QWidget { QGridLayout* m_layout; QToolBar* m_toolBar; -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) WebBrowser* m_txtMessage; #else MessageBrowser* m_txtMessage; diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.cpp b/src/librssguard/gui/settings/settingsfeedsmessages.cpp index 75f105c49..09c66d53c 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.cpp +++ b/src/librssguard/gui/settings/settingsfeedsmessages.cpp @@ -25,7 +25,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent initializeMessageDateFormats(); GuiUtilities::setLabelAsNotice(*m_ui->label_9, false); -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) m_ui->m_tabMessages->layout()->removeWidget(m_ui->m_checkDisplayPlaceholders); m_ui->m_checkDisplayPlaceholders->hide(); #else diff --git a/src/librssguard/gui/settings/settingsgui.cpp b/src/librssguard/gui/settings/settingsgui.cpp index 0750dacc5..ba5e6ffed 100755 --- a/src/librssguard/gui/settings/settingsgui.cpp +++ b/src/librssguard/gui/settings/settingsgui.cpp @@ -84,14 +84,11 @@ void SettingsGui::loadSettings() { onBeginLoadSettings(); // Load settings of tray icon. - if (SystemTrayIcon::isSystemTrayAvailable()) { - m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); - } + m_ui->m_grpTray->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); - // Tray icon is not supported on this machine. - else { - m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Tray icon is not available.)")); - m_ui->m_grpTray->setChecked(false); + if (!SystemTrayIcon::isSystemTrayAreaAvailable()) { + m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Your OS does not support tray icons at the moment.)")); + m_ui->m_grpTray->setEnabled(false); } m_ui->m_checkHidden->setChecked(settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool()); @@ -200,7 +197,7 @@ void SettingsGui::saveSettings() { m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex())); // Save tray icon. - if (SystemTrayIcon::isSystemTrayAvailable()) { + if (SystemTrayIcon::isSystemTrayAreaAvailable()) { settings()->setValue(GROUP(GUI), GUI::UseTrayIcon, m_ui->m_grpTray->isChecked()); if (m_ui->m_grpTray->isChecked()) { diff --git a/src/librssguard/gui/systemtrayicon.cpp b/src/librssguard/gui/systemtrayicon.cpp index 113f11b27..840affac3 100644 --- a/src/librssguard/gui/systemtrayicon.cpp +++ b/src/librssguard/gui/systemtrayicon.cpp @@ -60,12 +60,12 @@ void SystemTrayIcon::onActivated(QSystemTrayIcon::ActivationReason reason) { } } -bool SystemTrayIcon::isSystemTrayAvailable() { +bool SystemTrayIcon::isSystemTrayAreaAvailable() { return QSystemTrayIcon::isSystemTrayAvailable() && QSystemTrayIcon::supportsMessages(); } -bool SystemTrayIcon::isSystemTrayActivated() { - return SystemTrayIcon::isSystemTrayAvailable() && qApp->settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool(); +bool SystemTrayIcon::isSystemTrayDesired() { + return qApp->settings()->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool(); } bool SystemTrayIcon::areNotificationsEnabled() { @@ -92,8 +92,8 @@ void SystemTrayIcon::show() { showPrivate(); #else // Delay avoids race conditions and tray icon is properly displayed. - qDebugNN << LOGSEC_GUI << "Showing tray icon with 1000 ms delay."; - QTimer::singleShot(1000, this, &SystemTrayIcon::showPrivate); + qDebugNN << LOGSEC_GUI << "Showing tray icon with 3000 ms delay."; + QTimer::singleShot(3000, this, &SystemTrayIcon::showPrivate); #endif } diff --git a/src/librssguard/gui/systemtrayicon.h b/src/librssguard/gui/systemtrayicon.h index fa4d92ef8..161bf7b91 100644 --- a/src/librssguard/gui/systemtrayicon.h +++ b/src/librssguard/gui/systemtrayicon.h @@ -46,12 +46,11 @@ class SystemTrayIcon : public QSystemTrayIcon { void showMessage(const QString& title, const QString& message, MessageIcon icon = Information, int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, std::function functor = nullptr); - // Returns true if tray icon CAN be constructed on this machine. - static bool isSystemTrayAvailable(); + // Returns true if tray area is available and icon can be displayed. + static bool isSystemTrayAreaAvailable(); - // Returns true if tray icon CAN be costructed and IS enabled in - // application settings. - static bool isSystemTrayActivated(); + // Returns true if user wants to have tray icon displayed. + static bool isSystemTrayDesired(); // Determines whether balloon tips are enabled or not on tray icons. static bool areNotificationsEnabled(); diff --git a/src/librssguard/gui/tabwidget.cpp b/src/librssguard/gui/tabwidget.cpp index 9582b3e60..e3043f5c4 100644 --- a/src/librssguard/gui/tabwidget.cpp +++ b/src/librssguard/gui/tabwidget.cpp @@ -221,7 +221,7 @@ int TabWidget::addBrowser(bool move_after_current, bool make_active, const QUrl& int final_index; QString browser_tab_name = tr("Web browser"); -#if defined (Q_OS_MACOSOS) +#if defined(Q_OS_MACOSOS) browser_tab_name = browser_tab_name.prepend(QSL(" ")); #endif @@ -283,7 +283,7 @@ void TabWidget::gotoPreviousTab() { } void TabWidget::indentTabText(int index) { -#if defined (Q_OS_MACOSOS) +#if defined(Q_OS_MACOSOS) if (tabBar()->tabType(index) != TabBar::FeedReader && !tabIcon(index).isNull()) { // We have closable tab with some icon, fix the title. const QString text = tabText(index); diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index 6f9c32a93..41dfd9a4d 100755 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -26,6 +26,7 @@ #include #include +#include #if defined(USE_WEBENGINE) #include "network-web/adblock/adblockicon.h" @@ -122,7 +123,9 @@ void Application::reactOnForeignNotifications() { void Application::hideOrShowMainForm() { // Display main window. - if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool() && SystemTrayIcon::isSystemTrayActivated()) { + if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool() && + SystemTrayIcon::isSystemTrayDesired() && + SystemTrayIcon::isSystemTrayAreaAvailable()) { qDebugNN << LOGSEC_CORE << "Hiding the main window when the application is starting."; mainForm()->switchVisibility(true); } @@ -158,7 +161,7 @@ bool Application::isAlreadyRunning() { : sendMessage((QStringList() << APP_IS_RUNNING << Application::arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR)); } -FeedReader* Application::feedReader() { +FeedReader* Application:: feedReader() { return m_feedReader; } @@ -280,7 +283,7 @@ QString Application::userDataHomeFolder() const { return home_folder; } else { -#if defined (Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) return IOFactory::getSystemFolder(QStandardPaths::GenericDataLocation) + QDir::separator() + QSL(APP_NAME); #else return configFolder() + QDir::separator() + QSL(APP_NAME); @@ -297,7 +300,7 @@ QString Application::documentsFolder() const { } QString Application::homeFolder() const { -#if defined (Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) return IOFactory::getSystemFolder(QStandardPaths::GenericDataLocation); #else return IOFactory::getSystemFolder(QStandardPaths::HomeLocation); @@ -412,8 +415,15 @@ QIcon Application::desktopAwareIcon() const { void Application::showTrayIcon() { // Display tray icon if it is enabled and available. - if (SystemTrayIcon::isSystemTrayActivated()) { - qDebugNN << LOGSEC_CORE << "Showing tray icon."; + if (SystemTrayIcon::isSystemTrayDesired()) { +#if !defined(Q_OS_LINUX) + if (!SystemTrayIcon::isSystemTrayAreaAvailable()) { + qWarningNN << LOGSEC_GUI << "Tray icon area is not available."; + return; + } +#endif + + qDebugNN << LOGSEC_GUI << "Showing tray icon."; trayIcon()->show(); } } @@ -433,7 +443,9 @@ void Application::deleteTrayIcon() { void Application::showGuiMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon message_type, QWidget* parent, bool show_at_least_msgbox, std::function functor) { - if (SystemTrayIcon::areNotificationsEnabled() && SystemTrayIcon::isSystemTrayActivated()) { + if (SystemTrayIcon::areNotificationsEnabled() && + SystemTrayIcon::isSystemTrayDesired() && + SystemTrayIcon::isSystemTrayAreaAvailable()) { trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, std::move(functor)); } else if (show_at_least_msgbox) { diff --git a/src/librssguard/miscellaneous/databasequeries.cpp b/src/librssguard/miscellaneous/databasequeries.cpp index 20fafdf9d..326f2c7f9 100755 --- a/src/librssguard/miscellaneous/databasequeries.cpp +++ b/src/librssguard/miscellaneous/databasequeries.cpp @@ -2637,7 +2637,7 @@ QList DatabaseQueries::getFeedlyAccounts(const QSqlDatabase& db, b root->network()->setUsername(query.value(1).toString()); root->network()->setDeveloperAccessToken(query.value(2).toString()); -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) root->network()->oauth()->setRefreshToken(query.value(3).toString()); #endif diff --git a/src/librssguard/miscellaneous/settings.cpp b/src/librssguard/miscellaneous/settings.cpp index a88c11dec..151fa32d5 100755 --- a/src/librssguard/miscellaneous/settings.cpp +++ b/src/librssguard/miscellaneous/settings.cpp @@ -9,7 +9,7 @@ #include #include -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) // WebEngine. DKEY WebEngineAttributes::ID = "web_engine_attributes"; @@ -425,7 +425,7 @@ SettingsProperties Settings::determineProperties() { else { // We will use PORTABLE settings only and only if it is available and NON-PORTABLE // settings was not initialized before. -#if defined (Q_OS_LINUX) || defined (Q_OS_ANDROID) || defined (Q_OS_MACOSOS) +#if defined(Q_OS_LINUX) || defined (Q_OS_ANDROID) || defined (Q_OS_MACOSOS) // DO NOT use portable settings for Linux, it is really not used on that platform. const bool will_we_use_portable_settings = false; #else diff --git a/src/librssguard/miscellaneous/settings.h b/src/librssguard/miscellaneous/settings.h index 4227e1c74..befe1320d 100644 --- a/src/librssguard/miscellaneous/settings.h +++ b/src/librssguard/miscellaneous/settings.h @@ -26,7 +26,7 @@ #define DEFAULT_VALUE(x) x ## Def #define GROUP(x) x::ID -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) namespace WebEngineAttributes { KEY ID; } diff --git a/src/librssguard/network-web/webfactory.cpp b/src/librssguard/network-web/webfactory.cpp index b3eaaae3b..20f388cc5 100644 --- a/src/librssguard/network-web/webfactory.cpp +++ b/src/librssguard/network-web/webfactory.cpp @@ -25,7 +25,7 @@ WebFactory::WebFactory(QObject* parent) : QObject(parent) { -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) m_engineSettings = nullptr; m_adBlock = new AdBlockManager(this); m_urlInterceptor = new NetworkUrlInterceptor(this); @@ -41,7 +41,7 @@ WebFactory::WebFactory(QObject* parent) } WebFactory::~WebFactory() { -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) if (m_engineSettings != nullptr && m_engineSettings->menu() != nullptr) { m_engineSettings->menu()->deleteLater(); } @@ -222,7 +222,7 @@ void WebFactory::updateProxy() { } } -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) AdBlockManager* WebFactory::adBlock() { return m_adBlock; } diff --git a/src/librssguard/network-web/webfactory.h b/src/librssguard/network-web/webfactory.h index a2ab33d38..0d80fc1e8 100644 --- a/src/librssguard/network-web/webfactory.h +++ b/src/librssguard/network-web/webfactory.h @@ -9,11 +9,11 @@ #include -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) #include #endif -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) class QMenu; class AdBlockManager; class NetworkUrlInterceptor; @@ -35,7 +35,7 @@ class WebFactory : public QObject { // ∀ = ∀ (entity name), ∀ (base-10 entity), ∀ (base-16 entity) QString unescapeHtml(const QString& html); -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) QAction* engineSettingsAction(); AdBlockManager* adBlock(); NetworkUrlInterceptor* urlIinterceptor(); @@ -46,7 +46,7 @@ class WebFactory : public QObject { bool openUrlInExternalBrowser(const QString& url) const; bool sendMessageViaEmail(const Message& message); -#if defined (USE_WEBENGINE) +#if defined(USE_WEBENGINE) private slots: void createMenu(QMenu* menu = nullptr); void webEngineSettingChanged(bool enabled); diff --git a/src/librssguard/services/feedly/feedlynetwork.cpp b/src/librssguard/services/feedly/feedlynetwork.cpp index 4bf1dab59..73f384ab2 100755 --- a/src/librssguard/services/feedly/feedlynetwork.cpp +++ b/src/librssguard/services/feedly/feedlynetwork.cpp @@ -16,7 +16,7 @@ #include "services/feedly/feedlyfeed.h" #include "services/feedly/feedlyserviceroot.h" -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) #include "network-web/oauth2service.h" #endif @@ -26,7 +26,7 @@ FeedlyNetwork::FeedlyNetwork(QObject* parent) : QObject(parent), m_service(nullptr), -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) m_oauth(new OAuth2Service(QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_AUTH, QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TOKEN, FEEDLY_CLIENT_ID, @@ -36,7 +36,7 @@ FeedlyNetwork::FeedlyNetwork(QObject* parent) m_username(QString()), m_developerAccessToken(QString()), m_batchSize(FEEDLY_DEFAULT_BATCH_SIZE), m_downloadOnlyUnreadMessages(false) { -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) m_oauth->setRedirectUrl(QString(OAUTH_REDIRECT_URI) + QL1C(':') + QString::number(FEEDLY_API_REDIRECT_URI_PORT)); connect(m_oauth, &OAuth2Service::tokensRetrieveError, this, &FeedlyNetwork::onTokensError); @@ -490,7 +490,7 @@ void FeedlyNetwork::setBatchSize(int batch_size) { m_batchSize = batch_size; } -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) void FeedlyNetwork::onTokensError(const QString& error, const QString& error_description) { Q_UNUSED(error) @@ -561,7 +561,7 @@ QString FeedlyNetwork::fullUrl(FeedlyNetwork::Service service) const { } QString FeedlyNetwork::bearer() const { -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) if (m_developerAccessToken.simplified().isEmpty()) { return m_oauth->bearer().toLocal8Bit(); } diff --git a/src/librssguard/services/feedly/feedlynetwork.h b/src/librssguard/services/feedly/feedlynetwork.h index a565f4ee2..c18102f05 100755 --- a/src/librssguard/services/feedly/feedlynetwork.h +++ b/src/librssguard/services/feedly/feedlynetwork.h @@ -8,7 +8,7 @@ #include "network-web/networkfactory.h" #include "services/abstract/feed.h" -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) class OAuth2Service; #endif @@ -44,7 +44,7 @@ class FeedlyNetwork : public QObject { void setService(FeedlyServiceRoot* service); -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) OAuth2Service* oauth() const; void setOauth(OAuth2Service* oauth); @@ -73,7 +73,7 @@ class FeedlyNetwork : public QObject { private: FeedlyServiceRoot* m_service; -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) OAuth2Service* m_oauth; #endif diff --git a/src/librssguard/services/feedly/feedlyserviceroot.cpp b/src/librssguard/services/feedly/feedlyserviceroot.cpp index 95e9eedef..4555c7a67 100755 --- a/src/librssguard/services/feedly/feedlyserviceroot.cpp +++ b/src/librssguard/services/feedly/feedlyserviceroot.cpp @@ -19,7 +19,7 @@ #include "services/feedly/feedlynetwork.h" #include "services/feedly/gui/formeditfeedlyaccount.h" -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) #include "network-web/oauth2service.h" #endif @@ -205,7 +205,7 @@ void FeedlyServiceRoot::saveAccountDataToDatabase(bool creating_new) { if (DatabaseQueries::overwriteFeedlyAccount(database, m_network->username(), m_network->developerAccessToken(), -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) m_network->oauth()->refreshToken(), #else {}, @@ -221,7 +221,7 @@ void FeedlyServiceRoot::saveAccountDataToDatabase(bool creating_new) { if (DatabaseQueries::createFeedlyAccount(database, m_network->username(), m_network->developerAccessToken(), -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) m_network->oauth()->refreshToken(), #else {}, diff --git a/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp b/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp index 3ea3bd7fd..dd153502d 100755 --- a/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp +++ b/src/librssguard/services/feedly/gui/feedlyaccountdetails.cpp @@ -81,7 +81,7 @@ FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent) { onDeveloperAccessTokenChanged(); onUsernameChanged(); -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) hookNetwork(); #endif } @@ -90,7 +90,7 @@ void FeedlyAccountDetails::getDeveloperAccessToken() { qApp->web()->openUrlInExternalBrowser(FEEDLY_GENERATE_DAT); } -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) void FeedlyAccountDetails::hookNetwork() { connect(m_oauth, &OAuth2Service::tokensRetrieved, this, &FeedlyAccountDetails::onAuthGranted); @@ -121,7 +121,7 @@ void FeedlyAccountDetails::onAuthGranted() { #endif void FeedlyAccountDetails::performTest(const QNetworkProxy& custom_proxy) { -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) m_oauth->logout(false); if (m_ui.m_txtDeveloperAccessToken->lineEdit()->text().simplified().isEmpty()) { @@ -168,7 +168,7 @@ void FeedlyAccountDetails::onDeveloperAccessTokenChanged() { const QString token = m_ui.m_txtDeveloperAccessToken->lineEdit()->text(); if (token.isEmpty()) { -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) WidgetWithStatus::StatusType stat = WidgetWithStatus::StatusType::Ok; #else WidgetWithStatus::StatusType stat = WidgetWithStatus::StatusType::Error; diff --git a/src/librssguard/services/feedly/gui/feedlyaccountdetails.h b/src/librssguard/services/feedly/gui/feedlyaccountdetails.h index faa6e7c42..26a19e604 100755 --- a/src/librssguard/services/feedly/gui/feedlyaccountdetails.h +++ b/src/librssguard/services/feedly/gui/feedlyaccountdetails.h @@ -11,7 +11,7 @@ #include -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) class OAuth2Service; #endif @@ -29,7 +29,7 @@ class FeedlyAccountDetails : public QWidget { void onUsernameChanged(); void onDeveloperAccessTokenChanged(); -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) private slots: void onAuthFailed(); void onAuthError(const QString& error, const QString& detailed_description); @@ -42,7 +42,7 @@ class FeedlyAccountDetails : public QWidget { private: Ui::FeedlyAccountDetails m_ui; -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) OAuth2Service* m_oauth; #endif }; diff --git a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp index 2d83a9a0c..5e8a1d6e2 100755 --- a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp +++ b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp @@ -10,7 +10,7 @@ #include "services/feedly/feedlyserviceroot.h" #include "services/feedly/gui/feedlyaccountdetails.h" -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) #include "network-web/oauth2service.h" #endif @@ -26,7 +26,7 @@ FormEditFeedlyAccount::FormEditFeedlyAccount(QWidget* parent) void FormEditFeedlyAccount::apply() { bool editing_account = !applyInternal(); -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) if (!editing_account) { // We transfer refresh token to avoid the need to login once more, // then we delete testing OAuth service. @@ -60,7 +60,7 @@ void FormEditFeedlyAccount::apply() { void FormEditFeedlyAccount::setEditableAccount(ServiceRoot* editable_account) { FormAccountDetails::setEditableAccount(editable_account); -#if defined (FEEDLY_OFFICIAL_SUPPORT) +#if defined(FEEDLY_OFFICIAL_SUPPORT) if (m_details->m_oauth != nullptr) { // We will use live OAuth service for testing. m_details->m_oauth->logout(true); diff --git a/src/rssguard/main.cpp b/src/rssguard/main.cpp index 3925b2122..5759d0bdc 100755 --- a/src/rssguard/main.cpp +++ b/src/rssguard/main.cpp @@ -12,7 +12,7 @@ #include #endif -#if defined (Q_OS_MACOS) +#if defined(Q_OS_MACOS) extern void disableWindowTabbing(); #endif @@ -25,14 +25,14 @@ int main(int argc, char* argv[]) { QApplication::setAttribute(Qt::ApplicationAttribute::AA_EnableHighDpiScaling); #endif -#if defined (Q_OS_LINUX) +#if defined(Q_OS_LINUX) QApplication::setDesktopFileName(APP_DESKTOP_ENTRY_FILE); #endif // Ensure that ini format is used as application settings storage on Mac OS. QSettings::setDefaultFormat(QSettings::IniFormat); -#if defined (Q_OS_MACOS) +#if defined(Q_OS_MACOS) QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); disableWindowTabbing(); #endif