Skip to content

Commit

Permalink
Format code with clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-spataru committed Oct 11, 2020
1 parent 23931b8 commit 48e5143
Show file tree
Hide file tree
Showing 14 changed files with 1,091 additions and 1,012 deletions.
94 changes: 94 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright (C) 2016 Olivier Goffart <[email protected]>
#
# You may use this file under the terms of the 3-clause BSD license.
# See the file LICENSE from this package for details.

# This is the clang-format configuration style to be used by Qt,
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
# https://wiki.qt.io/Coding_Conventions

---
# Webkit style was loosely based on the Qt style
BasedOnStyle: WebKit

Standard: Cpp11

# Leave the line breaks up to the user.
# Note that this may be changed at some point in the future.
ColumnLimit: 0
# How much weight do extra characters after the line length limit have.
# PenaltyExcessCharacter: 4

# Disable reflow of qdoc comments: indentation rules are different.
# Translation comments are also excluded.
CommentPragmas: "^!|^:"

# We want a space between the type and the star for pointer types.
PointerBindsToType: false

# We use template< without space.
SpaceAfterTemplateKeyword: false

# We want to break before the operators, but not before a '='.
BreakBeforeBinaryOperators: All

# Braces are usually attached, but not after functions or class declarations.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false

BreakBeforeTernaryOperators: true

BreakConstructorInitializers: BeforeComma

# Indent initializers by 3 spaces
ConstructorInitializerIndentWidth: 3

# No indentation for namespaces.
NamespaceIndentation: None

# Horizontally align arguments after an open bracket.
# The coding style does not specify the following, but this is what gives
# results closest to the existing code.
AlignAfterOpenBracket: true
AlwaysBreakTemplateDeclarations: true

# Ideally we should also allow less short function in a single line, but
# clang-format does not handle that.
AllowShortFunctionsOnASingleLine: Inline

# The coding style specifies some include order categories, but also tells to
# separate categories with an empty line. It does not specify the order within
# the categories. Since the SortInclude feature of clang-format does not
# re-order includes separated by empty lines, the feature is not used.
SortIncludes: false

# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]

IndentCaseLabels: true

IndentPPDirectives: AfterHash

AlignAfterOpenBracket: Align

AccessModifierOffset: -3

IndentWidth: 3

#StatementMacros ['Q_OBJECT', 'Q_UNUSED']

ColumnLimit: 120



20 changes: 0 additions & 20 deletions etc/scripts/format-code.bat

This file was deleted.

2 changes: 0 additions & 2 deletions etc/scripts/format-code.sh

This file was deleted.

92 changes: 46 additions & 46 deletions examples/JoystickList/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,63 +29,63 @@
#include <QJoysticks.h>

#ifdef Q_OS_WIN
#ifdef main
#undef main
#endif
# ifdef main
# undef main
# endif
#endif

void configureDarkStyle()
{
qApp->setStyle (QStyleFactory::create ("Fusion"));
QPalette darkPalette;
darkPalette.setColor (QPalette::BrightText, Qt::red);
darkPalette.setColor (QPalette::WindowText, Qt::white);
darkPalette.setColor (QPalette::ToolTipBase, Qt::white);
darkPalette.setColor (QPalette::ToolTipText, Qt::white);
darkPalette.setColor (QPalette::Text, Qt::white);
darkPalette.setColor (QPalette::ButtonText, Qt::white);
darkPalette.setColor (QPalette::HighlightedText, Qt::black);
darkPalette.setColor (QPalette::Window, QColor (53, 53, 53));
darkPalette.setColor (QPalette::Base, QColor (25, 25, 25));
darkPalette.setColor (QPalette::AlternateBase, QColor (53, 53, 53));
darkPalette.setColor (QPalette::Button, QColor (53, 53, 53));
darkPalette.setColor (QPalette::Link, QColor (42, 130, 218));
darkPalette.setColor (QPalette::Highlight, QColor (42, 130, 218));
qApp->setPalette (darkPalette);
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
qApp->setPalette(darkPalette);
}

int main (int argc, char* argv[])
int main(int argc, char *argv[])
{
QApplication app (argc, argv);
QQmlApplicationEngine qmlEngine;
QApplication app(argc, argv);
QQmlApplicationEngine qmlEngine;

/*
* Make the application use the Fusion style + dark palette
*/
configureDarkStyle();
/*
* Make the application use the Fusion style + dark palette
*/
configureDarkStyle();

/*
* QJoysticks is single instance, you can use the "getInstance()" function
* directly if you want, or you can create a pointer to it to make code
* easier to read;
*/
QJoysticks* instance = QJoysticks::getInstance();
/*
* QJoysticks is single instance, you can use the "getInstance()" function
* directly if you want, or you can create a pointer to it to make code
* easier to read;
*/
QJoysticks *instance = QJoysticks::getInstance();

/* Enable the virtual joystick */
instance->setVirtualJoystickRange (1);
instance->setVirtualJoystickEnabled (true);
instance->setVirtualJoystickAxisSensibility(0.7);
/* Enable the virtual joystick */
instance->setVirtualJoystickRange(1);
instance->setVirtualJoystickEnabled(true);
instance->setVirtualJoystickAxisSensibility(0.7);

/*
* Register the QJoysticks with the QML engine, so that the QML interface
* can easilly use it.
*/
qmlEngine.rootContext()->setContextProperty ("QJoysticks", instance);
/*
* Register the QJoysticks with the QML engine, so that the QML interface
* can easilly use it.
*/
qmlEngine.rootContext()->setContextProperty("QJoysticks", instance);

/*
* Load main.qml and run the application.
*/
qmlEngine.load (QUrl (QStringLiteral ("qrc:/main.qml")));
/*
* Load main.qml and run the application.
*/
qmlEngine.load(QUrl(QStringLiteral("qrc:/main.qml")));

return app.exec();
return app.exec();
}
Loading

0 comments on commit 48e5143

Please sign in to comment.