aboutsummaryrefslogtreecommitdiff
path: root/plugins/ProfileEditor/forms
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ProfileEditor/forms')
-rw-r--r--plugins/ProfileEditor/forms/newhttpheaderdialog.cpp32
-rw-r--r--plugins/ProfileEditor/forms/newhttpheaderdialog.h33
-rw-r--r--plugins/ProfileEditor/forms/newhttpheaderdialog.ui84
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp46
-rw-r--r--plugins/ProfileEditor/forms/profileview.h3
-rw-r--r--plugins/ProfileEditor/forms/profileview.ui68
6 files changed, 264 insertions, 2 deletions
diff --git a/plugins/ProfileEditor/forms/newhttpheaderdialog.cpp b/plugins/ProfileEditor/forms/newhttpheaderdialog.cpp
new file mode 100644
index 0000000..3978c4e
--- /dev/null
+++ b/plugins/ProfileEditor/forms/newhttpheaderdialog.cpp
@@ -0,0 +1,32 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "newhttpheaderdialog.h"
+#include "ui_newhttpheaderdialog.h"
+
+NewHttpHeaderDialog::NewHttpHeaderDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::NewHttpHeaderDialog)
+{
+ ui->setupUi(this);
+}
+
+NewHttpHeaderDialog::~NewHttpHeaderDialog()
+{
+ delete ui;
+}
+
+QString NewHttpHeaderDialog::header() const
+{
+ return ui->header->text();
+}
+
+QString NewHttpHeaderDialog::value() const
+{
+ return ui->value->text();
+}
diff --git a/plugins/ProfileEditor/forms/newhttpheaderdialog.h b/plugins/ProfileEditor/forms/newhttpheaderdialog.h
new file mode 100644
index 0000000..53a2a80
--- /dev/null
+++ b/plugins/ProfileEditor/forms/newhttpheaderdialog.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef NEWHTTPHEADERDIALOG_H
+#define NEWHTTPHEADERDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class NewHttpHeaderDialog;
+}
+
+class NewHttpHeaderDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit NewHttpHeaderDialog(QWidget *parent = nullptr);
+ ~NewHttpHeaderDialog();
+
+ QString header() const;
+ QString value() const;
+
+private:
+ Ui::NewHttpHeaderDialog *ui;
+};
+
+#endif // NEWHTTPHEADERDIALOG_H
diff --git a/plugins/ProfileEditor/forms/newhttpheaderdialog.ui b/plugins/ProfileEditor/forms/newhttpheaderdialog.ui
new file mode 100644
index 0000000..a457ba6
--- /dev/null
+++ b/plugins/ProfileEditor/forms/newhttpheaderdialog.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NewHttpHeaderDialog</class>
+ <widget class="QDialog" name="NewHttpHeaderDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>108</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="header_label">
+ <property name="text">
+ <string>Header</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="header"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="value_label">
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="value"/>
+ </item>
+ <item row="2" 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>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>NewHttpHeaderDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>NewHttpHeaderDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index ccb4ae5..4a89af6 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -13,6 +13,7 @@
#include <QWebEngineSettings>
#include <QWebEngineCookieStore>
#include <QDateTime>
+#include "newhttpheaderdialog.h"
inline void connectSetting(QCheckBox *checkBox, WebProfile *profile, QWebEngineSettings::WebAttribute attr)
{
@@ -86,6 +87,28 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent)
ui->storagePath_lineEdit->setText(m_profile->persistentStoragePath());
ui->cachePath_lineEdit->setText(m_profile->cachePath());
+ // headers tab
+ for(auto i = m_profile->headers().constBegin(); i != m_profile->headers().constEnd(); ++i) {
+ //ui->httpHeaders->addItem();
+ headerChanged(i.key(), i.value());
+ }
+ connect(m_profile, &WebProfile::headerChanged, this, &ProfileView::headerChanged);
+ connect(m_profile, &WebProfile::headerRemoved, this, &ProfileView::headerRemoved);
+ connect(ui->headers_insert, &QPushButton::clicked, m_profile, [this]() {
+ auto *dlg = new NewHttpHeaderDialog(this);
+ if(dlg->exec() == QDialog::Accepted) {
+ m_profile->setHttpHeader(dlg->header(), dlg->value());
+ }
+ delete dlg;
+ });
+ connect(ui->headers_delete, &QPushButton::clicked, m_profile, [this]() {
+ for(auto &list : ui->httpHeaders->selectedRanges()) {
+ for(int i = list.bottomRow(); i >= list.topRow(); --i) {
+ m_profile->removeHttpHeader(ui->httpHeaders->item(i, 0)->text());
+ }
+ }
+ });
+
// settings tab
connectSetting(ui->autoloadImages, m_profile, QWebEngineSettings::AutoLoadImages);
connectSetting(ui->autoloadIcons, m_profile, QWebEngineSettings::AutoLoadIconsForPage);
@@ -157,6 +180,29 @@ void ProfileView::loadCookies(QWebEngineCookieStore *store)
connect(ui->cookies_deleteAll, &QPushButton::clicked, store, &QWebEngineCookieStore::deleteAllCookies);
}
+void ProfileView::headerChanged(const QString &name, const QString &value)
+{
+ const auto items = ui->httpHeaders->findItems(name, Qt::MatchExactly);
+ if(!items.isEmpty()) {
+ QTableWidgetItem *valueItem = ui->httpHeaders->item(items.constFirst()->row(), 1);
+ valueItem->setText(value);
+ } else {
+ // new header
+ const int index = ui->httpHeaders->rowCount();
+ ui->httpHeaders->setRowCount(index + 1);
+ ui->httpHeaders->setItem(index, 0, new QTableWidgetItem(name));
+ ui->httpHeaders->setItem(index, 1, new QTableWidgetItem(value));
+ }
+}
+
+void ProfileView::headerRemoved(const QString& name)
+{
+ const auto items = ui->httpHeaders->findItems(name, Qt::MatchExactly);
+ if(!items.isEmpty()) {
+ ui->httpHeaders->removeRow(items.constFirst()->row());
+ }
+}
+
void ProfileView::cookieAdded(const QNetworkCookie &cookie)
{
auto index = ui->cookies->rowCount();
diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h
index 5ff472b..d05b0f1 100644
--- a/plugins/ProfileEditor/forms/profileview.h
+++ b/plugins/ProfileEditor/forms/profileview.h
@@ -33,6 +33,9 @@ public:
private slots:
void loadCookies(QWebEngineCookieStore *store);
+ void headerChanged(const QString &name, const QString &value);
+ void headerRemoved(const QString &name);
+
void cookieAdded(const QNetworkCookie &cookie);
void cookieRemoved(const QNetworkCookie &cookie);
diff --git a/plugins/ProfileEditor/forms/profileview.ui b/plugins/ProfileEditor/forms/profileview.ui
index 74b6d5d..630e53d 100644
--- a/plugins/ProfileEditor/forms/profileview.ui
+++ b/plugins/ProfileEditor/forms/profileview.ui
@@ -234,6 +234,70 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="httpHeadersTab">
+ <attribute name="title">
+ <string>Headers</string>
+ </attribute>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QTableWidget" name="httpHeaders">
+ <attribute name="horizontalHeaderDefaultSectionSize">
+ <number>200</number>
+ </attribute>
+ <attribute name="horizontalHeaderMinimumSectionSize">
+ <number>100</number>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QPushButton" name="headers_insert">
+ <property name="text">
+ <string>Insert</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="headers_delete">
+ <property name="text">
+ <string>Delete</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>
+ </widget>
<widget class="QWidget" name="settingsTab">
<attribute name="title">
<string>Settings</string>
@@ -249,8 +313,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>276</width>
- <height>855</height>
+ <width>584</width>
+ <height>797</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">