From de247a9ccff6903c7c7b956dd4d85e4f0c3b9445 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 2 Apr 2017 15:47:17 +0200 Subject: Some code cleanup --- src/mainwindow.cpp | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 465d02a..5c6f0ca 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -73,8 +73,8 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : // Profile menu QMenu *profileMenu = new QMenu(tr("Profile"), menuBar); menuBar->addMenu(profileMenu); - profileMenu->addAction(tr("View profile"), this, SLOT(execProfileEditor())); - profileMenu->addAction(tr("Load profile"), this, SLOT(loadProfileGUI())); + profileMenu->addAction(tr("View profile"), this, SLOT(profileAction())); + profileMenu->addAction(tr("Load profile"), this, SLOT(loadProfile())); //profileMenu->addAction(tr("Settings")); profileMenu->addAction(tr("Cookies"), this, SLOT(cookiesAction())); @@ -96,7 +96,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*))); // Load profile - loadProfile(sSettings->value("browser.profile.default").toString()); + m_profile = qApp->profile(sSettings->value("browser.profile.default").toString()); // loading bar ui->statusBar->addPermanentWidget(progressBar); @@ -183,36 +183,20 @@ void MainWindow::about() dlg->exec(); } -void MainWindow::loadProfile(const QString &name) +void MainWindow::loadProfile(const QString name) { - if(m_profile) { - m_profile->deleteLater(); - } - if(name.isEmpty()) { - //profileName = tr("Off the record"); - m_profile = new WebEngineProfile(this); - qDebug("Creating off-the-record profile"); + bool ok; + QString _name = QInputDialog::getText(this, tr("Load Profile"), tr("Enter Profile name"), QLineEdit::Normal, QString(""), &ok); + if(ok) { + m_profile = qApp->profile(_name); + } else { + return; + } } else { - //profileName = name; - m_profile = new WebEngineProfile(name, this); - qDebug("Using profile: %s", qUtf8Printable(m_profile->storageName())); - } - - UrlRequestInterceptor *interceptor = new UrlRequestInterceptor(this); - interceptor->setSubscription(blocklistManager); - m_profile->setRequestInterceptor(interceptor); - connect(m_profile, SIGNAL(downloadRequested(QWebEngineDownloadItem*)), Browser::instance()->downloads(), SLOT(addDownload(QWebEngineDownloadItem*))); -} - -void MainWindow::loadProfileGUI() -{ - bool ok; - QString name = QInputDialog::getText(this, tr("Load Profile"), tr("Enter Profile name"), QLineEdit::Normal, QString(""), &ok); - if(ok) { - loadProfile(name); - tabBar->setProfile(m_profile); + m_profile = qApp->profile(name); } + tabBar->setProfile(m_profile); } void MainWindow::handleNewWindow(const QUrl &url) @@ -256,7 +240,7 @@ void MainWindow::handleTitleUpdated(const QString &title) setWindowTitle(sSettings->value("window.title").toString().replace("title", title).replace("profile", m_profile->storageName())); } -void MainWindow::execProfileEditor() +void MainWindow::profileAction() { m_profile->dialog()->showProfile(); } -- cgit v1.2.1