diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-17 13:25:38 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-17 13:25:38 +0100 |
commit | 7eb573a67ea883228ff7905190ff46c0f29593b1 (patch) | |
tree | dcad511c1c844419b107f127ee07203e379b62ff /src/forms | |
parent | Fixed release builds defining QT_DEBUG (diff) | |
download | smolbote-7eb573a67ea883228ff7905190ff46c0f29593b1.tar.xz |
ProfileView dialog
Diffstat (limited to 'src/forms')
-rw-r--r-- | src/forms/profilesdialog.cpp | 98 | ||||
-rw-r--r-- | src/forms/profilesdialog.h | 55 | ||||
-rw-r--r-- | src/forms/profilesdialog.ui | 115 | ||||
-rw-r--r-- | src/forms/profileview.cpp | 5 | ||||
-rw-r--r-- | src/forms/profileview.h | 6 | ||||
-rw-r--r-- | src/forms/profileview.ui | 7 |
6 files changed, 13 insertions, 273 deletions
diff --git a/src/forms/profilesdialog.cpp b/src/forms/profilesdialog.cpp deleted file mode 100644 index b295675..0000000 --- a/src/forms/profilesdialog.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - ** - ** smolbote: yet another qute browser - ** Copyright (C) 2017 Xian Nox - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see <http://www.gnu.org/licenses/>. - ** - ******************************************************************************/ - -#include "profilesdialog.h" -#include "ui_profilesdialog.h" - -#include "browser.h" -#include <QListWidget> -#include <QHBoxLayout> -#include <QDialogButtonBox> -#include <QPushButton> -#include <QInputDialog> - -#include "mainwindow.h" - -ProfilesDialog::ProfilesDialog(MainWindow *window, QWidget *parent) : - QDialog(parent), - ui(new Ui::ProfilesDialog) -{ - m_window = window; - - m_view = new ProfileView(nullptr, this); - - // Hide the profile view because we're fancy - // Give focus to the top widget because otherwise the listwidget gains focus - // which causes it to select the first item in it, which in turn triggers the signal - // and so the profile view gets shown even though the user hasn't selected anything - // and so we get to be less fancy, defeating the point of the exercise - // [on linux; other OS's not checked] - m_view->hide(); - this->setFocus(); - - ui->setupUi(this); - ui->horizontalLayout->addWidget(m_view); - ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Load")); - - connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(viewProfile(int))); - connect(ui->new_toolButton, SIGNAL(released()), this, SLOT(newProfile())); - disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(loadSelectedProfile())); - connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), m_view, SLOT(updateProfile())); - - loadProfiles(); -} - -ProfilesDialog::~ProfilesDialog() -{ - delete ui; -} - -void ProfilesDialog::loadProfiles() -{ - ui->listWidget->clear(); - -// for(QString name : browser->profiles()) { -// QListWidgetItem *item = new QListWidgetItem(browser->profile(name)->name(), ui->listWidget); -// item->setData(Qt::UserRole, name); -// } -} - -void ProfilesDialog::newProfile() -{ - bool ok; - QString name = QInputDialog::getText(this, tr("Profile Name"), tr("Profile Name:"), QLineEdit::Normal, tr("Default"), &ok); - -// if(ok) { -// browser->profile(name); -// loadProfiles(); -// } -} - -void ProfilesDialog::loadSelectedProfile() -{ - //m_window->setProfile(browser->profile(ui->listWidget->currentItem()->data(Qt::UserRole).toString())); -} - -void ProfilesDialog::viewProfile(int index) -{ - //m_view->setProfile(browser->profile(ui->listWidget->item(index)->data(Qt::UserRole).toString())); - m_view->show(); -} diff --git a/src/forms/profilesdialog.h b/src/forms/profilesdialog.h deleted file mode 100644 index 066fa7c..0000000 --- a/src/forms/profilesdialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - ** - ** smolbote: yet another qute browser - ** Copyright (C) 2017 Xian Nox - ** - ** This program is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program. If not, see <http://www.gnu.org/licenses/>. - ** - ******************************************************************************/ - -#ifndef PROFILESDIALOG_H -#define PROFILESDIALOG_H - -#include <QDialog> -#include "forms/profileview.h" - -namespace Ui { -class ProfilesDialog; -} - -class MainWindow; -class ProfilesDialog : public QDialog -{ - Q_OBJECT - -public: - explicit ProfilesDialog(MainWindow *window, QWidget *parent = nullptr); - ~ProfilesDialog(); - -public slots: - void loadProfiles(); - - void newProfile(); - -private slots: - void loadSelectedProfile(); - void viewProfile(int index); - -private: - Ui::ProfilesDialog *ui; - ProfileView *m_view; - MainWindow *m_window; -}; - -#endif // PROFILESDIALOG_H diff --git a/src/forms/profilesdialog.ui b/src/forms/profilesdialog.ui deleted file mode 100644 index 7e8bad5..0000000 --- a/src/forms/profilesdialog.ui +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProfilesDialog</class> - <widget class="QDialog" name="ProfilesDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>580</width> - <height>620</height> - </rect> - </property> - <property name="windowTitle"> - <string>Profiles</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QListWidget" name="listWidget"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="buttons_horizontalLayout"> - <item> - <widget class="QToolButton" name="new_toolButton"> - <property name="text"> - <string>New</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="clone_toolButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Clone</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="delete_toolButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Save</set> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProfilesDialog</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>ProfilesDialog</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> -</ui> diff --git a/src/forms/profileview.cpp b/src/forms/profileview.cpp index 6977b61..5e02179 100644 --- a/src/forms/profileview.cpp +++ b/src/forms/profileview.cpp @@ -33,7 +33,7 @@ #include <QFormLayout> ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) : - QWidget(parent), + QDialog(parent), ui(new Ui::ProfileView) { ui->setupUi(this); @@ -47,7 +47,8 @@ ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) : this->m_profile->clearAllVisitedLinks(); }); - //connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(updateProfile())); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ProfileView::updateProfile); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ProfileView::close); } ProfileView::~ProfileView() diff --git a/src/forms/profileview.h b/src/forms/profileview.h index a2ac98e..54ef019 100644 --- a/src/forms/profileview.h +++ b/src/forms/profileview.h @@ -21,7 +21,7 @@ #ifndef PROFILEDIALOG_H #define PROFILEDIALOG_H -#include <QWidget> +#include <QDialog> namespace Ui { class ProfileView; @@ -29,12 +29,12 @@ class ProfileView; class WebEngineProfile; class CookiesForm; -class ProfileView : public QWidget +class ProfileView : public QDialog { Q_OBJECT public: - explicit ProfileView(WebEngineProfile *profile, QWidget *parent = 0); + explicit ProfileView(WebEngineProfile *profile, QWidget *parent = nullptr); ~ProfileView(); void setProfile(WebEngineProfile *profile); diff --git a/src/forms/profileview.ui b/src/forms/profileview.ui index 5823d02..7590e87 100644 --- a/src/forms/profileview.ui +++ b/src/forms/profileview.ui @@ -216,6 +216,13 @@ </widget> </widget> </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> + </property> + </widget> + </item> </layout> </widget> <resources/> |