| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/network-web/adblock/adblockdialog.cpp`/ |
| 2 | |
| 3 | #include "network-web/adblock/adblockdialog.h"cxx . . $ `<file>/src/librssguard/network-web/adblock/adblockdialog.h`/ |
| 4 | |
| 5 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 6 | #include "exceptions/applicationexception.h"cxx . . $ `<file>/src/librssguard/exceptions/applicationexception.h`/ |
| 7 | #include "gui/guiutilities.h"cxx . . $ `<file>/src/librssguard/gui/guiutilities.h`/ |
| 8 | #include "gui/messagebox.h"cxx . . $ `<file>/src/librssguard/gui/messagebox.h`/ |
| 9 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 10 | #include "miscellaneous/iconfactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/iconfactory.h`/ |
| 11 | #include "miscellaneous/settings.h"cxx . . $ `<file>/src/librssguard/miscellaneous/settings.h`/ |
| 12 | #include "network-web/adblock/adblockmanager.h"cxx . . $ `<file>/src/librssguard/network-web/adblock/adblockmanager.h`/ |
| 13 | #include "network-web/webfactory.h"cxx . . $ `<file>/src/librssguard/network-web/webfactory.h`/ |
| 14 | |
| 15 | #include <QMenu> |
| 16 | #include <QMessageBox> |
| 17 | #include <QTimer> |
| 18 | |
| 19 | AdBlockDialogcxx . . $ AdBlockDialog#::AdBlockDialogcxx . . $ AdBlockDialog#AdBlockDialog(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) : QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).(parent), m_managercxx . . $ AdBlockDialog#m_manager.(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->webcxx . . $ Application#web(ad68e16c93841931).()->adBlockcxx . . $ WebFactory#adBlock(dd9ae43777736cac).()), m_loadedcxx . . $ AdBlockDialog#m_loaded.(false) { |
| 20 | m_uicxx . . $ AdBlockDialog#m_ui..setupUicxx . . $ Ui_AdBlockDialog#setupUi(d194de0c0f68c28b).(this); |
| 21 | m_uicxx . . $ AdBlockDialog#m_ui..m_cbEnablecxx . . $ Ui_AdBlockDialog#m_cbEnable.->setCheckedcxx . . $ QAbstractButton#setChecked(b45ddcbc8423892c).(m_managercxx . . $ AdBlockDialog#m_manager.->isEnabledcxx . . $ AdBlockManager#isEnabled(50ce9a9e25b4a850).()); |
| 22 | |
| 23 | GuiUtilitiescxx . . $ GuiUtilities#::applyDialogPropertiescxx . . $ GuiUtilities#applyDialogProperties(6e9150cdaac92159).(*this, |
| 24 | qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->miscIconcxx . . $ IconFactory#miscIcon(ef5a0418eb2d5e9b).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(ADBLOCK_ICON_ACTIVEcxx . . $ `src/librssguard/definitions/definitions.h:22:9`!)), |
| 25 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("AdBlock configuration")); |
| 26 | |
| 27 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(m_uicxx . . $ AdBlockDialog#m_ui..m_btnHelpcxx . . $ Ui_AdBlockDialog#m_btnHelp., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, [=]() { |
| 28 | qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->webcxx . . $ Application#web(ad68e16c93841931).()->openUrlInExternalBrowsercxx . . $ WebFactory#openUrlInExternalBrowser(dd54f9efb9153ea5).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(ADBLOCK_HOWTOcxx . . $ `src/librssguard/definitions/definitions.h:21:9`!)); |
| 29 | }); |
| 30 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(m_uicxx . . $ AdBlockDialog#m_ui..m_cbEnablecxx . . $ Ui_AdBlockDialog#m_cbEnable., &QCheckBoxcxx . . $ QCheckBox#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &AdBlockDialogcxx . . $ AdBlockDialog#::enableAdBlockcxx . . $ AdBlockDialog#enableAdBlock(b45ddcbc8423892c).); |
| 31 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(m_managercxx . . $ AdBlockDialog#m_manager., &AdBlockManagercxx . . $ AdBlockManager#::enabledChangedcxx . . $ AdBlockManager#enabledChanged(64b12fddccd2c229)., this, &AdBlockDialogcxx . . $ AdBlockDialog#::onAdBlockEnabledChangedcxx . . $ AdBlockDialog#onAdBlockEnabledChanged(5538ff71ffff3ce).); |
| 32 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(m_managercxx . . $ AdBlockDialog#m_manager., &AdBlockManagercxx . . $ AdBlockManager#::processTerminatedcxx . . $ AdBlockManager#processTerminated(49f6e7a06ebc5aa8)., this, &AdBlockDialogcxx . . $ AdBlockDialog#::onAdBlockProcessTerminatedcxx . . $ AdBlockDialog#onAdBlockProcessTerminated(49f6e7a06ebc5aa8).); |
| 33 | |
| 34 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->labelcxx . . $ LabelWithStatus#label(a31910c5384f8d7e).()->setWordWrapcxx . . $ QLabel#setWordWrap(b45ddcbc8423892c).(true); |
| 35 | m_uicxx . . $ AdBlockDialog#m_ui..m_btnHelpcxx . . $ Ui_AdBlockDialog#m_btnHelp.->setIconcxx . . $ QAbstractButton#setIcon(71dcdac178620ed6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("help-about"))); |
| 36 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->setStatuscxx . . $ LabelWithStatus#setStatus(810dc34ace2b0f32).(WidgetWithStatuscxx . . $ WidgetWithStatus#::StatusTypecxx . . $ WidgetWithStatus#StatusType#::Informationcxx . . $ WidgetWithStatus#StatusType#Information., |
| 37 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("No additional info."), |
| 38 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("No additional info.")); |
| 39 | |
| 40 | loadDialogcxx . . $ AdBlockDialog#loadDialog(49f6e7a06ebc5aa8).(); |
| 41 | m_uicxx . . $ AdBlockDialog#m_ui..m_buttonBoxcxx . . $ Ui_AdBlockDialog#m_buttonBox.->setFocuscxx . . $ QWidget#setFocus(49f6e7a06ebc5aa8).(); |
| 42 | } |
| 43 | |
| 44 | void AdBlockDialogcxx . . $ AdBlockDialog#::saveOnClosecxx . . $ AdBlockDialog#saveOnClose(49f6e7a06ebc5aa8).() { |
| 45 | m_managercxx . . $ AdBlockDialog#m_manager.->setFilterListscxx . . $ AdBlockManager#setFilterLists(4c9f0945b8b27034).(m_uicxx . . $ AdBlockDialog#m_ui..m_txtPredefinedcxx . . $ Ui_AdBlockDialog#m_txtPredefined.->toPlainTextcxx . . $ QPlainTextEdit#toPlainText(6ef7b6c27b00b43d).().splitcxx . . $ QString#split(404c44787f61d3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"))); |
| 46 | m_managercxx . . $ AdBlockDialog#m_manager.->setCustomFilterscxx . . $ AdBlockManager#setCustomFilters(4c9f0945b8b27034).(m_uicxx . . $ AdBlockDialog#m_ui..m_txtCustomcxx . . $ Ui_AdBlockDialog#m_txtCustom.->toPlainTextcxx . . $ QPlainTextEdit#toPlainText(6ef7b6c27b00b43d).().splitcxx . . $ QString#split(404c44787f61d3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"))); |
| 47 | |
| 48 | try { |
| 49 | auto enabl = m_managercxx . . $ AdBlockDialog#m_manager.->isEnabledcxx . . $ AdBlockManager#isEnabled(50ce9a9e25b4a850).(); |
| 50 | |
| 51 | m_managercxx . . $ AdBlockDialog#m_manager.->setEnabledcxx . . $ AdBlockManager#setEnabled(b45ddcbc8423892c).(false); |
| 52 | |
| 53 | if (enabl) { |
| 54 | m_managercxx . . $ AdBlockDialog#m_manager.->setEnabledcxx . . $ AdBlockManager#setEnabled(b45ddcbc8423892c).(enabl); |
| 55 | } |
| 56 | } |
| 57 | catch (const ApplicationExceptioncxx . . $ ApplicationException#& ex) { |
| 58 | qCriticalNNcxx . . $ `src/librssguard/definitions/definitions.h:421:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_ADBLOCKcxx . . $ `src/librssguard/definitions/definitions.h:169:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Failed to enable AdBlock, error:" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(ex.message()); |
| 59 | |
| 60 | MsgBoxcxx . . $ MsgBox#::showcxx . . $ MsgBox#show(699e792c6fa2d501).(this, |
| 61 | QMessageBoxcxx . . $ QMessageBox#::Iconcxx . . $ QMessageBox#Icon#::Criticalcxx . . $ QMessageBox#Critical., |
| 62 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("Cannot enable AdBlock"), |
| 63 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("There is some error in AdBlock component and it cannot be enabled. " |
| 64 | "Check error message below (or application debug log) for more information."), |
| 65 | {cxx . . $ QString#QString(ced63f7c635d850d).}, |
| 66 | ex.messagecxx . . $ ApplicationException#message(6ef7b6c27b00b43d).()); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void AdBlockDialogcxx . . $ AdBlockDialog#::enableAdBlockcxx . . $ AdBlockDialog#enableAdBlock(b45ddcbc8423892c).(bool enable) { |
| 71 | qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->setValuecxx . . $ Settings#setValue(365356ede4ebaabb).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(AdBlock), AdBlockcxx . . $ AdBlock/::AdBlockEnabledcxx . . $ AdBlock/AdBlockEnabled., enablecxx . . $ QVariant#QVariant(9f0ba574c1c44ffc).); |
| 72 | |
| 73 | m_managercxx . . $ AdBlockDialog#m_manager.->setFilterListscxx . . $ AdBlockManager#setFilterLists(4c9f0945b8b27034).(m_uicxx . . $ AdBlockDialog#m_ui..m_txtPredefinedcxx . . $ Ui_AdBlockDialog#m_txtPredefined.->toPlainTextcxx . . $ QPlainTextEdit#toPlainText(6ef7b6c27b00b43d).().splitcxx . . $ QString#split(404c44787f61d3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"))); |
| 74 | m_managercxx . . $ AdBlockDialog#m_manager.->setCustomFilterscxx . . $ AdBlockManager#setCustomFilters(4c9f0945b8b27034).(m_uicxx . . $ AdBlockDialog#m_ui..m_txtCustomcxx . . $ Ui_AdBlockDialog#m_txtCustom.->toPlainTextcxx . . $ QPlainTextEdit#toPlainText(6ef7b6c27b00b43d).().splitcxx . . $ QString#split(404c44787f61d3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"))); |
| 75 | |
| 76 | try { |
| 77 | m_managercxx . . $ AdBlockDialog#m_manager.->setEnabledcxx . . $ AdBlockManager#setEnabled(b45ddcbc8423892c).(enable); |
| 78 | } |
| 79 | catch (const ApplicationExceptioncxx . . $ ApplicationException#& ex) { |
| 80 | qCriticalNNcxx . . $ `src/librssguard/definitions/definitions.h:421:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_ADBLOCKcxx . . $ `src/librssguard/definitions/definitions.h:169:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Test of configuration failed:" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(ex.message()); |
| 81 | |
| 82 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->setStatuscxx . . $ LabelWithStatus#setStatus(810dc34ace2b0f32).(WidgetWithStatuscxx . . $ WidgetWithStatus#::StatusTypecxx . . $ WidgetWithStatus#StatusType#::Errorcxx . . $ WidgetWithStatus#StatusType#Error., |
| 83 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("There is error, check application log for more details and " |
| 84 | "head to online documentation. Also make sure that Node.js is installed." |
| 85 | "\n\nError: %1") |
| 86 | .argcxx . . $ QString#arg(ad0bca07273edcc2).(ex.messagecxx . . $ ApplicationException#message(6ef7b6c27b00b43d).()), |
| 87 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("ERROR!")); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | void AdBlockDialogcxx . . $ AdBlockDialog#::onAdBlockEnabledChangedcxx . . $ AdBlockDialog#onAdBlockEnabledChanged(5538ff71ffff3ce).(bool enabled, const QStringcxx . . $ QString#& message) { |
| 92 | m_uicxx . . $ AdBlockDialog#m_ui..m_cbEnablecxx . . $ Ui_AdBlockDialog#m_cbEnable.->setCheckedcxx . . $ QAbstractButton#setChecked(b45ddcbc8423892c).(enabled); |
| 93 | |
| 94 | if (enabled) { |
| 95 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->setStatuscxx . . $ LabelWithStatus#setStatus(810dc34ace2b0f32).(WidgetWithStatuscxx . . $ WidgetWithStatus#::StatusTypecxx . . $ WidgetWithStatus#StatusType#::Okcxx . . $ WidgetWithStatus#StatusType#Ok., |
| 96 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("It seems your AdBlock runs fine, but wait few seconds to be sure."), |
| 97 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("OK!")); |
| 98 | } |
| 99 | else if (!message.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 100 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->setStatuscxx . . $ LabelWithStatus#setStatus(810dc34ace2b0f32).(WidgetWithStatuscxx . . $ WidgetWithStatus#::StatusTypecxx . . $ WidgetWithStatus#StatusType#::Warningcxx . . $ WidgetWithStatus#StatusType#Warning., message, message); |
| 101 | } |
| 102 | else { |
| 103 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->setStatuscxx . . $ LabelWithStatus#setStatus(810dc34ace2b0f32).(WidgetWithStatuscxx . . $ WidgetWithStatus#::StatusTypecxx . . $ WidgetWithStatus#StatusType#::Informationcxx . . $ WidgetWithStatus#StatusType#Information., |
| 104 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("No additional info."), |
| 105 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("No additional info.")); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | void AdBlockDialogcxx . . $ AdBlockDialog#::onAdBlockProcessTerminatedcxx . . $ AdBlockDialog#onAdBlockProcessTerminated(49f6e7a06ebc5aa8).() { |
| 110 | m_uicxx . . $ AdBlockDialog#m_ui..m_cbEnablecxx . . $ Ui_AdBlockDialog#m_cbEnable.->setCheckedcxx . . $ QAbstractButton#setChecked(b45ddcbc8423892c).(false); |
| 111 | m_uicxx . . $ AdBlockDialog#m_ui..m_lblTestResultcxx . . $ Ui_AdBlockDialog#m_lblTestResult.->setStatuscxx . . $ LabelWithStatus#setStatus(810dc34ace2b0f32).(WidgetWithStatuscxx . . $ WidgetWithStatus#::StatusTypecxx . . $ WidgetWithStatus#StatusType#::Errorcxx . . $ WidgetWithStatus#StatusType#Error., |
| 112 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("There is error, check application log for more details and " |
| 113 | "head to online documentation."), |
| 114 | trcxx . . $ AdBlockDialog#tr(75d9f1c324b4579d).("ERROR!")); |
| 115 | } |
| 116 | |
| 117 | void AdBlockDialogcxx . . $ AdBlockDialog#::loadDialogcxx . . $ AdBlockDialog#loadDialog(49f6e7a06ebc5aa8).() { |
| 118 | m_uicxx . . $ AdBlockDialog#m_ui..m_txtCustomcxx . . $ Ui_AdBlockDialog#m_txtCustom.->setPlainTextcxx . . $ QPlainTextEdit#setPlainText(3520e46b33348bf6).(m_managercxx . . $ AdBlockDialog#m_manager.->customFilterscxx . . $ AdBlockManager#customFilters(2b25566bdf736d18).().joincxx . . $ QListSpecialMethods#join(5555d9024dcf93fb).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"))); |
| 119 | m_uicxx . . $ AdBlockDialog#m_ui..m_txtPredefinedcxx . . $ Ui_AdBlockDialog#m_txtPredefined.->setPlainTextcxx . . $ QPlainTextEdit#setPlainText(3520e46b33348bf6).(m_managercxx . . $ AdBlockDialog#m_manager.->filterListscxx . . $ AdBlockManager#filterLists(2b25566bdf736d18).().joincxx . . $ QListSpecialMethods#join(5555d9024dcf93fb).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"))); |
| 120 | } |
| 121 | |
| 122 | void AdBlockDialogcxx . . $ AdBlockDialog#::hideEventcxx . . $ AdBlockDialog#hideEvent(6177daf7b5c7b9b3).(QHideEventcxx . . $ QHideEvent#* event) { |
| 123 | QDialogcxx . . $ QDialog#::hideEventcxx . . $ QWidget#hideEvent(6177daf7b5c7b9b3).(event); |
| 124 | |
| 125 | saveOnClosecxx . . $ AdBlockDialog#saveOnClose(49f6e7a06ebc5aa8).(); |
| 126 | } |