From e4ffd8374040d36c22125eeb534d884f56978592 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 17 Apr 2018 17:43:38 +0200 Subject: Style pass --- lib/about/aboutdialog.cpp | 14 +++++++------- lib/bookmarks/bookmarksview.h | 1 - lib/bookmarks/bookmarkswidget.cpp | 2 +- lib/bookmarks/bookmarkswidget.h | 4 ++-- lib/bookmarks/xbel.h | 2 +- lib/configuration/configuration.h | 16 ++++++++-------- lib/downloads/widgets/downloaditemwidget.cpp | 2 +- src/addressbar/addressbar.cpp | 9 +++++---- src/addressbar/addressbar.h | 2 +- src/addressbar/urllineedit.h | 1 - src/browser.cpp | 6 +++--- src/browser.h | 1 - src/main.cpp | 2 +- src/mainwindow/mainwindow.cpp | 6 +++--- src/mainwindow/widgets/searchform.cpp | 20 ++++++++++---------- src/webengine/webprofile.h | 3 ++- src/webengine/webview.cpp | 4 ++-- 17 files changed, 47 insertions(+), 48 deletions(-) diff --git a/lib/about/aboutdialog.cpp b/lib/about/aboutdialog.cpp index ff4200f..1d60eb4 100644 --- a/lib/about/aboutdialog.cpp +++ b/lib/about/aboutdialog.cpp @@ -33,7 +33,8 @@ AboutDialog::AboutDialog(QWidget *parent) auto *aboutLabel = new QLabel(this); aboutLabel->setWordWrap(true); aboutLabel->setText(tr("

smolbote %1

" - "

yet another no-frills browser

").arg(qApp->applicationVersion())); + "

yet another no-frills browser

") + .arg(qApp->applicationVersion())); ui->toolBox->addItem(aboutLabel, tr("About")); auto *licenseLabel = new QLabel(this); @@ -53,13 +54,12 @@ AboutDialog::AboutDialog(QWidget *parent) auto *detailsLabel = new QLabel(this); detailsLabel->setWordWrap(true); detailsLabel->setText(tr("

Compiled with " compiler "

" - "

")); + "

")); ui->toolBox->addItem(detailsLabel, tr("Details")); - } AboutDialog::~AboutDialog() diff --git a/lib/bookmarks/bookmarksview.h b/lib/bookmarks/bookmarksview.h index 5b408e0..47b3f9c 100644 --- a/lib/bookmarks/bookmarksview.h +++ b/lib/bookmarks/bookmarksview.h @@ -34,5 +34,4 @@ private: QIcon bookmarkIcon; }; - #endif // SMOLBOTE_BOOKMARKSVIEW_H diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp index 339e913..cae1eb3 100644 --- a/lib/bookmarks/bookmarkswidget.cpp +++ b/lib/bookmarks/bookmarkswidget.cpp @@ -129,7 +129,7 @@ void BookmarksWidget::save() } } -void BookmarksWidget::search(const QString& term, std::function callback) const +void BookmarksWidget::search(const QString &term, std::function callback) const { QStringList ret; const QList res = ui->treeWidget->findItems(term, Qt::MatchContains | Qt::MatchRecursive, 1); diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h index 6322918..40f5c04 100644 --- a/lib/bookmarks/bookmarkswidget.h +++ b/lib/bookmarks/bookmarkswidget.h @@ -9,9 +9,9 @@ #ifndef BOOKMARKSDIALOG_H #define BOOKMARKSDIALOG_H +#include #include #include -#include #include namespace Ui @@ -35,7 +35,7 @@ signals: void openUrl(const QUrl &url); public slots: - void search(const QString &term, std::function callback) const; + void search(const QString &term, std::function callback) const; private: Ui::BookmarksDialog *ui; diff --git a/lib/bookmarks/xbel.h b/lib/bookmarks/xbel.h index 6981627..ecc185a 100644 --- a/lib/bookmarks/xbel.h +++ b/lib/bookmarks/xbel.h @@ -9,9 +9,9 @@ #ifndef XBELREADER_H #define XBELREADER_H +#include "bookmarksview.h" #include #include -#include "bookmarksview.h" class XbelReader { diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h index 1c919b0..c5e044f 100644 --- a/lib/configuration/configuration.h +++ b/lib/configuration/configuration.h @@ -9,13 +9,13 @@ #ifndef SMOLBOTE_CONFIGURATION_H #define SMOLBOTE_CONFIGURATION_H -#include -#include -#include #include -#include #include #include +#include +#include +#include +#include class Configuration { @@ -43,16 +43,15 @@ public: std::string r; try { r = vm[path].as(); - } catch (boost::bad_any_cast &) { + } catch(boost::bad_any_cast &) { // try int try { r = std::to_string(vm[path].as()); - } catch (boost::bad_any_cast &) { + } catch(boost::bad_any_cast &) { // try bool, and crash if not that either r = vm[path].as() ? "true" : "false"; } - } // check if it's a path @@ -65,7 +64,8 @@ public: return std::optional(vm[path].as()); } - const std::vector> & options() { + const std::vector> &options() + { return desc.options(); } diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp index 576ae0c..2790c5c 100644 --- a/lib/downloads/widgets/downloaditemwidget.cpp +++ b/lib/downloads/widgets/downloaditemwidget.cpp @@ -8,8 +8,8 @@ #include "downloaditemwidget.h" #include "ui_downloaditemform.h" -#include #include +#include DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent) : QWidget(parent) diff --git a/src/addressbar/addressbar.cpp b/src/addressbar/addressbar.cpp index 1c10d69..b86230c 100644 --- a/src/addressbar/addressbar.cpp +++ b/src/addressbar/addressbar.cpp @@ -10,8 +10,8 @@ #include "urllineedit.h" #include "webengine/webview.h" #include -#include #include +#include AddressBar::AddressBar(const QHash &config, QWidget *parent) : QWidget(parent) @@ -36,7 +36,7 @@ AddressBar::AddressBar(const QHash &config, QWidget *parent) urlBar->toolsMenu_action->setToolTip(tr("Tools (%1)").arg(urlBar->toolsMenu_action->shortcut().toString())); connect(urlBar, &UrlLineEdit::textEdited, [=](const QString &text) { - std::function callback = std::bind(&UrlLineEdit::updateCompleter, urlBar, std::placeholders::_1); + std::function callback = std::bind(&UrlLineEdit::updateCompleter, urlBar, std::placeholders::_1); emit complete(text, callback); }); @@ -53,7 +53,7 @@ AddressBar::~AddressBar() disconnect(progressBarConnection); } -void AddressBar::connectWebView(WebView* view) +void AddressBar::connectWebView(WebView *view) { disconnect(urlChangedConnection); disconnect(loadUrlConnection); @@ -73,7 +73,8 @@ void AddressBar::connectWebView(WebView* view) urlBar->toolsMenu_action->setMenu(view->toolsMenu()); urlChangedConnection = connect(view, &WebView::urlChanged, urlBar, &UrlLineEdit::setUrl); loadUrlConnection = connect(urlBar, &UrlLineEdit::returnPressed, [=]() { - if(urlBar->text().startsWith('#')) {; + if(urlBar->text().startsWith('#')) { + ; view->search(urlBar->text().mid(1)); } else { view->load(QUrl::fromUserInput(urlBar->text())); diff --git a/src/addressbar/addressbar.h b/src/addressbar/addressbar.h index 224fb9b..9b8b360 100644 --- a/src/addressbar/addressbar.h +++ b/src/addressbar/addressbar.h @@ -24,7 +24,7 @@ public: ~AddressBar() override; signals: - void complete(const QString &term, std::function callback); + void complete(const QString &term, std::function callback); public slots: void connectWebView(WebView *view); diff --git a/src/addressbar/urllineedit.h b/src/addressbar/urllineedit.h index bc23f58..f27addc 100644 --- a/src/addressbar/urllineedit.h +++ b/src/addressbar/urllineedit.h @@ -33,7 +33,6 @@ public: // devMenu action: scripts, etc QAction *toolsMenu_action = nullptr; - protected: void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; diff --git a/src/browser.cpp b/src/browser.cpp index e5e83e8..0caae05 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -7,16 +7,16 @@ */ #include "browser.h" +#include "addressbar/addressbar.h" #include "mainwindow/mainwindow.h" #include "mainwindow/window.h" +#include "webengine/urlinterceptor.h" #include "webengine/webprofile.h" #include -#include #include +#include #include #include -#include "webengine/urlinterceptor.h" -#include "addressbar/addressbar.h" Browser::Browser(int &argc, char *argv[]) : SingleApplication(argc, argv) diff --git a/src/browser.h b/src/browser.h index b43d45a..c8e906d 100644 --- a/src/browser.h +++ b/src/browser.h @@ -42,7 +42,6 @@ private: std::shared_ptr m_urlFilter; QVector m_windows; - }; #endif // SMOLBOTE_BROWSER_H diff --git a/src/main.cpp b/src/main.cpp index 9fd009b..1b4d26f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,11 +6,11 @@ * SPDX-License-Identifier: GPL-3.0 */ +#include "browser.h" #include "commandline.h" #include "mainwindow/mainwindow.h" #include "version.h" #include "webengine/webprofile.h" -#include "browser.h" #include #include diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 18e1b63..c43e001 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -7,8 +7,10 @@ */ #include "mainwindow.h" +#include "addressbar/addressbar.h" #include "webengine/webview.h" #include "widgets/navigationbar.h" +#include "widgets/searchform.h" #include "window.h" #include #include @@ -19,13 +21,11 @@ #include #include #include +#include #include #include #include #include -#include "addressbar/addressbar.h" -#include -#include "widgets/searchform.h" MainWindow::MainWindow(std::shared_ptr &config, QWidget *parent) : QMainWindow(parent) diff --git a/src/mainwindow/widgets/searchform.cpp b/src/mainwindow/widgets/searchform.cpp index 79cc0cf..b400079 100644 --- a/src/mainwindow/widgets/searchform.cpp +++ b/src/mainwindow/widgets/searchform.cpp @@ -8,8 +8,8 @@ #include "searchform.h" #include "ui_searchform.h" -#include #include +#include SearchForm::SearchForm(QWidget *parent) : QWidget(parent) @@ -22,12 +22,12 @@ SearchForm::SearchForm(QWidget *parent) connect(ui->lineEdit, &QLineEdit::returnPressed, this, [this]() { if(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) { - ui->result_label->setVisible(!found); - }); + 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) { + ui->result_label->setVisible(!found); + }); } }); } @@ -37,19 +37,19 @@ SearchForm::~SearchForm() delete ui; } -void SearchForm::setView(QWebEngineView* view) +void SearchForm::setView(QWebEngineView *view) { this->view = view; } -void SearchForm::showEvent(QShowEvent* e) +void SearchForm::showEvent(QShowEvent *e) { e->accept(); ui->lineEdit->setFocus(); ui->lineEdit->selectAll(); } -void SearchForm::hideEvent(QHideEvent* e) +void SearchForm::hideEvent(QHideEvent *e) { e->accept(); // clear highlighted text when hiding diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h index 1668067..0b3ce7f 100644 --- a/src/webengine/webprofile.h +++ b/src/webengine/webprofile.h @@ -34,7 +34,8 @@ public: } QString name() const; - QString search() const { + QString search() const + { return m_search; } QUrl homepage() const; diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index dadac1e..3c4e19e 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -7,6 +7,7 @@ */ #include "webview.h" +#include "mainwindow/window.h" #include "webpage.h" #include "webprofile.h" #include "widgets/pagemenu.h" @@ -14,7 +15,6 @@ #include #include #include -#include "mainwindow/window.h" WebView::WebView(WebProfile *profile, QWidget *parent) : QWebEngineView(parent) @@ -73,7 +73,7 @@ int WebView::loadProgress() const return m_loadProgress; } -void WebView::search(const QString& term) +void WebView::search(const QString &term) { const QString searchUrl = m_profile->search().arg(QString(QUrl::toPercentEncoding(term))); load(searchUrl); -- cgit v1.2.1