From 7eb573a67ea883228ff7905190ff46c0f29593b1 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 17 Dec 2017 13:25:38 +0100 Subject: ProfileView dialog --- src/forms/profilesdialog.cpp | 98 ------------------------------------ src/forms/profilesdialog.h | 55 --------------------- src/forms/profilesdialog.ui | 115 ------------------------------------------- src/forms/profileview.cpp | 5 +- src/forms/profileview.h | 6 +-- src/forms/profileview.ui | 7 +++ 6 files changed, 13 insertions(+), 273 deletions(-) delete mode 100644 src/forms/profilesdialog.cpp delete mode 100644 src/forms/profilesdialog.h delete mode 100644 src/forms/profilesdialog.ui (limited to 'src/forms') 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 . - ** - ******************************************************************************/ - -#include "profilesdialog.h" -#include "ui_profilesdialog.h" - -#include "browser.h" -#include -#include -#include -#include -#include - -#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 . - ** - ******************************************************************************/ - -#ifndef PROFILESDIALOG_H -#define PROFILESDIALOG_H - -#include -#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 @@ - - - ProfilesDialog - - - - 0 - 0 - 580 - 620 - - - - Profiles - - - - - - - - - - - - - - - New - - - - - - - false - - - Clone - - - - - - - false - - - Delete - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Save - - - - - - - - - - - buttonBox - accepted() - ProfilesDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ProfilesDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - 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 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 +#include 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 @@ + + + + QDialogButtonBox::Close|QDialogButtonBox::Save + + + -- cgit v1.2.1