From 6318845388852c3eccb15ddce619389a3d49317d Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 25 Jan 2023 10:11:33 +0100 Subject: set background color on load to black --- config.hpp | 2 +- sb.cpp | 1 + webengine.hpp | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/config.hpp b/config.hpp index f3337a1..d7b1424 100644 --- a/config.hpp +++ b/config.hpp @@ -1,6 +1,6 @@ const bool enable_smooth_scrollig = true; -const char search_engine[] = "https://duckduckgo.com/?q="; +const char search_engine[] = "https://searx.org/?q="; const char dmenu_args[] = "-s 0"; const unsigned scroll_speed = 100; diff --git a/sb.cpp b/sb.cpp index 11a91f9..812064e 100644 --- a/sb.cpp +++ b/sb.cpp @@ -136,6 +136,7 @@ main(int argc, char **argv) { web = new QWebEngineView(); web->setPage(&page); web->load(QUrl(getenv("WWW_HOME"))); + page.setBackgroundColor(QColor(40, 40, 40)); progressbar.setMaximum(100); progressbar.setMinimum(0); progressbar.setTextVisible(false); diff --git a/webengine.hpp b/webengine.hpp index 08cdbe5..dc73d97 100644 --- a/webengine.hpp +++ b/webengine.hpp @@ -17,6 +17,28 @@ #error "(The moc has changed too much.)" #endif +class WebEnginePage: public QWebEnginePage { +Q_OBJECT +public: + WebEnginePage(QWebEngineProfile *profile) : QWebEnginePage(profile) {}; + virtual ~WebEnginePage() = default; + +protected: + QWebEnginePage *createWindow(WebWindowType){ + WebEnginePage *page = new WebEnginePage(this->profile()); + connect(page, &QWebEnginePage::urlChanged, this, &WebEnginePage::onUrlChanged); + return page; + } + +private: + void onUrlChanged(const QUrl & url){ + if(WebEnginePage *page = qobject_cast(sender())){ + setUrl(url); + page->deleteLater(); + } + } +}; + QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED -- cgit v1.2.3-70-g09d2