aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-07-02 14:36:54 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-07-02 14:36:54 +0200
commitf47e32c5d0451308d5f0ff99e31397bd8ce53f73 (patch)
tree33c5ee229529878fc399c159993e2a8538f9d06c
parentConfiguration defaults file (diff)
downloadsmolbote-f47e32c5d0451308d5f0ff99e31397bd8ce53f73.tar.xz
Added homepage button
-rw-r--r--data/poi.toml23
-rw-r--r--smolbote.qbs23
-rw-r--r--src/mainwindow.cpp11
-rw-r--r--src/webengine/webengineprofile.cpp7
-rw-r--r--src/webengine/webengineprofile.h4
-rw-r--r--src/widgets/webviewtabbar.cpp15
-rw-r--r--src/widgets/webviewtabbar.h7
7 files changed, 72 insertions, 18 deletions
diff --git a/data/poi.toml b/data/poi.toml
index 904ad7a..31e1152 100644
--- a/data/poi.toml
+++ b/data/poi.toml
@@ -1,9 +1,21 @@
#
# poi.conf
#
-# §home is ???
-# $cache is ???
-# $settings is ???
+## Settings and default settings
+# There are two parts to the settings - default values and user overrides.
+# The default settings are read from:
+# - /usr/local/share/smolbote/poi.conf
+# - /usr/share/smolbote/poi.conf
+# - /etc/smolbote.d/poi.conf
+# - :/poi.toml
+# The user settings are read from:
+# - any location specified with -c/--config
+# - QStandardPaths::AppConfigLocation + "/poi.conf"
+#
+## Variables
+# §home is QStandardPaths::HomeLocation
+# $cache is QStandardPaths::CacheLocation
+# $settings is the directory where the settings file is located
# General
[general]
@@ -21,6 +33,11 @@ search="https://duckduckgo.com/?q=$term&kp=-1"
default=""
path="$cache/Profiles/"
+[browser.profile.new]
+path="$home/.config/smolbote/profiles"
+homepage="https://duckduckgo.com"
+newtab="about:blank"
+
# Main window settings
[window]
height=720
diff --git a/smolbote.qbs b/smolbote.qbs
index 3ffd488..a70d49e 100644
--- a/smolbote.qbs
+++ b/smolbote.qbs
@@ -3,26 +3,29 @@ import "tools/qbs/GitRepo.js" as GitRepo
Project {
id: project
- // Qt 5.7 has qbs version 1.6.0
- // Qt 5.8 has qbs version 1.7.0
- minimumQbsVersion: "1.6.0"
+ minimumQbsVersion: "1.8.0"
property bool gitVersion: true
// The following define makes your compiler emit warnings if you use any
// feature of Qt which as been marked as deprecated (the exact warnings
- // depend on your compiler). Please consult the documentation of the
- // deprecated API in order to know how to port your code away from it.
+ // depend on your compiler).
property bool deprecatedWarnings: true
- // The code also fails to compile if you use APIs deprecated before Qt 5.7.
- property string deprecatedBefore: "0x050700"
+ // The code also fails to compile if you use APIs deprecated before Qt 5.9.
+ property string deprecatedBefore: "0x050900"
CppApplication {
id: poi
name: "poi"
property stringList defines: []
+ Depends {
+ name: "Qt"
+ versionAtLeast: "5.9.0"
+ submodules: ["core", "widgets", "webengine", "webenginewidgets"]
+ }
+
Probe {
id: git
property string version: ""
@@ -51,8 +54,6 @@ Project {
return defines;
}
- Depends { name: "Qt"; submodules: ["core", "widgets", "webengine", "webenginewidgets"] }
-
Group {
name: "main"
files: [
@@ -83,6 +84,8 @@ Project {
"src/forms/aboutdialog.cpp",
"src/forms/aboutdialog.h",
"src/forms/aboutdialog.ui",
+ "src/webengine/webview.cpp",
+ "src/webengine/webview.h",
"src/widgets/dockingwidget.cpp",
"src/widgets/dockingwidget.h",
"src/widgets/loadingbar.cpp",
@@ -164,8 +167,6 @@ Project {
files: [
"data/resources.qrc",
- "src/webengine/webview.cpp",
- "src/webengine/webview.h",
]
Group {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a72a784..bda8bdb 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -70,18 +70,23 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
QToolButton *backButton = new QToolButton(this);
backButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
connect(backButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map()));
- tabBar->signalMapper()->setMapping(backButton, QWebEnginePage::Back);
+ tabBar->signalMapper()->setMapping(backButton, WebViewTabBar::Back);
QToolButton *forwardButton = new QToolButton(this);
forwardButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward));
connect(forwardButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map()));
- tabBar->signalMapper()->setMapping(forwardButton, QWebEnginePage::Forward);
+ tabBar->signalMapper()->setMapping(forwardButton, WebViewTabBar::Forward);
QToolButton *reloadButton = new QToolButton(this);
reloadButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
connect(reloadButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map()));
- tabBar->signalMapper()->setMapping(reloadButton, QWebEnginePage::Reload);
+ tabBar->signalMapper()->setMapping(reloadButton, WebViewTabBar::Reload);
+ QToolButton *homepageButton = new QToolButton(this);
+ homepageButton->setIcon(style()->standardIcon(QStyle::SP_DirHomeIcon));
+ connect(homepageButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map()));
+ tabBar->signalMapper()->setMapping(homepageButton, WebViewTabBar::Homepage);
navigationToolBar->addWidget(backButton);
navigationToolBar->addWidget(forwardButton);
navigationToolBar->addWidget(reloadButton);
+ navigationToolBar->addWidget(homepageButton);
navigationToolBar->addWidget(urlLineEdit);
this->addToolBar(Qt::TopToolBarArea, navigationToolBar);
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
index ddf62a8..5d00495 100644
--- a/src/webengine/webengineprofile.cpp
+++ b/src/webengine/webengineprofile.cpp
@@ -28,12 +28,14 @@ WebEngineProfile::WebEngineProfile(QObject *parent) :
{
// Off-the-record constructor
m_name = tr("Off-the-record");
+ m_homepage = QUrl("https://duckduckgo.com");
}
WebEngineProfile::WebEngineProfile(const QString &name, const QString &path, QObject *parent) :
QWebEngineProfile(name, parent)
{
m_name = name;
+ m_homepage = QUrl("https://duckduckgo.com");
setPersistentStoragePath(path + name);
setCachePath(path + name);
@@ -126,6 +128,11 @@ ProfileView *WebEngineProfile::dialog()
return m_profileDialog;
}
+QUrl WebEngineProfile::homepage() const
+{
+ return m_homepage;
+}
+
void WebEngineProfile::saveProfile()
{
QSettings config(persistentStoragePath() + "/profile.ini", QSettings::IniFormat);
diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h
index f13b266..8ddf329 100644
--- a/src/webengine/webengineprofile.h
+++ b/src/webengine/webengineprofile.h
@@ -22,6 +22,7 @@
#define WEBENGINEPROFILE_H
#include <QWebEngineProfile>
+#include <QUrl>
#include "forms/profileview.h"
class WebEngineProfile : public QWebEngineProfile
@@ -37,6 +38,8 @@ public:
ProfileView *dialog();
+ QUrl homepage() const;
+
signals:
public slots:
@@ -44,6 +47,7 @@ public slots:
private:
QString m_name;
+ QUrl m_homepage;
ProfileView *m_profileDialog = nullptr;
};
diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp
index 4d3a859..bd24304 100644
--- a/src/widgets/webviewtabbar.cpp
+++ b/src/widgets/webviewtabbar.cpp
@@ -172,5 +172,18 @@ void WebViewTabBar::updateVectorArrangement(int from, int to)
void WebViewTabBar::webAction(int action)
{
- currentView()->pageAction(static_cast<QWebEnginePage::WebAction>(action))->trigger();
+ switch (action) {
+ case WebActions::Back:
+ currentView()->pageAction(QWebEnginePage::Back)->trigger();
+ break;
+ case WebActions::Forward:
+ currentView()->pageAction(QWebEnginePage::Forward)->trigger();
+ break;
+ case WebActions::Reload:
+ currentView()->pageAction(QWebEnginePage::Reload)->trigger();
+ break;
+ case WebActions::Homepage:
+ currentView()->load(m_profile->homepage());
+ break;
+ }
}
diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h
index 31a3ab2..4682a94 100644
--- a/src/widgets/webviewtabbar.h
+++ b/src/widgets/webviewtabbar.h
@@ -31,6 +31,13 @@ class WebViewTabBar : public QTabBar
Q_OBJECT
public:
+ enum WebActions {
+ Back = QWebEnginePage::Back,
+ Forward = QWebEnginePage::Forward,
+ Reload = QWebEnginePage::Reload,
+ Homepage
+ };
+
explicit WebViewTabBar(WebEngineProfile *profile = nullptr, QWidget *parent = 0);
~WebViewTabBar();