From e4258160cd88f89005228eec70e08ce470b5e61c Mon Sep 17 00:00:00 2001 From: pajlada Date: Sun, 10 Dec 2023 13:28:31 +0100 Subject: [PATCH] Fixed "Yes, don't ask again" image uploader prompt not working on macOS (#5011) --- CHANGELOG.md | 1 + src/widgets/splits/Split.cpp | 36 +++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e13735bc3..dc1805ed6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ - Bugfix: Fixed lookahead/-behind not working in _Ignores_. (#4965) - Bugfix: Fixed Image Uploader accidentally deleting images with some hosts when link resolver was enabled. (#4971) - Bugfix: Fixed rare crash with Image Uploader when closing a split right after starting an upload. (#4971) +- Bugfix: Fixed an issue on macOS where the image uploader would keep prompting the user even after they clicked "Yes, don't ask again". (#5011) - Bugfix: Hide the Usercard button in the User Info Popup when in special channels. (#4972) - Bugfix: Fixed support for Windows 11 Snap layouts. (#4994) - Bugfix: Fixed some windows appearing between screens. (#4797) diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 90ab8bd46..656aa18e4 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -381,7 +381,9 @@ Split::Split(QWidget *parent) std::ignore = this->input_->ui_.textEdit->imagePasted.connect( [this](const QMimeData *source) { if (!getSettings()->imageUploaderEnabled) + { return; + } if (getSettings()->askOnImageUpload.getValue()) { @@ -392,21 +394,37 @@ Split::Split(QWidget *parent) "You are uploading an image to a 3rd party service not in " "control of the Chatterino team. You may not 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); + auto *cancel = msgBox.addButton(QMessageBox::Cancel); + auto *yes = msgBox.addButton(QMessageBox::Yes); + auto *yesDontAskAgain = 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 + msgBox.exec(); + + auto *clickedButton = msgBox.clickedButton(); + if (clickedButton == yesDontAskAgain) { getSettings()->askOnImageUpload.setValue(false); } + else if (clickedButton == yes) + { + // Continue with image upload + } + else if (clickedButton == cancel) + { + // Not continuing with image upload + return; + } + else + { + // An unknown "button" was pressed - handle it as if cancel was pressed + // cancel is already handled as the "escape" option, so this should never happen + qCWarning(chatterinoImageuploader) + << "Unhandled button pressed:" << clickedButton; + return; + } } QPointer edit = this->input_->ui_.textEdit; getApp()->imageUploader->upload(source, this->getChannel(), edit);