Add confirmation box for uploads.

This commit is contained in:
Mm2PL 2020-05-09 13:14:41 +02:00
parent 84007d2edb
commit 2b1c9794b7
No known key found for this signature in database
GPG key ID: 1C400DA5602DE62E
3 changed files with 31 additions and 4 deletions

View file

@ -291,6 +291,7 @@ public:
"/misc/attachExtensionToAnyProcess", false};
BoolSetting hideViewerCountAndDuration = {
"/misc/hideViewerCountAndDuration", false};
BoolSetting askOnImageUpload = {"/misc/askOnImageUpload", true};
/// Debug
BoolSetting showUnhandledIrcMessages = {"/debug/showUnhandledIrcMessages",

View file

@ -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(

View file

@ -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);
}