aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-06-24 10:23:13 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-06-24 10:23:13 +0200
commit7f686d7740cab02f92d158df487341dbc0513b61 (patch)
treee4a8e255309458ae4bc536652ed80d063a3e2753 /src
parentFixed crash when closing last tab (diff)
downloadsmolbote-7f686d7740cab02f92d158df487341dbc0513b61.tar.xz
Some MainWindow and WebViewTabBar cleanup
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp15
-rw-r--r--src/mainwindow.h3
-rw-r--r--src/widgets/webviewtabbar.cpp11
-rw-r--r--src/widgets/webviewtabbar.h8
4 files changed, 21 insertions, 16 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 861f7cf..6944ac7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -90,8 +90,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*)));
// Load profile
- m_profile = qApp->profile(sSettings->value("browser.profile.default").toString());
- tabBar->setProfile(m_profile);
+ tabBar->setProfile(qApp->profile(sSettings->value("browser.profile.default").toString()));
// loading bar
ui->statusBar->addPermanentWidget(progressBar);
@@ -181,8 +180,8 @@ void MainWindow::about()
void MainWindow::setProfile(WebEngineProfile *profile)
{
- m_profile = profile;
- tabBar->setProfile(m_profile);
+ Q_ASSERT(profile != nullptr);
+ tabBar->setProfile(profile);
}
void MainWindow::toggleFullscreen()
@@ -201,7 +200,7 @@ void MainWindow::newWindow(const QUrl &url)
void MainWindow::handleTabChanged(WebView *view)
{
- Q_ASSERT(view);
+ Q_ASSERT(view != nullptr);
// centralWidget can be a nullptr
if(centralWidget()) {
@@ -235,15 +234,15 @@ void MainWindow::handleUrlChanged()
void MainWindow::handleTitleUpdated(const QString &title)
{
- setWindowTitle(sSettings->value("window.title").toString().replace("title", title).replace("profile", m_profile->name()));
+ setWindowTitle(sSettings->value("window.title").toString().replace("title", title).replace("profile", tabBar->profile()->name()));
}
void MainWindow::profileAction()
{
- m_profile->dialog()->showProfile();
+ tabBar->profile()->dialog()->showProfile();
}
void MainWindow::cookiesAction()
{
- m_profile->dialog()->showCookies();
+ tabBar->profile()->dialog()->showCookies();
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index a1cbcc0..ac2a335 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -70,9 +70,6 @@ private slots:
void handleTitleUpdated(const QString &title);
private:
- WebEngineProfile *m_profile = nullptr;
-
- // ui
Ui::MainWindow *ui;
QToolBar *navigationToolBar, *tabToolBar;
WebViewTabBar *tabBar;
diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp
index d57e095..4d3a859 100644
--- a/src/widgets/webviewtabbar.cpp
+++ b/src/widgets/webviewtabbar.cpp
@@ -22,7 +22,7 @@
#include "browser.h"
#include <QAction>
-WebViewTabBar::WebViewTabBar(QWebEngineProfile *profile, QWidget *parent) :
+WebViewTabBar::WebViewTabBar(WebEngineProfile *profile, QWidget *parent) :
QTabBar(parent)
{
m_profile = profile;
@@ -96,8 +96,10 @@ int WebViewTabBar::addTab(const QUrl &url)
return QTabBar::addTab("New Tab");
}
-void WebViewTabBar::setProfile(QWebEngineProfile *profile)
+void WebViewTabBar::setProfile(WebEngineProfile *profile)
{
+ Q_ASSERT(profile != nullptr);
+
m_profile = profile;
for(auto view : qAsConst(m_views)) {
QWebEnginePage *page = new QWebEnginePage(profile);
@@ -106,6 +108,11 @@ void WebViewTabBar::setProfile(QWebEngineProfile *profile)
}
}
+WebEngineProfile *WebViewTabBar::profile()
+{
+ return m_profile;
+}
+
WebView *WebViewTabBar::currentView()
{
return m_views.at(currentIndex());
diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h
index d1ccf81..31a3ab2 100644
--- a/src/widgets/webviewtabbar.h
+++ b/src/widgets/webviewtabbar.h
@@ -24,16 +24,18 @@
#include <QTabBar>
#include "webengine/webview.h"
#include <QSignalMapper>
+#include "webengine/webengineprofile.h"
class WebViewTabBar : public QTabBar
{
Q_OBJECT
public:
- explicit WebViewTabBar(QWebEngineProfile *profile, QWidget *parent = 0);
+ explicit WebViewTabBar(WebEngineProfile *profile = nullptr, QWidget *parent = 0);
~WebViewTabBar();
- void setProfile(QWebEngineProfile *profile);
+ void setProfile(WebEngineProfile *profile);
+ WebEngineProfile *profile();
QSignalMapper *signalMapper();
WebView *currentView();
@@ -62,7 +64,7 @@ private:
QVector<WebView*> m_views;
QSignalMapper *m_signalMapper;
- QWebEngineProfile *m_profile;
+ WebEngineProfile *m_profile = nullptr;
};
#endif // WEBVIEWTABBAR_H