diff options
-rw-r--r-- | lib/addressbar/addressbar.cpp | 2 | ||||
-rw-r--r-- | lib/addressbar/completer.cpp | 1 | ||||
-rw-r--r-- | lib/addressbar/urllineedit.cpp | 1 | ||||
-rw-r--r-- | lib/configuration/configuration.cpp | 2 | ||||
-rw-r--r-- | lib/configuration/configuration.h | 6 | ||||
-rw-r--r-- | src/main.cpp | 13 |
6 files changed, 22 insertions, 3 deletions
diff --git a/lib/addressbar/addressbar.cpp b/lib/addressbar/addressbar.cpp index a923e72..2215c0e 100644 --- a/lib/addressbar/addressbar.cpp +++ b/lib/addressbar/addressbar.cpp @@ -30,13 +30,13 @@ AddressBar::AddressBar(const QHash<QString, QString> &config, QWidget *parent) urlBar->selectAll(); }); - connect(urlBar, &UrlLineEdit::textEdited, [=](const QString &text) { std::function<void(QStringList &)> callback = std::bind(&UrlLineEdit::updateCompleter, urlBar, std::placeholders::_1); emit complete(text, callback); }); progressBar = new QProgressBar(this); + progressBar->setObjectName("LoadingBar"); progressBar->setMaximumHeight(5); progressBar->setTextVisible(false); layout()->addWidget(progressBar); diff --git a/lib/addressbar/completer.cpp b/lib/addressbar/completer.cpp index 9b95ac0..6c04775 100644 --- a/lib/addressbar/completer.cpp +++ b/lib/addressbar/completer.cpp @@ -12,6 +12,7 @@ Completer::Completer(QWidget *parent) : QListView(parent) { + setObjectName("Completer"); setWindowFlags(Qt::ToolTip); } diff --git a/lib/addressbar/urllineedit.cpp b/lib/addressbar/urllineedit.cpp index f92518e..ac311b3 100644 --- a/lib/addressbar/urllineedit.cpp +++ b/lib/addressbar/urllineedit.cpp @@ -16,6 +16,7 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) : QLineEdit(parent) , m_listView(new Completer(this)) { + setObjectName("UrlBar"); setPlaceholderText(tr("Enter address")); m_listView->setVisible(false); diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp index 6351348..1829a5e 100644 --- a/lib/configuration/configuration.cpp +++ b/lib/configuration/configuration.cpp @@ -53,6 +53,8 @@ Configuration::Configuration() ; configuration_desc.add_options() + ("browser.stylesheet", po::value<std::string>()) + // main window ui ("mainwindow.height", po::value<int>()->default_value(720)) ("mainwindow.width", po::value<int>()->default_value(1280)) diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h index 5bb9f5d..af75122 100644 --- a/lib/configuration/configuration.h +++ b/lib/configuration/configuration.h @@ -31,11 +31,13 @@ public: { // if setting doesn't exist, we crash // in debug builds, check if setting exists -#ifdef QT_DEBUG + if(vm.count(path) == 0) { +#ifdef QT_DEBUG qWarning("value(%s) does not exist, probably crashing now", path); - } #endif + return std::nullopt; + } if constexpr(std::is_same_v<T, std::string>) { std::string r; diff --git a/src/main.cpp b/src/main.cpp index bfe4ecd..548aec8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,11 +12,15 @@ #include "webengine/webprofile.h" #include <configuration/configuration.h> #include <memory> +#include <QFile> int main(int argc, char **argv) { Browser app(argc, argv); + // set this, otherwise the webview becomes black when using a stylesheet + app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); + // create and load configuration std::shared_ptr<Configuration> config = std::make_shared<Configuration>(); if(!config->parseCommandLine(argc, argv)) { @@ -37,6 +41,15 @@ int main(int argc, char **argv) // if we are the only instance, set up the browser if(isSingleInstance) { + auto stylesheet = config->value<std::string>("browser.stylesheet"); + if(stylesheet) { + QFile f(QString::fromStdString(stylesheet.value())); + if(f.open(QIODevice::ReadOnly)) { + app.setStyleSheet(f.readAll()); + f.close(); + } + } + app.setup(QString::fromStdString(config->value<std::string>("profile.default").value())); QObject::connect(&app, &Browser::messageAvailable, &app, &Browser::createSession); } |