aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-04-02 15:47:01 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-04-02 15:47:01 +0200
commita6e6823da845ca14d37d8914c80185257e8c0e62 (patch)
tree1c0126f5a78bc95a6f536d2b091cf762972943c9 /src/webengine
parentUpdated documentation (diff)
downloadsmolbote-a6e6823da845ca14d37d8914c80185257e8c0e62.tar.xz
Refactoring TabBar
- cleaned up code - moved to mainwindow/widgets - add Close tabs left/right to context menu
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/webengineprofile.cpp16
-rw-r--r--src/webengine/webengineprofile.h4
-rw-r--r--src/webengine/webview.cpp11
-rw-r--r--src/webengine/webview.h3
4 files changed, 20 insertions, 14 deletions
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
index 263dcb5..55af9f2 100644
--- a/src/webengine/webengineprofile.cpp
+++ b/src/webengine/webengineprofile.cpp
@@ -51,25 +51,17 @@ QUrl WebEngineProfile::newtab() const
return m_newtab;
}
-void WebEngineProfile::loadProfile(const QString &path)
+void WebEngineProfile::loadProfile(QHash<QString, QString> conf, const QString &path)
{
m_configPath = path;
- // check if config file exists
- if(!QFileInfo::exists(m_configPath)) {
-#ifdef QT_DEBUG
- qDebug("No config for profile '%s': %s", qUtf8Printable(m_name), qUtf8Printable(m_configPath));
-#endif
- return;
- }
-
#ifdef QT_DEBUG
qDebug("Reading config for profile '%s': %s", qUtf8Printable(m_name), qUtf8Printable(m_configPath));
#endif
QSettings config(m_configPath, QSettings::IniFormat);
- m_homepage = config.value("homepage", m_homepage).toUrl();
- m_newtab = config.value("newtab", m_newtab).toUrl();
+ m_homepage = config.value("homepage", conf["profile.homepage"]).toUrl();
+ m_newtab = config.value("newtab", conf["profile.newtab"]).toUrl();
config.beginGroup("http");
setHttpUserAgent(config.value("userAgent", httpUserAgent()).toString());
@@ -84,7 +76,7 @@ void WebEngineProfile::loadProfile(const QString &path)
setHttpCacheType(QWebEngineProfile::NoCache);
}
}
- setHttpCacheMaximumSize(config.value("cacheSize").toInt());
+ setHttpCacheMaximumSize(config.value("cacheSize", httpCacheMaximumSize()).toInt());
config.endGroup(); // http
config.beginGroup("policy");
diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h
index 6a0d4e2..76295d3 100644
--- a/src/webengine/webengineprofile.h
+++ b/src/webengine/webengineprofile.h
@@ -9,9 +9,9 @@
#ifndef SMOLBOTE_WEBENGINEPROFILE_H
#define SMOLBOTE_WEBENGINEPROFILE_H
+#include "cookiefilter.h"
#include <QUrl>
#include <QWebEngineProfile>
-#include "cookiefilter.h"
class WebEngineProfile : public QWebEngineProfile
{
@@ -27,7 +27,7 @@ public:
QUrl newtab() const;
public slots:
- void loadProfile(const QString &path);
+ void loadProfile(QHash<QString, QString> conf, const QString &path);
void saveProfile(const QString &path = QString());
private:
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 7ca3280..520ce50 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -13,6 +13,7 @@
#include <QDialog>
#include <QStatusBar>
#include <QVBoxLayout>
+#include "mainwindow/widgets/tabbar.h"
WebView::WebView(MainWindow *parentMainWindow, QWidget *parent)
: QWebEngineView(parent)
@@ -127,3 +128,13 @@ void WebView::triggerViewAction(WebView::ViewAction action)
break;
}
}
+
+WebView *createWebView(const QUrl &url, WebEngineProfile *profile, MainWindow *parent)
+{
+ auto *view = new WebView(parent);
+ auto *page = new WebPage(profile);
+ view->setPage(page);
+ page->load(url);
+
+ return view;
+}
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index 1fab1db..0750aee 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -14,6 +14,7 @@
class QMenu;
class MainWindow;
+class WebEngineProfile;
class WebView : public QWebEngineView
{
Q_OBJECT
@@ -62,4 +63,6 @@ private:
QWebEnginePage *m_devToolsPage;
};
+WebView *createWebView(const QUrl &url, WebEngineProfile *profile, MainWindow *parent);
+
#endif // SMOLBOTE_WEBVIEW_H