aboutsummaryrefslogtreecommitdiff
path: root/src/browser.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-05-26 22:23:25 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-28 19:43:45 +0300
commit9c4dd932c6d692178bb8d5265c634126cb415767 (patch)
tree527300f8e710859965c142aed4e779a16b9d4ab6 /src/browser.cpp
parentUpdate ProfileEditor plugin (diff)
downloadsmolbote-9c4dd932c6d692178bb8d5265c634126cb415767.tar.xz
Turn on more warnings by default
- fix clazy warnings - fix various other compiler warnings - bugfix: connect profiles' downloadRequested signal
Diffstat (limited to 'src/browser.cpp')
-rw-r--r--src/browser.cpp96
1 files changed, 46 insertions, 50 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 4f1e02e..f748e2f 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -63,6 +63,49 @@ Browser::Browser(int &argc, char *argv[], bool allowSecondary)
if(auto iconTheme = conf.value<QString>("browser.iconTheme")) {
QIcon::setThemeName(iconTheme.value());
}
+
+ if(auto stylesheet = conf.value<QString>("browser.stylesheet")) {
+ QFile f(stylesheet.value());
+ if(f.open(QIODevice::ReadOnly)) {
+ setStyleSheet(f.readAll());
+ f.close();
+ }
+ }
+
+ // load profiles
+ {
+ const auto profiles = Util::files(conf.value<QString>("profile.path").value(), { "*.profile" });
+ const auto search = conf.value<QString>("profile.search").value();
+ const auto homepage = QUrl::fromUserInput(conf.value<QString>("profile.homepage").value());
+ const auto newtab = QUrl::fromUserInput(conf.value<QString>("profile.newtab").value());
+ const auto default_id = conf.value<QString>("profile.default").value();
+ m_profileManager = std::make_unique<WebProfileManager<false>>(profiles, default_id, search, homepage, newtab);
+ m_profileManager->make_global();
+
+ for(auto &id : m_profileManager->idList()) {
+ spdlog::info("Added profile\t{}", qUtf8Printable(id));
+ }
+
+ // set default profile
+ auto *profile = m_profileManager->profile(default_id);
+ spdlog::info("Default profile\t{}{}\t{}", qUtf8Printable(default_id), profile->isOffTheRecord() ? "*" : "", qUtf8Printable(profile->name()));
+ }
+
+ // downloads
+ m_downloads = std::make_unique<DownloadsWidget>(conf.value<QString>("downloads.path").value());
+ m_profileManager->walk([this](const QString &, WebProfile *profile, QSettings *) {
+ connect(profile, &QWebEngineProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload);
+ });
+
+ // bookmarks
+ m_bookmarks = std::make_shared<BookmarksWidget>(QString::fromStdString(conf.value<std::string>("bookmarks.path").value()));
+ connect(m_bookmarks.get(), &BookmarksWidget::openUrl, this, [this](const QUrl &url) {
+ m_windows.last()->createTab(url);
+ });
+
+ auto *timer = new QTimer(this);
+ connect(timer, &QTimer::timeout, m_bookmarks.get(), &BookmarksWidget::save);
+ timer->start(5 * 60 * 1000); // 5min * 60sec * 1000ms
}
Browser::~Browser()
@@ -86,7 +129,7 @@ void Browser::about()
void Browser::aboutPlugins()
{
auto *dlg = new AboutPluginDialog;
- for(auto *info : m_plugins) {
+ for(auto *info : qAsConst(m_plugins)) {
dlg->add(info->loader);
}
dlg->exec();
@@ -118,53 +161,6 @@ bool Browser::loadPlugin(const QString &path)
return true;
}
-void Browser::setup()
-{
- Configuration conf;
-
- if(auto stylesheet = conf.value<QString>("browser.stylesheet")) {
- QFile f(stylesheet.value());
- if(f.open(QIODevice::ReadOnly)) {
- setStyleSheet(f.readAll());
- f.close();
- }
- }
-
- // downloads
- m_downloads = std::make_unique<DownloadsWidget>(conf.value<QString>("downloads.path").value());
-
- // load profiles
- {
- const auto profiles = Util::files(conf.value<QString>("profile.path").value(), { "*.profile" });
- const auto search = conf.value<QString>("profile.search").value();
- const auto homepage = QUrl::fromUserInput(conf.value<QString>("profile.homepage").value());
- const auto newtab = QUrl::fromUserInput(conf.value<QString>("profile.newtab").value());
- const auto default_id = conf.value<QString>("profile.default").value();
- m_profileManager = std::make_unique<WebProfileManager<false>>(profiles, default_id, search, homepage, newtab);
- m_profileManager->make_global();
-
- for(const auto &id : m_profileManager->idList()) {
- spdlog::info("Added profile\t{}", qUtf8Printable(id));
- }
-
- // set default profile
- auto *profile = m_profileManager->profile(default_id);
- spdlog::info("Default profile\t{}{}\t{}", qUtf8Printable(default_id), profile->isOffTheRecord() ? "*" : "", qUtf8Printable(profile->name()));
- }
-
- // bookmarks
- m_bookmarks = std::make_shared<BookmarksWidget>(QString::fromStdString(conf.value<std::string>("bookmarks.path").value()));
-
- connect(m_bookmarks.get(), &BookmarksWidget::openUrl, this, [this](const QUrl &url) {
- m_windows.last()->createTab(url);
- });
-
- auto *timer = new QTimer(this);
- connect(timer, &QTimer::timeout, m_bookmarks.get(), &BookmarksWidget::save);
- // 5min * 60sec * 1000ms
- timer->start(5 * 60 * 1000);
-}
-
void Browser::showWidget(QWidget *widget, MainWindow *where) const
{
bool wasVisible = widget->isVisible();
@@ -191,8 +187,8 @@ void Browser::open(const QVector<Session::MainWindow> &data, bool merge)
window->createTab(tab);
}
} else {
- for(const auto &data : windowData.subwindows) {
- window->createSubWindow(data);
+ for(const auto &window_data : windowData.subwindows) {
+ window->createSubWindow(window_data);
}
}