aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/configuration/configuration.cpp2
-rw-r--r--src/addressbar/urllineedit.cpp4
-rw-r--r--src/addressbar/urllineedit.h1
-rw-r--r--src/browser.cpp1
-rw-r--r--src/webengine/webprofile.cpp8
-rw-r--r--src/webengine/webprofile.h6
-rw-r--r--src/webengine/webview.cpp10
-rw-r--r--src/webengine/webview.h2
8 files changed, 25 insertions, 9 deletions
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp
index 8cbcee0..213e5ef 100644
--- a/lib/configuration/configuration.cpp
+++ b/lib/configuration/configuration.cpp
@@ -72,7 +72,7 @@ Configuration::Configuration()
// default profile name the browser should use; "" is off-the-record
("profile.default", po::value<std::string>()->default_value(""))
("profile.path", po::value<std::string>()->default_value("~/.config/smolbote/profiles.d"))
- ("profile.search", po::value<std::string>()->default_value("https://duckduckgo.com/?q=$term&ia=web"))
+ ("profile.search", po::value<std::string>()->default_value("https://duckduckgo.com/?q=%1&ia=web"))
("profile.homepage", po::value<std::string>()->default_value("about:blank"))
("profile.newtab", po::value<std::string>()->default_value("about:blank"))
diff --git a/src/addressbar/urllineedit.cpp b/src/addressbar/urllineedit.cpp
index d38acdc..e2cb7a5 100644
--- a/src/addressbar/urllineedit.cpp
+++ b/src/addressbar/urllineedit.cpp
@@ -55,8 +55,8 @@ UrlLineEdit::UrlLineEdit(const QHash<QString, QString> &config, QWidget *parent)
// connect signals
connect(this, &QLineEdit::returnPressed, [this]() {
- if(this->text().startsWith('#')) {
- emit searchTermEntered(this->text().mid(1));
+ if(this->text().startsWith('#')) {;
+ m_view->search(this->text().mid(1));
} else {
if(m_view) {
m_view->load(QUrl::fromUserInput(this->text()));
diff --git a/src/addressbar/urllineedit.h b/src/addressbar/urllineedit.h
index 1fe3d3c..d3753f4 100644
--- a/src/addressbar/urllineedit.h
+++ b/src/addressbar/urllineedit.h
@@ -31,7 +31,6 @@ public:
};
signals:
- void searchTermEntered(const QString &term);
void complete(const QString &term);
public slots:
diff --git a/src/browser.cpp b/src/browser.cpp
index 659da14..f1336bc 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -59,6 +59,7 @@ void Browser::setup(const QString &defaultProfile)
// load profiles
if(defaultProfile == "") {
auto *p = new WebProfile(this);
+ p->loadProfile(m_config->section("profile"));
p->setRequestInterceptor(m_urlFilter.get());
connect(p, &WebProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload);
WebProfile::setDefaultProfile(p);
diff --git a/src/webengine/webprofile.cpp b/src/webengine/webprofile.cpp
index 24b23a0..54aab5a 100644
--- a/src/webengine/webprofile.cpp
+++ b/src/webengine/webprofile.cpp
@@ -53,15 +53,19 @@ QUrl WebProfile::newtab() const
return m_newtab;
}
-void WebProfile::loadProfile(QHash<QString, QString> conf, const QString &path)
+void WebProfile::loadProfile(QHash<QString, QString> conf)
{
- m_configPath = path;
+ if(isOffTheRecord())
+ m_configPath = conf.value("profile.path") + "/otr.ini";
+ else
+ m_configPath = conf.value("profile.path") + "/" + storageName() + "/profile.ini";
#ifdef QT_DEBUG
qDebug("Reading config for profile '%s': %s", qUtf8Printable(m_name), qUtf8Printable(m_configPath));
#endif
QSettings config(m_configPath, QSettings::IniFormat);
+ m_search = config.value("search", conf.value("profile.search")).toString();
m_homepage = config.value("homepage", conf["profile.homepage"]).toUrl();
m_newtab = config.value("newtab", conf["profile.newtab"]).toUrl();
diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h
index 41d1aec..1668067 100644
--- a/src/webengine/webprofile.h
+++ b/src/webengine/webprofile.h
@@ -34,11 +34,14 @@ public:
}
QString name() const;
+ QString search() const {
+ return m_search;
+ }
QUrl homepage() const;
QUrl newtab() const;
public slots:
- void loadProfile(QHash<QString, QString> conf, const QString &path);
+ void loadProfile(QHash<QString, QString> conf);
void saveProfile(const QString &path = QString());
private:
@@ -46,6 +49,7 @@ private:
QString m_configPath;
QString m_name;
+ QString m_search = QString("about:blank");
QUrl m_homepage = QUrl("about:blank");
QUrl m_newtab = QUrl("about:blank");
};
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index d145d2b..1e5d8d5 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -74,10 +74,16 @@ int WebView::loadProgress() const
return m_loadProgress;
}
+void WebView::search(const QString& term)
+{
+ const QString searchUrl = m_profile->search().arg(QString(QUrl::toPercentEncoding(term)));
+ load(searchUrl);
+}
+
WebView *WebView::createWindow(QWebEnginePage::WebWindowType type)
{
if(m_parentWindow == nullptr) {
- qDebug("parent window not found!");
+ qDebug("WebView::createWindow: parent window not found, returning nullptr");
return nullptr;
}
@@ -111,7 +117,7 @@ WebView *WebView::createWindow(QWebEnginePage::WebWindowType type)
void WebView::handleLinkHovered(const QString &url)
{
// TODO: tooltip
- qDebug("%s", qUtf8Printable(url));
+ Q_UNUSED(url);
}
void WebView::triggerViewAction(WebView::ViewAction action)
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index a27a61f..ab86ec2 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -38,6 +38,8 @@ public:
bool isLoaded() const;
int loadProgress() const;
+ void search(const QString &term);
+
void triggerViewAction(ViewAction action);
signals: