diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-09 12:05:28 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-10-09 12:05:28 +0200 |
commit | 3639d5789259561c531a3481d7061a0cb492c644 (patch) | |
tree | c9c7ff04022b62cf5be4d4ea31bf28d966ccefda /plugins/ProfileEditor/forms | |
parent | Create .profile file when adding a new profile (diff) | |
download | smolbote-3639d5789259561c531a3481d7061a0cb492c644.tar.xz |
Unlink plugins from lib/ libraries
Diffstat (limited to 'plugins/ProfileEditor/forms')
-rw-r--r-- | plugins/ProfileEditor/forms/newprofiledialog.cpp | 5 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/newprofiledialog.h | 1 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/newprofiledialog.ui | 35 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profilemanagerdialog.cpp | 50 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profilemanagerdialog.h | 19 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.cpp | 11 | ||||
-rw-r--r-- | plugins/ProfileEditor/forms/profileview.h | 6 |
7 files changed, 44 insertions, 83 deletions
diff --git a/plugins/ProfileEditor/forms/newprofiledialog.cpp b/plugins/ProfileEditor/forms/newprofiledialog.cpp index 13c46f8..3ed61d8 100644 --- a/plugins/ProfileEditor/forms/newprofiledialog.cpp +++ b/plugins/ProfileEditor/forms/newprofiledialog.cpp @@ -25,3 +25,8 @@ const QString NewProfileDialog::getId() const { return ui->id_lineEdit->text(); } + +bool NewProfileDialog::getOtr() const +{ + return ui->offTheRecord->isChecked(); +} diff --git a/plugins/ProfileEditor/forms/newprofiledialog.h b/plugins/ProfileEditor/forms/newprofiledialog.h index 84626fa..dd9aa4e 100644 --- a/plugins/ProfileEditor/forms/newprofiledialog.h +++ b/plugins/ProfileEditor/forms/newprofiledialog.h @@ -24,6 +24,7 @@ public: ~NewProfileDialog(); const QString getId() const; + bool getOtr() const; private: Ui::NewProfileDialog *ui; diff --git a/plugins/ProfileEditor/forms/newprofiledialog.ui b/plugins/ProfileEditor/forms/newprofiledialog.ui index c46c3b3..8b4888d 100644 --- a/plugins/ProfileEditor/forms/newprofiledialog.ui +++ b/plugins/ProfileEditor/forms/newprofiledialog.ui @@ -7,28 +7,24 @@ <x>0</x> <y>0</y> <width>320</width> - <height>78</height> + <height>112</height> </rect> </property> <property name="windowTitle"> <string>New Profile</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="id_label"> - <property name="text"> - <string>ID</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="id_lineEdit"/> - </item> - </layout> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="id_label"> + <property name="text"> + <string>ID</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="id_lineEdit"/> </item> - <item> + <item row="2" column="0" colspan="2"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -38,6 +34,13 @@ </property> </widget> </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="offTheRecord"> + <property name="text"> + <string>Off the record</string> + </property> + </widget> + </item> </layout> </widget> <resources/> diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp index b6c1c7e..f5a17b1 100644 --- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp +++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp @@ -8,13 +8,10 @@ #include "profilemanagerdialog.h" #include "profileview.h" -#include "ui_profilemanagerdialog.h" -#include <webprofile.h> #include <QDir> #include <QPointer> -#include "newprofiledialog.h" -ProfileManagerDialog::ProfileManagerDialog(const ProfileManager *profiles, QWidget *parent) +ProfileManagerDialog::ProfileManagerDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::ProfileManagerDialog) { @@ -22,22 +19,6 @@ ProfileManagerDialog::ProfileManagerDialog(const ProfileManager *profiles, QWidg connect(ui->listWidget, &QListWidget::itemPressed, this, &ProfileManagerDialog::showProfile); showProfile(nullptr); - - connect(ui->new_pushButton, &QPushButton::clicked, this, [=]() { - auto *profileDlg = new NewProfileDialog(this); - if(profileDlg->exec() == QDialog::Accepted) { - emit createProfile(profileDlg->getId()); - } - delete profileDlg; - }); - - connect(ui->delete_pushButton, &QPushButton::clicked, this, [=]() { - deleteProfile(ui->listWidget->currentItem()); - }); - - for(const QString &profileId : profiles->idList()) { - addProfile(profiles->profile(profileId)); - } } ProfileManagerDialog::~ProfileManagerDialog() @@ -45,14 +26,13 @@ ProfileManagerDialog::~ProfileManagerDialog() delete ui; } -void ProfileManagerDialog::addProfile(WebProfile *profile) +void ProfileManagerDialog::addProfile(const QString &id, Profile *profile) { Q_CHECK_PTR(profile); - auto *item = new QListWidgetItem(ui->listWidget); - item->setText(profile->name()); + auto *item = new QListWidgetItem(id, ui->listWidget); - auto pointer = QPointer<WebProfile>(profile); + auto pointer = QPointer<Profile>(profile); item->setData(Qt::UserRole, QVariant::fromValue(pointer)); } @@ -71,28 +51,8 @@ void ProfileManagerDialog::showProfile(QListWidgetItem *item) } ui->groupBox->setVisible(true); - auto profile = item->data(Qt::UserRole).value<QPointer<WebProfile>>(); + auto profile = item->data(Qt::UserRole).value<QPointer<Profile>>(); auto *v = new ProfileView(profile.data(), this); ui->groupBox->layout()->addWidget(v); v->adjustSize(); } - -void ProfileManagerDialog::deleteProfile(QListWidgetItem *item) -{ - if(item == nullptr) - return; - - // clear out groupbox layout - QLayoutItem *i; - while((i = ui->groupBox->layout()->takeAt(0)) != nullptr) { - delete i->widget(); - delete i; - } - - auto profile = item->data(Qt::UserRole).value<QPointer<WebProfile>>(); - Q_ASSERT(!profile.isNull()); - - emit removeProfile(profile); - - delete item; -} diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.h b/plugins/ProfileEditor/forms/profilemanagerdialog.h index 35c2111..fe91948 100644 --- a/plugins/ProfileEditor/forms/profilemanagerdialog.h +++ b/plugins/ProfileEditor/forms/profilemanagerdialog.h @@ -11,12 +11,8 @@ #include <QDialog> #include <QVector> -#include <profilemanager.h> - -namespace Ui -{ -class ProfileManagerDialog; -} +#include <profileinterface.h> +#include "ui_profilemanagerdialog.h" class WebProfile; class QListWidgetItem; @@ -24,20 +20,17 @@ class ProfileManagerDialog : public QDialog { Q_OBJECT + friend class ProfileEditorPlugin; + public: - explicit ProfileManagerDialog(const ProfileManager *profiles, QWidget *parent = 0); + explicit ProfileManagerDialog(QWidget *parent = 0); ~ProfileManagerDialog() override; -signals: - void createProfile(const QString &id); - void removeProfile(const WebProfile *profile); - public slots: - void addProfile(WebProfile *profile); + void addProfile(const QString &id, Profile *profile); private slots: void showProfile(QListWidgetItem *item); - void deleteProfile(QListWidgetItem *item); private: Ui::ProfileManagerDialog *ui; diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp index 4a89af6..9a19cfc 100644 --- a/plugins/ProfileEditor/forms/profileview.cpp +++ b/plugins/ProfileEditor/forms/profileview.cpp @@ -8,14 +8,13 @@ #include "profileview.h" #include "ui_profileview.h" -#include <webprofile.h> -#include <profilemanager.h> +#include <profileinterface.h> #include <QWebEngineSettings> #include <QWebEngineCookieStore> #include <QDateTime> #include "newhttpheaderdialog.h" -inline void connectSetting(QCheckBox *checkBox, WebProfile *profile, QWebEngineSettings::WebAttribute attr) +inline void connectSetting(QCheckBox *checkBox, Profile *profile, QWebEngineSettings::WebAttribute attr) { checkBox->setChecked(profile->settings()->testAttribute(attr)); QObject::connect(checkBox, &QCheckBox::clicked, [profile, attr](bool checked) { @@ -24,7 +23,7 @@ inline void connectSetting(QCheckBox *checkBox, WebProfile *profile, QWebEngineS }); } -ProfileView::ProfileView(WebProfile *profile, QWidget *parent) +ProfileView::ProfileView(Profile *profile, QWidget *parent) : QWidget(parent) , ui(new Ui::ProfileView) { @@ -92,8 +91,8 @@ ProfileView::ProfileView(WebProfile *profile, QWidget *parent) //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(m_profile, &Profile::headerChanged, this, &ProfileView::headerChanged); + connect(m_profile, &Profile::headerRemoved, this, &ProfileView::headerRemoved); connect(ui->headers_insert, &QPushButton::clicked, m_profile, [this]() { auto *dlg = new NewHttpHeaderDialog(this); if(dlg->exec() == QDialog::Accepted) { diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h index d05b0f1..7f3e738 100644 --- a/plugins/ProfileEditor/forms/profileview.h +++ b/plugins/ProfileEditor/forms/profileview.h @@ -18,7 +18,7 @@ namespace Ui class ProfileView; } -class WebProfile; +class Profile; class QWebEngineCookieStore; class QCheckBox; @@ -27,7 +27,7 @@ class ProfileView : public QWidget Q_OBJECT public: - explicit ProfileView(WebProfile *profile, QWidget *parent = nullptr); + explicit ProfileView(Profile *profile, QWidget *parent = nullptr); ~ProfileView() override; private slots: @@ -41,7 +41,7 @@ private slots: private: Ui::ProfileView *ui; - WebProfile *m_profile; + Profile *m_profile; }; #endif // PROFILEDIALOG_H |