diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-10 13:45:16 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-10 13:45:16 +0200 |
commit | 5efa5501fb470b4d9ed48fc243a27768804c8eb4 (patch) | |
tree | b8f58f6b3e545e8801144cf9f3f0a64585c2221f /plugins/ProfileEditor | |
parent | Update pkgbuild (diff) | |
download | smolbote-5efa5501fb470b4d9ed48fc243a27768804c8eb4.tar.xz |
ProfileEditor: apply http settings when they're changed
Diffstat (limited to 'plugins/ProfileEditor')
-rw-r--r-- | plugins/ProfileEditor/forms/profilemanagerdialog.cpp | 1 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.cpp | 67 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.h | 1 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.ui | 12 |
4 files changed, 31 insertions, 50 deletions
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp index 1c4d100..d05b480 100644 --- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp +++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp @@ -40,4 +40,5 @@ void ProfileManagerDialog::showProfile(QListWidgetItem *item) auto *v = new ProfileView(profiles->value(item->text()), this); ui->groupBox->layout()->addWidget(v); + v->adjustSize(); } diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp index b53cc7d..b723a61 100644 --- a/plugins/ProfileEditor/forms/profileview.cpp +++ b/plugins/ProfileEditor/forms/profileview.cpp @@ -25,6 +25,27 @@ ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent) m_profile = profile; ui->setupUi(this); + loadProfile(); + + // http tab + connect(ui->userAgent, &QPlainTextEdit::textChanged, profile, [=]() { + profile->setHttpUserAgent(ui->userAgent->toPlainText()); + }); + connect(ui->acceptLanguage, &QPlainTextEdit::textChanged, profile, [=]() { + profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText()); + }); + connect(ui->cacheType, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) { + profile->setHttpCacheType(static_cast<QWebEngineProfile::HttpCacheType>(index)); + }); + connect(ui->cacheSize, &QLineEdit::textChanged, profile, [=](const QString &text) { + profile->setHttpCacheMaximumSize(text.toInt()); + }); + connect(ui->cookiePolicy, QOverload<int>::of(&QComboBox::currentIndexChanged), profile, [=](int index) { + profile->setPersistentCookiesPolicy(static_cast<QWebEngineProfile::PersistentCookiesPolicy>(index)); + }); + connect(ui->clearCache_pushButton, &QPushButton::clicked, profile, &QWebEngineProfile::clearHttpCache); + connect(ui->clearHistory_pushButton, &QPushButton::clicked, profile, &QWebEngineProfile::clearAllVisitedLinks); + QWebEngineSettings *settings = m_profile->settings(); connectSetting(ui->autoloadImages, settings, QWebEngineSettings::AutoLoadImages); connectSetting(ui->autoloadIcons, settings, QWebEngineSettings::AutoLoadIconsForPage); @@ -59,16 +80,6 @@ ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent) connectSetting(ui->fullscreenSupportEnabled, settings, QWebEngineSettings::FullScreenSupportEnabled); connectSetting(ui->screenCaptureEnabled, settings, QWebEngineSettings::ScreenCaptureEnabled); connectSetting(ui->printElementBackgrounds, settings, QWebEngineSettings::PrintElementBackgrounds); - - // actions - connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() { - this->m_profile->clearHttpCache(); - }); - connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() { - this->m_profile->clearAllVisitedLinks(); - }); - - loadProfile(); } ProfileView::~ProfileView() @@ -125,39 +136,3 @@ void ProfileView::loadProfile() // policy ui->cookiePolicy->setCurrentIndex(m_profile->persistentCookiesPolicy()); } - -void ProfileView::updateProfile() -{ - // 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; - } -} diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h index acffbfe..a264cc0 100644 --- a/plugins/ProfileEditor/forms/profileview.h +++ b/plugins/ProfileEditor/forms/profileview.h @@ -27,7 +27,6 @@ public: public slots: void loadProfile(); - void updateProfile(); private: Ui::ProfileView *ui; diff --git a/plugins/ProfileEditor/forms/profileview.ui b/plugins/ProfileEditor/forms/profileview.ui index b55bda8..f0ea24c 100644 --- a/plugins/ProfileEditor/forms/profileview.ui +++ b/plugins/ProfileEditor/forms/profileview.ui @@ -10,6 +10,12 @@ <height>504</height> </rect> </property> + <property name="minimumSize"> + <size> + <width>600</width> + <height>0</height> + </size> + </property> <property name="windowTitle"> <string>Profile</string> </property> @@ -164,9 +170,9 @@ <property name="geometry"> <rect> <x>0</x> - <y>-88</y> - <width>584</width> - <height>797</height> + <y>0</y> + <width>276</width> + <height>855</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_4"> |