diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-15 00:35:58 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-01-15 00:35:58 +0100 |
commit | 2660fff9e6191808aa83197639a663b73a27bbfa (patch) | |
tree | e01930c4202d87c5b74f701938a0004a952425a1 /src/forms | |
parent | Initial plugins testing (diff) | |
download | smolbote-2660fff9e6191808aa83197639a663b73a27bbfa.tar.xz |
Moved ProfileView to ProfileEditorPlugin
Diffstat (limited to 'src/forms')
-rw-r--r-- | src/forms/profileview.cpp | 132 | ||||
-rw-r--r-- | src/forms/profileview.h | 42 | ||||
-rw-r--r-- | src/forms/profileview.ui | 230 |
3 files changed, 0 insertions, 404 deletions
diff --git a/src/forms/profileview.cpp b/src/forms/profileview.cpp deleted file mode 100644 index 3d85963..0000000 --- a/src/forms/profileview.cpp +++ /dev/null @@ -1,132 +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: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "profileview.h" -#include "ui_profileview.h" - -#include "forms/cookiesform.h" -#include "webengine/webengineprofile.h" -#include <QComboBox> -#include <QLineEdit> -#include <QPlainTextEdit> -#include <QPushButton> - -#include <QDialogButtonBox> - -#include <QFormLayout> - -ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) - : QDialog(parent) - , ui(new Ui::ProfileView) -{ - ui->setupUi(this); - setProfile(profile); - - // actions - connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() { - this->m_profile->clearHttpCache(); - }); - connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() { - this->m_profile->clearAllVisitedLinks(); - }); - - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ProfileView::updateProfile); - connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ProfileView::close); -} - -ProfileView::~ProfileView() -{ - delete ui; -} - -void ProfileView::setProfile(WebEngineProfile *profile) -{ - Q_CHECK_PTR(profile); - - m_profile = profile; - setWindowTitle(m_profile->name()); - - m_cookiesForm = new CookiesForm(m_profile->cookieStore(), this); - //ui->tabWidget->addTab(m_cookiesForm, m_cookiesForm->windowTitle()); - - // general - ui->homepage_lineEdit->setText(m_profile->homepage().toString()); - ui->newtab_lineEdit->setText(m_profile->newtab().toString()); - - // http - ui->userAgent->setPlainText(m_profile->httpUserAgent()); - ui->acceptLanguage->setPlainText(m_profile->httpAcceptLanguage()); - ui->cacheType->setCurrentIndex(m_profile->httpCacheType()); - ui->cacheSize->setText(QString::number(m_profile->httpCacheMaximumSize())); - - // path - ui->storagePath_lineEdit->setText(m_profile->persistentStoragePath()); - ui->cachePath_lineEdit->setText(m_profile->cachePath()); - - // policy - ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy()); - - //ui->formLayout_3->addWidget(m_cookiesForm); - ui->verticalLayout_3->addWidget(m_cookiesForm); -} - -void ProfileView::showProfile() -{ - ui->tabWidget->setCurrentIndex(0); - show(); -} - -void ProfileView::showCookies() -{ - ui->tabWidget->setCurrentIndex(2); - show(); -} - -void ProfileView::updateProfile() -{ - qDebug("Updating profile [%s]...", qUtf8Printable(m_profile->name())); - - // general - m_profile->setHomepage(QUrl::fromUserInput(ui->homepage_lineEdit->text())); - m_profile->setNewtab(QUrl::fromUserInput(ui->newtab_lineEdit->text())); - - // http - m_profile->setHttpUserAgent(ui->userAgent->toPlainText()); - m_profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText()); - switch(ui->cacheType->currentIndex()) { - case 0: - m_profile->setHttpCacheType(QWebEngineProfile::MemoryHttpCache); - break; - case 1: - m_profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache); - break; - case 2: - m_profile->setHttpCacheType(QWebEngineProfile::NoCache); - break; - default: - break; - } - m_profile->setHttpCacheMaximumSize(ui->cacheSize->text().toInt()); - - // policy - switch(ui->cookiePolicy->currentIndex()) { - case 0: - m_profile->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); - break; - case 1: - m_profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies); - break; - case 2: - m_profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); - break; - default: - break; - } - - m_profile->saveProfile(); -} diff --git a/src/forms/profileview.h b/src/forms/profileview.h deleted file mode 100644 index bf44346..0000000 --- a/src/forms/profileview.h +++ /dev/null @@ -1,42 +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: git://neueland.iserlohn-fortress.net/smolbote.git - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#ifndef PROFILEDIALOG_H -#define PROFILEDIALOG_H - -#include <QDialog> - -namespace Ui -{ -class ProfileView; -} - -class WebEngineProfile; -class CookiesForm; -class ProfileView : public QDialog -{ - Q_OBJECT - -public: - explicit ProfileView(WebEngineProfile *profile, QWidget *parent = nullptr); - ~ProfileView(); - - void setProfile(WebEngineProfile *profile); - -public slots: - void showProfile(); - void showCookies(); - void updateProfile(); - -private: - Ui::ProfileView *ui; - WebEngineProfile *m_profile; - CookiesForm *m_cookiesForm; -}; - -#endif // PROFILEDIALOG_H diff --git a/src/forms/profileview.ui b/src/forms/profileview.ui deleted file mode 100644 index 7590e87..0000000 --- a/src/forms/profileview.ui +++ /dev/null @@ -1,230 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProfileView</class> - <widget class="QWidget" name="ProfileView"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>480</width> - <height>640</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="windowTitle"> - <string>Profile</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>General</string> - </attribute> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Homepage</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="homepage_lineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Newtab</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="newtab_lineEdit"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="httpTab"> - <attribute name="title"> - <string>HTTP</string> - </attribute> - <layout class="QFormLayout" name="formLayout_2"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>User Agent</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPlainTextEdit" name="userAgent"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Accept Language</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Cache Type</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Cache Size</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPlainTextEdit" name="acceptLanguage"/> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="cacheType"> - <item> - <property name="text"> - <string>Memory Cache</string> - </property> - </item> - <item> - <property name="text"> - <string>Disk Cache</string> - </property> - </item> - <item> - <property name="text"> - <string>Disabled</string> - </property> - </item> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="cacheSize"/> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="storagePath_label"> - <property name="text"> - <string>Storage Path</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QLineEdit" name="storagePath_lineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="cachePath_label"> - <property name="text"> - <string>Cache Path</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="cachePath_lineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QPushButton" name="clearCache_pushButton"> - <property name="text"> - <string>Clear Cache</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="policiesTab"> - <attribute name="title"> - <string>Cookies</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QFormLayout" name="cookies_formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Cookies</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="cookiePolicy"> - <item> - <property name="text"> - <string>No Persistent Cookies</string> - </property> - </item> - <item> - <property name="text"> - <string>Allow Persistent Cookies</string> - </property> - </item> - <item> - <property name="text"> - <string>Force Persistent Cookies</string> - </property> - </item> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="actionsTab"> - <attribute name="title"> - <string>History</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="clearHistory_pushButton"> - <property name="text"> - <string>Clear History</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> - </widget> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> |