aboutsummaryrefslogtreecommitdiff
path: root/src/browser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/browser.cpp')
-rw-r--r--src/browser.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 73b466f..fe103a8 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -24,6 +24,7 @@
#include <version.h>
#include <webprofile.h>
#include "profilemanager.h"
+#include <QJsonDocument>
Browser::Browser(int &argc, char *argv[])
: SingleApplication(argc, argv)
@@ -128,27 +129,39 @@ void Browser::setup(const QString &defaultProfile)
connect(WebProfile::defaultProfile(), &WebProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload);
}
-void Browser::createSession(const QString &profileName, bool newWindow, const QStringList &urls)
+void Browser::createSession(const QJsonObject &object)
{
- if(m_windows.isEmpty()) {
- createWindow();
- }
-
- auto *mainwindow = m_windows.last();
- if(newWindow) {
- QString firstUrl; // = WebProfile::defaultProfile()->homepage();
- if(!urls.isEmpty())
- firstUrl = urls.at(0);
- auto *w = mainwindow->createSubWindow(firstUrl);
- for(int i = 1; i < urls.count() - 1; i++) {
- w->addTab(QUrl::fromUserInput(urls.at(i)));
+ MainWindow *mainwindow = nullptr;
+ if(m_windows.isEmpty())
+ mainwindow = createWindow();
+ else
+ mainwindow = m_windows.last();
+
+ const QJsonArray subwindows = object.value("subwindows").toArray();
+
+ for(const QJsonValue &s : subwindows) {
+ const QJsonObject subwindow = s.toObject();
+ const QString profileId = subwindow.value("profile").toString();
+ WebProfile *profile = ProfileManager::profile(profileId);
+ Q_CHECK_PTR(profile);
+
+ SubWindow *window = nullptr;
+ for(SubWindow *w : mainwindow->subWindows()) {
+ if(w->profile() == profile) {
+ window = w;
+ break;
+ }
}
- } else {
- if(urls.isEmpty())
- mainwindow->createTab(WebProfile::defaultProfile()->homepage());
+ if(window == nullptr)
+ window = mainwindow->createSubWindow(profile);
+
+ const QJsonArray tabs = subwindow.value("tabs").toArray();
+ if(tabs.isEmpty())
+ window->addTab(profile->newtab());
else {
- for(const QString &url : urls) {
- mainwindow->createTab(QUrl::fromUserInput(url));
+ for(const QJsonValue &t : subwindow.value("tabs").toArray()) {
+ const QJsonObject tab = t.toObject();
+ window->addTab(QUrl::fromUserInput(tab.value("url").toString()));
}
}
}