mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Asdd UI for default HTML5 permission settings
- It is a dummy UI, may change in the future. Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
0c462f0a1c
commit
5eff4dc0e5
@ -244,6 +244,7 @@ set(SRCS ${SRCS}
|
|||||||
tools/headerview.cpp
|
tools/headerview.cpp
|
||||||
tools/horizontallistwidget.cpp
|
tools/horizontallistwidget.cpp
|
||||||
tools/html5permissions/html5permissionsdialog.cpp
|
tools/html5permissions/html5permissionsdialog.cpp
|
||||||
|
tools/html5permissions/html5permissionsitem.cpp
|
||||||
tools/html5permissions/html5permissionsmanager.cpp
|
tools/html5permissions/html5permissionsmanager.cpp
|
||||||
tools/html5permissions/html5permissionsnotification.cpp
|
tools/html5permissions/html5permissionsnotification.cpp
|
||||||
tools/iconprovider.cpp
|
tools/iconprovider.cpp
|
||||||
@ -475,6 +476,7 @@ set(SRCS ${SRCS}
|
|||||||
tools/headerview.h
|
tools/headerview.h
|
||||||
tools/horizontallistwidget.h
|
tools/horizontallistwidget.h
|
||||||
tools/html5permissions/html5permissionsdialog.h
|
tools/html5permissions/html5permissionsdialog.h
|
||||||
|
tools/html5permissions/html5permissionsitem.h
|
||||||
tools/html5permissions/html5permissionsmanager.h
|
tools/html5permissions/html5permissionsmanager.h
|
||||||
tools/html5permissions/html5permissionsnotification.h
|
tools/html5permissions/html5permissionsnotification.h
|
||||||
tools/iconprovider.h
|
tools/iconprovider.h
|
||||||
@ -562,6 +564,7 @@ qt_wrap_ui(SRCS
|
|||||||
tools/certificateinfowidget.ui
|
tools/certificateinfowidget.ui
|
||||||
tools/docktitlebarwidget.ui
|
tools/docktitlebarwidget.ui
|
||||||
tools/html5permissions/html5permissionsdialog.ui
|
tools/html5permissions/html5permissionsdialog.ui
|
||||||
|
tools/html5permissions/html5permissionsitem.ui
|
||||||
tools/html5permissions/html5permissionsnotification.ui
|
tools/html5permissions/html5permissionsnotification.ui
|
||||||
webengine/jsalert.ui
|
webengine/jsalert.ui
|
||||||
webengine/jsconfirm.ui
|
webengine/jsconfirm.ui
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "sqldatabase.h"
|
#include "sqldatabase.h"
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <qwebenginesettings.h>
|
|
||||||
|
|
||||||
SiteSettingsManager::SiteSettingsManager ( QObject* parent )
|
SiteSettingsManager::SiteSettingsManager ( QObject* parent )
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@ -191,11 +190,28 @@ QString SiteSettingsManager::optionToSqlColumn(const SiteSettingsManager::PageOp
|
|||||||
return QSL("allow_desktop_audio_video_capture");
|
return QSL("allow_desktop_audio_video_capture");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
qWarning() << "Unknown option" << option;
|
qWarning() << "Unknown option" << option;
|
||||||
return QLatin1String("");
|
return QLatin1String("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SiteSettingsManager::Permission SiteSettingsManager::getDefaultPermission(const SiteSettingsManager::PageOptions& option)
|
||||||
|
{
|
||||||
|
switch (option) {
|
||||||
|
case poAllowJavascript:
|
||||||
|
return testAttribute(QWebEngineSettings::JavascriptEnabled);
|
||||||
|
|
||||||
|
case poAllowImages:
|
||||||
|
return testAttribute(QWebEngineSettings::AutoLoadImages);
|
||||||
|
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
qWarning() << "Unknown option" << option;
|
||||||
|
return Deny;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SiteSettingsManager::getDefaultOptionValue(const SiteSettingsManager::PageOptions& option)
|
bool SiteSettingsManager::getDefaultOptionValue(const SiteSettingsManager::PageOptions& option)
|
||||||
{
|
{
|
||||||
switch (option) {
|
switch (option) {
|
||||||
@ -213,12 +229,13 @@ bool SiteSettingsManager::getDefaultOptionValue(const SiteSettingsManager::PageO
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
qWarning() << "Unknown option" << option;
|
qWarning() << "Unknown option" << option;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SiteSettingsManager::PageOptions SiteSettingsManager::optionFromWebEngineFeature(const QWebEnginePage::Feature& feature)
|
SiteSettingsManager::PageOptions SiteSettingsManager::optionFromWebEngineFeature(const QWebEnginePage::Feature& feature) const
|
||||||
{
|
{
|
||||||
switch (feature) {
|
switch (feature) {
|
||||||
case QWebEnginePage::Notifications:
|
case QWebEnginePage::Notifications:
|
||||||
@ -246,6 +263,7 @@ SiteSettingsManager::PageOptions SiteSettingsManager::optionFromWebEngineFeature
|
|||||||
return poAllowDesktopAudioVideoCapture;
|
return poAllowDesktopAudioVideoCapture;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
qWarning() << "Unknown feature" << feature;
|
qWarning() << "Unknown feature" << feature;
|
||||||
return poAllowNotifications;
|
return poAllowNotifications;
|
||||||
}
|
}
|
||||||
@ -255,3 +273,13 @@ QString SiteSettingsManager::sqlColumnFromWebEngineFeature(const QWebEnginePage:
|
|||||||
{
|
{
|
||||||
return optionToSqlColumn(optionFromWebEngineFeature(feature));
|
return optionToSqlColumn(optionFromWebEngineFeature(feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SiteSettingsManager::Permission SiteSettingsManager::testAttribute(const QWebEngineSettings::WebAttribute attribute) const
|
||||||
|
{
|
||||||
|
if (mApp->webSettings()->testAttribute(attribute)) {
|
||||||
|
return Allow;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Deny;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "qzcommon.h"
|
#include "qzcommon.h"
|
||||||
#include <QWebEnginePage>
|
#include <QWebEnginePage>
|
||||||
|
#include <QWebEngineSettings>
|
||||||
|
|
||||||
class QUrl;
|
class QUrl;
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ public:
|
|||||||
Deny = 2,
|
Deny = 2,
|
||||||
Ask = 3,
|
Ask = 3,
|
||||||
};
|
};
|
||||||
|
Q_ENUM(Permission);
|
||||||
|
|
||||||
enum PageOptions {
|
enum PageOptions {
|
||||||
poAllowJavascript,
|
poAllowJavascript,
|
||||||
@ -57,6 +59,7 @@ public:
|
|||||||
poAllowDesktopVideoCapture,
|
poAllowDesktopVideoCapture,
|
||||||
poAllowDesktopAudioVideoCapture,
|
poAllowDesktopAudioVideoCapture,
|
||||||
};
|
};
|
||||||
|
Q_ENUM(PageOptions);
|
||||||
|
|
||||||
struct SiteSettings
|
struct SiteSettings
|
||||||
{
|
{
|
||||||
@ -102,7 +105,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString optionToSqlColumn(const PageOptions &option);
|
QString optionToSqlColumn(const PageOptions &option);
|
||||||
bool getDefaultOptionValue(const PageOptions &option);
|
bool getDefaultOptionValue(const PageOptions &option);
|
||||||
PageOptions optionFromWebEngineFeature(const QWebEnginePage::Feature &feature);
|
Permission getDefaultPermission(const PageOptions &option);
|
||||||
|
PageOptions optionFromWebEngineFeature(const QWebEnginePage::Feature &feature) const;
|
||||||
|
Permission testAttribute(const QWebEngineSettings::WebAttribute attribute) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "ui_html5permissionsdialog.h"
|
#include "ui_html5permissionsdialog.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
|
#include "html5permissionsitem.h"
|
||||||
#include "html5permissionsmanager.h"
|
#include "html5permissionsmanager.h"
|
||||||
#include "sitesettingsmanager.h"
|
#include "sitesettingsmanager.h"
|
||||||
|
|
||||||
@ -41,6 +42,14 @@ HTML5PermissionsDialog::HTML5PermissionsDialog(QWidget* parent)
|
|||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &HTML5PermissionsDialog::saveSettings);
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &HTML5PermissionsDialog::saveSettings);
|
||||||
|
|
||||||
showFeaturePermissions(currentFeature());
|
showFeaturePermissions(currentFeature());
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
// Create permission item
|
||||||
|
auto* listItem = new QListWidgetItem(ui->listWidgetDefaults);
|
||||||
|
auto* permItem = new HTML5PermissionsItem(indexToFeature(i), SiteSettingsManager::Ask, this);
|
||||||
|
ui->listWidgetDefaults->setItemWidget(listItem, permItem);
|
||||||
|
listItem->setSizeHint(permItem->sizeHint());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HTML5PermissionsDialog::~HTML5PermissionsDialog()
|
HTML5PermissionsDialog::~HTML5PermissionsDialog()
|
||||||
|
@ -6,39 +6,154 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>483</width>
|
<width>586</width>
|
||||||
<height>332</height>
|
<height>387</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>HTML5 Permissions</string>
|
<string>HTML5 Permissions</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="1">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<item>
|
<property name="currentIndex">
|
||||||
<spacer name="verticalSpacer">
|
<number>0</number>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Vertical</enum>
|
<widget class="QWidget" name="tab">
|
||||||
</property>
|
<attribute name="title">
|
||||||
<property name="sizeHint" stdset="0">
|
<string>Site permissions</string>
|
||||||
<size>
|
</attribute>
|
||||||
<width>20</width>
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<height>40</height>
|
<item row="1" column="1">
|
||||||
</size>
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
</property>
|
<item>
|
||||||
</spacer>
|
<spacer name="verticalSpacer">
|
||||||
</item>
|
<property name="orientation">
|
||||||
<item>
|
<enum>Qt::Vertical</enum>
|
||||||
<widget class="QPushButton" name="remove">
|
</property>
|
||||||
<property name="text">
|
<property name="sizeHint" stdset="0">
|
||||||
<string>Remove</string>
|
<size>
|
||||||
</property>
|
<width>20</width>
|
||||||
</widget>
|
<height>183</height>
|
||||||
</item>
|
</size>
|
||||||
</layout>
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="remove">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QTreeWidget" name="treeWidget">
|
||||||
|
<property name="indentation">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="allColumnsShowFocus">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Site</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Behaviour</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Permission for:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="feature">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Notifications</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Geolocation</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Microphone</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Camera</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Microphone and Camera</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hide Pointer</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Display Capture</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Display and Audio Capture</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>81</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Defaults</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="listWidgetDefaults"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -48,97 +163,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QTreeWidget" name="treeWidget">
|
|
||||||
<property name="indentation">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="sortingEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="allColumnsShowFocus">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Site</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Behaviour</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Permission for:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="feature">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Notifications</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Geolocation</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Microphone</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Camera</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Microphone and Camera</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Hide Pointer</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Display Capture</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Display and Audio Capture</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
129
src/lib/tools/html5permissions/html5permissionsitem.cpp
Normal file
129
src/lib/tools/html5permissions/html5permissionsitem.cpp
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* Falkon - Qt web browser
|
||||||
|
* Copyright (C) 2022 Juraj Oravec <jurajoravec@mailo.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "html5permissionsitem.h"
|
||||||
|
#include "ui_html5permissionsitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
HTML5PermissionsItem::HTML5PermissionsItem(const QWebEnginePage::Feature& feature, const SiteSettingsManager::Permission& permission, QWidget* parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, ui(new Ui::HTML5PermissionsItem())
|
||||||
|
, m_feature(feature)
|
||||||
|
, m_permission(permission)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
setLabel();
|
||||||
|
setCombo();
|
||||||
|
|
||||||
|
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(permissionIndexChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
HTML5PermissionsItem::~HTML5PermissionsItem() noexcept
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTML5PermissionsItem::permissionIndexChanged()
|
||||||
|
{
|
||||||
|
switch (ui->comboBox->currentIndex()) {
|
||||||
|
case 0:
|
||||||
|
m_permission = SiteSettingsManager::Allow;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
m_permission = SiteSettingsManager::Deny;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
m_permission = SiteSettingsManager::Ask;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
qWarning() << "Unknown permission index" << ui->comboBox->currentIndex();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTML5PermissionsItem::setLabel()
|
||||||
|
{
|
||||||
|
switch (m_feature) {
|
||||||
|
case QWebEnginePage::Notifications:
|
||||||
|
ui->label->setText("Notifications");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::Geolocation:
|
||||||
|
ui->label->setText("Location");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::MediaAudioCapture:
|
||||||
|
ui->label->setText("Microphone");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::MediaVideoCapture:
|
||||||
|
ui->label->setText("Camera");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::MediaAudioVideoCapture:
|
||||||
|
ui->label->setText("Microphone and Camera");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::MouseLock:
|
||||||
|
ui->label->setText("Hide mouse pointer");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::DesktopVideoCapture:
|
||||||
|
ui->label->setText("Screen capture");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QWebEnginePage::DesktopAudioVideoCapture:
|
||||||
|
ui->label->setText("Screen capture with audio");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
qWarning() << "Unknown feature" << m_feature;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTML5PermissionsItem::setCombo()
|
||||||
|
{
|
||||||
|
switch (m_permission) {
|
||||||
|
case SiteSettingsManager::Allow:
|
||||||
|
ui->comboBox->setCurrentIndex(0);
|
||||||
|
break;
|
||||||
|
case SiteSettingsManager::Deny:
|
||||||
|
ui->comboBox->setCurrentIndex(1);
|
||||||
|
break;
|
||||||
|
case SiteSettingsManager::Ask:
|
||||||
|
ui->comboBox->setCurrentIndex(2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
qWarning() << "Unknown permission" << m_permission;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWebEnginePage::Feature HTML5PermissionsItem::getFeature() const
|
||||||
|
{
|
||||||
|
return m_feature;
|
||||||
|
}
|
||||||
|
|
||||||
|
SiteSettingsManager::Permission HTML5PermissionsItem::getPermission() const
|
||||||
|
{
|
||||||
|
return m_permission;
|
||||||
|
}
|
54
src/lib/tools/html5permissions/html5permissionsitem.h
Normal file
54
src/lib/tools/html5permissions/html5permissionsitem.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* Falkon - Qt web browser
|
||||||
|
* Copyright (C) 2022 Juraj Oravec <jurajoravec@mailo.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef HTML5PERMISSIONSITEM_H
|
||||||
|
#define HTML5PERMISSIONSITEM_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "qzcommon.h"
|
||||||
|
#include "sitesettingsmanager.h"
|
||||||
|
#include <QWebEnginePage>
|
||||||
|
#include <QWebEngineSettings>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class HTML5PermissionsItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FALKON_EXPORT HTML5PermissionsItem : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit HTML5PermissionsItem(const QWebEnginePage::Feature &feature, const SiteSettingsManager::Permission &permission, QWidget* parent = nullptr);
|
||||||
|
~HTML5PermissionsItem();
|
||||||
|
|
||||||
|
QWebEnginePage::Feature getFeature() const;
|
||||||
|
SiteSettingsManager::Permission getPermission() const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void permissionIndexChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setLabel();
|
||||||
|
void setCombo();
|
||||||
|
|
||||||
|
Ui::HTML5PermissionsItem* ui;
|
||||||
|
QWebEnginePage::Feature m_feature;
|
||||||
|
SiteSettingsManager::Permission m_permission;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HTML5PERMISSIONSITEM_H
|
57
src/lib/tools/html5permissions/html5permissionsitem.ui
Normal file
57
src/lib/tools/html5permissions/html5permissionsitem.ui
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>HTML5PermissionsItem</class>
|
||||||
|
<widget class="QWidget" name="HTML5PermissionsItem">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>319</width>
|
||||||
|
<height>38</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Allow</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Deny</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ask</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue
Block a user