1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Add ProtocolHandlerDialog

It is now possible to remove previously registered protocol handlers.
This commit is contained in:
David Rosca 2019-03-14 11:13:37 +01:00
parent a154ef5480
commit 1a81c0c821
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
7 changed files with 350 additions and 101 deletions

View File

@ -151,6 +151,7 @@ set(SRCS ${SRCS}
other/statusbar.cpp
other/updater.cpp
other/useragentmanager.cpp
other/protocolhandlerdialog.cpp
other/protocolhandlermanager.cpp
plugins/pluginproxy.cpp
plugins/plugins.cpp
@ -302,6 +303,7 @@ qt5_wrap_ui(SRCS
other/browsinglibrary.ui
other/clearprivatedata.ui
other/iconchooser.ui
other/protocolhandlerdialog.ui
other/siteinfo.ui
other/siteinfowidget.ui
preferences/acceptlanguage.ui

View File

@ -0,0 +1,72 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 David Rosca <nowrep@gmail.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 "protocolhandlerdialog.h"
#include "ui_protocolhandlerdialog.h"
#include "mainapplication.h"
#include "protocolhandlermanager.h"
ProtocolHandlerDialog::ProtocolHandlerDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::ProtocolHandlerDialog)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
init();
ui->treeWidget->header()->resizeSection(0, 100);
connect(ui->remove, &QPushButton::clicked, this, &ProtocolHandlerDialog::removeEntry);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ProtocolHandlerDialog::accepted);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ProtocolHandlerDialog::close);
}
ProtocolHandlerDialog::~ProtocolHandlerDialog()
{
delete ui;
}
void ProtocolHandlerDialog::init()
{
const auto handlers = mApp->protocolHandlerManager()->protocolHandlers();
for (auto it = handlers.cbegin(); it != handlers.cend(); ++it) {
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, it.key());
item->setText(1, it.value().host());
ui->treeWidget->addTopLevelItem(item);
}
}
void ProtocolHandlerDialog::accepted()
{
auto handlers = mApp->protocolHandlerManager()->protocolHandlers();
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = ui->treeWidget->topLevelItem(i);
handlers.remove(item->text(0));
}
for (auto it = handlers.cbegin(); it != handlers.cend(); ++it) {
mApp->protocolHandlerManager()->removeProtocolHandler(it.key());
}
close();
}
void ProtocolHandlerDialog::removeEntry()
{
delete ui->treeWidget->currentItem();
}

View File

@ -0,0 +1,41 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 David Rosca <nowrep@gmail.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/>.
* ============================================================ */
#pragma once
#include <QDialog>
#include <QStringList>
namespace Ui {
class ProtocolHandlerDialog;
}
class ProtocolHandlerDialog : public QDialog
{
Q_OBJECT
public:
explicit ProtocolHandlerDialog(QWidget *parent = 0);
~ProtocolHandlerDialog();
private:
void init();
void accepted();
void removeEntry();
Ui::ProtocolHandlerDialog *ui;
};

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProtocolHandlerDialog</class>
<widget class="QDialog" name="ProtocolHandlerDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>483</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>Manage protocol handlers</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" 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>Protocol</string>
</property>
</column>
<column>
<property name="text">
<string>Site</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<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>
<item>
<widget class="QPushButton" name="remove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -46,6 +46,7 @@
#include "html5permissions/html5permissionsdialog.h"
#include "searchenginesdialog.h"
#include "webscrollbarmanager.h"
#include "protocolhandlerdialog.h"
#include "../config.h"
#include <QSettings>
@ -512,6 +513,7 @@ Preferences::Preferences(BrowserWindow* window)
connect(ui->uaManager, &QAbstractButton::clicked, this, &Preferences::openUserAgentManager);
connect(ui->jsOptionsButton, &QAbstractButton::clicked, this, &Preferences::openJsOptions);
connect(ui->searchEngines, &QAbstractButton::clicked, this, &Preferences::openSearchEnginesManager);
connect(ui->protocolHandlers, &QAbstractButton::clicked, this, &Preferences::openProtocolHandlersManager);
connect(ui->listWidget, &QListWidget::currentItemChanged, this, &Preferences::showStackedPage);
ui->listWidget->setItemSelected(ui->listWidget->itemAt(5, 5), true);
@ -727,6 +729,12 @@ void Preferences::openSearchEnginesManager()
dialog->open();
}
void Preferences::openProtocolHandlersManager()
{
ProtocolHandlerDialog *dialog = new ProtocolHandlerDialog(this);
dialog->open();
}
void Preferences::showAcceptLanguage()
{
AcceptLanguage* dialog = new AcceptLanguage(this);

View File

@ -64,6 +64,7 @@ private Q_SLOTS:
void openUserAgentManager();
void openJsOptions();
void openSearchEnginesManager();
void openProtocolHandlersManager();
void searchFromAddressBarChanged(bool state);
void saveHistoryChanged(bool state);

View File

@ -146,7 +146,7 @@
<x>0</x>
<y>0</y>
<width>582</width>
<height>534</height>
<height>476</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -2400,8 +2400,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<height>28</height>
<width>560</width>
<height>80</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_14">
@ -2439,6 +2439,13 @@
</widget>
<widget class="QWidget" name="otherPage">
<layout class="QGridLayout" name="gridLayout_13">
<item row="15" column="2">
<widget class="MacToolButton" name="chooseUserStylesheet">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="4">
<widget class="QLabel" name="label_66">
<property name="text">
@ -2446,110 +2453,13 @@
</property>
</widget>
</item>
<item row="11" column="0" colspan="4">
<item row="13" column="0" colspan="4">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&lt;b&gt;User Style Sheet&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="4">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Style Sheet automatically loaded with all websites: </string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLineEdit" name="userStyleSheet"/>
</item>
<item row="13" column="2">
<widget class="MacToolButton" name="chooseUserStylesheet">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="14" 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="4" column="0" colspan="4">
<widget class="QLabel" name="label_36">
<property name="text">
<string>&lt;b&gt;Preferred language for web sites&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="5" column="3">
<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="7" column="0" colspan="4">
<widget class="QLabel" name="label_60">
<property name="text">
<string>&lt;b&gt;Change browser identification&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<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="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
@ -2590,6 +2500,53 @@
</item>
</layout>
</item>
<item row="7" column="0" colspan="4">
<widget class="QLabel" name="label_60">
<property name="text">
<string>&lt;b&gt;Change browser identification&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_28">
<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="protocolHandlers">
<property name="text">
<string>Protocol Handlers Manager</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_34">
<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="10" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
@ -2630,6 +2587,96 @@
</item>
</layout>
</item>
<item row="5" column="3">
<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="16" 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="14" column="0" colspan="4">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Style Sheet automatically loaded with all websites: </string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QLineEdit" name="userStyleSheet"/>
</item>
<item row="4" column="0" colspan="4">
<widget class="QLabel" name="label_36">
<property name="text">
<string>&lt;b&gt;Preferred language for web sites&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<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="11" column="0" colspan="4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&lt;b&gt;Manage protocol handlers&lt;/b&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>