From 0d93cf6fea0a5bae6bdf4adc15d5d6fd3306d0e6 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 28 Jun 2018 10:21:47 +0200 Subject: Add --session parameter to load a session json Add Session menu to main window --- src/mainwindow/subwindow.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'src/mainwindow/subwindow.cpp') diff --git a/src/mainwindow/subwindow.cpp b/src/mainwindow/subwindow.cpp index bcddabf..5a1eeda 100644 --- a/src/mainwindow/subwindow.cpp +++ b/src/mainwindow/subwindow.cpp @@ -127,6 +127,11 @@ WebView *SubWindow::view(int index) const return qobject_cast(tabWidget->widget(index)); } +int SubWindow::tabCount() const +{ + return tabWidget->count(); +} + void SubWindow::setProfile(WebProfile *profile) { Q_CHECK_PTR(profile); @@ -142,9 +147,9 @@ WebProfile *SubWindow::profile() const return m_profile; } -int SubWindow::addTab(const QUrl &url) +int SubWindow::addTab(const QUrl &url, WebProfile *profile) { - auto *view = new WebView(m_profile, this); + auto *view = new WebView((profile == nullptr) ? m_profile : profile, this); if(!url.isEmpty()) view->load(url); return tabWidget->addTab(view); @@ -154,22 +159,3 @@ void SubWindow::setCurrentTab(int index) { tabWidget->setCurrentIndex(index); } - -QJsonObject SubWindow::session() const -{ - QJsonObject obj; - obj.insert("profile", ProfileManager::id(m_profile)); - - QJsonArray tabs; - for(int i = 0; i < tabWidget->count(); ++i) { - auto *view = qobject_cast(tabWidget->widget(i)); - if(view) { - QJsonObject tab; - tab.insert(view->url().toString(), ProfileManager::id(view->profile())); - tabs.append(tab); - } - } - obj.insert("tabs", tabs); - - return obj; -} -- cgit v1.2.1