aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow/mainwindow.cpp')
-rw-r--r--src/mainwindow/mainwindow.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index a01cb94..9e6f187 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -95,7 +95,7 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
{
connect(ui->actionNewSubwindow, &QAction::triggered, this, [this, &config]() {
auto *profile = WebProfile::defaultProfile();
- auto *window = createSubWindow(config, profile);
+ auto *window = createSubWindow(config.get(), profile);
window->addTab(profile->newtab(), profile);
});
config->setShortcut(ui->actionNewSubwindow, "mainwindow.shortcuts.newGroup");
@@ -118,34 +118,18 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
// connect session menu
{
- connect(ui->actionSaveSession, &QAction::triggered, this, [this]() {
-#ifndef QT_DEBUG
- const QString filename = QFileDialog::getSaveFileName(this, tr("Save Session"), QDir::homePath(), tr("JSON (*.json)"));
+ const QString sessionPath = config->value<QString>("browser.session.path").value();
+ connect(ui->actionSaveSession, &QAction::triggered, this, [this, sessionPath]() {
+ const QString filename = QFileDialog::getSaveFileName(this, tr("Save Session"), sessionPath, tr("JSON (*.json)"));
QFile output(filename);
if(output.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
- output.write(QJsonDocument(Session::window(this)).toJson());
+ auto *browser = qobject_cast<Browser *>(qApp);
+ auto data = Session::_session(browser->windows());
+ output.write(QJsonDocument(data).toJson());
output.close();
}
-#else
- auto data = Session::view(currentView);
- QJsonDocument doc(data);
- qDebug(qUtf8Printable(doc.toJson()));
-#endif
});
-#ifdef QT_DEBUG
- auto *openViewAction = ui->menuSession->addAction("Open View");
- connect(openViewAction, &QAction::triggered, this, [this]() {
- const QString filename = QFileDialog::getOpenFileName(this, tr("Open View"), QDir::homePath(), tr("JSON (*json)"));
- QFile output(filename);
- if(output.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QJsonDocument doc = QJsonDocument::fromJson(output.readAll());
- Session::restoreView(currentView, doc.object());
- output.close();
- }
- });
-#endif
-
connect(ui->actionLoadSession, &QAction::triggered, this, [this]() {
auto *sessionDialog = new SessionDialog(this);
sessionDialog->exec();
@@ -356,7 +340,7 @@ SubWindow *MainWindow::currentSubWindow() const
return qobject_cast<SubWindow *>(mdiArea->currentSubWindow());
}
-SubWindow *MainWindow::createSubWindow(const std::unique_ptr<Configuration> &config, WebProfile *profile)
+SubWindow *MainWindow::createSubWindow(const Configuration *config, WebProfile *profile)
{
bool shouldMaximize = true;
// if there is a current window, use its maximize state