aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp3
-rw-r--r--src/browser.h2
-rw-r--r--src/builtins.cpp6
-rw-r--r--src/builtins.h8
-rw-r--r--src/main.cpp2
-rw-r--r--src/mainwindow/mainwindow.cpp16
-rw-r--r--src/mainwindow/menubar.cpp4
-rw-r--r--src/session/session.cpp2
-rw-r--r--src/session/sessiondialog.cpp8
-rw-r--r--src/webengine/webengineprofile.cpp0
-rw-r--r--src/webengine/webengineprofile.h0
11 files changed, 26 insertions, 25 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 6e1e2ba..430a7d4 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -216,11 +216,12 @@ void Browser::setup(QVector<QPluginLoader *> plugins)
// bookmarks
m_bookmarks = std::make_shared<BookmarksWidget>(QString::fromStdString(m_config->value<std::string>("bookmarks.path").value()));
connect(m_bookmarks.get(), &BookmarksWidget::showContextMenu, this, [this](const QUrl &url, const QPoint &pos) {
- auto *menu = new QMenu(m_bookmarks.get());
auto *subwindow = m_windows.last()->currentSubWindow();
if(subwindow == nullptr)
return;
+ auto *menu = new QMenu(m_bookmarks.get());
+
menu->addAction(tr("Open link in current tab"), subwindow, [url, subwindow]() {
subwindow->currentView()->load(url);
});
diff --git a/src/browser.h b/src/browser.h
index 32011e0..a005513 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -90,7 +90,7 @@ private:
std::unique_ptr<Configuration> m_config;
std::shared_ptr<BookmarksWidget> m_bookmarks;
std::unique_ptr<DownloadsWidget> m_downloads;
- WebProfileManager *m_profileManager;
+ WebProfileManager *m_profileManager = nullptr;
QVector<UrlFilter *> m_filters;
QVector<MainWindow *> m_windows;
diff --git a/src/builtins.cpp b/src/builtins.cpp
index 8cfdb46..55bdc31 100644
--- a/src/builtins.cpp
+++ b/src/builtins.cpp
@@ -36,9 +36,9 @@ int builtins::build()
}
int builtins::help(const char *cmd,
- boost::program_options::options_description cmd_opts,
- boost::program_options::options_description config_opts,
- CommandHash_t pluginCommands, const QTranslator *translator)
+ const boost::program_options::options_description &cmd_opts,
+ const boost::program_options::options_description &config_opts,
+ const CommandHash_t &pluginCommands, const QTranslator *translator)
{
const auto version = QVersionNumber::fromString(QLatin1String(poi_Version)).toString().toStdString();
std::cout << tr(translator, "smolbote ") << version << tr(translator, ": yet another no-frills browser\n");
diff --git a/src/builtins.h b/src/builtins.h
index 7ad8ba5..e151e8d 100644
--- a/src/builtins.h
+++ b/src/builtins.h
@@ -17,10 +17,10 @@ namespace builtins
int version();
int build();
int help(const char *cmd,
- boost::program_options::options_description cmd_opts,
- boost::program_options::options_description config_opts,
- CommandHash_t pluginCommands,
- const QTranslator *translator);
+ const boost::program_options::options_description &cmd_opts,
+ const boost::program_options::options_description &config_opts,
+ const CommandHash_t &pluginCommands,
+ const QTranslator *translator);
}
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 11db0d7..0072b04 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
// Load plugins
for(const QString &path : Util::files(config->value<QString>("plugins.path").value())) {
- QPluginLoader *loader = new QPluginLoader(path);
+ auto *loader = new QPluginLoader(path);
const bool loaded = loader->load();
#ifdef QT_DEBUG
qDebug("Loading plugin %s %s", qUtf8Printable(path), loaded ? "[ok]" : "[failed]");
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 71b594a..7fb7d9e 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -69,7 +69,7 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
config->setShortcut(subwindowMenuAction, "subwindow.shortcuts.menu");
connect(subwindowMenuAction, &QAction::triggered, this, [this]() {
QMdiSubWindow *window = mdiArea->currentSubWindow();
- if(window) {
+ if(window != nullptr) {
// show the menu at the subwindow position
// position has to be global, and mapped by the mdiArea (parentWidget() of the subwindow)
const auto position = mdiArea->mapToGlobal(window->pos());
@@ -114,20 +114,20 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
// address bar
connect(addressBar, &AddressBar::search, this, [this](const QString &term) {
- if(this->currentView) {
+ if(this->currentView != nullptr) {
currentView->search(term);
currentView->setFocus();
}
});
connect(addressBar, &AddressBar::load, this, [this](const QUrl &url) {
- if(this->currentView) {
+ if(this->currentView != nullptr) {
currentView->load(url);
currentView->setFocus();
}
});
connect(addressBar, &AddressBar::giveFocus, this, [this]() {
- if(this->currentView) {
+ if(this->currentView != nullptr) {
currentView->setFocus();
}
});
@@ -244,13 +244,13 @@ SubWindow *MainWindow::createSubWindow(WebProfile *profile, bool openProfileNewt
void MainWindow::setView(WebView *view)
{
- if(currentView) {
+ if(currentView != nullptr) {
// disconnect old view
- disconnect(currentView, 0, addressBar, 0);
+ disconnect(currentView, nullptr, addressBar, nullptr);
}
currentView = view;
- if(view) {
+ if(view != nullptr) {
connect(view, &WebView::urlChanged, addressBar, &AddressBar::setUrl);
addressBar->setUrl(view->url());
@@ -277,7 +277,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
}
mdiArea->closeAllSubWindows();
- if(mdiArea->currentSubWindow())
+ if(mdiArea->currentSubWindow() != nullptr)
event->ignore();
else
event->accept();
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index 117641f..7b7d912 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -30,7 +30,7 @@
#include <functional>
#include <QVBoxLayout>
-inline void run_if(SubWindow *_subwindow, std::function<void(SubWindow*, int)> f)
+inline void run_if(SubWindow *_subwindow, const std::function<void(SubWindow*, int)> &f)
{
if(_subwindow != nullptr)
f(_subwindow, _subwindow->currentTabIndex());
@@ -111,7 +111,7 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
const QString sessionPath = config->value<QString>("browser.session.path").value();
auto *actionSaveSession = smolbote->addAction(tr("Save Session"), parent, [sessionPath]() {
auto *sessionDialog = new SaveSessionDialog(nullptr);
- if(sessionDialog->exec())
+ if(sessionDialog->exec() == QDialog::Accepted)
sessionDialog->save(sessionPath);
});
config->setShortcut(actionSaveSession, "mainwindow.shortcuts.saveSession");
diff --git a/src/session/session.cpp b/src/session/session.cpp
index 51575bf..67cea70 100644
--- a/src/session/session.cpp
+++ b/src/session/session.cpp
@@ -120,7 +120,7 @@ void Session::restoreView(WebView *view, const QJsonObject &data)
Q_CHECK_PTR(profileManager);
auto *profile = profileManager->profile(data["profile"].toString());
- if(profile)
+ if(profile != nullptr)
view->setProfile(profile);
auto url = data.value("url");
diff --git a/src/session/sessiondialog.cpp b/src/session/sessiondialog.cpp
index 184c44d..b734088 100644
--- a/src/session/sessiondialog.cpp
+++ b/src/session/sessiondialog.cpp
@@ -35,11 +35,11 @@ SessionDialog::SessionDialog(QWidget *parent)
connect(ui->listWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *currentItem, QListWidgetItem *previousItem) {
auto *currentWidget = qobject_cast<SessionForm *>(ui->listWidget->itemWidget(currentItem));
- if(currentWidget)
+ if(currentWidget != nullptr)
currentWidget->ui->delete_toolButton->show();
auto *previousWidget = qobject_cast<SessionForm *>(ui->listWidget->itemWidget(previousItem));
- if(previousWidget)
+ if(previousWidget != nullptr)
previousWidget->ui->delete_toolButton->hide();
});
@@ -53,7 +53,7 @@ SessionDialog::SessionDialog(QWidget *parent)
accepted_connection = connect(this, &SessionDialog::accepted, this, [this, browser]() {
auto *currentWidget = qobject_cast<SessionForm *>(ui->listWidget->itemWidget(ui->listWidget->currentItem()));
- if(currentWidget)
+ if(currentWidget != nullptr)
this->openSession(currentWidget->ui->label->text());
else
browser->createWindow();
@@ -76,7 +76,7 @@ std::optional<QJsonObject> SessionDialog::pickSession()
}
auto *currentWidget = qobject_cast<SessionForm *>(ui->listWidget->itemWidget(ui->listWidget->currentItem()));
- if(currentWidget) {
+ if(currentWidget != nullptr) {
QFile json(currentWidget->ui->label->text());
if(json.open(QIODevice::ReadOnly | QIODevice::Text)) {
auto doc = QJsonDocument::fromJson(json.readAll());
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/webengine/webengineprofile.cpp
+++ /dev/null
diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h
deleted file mode 100644
index e69de29..0000000
--- a/src/webengine/webengineprofile.h
+++ /dev/null