From 87c0ff76e7146731c3460b41e2ab7865b0e178dc Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 8 Sep 2019 14:59:51 +0200 Subject: [PATCH] added setting to open links in incognito by default --- src/singletons/Settings.hpp | 1 + src/widgets/helper/ChannelView.cpp | 15 ++++++--------- src/widgets/settingspages/GeneralPage.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 2ab20d06d..c4f6bac0e 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -204,6 +204,7 @@ public: BoolSetting loadTwitchMessageHistoryOnConnect = { "/misc/twitch/loadMessageHistoryOnConnect", true}; IntSetting emotesTooltipPreview = {"/misc/emotesTooltipPreview", 0}; + BoolSetting openLinksIncognito = {"/misc/openLinksIncognito", 0}; QStringSetting cachePath = {"/cache/path", ""}; diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 29548b6cc..bf49c85cf 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1528,14 +1528,8 @@ void ChannelView::addContextMenuItems( QString url = hoveredElement->getLink().value; // open link - bool incognitoByDefault = supportsIncognitoLinks() && - layout->getMessage()->loginName == "hemirt"; - menu->addAction("Open link", [url, incognitoByDefault] { - if (incognitoByDefault) - openLinkIncognito(url); - else - QDesktopServices::openUrl(QUrl(url)); - }); + menu->addAction("Open link", + [url] { QDesktopServices::openUrl(QUrl(url)); }); // open link default if (supportsIncognitoLinks()) { @@ -1701,7 +1695,10 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, case Link::Url: { - QDesktopServices::openUrl(QUrl(link.value)); + if (getSettings()->openLinksIncognito && supportsIncognitoLinks()) + openLinkIncognito(link.value); + else + QDesktopServices::openUrl(QUrl(link.value)); } break; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 934d4f432..0d5ebcdfa 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -11,6 +11,7 @@ #include "singletons/WindowManager.hpp" #include "util/FuzzyConvert.hpp" #include "util/Helpers.hpp" +#include "util/IncognitoBrowser.hpp" #include "widgets/BaseWindow.hpp" #include "widgets/helper/Line.hpp" @@ -377,6 +378,11 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addTitle("Miscellaneous"); + if (supportsIncognitoLinks()) + { + layout.addCheckbox("Open links in incognito/private mode", + s.openLinksIncognito); + } layout.addCheckbox("Show moderation messages", s.hideModerationActions, true); layout.addCheckbox("Random username color for users who never set a color",