aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/bookmarks/bookmarkswidget.cpp6
-rw-r--r--src/browser.cpp96
-rw-r--r--src/browser.h2
-rw-r--r--src/main.cpp6
-rw-r--r--src/mainwindow/mainwindow.cpp16
-rw-r--r--src/mainwindow/mainwindow.h6
-rw-r--r--src/mainwindow/menubar.cpp92
-rw-r--r--src/mainwindow/widgets/searchform.cpp10
-rw-r--r--src/mainwindow/widgets/searchform.h2
-rw-r--r--src/subwindow/subwindow.cpp16
-rw-r--r--src/subwindow/subwindow.h6
-rw-r--r--src/subwindow/tabwidget.cpp22
-rw-r--r--src/webengine/webpage.cpp4
-rw-r--r--src/webengine/webprofile.h2
-rw-r--r--src/webengine/webview.cpp10
-rw-r--r--src/webengine/webview.h2
-rw-r--r--src/webengine/webviewcontextmenu.cpp2
17 files changed, 145 insertions, 155 deletions
diff --git a/src/bookmarks/bookmarkswidget.cpp b/src/bookmarks/bookmarkswidget.cpp
index e05f291..c7bc5f0 100644
--- a/src/bookmarks/bookmarkswidget.cpp
+++ b/src/bookmarks/bookmarkswidget.cpp
@@ -163,9 +163,9 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
// import button
connect(ui->import_toolButton, &QToolButton::clicked, this, [this]() {
- const auto path = QFileDialog::getOpenFileName(this, tr("Open bookmarks file"), QDir::homePath(), tr("Firefox bookmarks backup (*.json)"));
- if(!path.isEmpty()) {
- loadModel(path, m_model, ui->treeView);
+ const auto import_path = QFileDialog::getOpenFileName(this, tr("Open bookmarks file"), QDir::homePath(), tr("Firefox bookmarks backup (*.json)"));
+ if(!import_path.isEmpty()) {
+ loadModel(import_path, m_model, ui->treeView);
}
});
}
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);
}
}
diff --git a/src/browser.h b/src/browser.h
index 1964267..5b4785b 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -31,8 +31,6 @@ public:
explicit Browser(int &argc, char *argv[], bool allowSecondary = true);
~Browser() final;
- void setup();
-
const QVector<MainWindow *> windows() const
{
return qAsConst(m_windows);
diff --git a/src/main.cpp b/src/main.cpp
index f0c1591..dad1f73 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -132,15 +132,13 @@ int main(int argc, char **argv)
return c.value<QString>("profile.default").value();
}();
- app.setup();
-
QStringList urls;
-
for(const auto &u : args::get(cmd_args)) {
urls.append(QString::fromStdString(u));
}
- if(urls.isEmpty())
+ if(urls.isEmpty()) {
urls.append(QString());
+ }
// if app is primary, create new sessions from received messages
if(app.isPrimary() && !cmd_noRemote) {
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 4ec79b1..64c149c 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -24,7 +24,7 @@
#include <QMessageBox>
#include <QStatusBar>
-MainWindow::MainWindow(const Session::MainWindow &data, QMenu *appMenu, QWidget *parent)
+MainWindow::MainWindow(const Session::MainWindow &mainwindow_data, QMenu *appMenu, QWidget *parent)
: QMainWindow(parent)
{
Configuration config;
@@ -66,7 +66,7 @@ MainWindow::MainWindow(const Session::MainWindow &data, QMenu *appMenu, QWidget
});
QMainWindow::addAction(searchAction);
- for(const auto &s : data.subwindows) {
+ for(const auto &s : mainwindow_data.subwindows) {
createSubWindow(s);
}
if(m_subwindows.isEmpty()) {
@@ -115,19 +115,19 @@ void MainWindow::createTab(const QUrl &url)
}
}
-void MainWindow::createTab(const Session::WebView &data)
+void MainWindow::createTab(const Session::WebView &tab_data)
{
auto *w = qobject_cast<SubWindow *>(centralWidget());
if(w != nullptr) {
- w->addTab(data);
+ w->addTab(tab_data);
}
}
-SubWindow *MainWindow::createSubWindow(const Session::SubWindow &data)
+SubWindow *MainWindow::createSubWindow(const Session::SubWindow &subwindow_data)
{
WebProfileManager profileManager;
- auto *profile = profileManager.profile(data.profile);
+ auto *profile = profileManager.profile(subwindow_data.profile);
if(profile == nullptr) {
profile = WebProfile::defaultProfile();
}
@@ -153,11 +153,11 @@ SubWindow *MainWindow::createSubWindow(const Session::SubWindow &data)
}
});
- if(data.tabs.count() == 0) {
+ if(subwindow_data.tabs.count() == 0) {
w->addTab(profile->newtab());
return w;
}
- for(const auto &tab : data.tabs) {
+ for(const auto &tab : subwindow_data.tabs) {
w->addTab(tab);
}
return w;
diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h
index 31f5658..c5d573e 100644
--- a/src/mainwindow/mainwindow.h
+++ b/src/mainwindow/mainwindow.h
@@ -34,7 +34,7 @@ public:
ToolsMenu
};
- explicit MainWindow(const Session::MainWindow &data, QMenu *appMenu, QWidget *parent = nullptr);
+ explicit MainWindow(const Session::MainWindow &mainwindow_data, QMenu *appMenu, QWidget *parent = nullptr);
MainWindow(const MainWindow &) = delete;
~MainWindow() = default;
@@ -66,8 +66,8 @@ public:
public slots:
void createTab(const QUrl &url);
- void createTab(const Session::WebView &data);
- SubWindow *createSubWindow(const Session::SubWindow &data);
+ void createTab(const Session::WebView &tab_data);
+ SubWindow *createSubWindow(const Session::SubWindow &subwindow_data);
void setCurrentSubWindow(SubWindow *subwindow);
private slots:
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index f8979de..5fc039a 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -87,37 +87,37 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
conf.shortcut<QAction>(*actionDownloads, "shortcuts.window.downloads.show");
window->addSeparator();
- auto *actionNewWindow = window->addAction(tr("New Window"), browser, [browser]() {
- const Session::MainWindow window;
- browser->open({ window }, false);
- });
- conf.shortcut<QAction>(*actionNewWindow, "shortcuts.window.newwindow");
+ auto *actionNewWindow = window->addAction(tr("New Window"), browser, [browser]() {
+ const Session::MainWindow window_data;
+ browser->open({ window_data }, false);
+ });
+ conf.shortcut<QAction>(*actionNewWindow, "shortcuts.window.newwindow");
- auto *actionNewSubwindow = window->addAction(tr("New Subwindow"), parent, [parent]() {
- const Session::SubWindow session;
- parent->createSubWindow(session);
- });
- conf.shortcut<QAction>(*actionNewSubwindow, "shortcuts.window.newgroup");
+ auto *actionNewSubwindow = window->addAction(tr("New Subwindow"), parent, [parent]() {
+ const Session::SubWindow session;
+ parent->createSubWindow(session);
+ });
+ conf.shortcut<QAction>(*actionNewSubwindow, "shortcuts.window.newgroup");
- auto *actionCloseSubwindow = window->addAction(tr("Close Subwindow"), parent, [parent]() {
- parent->currentSubWindow()->close();
- });
- conf.shortcut<QAction>(*actionCloseSubwindow, "shortcuts.subwindow.close");
+ auto *actionCloseSubwindow = window->addAction(tr("Close Subwindow"), parent, [parent]() {
+ parent->currentSubWindow()->close();
+ });
+ conf.shortcut<QAction>(*actionCloseSubwindow, "shortcuts.subwindow.close");
- window->addSeparator()->setText(tr("Toolbars"));
+ window->addSeparator()->setText(tr("Toolbars"));
- bool hasMovableToolbar = false;
+ bool hasMovableToolbar = false;
- for(auto *toolbar : parent->findChildren<QToolBar *>()) {
- auto *action = window->addAction(toolbar->windowTitle());
- action->setCheckable(true);
- action->setChecked(toolbar->isVisible());
- connect(toolbar, &QToolBar::visibilityChanged, action, &QAction::setChecked);
- connect(action, &QAction::triggered, toolbar, &QToolBar::setVisible);
- conf.shortcut<QAction>(*action, qUtf8Printable(toolbar->objectName() + ".show"));
+ for(auto *toolbar : parent->findChildren<QToolBar *>()) {
+ auto *action = window->addAction(toolbar->windowTitle());
+ action->setCheckable(true);
+ action->setChecked(toolbar->isVisible());
+ connect(toolbar, &QToolBar::visibilityChanged, action, &QAction::setChecked);
+ connect(action, &QAction::triggered, toolbar, &QToolBar::setVisible);
+ conf.shortcut<QAction>(*action, qUtf8Printable(toolbar->objectName() + ".show"));
- if(toolbar->isMovable())
- hasMovableToolbar = true;
+ if(toolbar->isMovable())
+ hasMovableToolbar = true;
}
auto *lockAction = window->addAction(tr("Unlock toolbars"));
@@ -169,27 +169,27 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
auto *actionLockClose = subwindow->addAction(tr("Prevent tab from closing"), parent, [parent](bool checked) {
run_if(parent->currentSubWindow(), [checked](SubWindow *_subwindow, int currentIdx) {
- auto data = _subwindow->tabData(currentIdx);
- data.closeLocked = checked;
- _subwindow->setTabData(data, currentIdx);
+ auto tab_data = _subwindow->tabData(currentIdx);
+ tab_data.closeLocked = checked;
+ _subwindow->setTabData(tab_data, currentIdx);
});
});
actionLockClose->setCheckable(true);
auto *actionLockRefresh = subwindow->addAction(tr("Prevent tab from refreshing"), parent, [parent](bool checked) {
run_if(parent->currentSubWindow(), [checked](SubWindow *_subwindow, int currentIdx) {
- auto data = _subwindow->tabData(currentIdx);
- data.refreshLocked = checked;
- _subwindow->setTabData(data, currentIdx);
+ auto tab_data = _subwindow->tabData(currentIdx);
+ tab_data.refreshLocked = checked;
+ _subwindow->setTabData(tab_data, currentIdx);
});
});
actionLockRefresh->setCheckable(true);
connect(subwindow, &QMenu::aboutToShow, subwindow, [=]() {
run_if(parent->currentSubWindow(), [=](SubWindow *_subwindow, int currentIdx) {
- auto data = _subwindow->tabData(currentIdx);
- actionLockClose->setChecked(data.closeLocked);
- actionLockRefresh->setChecked(data.refreshLocked);
+ auto tab_data = _subwindow->tabData(currentIdx);
+ actionLockClose->setChecked(tab_data.closeLocked);
+ actionLockRefresh->setChecked(tab_data.refreshLocked);
});
});
@@ -235,8 +235,8 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
subwindow->addAction(tr("Close tabs to the left"), parent, [parent]() {
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) {
for(int i = currentIdx - 1; i >= 0; i--) {
- const auto data = _subwindow->tabData(i);
- if(!data.closeLocked)
+ const auto tab_data = _subwindow->tabData(i);
+ if(!tab_data.closeLocked)
_subwindow->closeTab(i);
}
});
@@ -244,8 +244,8 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
subwindow->addAction(tr("Close tabs to the right"), parent, [parent]() {
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) {
for(int i = _subwindow->tabCount() - 1; i > currentIdx; i--) {
- const auto data = _subwindow->tabData(i);
- if(!data.closeLocked)
+ const auto tab_data = _subwindow->tabData(i);
+ if(!tab_data.closeLocked)
_subwindow->closeTab(i);
}
});
@@ -254,8 +254,8 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) {
for(int i = _subwindow->tabCount() - 1; i >= 0; i--) {
if(i != currentIdx) {
- const auto data = _subwindow->tabData(i);
- if(!data.closeLocked)
+ const auto tab_data = _subwindow->tabData(i);
+ if(!tab_data.closeLocked)
_subwindow->closeTab(i);
}
}
@@ -267,8 +267,8 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
subwindow->addAction(tr("Refresh tabs to the left"), parent, [parent]() {
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) {
for(int i = 0; i < currentIdx; i++) {
- const auto data = _subwindow->tabData(i);
- if(!data.refreshLocked)
+ const auto tab_data = _subwindow->tabData(i);
+ if(!tab_data.refreshLocked)
_subwindow->view(i)->triggerPageAction(QWebEnginePage::Reload);
}
});
@@ -276,8 +276,8 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
subwindow->addAction(tr("Refresh tabs to the right"), parent, [parent]() {
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) {
for(int i = currentIdx + 1; i < _subwindow->tabCount(); i++) {
- const auto data = _subwindow->tabData(i);
- if(!data.refreshLocked)
+ const auto tab_data = _subwindow->tabData(i);
+ if(!tab_data.refreshLocked)
_subwindow->view(i)->triggerPageAction(QWebEnginePage::Reload);
}
});
@@ -286,8 +286,8 @@ MenuBar::MenuBar(QMenu *appMenu, MainWindow *parent)
run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int currentIdx) {
for(int i = 0; i < _subwindow->tabCount(); i++) {
if(i != currentIdx) {
- const auto data = _subwindow->tabData(i);
- if(!data.refreshLocked)
+ const auto tab_data = _subwindow->tabData(i);
+ if(!tab_data.refreshLocked)
_subwindow->view(i)->triggerPageAction(QWebEnginePage::Reload);
}
}
diff --git a/src/mainwindow/widgets/searchform.cpp b/src/mainwindow/widgets/searchform.cpp
index 1519df2..e10933b 100644
--- a/src/mainwindow/widgets/searchform.cpp
+++ b/src/mainwindow/widgets/searchform.cpp
@@ -22,11 +22,11 @@ SearchForm::SearchForm(QWidget *parent)
ui->result_label->setVisible(false);
connect(ui->lineEdit, &QLineEdit::returnPressed, this, [this]() {
- if(view) {
+ if(m_view) {
QWebEnginePage::FindFlags searchFlags;
searchFlags.setFlag(QWebEnginePage::FindCaseSensitively, ui->caseSensitivity_checkBox->isChecked());
searchFlags.setFlag(QWebEnginePage::FindBackward, ui->reverseSearch_checkBox->isChecked());
- view->findText(ui->lineEdit->text(), searchFlags, [this](bool found) {
+ m_view->findText(ui->lineEdit->text(), searchFlags, [this](bool found) {
ui->result_label->setVisible(!found);
});
}
@@ -40,7 +40,7 @@ SearchForm::~SearchForm()
void SearchForm::setView(QWebEngineView *view)
{
- this->view = view;
+ m_view = view;
}
void SearchForm::showEvent(QShowEvent *event)
@@ -53,8 +53,8 @@ void SearchForm::showEvent(QShowEvent *event)
void SearchForm::hideEvent(QHideEvent *event)
{
// clear highlighted text when hiding
- if(view) {
- view->findText("");
+ if(m_view) {
+ m_view->findText("");
}
event->accept();
}
diff --git a/src/mainwindow/widgets/searchform.h b/src/mainwindow/widgets/searchform.h
index 16effe9..285ed16 100644
--- a/src/mainwindow/widgets/searchform.h
+++ b/src/mainwindow/widgets/searchform.h
@@ -34,7 +34,7 @@ protected:
private:
Ui::SearchForm *ui;
- QWebEngineView *view = nullptr;
+ QWebEngineView *m_view = nullptr;
};
#endif // SMOLBOTE_SEARCHFORM_H
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp
index 588a070..6e9a713 100644
--- a/src/subwindow/subwindow.cpp
+++ b/src/subwindow/subwindow.cpp
@@ -78,18 +78,18 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags flags)
});
}
-SubWindow::SubWindow(const Session::SubWindow &data, QWidget *parent, Qt::WindowFlags flags)
+SubWindow::SubWindow(const Session::SubWindow &tab_data, QWidget *parent, Qt::WindowFlags flags)
: SubWindow(parent, flags)
{
WebProfileManager profileManager;
- auto *profile = profileManager.profile(data.profile);
+ auto *profile = profileManager.profile(tab_data.profile);
if(profile != nullptr) {
setProfile(profile);
}
- for(const auto &data : data.tabs) {
- addTab(data);
+ for(const auto &tab : tab_data.tabs) {
+ addTab(tab);
}
}
@@ -117,9 +117,9 @@ void SubWindow::setProfile(WebProfile *profile)
}
}
-void SubWindow::setTabData(TabData &data, int index)
+void SubWindow::setTabData(TabData &tab_data, int index)
{
- tabWidget->tabBar()->setTabData(index, QVariant::fromValue<TabData>(data));
+ tabWidget->tabBar()->setTabData(index, QVariant::fromValue<TabData>(tab_data));
}
SubWindow::TabData SubWindow::tabData(int index) const
@@ -149,9 +149,9 @@ int SubWindow::addTab(const QUrl &url, WebProfile *profile)
return tabWidget->addTab(view);
}
-int SubWindow::addTab(const Session::WebView &data)
+int SubWindow::addTab(const Session::WebView &tab_data)
{
- auto *view = new WebView(data, std::bind(&SubWindow::createView, this, std::placeholders::_1), this);
+ auto *view = new WebView(tab_data, std::bind(&SubWindow::createView, this, std::placeholders::_1), this);
return tabWidget->addTab(view);
}
diff --git a/src/subwindow/subwindow.h b/src/subwindow/subwindow.h
index 88f3985..68f7cf9 100644
--- a/src/subwindow/subwindow.h
+++ b/src/subwindow/subwindow.h
@@ -28,7 +28,7 @@ public:
};
explicit SubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
- explicit SubWindow(const Session::SubWindow &data, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
+ explicit SubWindow(const Session::SubWindow &tab_data, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~SubWindow() = default;
[[nodiscard]] Session::SubWindow serialize() const;
@@ -58,7 +58,7 @@ public:
return m_profile;
}
- void setTabData(TabData &data, int index);
+ void setTabData(TabData &tab_data, int index);
[[nodiscard]] TabData tabData(int index) const;
signals:
@@ -71,7 +71,7 @@ public slots:
WebView *createView(QWebEnginePage::WebWindowType type);
int addTab(const QUrl &url = QUrl(), WebProfile *profile = nullptr);
- int addTab(const Session::WebView &data);
+ int addTab(const Session::WebView &tab_data);
void closeTab(int index)
{
tabWidget->removeTab(index);
diff --git a/src/subwindow/tabwidget.cpp b/src/subwindow/tabwidget.cpp
index efa2b6a..6f1e348 100644
--- a/src/subwindow/tabwidget.cpp
+++ b/src/subwindow/tabwidget.cpp
@@ -87,23 +87,21 @@ int TabWidget::addTab(WebView *view)
{
Q_ASSERT_X(view != nullptr, "TabWidget::addTab", "Tried to add null view");
- int idx = QTabWidget::addTab(view, view->title());
+ const int idx = QTabWidget::addTab(view, view->title());
connect(view, &WebView::titleChanged, [this, view](const QString &title) {
- int idx = this->indexOf(view);
- Q_ASSERT(idx != -1);
-
- this->setTabText(idx, title);
+ const int current_idx = indexOf(view);
+ if(current_idx != -1) {
+ setTabText(current_idx, title);
+ }
});
connect(view, &WebView::iconChanged, [this, view](const QIcon &icon) {
- int idx = this->indexOf(view);
- Q_ASSERT(idx != -1);
-
- this->setTabIcon(idx, icon);
+ const int current_idx = indexOf(view);
+ if(current_idx != -1) {
+ setTabIcon(current_idx, icon);
+ }
});
- SubWindow::TabData data;
- tabBar()->setTabData(idx, QVariant::fromValue<SubWindow::TabData>(data));
-
+ tabBar()->setTabData(idx, QVariant::fromValue<SubWindow::TabData>(SubWindow::TabData{}));
return idx;
}
diff --git a/src/webengine/webpage.cpp b/src/webengine/webpage.cpp
index 8c6b8db..b2b19b5 100644
--- a/src/webengine/webpage.cpp
+++ b/src/webengine/webpage.cpp
@@ -13,7 +13,7 @@
#include <QWebEngineFullScreenRequest>
#include <QWebEngineCertificateError>
-QString tr_terminationStatus(QWebEnginePage::RenderProcessTerminationStatus status)
+[[nodiscard]] inline QString tr_terminationStatus(QWebEnginePage::RenderProcessTerminationStatus status)
{
switch(status) {
case QWebEnginePage::NormalTerminationStatus:
@@ -29,7 +29,7 @@ QString tr_terminationStatus(QWebEnginePage::RenderProcessTerminationStatus stat
return QObject::tr("The render process was terminated with an unknown status.");
}
-QString feature_toString(QWebEnginePage::Feature feature)
+[[nodiscard]] inline QString feature_toString(QWebEnginePage::Feature feature)
{
switch(feature) {
case QWebEnginePage::Notifications:
diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h
index 0747638..894463f 100644
--- a/src/webengine/webprofile.h
+++ b/src/webengine/webprofile.h
@@ -205,7 +205,7 @@ public slots:
auto *store = cookieStore();
store->deleteAllCookies();
for(const auto &data : cookies) {
- for(const auto &cookie : QNetworkCookie::parseCookies(data.toByteArray())) {
+ for(auto &cookie : QNetworkCookie::parseCookies(data.toByteArray())) {
store->setCookie(cookie);
}
}
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 135f25c..38e564a 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -42,21 +42,21 @@ WebView::WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent)
setPage(new WebPage(profile, this));
}
-WebView::WebView(const Session::WebView &data, cb_createWindow_t cb, QWidget *parent)
+WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWidget *parent)
: WebView(parent)
{
cb_createWindow = cb;
WebProfileManager profileManager;
- auto *profile = profileManager.profile(data.profile);
+ auto *profile = profileManager.profile(webview_data.profile);
if(profile != nullptr) {
setProfile(profile);
}
- if(!data.url.isEmpty())
- load(QUrl::fromUserInput(data.url));
+ if(!webview_data.url.isEmpty())
+ load(QUrl::fromUserInput(webview_data.url));
else {
- QByteArray copy(data.history);
+ QByteArray copy(webview_data.history);
QDataStream historyStream(&copy, QIODevice::ReadOnly);
historyStream >> *history();
}
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index a9c6866..34c77bf 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -28,7 +28,7 @@ public:
typedef std::function<WebView *(QWebEnginePage::WebWindowType)> cb_createWindow_t;
WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent = nullptr);
- WebView(const Session::WebView &data, cb_createWindow_t cb, QWidget *parent = nullptr);
+ WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWidget *parent = nullptr);
~WebView() = default;
[[nodiscard]] WebProfile *profile() const
diff --git a/src/webengine/webviewcontextmenu.cpp b/src/webengine/webviewcontextmenu.cpp
index 1f6b337..ea5e8c6 100644
--- a/src/webengine/webviewcontextmenu.cpp
+++ b/src/webengine/webviewcontextmenu.cpp
@@ -196,7 +196,7 @@ WebViewContextMenu::WebViewContextMenu(WebView *view)
auto *zoomSlider = new QSlider(Qt::Horizontal);
zoomSlider->setMinimum(5);
zoomSlider->setMaximum(50);
- zoomSlider->setValue(view->zoomFactor() * 10);
+ zoomSlider->setValue(static_cast<int>(view->zoomFactor() * 10));
auto *zoomAction = this->addAction(tr("Zoom: %1x").arg(view->zoomFactor()));
connect(zoomAction, &QAction::triggered, view, [zoomSlider]() {