diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-05-28 12:46:11 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-05-28 12:46:11 +0200 |
commit | 27742143d60e80bc925439e44664cc23c472f433 (patch) | |
tree | f6554dfe136ae290f1cce6da7a3dc36453c937c4 /src/forms | |
parent | Profile improvements (diff) | |
download | smolbote-27742143d60e80bc925439e44664cc23c472f433.tar.xz |
Profiles dialog
Diffstat (limited to 'src/forms')
-rw-r--r-- | src/forms/profilesdialog.cpp | 17 | ||||
-rw-r--r-- | src/forms/profilesdialog.h | 3 | ||||
-rw-r--r-- | src/forms/profilesdialog.ui | 9 | ||||
-rw-r--r-- | src/forms/profileview.cpp (renamed from src/forms/profiledialog.cpp) | 60 | ||||
-rw-r--r-- | src/forms/profileview.h (renamed from src/forms/profiledialog.h) | 14 | ||||
-rw-r--r-- | src/forms/profileview.ui (renamed from src/forms/profiledialog.ui) | 50 |
6 files changed, 73 insertions, 80 deletions
diff --git a/src/forms/profilesdialog.cpp b/src/forms/profilesdialog.cpp index c77208d..cf6791c 100644 --- a/src/forms/profilesdialog.cpp +++ b/src/forms/profilesdialog.cpp @@ -23,14 +23,19 @@ #include "browser.h" #include <QListWidget> +#include <QHBoxLayout> ProfilesDialog::ProfilesDialog(MainWindow *window, QWidget *parent) : QDialog(parent), ui(new Ui::ProfilesDialog) { - ui->setupUi(this); m_window = window; + m_view = new ProfileView(0, this); + ui->setupUi(this); + ui->horizontalLayout->addWidget(m_view); + + connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(viewProfile(int))); connect(this, SIGNAL(accepted()), this, SLOT(loadSelectedProfile())); } @@ -43,12 +48,18 @@ int ProfilesDialog::exec() { qDebug("Showing..."); for(QString name : qApp->profiles()) { - ui->listWidget->addItem(name); + QListWidgetItem *item = new QListWidgetItem(qApp->profile(name)->name(), ui->listWidget); + item->setData(Qt::UserRole, name); } return QDialog::exec(); } void ProfilesDialog::loadSelectedProfile() { - m_window->setProfile(qApp->profile(ui->listWidget->currentItem()->text())); + m_window->setProfile(qApp->profile(ui->listWidget->currentItem()->data(Qt::UserRole).toString())); +} + +void ProfilesDialog::viewProfile(int index) +{ + m_view->setProfile(qApp->profile(ui->listWidget->item(index)->data(Qt::UserRole).toString())); } diff --git a/src/forms/profilesdialog.h b/src/forms/profilesdialog.h index bb6655b..302bf82 100644 --- a/src/forms/profilesdialog.h +++ b/src/forms/profilesdialog.h @@ -22,6 +22,7 @@ #define PROFILESDIALOG_H #include <QDialog> +#include "forms/profileview.h" namespace Ui { class ProfilesDialog; @@ -41,9 +42,11 @@ public slots: private slots: void loadSelectedProfile(); + void viewProfile(int index); private: Ui::ProfilesDialog *ui; + ProfileView *m_view; MainWindow *m_window; }; diff --git a/src/forms/profilesdialog.ui b/src/forms/profilesdialog.ui index 880e441..7675a9d 100644 --- a/src/forms/profilesdialog.ui +++ b/src/forms/profilesdialog.ui @@ -6,12 +6,12 @@ <rect> <x>0</x> <y>0</y> - <width>564</width> - <height>458</height> + <width>580</width> + <height>620</height> </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>Profiles</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> @@ -19,9 +19,6 @@ <item> <widget class="QListWidget" name="listWidget"/> </item> - <item> - <widget class="QWidget" name="widget" native="true"/> - </item> </layout> </item> <item> diff --git a/src/forms/profiledialog.cpp b/src/forms/profileview.cpp index 4d6c047..9d2e9ed 100644 --- a/src/forms/profiledialog.cpp +++ b/src/forms/profileview.cpp @@ -18,8 +18,8 @@ ** ******************************************************************************/ -#include "profiledialog.h" -#include "ui_profiledialog.h" +#include "profileview.h" +#include "ui_profileview.h" #include <QLineEdit> #include <QPlainTextEdit> @@ -28,13 +28,38 @@ #include "webengine/webengineprofile.h" #include "forms/cookiesform.h" -ProfileDialog::ProfileDialog(WebEngineProfile *profile, QWidget *parent) : - QDialog(parent), - ui(new Ui::ProfileDialog) -{ - _profile = profile; +#include <QDialogButtonBox> +ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) : + QWidget(parent), + ui(new Ui::ProfileView) +{ ui->setupUi(this); + setProfile(profile); + + // actions + connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() { + this->_profile->clearHttpCache(); + }); + connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() { + this->_profile->clearAllVisitedLinks(); + }); + + connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(updateProfile())); +} + +ProfileView::~ProfileView() +{ + delete ui; +} + +void ProfileView::setProfile(WebEngineProfile *profile) +{ + if(!profile) { + return; + } + + _profile = profile; if(!_profile->storageName().isEmpty()) { setWindowTitle(_profile->storageName()); } else { @@ -56,36 +81,21 @@ ProfileDialog::ProfileDialog(WebEngineProfile *profile, QWidget *parent) : // policy ui->cookiePolicy->setCurrentIndex(_profile->persistentCookiesPolicy()); - - // actions - connect(ui->clearCache_pushButton, &QPushButton::clicked, [this]() { - this->_profile->clearHttpCache(); - }); - connect(ui->clearHistory_pushButton, &QPushButton::clicked, [this]() { - this->_profile->clearAllVisitedLinks(); - }); - - connect(this, SIGNAL(accepted()), this, SLOT(updateProfile())); -} - -ProfileDialog::~ProfileDialog() -{ - delete ui; } -void ProfileDialog::showProfile() +void ProfileView::showProfile() { ui->tabWidget->setCurrentIndex(0); show(); } -void ProfileDialog::showCookies() +void ProfileView::showCookies() { ui->tabWidget->setCurrentIndex(4); show(); } -void ProfileDialog::updateProfile() +void ProfileView::updateProfile() { qDebug("Updating profile..."); diff --git a/src/forms/profiledialog.h b/src/forms/profileview.h index 613ed80..5dbdb59 100644 --- a/src/forms/profiledialog.h +++ b/src/forms/profileview.h @@ -21,21 +21,23 @@ #ifndef PROFILEDIALOG_H #define PROFILEDIALOG_H -#include <QDialog> +#include <QWidget> namespace Ui { -class ProfileDialog; +class ProfileView; } class WebEngineProfile; class CookiesForm; -class ProfileDialog : public QDialog +class ProfileView : public QWidget { Q_OBJECT public: - explicit ProfileDialog(WebEngineProfile *profile, QWidget *parent = 0); - ~ProfileDialog(); + explicit ProfileView(WebEngineProfile *profile, QWidget *parent = 0); + ~ProfileView(); + + void setProfile(WebEngineProfile *profile); public slots: void showProfile(); @@ -46,7 +48,7 @@ private slots: private: WebEngineProfile *_profile; - Ui::ProfileDialog *ui; + Ui::ProfileView *ui; CookiesForm *m_cookiesForm; }; diff --git a/src/forms/profiledialog.ui b/src/forms/profileview.ui index 528d672..e7bcbae 100644 --- a/src/forms/profiledialog.ui +++ b/src/forms/profileview.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>ProfileDialog</class> - <widget class="QDialog" name="ProfileDialog"> + <class>ProfileView</class> + <widget class="QWidget" name="ProfileView"> <property name="geometry"> <rect> <x>0</x> @@ -10,6 +10,12 @@ <height>640</height> </rect> </property> + <property name="minimumSize"> + <size> + <width>200</width> + <height>0</height> + </size> + </property> <property name="windowTitle"> <string>Profile</string> </property> @@ -188,49 +194,13 @@ </item> <item> <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> <property name="standardButtons"> - <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> + <set>QDialogButtonBox::Save</set> </property> </widget> </item> </layout> </widget> <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProfileDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ProfileDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> + <connections/> </ui> |