aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/browser.h2
-rw-r--r--src/main.cpp2
-rw-r--r--src/mainwindow/mainwindow.cpp2
-rw-r--r--src/session.cpp18
-rw-r--r--src/session.h20
5 files changed, 13 insertions, 31 deletions
diff --git a/src/browser.h b/src/browser.h
index 694a3a7..0547168 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -50,7 +50,7 @@ public:
void setup(const QString &defaultProfile);
QJsonObject session() const {
- return JsonSession::session(m_windows);
+ return Session::session(m_windows);
}
public slots:
diff --git a/src/main.cpp b/src/main.cpp
index e7fdcee..41091a4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -194,7 +194,7 @@ int main(int argc, char **argv)
sessionJson.close();
}
} else {
- sessionData = Session::toJsonObject(profile.value(), urls);
+ sessionData = Session::window(profile.value(), urls);
}
if(app.isPrimary() || isStandalone) {
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index cc67b3d..e3c64f5 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -130,7 +130,7 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
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::toJsonObject(this)).toJson());
+ output.write(QJsonDocument(Session::window(this)).toJson());
output.close();
}
});
diff --git a/src/session.cpp b/src/session.cpp
index 9c69088..70e1deb 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -15,26 +15,22 @@
#include <web/profilemanager.h>
-QJsonObject JsonSession::session(QVector<MainWindow *> windows)
+QJsonObject Session::session(QVector<MainWindow *> windows)
{
QJsonObject obj;
QJsonArray windowsArray;
for(const MainWindow *window : windows) {
- windowsArray.append(Session::toJsonObject(window));
+ windowsArray.append(Session::window(window));
}
obj.insert("windows", windowsArray);
return obj;
}
-Session::Session(QObject *parent) : QObject(parent)
+QJsonObject Session::window(const MainWindow *window)
{
-}
-
-QJsonObject Session::toJsonObject(const MainWindow *window)
-{
- QJsonObject session;
+ QJsonObject obj;
QJsonArray subwindows;
for(const SubWindow *subwindow : window->subWindows()) {
@@ -52,12 +48,12 @@ QJsonObject Session::toJsonObject(const MainWindow *window)
subwindows.append(window);
}
- session.insert("subwindows", subwindows);
+ obj.insert("subwindows", subwindows);
- return session;
+ return obj;
}
-QJsonObject Session::toJsonObject(const QString &profile, const QStringList &urls)
+QJsonObject Session::window(const QString &profile, const QStringList &urls)
{
QJsonObject session;
diff --git a/src/session.h b/src/session.h
index c81b2bf..759687c 100644
--- a/src/session.h
+++ b/src/session.h
@@ -9,27 +9,13 @@
#ifndef SMOLBOTE_SESSION_H
#define SMOLBOTE_SESSION_H
-#include <QObject>
#include <QJsonDocument>
class MainWindow;
-
-namespace JsonSession {
+namespace Session {
QJsonObject session(QVector<MainWindow *> windows);
+QJsonObject window(const MainWindow *window);
+QJsonObject window(const QString &profile, const QStringList &urls);
}
-class Session : public QObject
-{
- Q_OBJECT
-public:
- explicit Session(QObject *parent = nullptr);
-
- static QJsonObject toJsonObject(const MainWindow *window);
- static QJsonObject toJsonObject(const QString &profile, const QStringList &urls);
-
-signals:
-
-public slots:
-};
-
#endif // SMOLBOTE_SESSION_H