From 2b1c9794b7dc9a9bcc1951de6627ccb6f4b59bca Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sat, 9 May 2020 13:14:41 +0200 Subject: [PATCH] Add confirmation box for uploads. --- src/singletons/Settings.hpp | 1 + src/widgets/settingspages/GeneralPage.cpp | 3 +++ src/widgets/splits/Split.cpp | 31 ++++++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 1d56e5787..11927120a 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -291,6 +291,7 @@ public: "/misc/attachExtensionToAnyProcess", false}; BoolSetting hideViewerCountAndDuration = { "/misc/hideViewerCountAndDuration", false}; + BoolSetting askOnImageUpload = {"/misc/askOnImageUpload", true}; /// Debug BoolSetting showUnhandledIrcMessages = {"/debug/showUnhandledIrcMessages", diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 26f35cdbe..fb8fd1524 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -545,6 +545,9 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addCheckbox( "Hide viewercount and stream length while hovering the split", s.hideViewerCountAndDuration); + layout.addCheckbox( + "Ask for confirmation when uploading an image to i.nuuls.com", + s.askOnImageUpload); layout.addTitle("Cache"); layout.addDescription( diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index c331f3c23..84048191b 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -207,10 +207,33 @@ Split::Split(QWidget *parent) [this] { this->focused.invoke(); }); this->input_->ui_.textEdit->focusLost.connect( [this] { this->focusLost.invoke(); }); - this->input_->ui_.textEdit->imagePasted.connect( - [this](const QMimeData *source) { - upload(source, this->getChannel(), *this->input_->ui_.textEdit); - }); + this->input_->ui_.textEdit->imagePasted.connect([this](const QMimeData + *source) { + if (getSettings()->askOnImageUpload.getValue()) + { + QMessageBox msgBox; + msgBox.setText("Image upload"); + msgBox.setInformativeText( + "You are uploading an image to i.nuuls.com. You won't be able " + "to remove the image from the site. Are you okay with this?"); + msgBox.addButton(QMessageBox::Cancel); + msgBox.addButton(QMessageBox::Yes); + msgBox.addButton("Yes, don't ask again", QMessageBox::YesRole); + + msgBox.setDefaultButton(QMessageBox::Yes); + + auto picked = msgBox.exec(); + if (picked == QMessageBox::Cancel) + { + return; + } + else if (picked == 0) // don't ask again button + { + getSettings()->askOnImageUpload.setValue(false); + } + } + upload(source, this->getChannel(), *this->input_->ui_.textEdit); + }); setAcceptDrops(true); }