From f15af11e4b6ad5dfa1be5107c2db0ddad6480f5b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 14 Dec 2018 14:25:04 +0100 Subject: Add SaveSessionDialog --- src/mainwindow/menubar.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/mainwindow') diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp index 0429ffd..84ce24f 100644 --- a/src/mainwindow/menubar.cpp +++ b/src/mainwindow/menubar.cpp @@ -13,6 +13,7 @@ #include "downloadswidget.h" #include "mainwindow.h" #include "profilemanager.h" +#include "session/savesessiondialog.h" #include "session/sessiondialog.h" #include "subwindow/subwindow.h" #include "webengine/webview.h" @@ -69,21 +70,18 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent) smolbote->addSeparator(); const QString sessionPath = config->value("browser.session.path").value(); - smolbote->addAction(tr("Save Session"), parent, [parent, sessionPath]() { - const QString filename = QFileDialog::getSaveFileName(parent, tr("Save Session"), sessionPath, tr("JSON (*.json)")); - QFile output(filename); - if(output.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { - auto *browser = qobject_cast(qApp); - auto data = Session::_session(browser->windows()); - output.write(QJsonDocument(data).toJson()); - output.close(); - } + auto *actionSaveSession = smolbote->addAction(tr("Save Session"), parent, [sessionPath]() { + auto *sessionDialog = new SaveSessionDialog(nullptr); + if(sessionDialog->exec()) + sessionDialog->save(sessionPath); }); + config->setShortcut(actionSaveSession, "mainwindow.shortcuts.saveSession"); - smolbote->addAction(tr("Open Session"), parent, [parent]() { + auto *actionOpenSession = smolbote->addAction(tr("Open Session"), parent, [parent]() { auto *sessionDialog = new SessionDialog(parent); sessionDialog->exec(); }); + config->setShortcut(actionOpenSession, "mainwindow.shortcuts.openSession"); smolbote->addSeparator(); auto *actionBookmarks = smolbote->addAction(tr("Bookmarks"), browser, [browser, parent]() { -- cgit v1.2.1