diff options
Diffstat (limited to 'src/mainwindow')
| -rw-r--r-- | src/mainwindow/mainwindow.cpp | 22 | 
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 80e4faa..a01cb94 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -12,7 +12,7 @@  #include "config.h"  #include "configuration.h"  #include "profilemanager.h" -#include "session.h" +#include "session/session.h"  #include "session/sessiondialog.h"  #include "subwindow/subwindow.h"  #include "ui_mainwindow.h" @@ -119,13 +119,33 @@ 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)"));              QFile output(filename);              if(output.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {                  output.write(QJsonDocument(Session::window(this)).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();  | 
