diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 4a31f822d..7a3ba77fb 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -1,6 +1,9 @@ 3.4.0 ————— +Added: +▪ Fixed #76, now user can choose to "not show the dialog again" when opening hyperlink from message previewer. This only concerns the lite version of RSS Guard which uses simpler text component for message previewing. + Changed: ▪ (Linux only) Primary user data/config storage is now undex $HOME/.config. XDG_CONFIG_HOME variable is respected. If old user data is detected, then old user data path is used. ▪ RSS Guard now uses "_" character as localization file names separator. (issue #75) diff --git a/src/gui/messagebox.cpp b/src/gui/messagebox.cpp index eef3b1a8c..92dc7b674 100755 --- a/src/gui/messagebox.cpp +++ b/src/gui/messagebox.cpp @@ -25,6 +25,7 @@ #include #include #include +#include MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) { @@ -41,6 +42,19 @@ void MessageBox::setIcon(QMessageBox::Icon icon) { setIconPixmap(iconForStatus(icon).pixmap(icon_size, icon_size)); } +void MessageBox::setCheckBox(QMessageBox *msg_box, const QString &text, bool *data) { + // Add "don't show this again checkbox. + QCheckBox *check_box = new QCheckBox(msg_box); + + check_box->setChecked(*data); + check_box->setText(text); + connect(check_box, &QCheckBox::toggled, [=](bool checked) { + *data = checked; + }); + + msg_box->setCheckBox(check_box); +} + QIcon MessageBox::iconForStatus(QMessageBox::Icon status) { switch (status) { case QMessageBox::Information: @@ -68,7 +82,8 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent, const QString &informative_text, const QString &detailed_text, QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton default_button) { + QMessageBox::StandardButton default_button, + bool *dont_show_again) { // Create and find needed components. MessageBox msg_box(parent); @@ -81,6 +96,10 @@ QMessageBox::StandardButton MessageBox::show(QWidget *parent, msg_box.setStandardButtons(buttons); msg_box.setDefaultButton(default_button); + if (dont_show_again != nullptr) { + MessageBox::setCheckBox(&msg_box, tr("Do not show this dialog again."), dont_show_again); + } + // Display it. if (msg_box.exec() == -1) { return QMessageBox::Cancel; diff --git a/src/gui/messagebox.h b/src/gui/messagebox.h index e1e610ca3..723c6bb43 100755 --- a/src/gui/messagebox.h +++ b/src/gui/messagebox.h @@ -33,6 +33,8 @@ class MessageBox : public QMessageBox { // Custom icon setting. void setIcon(Icon icon); + static void setCheckBox(QMessageBox *msg_box, const QString &text, bool *data); + // Displays custom message box. static QMessageBox::StandardButton show(QWidget *parent, QMessageBox::Icon icon, @@ -41,7 +43,8 @@ class MessageBox : public QMessageBox { const QString &informative_text = QString(), const QString &detailed_text = QString(), QMessageBox::StandardButtons buttons = QMessageBox::Ok, - QMessageBox::StandardButton default_button = QMessageBox::Ok); + QMessageBox::StandardButton default_button = QMessageBox::Ok, + bool *dont_show_again = nullptr); static QIcon iconForStatus(QMessageBox::Icon status); }; diff --git a/src/gui/messagepreviewer.cpp b/src/gui/messagepreviewer.cpp index f806c3ff2..3ec5a701a 100755 --- a/src/gui/messagepreviewer.cpp +++ b/src/gui/messagepreviewer.cpp @@ -32,29 +32,45 @@ void MessagePreviewer::createConnections() { connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl &url) { if (!url.isEmpty()) { - // User clicked some URL. Open it in external browser or download? - MessageBox box(qApp->mainForm()); + bool open_externally_now = qApp->settings()->value(GROUP(Browser), + SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool(); - box.setText(tr("You clicked some link. You can download the link contents or open it in external web browser.")); - box.setInformativeText(tr("What action do you want to take?")); - box.setDetailedText(url.toString()); - QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::ActionRole); - QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::ActionRole); - QAbstractButton *btn_cancel = box.addButton(QMessageBox::Cancel); - - box.setDefaultButton(QMessageBox::Cancel); - box.exec(); - - if (box.clickedButton() == btn_open) { + if (open_externally_now) { WebFactory::instance()->openUrlInExternalBrowser(url.toString()); } - else if (box.clickedButton() == btn_download) { - qApp->downloadManager()->download(url); - } + else { + // User clicked some URL. Open it in external browser or download? + MessageBox box(qApp->mainForm()); - btn_download->deleteLater(); - btn_open->deleteLater(); - btn_cancel->deleteLater(); + box.setText(tr("You clicked some link. You can download the link contents or open it in external web browser.")); + box.setInformativeText(tr("What action do you want to take?")); + box.setDetailedText(url.toString()); + QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::ActionRole); + QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::ActionRole); + QAbstractButton *btn_cancel = box.addButton(QMessageBox::Cancel); + + bool always; + MessageBox::setCheckBox(&box, tr("Alway open links in external browser."), &always); + + box.setDefaultButton(QMessageBox::Cancel); + box.exec(); + + if (box.clickedButton() != box.button(QMessageBox::Cancel)) { + // Store selected checkbox value. + qApp->settings()->setValue(GROUP(Browser), Browser::OpenLinksInExternalBrowserRightAway, always); + } + + if (box.clickedButton() == btn_open) { + WebFactory::instance()->openUrlInExternalBrowser(url.toString()); + } + else if (box.clickedButton() == btn_download) { + qApp->downloadManager()->download(url); + } + + btn_download->deleteLater(); + btn_open->deleteLater(); + btn_cancel->deleteLater(); + } } else { MessageBox::show(qApp->mainForm(), QMessageBox::Warning, tr("Incorrect link"), diff --git a/src/gui/settings/settingsbrowsermail.cpp b/src/gui/settings/settingsbrowsermail.cpp index 997dc491d..9d4e2ca82 100755 --- a/src/gui/settings/settingsbrowsermail.cpp +++ b/src/gui/settings/settingsbrowsermail.cpp @@ -29,6 +29,12 @@ SettingsBrowserMail::SettingsBrowserMail(Settings *settings, QWidget *parent) : SettingsPanel(settings, parent), m_ui(new Ui::SettingsBrowserMail) { m_ui->setupUi(this); +#if defined(USE_WEBENGINE) + m_ui->m_checkOpenLinksInExternal->setVisible(false); +#else + connect(m_ui->m_checkOpenLinksInExternal, &QCheckBox::stateChanged, this, &SettingsBrowserMail::dirtifySettings); +#endif + connect(m_ui->m_cmbProxyType, static_cast(&QComboBox::currentIndexChanged), this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtProxyHost, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); connect(m_ui->m_txtProxyPassword, &QLineEdit::textChanged, this, &SettingsBrowserMail::dirtifySettings); @@ -127,6 +133,11 @@ void SettingsBrowserMail::selectEmailExecutable() { void SettingsBrowserMail::loadSettings() { onBeginLoadSettings(); +#if !defined(USE_WEBENGINE) + m_ui->m_checkOpenLinksInExternal->setChecked(settings()->value(GROUP(Browser), + SETTING(Browser::OpenLinksInExternalBrowserRightAway)).toBool()); +#endif + // Load settings of web browser GUI. m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); m_ui->m_txtExternalBrowserExecutable->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString()); @@ -159,6 +170,10 @@ void SettingsBrowserMail::loadSettings() { void SettingsBrowserMail::saveSettings() { onBeginSaveSettings(); +#if !defined(USE_WEBENGINE) + settings()->setValue(GROUP(Browser), Browser::OpenLinksInExternalBrowserRightAway, m_ui->m_checkOpenLinksInExternal->isChecked()); +#endif + // Save settings of GUI of web browser. settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text()); diff --git a/src/gui/settings/settingsbrowsermail.ui b/src/gui/settings/settingsbrowsermail.ui index 35e5dc807..26fb77962 100755 --- a/src/gui/settings/settingsbrowsermail.ui +++ b/src/gui/settings/settingsbrowsermail.ui @@ -33,7 +33,7 @@ External web browser - + <html><head/><body><p>If unchecked, then default system-wide web browser is used.</p></body></html> @@ -122,6 +122,13 @@ + + + + Always open links from simple internal text browser in external web browser + + + diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 3529cb607..3c59dbc02 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -246,6 +246,9 @@ DKEY Keyboard::ID = "keyboard"; // Web browser. DKEY Browser::ID = "browser"; +DKEY Browser::OpenLinksInExternalBrowserRightAway = "open_link_externally_wo_confirmation"; +DVALUE(bool) Browser::OpenLinksInExternalBrowserRightAwayDef = false; + DKEY Browser::CustomExternalBrowserEnabled = "custom_external_browser"; DVALUE(bool) Browser::CustomExternalBrowserEnabledDef = false; diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h index 55c157173..08c22590b 100755 --- a/src/miscellaneous/settings.h +++ b/src/miscellaneous/settings.h @@ -276,6 +276,9 @@ namespace Keyboard { namespace Browser { KEY ID; + KEY OpenLinksInExternalBrowserRightAway; + VALUE(bool) OpenLinksInExternalBrowserRightAwayDef; + KEY CustomExternalBrowserEnabled; VALUE(bool) CustomExternalBrowserEnabledDef;