diff options
| author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-11-26 00:58:19 +0100 | 
|---|---|---|
| committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-11-26 00:58:19 +0100 | 
| commit | 696743557de6a6b82303618d8f60f08f8978e650 (patch) | |
| tree | 98aeb14150260921e0130c0879d59a65f4a45741 /src/mainwindow | |
| parent | Add Session Dialog (diff) | |
| download | smolbote-696743557de6a6b82303618d8f60f08f8978e650.tar.xz | |
Add Session::view and Session::restoreView
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();  | 
