diff options
Diffstat (limited to 'src/session.cpp')
-rw-r--r-- | src/session.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/src/session.cpp b/src/session.cpp deleted file mode 100644 index 4e1c6d6..0000000 --- a/src/session.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "session.h" -#include "mainwindow/mainwindow.h" -#include "subwindow/subwindow.h" -#include <QJsonObject> -#include <QJsonArray> -#include "webengine/webview.h" -#include "profilemanager.h" -#include "browser.h" - -QJsonObject Session::session(QVector<MainWindow *> windows) -{ - QJsonObject obj; - - QJsonArray windowsArray; - for(const MainWindow *window : windows) { - windowsArray.append(Session::window(window)); - } - obj.insert("windows", windowsArray); - - return obj; -} - -QJsonObject Session::window(const MainWindow *window) -{ - QJsonObject obj; - auto *profileManager = dynamic_cast<Browser *>(qApp)->getProfileManager(); - - QJsonArray subwindows; - for(const SubWindow *subwindow : window->subWindows()) { - QJsonObject window; - window.insert("profile", profileManager->id(subwindow->profile())); - - QJsonArray tabs; - for(int i = 0; i < subwindow->tabCount(); ++i) { - QJsonObject tab; - tab.insert("url", subwindow->view(i)->url().toString()); - tab.insert("profile", profileManager->id(subwindow->view(i)->profile())); - tabs.append(tab); - } - window.insert("tabs", tabs); - - subwindows.append(window); - } - obj.insert("subwindows", subwindows); - - return obj; -} - -QJsonObject Session::window(const QString &profile, const QStringList &urls) -{ - QJsonObject session; - - QJsonArray subwindows; - { - QJsonObject window; - window.insert("profile", profile); - - QJsonArray tabs; - for(const auto &url : urls) { - QJsonObject tab; - tab.insert("url", url); - tab.insert("profile", profile); - tabs.append(tab); - } - window.insert("tabs", tabs); - - subwindows.append(window); - } - session.insert("subwindows", subwindows); - - return session; -} |