diff --git a/src/lib/other/sitesettingsmanager.cpp b/src/lib/other/sitesettingsmanager.cpp index 3ee9492a9..34f81cf2b 100644 --- a/src/lib/other/sitesettingsmanager.cpp +++ b/src/lib/other/sitesettingsmanager.cpp @@ -114,21 +114,6 @@ void SiteSettingsManager::setOption(const QWebEnginePage::Feature& feature, cons setOption(option, url, value); } -bool SiteSettingsManager::getOption(const SiteSettingsManager::PageOptions option, const QUrl& url) -{ - auto perm = getPermission(option, url); - - if (perm == Allow) { - return true; - } - else if (perm == Deny) { - return false; - } - else { - return getDefaultOptionValue(option); - } -} - SiteSettingsManager::Permission SiteSettingsManager::getPermission(const SiteSettingsManager::PageOptions option, const QUrl& url) { QString column = optionToSqlColumn(option); @@ -145,11 +130,15 @@ SiteSettingsManager::Permission SiteSettingsManager::getPermission(const SiteSet if (query.next()) { int allow_option = query.value(column).toInt(); - if (allow_option == 0) { - return Default; - } - else { - return (allow_option == 1) ? Allow : Deny; + switch (allow_option) { + case Allow: + return Allow; + case Deny: + return Deny; + case Ask: + return Ask; + default: + return Default; } } diff --git a/src/lib/other/sitesettingsmanager.h b/src/lib/other/sitesettingsmanager.h index 749f6b077..0bd0489a3 100644 --- a/src/lib/other/sitesettingsmanager.h +++ b/src/lib/other/sitesettingsmanager.h @@ -40,6 +40,7 @@ public: Default = 0, Allow = 1, Deny = 2, + Ask = 3, }; enum PageOptions { @@ -90,7 +91,6 @@ public: void setJavascript(const QUrl &url, const int value); void setImages(const QUrl &url, const int value); - bool getOption(const PageOptions option, const QUrl &url); Permission getPermission(const PageOptions option, const QUrl &url); Permission getPermission(const QWebEnginePage::Feature &feature, const QUrl &url); diff --git a/src/lib/tools/html5permissions/html5permissionsdialog.cpp b/src/lib/tools/html5permissions/html5permissionsdialog.cpp index e89a9183c..eda0bb1fa 100644 --- a/src/lib/tools/html5permissions/html5permissionsdialog.cpp +++ b/src/lib/tools/html5permissions/html5permissionsdialog.cpp @@ -89,11 +89,20 @@ void HTML5PermissionsDialog::createEntry(const HTML5PermissionsDialog::SiteData& auto* item = new QTreeWidgetItem(ui->treeWidget); item->setText(0, siteData.host); - if (siteData.perm == SiteSettingsManager::Allow) { - item->setText(1, tr("Allow")); - } - else { - item->setText(1, tr("Deny")); + switch (siteData.perm) { + case SiteSettingsManager::Allow: + item->setText(1, tr("Allow")); + break; + case SiteSettingsManager::Deny: + item->setText(1, tr("Deny")); + break; + case SiteSettingsManager::Ask: + item->setText(1, tr("Ask")); + break; + default: + Q_UNREACHABLE(); + item->setText(1, tr("Default")); + break; } item->setData(0, Qt::UserRole + 10, siteData.id); ui->treeWidget->addTopLevelItem(item); @@ -149,7 +158,8 @@ void HTML5PermissionsDialog::saveSettings() for (int i = 0; i < 8; ++i) { const QWebEnginePage::Feature feature = indexToFeature(i); const QString column = mApp->siteSettingsManager()->sqlColumnFromWebEngineFeature(feature); - query.prepare(QSL("UPDATE site_settings SET %1 = 0 WHERE id = ?").arg(column)); + query.prepare(QSL("UPDATE site_settings SET %1 = ? WHERE id = ?").arg(column)); + query.addBindValue(SiteSettingsManager::Default); query.addBindValue(m_removed[feature]); if (!query.execBatch()) {