mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Add support for custom url schemes
BUG: 434099 FIXED_IN: 23.08.0 Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
37f7703d4e
commit
205018775c
|
@ -207,6 +207,7 @@ set(SRCS ${SRCS}
|
|||
preferences/pluginlistdelegate.cpp
|
||||
preferences/pluginsmanager.cpp
|
||||
preferences/preferences.cpp
|
||||
preferences/schememanager.cpp
|
||||
preferences/thememanager.cpp
|
||||
preferences/useragentdialog.cpp
|
||||
session/recoveryjsobject.cpp
|
||||
|
@ -436,6 +437,7 @@ set(SRCS ${SRCS}
|
|||
preferences/pluginlistdelegate.h
|
||||
preferences/pluginsmanager.h
|
||||
preferences/preferences.h
|
||||
preferences/schememanager.h
|
||||
preferences/thememanager.h
|
||||
preferences/useragentdialog.h
|
||||
session/recoveryjsobject.h
|
||||
|
@ -549,6 +551,7 @@ qt_wrap_ui(SRCS
|
|||
preferences/jsoptions.ui
|
||||
preferences/pluginslist.ui
|
||||
preferences/preferences.ui
|
||||
preferences/schememanager.ui
|
||||
preferences/thememanager.ui
|
||||
preferences/useragentdialog.ui
|
||||
session/sessionmanagerdialog.ui
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include <QtWebEngineCoreVersion>
|
||||
|
||||
#include <QWebEngineNotification>
|
||||
#include <QWebEngineUrlScheme>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QtWin>
|
||||
|
@ -293,6 +294,7 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
}
|
||||
|
||||
NetworkManager::registerSchemes();
|
||||
registerAllowedSchemes();
|
||||
|
||||
m_webProfile = isPrivate() ? new QWebEngineProfile() : QWebEngineProfile::defaultProfile();
|
||||
connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested);
|
||||
|
@ -1116,6 +1118,19 @@ void MainApplication::checkOptimizeDatabase()
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
void MainApplication::registerAllowedSchemes()
|
||||
{
|
||||
for (const QString &schemeName : qAsConst(qzSettings->allowedSchemes)) {
|
||||
if (qzSettings->blockedSchemes.contains(schemeName)) {
|
||||
continue;
|
||||
}
|
||||
QWebEngineUrlScheme scheme(schemeName.toUtf8());
|
||||
scheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored);
|
||||
scheme.setSyntax(QWebEngineUrlScheme::Syntax::Path);
|
||||
QWebEngineUrlScheme::registerScheme(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
void MainApplication::setupUserScripts()
|
||||
{
|
||||
// WebChannel for SafeJsWorld
|
||||
|
|
|
@ -164,6 +164,8 @@ private:
|
|||
void checkDefaultWebBrowser();
|
||||
void checkOptimizeDatabase();
|
||||
|
||||
void registerAllowedSchemes();
|
||||
|
||||
bool m_isPrivate;
|
||||
bool m_isPortable;
|
||||
bool m_isClosing;
|
||||
|
|
|
@ -51,6 +51,8 @@ void QzSettings::loadSettings()
|
|||
loadTabsOnActivation = settings.value("LoadTabsOnActivation", true).toBool();
|
||||
autoOpenProtocols = settings.value("AutomaticallyOpenProtocols", QStringList()).toStringList();
|
||||
blockedProtocols = settings.value("BlockOpeningProtocols", QStringList()).toStringList();
|
||||
allowedSchemes = settings.value("AllowedSchemes", QStringList()).toStringList();
|
||||
blockedSchemes = settings.value("BlockedSchemes", QStringList()).toStringList();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("Browser-Tabs-Settings");
|
||||
|
|
|
@ -56,6 +56,9 @@ public:
|
|||
QStringList autoOpenProtocols;
|
||||
QStringList blockedProtocols;
|
||||
|
||||
QStringList allowedSchemes;
|
||||
QStringList blockedSchemes;
|
||||
|
||||
// Browser-Tabs-Settings
|
||||
Qz::NewTabPositionFlags newTabPosition;
|
||||
bool tabsOnTop;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "searchenginesdialog.h"
|
||||
#include "webscrollbarmanager.h"
|
||||
#include "protocolhandlerdialog.h"
|
||||
#include "schememanager.h"
|
||||
#include "../config.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
@ -522,6 +523,7 @@ Preferences::Preferences(BrowserWindow* window)
|
|||
connect(ui->searchEngines, &QAbstractButton::clicked, this, &Preferences::openSearchEnginesManager);
|
||||
connect(ui->certificateManager, &QAbstractButton::clicked, this, &Preferences::openCertificateManager);
|
||||
connect(ui->protocolHandlers, &QAbstractButton::clicked, this, &Preferences::openProtocolHandlersManager);
|
||||
connect(ui->customSchemes, &QAbstractButton::clicked, this, &Preferences::openSchemesManager);
|
||||
|
||||
connect(ui->listWidget, &QListWidget::currentItemChanged, this, &Preferences::showStackedPage);
|
||||
ui->listWidget->itemAt(5, 5)->setSelected(true);
|
||||
|
@ -754,6 +756,12 @@ void Preferences::openProtocolHandlersManager()
|
|||
dialog->open();
|
||||
}
|
||||
|
||||
void Preferences::openSchemesManager()
|
||||
{
|
||||
auto *dialog = new SchemeManager(this);
|
||||
dialog->open();
|
||||
}
|
||||
|
||||
void Preferences::showAcceptLanguage()
|
||||
{
|
||||
auto* dialog = new AcceptLanguage(this);
|
||||
|
|
|
@ -66,6 +66,7 @@ private Q_SLOTS:
|
|||
void openSearchEnginesManager();
|
||||
void openCertificateManager();
|
||||
void openProtocolHandlersManager();
|
||||
void openSchemesManager();
|
||||
|
||||
void searchFromAddressBarChanged(bool state);
|
||||
void saveHistoryChanged(bool state);
|
||||
|
|
|
@ -2474,120 +2474,6 @@
|
|||
</widget>
|
||||
<widget class="QWidget" name="otherPage">
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
<item row="4" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
<string><b>Preferred language for web sites</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string><b>Manage protocol handlers</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string><b>Certificate manager</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_35">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="certificateManager">
|
||||
<property name="text">
|
||||
<string>Certificate Exception Manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_36">
|
||||
<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>
|
||||
<item row="8" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_26">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="uaManager">
|
||||
<property name="text">
|
||||
<string>User Agent Manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_25">
|
||||
<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>
|
||||
<item row="26" column="0">
|
||||
<spacer name="verticalSpacer_15">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="17" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
|
@ -2628,20 +2514,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_66">
|
||||
<property name="text">
|
||||
<string><b>Manage search engines</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Style Sheet automatically loaded with all websites: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_25">
|
||||
<item>
|
||||
|
@ -2682,26 +2554,33 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="5">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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 row="18" column="0" colspan="6">
|
||||
<item row="20" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string><b>User Style Sheet</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_66">
|
||||
<property name="text">
|
||||
<string><b>Manage search engines</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Manage custom schemes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
|
@ -2742,6 +2621,53 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
<string><b>Preferred language for web sites</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_35">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="certificateManager">
|
||||
<property name="text">
|
||||
<string>Certificate Exception Manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_36">
|
||||
<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>
|
||||
<item row="7" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_60">
|
||||
<property name="text">
|
||||
|
@ -2749,7 +2675,54 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="21" column="0">
|
||||
<item row="8" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_26">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="uaManager">
|
||||
<property name="text">
|
||||
<string>User Agent Manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_25">
|
||||
<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>
|
||||
<item row="21" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Style Sheet automatically loaded with all websites: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="23" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_37">
|
||||
|
@ -2779,6 +2752,86 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="16" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string><b>Manage protocol handlers</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string><b>Certificate manager</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="28" column="0">
|
||||
<spacer name="verticalSpacer_15">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="5">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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 row="19" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_38">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="customSchemes">
|
||||
<property name="text">
|
||||
<string>Custom Scheme Manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_39">
|
||||
<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>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
143
src/lib/preferences/schememanager.cpp
Normal file
143
src/lib/preferences/schememanager.cpp
Normal file
|
@ -0,0 +1,143 @@
|
|||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2023 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 "ui_schememanager.h"
|
||||
#include "schememanager.h"
|
||||
#include "qzsettings.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
SchemeManager::SchemeManager(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::SchemeManager)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
reset();
|
||||
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &SchemeManager::accept);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QAbstractButton::clicked, this, &SchemeManager::reset);
|
||||
connect(m_ui->blockButton, &QAbstractButton::clicked, this, &SchemeManager::blockScheme);
|
||||
connect(m_ui->allowedAddButton, &QAbstractButton::clicked, this, &SchemeManager::allowedAdd);
|
||||
connect(m_ui->allowedRemoveButton, &QAbstractButton::clicked, this, &SchemeManager::allowedRemove);
|
||||
connect(m_ui->blockedAddButton, &QAbstractButton::clicked, this, &SchemeManager::blockedAdd);
|
||||
connect(m_ui->blockedRemoveButton, &QAbstractButton::clicked, this, &SchemeManager::blockedRemove);
|
||||
}
|
||||
|
||||
void SchemeManager::reset()
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup(QSL("Web-Browser-Settings"));
|
||||
|
||||
m_ui->allowedList->clear();
|
||||
m_ui->allowedList->addItems(settings.value(QSL("AllowedSchemes"), QStringList()).toStringList());
|
||||
|
||||
m_ui->blockedList->clear();
|
||||
m_ui->blockedList->addItems(settings.value(QSL("BlockedSchemes"), QStringList()).toStringList());
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void SchemeManager::accept()
|
||||
{
|
||||
QStringList list;
|
||||
Settings settings;
|
||||
settings.beginGroup(QSL("Web-Browser-Settings"));
|
||||
|
||||
for (int i = 0; i < m_ui->allowedList->count(); ++i) {
|
||||
list.append(m_ui->allowedList->item(i)->text().toLower());
|
||||
}
|
||||
list.removeDuplicates();
|
||||
settings.setValue(QSL("AllowedSchemes"), list);
|
||||
|
||||
list.clear();
|
||||
for (int i = 0; i < m_ui->blockedList->count(); ++i) {
|
||||
list.append(m_ui->blockedList->item(i)->text().toLower());
|
||||
}
|
||||
list.removeDuplicates();
|
||||
settings.setValue(QSL("BlockedSchemes"), list);
|
||||
settings.endGroup();
|
||||
|
||||
QDialog::close();
|
||||
}
|
||||
|
||||
void SchemeManager::allowedAdd()
|
||||
{
|
||||
const QString scheme = QInputDialog::getText(this, tr("Add allowed scheme"), tr("Scheme:"));
|
||||
|
||||
if (scheme.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_ui->allowedList->findItems(scheme, Qt::MatchFixedString).isEmpty()) {
|
||||
m_ui->allowedList->addItem(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
void SchemeManager::allowedRemove()
|
||||
{
|
||||
int currentRow = m_ui->allowedList->currentRow();
|
||||
auto* item = m_ui->allowedList->item(currentRow);
|
||||
|
||||
if ((item != nullptr) && (item->isSelected())) {
|
||||
m_ui->allowedList->takeItem(m_ui->allowedList->currentRow());
|
||||
}
|
||||
}
|
||||
|
||||
void SchemeManager::blockScheme()
|
||||
{
|
||||
int currentRow = m_ui->allowedList->currentRow();
|
||||
auto* item = m_ui->allowedList->item(currentRow);
|
||||
|
||||
if ((item != nullptr) && (item->isSelected())) {
|
||||
if (m_ui->blockedList->findItems(item->text(), Qt::MatchFixedString).isEmpty()) {
|
||||
m_ui->blockedList->addItem(item->text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SchemeManager::blockedAdd()
|
||||
{
|
||||
const QString scheme = QInputDialog::getText(this, tr("Add blocked scheme"), tr("Scheme:"));
|
||||
|
||||
if (scheme.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_ui->blockedList->findItems(scheme, Qt::MatchFixedString).isEmpty()) {
|
||||
m_ui->blockedList->addItem(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
void SchemeManager::blockedRemove()
|
||||
{
|
||||
int currentRow = m_ui->blockedList->currentRow();
|
||||
auto* item = m_ui->blockedList->item(currentRow);
|
||||
|
||||
if ((item != nullptr) && (item->isSelected())) {
|
||||
m_ui->blockedList->takeItem(m_ui->blockedList->currentRow());
|
||||
}
|
||||
}
|
||||
|
||||
SchemeManager::~SchemeManager()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
52
src/lib/preferences/schememanager.h
Normal file
52
src/lib/preferences/schememanager.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2023 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 SCHEMEMANAGER_H
|
||||
#define SCHEMEMANAGER_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class SchemeManager;
|
||||
}
|
||||
|
||||
class SchemeManager : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SchemeManager(QWidget* parent = nullptr);
|
||||
~SchemeManager() override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void accept() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void reset();
|
||||
void blockScheme();
|
||||
|
||||
void allowedAdd();
|
||||
void allowedRemove();
|
||||
void blockedAdd();
|
||||
void blockedRemove();
|
||||
|
||||
private:
|
||||
Ui::SchemeManager *m_ui;
|
||||
};
|
||||
|
||||
#endif // SCHEMEMANAGER_H
|
191
src/lib/preferences/schememanager.ui
Normal file
191
src/lib/preferences/schememanager.ui
Normal file
|
@ -0,0 +1,191 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SchemeManager</class>
|
||||
<widget class="QDialog" name="SchemeManager">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>490</width>
|
||||
<height>499</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Custom scheme manager</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allowed schemes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>**Note:** Allowed schemes can be added by extensions.</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::MarkdownText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="allowedList">
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="allowedAddButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="allowedRemoveButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="blockButton">
|
||||
<property name="text">
|
||||
<string>Block</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Blocked schemes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="blockedList">
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="blockedAddButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="blockedRemoveButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Changes will take effect after Falkon restart.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>allowedList</tabstop>
|
||||
<tabstop>allowedAddButton</tabstop>
|
||||
<tabstop>allowedRemoveButton</tabstop>
|
||||
<tabstop>blockButton</tabstop>
|
||||
<tabstop>blockedList</tabstop>
|
||||
<tabstop>blockedAddButton</tabstop>
|
||||
<tabstop>blockedRemoveButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SchemeManager</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>302</x>
|
||||
<y>475</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>404</x>
|
||||
<y>413</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -29,6 +29,7 @@
|
|||
#include "webview.h"
|
||||
#include "downloadkjob.h"
|
||||
#include "downloaditem.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <KCrash>
|
||||
#include <KAboutData>
|
||||
|
@ -37,6 +38,7 @@
|
|||
#include <KUiServerJobTracker>
|
||||
|
||||
#include <QWebEngineProfile>
|
||||
#include <QWebEngineUrlScheme>
|
||||
#include <QMenu>
|
||||
#include <QJsonArray>
|
||||
|
||||
|
@ -74,15 +76,34 @@ void KDEFrameworksIntegrationPlugin::init(InitState state, const QString &settin
|
|||
});
|
||||
|
||||
|
||||
QStringList newSchemes;
|
||||
const auto protocols = KProtocolInfo::protocols();
|
||||
for (const QString &protocol : protocols) {
|
||||
if (WebPage::internalSchemes().contains(protocol)) {
|
||||
continue;
|
||||
}
|
||||
auto *handler = new KIOSchemeHandler(protocol, this);
|
||||
m_kioSchemeHandlers.append(handler);
|
||||
mApp->webProfile()->installUrlSchemeHandler(protocol.toUtf8(), handler);
|
||||
WebPage::addSupportedScheme(protocol);
|
||||
if (!QWebEngineUrlScheme::schemeByName(protocol.toUtf8()).name().isEmpty()) {
|
||||
auto *handler = new KIOSchemeHandler(protocol, this);
|
||||
m_kioSchemeHandlers.append(handler);
|
||||
mApp->webProfile()->installUrlSchemeHandler(protocol.toUtf8(), handler);
|
||||
WebPage::addSupportedScheme(protocol);
|
||||
}
|
||||
else {
|
||||
newSchemes.append(protocol);
|
||||
qInfo() << QSL("KDEFrameworksIntegration: Custom scheme '%1' will be available after browser restart.").arg(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
if (!newSchemes.isEmpty()) {
|
||||
Settings settings;
|
||||
settings.beginGroup(QSL("Web-Browser-Settings"));
|
||||
|
||||
QStringList allowedSchemes = settings.value(QSL("AllowedSchemes"), QStringList()).toStringList();
|
||||
allowedSchemes.append(newSchemes);
|
||||
allowedSchemes.removeDuplicates();
|
||||
settings.setValue(QSL("AllowedSchemes"), allowedSchemes);
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
m_sharePageMenu = new Purpose::Menu();
|
||||
|
|
Loading…
Reference in New Issue
Block a user