diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/forms/cookiesform.cpp | 73 | ||||
-rw-r--r-- | src/forms/cookiesform.h | 46 | ||||
-rw-r--r-- | src/forms/cookiesform.ui | 120 |
3 files changed, 0 insertions, 239 deletions
diff --git a/src/forms/cookiesform.cpp b/src/forms/cookiesform.cpp deleted file mode 100644 index 9060afa..0000000 --- a/src/forms/cookiesform.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 "cookiesform.h" -#include "ui_cookiesform.h" -#include <QDateTime> - -CookiesForm::CookiesForm(QWebEngineCookieStore *store, QWidget *parent) - : QWidget(parent) - , ui(new Ui::CookiesForm) -{ - setAttribute(Qt::WA_DeleteOnClose, false); - ui->setupUi(this); - ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - - connect(store, &QWebEngineCookieStore::cookieAdded, this, &CookiesForm::addCookie); - connect(ui->treeWidget, &QTreeWidget::currentItemChanged, this, &CookiesForm::showDetails); -} - -CookiesForm::~CookiesForm() -{ - delete ui; -} - -void CookiesForm::addCookie(const QNetworkCookie &cookie) -{ - // find topLevelItem to which to add the cookie - QTreeWidgetItem *domainItem = nullptr; - - // loop through all top level items and check if one matches the domain - for(int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { - QTreeWidgetItem *parentItem = ui->treeWidget->topLevelItem(i); - if(parentItem->text(0) == cookie.domain()) { - domainItem = parentItem; - break; - } - } - - // no topLevelItem matches - if(!domainItem) { - domainItem = new QTreeWidgetItem(ui->treeWidget); - domainItem->setText(0, cookie.domain()); - } - - QTreeWidgetItem *item = new QTreeWidgetItem(domainItem); - item->setText(0, cookie.name()); - item->setText(1, cookie.expirationDate().toString(Qt::RFC2822Date)); - - item->setData(0, ValueRole, cookie.value()); - item->setData(0, IsHttpOnlyRole, cookie.isHttpOnly() ? tr("yes") : tr("no")); - item->setData(0, IsSecureRole, cookie.isSecure() ? tr("yes") : tr("no")); - item->setData(0, IsSessionCookieRole, cookie.isSessionCookie() ? tr("yes") : tr("no")); - item->setData(0, PathRole, cookie.path()); -} - -void CookiesForm::showDetails(QTreeWidgetItem *current, QTreeWidgetItem *previous) -{ - Q_UNUSED(previous) - if(!current) { - return; - } - - ui->value->setPlainText(current->data(0, ValueRole).toString()); - ui->httponly->setText(current->data(0, IsHttpOnlyRole).toString()); - ui->secure->setText(current->data(0, IsSecureRole).toString()); - ui->session->setText(current->data(0, IsSessionCookieRole).toString()); - ui->path->setText(current->data(0, PathRole).toString()); -} diff --git a/src/forms/cookiesform.h b/src/forms/cookiesform.h deleted file mode 100644 index a950ae1..0000000 --- a/src/forms/cookiesform.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 COOKIESFORM_H -#define COOKIESFORM_H - -#include <QTreeWidgetItem> -#include <QWebEngineCookieStore> -#include <QWidget> - -namespace Ui -{ -class CookiesForm; -} - -class CookiesForm : public QWidget -{ - Q_OBJECT - -public: - enum DetailsRoles { - ValueRole = Qt::UserRole, - - IsHttpOnlyRole = Qt::UserRole + 1, - IsSecureRole = Qt::UserRole + 2, - IsSessionCookieRole = Qt::UserRole + 3, - PathRole = Qt::UserRole + 4 - }; - - explicit CookiesForm(QWebEngineCookieStore *store, QWidget *parent = 0); - ~CookiesForm(); - -private slots: - void addCookie(const QNetworkCookie &cookie); - void showDetails(QTreeWidgetItem *current, QTreeWidgetItem *previous); - -private: - Ui::CookiesForm *ui; -}; - -#endif // COOKIESFORM_H diff --git a/src/forms/cookiesform.ui b/src/forms/cookiesform.ui deleted file mode 100644 index f5546bd..0000000 --- a/src/forms/cookiesform.ui +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>CookiesForm</class> - <widget class="QWidget" name="CookiesForm"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>480</width> - <height>640</height> - </rect> - </property> - <property name="windowTitle"> - <string>Cookies</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QTreeWidget" name="treeWidget"> - <property name="headerHidden"> - <bool>false</bool> - </property> - <column> - <property name="text"> - <string notr="true">Name</string> - </property> - </column> - <column> - <property name="text"> - <string>Expiration</string> - </property> - </column> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Details</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="httponly_label"> - <property name="text"> - <string>Is HTTP Only</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="secure_label"> - <property name="text"> - <string>Is Secure</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="session_label"> - <property name="text"> - <string>Is Session Cookie</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="httponly"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="secure"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="session"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="path_label"> - <property name="text"> - <string>Path</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="path"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QPlainTextEdit" name="value"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> |