diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-26 19:51:52 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-06-26 19:51:52 +0200 |
commit | 5825451aef1a762bfaeff2d37c09b3790deee7b1 (patch) | |
tree | 75feca7f6483e25d9bd920645e6044d3bb22966b /src/mainwindow | |
parent | Update pkgbuild (diff) | |
download | smolbote-5825451aef1a762bfaeff2d37c09b3790deee7b1.tar.xz |
Socket messages are json formatted
Diffstat (limited to 'src/mainwindow')
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 11 | ||||
-rw-r--r-- | src/mainwindow/mainwindow.h | 2 | ||||
-rw-r--r-- | src/mainwindow/subwindow.cpp | 15 | ||||
-rw-r--r-- | src/mainwindow/subwindow.h | 3 |
4 files changed, 25 insertions, 6 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 07ac8f0..9a9b8e8 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -28,6 +28,7 @@ #include <QToolBar> #include <QUrl> #include <configuration/configuration.h> +#include <webprofile.h> #ifdef QT_DEBUG #include "session.h" @@ -267,6 +268,16 @@ SubWindow *MainWindow::currentSubWindow() const return qobject_cast<SubWindow *>(mdiArea->currentSubWindow()); } +SubWindow *MainWindow::createSubWindow(WebProfile *profile) +{ + auto *w = new SubWindow(m_config->section("window"), this); + w->setProfile(profile); + mdiArea->addSubWindow(w); + w->showMaximized(); + w->setFocus(); + return w; +} + SubWindow *MainWindow::createSubWindow(const QString &url) { auto *w = new SubWindow(m_config->section("window"), this); diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h index 9cb65d6..287602a 100644 --- a/src/mainwindow/mainwindow.h +++ b/src/mainwindow/mainwindow.h @@ -21,6 +21,7 @@ class AddressBar; class SearchForm; class WebView; class NavigationBar; +class WebProfile; class MainWindow : public QMainWindow { friend class Browser; @@ -47,6 +48,7 @@ public: public slots: void createTab(const QUrl &url); + SubWindow *createSubWindow(WebProfile *profile); SubWindow *createSubWindow(const QString &url = QString()); void setView(WebView *view); diff --git a/src/mainwindow/subwindow.cpp b/src/mainwindow/subwindow.cpp index 354e07e..bcddabf 100644 --- a/src/mainwindow/subwindow.cpp +++ b/src/mainwindow/subwindow.cpp @@ -31,14 +31,14 @@ SubWindow::SubWindow(const QHash<QString, QString> &config, QWidget *parent, Qt: resize(800, 600); setWidget(tabWidget); - profile = WebProfile::defaultProfile(); + m_profile = WebProfile::defaultProfile(); // system menu { auto *menu = systemMenu(); menu->addSeparator(); - auto *profileName_action = menu->addAction(tr("Profile: %1").arg(profile->name())); + auto *profileName_action = menu->addAction(tr("Profile: %1").arg(m_profile->name())); profileName_action->setEnabled(false); auto *loadProfile_menu = menu->addMenu(tr("Load profile")); @@ -130,16 +130,21 @@ WebView *SubWindow::view(int index) const void SubWindow::setProfile(WebProfile *profile) { Q_CHECK_PTR(profile); - this->profile = profile; + this->m_profile = profile; for(int i = 0; i < tabWidget->count(); ++i) { auto *view = qobject_cast<WebView *>(tabWidget->widget(i)); view->setProfile(profile); } } +WebProfile *SubWindow::profile() const +{ + return m_profile; +} + int SubWindow::addTab(const QUrl &url) { - auto *view = new WebView(profile, this); + auto *view = new WebView(m_profile, this); if(!url.isEmpty()) view->load(url); return tabWidget->addTab(view); @@ -153,7 +158,7 @@ void SubWindow::setCurrentTab(int index) QJsonObject SubWindow::session() const { QJsonObject obj; - obj.insert("profile", ProfileManager::id(profile)); + obj.insert("profile", ProfileManager::id(m_profile)); QJsonArray tabs; for(int i = 0; i < tabWidget->count(); ++i) { diff --git a/src/mainwindow/subwindow.h b/src/mainwindow/subwindow.h index d5f4f4c..e6d7177 100644 --- a/src/mainwindow/subwindow.h +++ b/src/mainwindow/subwindow.h @@ -28,6 +28,7 @@ public: WebView *view(int index) const; void setProfile(WebProfile *profile); + WebProfile *profile() const; QJsonObject session() const; @@ -40,7 +41,7 @@ public slots: void setCurrentTab(int index); private: - WebProfile *profile; + WebProfile *m_profile; TabWidget *tabWidget; QMetaObject::Connection titleConnection; |