From b984992fc92b6dd607732d6dad1c533b36f1ba3a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 7 Jan 2018 23:28:42 +0100 Subject: Added .clang-format --- .clang-format | 108 +++++++++++++++++++++++++++ astyle.rc | 4 - lib/bookmarks/bookmarkitem.cpp | 2 +- lib/bookmarks/bookmarkitem.h | 8 +- lib/bookmarks/bookmarksmodel.cpp | 18 ++--- lib/bookmarks/bookmarksmodel.h | 3 +- lib/bookmarks/bookmarkswidget.cpp | 6 +- lib/bookmarks/bookmarkswidget.h | 10 +-- lib/bookmarks/xbel.cpp | 1 - lib/bookmarks/xbel.h | 2 +- lib/downloads/downloadswidget.cpp | 18 ++--- lib/downloads/downloadswidget.h | 3 +- lib/downloads/widgets/downloaditemwidget.cpp | 8 +- lib/downloads/widgets/downloaditemwidget.h | 5 +- lib/downloads/widgets/elidedlabel.h | 6 +- lib/navigation/navigationbutton.cpp | 16 ++-- lib/navigation/navigationbutton.h | 3 +- lib/navigation/urllineedit.cpp | 12 ++- lib/navigation/urllineedit.h | 2 +- lib/settings/configuration.cpp | 54 +++++++------- lib/settings/configuration.h | 35 ++++----- lib/settings/settingsdialog.cpp | 14 ++-- lib/settings/settingsdialog.h | 3 +- src/browser.cpp | 12 ++- src/browser.h | 2 +- src/forms/aboutdialog.cpp | 12 +-- src/forms/aboutdialog.h | 3 +- src/forms/cookiesform.cpp | 9 +-- src/forms/cookiesform.h | 7 +- src/forms/profileview.cpp | 16 ++-- src/forms/profileview.h | 3 +- src/forms/searchform.cpp | 8 +- src/forms/searchform.h | 3 +- src/main.cpp | 12 +-- src/mainwindow.cpp | 26 +++---- src/mainwindow.h | 9 ++- src/singleapplication.cpp | 6 +- src/singleapplication.h | 1 - src/webengine/urlinterceptor.cpp | 4 +- src/webengine/urlinterceptor.h | 3 +- src/webengine/webengineprofile.cpp | 72 +++++++++--------- src/webengine/webengineprofile.h | 2 +- src/webengine/webpage.cpp | 4 +- src/webengine/webview.cpp | 14 ++-- src/webengine/webview.h | 4 +- src/widgets/loadingbar.cpp | 6 +- src/widgets/mainwindowmenubar.cpp | 10 +-- src/widgets/mainwindowtabbar.cpp | 12 +-- src/widgets/mainwindowtabbar.h | 6 +- tools/hooks/pre-commit.rb | 6 -- 50 files changed, 356 insertions(+), 257 deletions(-) create mode 100644 .clang-format delete mode 100644 astyle.rc diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..64af425 --- /dev/null +++ b/.clang-format @@ -0,0 +1,108 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Linux +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: Never +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... + diff --git a/astyle.rc b/astyle.rc deleted file mode 100644 index d0f745a..0000000 --- a/astyle.rc +++ /dev/null @@ -1,4 +0,0 @@ ---style=otbs ---attach-namespaces ---attach-inlines ---indent=spaces=4 diff --git a/lib/bookmarks/bookmarkitem.cpp b/lib/bookmarks/bookmarkitem.cpp index 14ad197..875ccc6 100644 --- a/lib/bookmarks/bookmarkitem.cpp +++ b/lib/bookmarks/bookmarkitem.cpp @@ -48,7 +48,7 @@ int BookmarkItem::childCount() const int BookmarkItem::row() const { if(m_parentItem) { - return m_parentItem->m_childItems.indexOf(const_cast(this)); + return m_parentItem->m_childItems.indexOf(const_cast(this)); } // no parent item, we are root diff --git a/lib/bookmarks/bookmarkitem.h b/lib/bookmarks/bookmarkitem.h index 839f10e..1b9223e 100644 --- a/lib/bookmarks/bookmarkitem.h +++ b/lib/bookmarks/bookmarkitem.h @@ -29,10 +29,12 @@ public: int childIndex(BookmarkItem *item) const; int childCount() const; - BookmarkItemType type() const { + BookmarkItemType type() const + { return m_type; }; - int columnCount() const { + int columnCount() const + { return 2; }; @@ -47,7 +49,7 @@ public: private: BookmarkItemType m_type; BookmarkItem *m_parentItem; - QVector m_childItems; + QVector m_childItems; }; #endif //BOOKMARKITEM_H diff --git a/lib/bookmarks/bookmarksmodel.cpp b/lib/bookmarks/bookmarksmodel.cpp index 757612e..7e0c35b 100644 --- a/lib/bookmarks/bookmarksmodel.cpp +++ b/lib/bookmarks/bookmarksmodel.cpp @@ -9,7 +9,8 @@ #include "bookmarksmodel.h" #include -BookmarksModel::BookmarksModel(QStyle *style, QObject *parent) : QAbstractItemModel(parent) +BookmarksModel::BookmarksModel(QStyle *style, QObject *parent) + : QAbstractItemModel(parent) { folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On); folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal, QIcon::Off); @@ -62,14 +63,14 @@ QModelIndex BookmarksModel::index(BookmarkItem *node, int column) const QModelIndex BookmarksModel::index(int row, int column, const QModelIndex &parent) const { // invalid item requested - if (!hasIndex(row, column, parent)) { + if(!hasIndex(row, column, parent)) { return QModelIndex(); } // index exists BookmarkItem *parentItem; if(parent.isValid()) { - parentItem = static_cast(parent.internalPointer()); + parentItem = static_cast(parent.internalPointer()); } else { parentItem = m_rootItem; } @@ -87,7 +88,7 @@ QModelIndex BookmarksModel::parent(const QModelIndex &index) const return QModelIndex(); } - BookmarkItem *childItem = static_cast(index.internalPointer()); + BookmarkItem *childItem = static_cast(index.internalPointer()); BookmarkItem *parentItem = childItem->parentItem(); if(parentItem == m_rootItem) { @@ -107,7 +108,7 @@ int BookmarksModel::rowCount(const QModelIndex &parent) const if(!parent.isValid()) { parentItem = m_rootItem; } else { - parentItem = static_cast(parent.internalPointer()); + parentItem = static_cast(parent.internalPointer()); } return parentItem->childCount(); @@ -116,7 +117,7 @@ int BookmarksModel::rowCount(const QModelIndex &parent) const int BookmarksModel::columnCount(const QModelIndex &parent) const { if(parent.isValid()) { - return static_cast(parent.internalPointer())->columnCount(); + return static_cast(parent.internalPointer())->columnCount(); } else { return m_rootItem->columnCount(); } @@ -125,12 +126,12 @@ int BookmarksModel::columnCount(const QModelIndex &parent) const QVariant BookmarksModel::data(const QModelIndex &index, int role) const { // get data of invalid index? - if (!index.isValid()) { + if(!index.isValid()) { return QVariant(); } const BookmarkItem *item = static_cast(index.internalPointer()); - switch (role) { + switch(role) { case Qt::DisplayRole: case Qt::EditRole: if(index.column() == 0) { @@ -200,6 +201,5 @@ QModelIndexList BookmarksModel::match(const QModelIndex &start, int role, const } } - return list; } diff --git a/lib/bookmarks/bookmarksmodel.h b/lib/bookmarks/bookmarksmodel.h index 9d884fb..baf2ba9 100644 --- a/lib/bookmarks/bookmarksmodel.h +++ b/lib/bookmarks/bookmarksmodel.h @@ -6,9 +6,9 @@ * SPDX-License-Identifier: GPL-3.0 */ +#include "bookmarkitem.h" #include #include -#include "bookmarkitem.h" #ifndef BOOKMARKSMODEL_H #define BOOKMARKSMODEL_H @@ -46,7 +46,6 @@ private: QIcon bookmarkIcon; BookmarkItem *m_rootItem; - }; #endif //BOOKMARKSMODEL_H diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp index daec3f4..8aafe37 100644 --- a/lib/bookmarks/bookmarkswidget.cpp +++ b/lib/bookmarks/bookmarkswidget.cpp @@ -10,9 +10,9 @@ #include "ui_bookmarksform.h" #include -BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent) : - QWidget(parent), - ui(new Ui::BookmarksDialog) +BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent) + : QWidget(parent) + , ui(new Ui::BookmarksDialog) { // make sure this dialog does not get deleted on close setAttribute(Qt::WA_DeleteOnClose, false); diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h index cdc013e..f82a512 100644 --- a/lib/bookmarks/bookmarkswidget.h +++ b/lib/bookmarks/bookmarkswidget.h @@ -9,11 +9,12 @@ #ifndef BOOKMARKSDIALOG_H #define BOOKMARKSDIALOG_H -#include -#include "xbel.h" #include "bookmarksmodel.h" +#include "xbel.h" +#include -namespace Ui { +namespace Ui +{ class BookmarksDialog; } @@ -23,7 +24,7 @@ class BookmarksWidget : public QWidget public: explicit BookmarksWidget(const QString &path, QWidget *parent = 0); - ~BookmarksWidget() override ; + ~BookmarksWidget() override; void save(); QAbstractItemModel *model() const; @@ -31,7 +32,6 @@ public: signals: void openUrl(const QUrl &url); - private: void expandNodes(BookmarkItem *node); diff --git a/lib/bookmarks/xbel.cpp b/lib/bookmarks/xbel.cpp index eeb019a..7a7632c 100644 --- a/lib/bookmarks/xbel.cpp +++ b/lib/bookmarks/xbel.cpp @@ -46,7 +46,6 @@ BookmarkItem *Xbel::read() return root; } - void Xbel::readChildElements(QXmlStreamReader &reader, BookmarkItem *parentItem) { while(reader.readNextStartElement()) { diff --git a/lib/bookmarks/xbel.h b/lib/bookmarks/xbel.h index 1c03b74..c425cc5 100644 --- a/lib/bookmarks/xbel.h +++ b/lib/bookmarks/xbel.h @@ -9,9 +9,9 @@ #ifndef XBELREADER_H #define XBELREADER_H +#include "bookmarkitem.h" #include #include -#include "bookmarkitem.h" class Xbel { diff --git a/lib/downloads/downloadswidget.cpp b/lib/downloads/downloadswidget.cpp index 1a5f268..b3bad67 100644 --- a/lib/downloads/downloadswidget.cpp +++ b/lib/downloads/downloadswidget.cpp @@ -9,14 +9,14 @@ #include "downloadswidget.h" #include "ui_downloadsform.h" -#include +#include "widgets/downloaditemwidget.h" #include #include -#include "widgets/downloaditemwidget.h" +#include -DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) : - QDialog(parent), - ui(new Ui::DownloadDialog) +DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) + : QDialog(parent) + , ui(new Ui::DownloadDialog) { // make sure this dialog does not get deleted on close setAttribute(Qt::WA_DeleteOnClose, false); @@ -27,13 +27,13 @@ DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) : m_downloadPath = downloadPath; connect(ui->listWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous) { - DownloadItemWidget *currentWidget = qobject_cast(ui->listWidget->itemWidget(current)); + DownloadItemWidget *currentWidget = qobject_cast(ui->listWidget->itemWidget(current)); currentWidget->showDetails(); currentWidget->setFixedWidth(ui->listWidget->viewport()->width()); currentWidget->adjustSize(); current->setSizeHint(currentWidget->size()); - DownloadItemWidget *previousWidget = qobject_cast(ui->listWidget->itemWidget(previous)); + DownloadItemWidget *previousWidget = qobject_cast(ui->listWidget->itemWidget(previous)); if(previousWidget != nullptr) { previousWidget->hideDetails(); previousWidget->setFixedWidth(ui->listWidget->viewport()->width()); @@ -53,8 +53,8 @@ void DownloadsWidget::addDownload(QWebEngineDownloadItem *item) this->show(); QString filepath = QFileDialog::getSaveFileName(this, - tr("Save"), - m_downloadPath + "/" + QFileInfo(item->path()).fileName()); + tr("Save"), + m_downloadPath + "/" + QFileInfo(item->path()).fileName()); if(filepath.isEmpty()) { // user cancelled the save dialog diff --git a/lib/downloads/downloadswidget.h b/lib/downloads/downloadswidget.h index 8c9ea21..d724e08 100644 --- a/lib/downloads/downloadswidget.h +++ b/lib/downloads/downloadswidget.h @@ -11,7 +11,8 @@ #include -namespace Ui { +namespace Ui +{ class DownloadDialog; } diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp index a51275e..6860c16 100644 --- a/lib/downloads/widgets/downloaditemwidget.cpp +++ b/lib/downloads/widgets/downloaditemwidget.cpp @@ -11,9 +11,9 @@ #include -DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent) : - QWidget(parent), - ui(new Ui::DownloadItemForm) +DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent) + : QWidget(parent) + , ui(new Ui::DownloadItemForm) { m_item = item; @@ -68,7 +68,7 @@ QString DownloadItemWidget::sizeString(int size) const void DownloadItemWidget::updateState(QWebEngineDownloadItem::DownloadState state) { - switch (state) { + switch(state) { case QWebEngineDownloadItem::DownloadRequested: ui->status_label->setText(tr("Requested")); break; diff --git a/lib/downloads/widgets/downloaditemwidget.h b/lib/downloads/widgets/downloaditemwidget.h index c6246da..09a7370 100644 --- a/lib/downloads/widgets/downloaditemwidget.h +++ b/lib/downloads/widgets/downloaditemwidget.h @@ -9,10 +9,11 @@ #ifndef DOWNLOADITEMFORM_H #define DOWNLOADITEMFORM_H -#include #include +#include -namespace Ui { +namespace Ui +{ class DownloadItemForm; } diff --git a/lib/downloads/widgets/elidedlabel.h b/lib/downloads/widgets/elidedlabel.h index d0f6221..d6c06c5 100644 --- a/lib/downloads/widgets/elidedlabel.h +++ b/lib/downloads/widgets/elidedlabel.h @@ -67,10 +67,12 @@ public: explicit ElidedLabel(QWidget *parent = nullptr); void setContent(const QString &text); - const QString & text() const { + const QString &text() const + { return content; } - bool isElided() const { + bool isElided() const + { return elided; } diff --git a/lib/navigation/navigationbutton.cpp b/lib/navigation/navigationbutton.cpp index ecf7c81..577c291 100644 --- a/lib/navigation/navigationbutton.cpp +++ b/lib/navigation/navigationbutton.cpp @@ -11,13 +11,13 @@ #include #include -NavigationButton::NavigationButton(Type type, QWidget *parent) : - QToolButton(parent) +NavigationButton::NavigationButton(Type type, QWidget *parent) + : QToolButton(parent) { m_type = type; menu = new QMenu(this); - switch (type) { + switch(type) { case BackButton: setIcon(style()->standardIcon(QStyle::SP_ArrowBack)); setMenu(menu); @@ -37,10 +37,8 @@ NavigationButton::NavigationButton(Type type, QWidget *parent) : } connect(this, &NavigationButton::clicked, this, &NavigationButton::doAction); - } - void NavigationButton::setView(WebView *view) { disconnect(loadStartedConnection); @@ -57,7 +55,7 @@ void NavigationButton::setView(WebView *view) void NavigationButton::updateOnLoadStarted() { - switch (m_type) { + switch(m_type) { case BackButton: break; case ForwardButton: @@ -73,7 +71,7 @@ void NavigationButton::updateOnLoadStarted() void NavigationButton::updateOnLoadFinished() { - switch (m_type) { + switch(m_type) { case BackButton: if(m_view->history()->canGoBack()) { setEnabled(true); @@ -99,7 +97,7 @@ void NavigationButton::updateOnLoadFinished() void NavigationButton::doAction() { - switch (m_type) { + switch(m_type) { case BackButton: m_view->history()->back(); break; @@ -120,7 +118,7 @@ void NavigationButton::prepareMenu() menu->clear(); QList items; - switch (m_type) { + switch(m_type) { case BackButton: items = m_view->history()->backItems(10); break; diff --git a/lib/navigation/navigationbutton.h b/lib/navigation/navigationbutton.h index 7c76b9c..e0d358a 100644 --- a/lib/navigation/navigationbutton.h +++ b/lib/navigation/navigationbutton.h @@ -9,8 +9,8 @@ #ifndef NAVIGATIONBUTTON_H #define NAVIGATIONBUTTON_H -#include #include "../../src/webengine/webview.h" +#include class QMenu; @@ -18,7 +18,6 @@ class NavigationButton : public QToolButton { Q_OBJECT public: - enum Type { BackButton, ForwardButton, diff --git a/lib/navigation/urllineedit.cpp b/lib/navigation/urllineedit.cpp index 85f443d..4c207a1 100644 --- a/lib/navigation/urllineedit.cpp +++ b/lib/navigation/urllineedit.cpp @@ -7,9 +7,9 @@ */ #include "urllineedit.h" -#include #include #include +#include #include // ssl menu @@ -18,9 +18,9 @@ #include #include -UrlLineEdit::UrlLineEdit(QWidget *parent) : - QLineEdit(parent), - m_listView(new QListView(this)) +UrlLineEdit::UrlLineEdit(QWidget *parent) + : QLineEdit(parent) + , m_listView(new QListView(this)) { setPlaceholderText(tr("Enter address")); @@ -66,7 +66,6 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) : } this->clearFocus(); }); - } QAction *UrlLineEdit::pageAction() @@ -145,7 +144,7 @@ void UrlLineEdit::keyPressEvent(QKeyEvent *event) int count = m_listView->model()->rowCount(); QModelIndex currentIndex = m_listView->currentIndex(); - switch (key) { + switch(key) { case Qt::Key_Down: if(currentIndex.row() + 1 >= count) { m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); @@ -185,7 +184,6 @@ void UrlLineEdit::setTextFormat(const QTextLayout::FormatRange &format) attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, format.start, format.length, format.format)); QInputMethodEvent ev(QString(), attributes); event(&ev); - } void UrlLineEdit::clearTextFormat() diff --git a/lib/navigation/urllineedit.h b/lib/navigation/urllineedit.h index a06ba1b..9ac0366 100644 --- a/lib/navigation/urllineedit.h +++ b/lib/navigation/urllineedit.h @@ -9,9 +9,9 @@ #ifndef URLLINEEDIT_H #define URLLINEEDIT_H +#include #include #include -#include class QAbstractItemModel; class QMenu; diff --git a/lib/settings/configuration.cpp b/lib/settings/configuration.cpp index 1fa1fbf..06ee0bd 100644 --- a/lib/settings/configuration.cpp +++ b/lib/settings/configuration.cpp @@ -38,19 +38,19 @@ bool Configuration::readUserConfiguration(const std::string &path) m_userCfgPath = path; try { m_userCfg->readFile(path.c_str()); - } catch (FileIOException) { + } catch(FileIOException) { return false; - } catch (ParseException) { + } catch(ParseException) { return false; } - return true; + return true; } bool Configuration::parse(const std::string &contents) { try { m_userCfg->readString(contents); - } catch (ParseException) { + } catch(ParseException) { return false; } return true; @@ -61,7 +61,7 @@ bool Configuration::writeUserConfiguration(const std::string &path) m_userCfgPath = path; try { m_userCfg->writeFile(m_userCfgPath.c_str()); - } catch (FileIOException) { + } catch(FileIOException) { return false; } return true; @@ -71,7 +71,7 @@ bool Configuration::writeIfNeeded() { try { m_userCfg->writeFile(m_userCfgPath.c_str()); - } catch (FileIOException) { + } catch(FileIOException) { return false; } return true; @@ -81,13 +81,13 @@ bool Configuration::parseDefaultConfiguration(const std::string &contents) { try { m_defaultCfg->readString(contents); - } catch (ParseException) { + } catch(ParseException) { return false; } return true; } -std::vector Configuration::childrenSettings(const char* name) +std::vector Configuration::childrenSettings(const char *name) { std::vector groupNames; const Setting &root = m_userCfg->lookup(name); @@ -101,7 +101,7 @@ std::vector Configuration::childrenSettings(const char* name) return groupNames; } -std::vector Configuration::childrenGroups(const char* name) +std::vector Configuration::childrenGroups(const char *name) { std::vector groupNames; const Setting &root = m_userCfg->lookup(name); @@ -118,7 +118,7 @@ void Configuration::resetValue(const char *path) { if(m_userCfg->exists(path)) { Setting &v = m_userCfg->lookup(path); - switch (v.getType()) { + switch(v.getType()) { case Setting::TypeNone: break; case Setting::TypeInt: @@ -146,8 +146,8 @@ void Configuration::resetValue(const char *path) } } -template -std::optional Configuration::value(const char* path) const +template +std::optional Configuration::value(const char *path) const { // if setting doesn't exist, give back a nullopt if(!m_userCfg->exists(path)) { @@ -160,7 +160,7 @@ std::optional Configuration::value(const char* path) const // cast depending on type // type checks are done during compile time - switch (setting.getType()) { + switch(setting.getType()) { case Setting::TypeNone: r = std::nullopt; break; @@ -201,7 +201,7 @@ std::optional Configuration::value(const char* path) const case Setting::TypeString: // const char*, std::string if constexpr(std::is_same::value) { - r = std::optional(static_cast(setting)); + r = std::optional(static_cast(setting)); } else { r = std::nullopt; } @@ -235,22 +235,22 @@ std::optional Configuration::value(const char* path) const } // tell the compiler to export these functions, otherwise you get linking errors -template std::optional Configuration::value(const char* path) const; -template std::optional Configuration::value(const char* path) const; -template std::optional Configuration::value(const char* path) const; -template std::optional Configuration::value(const char* path) const; +template std::optional Configuration::value(const char *path) const; +template std::optional Configuration::value(const char *path) const; +template std::optional Configuration::value(const char *path) const; +template std::optional Configuration::value(const char *path) const; -template std::optional Configuration::value(const char* path) const; -template std::optional Configuration::value(const char* path) const; +template std::optional Configuration::value(const char *path) const; +template std::optional Configuration::value(const char *path) const; -template std::optional Configuration::value(const char* path) const; -template std::optional Configuration::value(const char* path) const; +template std::optional Configuration::value(const char *path) const; +template std::optional Configuration::value(const char *path) const; -template std::optional Configuration::value(const char* path) const; +template std::optional Configuration::value(const char *path) const; -template std::optional Configuration::value(const char* path) const; +template std::optional Configuration::value(const char *path) const; -template +template bool Configuration::setValue(std::string path, const T &val) { if(m_userCfg->exists(path)) { @@ -259,7 +259,7 @@ bool Configuration::setValue(std::string path, const T &val) if constexpr(std::is_unsigned_v && !std::is_same_v) { setting = static_cast>(val); } else if constexpr(std::is_same_v) { - switch (setting.getType()) { + switch(setting.getType()) { case Setting::TypeNone: break; @@ -279,7 +279,7 @@ bool Configuration::setValue(std::string path, const T &val) case Setting::TypeBoolean: if(static_cast(val) == "true") { setting = true; - } else if (static_cast(val) == "false") { + } else if(static_cast(val) == "false") { setting = false; } break; diff --git a/lib/settings/configuration.h b/lib/settings/configuration.h index b258cb3..4fc614e 100644 --- a/lib/settings/configuration.h +++ b/lib/settings/configuration.h @@ -10,10 +10,11 @@ #define CONFIGURATION_H #include -#include #include +#include -namespace libconfig { +namespace libconfig +{ class Config; class Setting; } @@ -34,12 +35,12 @@ public: std::vector childrenSettings(const char *name = ""); std::vector childrenGroups(const char *name = ""); - void resetValue(const char* path); + void resetValue(const char *path); - template - std::optional value(const char* path) const; + template + std::optional value(const char *path) const; - template + template bool setValue(std::string path, const T &val); private: @@ -49,26 +50,26 @@ private: }; // replace ~ with home -std::string& patchHome(std::string &path, const std::string &home); +std::string &patchHome(std::string &path, const std::string &home); // instantiate functions // this needs to be done because the implementation is in the cpp file // Settings::value<> -extern template std::optional Configuration::value(const char* path) const; -extern template std::optional Configuration::value(const char* path) const; -extern template std::optional Configuration::value(const char* path) const; -extern template std::optional Configuration::value(const char* path) const; +extern template std::optional Configuration::value(const char *path) const; +extern template std::optional Configuration::value(const char *path) const; +extern template std::optional Configuration::value(const char *path) const; +extern template std::optional Configuration::value(const char *path) const; -extern template std::optional Configuration::value(const char* path) const; -extern template std::optional Configuration::value(const char* path) const; +extern template std::optional Configuration::value(const char *path) const; +extern template std::optional Configuration::value(const char *path) const; -extern template std::optional Configuration::value(const char* path) const; -extern template std::optional Configuration::value(const char* path) const; +extern template std::optional Configuration::value(const char *path) const; +extern template std::optional Configuration::value(const char *path) const; -extern template std::optional Configuration::value(const char* path) const; +extern template std::optional Configuration::value(const char *path) const; -extern template std::optional Configuration::value(const char* path) const; +extern template std::optional Configuration::value(const char *path) const; // Settings::setValue<> extern template bool Configuration::setValue(std::string path, const int &val); diff --git a/lib/settings/settingsdialog.cpp b/lib/settings/settingsdialog.cpp index 478e372..97b5f44 100644 --- a/lib/settings/settingsdialog.cpp +++ b/lib/settings/settingsdialog.cpp @@ -7,19 +7,19 @@ */ #include "settingsdialog.h" -#include "ui_settingsdialog.h" #include "configuration.h" -#include +#include "ui_settingsdialog.h" #include +#include #include +#include #include -#include inline QHBoxLayout *createEntry(Configuration *config, const std::string &path, QWidget *widget); -SettingsDialog::SettingsDialog(std::shared_ptr &settings, QWidget *parent) : - QDialog(parent), - ui(new Ui::SettingsDialog) +SettingsDialog::SettingsDialog(std::shared_ptr &settings, QWidget *parent) + : QDialog(parent) + , ui(new Ui::SettingsDialog) { ui->setupUi(this); @@ -67,7 +67,7 @@ QWidget *widgetForGroup(std::shared_ptr &settings, const std::str return widget; } -inline QHBoxLayout *createEntry(Configuration* config, const std::string &path, QWidget *widget) +inline QHBoxLayout *createEntry(Configuration *config, const std::string &path, QWidget *widget) { QLineEdit *lineEdit = new QLineEdit(widget); lineEdit->setText(QString::fromStdString(config->value(path.c_str()).value())); diff --git a/lib/settings/settingsdialog.h b/lib/settings/settingsdialog.h index 74dd964..f77b822 100644 --- a/lib/settings/settingsdialog.h +++ b/lib/settings/settingsdialog.h @@ -12,7 +12,8 @@ #include #include -namespace Ui { +namespace Ui +{ class SettingsDialog; } diff --git a/src/browser.cpp b/src/browser.cpp index aad80bb..bd1f841 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -7,14 +7,14 @@ */ #include "browser.h" -#include -#include -#include "webengine/urlinterceptor.h" #include "mainwindow.h" +#include "webengine/urlinterceptor.h" #include +#include +#include -Browser::Browser(int &argc, char *argv[]) : - SingleApplication(argc, argv) +Browser::Browser(int &argc, char *argv[]) + : SingleApplication(argc, argv) { setApplicationName("smolbote"); setWindowIcon(QIcon(":/icon.svg")); @@ -43,7 +43,6 @@ void Browser::setConfiguration(std::shared_ptr &config) // set default profile m_defaultProfile = profile(QString::fromStdString(m_config->value("browser.profile").value())); - } MainWindow *Browser::createWindow() @@ -124,4 +123,3 @@ QStringList Browser::profiles() const { return m_profiles.keys(); } - diff --git a/src/browser.h b/src/browser.h index a193e61..1383c44 100644 --- a/src/browser.h +++ b/src/browser.h @@ -9,11 +9,11 @@ #ifndef BROWSER_H #define BROWSER_H +#include "settings/configuration.h" #include "singleapplication.h" #include "webengine/webengineprofile.h" #include #include -#include "settings/configuration.h" class MainWindow; class BookmarksWidget; diff --git a/src/forms/aboutdialog.cpp b/src/forms/aboutdialog.cpp index 0744a5f..e5dfc7d 100644 --- a/src/forms/aboutdialog.cpp +++ b/src/forms/aboutdialog.cpp @@ -12,7 +12,7 @@ constexpr const char *getCompiler() { - // clang also defines __GNUC__, so we need to check for clang first +// clang also defines __GNUC__, so we need to check for clang first #if defined(__clang__) return "Clang " __clang_version__; #elif defined(__GNUC__) @@ -31,9 +31,9 @@ inline const QString getLongVersion() #endif } -AboutDialog::AboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutDialog) +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent) + , ui(new Ui::AboutDialog) { setAttribute(Qt::WA_DeleteOnClose, true); ui->setupUi(this); @@ -44,7 +44,7 @@ AboutDialog::AboutDialog(QWidget *parent) : aboutLabel->setWordWrap(true); aboutLabel->setText(tr("

smolbote %1

" "

yet another no-frills browser

") - .arg(qApp->applicationVersion())); + .arg(qApp->applicationVersion())); ui->toolBox->addItem(aboutLabel, tr("About")); QLabel *licenseLabel = new QLabel(this); @@ -72,7 +72,7 @@ AboutDialog::AboutDialog(QWidget *parent) : "
  • Qt %3
  • " "
  • libconfig
  • " "

    ") - .arg(getLongVersion(), getCompiler(), qVersion())); + .arg(getLongVersion(), getCompiler(), qVersion())); ui->toolBox->addItem(libsLabel, tr("Details")); } diff --git a/src/forms/aboutdialog.h b/src/forms/aboutdialog.h index 9f2189e..740df09 100644 --- a/src/forms/aboutdialog.h +++ b/src/forms/aboutdialog.h @@ -11,7 +11,8 @@ #include -namespace Ui { +namespace Ui +{ class AboutDialog; } diff --git a/src/forms/cookiesform.cpp b/src/forms/cookiesform.cpp index 94d1854..cf2bcb8 100644 --- a/src/forms/cookiesform.cpp +++ b/src/forms/cookiesform.cpp @@ -11,16 +11,16 @@ #include -CookiesForm::CookiesForm(QWebEngineCookieStore *store, QWidget *parent) : - QWidget(parent), - ui(new Ui::CookiesForm) +CookiesForm::CookiesForm(QWebEngineCookieStore *store, QWidget *parent) + : QWidget(parent) + , ui(new Ui::CookiesForm) { setAttribute(Qt::WA_DeleteOnClose, false); ui->setupUi(this); ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); connect(store, SIGNAL(cookieAdded(QNetworkCookie)), this, SLOT(addCookie(QNetworkCookie))); - connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(showDetails(QTreeWidgetItem*,QTreeWidgetItem*))); + connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(showDetails(QTreeWidgetItem *, QTreeWidgetItem *))); } CookiesForm::~CookiesForm() @@ -57,7 +57,6 @@ void CookiesForm::addCookie(const QNetworkCookie &cookie) item->setData(0, IsSecureRole, cookie.isSecure() ? tr("yes") : tr("no")); item->setData(0, IsSessionCookieRole, cookie.isSessionCookie() ? tr("yes") : tr("no")); item->setData(0, PathRole, cookie.path()); - } void CookiesForm::showDetails(QTreeWidgetItem *current, QTreeWidgetItem *previous) diff --git a/src/forms/cookiesform.h b/src/forms/cookiesform.h index 01c32ff..18c7698 100644 --- a/src/forms/cookiesform.h +++ b/src/forms/cookiesform.h @@ -9,11 +9,12 @@ #ifndef COOKIESFORM_H #define COOKIESFORM_H -#include -#include #include +#include +#include -namespace Ui { +namespace Ui +{ class CookiesForm; } diff --git a/src/forms/profileview.cpp b/src/forms/profileview.cpp index 7d3396f..3d85963 100644 --- a/src/forms/profileview.cpp +++ b/src/forms/profileview.cpp @@ -9,20 +9,20 @@ #include "profileview.h" #include "ui_profileview.h" +#include "forms/cookiesform.h" +#include "webengine/webengineprofile.h" +#include #include #include -#include #include -#include "webengine/webengineprofile.h" -#include "forms/cookiesform.h" #include #include -ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) : - QDialog(parent), - ui(new Ui::ProfileView) +ProfileView::ProfileView(WebEngineProfile *profile, QWidget *parent) + : QDialog(parent) + , ui(new Ui::ProfileView) { ui->setupUi(this); setProfile(profile); @@ -98,7 +98,7 @@ void ProfileView::updateProfile() // http m_profile->setHttpUserAgent(ui->userAgent->toPlainText()); m_profile->setHttpAcceptLanguage(ui->acceptLanguage->toPlainText()); - switch (ui->cacheType->currentIndex()) { + switch(ui->cacheType->currentIndex()) { case 0: m_profile->setHttpCacheType(QWebEngineProfile::MemoryHttpCache); break; @@ -114,7 +114,7 @@ void ProfileView::updateProfile() m_profile->setHttpCacheMaximumSize(ui->cacheSize->text().toInt()); // policy - switch (ui->cookiePolicy->currentIndex()) { + switch(ui->cookiePolicy->currentIndex()) { case 0: m_profile->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); break; diff --git a/src/forms/profileview.h b/src/forms/profileview.h index a2e42f2..bf44346 100644 --- a/src/forms/profileview.h +++ b/src/forms/profileview.h @@ -11,7 +11,8 @@ #include -namespace Ui { +namespace Ui +{ class ProfileView; } diff --git a/src/forms/searchform.cpp b/src/forms/searchform.cpp index b12ff80..42e5a1a 100644 --- a/src/forms/searchform.cpp +++ b/src/forms/searchform.cpp @@ -7,14 +7,14 @@ */ #include "searchform.h" -#include "ui_searchform.h" #include "../mainwindow.h" +#include "ui_searchform.h" #include -SearchForm::SearchForm(MainWindow *parentWindow, QWidget *parent) : - QWidget(parent), - ui(new Ui::SearchForm) +SearchForm::SearchForm(MainWindow *parentWindow, QWidget *parent) + : QWidget(parent) + , ui(new Ui::SearchForm) { Q_CHECK_PTR(parentWindow); diff --git a/src/forms/searchform.h b/src/forms/searchform.h index 646d4d4..85ce11b 100644 --- a/src/forms/searchform.h +++ b/src/forms/searchform.h @@ -11,7 +11,8 @@ #include -namespace Ui { +namespace Ui +{ class SearchForm; } diff --git a/src/main.cpp b/src/main.cpp index b7bd311..57389bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,15 +6,15 @@ * SPDX-License-Identifier: GPL-3.0 */ -#include -#include "version.h" #include "browser.h" +#include "mainwindow.h" +#include "version.h" #include +#include #include #include -#include #include -#include "mainwindow.h" +#include // startup time measuring #ifdef QT_DEBUG @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) parser.addVersionOption(); // user config, ~/.config/smolbote/smolbote.cfg or empty if there is none - QCommandLineOption configOption({"c", "config"}, "Set configuration file.", "path"); + QCommandLineOption configOption({ "c", "config" }, "Set configuration file.", "path"); configOption.setDefaultValue(QStandardPaths::locate(QStandardPaths::AppConfigLocation, "smolbote.cfg")); parser.addOption(configOption); @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) QCommandLineOption generateUserConfigOption("generate-user-config", "Generate user configuration and exit."); parser.addOption(generateUserConfigOption); - QCommandLineOption profileOption({"p", "profile"}, "Use this profile.", "PROFILE"); + QCommandLineOption profileOption({ "p", "profile" }, "Use this profile.", "PROFILE"); profileOption.setDefaultValue(""); parser.addOption(profileOption); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b7c4a05..a2b9ff1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -7,10 +7,10 @@ */ #include "mainwindow.h" +#include "forms/aboutdialog.h" #include "ui_mainwindow.h" #include "widgets/mainwindowmenubar.h" #include -#include "forms/aboutdialog.h" #include @@ -26,13 +26,13 @@ #include "forms/searchform.h" -MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow), - tabBar(new MainWindowTabBar(config, this)), - menuBar(new MainWindowMenuBar(config, this)), - m_addressBar(new UrlLineEdit(this)), - m_progressBar(new LoadingBar(this)) +MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) + , tabBar(new MainWindowTabBar(config, this)) + , menuBar(new MainWindowMenuBar(config, this)) + , m_addressBar(new UrlLineEdit(this)) + , m_progressBar(new LoadingBar(this)) { Q_ASSERT(config); m_config = config; @@ -93,7 +93,7 @@ MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) : url.replace("$term", t); tabBar->currentView()->load(QUrl::fromUserInput(url)); }); - connect(tabBar, SIGNAL(currentTabChanged(WebView*)), this, SLOT(handleTabChanged(WebView*))); + connect(tabBar, SIGNAL(currentTabChanged(WebView *)), this, SLOT(handleTabChanged(WebView *))); // loading bar ui->statusBar->addPermanentWidget(m_progressBar); @@ -124,7 +124,7 @@ MainWindow::~MainWindow() { // Release all dock widgets before deleting so we don't accidentally delete them // Also fixes that annoying crash when closing - QList allDockWidgets = findChildren(); + QList allDockWidgets = findChildren(); for(QDockWidget *w : allDockWidgets) { if(w->widget()) { w->widget()->setParent(nullptr); @@ -137,10 +137,10 @@ MainWindow::~MainWindow() void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QWidget *widget) { // get all dock widgets - QList allDockWidgets = findChildren(); + QList allDockWidgets = findChildren(); // make a list of widgets in the area we want - QVector areaDockWidgets; + QVector areaDockWidgets; for(QDockWidget *w : allDockWidgets) { if(dockWidgetArea(w) == area) { areaDockWidgets.append(w); @@ -176,7 +176,7 @@ void MainWindow::newTab(const QUrl &url) MainWindow *MainWindow::newWindow(const QUrl &url) { - Browser *instance = static_cast(qApp->instance()); + Browser *instance = static_cast(qApp->instance()); return instance->createSession(m_profile->storageName(), true, QStringList(url.toString())); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 2e6f510..c62ebe3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -9,17 +9,18 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include #include "webengine/webengineprofile.h" -#include -#include "widgets/mainwindowtabbar.h" #include "widgets/loadingbar.h" +#include "widgets/mainwindowtabbar.h" +#include +#include #include "lib/navigation/navigationbutton.h" #include -namespace Ui { +namespace Ui +{ class MainWindow; } diff --git a/src/singleapplication.cpp b/src/singleapplication.cpp index 4810d73..eb51d0c 100644 --- a/src/singleapplication.cpp +++ b/src/singleapplication.cpp @@ -7,11 +7,12 @@ */ #include "singleapplication.h" +#include #include #include -#include -SingleApplication::SingleApplication(int &argc, char **argv) : QApplication(argc, argv) +SingleApplication::SingleApplication(int &argc, char **argv) + : QApplication(argc, argv) { #ifdef Q_OS_UNIX // could be a path such as "/tmp/foo" @@ -65,7 +66,6 @@ bool SingleApplication::bindLocalSocket(const QString &name) } return true; } - } QString SingleApplication::serverName() const diff --git a/src/singleapplication.h b/src/singleapplication.h index a4ecb2e..8ebea12 100644 --- a/src/singleapplication.h +++ b/src/singleapplication.h @@ -17,7 +17,6 @@ class SingleApplication : public QApplication Q_OBJECT public: - explicit SingleApplication(int &argc, char **argv); ~SingleApplication(); diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp index b8d30cd..bb9bb5f 100644 --- a/src/webengine/urlinterceptor.cpp +++ b/src/webengine/urlinterceptor.cpp @@ -10,8 +10,8 @@ #include #include -UrlRequestInterceptor::UrlRequestInterceptor(const QString &path, QObject *parent) : - QWebEngineUrlRequestInterceptor(parent) +UrlRequestInterceptor::UrlRequestInterceptor(const QString &path, QObject *parent) + : QWebEngineUrlRequestInterceptor(parent) { #ifdef QT_DEBUG qDebug("Reading request blocklist: %s", qUtf8Printable(path)); diff --git a/src/webengine/urlinterceptor.h b/src/webengine/urlinterceptor.h index af0bf35..24936c3 100644 --- a/src/webengine/urlinterceptor.h +++ b/src/webengine/urlinterceptor.h @@ -15,7 +15,6 @@ class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor { Q_OBJECT public: - struct HostRule { bool isBlocking; }; @@ -29,7 +28,7 @@ public slots: int parseHostfile(const QString &filename); private: - QHash m_rules; + QHash m_rules; }; #endif // URLREQUESTINTERCEPTOR_H diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp index 2d98b3d..78f0b9a 100644 --- a/src/webengine/webengineprofile.cpp +++ b/src/webengine/webengineprofile.cpp @@ -7,12 +7,12 @@ */ #include "webengineprofile.h" +#include #include #include -#include -WebEngineProfile::WebEngineProfile(QObject *parent) : - QWebEngineProfile(parent) +WebEngineProfile::WebEngineProfile(QObject *parent) + : QWebEngineProfile(parent) { m_name = tr("Off-the-record"); @@ -23,8 +23,8 @@ WebEngineProfile::WebEngineProfile(QObject *parent) : // Off-the-record profiles have no persistent path } -WebEngineProfile::WebEngineProfile(const QString &name, const QString &path, QObject *parent) : - QWebEngineProfile(name, parent) +WebEngineProfile::WebEngineProfile(const QString &name, const QString &path, QObject *parent) + : QWebEngineProfile(name, parent) { m_name = name; @@ -78,7 +78,7 @@ void WebEngineProfile::saveProfile() config.beginGroup("http"); config.setValue("userAgent", httpUserAgent()); config.setValue("accept-lang", httpAcceptLanguage()); - switch (httpCacheType()) { + switch(httpCacheType()) { case MemoryHttpCache: config.setValue("cacheType", "memory"); break; @@ -90,10 +90,10 @@ void WebEngineProfile::saveProfile() break; } config.setValue("cacheSize", httpCacheMaximumSize()); - config.endGroup(); // http + config.endGroup(); // http config.beginGroup("policy"); - switch (persistentCookiesPolicy()) { + switch(persistentCookiesPolicy()) { case NoPersistentCookies: config.setValue("cookies", "disabled"); break; @@ -104,7 +104,7 @@ void WebEngineProfile::saveProfile() config.setValue("cookies", "force"); break; } - config.endGroup(); // policy + config.endGroup(); // policy QWebEngineSettings *s = settings(); config.beginGroup("attributes"); @@ -133,7 +133,7 @@ void WebEngineProfile::saveProfile() config.setValue("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)); config.setValue("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)); #endif - config.endGroup(); // attributes + config.endGroup(); // attributes config.sync(); } @@ -170,7 +170,7 @@ WebEngineProfile *createProfile(const QString &name, const QString &path, QObjec } } profile->setHttpCacheMaximumSize(config.value("cacheSize").toInt()); - config.endGroup(); // http + config.endGroup(); // http config.beginGroup("policy"); { @@ -183,59 +183,59 @@ WebEngineProfile *createProfile(const QString &name, const QString &path, QObjec profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies); } } - config.endGroup(); // policy + config.endGroup(); // policy config.beginGroup("attributes"); QWebEngineSettings *s = profile->settings(); s->setAttribute(QWebEngineSettings::AutoLoadImages, - config.value("autoLoadImages", s->testAttribute(QWebEngineSettings::AutoLoadImages)).toBool()); + config.value("autoLoadImages", s->testAttribute(QWebEngineSettings::AutoLoadImages)).toBool()); s->setAttribute(QWebEngineSettings::JavascriptEnabled, - config.value("javascriptEnabled", s->testAttribute(QWebEngineSettings::JavascriptEnabled)).toBool()); + config.value("javascriptEnabled", s->testAttribute(QWebEngineSettings::JavascriptEnabled)).toBool()); s->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, - config.value("javascriptCanOpenWindows", s->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)).toBool()); + config.value("javascriptCanOpenWindows", s->testAttribute(QWebEngineSettings::JavascriptCanOpenWindows)).toBool()); s->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, - config.value("javascriptCanAccessClipboard", s->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)).toBool()); + config.value("javascriptCanAccessClipboard", s->testAttribute(QWebEngineSettings::JavascriptCanAccessClipboard)).toBool()); s->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, - config.value("linksIncludedInFocusChain", s->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain)).toBool()); + config.value("linksIncludedInFocusChain", s->testAttribute(QWebEngineSettings::LinksIncludedInFocusChain)).toBool()); s->setAttribute(QWebEngineSettings::LocalStorageEnabled, - config.value("localStorageEnabled", s->testAttribute(QWebEngineSettings::LocalStorageEnabled)).toBool()); + config.value("localStorageEnabled", s->testAttribute(QWebEngineSettings::LocalStorageEnabled)).toBool()); s->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, - config.value("localContentCanAccessRemoteUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls)).toBool()); + config.value("localContentCanAccessRemoteUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls)).toBool()); s->setAttribute(QWebEngineSettings::XSSAuditingEnabled, - config.value("xssAuditingEnabled", s->testAttribute(QWebEngineSettings::XSSAuditingEnabled)).toBool()); + config.value("xssAuditingEnabled", s->testAttribute(QWebEngineSettings::XSSAuditingEnabled)).toBool()); s->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, - config.value("spatialNavigationEnabled", s->testAttribute(QWebEngineSettings::SpatialNavigationEnabled)).toBool()); + config.value("spatialNavigationEnabled", s->testAttribute(QWebEngineSettings::SpatialNavigationEnabled)).toBool()); s->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, - config.value("localContentCanAccessFileUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)).toBool()); + config.value("localContentCanAccessFileUrls", s->testAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls)).toBool()); s->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, - config.value("hyperlinkAuditingEnabled", s->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled)).toBool()); + config.value("hyperlinkAuditingEnabled", s->testAttribute(QWebEngineSettings::HyperlinkAuditingEnabled)).toBool()); s->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, - config.value("scrollAnimatorEnabled", s->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)).toBool()); + config.value("scrollAnimatorEnabled", s->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled)).toBool()); s->setAttribute(QWebEngineSettings::ErrorPageEnabled, - config.value("errorPageEnabled", s->testAttribute(QWebEngineSettings::ErrorPageEnabled)).toBool()); + config.value("errorPageEnabled", s->testAttribute(QWebEngineSettings::ErrorPageEnabled)).toBool()); s->setAttribute(QWebEngineSettings::PluginsEnabled, - config.value("pluginsEnabled", s->testAttribute(QWebEngineSettings::PluginsEnabled)).toBool()); + config.value("pluginsEnabled", s->testAttribute(QWebEngineSettings::PluginsEnabled)).toBool()); s->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, - config.value("fullscreenSupportEnabled", s->testAttribute(QWebEngineSettings::FullScreenSupportEnabled)).toBool()); + config.value("fullscreenSupportEnabled", s->testAttribute(QWebEngineSettings::FullScreenSupportEnabled)).toBool()); s->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, - config.value("screenCaptureEnabled", s->testAttribute(QWebEngineSettings::ScreenCaptureEnabled)).toBool()); + config.value("screenCaptureEnabled", s->testAttribute(QWebEngineSettings::ScreenCaptureEnabled)).toBool()); s->setAttribute(QWebEngineSettings::WebGLEnabled, - config.value("webglEnabled", s->testAttribute(QWebEngineSettings::WebGLEnabled)).toBool()); + config.value("webglEnabled", s->testAttribute(QWebEngineSettings::WebGLEnabled)).toBool()); s->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, - config.value("accelerated2dCanvasEnabled", s->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled)).toBool()); + config.value("accelerated2dCanvasEnabled", s->testAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled)).toBool()); s->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, - config.value("autoLoadIconsForPage", s->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)).toBool()); + config.value("autoLoadIconsForPage", s->testAttribute(QWebEngineSettings::AutoLoadIconsForPage)).toBool()); s->setAttribute(QWebEngineSettings::TouchIconsEnabled, - config.value("touchIconsEnabled", s->testAttribute(QWebEngineSettings::TouchIconsEnabled)).toBool()); + config.value("touchIconsEnabled", s->testAttribute(QWebEngineSettings::TouchIconsEnabled)).toBool()); #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) s->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, - config.value("focusOnNavigationEnabled", s->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled)).toBool()); + config.value("focusOnNavigationEnabled", s->testAttribute(QWebEngineSettings::FocusOnNavigationEnabled)).toBool()); s->setAttribute(QWebEngineSettings::PrintElementBackgrounds, - config.value("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)).toBool()); + config.value("printElementBackgrounds", s->testAttribute(QWebEngineSettings::PrintElementBackgrounds)).toBool()); s->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, - config.value("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)).toBool()); + config.value("allowRunningInsecureContent", s->testAttribute(QWebEngineSettings::AllowRunningInsecureContent)).toBool()); #endif - config.endGroup(); // attributes + config.endGroup(); // attributes } #ifdef QT_DEBUG else { diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h index 63a97a4..bcf21bc 100644 --- a/src/webengine/webengineprofile.h +++ b/src/webengine/webengineprofile.h @@ -9,8 +9,8 @@ #ifndef WEBENGINEPROFILE_H #define WEBENGINEPROFILE_H -#include #include +#include class WebEngineProfile : public QWebEngineProfile { diff --git a/src/webengine/webpage.cpp b/src/webengine/webpage.cpp index 96ae040..c8ad24b 100644 --- a/src/webengine/webpage.cpp +++ b/src/webengine/webpage.cpp @@ -10,8 +10,8 @@ #include -WebPage::WebPage(QWebEngineProfile *profile, QObject *parent) : - QWebEnginePage(profile, parent) +WebPage::WebPage(QWebEngineProfile *profile, QObject *parent) + : QWebEnginePage(profile, parent) { connect(this, &WebPage::fullScreenRequested, this, [](QWebEngineFullScreenRequest request) { request.accept(); diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index ee9b134..ea0ee26 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -13,18 +13,18 @@ #include // zoom widget -#include -#include #include -#include #include #include +#include +#include +#include // printer support #include +#include #include #include -#include #include "mainwindow.h" #include @@ -32,8 +32,8 @@ // ssl errors #include "lib/navigation/urllineedit.h" -WebView::WebView(MainWindow *parentMainWindow, QWidget *parent) : - QWebEngineView(parent) +WebView::WebView(MainWindow *parentMainWindow, QWidget *parent) + : QWebEngineView(parent) { Q_CHECK_PTR(parentMainWindow); m_parent = parentMainWindow; @@ -140,7 +140,7 @@ void WebView::setPage(WebPage *page) WebView *WebView::createWindow(QWebEnginePage::WebWindowType type) { WebView *view = new WebView(m_parent); - switch (type) { + switch(type) { case QWebEnginePage::WebBrowserWindow: // a complete web browser window m_parent->newWindow()->tabBar->addTab(view); diff --git a/src/webengine/webview.h b/src/webengine/webview.h index 9951630..18a1e02 100644 --- a/src/webengine/webview.h +++ b/src/webengine/webview.h @@ -9,9 +9,9 @@ #ifndef WEBVIEW_H #define WEBVIEW_H -#include -#include #include "webpage.h" +#include +#include class MainWindow; class WebView : public QWebEngineView diff --git a/src/widgets/loadingbar.cpp b/src/widgets/loadingbar.cpp index 5dde427..e72c5bb 100644 --- a/src/widgets/loadingbar.cpp +++ b/src/widgets/loadingbar.cpp @@ -7,11 +7,11 @@ */ #include "loadingbar.h" -#include #include +#include -LoadingBar::LoadingBar(QWidget *parent) : - QProgressBar(parent) +LoadingBar::LoadingBar(QWidget *parent) + : QProgressBar(parent) { setMaximum(100); } diff --git a/src/widgets/mainwindowmenubar.cpp b/src/widgets/mainwindowmenubar.cpp index ada3ad1..c0bea4f 100644 --- a/src/widgets/mainwindowmenubar.cpp +++ b/src/widgets/mainwindowmenubar.cpp @@ -7,17 +7,17 @@ */ #include "mainwindowmenubar.h" -#include -#include #include "forms/profileview.h" #include "mainwindow.h" +#include +#include #include #include "browser.h" #include "downloads/downloadswidget.h" -MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr config, MainWindow *parent) : - QMenuBar(parent) +MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr config, MainWindow *parent) + : QMenuBar(parent) { Q_ASSERT(config); Q_CHECK_PTR(parent); @@ -93,5 +93,5 @@ void MainWindowMenuBar::setProfileName(const QString &name) void MainWindowMenuBar::handleLoadProfile(const QString &name, MainWindow *window) { - window->setProfile(static_cast(qApp->instance())->profile(name)); + window->setProfile(static_cast(qApp->instance())->profile(name)); } diff --git a/src/widgets/mainwindowtabbar.cpp b/src/widgets/mainwindowtabbar.cpp index da2cef3..5cf360d 100644 --- a/src/widgets/mainwindowtabbar.cpp +++ b/src/widgets/mainwindowtabbar.cpp @@ -8,13 +8,13 @@ #include "mainwindowtabbar.h" #include -#include #include +#include #include "mainwindow.h" -MainWindowTabBar::MainWindowTabBar(const std::shared_ptr &config, MainWindow *parent) : - QTabBar(parent) +MainWindowTabBar::MainWindowTabBar(const std::shared_ptr &config, MainWindow *parent) + : QTabBar(parent) { Q_CHECK_PTR(parent); m_parent = parent; @@ -37,13 +37,13 @@ MainWindowTabBar::MainWindowTabBar(const std::shared_ptr &config, QShortcut *tabLeftShortcut = new QShortcut(parent); tabLeftShortcut->setKey(QKeySequence(QString::fromStdString(config->value("browser.shortcuts.tabLeft").value()))); connect(tabLeftShortcut, &QShortcut::activated, [this]() { - this->setCurrentIndex(currentIndex()-1); + this->setCurrentIndex(currentIndex() - 1); }); QShortcut *tabRightShortcut = new QShortcut(parent); tabRightShortcut->setKey(QKeySequence(QString::fromStdString(config->value("browser.shortcuts.tabRight").value()))); connect(tabRightShortcut, &QShortcut::activated, [this]() { - this->setCurrentIndex(currentIndex()+1); + this->setCurrentIndex(currentIndex() + 1); }); } @@ -94,7 +94,7 @@ void MainWindowTabBar::contextMenuEvent(QContextMenuEvent *event) } QMenu menu(this); - QAction* closeAction = menu.addAction(tr("Close tab")); + QAction *closeAction = menu.addAction(tr("Close tab")); connect(closeAction, &QAction::triggered, this, [tabIndex, this]() { removeTab(tabIndex); }); diff --git a/src/widgets/mainwindowtabbar.h b/src/widgets/mainwindowtabbar.h index d0ae9cb..845b908 100644 --- a/src/widgets/mainwindowtabbar.h +++ b/src/widgets/mainwindowtabbar.h @@ -9,9 +9,9 @@ #ifndef WEBVIEWTABBAR_H #define WEBVIEWTABBAR_H -#include -#include "webengine/webview.h" #include "webengine/webengineprofile.h" +#include "webengine/webview.h" +#include #include class Configuration; @@ -46,7 +46,7 @@ private slots: private: // store all views in a vector since tabs can only store a QVariant, and that can't easily take a pointer - QVector m_views; + QVector m_views; MainWindow *m_parent; }; diff --git a/tools/hooks/pre-commit.rb b/tools/hooks/pre-commit.rb index c224a49..825a851 100755 --- a/tools/hooks/pre-commit.rb +++ b/tools/hooks/pre-commit.rb @@ -15,11 +15,5 @@ files.each { |name| } } -puts 'Running astyle...' -if not `astyle --dry-run --formatted --options=astyle.rc #{files.join(' ')}`.empty? then - system "astyle --verbose --suffix=none --formatted --options=astyle.rc #{files.join(' ')}" - result = 1 -end - puts "pre-commit exit(#{result})" exit result -- cgit v1.2.1