diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-01-25 10:11:33 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-01-25 10:11:33 +0100 |
| commit | 6318845388852c3eccb15ddce619389a3d49317d (patch) | |
| tree | babc6ad3e79675cbdd949e257153a28892c0cde7 | |
| parent | 41652d5f074943cd5fecb4396edec0a8c22f7c7c (diff) | |
set background color on load to black
| -rw-r--r-- | config.hpp | 2 | ||||
| -rw-r--r-- | sb.cpp | 1 | ||||
| -rw-r--r-- | webengine.hpp | 22 |
3 files changed, 24 insertions, 1 deletions
@@ -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; @@ -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<WebEnginePage *>(sender())){ + setUrl(url); + page->deleteLater(); + } + } +}; + QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED |