Skip to content

Commit

Permalink
feat: add setting to disable blacklist warning pop-up (fix #3088)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jan 23, 2024
1 parent 9adb12f commit 57570b3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/gui/src/settings/options-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ OptionsWindow::OptionsWindow(Profile *profile, ThemeLoader *themeLoader, QWidget

// Blacklist
ui->textBlacklist->setPlainText(profile->getBlacklist().toString());
ui->checkWarnBlacklisted->setChecked(settings->value("warnblacklisted", true).toBool());
ui->checkDownloadBlacklisted->setChecked(settings->value("downloadblacklist", false).toBool());
new SearchSyntaxHighlighter(false, ui->textBlacklist->document());

Expand Down Expand Up @@ -1159,6 +1160,7 @@ void OptionsWindow::save()
blacklist.add(tags.trimmed().split(' ', Qt::SkipEmptyParts));
}
m_profile->setBlacklistedTags(blacklist);
settings->setValue("warnblacklisted", ui->checkWarnBlacklisted->isChecked());
settings->setValue("downloadblacklist", ui->checkDownloadBlacklisted->isChecked());

// Ignored tags
Expand Down
33 changes: 22 additions & 11 deletions src/gui/src/settings/options-window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -5007,21 +5007,16 @@
<item>
<widget class="QCheckBox" name="checkHideBlacklisted">
<property name="text">
<string>Ignore images containing a blacklisted tag</string>
<string>Hide images containing a blacklisted tag from results</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelHideBlacklisted">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<widget class="QCheckBox" name="checkWarnBlacklisted">
<property name="text">
<string>Images containing a blacklisted tag will not be displayed in the results if this box is checked. Else, a confirmation will be asked before showing one of these images.</string>
<string>Warn before opening images containing a blacklisted tag</string>
</property>
<property name="wordWrap">
<property name="checked">
<bool>true</bool>
</property>
</widget>
Expand Down Expand Up @@ -6049,8 +6044,24 @@
<y>263</y>
</hint>
<hint type="destinationlabel">
<x>498</x>
<y>291</y>
<x>718</x>
<y>325</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkHideBlacklisted</sender>
<signal>toggled(bool)</signal>
<receiver>checkWarnBlacklisted</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>523</x>
<y>507</y>
</hint>
<hint type="destinationlabel">
<x>515</x>
<y>522</y>
</hint>
</hints>
</connection>
Expand Down
12 changes: 7 additions & 5 deletions src/gui/src/tabs/search-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,11 +1089,13 @@ void SearchTab::openImage(int id)

const QSharedPointer<Image> &image = m_images.at(id);

QStringList detected = m_profile->getBlacklist().match(image->tokens(m_profile));
if (!detected.isEmpty()) {
const int reply = QMessageBox::question(parentWidget(), tr("Blacklist"), tr("%n tag figuring in the blacklist detected in this image: %1. Do you want to display it anyway?", "", detected.size()).arg(detected.join(", ")), QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::No) {
return;
if (m_settings->value("warnblacklisted", true).toBool()) {
QStringList detected = m_profile->getBlacklist().match(image->tokens(m_profile));
if (!detected.isEmpty()) {
const int reply = QMessageBox::question(parentWidget(), tr("Blacklist"), tr("%n tag figuring in the blacklist detected in this image: %1. Do you want to display it anyway?", "", detected.size()).arg(detected.join(", ")), QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::No) {
return;
}
}
}

Expand Down

0 comments on commit 57570b3

Please # to comment.