From 8c30d0d5f0ab93c44b6957040fd0a2b3b7749faa Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 12 Jan 2017 19:57:00 +0100 Subject: Profile config loading and saving --- src/mainwindow.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fef3bcc..1f27652 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,7 +20,16 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) : browserInstance = instance; Settings settings; - profile = QWebEngineProfile::defaultProfile(); + // Create the profile + profileName = settings.value("defaults/profile").toString(); + if(profileName.isEmpty()) { + qDebug("Creating off-the-record profile"); + profileName = tr("Off the record"); + profile = new WebEngineProfile(this); + } else { + qDebug("Using profile: %s", qUtf8Printable(profileName)); + profile = new WebEngineProfile(profileName, this); + } ui->setupUi(this); resize(settings.value("window/width", 800).toInt(), settings.value("window/height", 600).toInt()); @@ -36,11 +45,13 @@ MainWindow::MainWindow(Browser *instance, QUrl defaultUrl, QWidget *parent) : // Profile menu QMenuBar *rightBar = new QMenuBar(ui->menuBar); - profileMenu = new QMenu(tr("Profile: ") + profile->storageName()); + profileMenu = new QMenu(tr("Profile: ") + profileName); rightBar->addMenu(profileMenu); ui->menuBar->setCornerWidget(rightBar); profileMenu->addAction(tr("Edit profile"), this, SLOT(createProfileDialog())); profileMenu->addAction(tr("Load profile")); + profileMenu->addAction(tr("Settings")); + profileMenu->addAction(tr("Cookies")); this->addToolBar(Qt::TopToolBarArea, navigationToolBar); this->addToolBarBreak(Qt::TopToolBarArea); @@ -66,6 +77,8 @@ MainWindow::~MainWindow() void MainWindow::createNewTab(const QUrl &url) { QWebEngineView *view = new QWebEngineView(0); + QWebEnginePage *page = new QWebEnginePage(profile, view); + view->setPage(page); view->load(url); tabBar->addTab(view); } -- cgit v1.2.1