Skip to content

Commit 48e5143

Browse files
committed
Format code with clang-format
1 parent 23931b8 commit 48e5143

14 files changed

Lines changed: 1091 additions & 1012 deletions

.clang-format

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
2+
#
3+
# You may use this file under the terms of the 3-clause BSD license.
4+
# See the file LICENSE from this package for details.
5+
6+
# This is the clang-format configuration style to be used by Qt,
7+
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
8+
# https://wiki.qt.io/Coding_Conventions
9+
10+
---
11+
# Webkit style was loosely based on the Qt style
12+
BasedOnStyle: WebKit
13+
14+
Standard: Cpp11
15+
16+
# Leave the line breaks up to the user.
17+
# Note that this may be changed at some point in the future.
18+
ColumnLimit: 0
19+
# How much weight do extra characters after the line length limit have.
20+
# PenaltyExcessCharacter: 4
21+
22+
# Disable reflow of qdoc comments: indentation rules are different.
23+
# Translation comments are also excluded.
24+
CommentPragmas: "^!|^:"
25+
26+
# We want a space between the type and the star for pointer types.
27+
PointerBindsToType: false
28+
29+
# We use template< without space.
30+
SpaceAfterTemplateKeyword: false
31+
32+
# We want to break before the operators, but not before a '='.
33+
BreakBeforeBinaryOperators: All
34+
35+
# Braces are usually attached, but not after functions or class declarations.
36+
BreakBeforeBraces: Custom
37+
BraceWrapping:
38+
AfterClass: true
39+
AfterControlStatement: true
40+
AfterEnum: true
41+
AfterFunction: true
42+
AfterNamespace: true
43+
AfterObjCDeclaration: true
44+
AfterStruct: true
45+
AfterUnion: true
46+
BeforeCatch: true
47+
BeforeElse: true
48+
IndentBraces: false
49+
50+
BreakBeforeTernaryOperators: true
51+
52+
BreakConstructorInitializers: BeforeComma
53+
54+
# Indent initializers by 3 spaces
55+
ConstructorInitializerIndentWidth: 3
56+
57+
# No indentation for namespaces.
58+
NamespaceIndentation: None
59+
60+
# Horizontally align arguments after an open bracket.
61+
# The coding style does not specify the following, but this is what gives
62+
# results closest to the existing code.
63+
AlignAfterOpenBracket: true
64+
AlwaysBreakTemplateDeclarations: true
65+
66+
# Ideally we should also allow less short function in a single line, but
67+
# clang-format does not handle that.
68+
AllowShortFunctionsOnASingleLine: Inline
69+
70+
# The coding style specifies some include order categories, but also tells to
71+
# separate categories with an empty line. It does not specify the order within
72+
# the categories. Since the SortInclude feature of clang-format does not
73+
# re-order includes separated by empty lines, the feature is not used.
74+
SortIncludes: false
75+
76+
# macros for which the opening brace stays attached.
77+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
78+
79+
IndentCaseLabels: true
80+
81+
IndentPPDirectives: AfterHash
82+
83+
AlignAfterOpenBracket: Align
84+
85+
AccessModifierOffset: -3
86+
87+
IndentWidth: 3
88+
89+
#StatementMacros ['Q_OBJECT', 'Q_UNUSED']
90+
91+
ColumnLimit: 120
92+
93+
94+

etc/scripts/format-code.bat

Lines changed: 0 additions & 20 deletions
This file was deleted.

etc/scripts/format-code.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/JoystickList/main.cpp

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,63 +29,63 @@
2929
#include <QJoysticks.h>
3030

3131
#ifdef Q_OS_WIN
32-
#ifdef main
33-
#undef main
34-
#endif
32+
# ifdef main
33+
# undef main
34+
# endif
3535
#endif
3636

3737
void configureDarkStyle()
3838
{
39-
qApp->setStyle (QStyleFactory::create ("Fusion"));
40-
QPalette darkPalette;
41-
darkPalette.setColor (QPalette::BrightText, Qt::red);
42-
darkPalette.setColor (QPalette::WindowText, Qt::white);
43-
darkPalette.setColor (QPalette::ToolTipBase, Qt::white);
44-
darkPalette.setColor (QPalette::ToolTipText, Qt::white);
45-
darkPalette.setColor (QPalette::Text, Qt::white);
46-
darkPalette.setColor (QPalette::ButtonText, Qt::white);
47-
darkPalette.setColor (QPalette::HighlightedText, Qt::black);
48-
darkPalette.setColor (QPalette::Window, QColor (53, 53, 53));
49-
darkPalette.setColor (QPalette::Base, QColor (25, 25, 25));
50-
darkPalette.setColor (QPalette::AlternateBase, QColor (53, 53, 53));
51-
darkPalette.setColor (QPalette::Button, QColor (53, 53, 53));
52-
darkPalette.setColor (QPalette::Link, QColor (42, 130, 218));
53-
darkPalette.setColor (QPalette::Highlight, QColor (42, 130, 218));
54-
qApp->setPalette (darkPalette);
39+
qApp->setStyle(QStyleFactory::create("Fusion"));
40+
QPalette darkPalette;
41+
darkPalette.setColor(QPalette::BrightText, Qt::red);
42+
darkPalette.setColor(QPalette::WindowText, Qt::white);
43+
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
44+
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
45+
darkPalette.setColor(QPalette::Text, Qt::white);
46+
darkPalette.setColor(QPalette::ButtonText, Qt::white);
47+
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
48+
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
49+
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
50+
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
51+
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
52+
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
53+
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
54+
qApp->setPalette(darkPalette);
5555
}
5656

57-
int main (int argc, char* argv[])
57+
int main(int argc, char *argv[])
5858
{
59-
QApplication app (argc, argv);
60-
QQmlApplicationEngine qmlEngine;
59+
QApplication app(argc, argv);
60+
QQmlApplicationEngine qmlEngine;
6161

62-
/*
63-
* Make the application use the Fusion style + dark palette
64-
*/
65-
configureDarkStyle();
62+
/*
63+
* Make the application use the Fusion style + dark palette
64+
*/
65+
configureDarkStyle();
6666

67-
/*
68-
* QJoysticks is single instance, you can use the "getInstance()" function
69-
* directly if you want, or you can create a pointer to it to make code
70-
* easier to read;
71-
*/
72-
QJoysticks* instance = QJoysticks::getInstance();
67+
/*
68+
* QJoysticks is single instance, you can use the "getInstance()" function
69+
* directly if you want, or you can create a pointer to it to make code
70+
* easier to read;
71+
*/
72+
QJoysticks *instance = QJoysticks::getInstance();
7373

74-
/* Enable the virtual joystick */
75-
instance->setVirtualJoystickRange (1);
76-
instance->setVirtualJoystickEnabled (true);
77-
instance->setVirtualJoystickAxisSensibility(0.7);
74+
/* Enable the virtual joystick */
75+
instance->setVirtualJoystickRange(1);
76+
instance->setVirtualJoystickEnabled(true);
77+
instance->setVirtualJoystickAxisSensibility(0.7);
7878

79-
/*
80-
* Register the QJoysticks with the QML engine, so that the QML interface
81-
* can easilly use it.
82-
*/
83-
qmlEngine.rootContext()->setContextProperty ("QJoysticks", instance);
79+
/*
80+
* Register the QJoysticks with the QML engine, so that the QML interface
81+
* can easilly use it.
82+
*/
83+
qmlEngine.rootContext()->setContextProperty("QJoysticks", instance);
8484

85-
/*
86-
* Load main.qml and run the application.
87-
*/
88-
qmlEngine.load (QUrl (QStringLiteral ("qrc:/main.qml")));
85+
/*
86+
* Load main.qml and run the application.
87+
*/
88+
qmlEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));
8989

90-
return app.exec();
90+
return app.exec();
9191
}

0 commit comments

Comments
 (0)