diff options
Diffstat (limited to 'src/forms')
-rw-r--r-- | src/forms/cookiesform.cpp | 47 | ||||
-rw-r--r-- | src/forms/cookiesform.h | 15 | ||||
-rw-r--r-- | src/forms/cookiesform.ui | 102 | ||||
-rw-r--r-- | src/forms/profiledialog.cpp | 19 | ||||
-rw-r--r-- | src/forms/profiledialog.h | 12 |
5 files changed, 151 insertions, 44 deletions
diff --git a/src/forms/cookiesform.cpp b/src/forms/cookiesform.cpp index 44a9e44..7dfeb26 100644 --- a/src/forms/cookiesform.cpp +++ b/src/forms/cookiesform.cpp @@ -24,52 +24,65 @@ #include <QTreeWidget> #include <QDateTime> -CookiesWidget::CookiesWidget(QWebEngineCookieStore *store, QWidget *parent) : +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, SIGNAL(cookieAdded(QNetworkCookie)), this, SLOT(addCookie(QNetworkCookie))); connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(showDetails(QTreeWidgetItem*,QTreeWidgetItem*))); - connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(showDetails(QTreeWidgetItem*,int))); } -CookiesWidget::~CookiesWidget() +CookiesForm::~CookiesForm() { delete ui; } -void CookiesWidget::addCookie(const QNetworkCookie &cookie) +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()) { - QTreeWidgetItem *item = new QTreeWidgetItem(parentItem); - item->setText(0, cookie.name()); - item->setText(1, cookie.expirationDate().toString(Qt::RFC2822Date)); - item->setText(2, cookie.isHttpOnly() ? tr("yes") : tr("no")); - item->setText(3, cookie.isSecure() ? tr("yes") : tr("no")); - - item->setData(0, Qt::UserRole, cookie.value()); - return; + domainItem = parentItem; + break; } } // no topLevelItem matches - QTreeWidgetItem *parentItem = new QTreeWidgetItem(ui->treeWidget); - parentItem->setText(0, cookie.domain()); - addCookie(cookie); + 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 CookiesWidget::showDetails(QTreeWidgetItem *current, QTreeWidgetItem *previous) +void CookiesForm::showDetails(QTreeWidgetItem *current, QTreeWidgetItem *previous) { Q_UNUSED(previous) if(!current) { return; } - ui->value->setPlainText(current->data(0, Qt::UserRole).toString()); + 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 index c395941..0b3386a 100644 --- a/src/forms/cookiesform.h +++ b/src/forms/cookiesform.h @@ -29,13 +29,22 @@ namespace Ui { class CookiesForm; } -class CookiesWidget : public QWidget +class CookiesForm : public QWidget { Q_OBJECT public: - explicit CookiesWidget(QWebEngineCookieStore *store, QWidget *parent = 0); - ~CookiesWidget(); + 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); diff --git a/src/forms/cookiesform.ui b/src/forms/cookiesform.ui index 2662a9d..f5546bd 100644 --- a/src/forms/cookiesform.ui +++ b/src/forms/cookiesform.ui @@ -6,22 +6,19 @@ <rect> <x>0</x> <y>0</y> - <width>535</width> - <height>479</height> + <width>480</width> + <height>640</height> </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>Cookies</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QTreeWidget" name="treeWidget"> <property name="headerHidden"> <bool>false</bool> </property> - <attribute name="headerVisible"> - <bool>true</bool> - </attribute> <column> <property name="text"> <string notr="true">Name</string> @@ -32,23 +29,88 @@ <string>Expiration</string> </property> </column> - <column> - <property name="text"> - <string>Is HTTP only</string> - </property> - </column> - <column> - <property name="text"> - <string>Is Secure</string> - </property> - </column> </widget> </item> <item> - <widget class="QPlainTextEdit" name="value"> - <property name="readOnly"> - <bool>true</bool> + <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> diff --git a/src/forms/profiledialog.cpp b/src/forms/profiledialog.cpp index 057dc7d..047f51b 100644 --- a/src/forms/profiledialog.cpp +++ b/src/forms/profiledialog.cpp @@ -25,8 +25,10 @@ #include <QPlainTextEdit> #include <QComboBox> #include <QPushButton> +#include "webengine/webengineprofile.h" +#include "forms/cookiesform.h" -ProfileDialog::ProfileDialog(QWebEngineProfile *profile, QWidget *parent) : +ProfileDialog::ProfileDialog(WebEngineProfile *profile, QWidget *parent) : QDialog(parent), ui(new Ui::ProfileDialog) { @@ -39,6 +41,9 @@ ProfileDialog::ProfileDialog(QWebEngineProfile *profile, QWidget *parent) : setWindowTitle(tr("Off-the-record")); } + m_cookiesForm = new CookiesForm(_profile->cookieStore(), this); + ui->tabWidget->addTab(m_cookiesForm, m_cookiesForm->windowTitle()); + // http ui->userAgent->setPlainText(_profile->httpUserAgent()); ui->acceptLanguage->setPlainText(_profile->httpAcceptLanguage()); @@ -68,6 +73,18 @@ ProfileDialog::~ProfileDialog() delete ui; } +void ProfileDialog::showProfile() +{ + ui->tabWidget->setCurrentIndex(0); + show(); +} + +void ProfileDialog::showCookies() +{ + ui->tabWidget->setCurrentIndex(4); + show(); +} + void ProfileDialog::updateProfile() { qDebug("Updating profile..."); diff --git a/src/forms/profiledialog.h b/src/forms/profiledialog.h index ab367d8..79f85b1 100644 --- a/src/forms/profiledialog.h +++ b/src/forms/profiledialog.h @@ -22,26 +22,32 @@ #define PROFILEDIALOG_H #include <QDialog> -#include <QWebEngineProfile> namespace Ui { class ProfileDialog; } +class WebEngineProfile; +class CookiesForm; class ProfileDialog : public QDialog { Q_OBJECT public: - explicit ProfileDialog(QWebEngineProfile *profile, QWidget *parent = 0); + explicit ProfileDialog(WebEngineProfile *profile, QWidget *parent = 0); ~ProfileDialog(); +public slots: + void showProfile(); + void showCookies(); + private slots: void updateProfile(); private: - QWebEngineProfile *_profile; + WebEngineProfile *_profile; Ui::ProfileDialog *ui; + CookiesForm *m_cookiesForm; }; #endif // PROFILEDIALOG_H |