Fixed "Yes, don't ask again" image uploader prompt not working on macOS (#5011)

This commit is contained in:
pajlada 2023-12-10 13:28:31 +01:00 committed by GitHub
parent 13dc306506
commit e4258160cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View file

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

View file

@ -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<ResizingTextEdit> edit = this->input_->ui_.textEdit;
getApp()->imageUploader->upload(source, this->getChannel(), edit);