aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/subwindow.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-28 10:21:47 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-28 10:21:47 +0200
commit0d93cf6fea0a5bae6bdf4adc15d5d6fd3306d0e6 (patch)
tree8055cb02033892be64b16221bd7710f8012bdeed /src/mainwindow/subwindow.cpp
parentSocket messages are json formatted (diff)
downloadsmolbote-0d93cf6fea0a5bae6bdf4adc15d5d6fd3306d0e6.tar.xz
Add --session parameter to load a session json
Add Session menu to main window
Diffstat (limited to 'src/mainwindow/subwindow.cpp')
-rw-r--r--src/mainwindow/subwindow.cpp28
1 files changed, 7 insertions, 21 deletions
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<WebView *>(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<WebView *>(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;
-}