From 0a92cb82db28f70b9a63360d6bdffbea3fc94c79 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Fri, 3 Aug 2018 08:15:28 +0200 Subject: [PATCH] playing with clang-format --- .clang-format | 116 ++++++ examples/automotive/ButtonBar.cpp | 10 +- examples/automotive/ButtonBar.h | 4 +- examples/automotive/DefaultSkin.cpp | 40 +- examples/automotive/DefaultSkin.h | 4 +- examples/automotive/MainWindow.cpp | 2 +- examples/automotive/MainWindow.h | 4 +- examples/automotive/OtherSkin.cpp | 37 +- examples/automotive/OtherSkin.h | 4 +- examples/automotive/SkinFactory.h | 4 +- examples/automotive/SoundControl.cpp | 99 +++-- examples/automotive/SoundControl.h | 2 +- examples/automotive/Speedometer.cpp | 4 +- examples/automotive/Speedometer.h | 4 +- examples/automotive/SpeedometerDisplay.cpp | 20 +- examples/automotive/SpeedometerDisplay.h | 6 +- examples/automotive/SpeedometerSkinlet.cpp | 72 ++-- examples/automotive/SpeedometerSkinlet.h | 10 +- examples/automotive/main.cpp | 2 +- examples/boxes/Box.cpp | 19 +- examples/boxes/Box.h | 2 +- examples/boxes/Palette.cpp | 9 +- examples/boxes/Palette.h | 5 +- examples/boxes/main.cpp | 45 +- examples/buttons/main.cpp | 4 +- examples/colorswitch/Theme.cpp | 28 +- examples/colorswitch/Theme.h | 8 +- examples/colorswitch/main.cpp | 4 +- examples/desktop/main.cpp | 24 +- examples/dialogbuttons/Window.cpp | 16 +- examples/dialogbuttons/Window.h | 10 +- examples/frames/Frame.cpp | 24 +- examples/frames/Frame.h | 8 +- examples/frames/main.cpp | 2 +- examples/gbenchmark/Benchmark.cpp | 72 ++-- examples/gbenchmark/main.cpp | 23 +- examples/glabels/main.cpp | 2 +- examples/layouts/ButtonBox.cpp | 8 +- examples/layouts/ButtonBox.h | 2 +- examples/layouts/DynamicConstraintsPage.cpp | 30 +- examples/layouts/DynamicConstraintsPage.h | 2 +- examples/layouts/FlowLayoutPage.cpp | 16 +- examples/layouts/FlowLayoutPage.h | 2 +- examples/layouts/LinearLayoutPage.cpp | 21 +- examples/layouts/LinearLayoutPage.h | 2 +- examples/layouts/StackLayoutPage.cpp | 20 +- examples/layouts/StackLayoutPage.h | 2 +- examples/layouts/TestRectangle.cpp | 4 +- examples/layouts/TestRectangle.h | 2 +- examples/layouts/main.cpp | 14 +- examples/listbox/main.cpp | 9 +- examples/messagebox/main.cpp | 24 +- examples/messageboxQml/main.cpp | 2 +- examples/qvgviewer/MainWindow.cpp | 22 +- examples/qvgviewer/MainWindow.h | 6 +- examples/sliders/Slider.cpp | 8 +- examples/sliders/Slider.h | 2 +- examples/sliders/SliderSkinlet.cpp | 47 ++- examples/sliders/SliderSkinlet.h | 10 +- examples/sliders/main.cpp | 38 +- examples/tabview/main.cpp | 26 +- examples/thumbnails/main.cpp | 48 +-- examples/tlabels/main.cpp | 16 +- inputcontext/QskHunspellTextPredictor.cpp | 14 +- inputcontext/QskHunspellTextPredictor.h | 6 +- inputcontext/QskInputContextPlugin.cpp | 26 +- inputcontext/QskPinyinTextPredictor.cpp | 21 +- inputcontext/QskPinyinTextPredictor.h | 6 +- playground/images/Image.cpp | 22 +- playground/images/Image.h | 10 +- playground/images/main.cpp | 4 +- playground/inputpanel/main.cpp | 45 +- playground/invoker/Callback.cpp | 26 +- playground/invoker/Callback.h | 4 +- playground/invoker/Invoker.cpp | 28 +- playground/invoker/Invoker.h | 4 +- playground/invoker/main.cpp | 25 +- skins/material/QskMaterialSkin.cpp | 38 +- skins/material/QskMaterialSkin.h | 4 +- skins/material/QskMaterialSkinFactory.cpp | 4 +- skins/material/QskMaterialSkinFactory.h | 2 +- skins/squiek/QskSquiekSkin.cpp | 62 +-- skins/squiek/QskSquiekSkin.h | 4 +- skins/squiek/QskSquiekSkinFactory.cpp | 4 +- skins/squiek/QskSquiekSkinFactory.h | 2 +- src/common/QskAspect.cpp | 18 +- src/common/QskAspect.h | 54 +-- src/common/QskBoxBorderColors.cpp | 44 +- src/common/QskBoxBorderColors.h | 13 +- src/common/QskBoxBorderMetrics.cpp | 6 +- src/common/QskBoxBorderMetrics.h | 46 ++- src/common/QskBoxShapeMetrics.cpp | 43 +- src/common/QskBoxShapeMetrics.h | 47 ++- src/common/QskCorner.cpp | 2 +- src/common/QskCorner.h | 4 +- src/common/QskFunctions.cpp | 18 +- src/common/QskFunctions.h | 3 +- src/common/QskGlobal.h | 15 +- src/common/QskGradient.cpp | 98 +++-- src/common/QskGradient.h | 18 +- src/common/QskMargins.cpp | 3 +- src/common/QskMargins.h | 27 +- src/common/QskMetaFunction.cpp | 48 +-- src/common/QskMetaFunction.h | 12 +- src/common/QskMetaInvokable.cpp | 155 ++++--- src/common/QskMetaInvokable.h | 10 +- src/common/QskModule.cpp | 95 ++--- src/common/QskObjectCounter.cpp | 53 ++- src/common/QskObjectCounter.h | 8 +- src/common/QskSizePolicy.h | 29 +- src/common/QskTextColors.cpp | 17 +- src/common/QskTextColors.h | 11 +- src/common/QskTextOptions.cpp | 34 +- src/common/QskTextOptions.h | 8 +- src/controls/QskAbstractButton.cpp | 22 +- src/controls/QskAbstractButton.h | 25 +- src/controls/QskAnimationHint.h | 14 +- src/controls/QskAnimator.cpp | 48 +-- src/controls/QskAnimator.h | 17 +- src/controls/QskBox.cpp | 14 +- src/controls/QskBox.h | 2 +- src/controls/QskBoxSkinlet.cpp | 12 +- src/controls/QskBoxSkinlet.h | 3 +- src/controls/QskControl.cpp | 131 +++--- src/controls/QskControl.h | 25 +- src/controls/QskDirtyItemFilter.cpp | 21 +- src/controls/QskDirtyItemFilter.h | 4 +- src/controls/QskEvent.cpp | 44 +- src/controls/QskEvent.h | 21 +- src/controls/QskFlickAnimator.cpp | 34 +- src/controls/QskFlickAnimator.h | 12 +- src/controls/QskFocusIndicator.cpp | 14 +- src/controls/QskFocusIndicator.h | 6 +- src/controls/QskFocusIndicatorSkinlet.cpp | 14 +- src/controls/QskFocusIndicatorSkinlet.h | 7 +- src/controls/QskGesture.cpp | 32 +- src/controls/QskGesture.h | 22 +- src/controls/QskGestureRecognizer.cpp | 55 +-- src/controls/QskGestureRecognizer.h | 6 +- src/controls/QskGraphicLabel.cpp | 38 +- src/controls/QskGraphicLabel.h | 11 +- src/controls/QskGraphicLabelSkinlet.cpp | 14 +- src/controls/QskGraphicLabelSkinlet.h | 11 +- src/controls/QskHintAnimator.cpp | 20 +- src/controls/QskHintAnimator.h | 10 +- src/controls/QskInputGrabber.cpp | 30 +- src/controls/QskInputGrabber.h | 10 +- src/controls/QskListView.cpp | 20 +- src/controls/QskListView.h | 10 +- src/controls/QskListViewSkinlet.cpp | 27 +- src/controls/QskListViewSkinlet.h | 6 +- src/controls/QskObjectTree.cpp | 8 +- src/controls/QskObjectTree.h | 23 +- src/controls/QskPageIndicator.cpp | 25 +- src/controls/QskPageIndicator.h | 19 +- src/controls/QskPageIndicatorSkinlet.cpp | 25 +- src/controls/QskPageIndicatorSkinlet.h | 10 +- src/controls/QskPanGestureRecognizer.cpp | 50 +-- src/controls/QskPanGestureRecognizer.h | 4 +- src/controls/QskPopup.cpp | 48 +-- src/controls/QskPopup.h | 14 +- src/controls/QskPopupSkinlet.cpp | 10 +- src/controls/QskPopupSkinlet.h | 6 +- src/controls/QskPushButton.cpp | 32 +- src/controls/QskPushButton.h | 10 +- src/controls/QskPushButtonSkinlet.cpp | 10 +- src/controls/QskPushButtonSkinlet.h | 11 +- src/controls/QskQuick.cpp | 20 +- src/controls/QskRangeControl.cpp | 26 +- src/controls/QskRangeControl.h | 10 +- src/controls/QskRgbValue.cpp | 18 +- src/controls/QskRgbValue.h | 6 +- src/controls/QskScrollArea.cpp | 46 +-- src/controls/QskScrollArea.h | 10 +- src/controls/QskScrollView.cpp | 53 +-- src/controls/QskScrollView.h | 13 +- src/controls/QskScrollViewSkinlet.cpp | 10 +- src/controls/QskScrollViewSkinlet.h | 10 +- src/controls/QskSeparator.cpp | 10 +- src/controls/QskSeparator.h | 6 +- src/controls/QskSeparatorSkinlet.cpp | 14 +- src/controls/QskSeparatorSkinlet.h | 7 +- src/controls/QskSetup.cpp | 37 +- src/controls/QskSetup.h | 14 +- src/controls/QskShortcut.cpp | 38 +- src/controls/QskShortcut.h | 12 +- src/controls/QskShortcutMap.cpp | 24 +- src/controls/QskShortcutMap.h | 4 +- src/controls/QskSimpleListBox.cpp | 35 +- src/controls/QskSimpleListBox.h | 8 +- src/controls/QskSkin.cpp | 32 +- src/controls/QskSkin.h | 15 +- src/controls/QskSkinFactory.cpp | 4 +- src/controls/QskSkinFactory.h | 2 +- src/controls/QskSkinHintTable.cpp | 20 +- src/controls/QskSkinHintTable.h | 34 +- src/controls/QskSkinManager.cpp | 58 +-- src/controls/QskSkinManager.h | 6 +- src/controls/QskSkinTransition.cpp | 72 ++-- src/controls/QskSkinTransition.h | 10 +- src/controls/QskSkinlet.cpp | 46 +-- src/controls/QskSkinlet.h | 8 +- src/controls/QskSkinnable.cpp | 51 ++- src/controls/QskSkinnable.h | 15 +- src/controls/QskSlider.cpp | 28 +- src/controls/QskSlider.h | 8 +- src/controls/QskSliderSkinlet.cpp | 20 +- src/controls/QskSliderSkinlet.h | 6 +- src/controls/QskStatusIndicator.cpp | 34 +- src/controls/QskStatusIndicator.h | 10 +- src/controls/QskStatusIndicatorSkinlet.cpp | 14 +- src/controls/QskStatusIndicatorSkinlet.h | 11 +- src/controls/QskSubWindow.cpp | 12 +- src/controls/QskSubWindow.h | 12 +- src/controls/QskSubWindowArea.cpp | 33 +- src/controls/QskSubWindowArea.h | 6 +- src/controls/QskSubWindowAreaSkinlet.cpp | 12 +- src/controls/QskSubWindowAreaSkinlet.h | 7 +- src/controls/QskSubWindowSkinlet.cpp | 14 +- src/controls/QskSubWindowSkinlet.h | 12 +- src/controls/QskTabBar.cpp | 20 +- src/controls/QskTabBar.h | 10 +- src/controls/QskTabButton.cpp | 20 +- src/controls/QskTabButton.h | 9 +- src/controls/QskTabButtonSkinlet.cpp | 6 +- src/controls/QskTabButtonSkinlet.h | 12 +- src/controls/QskTabView.cpp | 30 +- src/controls/QskTabView.h | 11 +- src/controls/QskTabViewSkinlet.cpp | 12 +- src/controls/QskTabViewSkinlet.h | 10 +- src/controls/QskTextInput.cpp | 54 +-- src/controls/QskTextInput.h | 24 +- src/controls/QskTextInputSkinlet.cpp | 6 +- src/controls/QskTextInputSkinlet.h | 5 +- src/controls/QskTextLabel.cpp | 24 +- src/controls/QskTextLabel.h | 10 +- src/controls/QskTextLabelSkinlet.cpp | 14 +- src/controls/QskTextLabelSkinlet.h | 4 +- src/controls/QskVariantAnimator.cpp | 39 +- src/controls/QskVariantAnimator.h | 8 +- src/controls/QskWindow.cpp | 45 +- src/controls/QskWindow.h | 14 +- src/dialogs/QskDialog.cpp | 53 ++- src/dialogs/QskDialog.h | 27 +- src/dialogs/QskDialogButton.cpp | 12 +- src/dialogs/QskDialogButton.h | 11 +- src/dialogs/QskDialogButtonBox.cpp | 69 ++-- src/dialogs/QskDialogButtonBox.h | 14 +- src/dialogs/QskDialogSubWindow.cpp | 6 +- src/dialogs/QskDialogSubWindow.h | 13 +- src/dialogs/QskDialogWindow.cpp | 18 +- src/dialogs/QskDialogWindow.h | 14 +- src/dialogs/QskInputSubWindow.cpp | 44 +- src/dialogs/QskInputSubWindow.h | 11 +- src/dialogs/QskInputWindow.cpp | 12 +- src/dialogs/QskInputWindow.h | 11 +- src/dialogs/QskMessageSubWindow.cpp | 4 +- src/dialogs/QskMessageSubWindow.h | 2 +- src/dialogs/QskMessageWindow.cpp | 4 +- src/dialogs/QskMessageWindow.h | 2 +- src/dialogs/QskSelectionSubWindow.cpp | 20 +- src/dialogs/QskSelectionSubWindow.h | 6 +- src/dialogs/QskSelectionWindow.cpp | 4 +- src/dialogs/QskSelectionWindow.h | 6 +- src/graphic/QskColorFilter.cpp | 25 +- src/graphic/QskColorFilter.h | 12 +- src/graphic/QskGraphic.cpp | 111 ++--- src/graphic/QskGraphic.h | 20 +- src/graphic/QskGraphicIO.cpp | 24 +- src/graphic/QskGraphicImageProvider.cpp | 27 +- src/graphic/QskGraphicImageProvider.h | 4 +- src/graphic/QskGraphicPaintEngine.cpp | 27 +- src/graphic/QskGraphicPaintEngine.h | 4 +- src/graphic/QskGraphicProvider.cpp | 26 +- src/graphic/QskGraphicProvider.h | 6 +- src/graphic/QskGraphicProviderMap.cpp | 8 +- src/graphic/QskGraphicProviderMap.h | 4 +- src/graphic/QskGraphicTextureFactory.cpp | 12 +- src/graphic/QskGraphicTextureFactory.h | 13 +- src/graphic/QskPainterCommand.cpp | 43 +- src/graphic/QskPainterCommand.h | 22 +- src/graphic/QskStandardSymbol.cpp | 10 +- src/graphic/QskStandardSymbol.h | 2 +- src/inputpanel/QskInputContext.cpp | 50 ++- src/inputpanel/QskInputContext.h | 14 +- src/inputpanel/QskInputPanel.cpp | 29 +- src/inputpanel/QskInputPanel.h | 13 +- src/inputpanel/QskInputPanelBox.cpp | 41 +- src/inputpanel/QskInputPanelBox.h | 10 +- src/inputpanel/QskInputPredictionBar.cpp | 36 +- src/inputpanel/QskInputPredictionBar.h | 8 +- src/inputpanel/QskTextPredictor.cpp | 9 +- src/inputpanel/QskTextPredictor.h | 8 +- src/inputpanel/QskVirtualKeyboard.cpp | 67 +-- src/inputpanel/QskVirtualKeyboard.h | 8 +- src/layouts/QskGridBox.cpp | 29 +- src/layouts/QskGridBox.h | 8 +- src/layouts/QskIndexedLayoutBox.cpp | 22 +- src/layouts/QskIndexedLayoutBox.h | 15 +- src/layouts/QskLayout.cpp | 20 +- src/layouts/QskLayout.h | 9 +- src/layouts/QskLayoutConstraint.cpp | 10 +- src/layouts/QskLayoutEngine.cpp | 17 +- src/layouts/QskLayoutEngine.h | 3 +- src/layouts/QskLayoutItem.cpp | 43 +- src/layouts/QskLayoutItem.h | 4 +- src/layouts/QskLinearBox.cpp | 38 +- src/layouts/QskLinearBox.h | 10 +- src/layouts/QskStackBox.cpp | 23 +- src/layouts/QskStackBox.h | 10 +- src/layouts/QskStackBoxAnimator.cpp | 36 +- src/layouts/QskStackBoxAnimator.h | 20 +- src/nodes/QskBoxClipNode.cpp | 12 +- src/nodes/QskBoxClipNode.h | 4 +- src/nodes/QskBoxNode.cpp | 35 +- src/nodes/QskBoxNode.h | 6 +- src/nodes/QskBoxRenderer.h | 46 ++- src/nodes/QskBoxRendererColorMap.h | 155 +++---- src/nodes/QskBoxRendererDEllipse.cpp | 121 +++--- src/nodes/QskBoxRendererEllipse.cpp | 434 ++++++++++---------- src/nodes/QskBoxRendererRect.cpp | 74 ++-- src/nodes/QskGraphicNode.cpp | 19 +- src/nodes/QskGraphicNode.h | 8 +- src/nodes/QskPlainTextRenderer.cpp | 20 +- src/nodes/QskPlainTextRenderer.h | 16 +- src/nodes/QskRichTextRenderer.cpp | 35 +- src/nodes/QskRichTextRenderer.h | 14 +- src/nodes/QskTextNode.cpp | 18 +- src/nodes/QskTextNode.h | 6 +- src/nodes/QskTextRenderer.cpp | 28 +- src/nodes/QskTextRenderer.h | 13 +- src/nodes/QskTextureNode.cpp | 78 ++-- src/nodes/QskTextureNode.h | 8 +- src/nodes/QskVertex.cpp | 1 - src/nodes/QskVertex.h | 39 +- 335 files changed, 3834 insertions(+), 3708 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..e33eb0e16 --- /dev/null +++ b/.clang-format @@ -0,0 +1,116 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +#AllowShortFunctionsOnASingleLine: InlineOnly +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: false + BeforeCatch: true + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 100 +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 +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +RawStringFormats: + - Delimiter: pb + Language: TextProto + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: true +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: true +SpacesInParentheses: true +SpacesInSquareBrackets: true +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... + diff --git a/examples/automotive/ButtonBar.cpp b/examples/automotive/ButtonBar.cpp index efcacac44..5f9ba8fd3 100644 --- a/examples/automotive/ButtonBar.cpp +++ b/examples/automotive/ButtonBar.cpp @@ -8,9 +8,9 @@ QSK_SUBCONTROL( ButtonBar, Indicator ) class IndicatorLabel final : public QskGraphicLabel { -public: - IndicatorLabel( QQuickItem* parentItem = nullptr ): - QskGraphicLabel( parentItem ) + public: + IndicatorLabel( QQuickItem* parentItem = nullptr ) + : QskGraphicLabel( parentItem ) { // so the skins are able to colorize them setGraphicRole( SkinFactory::Indicator ); @@ -28,8 +28,8 @@ class IndicatorLabel final : public QskGraphicLabel } }; -ButtonBar::ButtonBar( QQuickItem* parentItem ): - QskLinearBox( parentItem ) +ButtonBar::ButtonBar( QQuickItem* parentItem ) + : QskLinearBox( parentItem ) { QColor c( Qt::black ); c.setAlphaF( 0.5 ); diff --git a/examples/automotive/ButtonBar.h b/examples/automotive/ButtonBar.h index 207cd5f84..45b65a421 100644 --- a/examples/automotive/ButtonBar.h +++ b/examples/automotive/ButtonBar.h @@ -5,13 +5,13 @@ class ButtonBar : public QskLinearBox { -public: + public: QSK_SUBCONTROLS( Indicator ) ButtonBar( QQuickItem* = nullptr ); void addIndicator( const char* name ); -protected: + protected: QSizeF contentsSizeHint() const override; }; diff --git a/examples/automotive/DefaultSkin.cpp b/examples/automotive/DefaultSkin.cpp index 406420dfd..67e78b009 100644 --- a/examples/automotive/DefaultSkin.cpp +++ b/examples/automotive/DefaultSkin.cpp @@ -1,29 +1,29 @@ #include "DefaultSkin.h" +#include "ButtonBar.h" #include "SkinFactory.h" #include "SoundControl.h" -#include "ButtonBar.h" #include "Speedometer.h" #include "SpeedometerSkinlet.h" #include +#include +#include +#include #include +#include #include +#include #include #include #include -#include -#include -#include -#include -#include #include class Transition final : public QskSkinTransition { -protected: + protected: void updateSkin( QskSkin*, QskSkin* newSkin ) override { DefaultSkin* skin = static_cast< DefaultSkin* >( newSkin ); @@ -33,8 +33,7 @@ class Transition final : public QskSkinTransition class Palette { -public: - + public: Palette( DefaultSkin::Scheme scheme = DefaultSkin::Daylight ) { if ( scheme == DefaultSkin::Daylight ) @@ -62,11 +61,10 @@ class Palette QColor color3; QColor color4; QColor color5; - }; -namespace { - +namespace +{ static inline QFont qskFont( qreal pointSize ) { QFont font( "Roboto" ); @@ -76,11 +74,11 @@ namespace { } // namespace -DefaultSkin::DefaultSkin( const QString& name, QObject* parent ): - QskSkin( parent ), - m_name( name ), - m_palette( new Palette ), - m_scheme( Daylight ) +DefaultSkin::DefaultSkin( const QString& name, QObject* parent ) + : QskSkin( parent ) + , m_name( name ) + , m_palette( new Palette ) + , m_scheme( Daylight ) { setObjectName( "DefaultSkin" ); declareSkinlet< Speedometer, SpeedometerSkinlet >(); @@ -155,9 +153,9 @@ void DefaultSkin::initHints() setBoxBorderMetrics( Speedometer::NeedleHead, 2 ); setMetric( Speedometer::NeedleHead | QskAspect::Size, 15 ); - setGradient( Speedometer::NeedleHead, QskGradient( QskGradient::Diagonal, - m_palette->color2, m_palette->color1 ) ); -// setBoxBorderColors( Speedometer::NeedleHead, m_palette->color4 ); + setGradient( Speedometer::NeedleHead, + QskGradient( QskGradient::Diagonal, m_palette->color2, m_palette->color1 ) ); + // setBoxBorderColors( Speedometer::NeedleHead, m_palette->color4 ); setMetric( Speedometer::Needle | QskAspect::MinimumWidth, 2 ); setMetric( Speedometer::Needle | QskAspect::Margin, 10 ); @@ -170,7 +168,6 @@ void DefaultSkin::initHints() setColor( Speedometer::Labels, m_palette->color4 ); setFontRole( Speedometer::Labels, QskSkin::SmallFont ); - // handle expanding, when being pressed for ( auto state : { QskAspect::NoState, QskSlider::Pressed } ) { @@ -217,4 +214,3 @@ void DefaultSkin::resetHints() m_palette = new Palette( m_scheme ); initHints(); } - diff --git a/examples/automotive/DefaultSkin.h b/examples/automotive/DefaultSkin.h index af043b900..8bda8bb04 100644 --- a/examples/automotive/DefaultSkin.h +++ b/examples/automotive/DefaultSkin.h @@ -7,7 +7,7 @@ class Palette; class DefaultSkin : public QskSkin { -public: + public: DefaultSkin( const QString& name, QObject* parent = nullptr ); ~DefaultSkin() override; @@ -20,7 +20,7 @@ class DefaultSkin : public QskSkin Nighttime }; -private: + private: void initHints(); QString m_name; diff --git a/examples/automotive/MainWindow.cpp b/examples/automotive/MainWindow.cpp index f648a107f..397c77109 100644 --- a/examples/automotive/MainWindow.cpp +++ b/examples/automotive/MainWindow.cpp @@ -48,7 +48,7 @@ QQuickItem* MainWindow::headerBar() const header->addIndicator( "location" ); header->addIndicator( "phone" ); - (void) new QskTextLabel( QDate::currentDate().toString(), header ); + ( void ) new QskTextLabel( QDate::currentDate().toString(), header ); header->addIndicator( "user" ); header->addIndicator( "bookmark" ); diff --git a/examples/automotive/MainWindow.h b/examples/automotive/MainWindow.h index de1166de9..f5896f7a8 100644 --- a/examples/automotive/MainWindow.h +++ b/examples/automotive/MainWindow.h @@ -7,10 +7,10 @@ class QQuickItem; class MainWindow : public QskWindow { -public: + public: MainWindow(); -private: + private: QQuickItem* headerBar() const; QQuickItem* mainContent() const; QQuickItem* footerBar() const; diff --git a/examples/automotive/OtherSkin.cpp b/examples/automotive/OtherSkin.cpp index 3512d1d0e..c6c9bb298 100644 --- a/examples/automotive/OtherSkin.cpp +++ b/examples/automotive/OtherSkin.cpp @@ -1,30 +1,29 @@ #include "OtherSkin.h" #include "SkinFactory.h" -#include "SoundControl.h" #include "ButtonBar.h" +#include "SoundControl.h" #include "Speedometer.h" #include "SpeedometerSkinlet.h" #include +#include +#include +#include #include +#include #include +#include #include #include #include -#include -#include -#include -#include -#include #include class Palette { -public: - + public: Palette() { // grey-blue-yellow: @@ -40,24 +39,22 @@ class Palette QColor color3; QColor color4; QColor color5; - }; -namespace { - +namespace +{ static inline QFont qskFont( qreal pointSize ) { QFont font( "Roboto" ); font.setPointSizeF( pointSize / qskDpiScaled( 1.0 ) ); return font; } - } -OtherSkin::OtherSkin( const QString& name, QObject* parent ): - QskSkin( parent ), - m_name( name ), - m_palette( new Palette ) +OtherSkin::OtherSkin( const QString& name, QObject* parent ) + : QskSkin( parent ) + , m_name( name ) + , m_palette( new Palette ) { setObjectName( "OtherSkin" ); declareSkinlet< Speedometer, SpeedometerSkinlet >(); @@ -113,8 +110,8 @@ void OtherSkin::initHints() setGradient( SoundControl::Overlay, overlayColor ); // -- slider control buttons - setBoxBorderMetrics( SoundControl::SliderControl, 0 ); - setBoxShape( SoundControl::SliderControl, 4 ); + setBoxBorderMetrics( SoundControl::SliderControl, 0 ); + setBoxShape( SoundControl::SliderControl, 4 ); setGradient( SoundControl::SliderControl, m_palette->color1 ); setGradient( SoundControl::SliderControl | QskPushButton::Pressed, m_palette->color2 ); @@ -144,8 +141,8 @@ void OtherSkin::initHints() // -- speedometers setBoxBorderMetrics( Speedometer::Panel, 5 ); - setGradient( Speedometer::Panel, QskGradient( QskGradient::Vertical, - m_palette->color2, m_palette->color4 ) ); + setGradient( Speedometer::Panel, + QskGradient( QskGradient::Vertical, m_palette->color2, m_palette->color4 ) ); setBoxBorderColors( Speedometer::Panel, m_palette->color3 ); setBoxBorderMetrics( Speedometer::NeedleHead, 5 ); diff --git a/examples/automotive/OtherSkin.h b/examples/automotive/OtherSkin.h index 318d8adeb..7b8b6fc8a 100644 --- a/examples/automotive/OtherSkin.h +++ b/examples/automotive/OtherSkin.h @@ -7,11 +7,11 @@ class Palette; class OtherSkin : public QskSkin { -public: + public: OtherSkin( const QString& name, QObject* parent = nullptr ); ~OtherSkin() override; -private: + private: void initHints(); void initGraphicFilters(); diff --git a/examples/automotive/SkinFactory.h b/examples/automotive/SkinFactory.h index d796ed5b8..fd5437a2c 100644 --- a/examples/automotive/SkinFactory.h +++ b/examples/automotive/SkinFactory.h @@ -7,7 +7,7 @@ class SkinFactory : public QskSkinFactory { Q_OBJECT -public: + public: enum GraphicRoles { // to be visisble on a button @@ -23,7 +23,7 @@ class SkinFactory : public QskSkinFactory QStringList skinNames() const override; QskSkin* createSkin( const QString& skinName ) override; -public Q_SLOTS: + public Q_SLOTS: void rotateSkin(); void toggleScheme(); }; diff --git a/examples/automotive/SoundControl.cpp b/examples/automotive/SoundControl.cpp index 9880fc56f..60051ddec 100644 --- a/examples/automotive/SoundControl.cpp +++ b/examples/automotive/SoundControl.cpp @@ -1,17 +1,17 @@ #include "SoundControl.h" #include "SkinFactory.h" +#include #include -#include #include +#include #include #include +#include #include +#include #include #include -#include -#include -#include QSK_SUBCONTROL( SoundControl, Overlay ) QSK_SUBCONTROL( SoundControl, CrossHair ) @@ -22,9 +22,9 @@ QSK_SUBCONTROL( SoundControl, SliderControl ) class VehicleLabel final : public QskGraphicLabel { -public: - VehicleLabel( QQuickItem* parentItem = nullptr ): - QskGraphicLabel( parentItem ) + public: + VehicleLabel( QQuickItem* parentItem = nullptr ) + : QskGraphicLabel( parentItem ) { setGraphic( QskGraphicIO::read( QString( ":/qvg/car.qvg" ) ) ); } @@ -43,9 +43,9 @@ class VehicleLabel final : public QskGraphicLabel class CrossHairLine final : public QskBox { -public: - CrossHairLine( QQuickItem* parent ): - QskBox( parent ) + public: + CrossHairLine( QQuickItem* parent ) + : QskBox( parent ) { } @@ -61,9 +61,9 @@ class CrossHairLine final : public QskBox class BalanceFadeMarker final : public QskBox { -public: - BalanceFadeMarker( QQuickItem* parent ): - QskBox( parent ) + public: + BalanceFadeMarker( QQuickItem* parent ) + : QskBox( parent ) { } @@ -79,10 +79,10 @@ class BalanceFadeMarker final : public QskBox class MarkerControlButton final : public QskPushButton { -public: - MarkerControlButton( Qsk::Direction direction, QQuickItem* parentItem = nullptr ): - QskPushButton( parentItem ), - m_direction( direction ) + public: + MarkerControlButton( Qsk::Direction direction, QQuickItem* parentItem = nullptr ) + : QskPushButton( parentItem ) + , m_direction( direction ) { const char* svgList[] = { "right", "left", "down", "up" }; @@ -97,7 +97,7 @@ class MarkerControlButton final : public QskPushButton { const qreal off = 5.0; - switch( m_direction ) + switch ( m_direction ) { case Qsk::LeftToRight: return QPointF( off, 0.0 ); @@ -126,7 +126,7 @@ class MarkerControlButton final : public QskPushButton return subControl; } -protected: + protected: QSizeF contentsSizeHint() const override { const qreal dim = 100; @@ -137,15 +137,15 @@ class MarkerControlButton final : public QskPushButton return QSizeF( dim, 0.5 * dim ); } -private: + private: const Qsk::Direction m_direction; }; class ControlButton final : public QskPushButton { -public: - ControlButton( const char symbol, QQuickItem* parentItem = nullptr ): - QskPushButton( parentItem ) + public: + ControlButton( const char symbol, QQuickItem* parentItem = nullptr ) + : QskPushButton( parentItem ) { setText( QChar( symbol ) ); setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); @@ -171,10 +171,10 @@ class ControlButton final : public QskPushButton class StackedControl final : public QskControl { -public: - StackedControl( QQuickItem* parent = nullptr ): - QskControl( parent ), - m_offset( 0.0, 0.0 ) + public: + StackedControl( QQuickItem* parent = nullptr ) + : QskControl( parent ) + , m_offset( 0.0, 0.0 ) { setPolishOnResize( true ); // we have t re-layout the crosshair setSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Expanding ); @@ -185,7 +185,7 @@ class StackedControl final : public QskControl auto verticalCarRectangle = new CrossHairLine( this ); verticalCarRectangle->setObjectName( "verticalBar" ); - (void) new VehicleLabel( this ); + ( void ) new VehicleLabel( this ); auto marker = new BalanceFadeMarker( this ); marker->setObjectName( "marker" ); @@ -202,7 +202,7 @@ class StackedControl final : public QskControl polish(); } -protected: + protected: void updateLayout() override { const QRectF cr = contentsRect(); @@ -238,15 +238,15 @@ class StackedControl final : public QskControl } } -private: + private: QPointF m_offset; }; class SectionTitleBar final : public QskLinearBox { -public: - SectionTitleBar( const char* title, QQuickItem* parentItem = nullptr ): - QskLinearBox( Qt::Horizontal, parentItem ) + public: + SectionTitleBar( const char* title, QQuickItem* parentItem = nullptr ) + : QskLinearBox( Qt::Horizontal, parentItem ) { setSpacing( 10 ); @@ -264,9 +264,9 @@ class SectionTitleBar final : public QskLinearBox class SliderBox final : public QskLinearBox { -public: - SliderBox( const char* title, qreal min, qreal max, QQuickItem* parentItem = nullptr ): - QskLinearBox( Qt::Vertical, parentItem ) + public: + SliderBox( const char* title, qreal min, qreal max, QQuickItem* parentItem = nullptr ) + : QskLinearBox( Qt::Vertical, parentItem ) { auto label = new QskTextLabel( title ); m_numberLabel = new QskTextLabel(); @@ -307,7 +307,7 @@ class SliderBox final : public QskLinearBox this, &SliderBox::setValue ); } -public Q_SLOTS: + public Q_SLOTS: void setValue( qreal value ) { m_slider->setValue( value ); @@ -318,7 +318,7 @@ public Q_SLOTS: m_numberLabel->setText( txt ); } -private: + private: void increment( qreal offset ) { setValue( m_slider->value() + offset ); @@ -330,9 +330,9 @@ public Q_SLOTS: class ToneControlBox final : public QskLinearBox { -public: - ToneControlBox( QQuickItem* parentItem = nullptr ): - QskLinearBox( Qt::Horizontal, parentItem ) + public: + ToneControlBox( QQuickItem* parentItem = nullptr ) + : QskLinearBox( Qt::Horizontal, parentItem ) { auto bassControl = new SliderBox( "Bass", 0.0, 40.0, this ); auto treebleControl = new SliderBox( "Treeble", 0.0, 40.0, this ); @@ -346,13 +346,13 @@ class ToneControlBox final : public QskLinearBox class BalanceFadeControlBox final : public QskGridBox { -public: - BalanceFadeControlBox( QQuickItem* parentItem = nullptr ): - QskGridBox( parentItem ) + public: + BalanceFadeControlBox( QQuickItem* parentItem = nullptr ) + : QskGridBox( parentItem ) { - MarkerControlButton* buttons[4]; + MarkerControlButton* buttons[ 4 ]; for ( int i = 0; i < 4; i++ ) - buttons[i] = new MarkerControlButton( static_cast< Qsk::Direction >( i ) ); + buttons[ i ] = new MarkerControlButton( static_cast< Qsk::Direction >( i ) ); m_carControl = new StackedControl(); @@ -365,7 +365,7 @@ class BalanceFadeControlBox final : public QskGridBox for ( int i = 0; i < 4; i++ ) { - const auto button = buttons[i]; + const auto button = buttons[ i ]; setAlignment( button, Qt::AlignCenter ); @@ -382,8 +382,8 @@ class BalanceFadeControlBox final : public QskGridBox StackedControl* m_carControl; }; -SoundControl::SoundControl( QQuickItem* parent ): - QskBox( parent ) +SoundControl::SoundControl( QQuickItem* parent ) + : QskBox( parent ) { setAutoLayoutChildren( true ); @@ -409,4 +409,3 @@ QskAspect::Subcontrol SoundControl::effectiveSubcontrol( return subControl; } - diff --git a/examples/automotive/SoundControl.h b/examples/automotive/SoundControl.h index a4bf5f264..fdf8b6cd9 100644 --- a/examples/automotive/SoundControl.h +++ b/examples/automotive/SoundControl.h @@ -5,7 +5,7 @@ class SoundControl : public QskBox { -public: + public: QSK_SUBCONTROLS( Overlay, CrossHair, Marker, Vehicle, SliderControl, MarkerControl ) SoundControl( QQuickItem* parent = nullptr ); diff --git a/examples/automotive/Speedometer.cpp b/examples/automotive/Speedometer.cpp index 769ebefca..d975ccd0e 100644 --- a/examples/automotive/Speedometer.cpp +++ b/examples/automotive/Speedometer.cpp @@ -8,8 +8,8 @@ QSK_SUBCONTROL( Speedometer, Labels ) QSK_SUBCONTROL( Speedometer, NeedleHead ) QSK_SUBCONTROL( Speedometer, Needle ) -Speedometer::Speedometer( QQuickItem* parent ) : - QskRangeControl( parent ) +Speedometer::Speedometer( QQuickItem* parent ) + : QskRangeControl( parent ) { } diff --git a/examples/automotive/Speedometer.h b/examples/automotive/Speedometer.h index 55f71547d..dc34f82aa 100644 --- a/examples/automotive/Speedometer.h +++ b/examples/automotive/Speedometer.h @@ -7,7 +7,7 @@ class Speedometer : public QskRangeControl { Q_OBJECT -public: + public: QSK_SUBCONTROLS( Panel, Labels, NeedleHead, Needle ) Speedometer( QQuickItem* parent = nullptr ); @@ -15,7 +15,7 @@ class Speedometer : public QskRangeControl QVector< QString > labels() const; void setLabels( const QVector< QString >& labels ); -private: + private: QVector< QString > m_labels; }; diff --git a/examples/automotive/SpeedometerDisplay.cpp b/examples/automotive/SpeedometerDisplay.cpp index 859bec742..ff51241a4 100644 --- a/examples/automotive/SpeedometerDisplay.cpp +++ b/examples/automotive/SpeedometerDisplay.cpp @@ -10,15 +10,15 @@ #include #include -SpeedometerDisplay::SpeedometerDisplay( QQuickItem *parent ) : - QskControl( parent ), - m_box( new QskLinearBox( Qt::Horizontal, this ) ), - m_revCounter( new Speedometer( m_box ) ), - m_revCounterText( new QskTextLabel( QStringLiteral( "x 1000 min^-1" ), m_revCounter ) ), - m_speedometer( new Speedometer( m_box ) ), - m_speedometerText( new QskTextLabel( QStringLiteral( "km/h" ), m_speedometer ) ), - m_fuelGauge( new Speedometer( m_box ) ), - m_fuelGaugeText( new QskTextLabel( QStringLiteral( "fuel" ), m_fuelGauge ) ) +SpeedometerDisplay::SpeedometerDisplay( QQuickItem* parent ) + : QskControl( parent ) + , m_box( new QskLinearBox( Qt::Horizontal, this ) ) + , m_revCounter( new Speedometer( m_box ) ) + , m_revCounterText( new QskTextLabel( QStringLiteral( "x 1000 min^-1" ), m_revCounter ) ) + , m_speedometer( new Speedometer( m_box ) ) + , m_speedometerText( new QskTextLabel( QStringLiteral( "km/h" ), m_speedometer ) ) + , m_fuelGauge( new Speedometer( m_box ) ) + , m_fuelGaugeText( new QskTextLabel( QStringLiteral( "fuel" ), m_fuelGauge ) ) { qsrand( static_cast< uint >( QTime::currentTime().msec() ) ); @@ -72,7 +72,6 @@ SpeedometerDisplay::SpeedometerDisplay( QQuickItem *parent ) : timer->setInterval( 16 ); timer->start(); - m_fuelGauge->setObjectName( QStringLiteral( "Fuel Gauge" ) ); m_fuelGauge->setMinimum( 195 ); m_fuelGauge->setMaximum( 345 ); @@ -83,7 +82,6 @@ SpeedometerDisplay::SpeedometerDisplay( QQuickItem *parent ) : m_fuelGauge->setLabels( fuelGaugeLabels ); - m_revCounterText->setMargins( 50 ); m_speedometerText->setMargins( 50 ); m_fuelGaugeText->setMargins( 50 ); diff --git a/examples/automotive/SpeedometerDisplay.h b/examples/automotive/SpeedometerDisplay.h index eeca1c835..52f7d5b4d 100644 --- a/examples/automotive/SpeedometerDisplay.h +++ b/examples/automotive/SpeedometerDisplay.h @@ -9,13 +9,13 @@ class Speedometer; class SpeedometerDisplay : public QskControl { -public: + public: SpeedometerDisplay( QQuickItem* parent = nullptr ); -protected: + protected: void updateLayout() override; -private: + private: QskLinearBox* m_box; Speedometer* m_revCounter; QskTextLabel* m_revCounterText; diff --git a/examples/automotive/SpeedometerSkinlet.cpp b/examples/automotive/SpeedometerSkinlet.cpp index d5d33b417..9cf6f0ec2 100644 --- a/examples/automotive/SpeedometerSkinlet.cpp +++ b/examples/automotive/SpeedometerSkinlet.cpp @@ -17,38 +17,38 @@ namespace { class TicksNode : public QSGGeometryNode { - public: - TicksNode(): - m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) - { - m_geometry.setDrawingMode( GL_LINES ); - m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); + public: + TicksNode() + : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) + { + m_geometry.setDrawingMode( GL_LINES ); + m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); - setGeometry( &m_geometry ); - setMaterial( &m_material ); - } + setGeometry( &m_geometry ); + setMaterial( &m_material ); + } - void setColor( const QColor& color ) - { - m_material.setColor( color ); - } + void setColor( const QColor& color ) + { + m_material.setColor( color ); + } - private: - QSGFlatColorMaterial m_material; - QSGGeometry m_geometry; + private: + QSGFlatColorMaterial m_material; + QSGGeometry m_geometry; }; } // namespace -SpeedometerSkinlet::SpeedometerSkinlet( QskSkin* skin ) : - QskSkinlet( skin ) +SpeedometerSkinlet::SpeedometerSkinlet( QskSkin* skin ) + : QskSkinlet( skin ) { setNodeRoles( { PanelRole, LabelsRole, NeedleRole } ); } SpeedometerSkinlet::~SpeedometerSkinlet() = default; -QRectF SpeedometerSkinlet::subControlRect( const QskSkinnable* skinnable, - QskAspect::Subcontrol /*unused*/ ) const +QRectF SpeedometerSkinlet::subControlRect( + const QskSkinnable* skinnable, QskAspect::Subcontrol ) const { const auto speedometer = static_cast< const Speedometer* >( skinnable ); @@ -56,12 +56,12 @@ QRectF SpeedometerSkinlet::subControlRect( const QskSkinnable* skinnable, return speedometer->contentsRect(); } -QSGNode* SpeedometerSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, - QSGNode* node ) const +QSGNode* SpeedometerSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { const auto speedometer = static_cast< const Speedometer* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: return updatePanelNode( speedometer, node ); @@ -81,7 +81,7 @@ QSGNode* SpeedometerSkinlet::updatePanelNode( const Speedometer* speedometer, QS { auto boxNode = static_cast< QskBoxNode* >( node ); - if( boxNode == nullptr ) + if ( boxNode == nullptr ) { boxNode = new QskBoxNode; } @@ -143,7 +143,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q QVector< QString > labels = speedometer->labels(); // Create a series of tickmarks from minimum to maximum - for( int i = 0; i < labelsCount; ++i, angle += step ) + for ( int i = 0; i < labelsCount; ++i, angle += step ) { qreal cosine = qCos( qDegreesToRadians( angle ) ); qreal sine = qSin( qDegreesToRadians( angle ) ); @@ -155,8 +155,8 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q auto xEnd = center.x() + ( radius - length ) * cosine; auto yEnd = center.y() + ( radius - length ) * sine; - vertexData[0].set( xStart, yStart ); - vertexData[1].set( xEnd, yEnd ); + vertexData[ 0 ].set( xStart, yStart ); + vertexData[ 1 ].set( xEnd, yEnd ); vertexData += 2; @@ -187,9 +187,8 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q } QFont font = speedometer->effectiveFont( Speedometer::Labels ); - numbersNode->setTextData( speedometer, text, numbersRect, font, - QskTextOptions(), QskTextColors( color ), - Qt::AlignCenter | Qt::AlignHCenter, Qsk::Normal ); + numbersNode->setTextData( speedometer, text, numbersRect, font, QskTextOptions(), + QskTextColors( color ), Qt::AlignCenter | Qt::AlignHCenter, Qsk::Normal ); if ( ticksNode->childCount() <= i ) { @@ -237,8 +236,7 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode( QskBoxBorderMetrics borderMetrics = speedometer->boxBorderMetricsHint( Speedometer::NeedleHead ); QskBoxBorderColors borderColors = speedometer->boxBorderColorsHint( Speedometer::NeedleHead ); QskGradient gradient = speedometer->gradientHint( Speedometer::NeedleHead ); - QRectF centerNodeRect( center.x() - radius, center.y() - radius, - 2 * radius, 2 * radius ); + QRectF centerNodeRect( center.x() - radius, center.y() - radius, 2 * radius, 2 * radius ); boxNode->setBoxData( centerNodeRect, shapeMetrics, borderMetrics, borderColors, gradient ); QColor color = speedometer->color( Speedometer::Needle ); @@ -249,8 +247,8 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode( auto needleWidth = speedometer->metric( Speedometer::Needle | QskAspect::MinimumWidth ); auto needleMargin = speedometer->metric( Speedometer::Needle | QskAspect::Margin ); - QRectF needleRect( center.x() - needleWidth , center.y() - needleWidth , - panelRadius - ( needleWidth + needleMargin ), 2 * needleWidth ); + QRectF needleRect( center.x() - needleWidth, center.y() - needleWidth, + panelRadius - ( needleWidth + needleMargin ), 2 * needleWidth ); float xStart = center.x(); float yStart = center.y(); @@ -268,10 +266,10 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode( auto vertexData = geometry->vertexDataAsPoint2D(); memset( vertexData, 0, static_cast< size_t >( geometry->vertexCount() ) ); - vertexData[0].set( xStart, yStart ); - vertexData[1].set( xEnd, yEnd ); + vertexData[ 0 ].set( xStart, yStart ); + vertexData[ 1 ].set( xEnd, yEnd ); - geometry->setLineWidth( 2 * needleWidth ); + geometry->setLineWidth( 2 * needleWidth ); geometry->markVertexDataDirty(); needleNode->markDirty( QSGNode::DirtyGeometry ); diff --git a/examples/automotive/SpeedometerSkinlet.h b/examples/automotive/SpeedometerSkinlet.h index 8e1b5ab33..da9c4c62b 100644 --- a/examples/automotive/SpeedometerSkinlet.h +++ b/examples/automotive/SpeedometerSkinlet.h @@ -9,8 +9,7 @@ class SpeedometerSkinlet : public QskSkinlet { Q_GADGET -public: - + public: enum NodeRole { PanelRole, @@ -24,10 +23,11 @@ class SpeedometerSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable* skinnable, QskAspect::Subcontrol ) const override; -protected: - virtual QSGNode* updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const override; + protected: + virtual QSGNode* updateSubNode( const QskSkinnable*, + quint8 nodeRole, QSGNode* node ) const override; -private: + private: QSGNode* updatePanelNode( const Speedometer*, QSGNode* ) const; QSGNode* updateLabelsNode( const Speedometer*, QSGNode* ) const; QSGNode* updateNeedleNode( const Speedometer*, QSGNode* ) const; diff --git a/examples/automotive/main.cpp b/examples/automotive/main.cpp index bbdac2b31..4d4c3ce8f 100644 --- a/examples/automotive/main.cpp +++ b/examples/automotive/main.cpp @@ -1,9 +1,9 @@ #include "MainWindow.h" #include "SkinFactory.h" +#include #include #include -#include #include #include diff --git a/examples/boxes/Box.cpp b/examples/boxes/Box.cpp index e26fcff1f..fd2e895df 100644 --- a/examples/boxes/Box.cpp +++ b/examples/boxes/Box.cpp @@ -1,11 +1,11 @@ #include "Box.h" -#include -#include #include +#include +#include -Box::Box( QQuickItem* parentItem ): - QskBox( parentItem ) +Box::Box( QQuickItem* parentItem ) + : QskBox( parentItem ) { setSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Ignored ); @@ -29,7 +29,7 @@ void Box::setBackground( FillType type, Palette::Color color, bool inverted ) const QColor light = pal.color( Palette::W300 ); const QColor mid = pal.color( Palette::W600 ); - switch( type ) + switch ( type ) { case Unfilled: setGradient( QskGradient() ); @@ -67,7 +67,7 @@ void Box::setBorder( BorderType type, Palette::Color color ) light.setAlpha( 100 ); #endif - switch( type ) + switch ( type ) { case NoBorder: setBorderWidth( 0 ); @@ -102,8 +102,7 @@ void Box::setShape( const QskBoxShapeMetrics& shape ) void Box::setShape( qreal radius, Qt::SizeMode sizeMode ) { - setBoxShapeHint( QskBox::Panel, - QskBoxShapeMetrics( radius, sizeMode ) ); + setBoxShapeHint( QskBox::Panel, QskBoxShapeMetrics( radius, sizeMode ) ); } void Box::setShape( qreal radiusX, qreal radiusY, Qt::SizeMode sizeMode ) @@ -179,8 +178,7 @@ void Box::setGradient( QVector< QskGradientStop > stops; - stops += QskGradientStop( - 0.0, pal.color( static_cast( 0 ) ) ); + stops += QskGradientStop( 0.0, pal.color( static_cast< Palette::Weight >( 0 ) ) ); const int count = Palette::NumWeights - 1; for ( int i = 1; i < count; i++ ) @@ -197,4 +195,3 @@ void Box::setGradient( setGradient( QskGradient( orientation, stops ) ); } - diff --git a/examples/boxes/Box.h b/examples/boxes/Box.h index 3ecffed5e..c13f089aa 100644 --- a/examples/boxes/Box.h +++ b/examples/boxes/Box.h @@ -6,7 +6,7 @@ class Box : public QskBox { -public: + public: enum FillType { Unfilled, diff --git a/examples/boxes/Palette.cpp b/examples/boxes/Palette.cpp index e5e3d55f2..2c5585a8c 100644 --- a/examples/boxes/Palette.cpp +++ b/examples/boxes/Palette.cpp @@ -13,12 +13,12 @@ namespace { class StandardPalette : public Palette { - public: + public: StandardPalette( int index ) { using namespace QskRgbValue; - static QRgb table[][Palette::NumWeights] = + static QRgb table[][ Palette::NumWeights ] = { RGBTABLE( Red ), RGBTABLE( Pink ), @@ -30,7 +30,7 @@ namespace RGBTABLE( Cyan ), RGBTABLE( Teal ), RGBTABLE( Green ), - RGBTABLE( LightGreen), + RGBTABLE( LightGreen ), RGBTABLE( Lime ), RGBTABLE( Yellow ), RGBTABLE( Amber ), @@ -41,7 +41,7 @@ namespace RGBTABLE( BlueGrey ), }; - const int count = sizeof( table ) / sizeof( table[0] ); + const int count = sizeof( table ) / sizeof( table[ 0 ] ); m_rgb = table[ qBound( 0, index, count ) ]; } }; @@ -51,4 +51,3 @@ Palette Palette::palette( Color color ) { return StandardPalette( static_cast< int >( color ) ); } - diff --git a/examples/boxes/Palette.h b/examples/boxes/Palette.h index 7b7c9af18..6358c814c 100644 --- a/examples/boxes/Palette.h +++ b/examples/boxes/Palette.h @@ -6,7 +6,7 @@ class Palette { -public: + public: enum Weight { W50, @@ -60,9 +60,8 @@ class Palette static Palette palette( Color ); -protected: + protected: QRgb* m_rgb; - }; #endif diff --git a/examples/boxes/main.cpp b/examples/boxes/main.cpp index 7e6dc3f21..515816914 100644 --- a/examples/boxes/main.cpp +++ b/examples/boxes/main.cpp @@ -12,9 +12,9 @@ #include #include -#include -#include #include +#include +#include #include #include @@ -24,18 +24,18 @@ class Rectangle : public Box { -public: - Rectangle( QQuickItem* parentItem ): - Box( parentItem ) + public: + Rectangle( QQuickItem* parentItem ) + : Box( parentItem ) { } }; class RoundedRectangle : public Box { -public: - RoundedRectangle( QQuickItem* parentItem ): - Box( parentItem ) + public: + RoundedRectangle( QQuickItem* parentItem ) + : Box( parentItem ) { setShape( 20, Qt::AbsoluteSize ); } @@ -43,9 +43,9 @@ class RoundedRectangle : public Box class Ellipse : public Box { -public: - Ellipse( QQuickItem* parentItem ): - Box( parentItem ) + public: + Ellipse( QQuickItem* parentItem ) + : Box( parentItem ) { setShape( 100, Qt::RelativeSize ); } @@ -257,7 +257,7 @@ static void addRectangles10( QskLinearBox* parent ) static void addRectangles11( QskLinearBox* parent ) { const qreal border = 5; - const Box::FillType fillType[5] = { Box::Solid, Box::Horizontal, + const Box::FillType fillType[ 5 ] = { Box::Solid, Box::Horizontal, Box::Vertical, Box::Horizontal, Box::Vertical }; for ( int i = 0; i < 5; i++ ) @@ -266,12 +266,12 @@ static void addRectangles11( QskLinearBox* parent ) box->setBorder( Box::Flat, Palette::Teal ); - qreal bw[4] = { border, border, border, border }; + qreal bw[ 4 ] = { border, border, border, border }; if ( i != 0 ) bw[ i - 1 ] = 0; - box->setBorderWidth( bw[0], bw[1], bw[2], bw[3] ); - box->setBackground( fillType[i], Palette::Brown, i >= 3 ); + box->setBorderWidth( bw[ 0 ], bw[ 1 ], bw[ 2 ], bw[ 3 ] ); + box->setBackground( fillType[ i ], Palette::Brown, i >= 3 ); } } @@ -302,12 +302,12 @@ static void addRectangles12( QskLinearBox* parent ) } for ( auto orientation : { QskGradient::Vertical, QskGradient::Diagonal } ) - { + { auto* box = new Box( parent ); box->setBorder( Box::Flat, Palette::DeepOrange ); box->setShape( 30, 40, Qt::RelativeSize ); box->setGradient( orientation, Palette::Blue ); - } + } for ( auto orientation : { QskGradient::Vertical, QskGradient::Horizontal, QskGradient::Diagonal } ) @@ -361,9 +361,9 @@ static void addRectanglesRest( QskLinearBox* parent ) class TabView : public QskTabView { -public: - TabView( QQuickItem* parentItem = nullptr ): - QskTabView( Qt::Vertical, parentItem ) + public: + TabView( QQuickItem* parentItem = nullptr ) + : QskTabView( Qt::Vertical, parentItem ) { setMargins( 10 ); @@ -400,7 +400,7 @@ class TabView : public QskTabView #endif } -private: + private: void addTab( QskLinearBox* layout ) { layout->setMargins( 10 ); @@ -421,8 +421,7 @@ int main( int argc, char* argv[] ) QGuiApplication app( argc, argv ); SkinnyFont::init( &app ); - SkinnyShortcut::enable( SkinnyShortcut::Quit | - SkinnyShortcut::DebugShortcuts ); + SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts ); auto* tabView = new TabView(); diff --git a/examples/buttons/main.cpp b/examples/buttons/main.cpp index d1b18457a..24907a78a 100644 --- a/examples/buttons/main.cpp +++ b/examples/buttons/main.cpp @@ -3,15 +3,15 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include #include +#include #include #include #include -#include #include +#include int main( int argc, char* argv[] ) { diff --git a/examples/colorswitch/Theme.cpp b/examples/colorswitch/Theme.cpp index 007a6b6ab..cb2c9354b 100644 --- a/examples/colorswitch/Theme.cpp +++ b/examples/colorswitch/Theme.cpp @@ -5,13 +5,13 @@ #include "Theme.h" +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include static void qskResetColors( QskSkin* skin, const QColor& accent ) { @@ -30,32 +30,32 @@ namespace { class SkinTransition final : public QskSkinTransition { - public: - SkinTransition( const QColor& accent ): - m_accent( accent ) + public: + SkinTransition( const QColor& accent ) + : m_accent( accent ) { } - protected: + protected: void updateSkin( QskSkin*, QskSkin* newSkin ) override { qskResetColors( newSkin, m_accent ); } - private: + private: const QColor m_accent; }; } -Theme::Theme( QObject* parent ): - QObject( parent ), - m_accent( qskSetup->skin()->color( QskAspect::Color ) ) +Theme::Theme( QObject* parent ) + : QObject( parent ) + , m_accent( qskSetup->skin()->color( QskAspect::Color ) ) { connect( qskSetup, &QskSetup::skinChanged, - this, [this]( QskSkin* ) { updateColors(); } ); + this, [ this ]( QskSkin* ) { updateColors(); } ); connect( qskSetup, &QskSetup::skinChanged, - this, [this]( QskSkin* ) { Q_EMIT skinChanged(); } ); + this, [ this ]( QskSkin* ) { Q_EMIT skinChanged(); } ); } void Theme::setAccent( QColor color ) diff --git a/examples/colorswitch/Theme.h b/examples/colorswitch/Theme.h index 9bfb45cbc..37ad6d842 100644 --- a/examples/colorswitch/Theme.h +++ b/examples/colorswitch/Theme.h @@ -6,8 +6,8 @@ #ifndef THEME_H #define THEME_H 1 -#include #include +#include class Theme : public QObject { @@ -16,7 +16,7 @@ class Theme : public QObject Q_PROPERTY( QColor accent READ accent WRITE setAccent NOTIFY accentChanged ) Q_PROPERTY( QString skin READ skin WRITE setSkin NOTIFY skinChanged ) -public: + public: Theme( QObject* parent = nullptr ); void setAccent( QColor color ); @@ -25,11 +25,11 @@ class Theme : public QObject void setSkin( const QString& ); QString skin() const; -Q_SIGNALS: + Q_SIGNALS: void accentChanged(); void skinChanged(); -private: + private: void updateColors(); QColor m_accent; diff --git a/examples/colorswitch/main.cpp b/examples/colorswitch/main.cpp index 02b672dca..b1e00097b 100644 --- a/examples/colorswitch/main.cpp +++ b/examples/colorswitch/main.cpp @@ -11,9 +11,9 @@ #include #include -#include -#include #include +#include +#include int main( int argc, char* argv[] ) { diff --git a/examples/desktop/main.cpp b/examples/desktop/main.cpp index dd17c2589..2bf100b6d 100644 --- a/examples/desktop/main.cpp +++ b/examples/desktop/main.cpp @@ -3,27 +3,27 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include #include +#include +#include +#include +#include #include -#include +#include #include #include -#include -#include -#include -#include +#include +#include #include #include -#include class SubWindow : public QskSubWindow { -public: - SubWindow( const QString& graphicSource, QQuickItem* parent = nullptr ): - QskSubWindow( parent ) + public: + SubWindow( const QString& graphicSource, QQuickItem* parent = nullptr ) + : QskSubWindow( parent ) { setObjectName( graphicSource ); @@ -35,7 +35,7 @@ class SubWindow : public QskSubWindow QskSizePolicy::MinimumExpanding ); QskShortcutMap::addShortcut( this, QKeySequence( Qt::Key_P ), true, - [=] { qDebug() << graphicSource; } ); + [ graphicSource ] { qDebug() << graphicSource; } ); } }; @@ -66,7 +66,7 @@ int main( int argc, char* argv[] ) { const qreal off = ( i + 1 ) * 100; - SubWindow* subWindow = new SubWindow( url + shapes[i], area ); + auto subWindow = new SubWindow( url + shapes[ i ], area ); subWindow->setGeometry( windowRect.translated( off, off ) ); } diff --git a/examples/dialogbuttons/Window.cpp b/examples/dialogbuttons/Window.cpp index 92d9ea02d..a6b1f83d0 100644 --- a/examples/dialogbuttons/Window.cpp +++ b/examples/dialogbuttons/Window.cpp @@ -3,13 +3,14 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include +#include "Window.h" + #include +#include #include -#include "Window.h" -Window::Window( Qt::Orientation orientation ): - m_orientation( orientation ) +Window::Window( Qt::Orientation orientation ) + : m_orientation( orientation ) { m_layoutBox = new QskLinearBox( invertedOrientation() ); m_layoutBox->setObjectName( "MainBox" ); @@ -17,10 +18,14 @@ Window::Window( Qt::Orientation orientation ): m_layoutBox->setExtraSpacingAt( Qt::BottomEdge | Qt::RightEdge ); addBox( QskDialog::Ok ); + addBox( QskDialog::StandardButtons( QskDialog::Ok | QskDialog::Cancel ) ); + addBox( QskDialog::StandardButtons( QskDialog::Yes | QskDialog::No ) ); + addBox( QskDialog::StandardButtons( QskDialog::Save | QskDialog::Discard | QskDialog::RestoreDefaults | QskDialog::Help ) ); + addBox( QskDialog::StandardButtons( QskDialog::Abort | QskDialog::Retry | QskDialog::Ignore ) ); @@ -90,8 +95,7 @@ QVector< QskDialogButtonBox* > Window::dialogBoxes() const QVector< QskDialogButtonBox* > boxes; for ( int i = 0; i < m_layoutBox->itemCount(); i++ ) { - if ( QskDialogButtonBox* box = - qobject_cast< QskDialogButtonBox* >( m_layoutBox->itemAtIndex( i ) ) ) + if ( auto box = qobject_cast< QskDialogButtonBox* >( m_layoutBox->itemAtIndex( i ) ) ) { boxes += box; } diff --git a/examples/dialogbuttons/Window.h b/examples/dialogbuttons/Window.h index 9ed2bc17d..56f967320 100644 --- a/examples/dialogbuttons/Window.h +++ b/examples/dialogbuttons/Window.h @@ -6,8 +6,8 @@ #ifndef WINDOW_H #define WINDOW_H 1 -#include #include +#include class QskDialogButtonBox; class QskLinearBox; @@ -16,21 +16,21 @@ class Window : public QskWindow { Q_OBJECT -public: + public: Window( Qt::Orientation ); -private Q_SLOTS: + private Q_SLOTS: void flipOrientation(); void centerButtons(); -private: + private: void addBox( QskDialog::StandardButtons ); void addActionBox(); QVector< QskDialogButtonBox* > dialogBoxes() const; Qt::Orientation invertedOrientation() const; -private: + private: QskLinearBox* m_layoutBox; Qt::Orientation m_orientation; }; diff --git a/examples/frames/Frame.cpp b/examples/frames/Frame.cpp index a54f4a215..c4df5fc65 100644 --- a/examples/frames/Frame.cpp +++ b/examples/frames/Frame.cpp @@ -5,11 +5,11 @@ #include "Frame.h" -#include -#include #include -#include +#include #include +#include +#include #include static inline qreal effectiveRadius( const QRectF& rect, qreal percentage ) @@ -17,12 +17,12 @@ static inline qreal effectiveRadius( const QRectF& rect, qreal percentage ) return percentage / 100.0 * 0.5 * qMin( rect.width(), rect.height() ); } -Frame::Frame( QQuickItem* parent ): - Inherited( parent ), - m_style( Frame::Plain ), - m_color( Qt::gray ), - m_frameWidth( 1.0 ), - m_radius( 0.0 ) +Frame::Frame( QQuickItem* parent ) + : Inherited( parent ) + , m_style( Frame::Plain ) + , m_color( Qt::gray ) + , m_frameWidth( 1.0 ) + , m_radius( 0.0 ) { } @@ -128,7 +128,7 @@ void Frame::updateFrameNode( const QRectF& rect, QskBoxNode* node ) QColor c1, c2; - switch( m_style ) + switch ( m_style ) { case Frame::Sunken: { @@ -147,10 +147,10 @@ void Frame::updateFrameNode( const QRectF& rect, QskBoxNode* node ) c1 = c2 = dark; } } - + const QskBoxBorderColors borderColors( c1, c1, c2, c2 ); const qreal radius = effectiveRadius( rect, m_radius ); - + node->setBoxData( rect, radius, m_frameWidth, borderColors, m_color ); } diff --git a/examples/frames/Frame.h b/examples/frames/Frame.h index ae1d2a195..c4761057d 100644 --- a/examples/frames/Frame.h +++ b/examples/frames/Frame.h @@ -27,7 +27,7 @@ class QSK_EXPORT Frame : public QskControl using Inherited = QskControl; -public: + public: enum Style { Plain, @@ -53,16 +53,16 @@ class QSK_EXPORT Frame : public QskControl void setColor( const QColor& ); QColor color() const; -Q_SIGNALS: + Q_SIGNALS: void styleChanged(); void frameWidthChanged(); void radiusChanged(); void colorChanged(); -protected: + protected: void updateNode( QSGNode* ) override; -private: + private: void updateFrameNode( const QRectF&, QskBoxNode* ); Style m_style; diff --git a/examples/frames/main.cpp b/examples/frames/main.cpp index 3a0ab2484..0c5e7101a 100644 --- a/examples/frames/main.cpp +++ b/examples/frames/main.cpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include int main( int argc, char* argv[] ) { diff --git a/examples/gbenchmark/Benchmark.cpp b/examples/gbenchmark/Benchmark.cpp index 8a94e9ffe..8d9866d60 100644 --- a/examples/gbenchmark/Benchmark.cpp +++ b/examples/gbenchmark/Benchmark.cpp @@ -9,14 +9,13 @@ #include #include -#include -#include -#include -#include #include +#include #include -#include #include +#include +#include +#include bool Benchmark::run( const QString& dirName ) { @@ -33,18 +32,18 @@ bool Benchmark::run( const QString& dirName ) QStringList qvgFiles = svgFiles; for ( int i = 0; i < qvgFiles.size(); i++ ) { - svgFiles[i].prepend( "/" ); - svgFiles[i].prepend( dirName ); + svgFiles[ i ].prepend( "/" ); + svgFiles[ i ].prepend( dirName ); - qvgFiles[i].replace( ".svg", ".qvg" ); - qvgFiles[i].prepend( "/" ); - qvgFiles[i].prepend( qvgPath ); + qvgFiles[ i ].replace( ".svg", ".qvg" ); + qvgFiles[ i ].prepend( "/" ); + qvgFiles[ i ].prepend( qvgPath ); } QVector< QskGraphic > graphics( qvgFiles.size() ); QVector< QSvgRenderer* > renderers( svgFiles.size() ); - qint64 msElapsed[6]; + qint64 msElapsed[ 6 ]; QElapsedTimer timer; @@ -55,15 +54,15 @@ bool Benchmark::run( const QString& dirName ) for ( int i = 0; i < svgFiles.size(); i++ ) { - renderers[i] = new QSvgRenderer(); - if ( !renderers[i]->load( svgFiles[i] ) ) + renderers[ i ] = new QSvgRenderer(); + if ( !renderers[ i ]->load( svgFiles[ i ] ) ) { - qCritical() << "Can't load" << svgFiles[i]; + qCritical() << "Can't load" << svgFiles[ i ]; return false; } } - msElapsed[0] = timer.elapsed(); + msElapsed[ 0 ] = timer.elapsed(); } { @@ -73,13 +72,12 @@ bool Benchmark::run( const QString& dirName ) for ( int i = 0; i < renderers.size(); i++ ) { - QPainter painter( &graphics[i] ); - renderers[i]->render( &painter ); + QPainter painter( &graphics[ i ] ); + renderers[ i ]->render( &painter ); painter.end(); } - - msElapsed[1] = timer.elapsed(); + msElapsed[ 1 ] = timer.elapsed(); } { @@ -89,10 +87,10 @@ bool Benchmark::run( const QString& dirName ) for ( int i = 0; i < graphics.size(); i++ ) { - QskGraphicIO::write( graphics[i], qvgFiles[i] ); + QskGraphicIO::write( graphics[ i ], qvgFiles[ i ] ); } - msElapsed[2] = timer.elapsed(); + msElapsed[ 2 ] = timer.elapsed(); } { @@ -102,15 +100,15 @@ bool Benchmark::run( const QString& dirName ) for ( int i = 0; i < qvgFiles.size(); i++ ) { - graphics[i] = QskGraphicIO::read( qvgFiles[i] ); - if ( graphics[i].isNull() ) + graphics[ i ] = QskGraphicIO::read( qvgFiles[ i ] ); + if ( graphics[ i ].isNull() ) { - qCritical() << "Can't load" << qvgFiles[i]; + qCritical() << "Can't load" << qvgFiles[ i ]; return false; } } - msElapsed[3] = timer.elapsed(); + msElapsed[ 3 ] = timer.elapsed(); } { @@ -125,16 +123,16 @@ bool Benchmark::run( const QString& dirName ) { const auto textureId = QskGraphicTextureFactory::createTexture( QskGraphicTextureFactory::OpenGL, targetRect, Qt::KeepAspectRatio, - graphics[i], colorFilter ); + graphics[ i ], colorFilter ); if ( textureId == 0 ) { - qCritical() << "Can't render texture for" << qvgFiles[i]; + qCritical() << "Can't render texture for" << qvgFiles[ i ]; return false; } } - msElapsed[4] = timer.elapsed(); + msElapsed[ 4 ] = timer.elapsed(); } { @@ -149,25 +147,25 @@ bool Benchmark::run( const QString& dirName ) { const auto textureId = QskGraphicTextureFactory::createTexture( QskGraphicTextureFactory::Raster, targetRect, Qt::KeepAspectRatio, - graphics[i], colorFilter ); + graphics[ i ], colorFilter ); if ( textureId == 0 ) { - qCritical() << "Can't render texture for" << qvgFiles[i]; + qCritical() << "Can't render texture for" << qvgFiles[ i ]; return false; } } - msElapsed[5] = timer.elapsed(); + msElapsed[ 5 ] = timer.elapsed(); } qDebug() << "#Icons:" << svgFiles.count() << - "Compiled:" << msElapsed[0] << - "Converted:" << msElapsed[1] << - "Stored:" << msElapsed[2] << - "Loaded:" << msElapsed[3] << - "Rendered OpenGL:" << msElapsed[4] << - "Rendered Raster:" << msElapsed[5]; + "Compiled:" << msElapsed[ 0 ] << + "Converted:" << msElapsed[ 1 ] << + "Stored:" << msElapsed[ 2 ] << + "Loaded:" << msElapsed[ 3 ] << + "Rendered OpenGL:" << msElapsed[ 4 ] << + "Rendered Raster:" << msElapsed[ 5 ]; svgDir.rmdir( qvgPath ); diff --git a/examples/gbenchmark/main.cpp b/examples/gbenchmark/main.cpp index 34f37b75a..a9d82e41f 100644 --- a/examples/gbenchmark/main.cpp +++ b/examples/gbenchmark/main.cpp @@ -5,18 +5,18 @@ #include "Benchmark.h" -#include -#include #include +#include +#include -#include #include +#include class Button : public QskPushButton { -public: - Button( const QString& testDir ): - m_testDir( testDir ) + public: + Button( const QString& testDir ) + : m_testDir( testDir ) { setText( QString( "Run: " ) + testDir ); setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); @@ -27,7 +27,7 @@ class Button : public QskPushButton Benchmark::run( m_testDir ); } -private: + private: QString m_testDir; }; @@ -36,19 +36,18 @@ int main( int argc, char* argv[] ) QGuiApplication app( argc, argv ); QCommandLineParser parser; - parser.setApplicationDescription("Benchmark for creating textures from SVGs"); + parser.setApplicationDescription( "Benchmark for creating textures from SVGs" ); parser.addHelpOption(); - parser.addPositionalArgument("svgdir", "Directory with SVG files.", "[pathname]"); + parser.addPositionalArgument( "svgdir", "Directory with SVG files.", "[pathname]" ); - parser.process(app); + parser.process( app ); const QStringList args = parser.positionalArguments(); if ( args.count() != 1 ) parser.showHelp( 1 ); - - Button* button = new Button( args[0] ); + auto button = new Button( args[ 0 ] ); QObject::connect( button, &Button::clicked, button, &Button::run ); auto box = new QskLinearBox(); diff --git a/examples/glabels/main.cpp b/examples/glabels/main.cpp index 184733cae..725f94102 100644 --- a/examples/glabels/main.cpp +++ b/examples/glabels/main.cpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include int main( int argc, char* argv[] ) { diff --git a/examples/layouts/ButtonBox.cpp b/examples/layouts/ButtonBox.cpp index 46db0f5f3..5b8f3bc0d 100644 --- a/examples/layouts/ButtonBox.cpp +++ b/examples/layouts/ButtonBox.cpp @@ -6,15 +6,15 @@ #include "ButtonBox.h" #include -ButtonBox::ButtonBox( QQuickItem* parent ): - QskLinearBox( Qt::Horizontal, parent ) +ButtonBox::ButtonBox( QQuickItem* parent ) + : QskLinearBox( Qt::Horizontal, parent ) { setObjectName( "ButtonBox" ); setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); } -void ButtonBox::addButton( const QString& text, - std::function< void() > func, bool autoRepeat ) +void ButtonBox::addButton( + const QString& text, std::function< void() > func, bool autoRepeat ) { QskPushButton* button = new QskPushButton( text ); button->setAutoRepeat( autoRepeat ); diff --git a/examples/layouts/ButtonBox.h b/examples/layouts/ButtonBox.h index a0e5311d3..166603a31 100644 --- a/examples/layouts/ButtonBox.h +++ b/examples/layouts/ButtonBox.h @@ -11,7 +11,7 @@ class ButtonBox : public QskLinearBox { -public: + public: ButtonBox( QQuickItem* parent = nullptr ); void addButton( const QString& text, diff --git a/examples/layouts/DynamicConstraintsPage.cpp b/examples/layouts/DynamicConstraintsPage.cpp index 617e6ee97..7ddba6afb 100644 --- a/examples/layouts/DynamicConstraintsPage.cpp +++ b/examples/layouts/DynamicConstraintsPage.cpp @@ -15,7 +15,7 @@ namespace { class Control final : public QskControl { - public: + public: Control( const char* colorName, QQuickItem* parent = nullptr ); Control( const char* colorName, qreal aspectRatio, QQuickItem* parent = nullptr ); @@ -24,25 +24,25 @@ namespace void transpose(); - private: + private: qreal m_aspectRatio; }; class Box : public QskLinearBox { - public: + public: Box( QQuickItem* parent = nullptr ); void flip(); - private: + private: void addControl( Control* ); }; } -Control::Control( const char* colorName, QQuickItem* parent ): - QskControl( parent ), - m_aspectRatio( 1.0 ) +Control::Control( const char* colorName, QQuickItem* parent ) + : QskControl( parent ) + , m_aspectRatio( 1.0 ) { setObjectName( colorName ); @@ -52,15 +52,15 @@ Control::Control( const char* colorName, QQuickItem* parent ): setPreferredSize( 80, 100 ); } -Control::Control( const char* colorName, qreal aspectRatio, QQuickItem* parent ): - QskControl( parent ), - m_aspectRatio( aspectRatio ) +Control::Control( const char* colorName, qreal aspectRatio, QQuickItem* parent ) + : QskControl( parent ) + , m_aspectRatio( aspectRatio ) { setObjectName( colorName ); setBackgroundColor( colorName ); - //setSizePolicy( QskSizePolicy::Constrained, QskSizePolicy::Ignored ); + // setSizePolicy( QskSizePolicy::Constrained, QskSizePolicy::Ignored ); setSizePolicy( QskSizePolicy::Constrained, QskSizePolicy::Fixed ); setPreferredHeight( 100 ); } @@ -83,8 +83,8 @@ void Control::transpose() setSizePolicy( sizePolicy().verticalPolicy(), sizePolicy().horizontalPolicy() ); } -Box::Box( QQuickItem* parent ): - QskLinearBox( Qt::Horizontal, 2, parent ) +Box::Box( QQuickItem* parent ) + : QskLinearBox( Qt::Horizontal, 2, parent ) { setObjectName( "Box" ); @@ -122,8 +122,8 @@ void Box::addControl( Control* control ) addItem( control, Qt::AlignCenter ); } -DynamicConstraintsPage::DynamicConstraintsPage( QQuickItem* parent ): - QskLinearBox( Qt::Vertical, parent ) +DynamicConstraintsPage::DynamicConstraintsPage( QQuickItem* parent ) + : QskLinearBox( Qt::Vertical, parent ) { setMargins( 10 ); setBackgroundColor( QskRgbValue::LightSteelBlue ); diff --git a/examples/layouts/DynamicConstraintsPage.h b/examples/layouts/DynamicConstraintsPage.h index b002d0cfe..68ce1a36d 100644 --- a/examples/layouts/DynamicConstraintsPage.h +++ b/examples/layouts/DynamicConstraintsPage.h @@ -10,7 +10,7 @@ class DynamicConstraintsPage : public QskLinearBox { -public: + public: DynamicConstraintsPage( QQuickItem* parent = nullptr ); }; diff --git a/examples/layouts/FlowLayoutPage.cpp b/examples/layouts/FlowLayoutPage.cpp index 0353f8fe8..b0d1dd9d1 100644 --- a/examples/layouts/FlowLayoutPage.cpp +++ b/examples/layouts/FlowLayoutPage.cpp @@ -4,21 +4,21 @@ *****************************************************************************/ #include "FlowLayoutPage.h" -#include "TestRectangle.h" #include "ButtonBox.h" +#include "TestRectangle.h" #include -#include #include #include +#include namespace { class Box : public QskLinearBox { - public: - Box( QQuickItem* parent = nullptr ): - QskLinearBox( Qt::Horizontal, 5, parent ) + public: + Box( QQuickItem* parent = nullptr ) + : QskLinearBox( Qt::Horizontal, 5, parent ) { setObjectName( "Box" ); @@ -72,7 +72,7 @@ namespace setDimension( dimension() + count ); } - private: + private: void addRectangle( const char* colorName ) { TestRectangle* rect = new TestRectangle( colorName ); @@ -82,8 +82,8 @@ namespace }; } -FlowLayoutPage::FlowLayoutPage( QQuickItem* parent ): - QskLinearBox( Qt::Vertical, parent ) +FlowLayoutPage::FlowLayoutPage( QQuickItem* parent ) + : QskLinearBox( Qt::Vertical, parent ) { setMargins( 10 ); setBackgroundColor( QskRgbValue::LightSteelBlue ); diff --git a/examples/layouts/FlowLayoutPage.h b/examples/layouts/FlowLayoutPage.h index 6c95d6ae3..7f0e0001a 100644 --- a/examples/layouts/FlowLayoutPage.h +++ b/examples/layouts/FlowLayoutPage.h @@ -10,7 +10,7 @@ class FlowLayoutPage : public QskLinearBox { -public: + public: FlowLayoutPage( QQuickItem* parent = nullptr ); }; diff --git a/examples/layouts/LinearLayoutPage.cpp b/examples/layouts/LinearLayoutPage.cpp index 021569126..eb2433601 100644 --- a/examples/layouts/LinearLayoutPage.cpp +++ b/examples/layouts/LinearLayoutPage.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "LinearLayoutPage.h" -#include "TestRectangle.h" #include "ButtonBox.h" +#include "TestRectangle.h" #include #include @@ -15,9 +15,9 @@ namespace { class Box : public QskLinearBox { - public: - Box( QQuickItem* parent = nullptr ): - QskLinearBox( Qt::Horizontal, parent ) + public: + Box( QQuickItem* parent = nullptr ) + : QskLinearBox( Qt::Horizontal, parent ) { setObjectName( "Box" ); @@ -35,10 +35,10 @@ namespace addRectangle( "FireBrick" ); addRectangle( "DarkRed" ); - //setRowSpacing( 5, 30 ); + // setRowSpacing( 5, 30 ); insertSpacer( 5, 30 ); - //insertStretch( 5, 2 ); - //setRetainSizeWhenHidden( 2, true ); + // insertStretch( 5, 2 ); + // setRetainSizeWhenHidden( 2, true ); } void mirror() @@ -69,8 +69,7 @@ namespace setSpacing( this->spacing() + spacing ); } - private: - + private: void addRectangle( const char* colorName ) { TestRectangle* rect = new TestRectangle( colorName ); @@ -81,8 +80,8 @@ namespace }; } -LinearLayoutPage::LinearLayoutPage( QQuickItem* parent ): - QskLinearBox( Qt::Vertical, parent ) +LinearLayoutPage::LinearLayoutPage( QQuickItem* parent ) + : QskLinearBox( Qt::Vertical, parent ) { setMargins( 10 ); setBackgroundColor( QskRgbValue::LightSteelBlue ); diff --git a/examples/layouts/LinearLayoutPage.h b/examples/layouts/LinearLayoutPage.h index 46b7d1f43..a6b6b5a60 100644 --- a/examples/layouts/LinearLayoutPage.h +++ b/examples/layouts/LinearLayoutPage.h @@ -10,7 +10,7 @@ class LinearLayoutPage : public QskLinearBox { -public: + public: LinearLayoutPage( QQuickItem* parent = nullptr ); }; diff --git a/examples/layouts/StackLayoutPage.cpp b/examples/layouts/StackLayoutPage.cpp index 8f130aadb..56cdc7576 100644 --- a/examples/layouts/StackLayoutPage.cpp +++ b/examples/layouts/StackLayoutPage.cpp @@ -4,23 +4,23 @@ *****************************************************************************/ #include "StackLayoutPage.h" -#include "TestRectangle.h" #include "ButtonBox.h" +#include "TestRectangle.h" #include -#include #include +#include #include #include -#include +#include namespace { class Box : public QskStackBox { - public: - Box( QQuickItem* parent = nullptr ): - QskStackBox( parent ) + public: + Box( QQuickItem* parent = nullptr ) + : QskStackBox( parent ) { setObjectName( "StackBox" ); @@ -41,7 +41,7 @@ namespace } } - public: + public: void incrementFading( int offset ) { auto animator = dynamic_cast< QskStackBoxAnimator3* >( this->animator() ); @@ -73,7 +73,7 @@ namespace setCurrentIndex( incrementedIndex( offset ) ); } - private: + private: void addRectangle( const char* colorName ) { auto rect = new TestRectangle( colorName ); @@ -96,8 +96,8 @@ namespace }; } -StackLayoutPage::StackLayoutPage( QQuickItem* parent ): - QskLinearBox( Qt::Vertical, parent ) +StackLayoutPage::StackLayoutPage( QQuickItem* parent ) + : QskLinearBox( Qt::Vertical, parent ) { setObjectName( "StackLayoutPage" ); diff --git a/examples/layouts/StackLayoutPage.h b/examples/layouts/StackLayoutPage.h index 4e712e7d6..f662e69cd 100644 --- a/examples/layouts/StackLayoutPage.h +++ b/examples/layouts/StackLayoutPage.h @@ -10,7 +10,7 @@ class StackLayoutPage : public QskLinearBox { -public: + public: StackLayoutPage( QQuickItem* parent = nullptr ); }; diff --git a/examples/layouts/TestRectangle.cpp b/examples/layouts/TestRectangle.cpp index 71d593071..948fb7981 100644 --- a/examples/layouts/TestRectangle.cpp +++ b/examples/layouts/TestRectangle.cpp @@ -7,8 +7,8 @@ #include -TestRectangle::TestRectangle( const char* colorName, QQuickItem* parent ): - QskTextLabel( parent ) +TestRectangle::TestRectangle( const char* colorName, QQuickItem* parent ) + : QskTextLabel( parent ) { setObjectName( colorName ); diff --git a/examples/layouts/TestRectangle.h b/examples/layouts/TestRectangle.h index 4659a7f49..05c31082e 100644 --- a/examples/layouts/TestRectangle.h +++ b/examples/layouts/TestRectangle.h @@ -10,7 +10,7 @@ class TestRectangle : public QskTextLabel { -public: + public: TestRectangle( const char* colorName, QQuickItem* parent = nullptr ); }; diff --git a/examples/layouts/main.cpp b/examples/layouts/main.cpp index 9c5c5595f..3c90ac4ec 100644 --- a/examples/layouts/main.cpp +++ b/examples/layouts/main.cpp @@ -3,31 +3,31 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ +#include "DynamicConstraintsPage.h" #include "FlowLayoutPage.h" #include "LinearLayoutPage.h" -#include "DynamicConstraintsPage.h" #include "StackLayoutPage.h" #include #include #include -#include -#include #include +#include +#include #include #include #include #include -#include +#include #include class DummyLabel : public QskTextLabel { -public: - DummyLabel( const QString& text, QQuickItem* parent = nullptr ): - QskTextLabel( text, parent ) + public: + DummyLabel( const QString& text, QQuickItem* parent = nullptr ) + : QskTextLabel( text, parent ) { setBackgroundColor( Qt::black ); setTextColor( Qt::white ); diff --git a/examples/listbox/main.cpp b/examples/listbox/main.cpp index a7d6f32c3..c4a63dab4 100644 --- a/examples/listbox/main.cpp +++ b/examples/listbox/main.cpp @@ -6,17 +6,17 @@ #include #include +#include #include #include #include -#include -#include #include +#include class ListBox : public QskSimpleListBox { -public: + public: ListBox() { using namespace QskAspect; @@ -31,7 +31,8 @@ class ListBox : public QskSimpleListBox setSelectedRow( 5 ); } -private: + + private: void populate() { const QString format( "Row %1: The quick brown fox jumps over the lazy dog" ); diff --git a/examples/messagebox/main.cpp b/examples/messagebox/main.cpp index aca184c2a..e7c50314a 100644 --- a/examples/messagebox/main.cpp +++ b/examples/messagebox/main.cpp @@ -6,23 +6,23 @@ #include #include -#include #include +#include #include -#include -#include +#include +#include #include +#include #include -#include #include -#include +#include class Button : public QskPushButton { -public: - Button( const QString& text, QQuickItem* parent = nullptr ): - QskPushButton( text, parent ) + public: + Button( const QString& text, QQuickItem* parent = nullptr ) + : QskPushButton( text, parent ) { setObjectName( text ); setSizePolicy( QskSizePolicy::MinimumExpanding, @@ -32,9 +32,9 @@ class Button : public QskPushButton class ButtonBox : public QskLinearBox { -public: - ButtonBox( QQuickItem* parent = nullptr ): - QskLinearBox( Qt::Horizontal, 2, parent ) + public: + ButtonBox( QQuickItem* parent = nullptr ) + : QskLinearBox( Qt::Horizontal, 2, parent ) { setObjectName( "ButtonBox" ); @@ -60,7 +60,7 @@ class ButtonBox : public QskLinearBox connect( selectButton, &Button::clicked, this, &ButtonBox::execSelection ); } -private: + private: void execMessage() { qDebug() << qskDialog->message( "Message", "Request vector, over.", diff --git a/examples/messageboxQml/main.cpp b/examples/messageboxQml/main.cpp index d0be1182d..b88fc3a46 100644 --- a/examples/messageboxQml/main.cpp +++ b/examples/messageboxQml/main.cpp @@ -9,8 +9,8 @@ #include #include -#include #include +#include int main( int argc, char* argv[] ) { diff --git a/examples/qvgviewer/MainWindow.cpp b/examples/qvgviewer/MainWindow.cpp index bfab06e17..a90d87ff6 100644 --- a/examples/qvgviewer/MainWindow.cpp +++ b/examples/qvgviewer/MainWindow.cpp @@ -5,34 +5,34 @@ #include "MainWindow.h" +#include +#include +#include +#include #include -#include #include -#include +#include #include -#include -#include -#include +#include +#include #include #include -#include -#include -#include +#include #include #include class GraphicLabel : public QskGraphicLabel { -public: + public: enum Role { Normal, Inverted }; - GraphicLabel( const QskGraphic& graphic, QQuickItem* parent = nullptr ): - QskGraphicLabel( graphic, parent ) + GraphicLabel( const QskGraphic& graphic, QQuickItem* parent = nullptr ) + : QskGraphicLabel( graphic, parent ) { setAlignment( Qt::AlignCenter ); setAutoFillBackground( true ); diff --git a/examples/qvgviewer/MainWindow.h b/examples/qvgviewer/MainWindow.h index ad8e2e2fa..631f94244 100644 --- a/examples/qvgviewer/MainWindow.h +++ b/examples/qvgviewer/MainWindow.h @@ -15,14 +15,14 @@ class MainWindow : public QskWindow { Q_OBJECT -public: + public: MainWindow(); -private Q_SLOTS: + private Q_SLOTS: void setDarknessMode( bool on ); void setGraphicRoles( QskSkin* ); -private: + private: QskTabView* m_tabView; }; diff --git a/examples/sliders/Slider.cpp b/examples/sliders/Slider.cpp index 01abbfb14..2b814245f 100644 --- a/examples/sliders/Slider.cpp +++ b/examples/sliders/Slider.cpp @@ -1,17 +1,17 @@ #include "Slider.h" #include "SliderSkinlet.h" +#include #include -#include #include #include -#include +#include QSK_SUBCONTROL( Slider, Scale ) QSK_SUBCONTROL( Slider, Decoration ) -Slider::Slider( QQuickItem* parentItem ): - QskSlider( parentItem ) +Slider::Slider( QQuickItem* parentItem ) + : QskSlider( parentItem ) { using namespace QskAspect; diff --git a/examples/sliders/Slider.h b/examples/sliders/Slider.h index 5d072c4ef..3d864fa57 100644 --- a/examples/sliders/Slider.h +++ b/examples/sliders/Slider.h @@ -12,7 +12,7 @@ class Slider : public QskSlider { using Inherited = QskSlider; -public: + public: QSK_SUBCONTROLS( Scale, Decoration ) Slider( QQuickItem* parent = nullptr ); diff --git a/examples/sliders/SliderSkinlet.cpp b/examples/sliders/SliderSkinlet.cpp index 74469af89..7931de665 100644 --- a/examples/sliders/SliderSkinlet.cpp +++ b/examples/sliders/SliderSkinlet.cpp @@ -7,14 +7,14 @@ #include "Slider.h" #include -#include #include +#include +#include #include #include -#include -#include #include +#include #include @@ -30,9 +30,9 @@ static QFont qskLabelFont; class TicksNode : public QSGGeometryNode { -public: - TicksNode( const QColor& color ): - m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) + public: + TicksNode( const QColor& color ) + : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) { m_geometry.setDrawingMode( GL_LINES ); m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); @@ -43,16 +43,16 @@ class TicksNode : public QSGGeometryNode setMaterial( &m_material ); } -private: + private: QSGFlatColorMaterial m_material; QSGGeometry m_geometry; }; class HandleNode : public QSGGeometryNode { -public: - HandleNode(): - m_geometry( QSGGeometry::defaultAttributes_Point2D(), 8 * 2 ) + public: + HandleNode() + : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 8 * 2 ) { setGeometry( &m_geometry ); setMaterial( &m_material ); @@ -93,14 +93,14 @@ class HandleNode : public QSGGeometryNode } } -private: + private: inline void setLine( QSGGeometry::Point2D* points, float x1, float x2, qreal y ) { - points[0].x = x1; - points[0].y = y; + points[ 0 ].x = x1; + points[ 0 ].y = y; - points[1].x = x2; - points[1].y = y; + points[ 1 ].x = x2; + points[ 1 ].y = y; } QRectF m_rect; @@ -121,8 +121,8 @@ SliderSkinlet::~SliderSkinlet() { } -QRectF SliderSkinlet::subControlRect( const QskSkinnable* skinnable, - QskAspect::Subcontrol subControl ) const +QRectF SliderSkinlet::subControlRect( + const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const { const auto slider = static_cast< const QskSlider* >( skinnable ); @@ -155,7 +155,7 @@ QSGNode* SliderSkinlet::updateSubNode( { const auto slider = static_cast< const QskSlider* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case ScaleRole: return updateScaleNode( slider, node ); @@ -251,8 +251,8 @@ QSGNode* SliderSkinlet::updateScaleNode( // Create a series of tickmarks from minimum to maximum for ( int i = 0; i < tickCount; ++i ) { - vertexData[0].set( x, y ); - vertexData[1].set( x, y - ( ( i % 10 ) ? qskMinorTick : qskMajorTick ) ); + vertexData[ 0 ].set( x, y ); + vertexData[ 1 ].set( x, y - ( ( i % 10 ) ? qskMinorTick : qskMajorTick ) ); vertexData += 2; x += stepStride; @@ -333,7 +333,7 @@ QSGNode* SliderSkinlet::updateHandleNode( // finally the value label auto labelNode = static_cast< QskTextNode* >( handleNode->firstChild() ); - if ( labelNode == nullptr ) + if ( labelNode == nullptr ) { labelNode = new QskTextNode; handleNode->appendChildNode( labelNode ); @@ -349,9 +349,8 @@ QSGNode* SliderSkinlet::updateHandleNode( const QString text = QString::number( slider->value(), 'f', 0 ); - labelNode->setTextData( slider, text, textRect, - font, QskTextOptions(), QskTextColors( Qt::white ), - Qt::AlignHCenter, Qsk::Normal ); + labelNode->setTextData( slider, text, textRect, font, QskTextOptions(), + QskTextColors( Qt::white ), Qt::AlignHCenter, Qsk::Normal ); return handleNode; } diff --git a/examples/sliders/SliderSkinlet.h b/examples/sliders/SliderSkinlet.h index 89ad91d1c..a970aa99a 100644 --- a/examples/sliders/SliderSkinlet.h +++ b/examples/sliders/SliderSkinlet.h @@ -14,7 +14,7 @@ class SliderSkinlet : public QskSliderSkinlet { using Inherited = QskSliderSkinlet; -public: + public: enum NodeRole { // we have a scale instead of a groove @@ -28,11 +28,11 @@ class SliderSkinlet : public QskSliderSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: - QSGNode* updateSubNode( - const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; + protected: + QSGNode* updateSubNode( const QskSkinnable*, + quint8 nodeRole, QSGNode* ) const override; -private: + private: QSGNode* updateScaleNode( const QskSlider*, QSGNode* ) const; QSGNode* updateDecorationNode( const QskSlider*, QSGNode* ) const; QSGNode* updateHandleNode( const QskSlider*, QSGNode* ) const; diff --git a/examples/sliders/main.cpp b/examples/sliders/main.cpp index d4a902fbb..10f1d5514 100644 --- a/examples/sliders/main.cpp +++ b/examples/sliders/main.cpp @@ -9,31 +9,31 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include -#include -#include +#include #include -#include -#include -#include +#include +#include +#include +#include #include #include class OtherSlider : public QskSlider { -public: + public: /* Slider overriding many hints from the skin. "Preserved" is for horizontal, "Transposed" for vertical orientation */ - OtherSlider( QQuickItem* parentItem = nullptr ): - QskSlider( parentItem ) + OtherSlider( QQuickItem* parentItem = nullptr ) + : QskSlider( parentItem ) { using namespace QskAspect; using namespace QskRgbValue; @@ -79,13 +79,13 @@ class OtherSlider : public QskSlider const Aspect aspect = Fill | placement; setMetric( aspect | Size, 0 ); } - + // Handle for ( auto placement : { Preserved, Transposed } ) { const Aspect aspect = Handle | placement; - + setBoxBorderMetricsHint( aspect, 1 ); setBoxShapeHint( aspect, 4 ); @@ -107,9 +107,9 @@ class OtherSlider : public QskSlider class SliderBox : public QskLinearBox { -public: - SliderBox( QQuickItem* parentItem = nullptr ): - QskLinearBox( Qt::Vertical, parentItem ) + public: + SliderBox( QQuickItem* parentItem = nullptr ) + : QskLinearBox( Qt::Vertical, parentItem ) { auto slider = new QskSlider( this ); slider->setMinimum( 0 ); @@ -118,7 +118,7 @@ class SliderBox : public QskLinearBox slider->setStepSize( 10 ); slider->setSnap( true ); - (void) new QskSeparator( Qt::Horizontal, this ); + ( void ) new QskSeparator( Qt::Horizontal, this ); auto otherSlider = new OtherSlider( this ); @@ -138,7 +138,7 @@ class SliderBox : public QskLinearBox { if ( QskSlider* slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) ) { - slider->setObjectName( "Slider " + QString::number(i + 1) ); + slider->setObjectName( "Slider " + QString::number( i + 1 ) ); slider->setValue( slider->minimum() + 0.5 * ( slider->maximum() - slider->minimum() ) ); #if 0 @@ -177,7 +177,7 @@ class SliderBox : public QskLinearBox } } -private: + private: Qt::Orientation inverted( Qt::Orientation orientation ) const { return ( orientation == Qt::Horizontal ) ? Qt::Vertical : Qt::Horizontal; diff --git a/examples/tabview/main.cpp b/examples/tabview/main.cpp index b6f7d38e2..855643d88 100644 --- a/examples/tabview/main.cpp +++ b/examples/tabview/main.cpp @@ -7,24 +7,24 @@ #include #include +#include +#include +#include #include -#include -#include -#include -#include #include -#include -#include -#include #include +#include +#include +#include +#include #include class Label : public QskTextLabel { -public: - Label( const QString& text, QQuickItem* parent = nullptr ): - QskTextLabel( text, parent ) + public: + Label( const QString& text, QQuickItem* parent = nullptr ) + : QskTextLabel( text, parent ) { setTextColor( Qt::darkRed ); setFontRole( QskSkin::LargeFont ); @@ -34,9 +34,9 @@ class Label : public QskTextLabel class TabView : public QskTabView { -public: - TabView( QQuickItem* parent = nullptr ): - QskTabView( parent ) + public: + TabView( QQuickItem* parent = nullptr ) + : QskTabView( parent ) { for ( int i = 0; i < 6; i++ ) { diff --git a/examples/thumbnails/main.cpp b/examples/thumbnails/main.cpp index ec47e987e..8245314b1 100644 --- a/examples/thumbnails/main.cpp +++ b/examples/thumbnails/main.cpp @@ -3,20 +3,20 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include #include +#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include @@ -50,7 +50,7 @@ static QColor randomColor() "DarkSlateGray" }; - const int index = qrand() % int( ( sizeof( colors ) / sizeof( colors[0] ) ) ); + const int index = qrand() % int( ( sizeof( colors ) / sizeof( colors[ 0 ] ) ) ); return QColor( colors[ index ] ); } @@ -61,9 +61,9 @@ static int randomShape() class Thumbnail : public QskPushButton { -public: - Thumbnail( const QColor& color, int shape, QQuickItem* parentItem ): - QskPushButton( parentItem ) + public: + Thumbnail( const QColor& color, int shape, QQuickItem* parentItem ) + : QskPushButton( parentItem ) { using namespace SkinnyShapeFactory; @@ -92,9 +92,9 @@ class Thumbnail : public QskPushButton class IconGrid : public QskLinearBox { -public: - IconGrid( QQuickItem* parentItem = nullptr ): - QskLinearBox( Qt::Horizontal, gridSize, parentItem ) + public: + IconGrid( QQuickItem* parentItem = nullptr ) + : QskLinearBox( Qt::Horizontal, gridSize, parentItem ) { setMargins( 20 ); setSpacing( 20 ); @@ -102,16 +102,16 @@ class IconGrid : public QskLinearBox for ( int col = 0; col < gridSize; col++ ) { for ( int row = 0; row < gridSize; row++ ) - (void) new Thumbnail( randomColor(), randomShape(), this ); + ( void ) new Thumbnail( randomColor(), randomShape(), this ); } } }; class ScrollArea : public QskScrollArea { -public: - ScrollArea( QQuickItem* parentItem = nullptr ) : - QskScrollArea( parentItem ) + public: + ScrollArea( QQuickItem* parentItem = nullptr ) + : QskScrollArea( parentItem ) { using namespace QskAspect; @@ -146,10 +146,10 @@ int main( int argc, char* argv[] ) with QskListView. The thumbnails are implemented as buttons, so that we can see if the gesture - recognition for the flicking works without stopping the buttons from being functional. + recognition for the flicking works without stopping the buttons from being functional. This example also shows, that blocking of the scene graph node creation - ( QskControl::DeferredUpdate + QskControl::CleanupOnVisibility ) + ( QskControl::DeferredUpdate + QskControl::CleanupOnVisibility ) could be improved to also respect being inside the window or a clip region. But here we only want to demonstrate how QskScrollArea works. @@ -161,8 +161,8 @@ int main( int argc, char* argv[] ) auto buttonBox = new QskLinearBox( Qt::Horizontal, box ); buttonBox->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed ); - new QskPushButton( "Push Me", buttonBox ); - new QskPushButton( "Push Me", buttonBox ); + new QskPushButton( "Push Me", buttonBox ); + new QskPushButton( "Push Me", buttonBox ); auto scrollArea = new ScrollArea( box ); scrollArea->setMargins( QMarginsF( 25, 25, 5, 5 ) ); diff --git a/examples/tlabels/main.cpp b/examples/tlabels/main.cpp index f420a0403..3e065c5a7 100644 --- a/examples/tlabels/main.cpp +++ b/examples/tlabels/main.cpp @@ -6,25 +6,25 @@ #include #include -#include #include +#include #include #include #include -class TextBox: public QskLinearBox +class TextBox : public QskLinearBox { -public: - TextBox( QQuickItem* parent = nullptr ): - QskLinearBox( Qt::Vertical, 3, parent ) + public: + TextBox( QQuickItem* parent = nullptr ) + : QskLinearBox( Qt::Vertical, 3, parent ) { - const QStringList texts = { "Default", "Tiny", "Small", - "Medium", "Large", "Huge" }; + const QStringList texts = + { "Default", "Tiny", "Small", "Medium", "Large", "Huge" }; for ( int i = 0; i < texts.size(); i++ ) { - auto label = new QskTextLabel( texts[i] + " Font", this ); + auto label = new QskTextLabel( texts[ i ] + " Font", this ); label->setFontRole( i ); } } diff --git a/inputcontext/QskHunspellTextPredictor.cpp b/inputcontext/QskHunspellTextPredictor.cpp index 92e66c44a..511bf3f46 100644 --- a/inputcontext/QskHunspellTextPredictor.cpp +++ b/inputcontext/QskHunspellTextPredictor.cpp @@ -5,14 +5,14 @@ class QskHunspellTextPredictor::PrivateData { -public: + public: Hunhandle* hunspellHandle; QVector< QString > candidates; }; -QskHunspellTextPredictor::QskHunspellTextPredictor( QObject* object ): - Inherited( Words, object ), - m_data( new PrivateData() ) +QskHunspellTextPredictor::QskHunspellTextPredictor( QObject* object ) + : Inherited( Words, object ) + , m_data( new PrivateData() ) { #if 1 // TODO: loading the language specific one depending on the locale @@ -58,11 +58,11 @@ void QskHunspellTextPredictor::request( const QString& text ) QVector< QString > candidates; candidates.reserve( count ); - for( int i = 0; i < count; i++ ) + for ( int i = 0; i < count; i++ ) { - const QString suggestion = QString::fromUtf8( suggestions[i] ); // ### encoding? + const QString suggestion = QString::fromUtf8( suggestions[ i ] ); // ### encoding? - if( suggestion.startsWith( text ) ) + if ( suggestion.startsWith( text ) ) candidates.prepend( suggestion ); else candidates.append( suggestion ); diff --git a/inputcontext/QskHunspellTextPredictor.h b/inputcontext/QskHunspellTextPredictor.h index 8e673939b..4054ec334 100644 --- a/inputcontext/QskHunspellTextPredictor.h +++ b/inputcontext/QskHunspellTextPredictor.h @@ -13,18 +13,18 @@ class QSK_EXPORT QskHunspellTextPredictor : public QskTextPredictor { using Inherited = QskTextPredictor; -public: + public: QskHunspellTextPredictor( QObject* = nullptr ); ~QskHunspellTextPredictor() override; int candidateCount() const override; QString candidate( int pos ) const override; -protected: + protected: void request( const QString& ) override; void reset() override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/inputcontext/QskInputContextPlugin.cpp b/inputcontext/QskInputContextPlugin.cpp index 28712d6aa..b33f11c56 100644 --- a/inputcontext/QskInputContextPlugin.cpp +++ b/inputcontext/QskInputContextPlugin.cpp @@ -3,8 +3,8 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ -#include #include +#include #include "QskInputContext.h" @@ -14,15 +14,15 @@ #include "QskHunspellTextPredictor.h" #endif +#include #include #include -#include namespace { class InputContextFactory : public QskInputContextFactory { - public: + public: virtual QskTextPredictor* createPredictor( const QLocale& locale ) const { #if HUNSPELL @@ -49,7 +49,7 @@ class QskPlatformInputContext final : public QPlatformInputContext using Inherited = QPlatformInputContext; -public: + public: QskPlatformInputContext(); virtual ~QskPlatformInputContext() = default; @@ -80,10 +80,10 @@ class QskPlatformInputContext final : public QPlatformInputContext bool filterEvent( const QEvent* ) override; -protected: + protected: bool event( QEvent* ) override; -private: + private: void updateContext(); void updateLocale(); @@ -129,13 +129,13 @@ void QskPlatformInputContext::updateLocale() { const auto oldLocale = m_locale; m_locale = m_context->locale(); - + if ( oldLocale != m_locale ) emitLocaleChanged(); - + if ( m_locale.textDirection() != oldLocale.textDirection() ) - emitInputDirectionChanged( m_locale.textDirection() ); - } + emitInputDirectionChanged( m_locale.textDirection() ); + } } bool QskPlatformInputContext::isValid() const @@ -165,7 +165,7 @@ void QskPlatformInputContext::update( void QskPlatformInputContext::invokeAction( QInputMethod::Action action, int cursorPosition ) { - if ( m_context ) + if ( m_context ) m_context->invokeAction( action, cursorPosition ); } @@ -246,7 +246,7 @@ bool QskPlatformInputContext::filterEvent( const QEvent* ) bool QskPlatformInputContext::event( QEvent* event ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::LocaleChange: { @@ -270,7 +270,7 @@ class QskInputContextPlugin final : public QPlatformInputContextPlugin Q_OBJECT Q_PLUGIN_METADATA( IID QPlatformInputContextFactoryInterface_iid FILE "metadata.json" ) -public: + public: QPlatformInputContext* create( const QString& system, const QStringList& ) override { diff --git a/inputcontext/QskPinyinTextPredictor.cpp b/inputcontext/QskPinyinTextPredictor.cpp index f2605dcda..4c849ab6d 100644 --- a/inputcontext/QskPinyinTextPredictor.cpp +++ b/inputcontext/QskPinyinTextPredictor.cpp @@ -8,18 +8,18 @@ #include "pinyinime.h" -#include #include +#include class QskPinyinTextPredictor::PrivateData { -public: + public: QStringList candidates; }; -QskPinyinTextPredictor::QskPinyinTextPredictor( QObject* parent ): - Inherited( Attributes(), parent ), - m_data( new PrivateData ) +QskPinyinTextPredictor::QskPinyinTextPredictor( QObject* parent ) + : Inherited( Attributes(), parent ) + , m_data( new PrivateData ) { #if 1 const char dictionary[] = "XXX/3rdparty/pinyin/data/dict_pinyin.dat"; @@ -28,7 +28,7 @@ QskPinyinTextPredictor::QskPinyinTextPredictor( QObject* parent ): // ### prevent having 2 calls to im_open_decoder by using a singleton or so bool opened = ime_pinyin::im_open_decoder( dictionary, "" ); - if( !opened ) + if ( !opened ) { qWarning() << "could not open pinyin decoder dictionary at" << dictionary; } @@ -70,21 +70,20 @@ void QskPinyinTextPredictor::request( const QString& text ) size_t count = ime_pinyin::im_search( bytes.constData(), size_t( bytes.length() ) ); - if( count <= 0 ) + if ( count <= 0 ) return; const size_t maxCount = 20; - if ( count > maxCount ) + if ( count > maxCount ) count = maxCount; QVector< QChar > candidateBuffer; candidateBuffer.resize( ime_pinyin::kMaxSearchSteps + 1 ); - QStringList candidates; candidates.reserve( count ); - for( unsigned int i = 0; i < count; i++ ) + for ( unsigned int i = 0; i < count; i++ ) { size_t length = static_cast< size_t >( candidateBuffer.length() - 1 ); const auto buf = reinterpret_cast< ime_pinyin::char16* >( candidateBuffer.data() ); @@ -95,7 +94,7 @@ void QskPinyinTextPredictor::request( const QString& text ) candidateBuffer.last() = 0; auto candidate = QString( candidateBuffer.data() ); - candidate = QChar( Qt::Key( candidate[0].unicode() ) ); + candidate = QChar( Qt::Key( candidate[ 0 ].unicode() ) ); candidates += candidate; } diff --git a/inputcontext/QskPinyinTextPredictor.h b/inputcontext/QskPinyinTextPredictor.h index d9981bdff..00fa19184 100644 --- a/inputcontext/QskPinyinTextPredictor.h +++ b/inputcontext/QskPinyinTextPredictor.h @@ -13,18 +13,18 @@ class QSK_EXPORT QskPinyinTextPredictor : public QskTextPredictor { using Inherited = QskTextPredictor; -public: + public: QskPinyinTextPredictor( QObject* = nullptr ); ~QskPinyinTextPredictor() override; int candidateCount() const override; QString candidate( int ) const override; -protected: + protected: void request( const QString& ) override; void reset() override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/playground/images/Image.cpp b/playground/images/Image.cpp index c4ccb47a5..25b7ccf47 100644 --- a/playground/images/Image.cpp +++ b/playground/images/Image.cpp @@ -10,12 +10,12 @@ class Image::PrivateData { -public: - PrivateData(): - sourceSizeAdjustment( false ), - deferredUpdates( true ), - dirtyPolish( false ), - dirtyUpdate( false ) + public: + PrivateData() + : sourceSizeAdjustment( false ) + , deferredUpdates( true ) + , dirtyPolish( false ) + , dirtyUpdate( false ) { } @@ -26,9 +26,9 @@ class Image::PrivateData bool dirtyUpdate : 1; }; -Image::Image( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +Image::Image( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { } @@ -124,8 +124,8 @@ void Image::itemChange( QQuickItem::ItemChange change, } } -void Image::geometryChanged( const QRectF& newGeometry, - const QRectF& oldGeometry ) +void Image::geometryChanged( + const QRectF& newGeometry, const QRectF& oldGeometry ) { Inherited::geometryChanged( newGeometry, oldGeometry ); diff --git a/playground/images/Image.h b/playground/images/Image.h index 36e015752..6beabcfc8 100644 --- a/playground/images/Image.h +++ b/playground/images/Image.h @@ -33,7 +33,7 @@ class Image : public QQuickImage using Inherited = QQuickImage; -public: + public: Image( QQuickItem* parent = nullptr ); ~Image() override; @@ -49,16 +49,16 @@ class Image : public QQuickImage Q_INVOKABLE virtual bool hasWidthForHeight() const; Q_INVOKABLE virtual qreal widthForHeight( qreal height ) const; -public Q_SLOTS: + public Q_SLOTS: void show(); void hide(); void setVisible( bool ); -Q_SIGNALS: + Q_SIGNALS: void sourceSizeAdjustmentChanged(); void deferredUpdatesChanged(); -protected: + protected: void geometryChanged( const QRectF&, const QRectF& ) override; void itemChange( ItemChange, const ItemChangeData& ) override; void componentComplete() override; @@ -66,7 +66,7 @@ public Q_SLOTS: QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override; void updatePolish() override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/playground/images/main.cpp b/playground/images/main.cpp index 584dbf29c..af3c343f6 100644 --- a/playground/images/main.cpp +++ b/playground/images/main.cpp @@ -8,12 +8,12 @@ #include #include -#include #include +#include #include -#include #include +#include int main( int argc, char* argv[] ) { diff --git a/playground/inputpanel/main.cpp b/playground/inputpanel/main.cpp index 44f173dcb..df99a7a04 100644 --- a/playground/inputpanel/main.cpp +++ b/playground/inputpanel/main.cpp @@ -8,26 +8,26 @@ #include #include +#include +#include #include #include #include -#include -#include -#include #include +#include #include -#include #include +#include -#define STRINGIFY(x) #x -#define STRING(x) STRINGIFY(x) +#define STRINGIFY( x ) #x +#define STRING( x ) STRINGIFY( x ) static inline QString nativeLocaleString( const QLocale& locale ) { - switch( locale.language() ) + switch ( locale.language() ) { case QLocale::Bulgarian: return QStringLiteral( "български език" ); @@ -46,7 +46,7 @@ static inline QString nativeLocaleString( const QLocale& locale ) case QLocale::English: { - switch( locale.country() ) + switch ( locale.country() ) { case QLocale::Canada: case QLocale::UnitedStates: @@ -92,7 +92,7 @@ static inline QString nativeLocaleString( const QLocale& locale ) case QLocale::Romanian: return QStringLiteral( "Română" ); - case QLocale::Russia: + case QLocale::Russian: return QStringLiteral( "Русский" ); case QLocale::Slovenian: @@ -114,9 +114,9 @@ static inline QString nativeLocaleString( const QLocale& locale ) class InputBox : public QskLinearBox { -public: - InputBox( QQuickItem* parentItem = nullptr ): - QskLinearBox( Qt::Vertical, parentItem ) + public: + InputBox( QQuickItem* parentItem = nullptr ) + : QskLinearBox( Qt::Vertical, parentItem ) { setExtraSpacingAt( Qt::BottomEdge | Qt::RightEdge ); @@ -150,10 +150,10 @@ class LocaleListView final : public QskListView { Q_OBJECT -public: - LocaleListView( QQuickItem* parentItem = nullptr ): - QskListView( parentItem ), - m_maxWidth( 0.0 ) + public: + LocaleListView( QQuickItem* parentItem = nullptr ) + : QskListView( parentItem ) + , m_maxWidth( 0.0 ) { for ( auto language : { @@ -166,7 +166,6 @@ class LocaleListView final : public QskListView QLocale::Slovak, QLocale::Turkish, QLocale::Chinese } ) { - if ( language == QLocale::English ) { append( QLocale( QLocale::English, QLocale::UnitedStates ) ); @@ -227,21 +226,21 @@ class LocaleListView final : public QskListView QVariant valueAt( int row, int ) const override { - return m_values[row].first; + return m_values[ row ].first; } QLocale localeAt( int row ) const { if ( row >= 0 && row < m_values.size() ) - return m_values[row].second; + return m_values[ row ].second; return QLocale(); } -Q_SIGNALS: + Q_SIGNALS: void selected( const QLocale& ); -private: + private: inline void append( const QLocale& locale ) { m_values += qMakePair( nativeLocaleString( locale ), locale ); @@ -253,7 +252,7 @@ class LocaleListView final : public QskListView class Window : public QskWindow { -public: + public: Window() { populate(); @@ -266,7 +265,7 @@ class Window : public QskWindow box->setMargins( 20 ); auto listView = new LocaleListView( box ); - auto inputBox = new InputBox( box ); + auto inputBox = new InputBox( box ); /* Disable Qt::ClickFocus, so that the input panel stays open diff --git a/playground/invoker/Callback.cpp b/playground/invoker/Callback.cpp index cfa8f846a..05b38e23b 100644 --- a/playground/invoker/Callback.cpp +++ b/playground/invoker/Callback.cpp @@ -6,31 +6,31 @@ #include "Callback.h" #include -Callback::Callback(): - m_context( nullptr ) +Callback::Callback() + : m_context( nullptr ) { } -Callback::Callback( const QObject* context, const QMetaMethod& method ): - m_context( const_cast< QObject* >( context ) ), - m_invokable( method ) +Callback::Callback( const QObject* context, const QMetaMethod& method ) + : m_context( const_cast< QObject* >( context ) ) + , m_invokable( method ) { } -Callback::Callback( const QObject* context, const char* methodName ): - Callback( context, qskMetaMethod( context, methodName ) ) +Callback::Callback( const QObject* context, const char* methodName ) + : Callback( context, qskMetaMethod( context, methodName ) ) { } -Callback::Callback( const QObject* context, const QMetaProperty& property ): - m_context( const_cast< QObject* >( context ) ), - m_invokable( property ) +Callback::Callback( const QObject* context, const QMetaProperty& property ) + : m_context( const_cast< QObject* >( context ) ) + , m_invokable( property ) { } -Callback::Callback( const QObject* context, const QskMetaFunction& function ): - m_context( const_cast< QObject* >( context ) ), - m_invokable( function ) +Callback::Callback( const QObject* context, const QskMetaFunction& function ) + : m_context( const_cast< QObject* >( context ) ) + , m_invokable( function ) { } diff --git a/playground/invoker/Callback.h b/playground/invoker/Callback.h index 32fa2b3cd..00c67e22b 100644 --- a/playground/invoker/Callback.h +++ b/playground/invoker/Callback.h @@ -12,7 +12,7 @@ class QObject; class Callback { -public: + public: Callback(); Callback( const QObject*, const QskMetaFunction& ); @@ -26,7 +26,7 @@ class Callback const QObject* context() const; const QskMetaInvokable& invokable() const; -private: + private: QObject* m_context; QskMetaInvokable m_invokable; }; diff --git a/playground/invoker/Invoker.cpp b/playground/invoker/Invoker.cpp index 83a604412..a2af5661b 100644 --- a/playground/invoker/Invoker.cpp +++ b/playground/invoker/Invoker.cpp @@ -5,28 +5,28 @@ #include "Invoker.h" -#include #include +#include -Invoker::Invoker( QObject* parent ): - QObject( parent ) +Invoker::Invoker( QObject* parent ) + : QObject( parent ) { } -void Invoker::addFunctionCall( const QObject* object, - const QskMetaFunction& function ) +void Invoker::addFunctionCall( + const QObject* object, const QskMetaFunction& function ) { m_callbacks.append( Callback( object, function ) ); } -void Invoker::addMethodCall( const QObject* object, - const char* methodName ) +void Invoker::addMethodCall( + const QObject* object, const char* methodName ) { m_callbacks.append( Callback( object, methodName ) ); } -void Invoker::addPropertyCall( const QObject* object, - const char* property ) +void Invoker::addPropertyCall( + const QObject* object, const char* property ) { const auto metaProperty = object->metaObject()->property( object->metaObject()->indexOfProperty( property ) ); @@ -34,16 +34,16 @@ void Invoker::addPropertyCall( const QObject* object, m_callbacks.append( Callback( object, metaProperty ) ); } -void Invoker::invoke( qreal realValue, int intValue, - Qt::ConnectionType connectionType ) +void Invoker::invoke( + qreal realValue, int intValue, Qt::ConnectionType connectionType ) { QString s = QString( "S: %1 + %2" ).arg( realValue ).arg( intValue ); for ( auto& callback : m_callbacks ) { - void* args[4] = { nullptr }; + void* args[ 4 ] = { nullptr }; - void **a = args + 1; + void** a = args + 1; const auto& invokable = callback.invokable(); for ( int i = 0; i < invokable.parameterCount(); i++ ) @@ -70,7 +70,7 @@ void Invoker::invoke( qreal realValue, int intValue, } } - switch( connectionType & 0x3 ) + switch ( connectionType & 0x3 ) { case Qt::DirectConnection: { diff --git a/playground/invoker/Invoker.h b/playground/invoker/Invoker.h index 3cbe7bef5..32f867242 100644 --- a/playground/invoker/Invoker.h +++ b/playground/invoker/Invoker.h @@ -14,7 +14,7 @@ class Invoker : public QObject { -public: + public: Invoker( QObject* parent = nullptr ); void addFunctionCall( const QskMetaFunction& ); @@ -25,7 +25,7 @@ class Invoker : public QObject void invoke( qreal d, int i, Qt::ConnectionType ); -private: + private: QVector< Callback > m_callbacks; }; diff --git a/playground/invoker/main.cpp b/playground/invoker/main.cpp index e8680e2a7..8fe13ac43 100644 --- a/playground/invoker/main.cpp +++ b/playground/invoker/main.cpp @@ -4,10 +4,11 @@ *****************************************************************************/ #include "Invoker.h" + #include #include -#include #include +#include void debugNone1() { @@ -47,9 +48,9 @@ class MyObject : public QObject Q_PROPERTY( qreal value WRITE setValue ) Q_PROPERTY( QString valueString WRITE setValueString ) -public: - MyObject( QObject* parent = nullptr ): - QObject( parent ) + public: + MyObject( QObject* parent = nullptr ) + : QObject( parent ) { } @@ -73,7 +74,7 @@ class MyObject : public QObject qDebug() << "setValueString" << s; } -public Q_SLOTS: + public Q_SLOTS: void print0( double d, int i ) const { qDebug() << "print0" << d << i; @@ -109,11 +110,11 @@ static auto fs = []( int i, double d ) { qDebug() << i << d; }; class Application : public QCoreApplication { -public: - Application( int& argc, char* argv[] ): - QCoreApplication( argc, argv ), - m_object( new MyObject() ), - m_thread( new QThread( this ) ) + public: + Application( int& argc, char* argv[] ) + : QCoreApplication( argc, argv ) + , m_object( new MyObject() ) + , m_thread( new QThread( this ) ) { #if 1 m_invoker.addPropertyCall( m_object, "number" ); @@ -124,7 +125,7 @@ class Application : public QCoreApplication #if 1 m_invoker.addMethodCall( m_object, "print0(double,int)" ); m_invoker.addMethodCall( m_object, "print1(double,int)" ); - m_invoker.addMethodCall( m_object, SLOT(print2(int,double)) ); + m_invoker.addMethodCall( m_object, SLOT( print2( int, double ) ) ); m_invoker.addMethodCall( m_object, "print3(double)" ); m_invoker.addMethodCall( m_object, "print4(int)" ); m_invoker.addMethodCall( m_object, "print4(int)" ); @@ -194,7 +195,7 @@ class Application : public QCoreApplication QTimer::singleShot( 10, m_thread, &QThread::quit ); } -private: + private: Invoker m_invoker; MyObject* m_object; QThread* m_thread; diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index 8461ed10d..1f8162292 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -5,8 +5,8 @@ #include "QskMaterialSkin.h" -#include #include +#include #include #include #include @@ -16,24 +16,24 @@ #include #include #include -#include #include +#include #include -#include #include +#include #include #include +#include #include -#include +#include +#include +#include #include -#include -#include #include -#include -#include -#include +#include +#include #if 1 // should be defined in the public header, so that @@ -55,7 +55,7 @@ namespace { class ColorPalette { - public: + public: ColorPalette( const QColor base = QColor::fromRgba( QskRgbValue::Grey100 ), const QColor& accent = QColor::fromRgba( QskRgbValue::Blue500 ), const QColor& contrast = QColor::fromRgba( QskRgbValue::White ) ) @@ -95,13 +95,13 @@ namespace class QskMaterialSkin::PrivateData { -public: + public: ColorPalette palette; }; -QskMaterialSkin::QskMaterialSkin( QObject* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskMaterialSkin::QskMaterialSkin( QObject* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { m_data->palette = ColorPalette( QskRgbValue::Grey100, QskRgbValue::Blue500, QskRgbValue::White ); @@ -190,7 +190,7 @@ void QskMaterialSkin::initTextLabelHints() const ColorPalette& pal = m_data->palette; setSkinHint( Q::Text | Alignment, Qt::AlignCenter ); - setColor( Q::Text, pal.textColor ); + setColor( Q::Text, pal.textColor ); } void QskMaterialSkin::initTextInputHints() @@ -199,13 +199,13 @@ void QskMaterialSkin::initTextInputHints() using Q = QskTextInput; setSkinHint( Q::Text | Alignment, - static_cast( Qt::AlignLeft | Qt::AlignTop ) ); + static_cast< int >( Qt::AlignLeft | Qt::AlignTop ) ); const ColorPalette& pal = m_data->palette; - setColor( Q::Text, pal.textColor ); - setColor( Q::PanelSelected, pal.accentColor ); - setColor( Q::TextSelected, pal.contrastColor ); + setColor( Q::Text, pal.textColor ); + setColor( Q::PanelSelected, pal.accentColor ); + setColor( Q::TextSelected, pal.contrastColor ); setMargins( Q::Panel | Padding, 5 ); setBoxShape( Q::Panel, 4 ); diff --git a/skins/material/QskMaterialSkin.h b/skins/material/QskMaterialSkin.h index 0afcf5e7a..000104df8 100644 --- a/skins/material/QskMaterialSkin.h +++ b/skins/material/QskMaterialSkin.h @@ -15,11 +15,11 @@ class QSK_EXPORT QskMaterialSkin : public QskSkin using Inherited = QskSkin; -public: + public: QskMaterialSkin( QObject* parent = nullptr ); ~QskMaterialSkin() override; -private: + private: void resetColors( const QColor& accent ) override; void initHints(); diff --git a/skins/material/QskMaterialSkinFactory.cpp b/skins/material/QskMaterialSkinFactory.cpp index e4325ae66..1b68a4aa3 100644 --- a/skins/material/QskMaterialSkinFactory.cpp +++ b/skins/material/QskMaterialSkinFactory.cpp @@ -8,8 +8,8 @@ static const QString materialSkinName = QStringLiteral( "material" ); -QskMaterialSkinFactory::QskMaterialSkinFactory( QObject* parent ): - QskSkinFactory( parent ) +QskMaterialSkinFactory::QskMaterialSkinFactory( QObject* parent ) + : QskSkinFactory( parent ) { } diff --git a/skins/material/QskMaterialSkinFactory.h b/skins/material/QskMaterialSkinFactory.h index 7bb85066b..6ef9992e3 100644 --- a/skins/material/QskMaterialSkinFactory.h +++ b/skins/material/QskMaterialSkinFactory.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskMaterialSkinFactory : public QskSkinFactory Q_PLUGIN_METADATA( IID QskSkinFactoryIID FILE "metadata.json" ) Q_INTERFACES( QskSkinFactory ) -public: + public: QskMaterialSkinFactory( QObject* parent = nullptr ); ~QskMaterialSkinFactory() override; diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index d01999a0f..c6b6ba810 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -5,37 +5,37 @@ #include "QskSquiekSkin.h" -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include #include +#include +#include #include -#include +#include #include +#include #include -#include -#include +#include +#include #include -#include -#include -#include #include +#include #include -#include +#include +#include +#include #include -#include -#include -#include #include -#include -#include -#include +#include +#include +#include static const int qskDuration = 200; @@ -43,7 +43,7 @@ namespace { class ColorPalette { - public: + public: ColorPalette( const QColor& themeColor = QskRgbValue::Silver ) { const bool isBright = themeColor.value() > 128; @@ -112,13 +112,13 @@ namespace class QskSquiekSkin::PrivateData { -public: + public: ColorPalette palette; }; -QskSquiekSkin::QskSquiekSkin( QObject* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskSquiekSkin::QskSquiekSkin( QObject* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { initHints(); setupFonts( "DejaVuSans" ); @@ -156,7 +156,7 @@ void QskSquiekSkin::setButton( QskGradient gradient; gradient.setOrientation( QskGradient::Vertical ); - switch( style ) + switch ( style ) { case Raised: { @@ -208,12 +208,12 @@ void QskSquiekSkin::setPanel( QskAspect::Aspect aspect, PanelStyle style ) setButton( aspect, style, 1 ); } -void QskSquiekSkin::setTab( QskAspect::Aspect aspect, - Qt::Orientation orientation ) +void QskSquiekSkin::setTab( QskAspect::Aspect aspect, Qt::Orientation orientation ) { const ColorPalette& pal = m_data->palette; - setGradient( aspect, QskGradient( QskGradient::Vertical, pal.lighter125, pal.lighter150 ) ); + setGradient( aspect, + QskGradient( QskGradient::Vertical, pal.lighter125, pal.lighter150 ) ); setBoxBorderColors( aspect, pal.darker200 ); QskBoxBorderMetrics border( 1 ); @@ -298,7 +298,7 @@ void QskSquiekSkin::initTextLabelHints() const ColorPalette& pal = m_data->palette; setSkinHint( Q::Text | Alignment, Qt::AlignCenter ); - setColor( Q::Text, pal.themeForeground ); + setColor( Q::Text, pal.themeForeground ); } void QskSquiekSkin::initTextInputHints() @@ -309,11 +309,11 @@ void QskSquiekSkin::initTextInputHints() const ColorPalette& pal = m_data->palette; setSkinHint( Q::Text | Alignment, - static_cast( Qt::AlignLeft | Qt::AlignTop ) ); + static_cast< int >( Qt::AlignLeft | Qt::AlignTop ) ); - setColor( Q::Text, pal.themeForeground ); - setColor( Q::PanelSelected, pal.highlighted ); - setColor( Q::TextSelected, pal.highlightedText ); + setColor( Q::Text, pal.themeForeground ); + setColor( Q::PanelSelected, pal.highlighted ); + setColor( Q::TextSelected, pal.highlightedText ); setMargins( Q::Panel | Padding, 5 ); setBoxBorderMetrics( Q::Panel, 2 ); diff --git a/skins/squiek/QskSquiekSkin.h b/skins/squiek/QskSquiekSkin.h index 099cf747a..e9a1e7426 100644 --- a/skins/squiek/QskSquiekSkin.h +++ b/skins/squiek/QskSquiekSkin.h @@ -15,11 +15,11 @@ class QSK_EXPORT QskSquiekSkin : public QskSkin using Inherited = QskSkin; -public: + public: QskSquiekSkin( QObject* parent = nullptr ); ~QskSquiekSkin() override; -private: + private: void resetColors( const QColor& accent ) override; void initHints(); diff --git a/skins/squiek/QskSquiekSkinFactory.cpp b/skins/squiek/QskSquiekSkinFactory.cpp index ef11fa06c..16c27524a 100644 --- a/skins/squiek/QskSquiekSkinFactory.cpp +++ b/skins/squiek/QskSquiekSkinFactory.cpp @@ -8,8 +8,8 @@ static const QString squiekSkinName = QStringLiteral( "squiek" ); -QskSquiekSkinFactory::QskSquiekSkinFactory( QObject* parent ): - QskSkinFactory( parent ) +QskSquiekSkinFactory::QskSquiekSkinFactory( QObject* parent ) + : QskSkinFactory( parent ) { } diff --git a/skins/squiek/QskSquiekSkinFactory.h b/skins/squiek/QskSquiekSkinFactory.h index be9df11d7..baba3ed87 100644 --- a/skins/squiek/QskSquiekSkinFactory.h +++ b/skins/squiek/QskSquiekSkinFactory.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskSquiekSkinFactory : public QskSkinFactory Q_PLUGIN_METADATA( IID QskSkinFactoryIID FILE "metadata.json" ) Q_INTERFACES( QskSkinFactory ) -public: + public: QskSquiekSkinFactory( QObject* parent = nullptr ); ~QskSquiekSkinFactory() override; diff --git a/src/common/QskAspect.cpp b/src/common/QskAspect.cpp index 79a7be804..9c75ad250 100644 --- a/src/common/QskAspect.cpp +++ b/src/common/QskAspect.cpp @@ -5,9 +5,9 @@ #include "QskAspect.h" +#include #include #include -#include #include #include @@ -57,8 +57,8 @@ QskAspect::Subcontrol QskAspect::nextSubcontrol( auto& names = qskAspectRegistry->subControlNames; auto& hashTable = qskAspectRegistry->subControlTable; - Q_ASSERT_X( names.size() <= LastSubcontrol, - "QskAspect", "There are no free subcontrol aspects; please modify your" + Q_ASSERT_X( names.size() <= LastSubcontrol, "QskAspect", + "There are no free subcontrol aspects; please modify your" " application to declare fewer aspects, or increase the mask size of" " QskAspect::Subcontrol in QskAspect.h." ); @@ -253,7 +253,7 @@ QDebug operator<<( QDebug debug, const QskAspect::Aspect& aspect ) void qskDebugState( QDebug debug, const QMetaObject* metaObject, QskAspect::State state ) { - QDebugStateSaver saver(debug); + QDebugStateSaver saver( debug ); debug.resetFormat(); debug.noquote(); @@ -266,7 +266,7 @@ void qskDebugAspect( QDebug debug, const QMetaObject* metaObject, QskAspect::Asp { using namespace QskAspect; - QDebugStateSaver saver(debug); + QDebugStateSaver saver( debug ); debug.resetFormat(); debug.noquote(); @@ -284,7 +284,7 @@ void qskDebugAspect( QDebug debug, const QMetaObject* metaObject, QskAspect::Asp if ( aspect.isAnimator() ) debug << "(A)"; - switch( aspect.type() ) + switch ( aspect.type() ) { case Color: { @@ -324,13 +324,13 @@ const char* QskAspect::Aspect::toPrintable() const debug << *this; // we should find a better impementation - static QByteArray bytes[10]; + static QByteArray bytes[ 10 ]; static int counter = 0; counter = ( counter + 1 ) % 10; - bytes[counter] = tmp.toUtf8(); - return bytes[counter].constData(); + bytes[ counter ] = tmp.toUtf8(); + return bytes[ counter ].constData(); } QskAspect::State QskAspect::Aspect::topState() const diff --git a/src/common/QskAspect.h b/src/common/QskAspect.h index 3091b9a9b..7064025f7 100644 --- a/src/common/QskAspect.h +++ b/src/common/QskAspect.h @@ -6,9 +6,11 @@ #ifndef QSK_ASPECT_H #define QSK_ASPECT_H +#include "QskGlobal.h" #include "QskFlags.h" #include + #include #ifdef Q_MOC_RUN @@ -27,8 +29,8 @@ QSK_NAMESPACE( QskAspect ) { enum Subcontrol : quint16 { - Control = 0, - LastSubcontrol = ( 1 << 12 ) - 1 + Control = 0, + LastSubcontrol = ( 1 << 12 ) - 1 }; QSK_ENUM( Subcontrol ) @@ -93,20 +95,20 @@ QSK_NAMESPACE( QskAspect ) Preserved = 0, Transposed = 1 }; - QSK_ENUM ( Placement ) + QSK_ENUM( Placement ) enum State : quint16 { - NoState = 0, + NoState = 0, - FirstSystemState = 1 << 0, - FirstUserState = 1 << 4, - LastUserState = 1 << 11, - LastSystemState = 1 << 15, + FirstSystemState = 1 << 0, + FirstUserState = 1 << 4, + LastUserState = 1 << 11, + LastSystemState = 1 << 15, - AllStates = 0xFFFF + AllStates = 0xFFFF }; - QSK_ENUM ( State ) + QSK_ENUM( State ) extern const QMetaObject staticMetaObject; } @@ -120,7 +122,7 @@ namespace QskAspect { class QSK_EXPORT Aspect { - public: + public: constexpr Aspect(); constexpr Aspect( Subcontrol ); constexpr Aspect( Type ); @@ -175,8 +177,9 @@ namespace QskAspect const char* toPrintable() const; - private: + private: constexpr Aspect( Subcontrol, Type, Placement ); + constexpr Aspect( uint subControl, uint type, bool isAnimator, uint primitive, uint placement, uint states ); @@ -202,34 +205,35 @@ namespace QskAspect }; }; - inline constexpr Aspect::Aspect(): - Aspect( Control, Flag, Preserved ) + inline constexpr Aspect::Aspect() + : Aspect( Control, Flag, Preserved ) { } - inline constexpr Aspect::Aspect( Subcontrol subControl ): - Aspect( subControl, Flag, Preserved ) + inline constexpr Aspect::Aspect( Subcontrol subControl ) + : Aspect( subControl, Flag, Preserved ) { } - inline constexpr Aspect::Aspect( Type type ): - Aspect( Control, type, Preserved ) + inline constexpr Aspect::Aspect( Type type ) + : Aspect( Control, type, Preserved ) { } - inline constexpr Aspect::Aspect( Placement placement ): - Aspect( Control, Flag, placement ) + inline constexpr Aspect::Aspect( Placement placement ) + : Aspect( Control, Flag, placement ) { } - inline constexpr Aspect::Aspect( Subcontrol subControl, Type type, Placement placement ): - Aspect( subControl, type, false, 0, placement, NoState ) + inline constexpr Aspect::Aspect( + Subcontrol subControl, Type type, Placement placement ) + : Aspect( subControl, type, false, 0, placement, NoState ) { } inline constexpr Aspect::Aspect( uint subControl, uint type, bool isAnimator, - uint primitive, uint placement, uint states ): - m_bits { subControl, type, isAnimator, primitive, placement, 0, states, 0 } + uint primitive, uint placement, uint states ) + : m_bits { subControl, type, isAnimator, primitive, placement, 0, states, 0 } { } @@ -257,7 +261,7 @@ namespace QskAspect inline constexpr Aspect Aspect::operator|( Type type ) const { return Aspect( m_bits.subControl, type, m_bits.isAnimator, - m_bits.primitive, m_bits.placement, m_bits.states ); + m_bits.primitive, m_bits.placement, m_bits.states ); } inline constexpr Aspect Aspect::operator|( FlagPrimitive primitive ) const diff --git a/src/common/QskBoxBorderColors.cpp b/src/common/QskBoxBorderColors.cpp index 76b7bd6df..d4e110e07 100644 --- a/src/common/QskBoxBorderColors.cpp +++ b/src/common/QskBoxBorderColors.cpp @@ -23,7 +23,7 @@ static inline bool qskIsVisble( const QColor& c ) static inline void qskSetColors( const QColor& c, QColor* colors ) { - colors[0] = colors[1] = colors[2] = colors[3] = c.toRgb(); + colors[ 0 ] = colors[ 1 ] = colors[ 2 ] = colors[ 3 ] = c.toRgb(); } static inline void qskSetColors( @@ -58,18 +58,18 @@ QskBoxBorderColors::~QskBoxBorderColors() bool QskBoxBorderColors::operator==( const QskBoxBorderColors& other ) const { - return ( m_colors[0] == other.m_colors[0] ) - && ( m_colors[1] == other.m_colors[1] ) - && ( m_colors[2] == other.m_colors[2] ) - && ( m_colors[3] == other.m_colors[3] ); + return ( m_colors[ 0 ] == other.m_colors[ 0 ] ) && + ( m_colors[ 1 ] == other.m_colors[ 1 ] ) && + ( m_colors[ 2 ] == other.m_colors[ 2 ] ) && + ( m_colors[ 3 ] == other.m_colors[ 3 ] ); } void QskBoxBorderColors::setAlpha( int alpha ) { for ( int i = 0; i < 4; i++ ) { - if ( m_colors[i].isValid() && m_colors[i].alpha() ) - m_colors[i].setAlpha( alpha ); + if ( m_colors[ i ].isValid() && m_colors[ i ].alpha() ) + m_colors[ i ].setAlpha( alpha ); } } @@ -110,7 +110,7 @@ void QskBoxBorderColors::setColorsAt( Qt::Edges edges, const QColor& color ) QColor QskBoxBorderColors::colorAt( Qt::Edge edge ) const { - switch( edge ) + switch ( edge ) { case Qt::TopEdge: return m_colors[ Qsk::Top ]; @@ -130,16 +130,16 @@ QColor QskBoxBorderColors::colorAt( Qt::Edge edge ) const bool QskBoxBorderColors::isVisible() const { - if ( qskIsVisble( m_colors[0] ) ) + if ( qskIsVisble( m_colors[ 0 ] ) ) return true; - if ( qskIsVisble( m_colors[1] ) ) + if ( qskIsVisble( m_colors[ 1 ] ) ) return true; - if ( qskIsVisble( m_colors[2] ) ) + if ( qskIsVisble( m_colors[ 2 ] ) ) return true; - if ( qskIsVisble( m_colors[3] ) ) + if ( qskIsVisble( m_colors[ 3 ] ) ) return true; return false; @@ -147,13 +147,13 @@ bool QskBoxBorderColors::isVisible() const bool QskBoxBorderColors::isMonochrome() const { - if ( m_colors[1] != m_colors[0] ) + if ( m_colors[ 1 ] != m_colors[ 0 ] ) return false; - if ( m_colors[2] != m_colors[1] ) + if ( m_colors[ 2 ] != m_colors[ 1 ] ) return false; - if ( m_colors[3] != m_colors[2] ) + if ( m_colors[ 3 ] != m_colors[ 2 ] ) return false; return true; @@ -166,8 +166,8 @@ QskBoxBorderColors QskBoxBorderColors::interpolated( for ( size_t i = 0; i < 4; i++ ) { - colors.m_colors[i] = QskRgbValue::interpolated( - m_colors[i], to.m_colors[i], ratio ); + colors.m_colors[ i ] = QskRgbValue::interpolated( + m_colors[ i ], to.m_colors[ i ], ratio ); } return colors; @@ -183,12 +183,12 @@ uint QskBoxBorderColors::hash( uint seed ) const { const QRgb rgb[] = { - m_colors[0].rgba(), - m_colors[1].rgba(), - m_colors[2].rgba(), - m_colors[3].rgba(), + m_colors[ 0 ].rgba(), + m_colors[ 1 ].rgba(), + m_colors[ 2 ].rgba(), + m_colors[ 3 ].rgba(), }; - + return qHashBits( rgb, sizeof( rgb ), seed ); } diff --git a/src/common/QskBoxBorderColors.h b/src/common/QskBoxBorderColors.h index d19863792..445b235be 100644 --- a/src/common/QskBoxBorderColors.h +++ b/src/common/QskBoxBorderColors.h @@ -16,8 +16,9 @@ class QDebug; class QSK_EXPORT QskBoxBorderColors { -public: + public: QskBoxBorderColors(); + QskBoxBorderColors( const QColor& left, const QColor& top, const QColor& right, const QColor& bottom ); @@ -54,18 +55,18 @@ class QSK_EXPORT QskBoxBorderColors bool isMonochrome() const; bool isVisible() const; -private: + private: // should be stored as QRgb QColor m_colors[ 4 ]; }; -inline QskBoxBorderColors::QskBoxBorderColors( Qt::GlobalColor color ): - QskBoxBorderColors( QColor( color ) ) +inline QskBoxBorderColors::QskBoxBorderColors( Qt::GlobalColor color ) + : QskBoxBorderColors( QColor( color ) ) { } -inline QskBoxBorderColors::QskBoxBorderColors( QRgb rgb ): - QskBoxBorderColors( QColor::fromRgba( rgb ) ) +inline QskBoxBorderColors::QskBoxBorderColors( QRgb rgb ) + : QskBoxBorderColors( QColor::fromRgba( rgb ) ) { } diff --git a/src/common/QskBoxBorderMetrics.cpp b/src/common/QskBoxBorderMetrics.cpp index 3d68b90c6..265b244d4 100644 --- a/src/common/QskBoxBorderMetrics.cpp +++ b/src/common/QskBoxBorderMetrics.cpp @@ -88,8 +88,9 @@ QskBoxBorderMetrics QskBoxBorderMetrics::interpolated( return QskBoxBorderMetrics( widths, m_sizeMode ); } -QVariant QskBoxBorderMetrics::interpolate( const QskBoxBorderMetrics& from, - const QskBoxBorderMetrics& to, qreal progress ) +QVariant QskBoxBorderMetrics::interpolate( + const QskBoxBorderMetrics& from, const QskBoxBorderMetrics& to, + qreal progress ) { return QVariant::fromValue( from.interpolated( to, progress ) ); } @@ -119,4 +120,3 @@ QDebug operator<<( QDebug debug, const QskBoxBorderMetrics& metrics ) } #endif - diff --git a/src/common/QskBoxBorderMetrics.h b/src/common/QskBoxBorderMetrics.h index 78eb636e5..7a87bbef2 100644 --- a/src/common/QskBoxBorderMetrics.h +++ b/src/common/QskBoxBorderMetrics.h @@ -9,8 +9,8 @@ #include "QskGlobal.h" #include "QskMargins.h" -#include #include +#include #include class QDebug; @@ -18,12 +18,17 @@ class QVariant; class QSK_EXPORT QskBoxBorderMetrics { -public: + public: constexpr QskBoxBorderMetrics(); - constexpr QskBoxBorderMetrics( qreal width, Qt::SizeMode = Qt::AbsoluteSize ); + + constexpr QskBoxBorderMetrics( + qreal width, Qt::SizeMode = Qt::AbsoluteSize ); + constexpr QskBoxBorderMetrics( qreal left, qreal top, qreal right, qreal bottom, Qt::SizeMode = Qt::AbsoluteSize ); - constexpr QskBoxBorderMetrics( const QskMargins& widths, Qt::SizeMode sizeMode = Qt::AbsoluteSize ); + + constexpr QskBoxBorderMetrics( + const QskMargins& widths, Qt::SizeMode sizeMode = Qt::AbsoluteSize ); ~QskBoxBorderMetrics(); @@ -41,41 +46,44 @@ class QSK_EXPORT QskBoxBorderMetrics void setSizeMode( Qt::SizeMode ); Qt::SizeMode sizeMode() const; - QskBoxBorderMetrics interpolated( const QskBoxBorderMetrics&, qreal value ) const; - QskBoxBorderMetrics toAbsolute ( const QSizeF& ) const; + QskBoxBorderMetrics interpolated( + const QskBoxBorderMetrics&, qreal value ) const; + + QskBoxBorderMetrics toAbsolute( const QSizeF& ) const; uint hash( uint seed = 0 ) const; static QVariant interpolate( const QskBoxBorderMetrics&, const QskBoxBorderMetrics&, qreal progress ); -private: + private: QskMargins m_widths; Qt::SizeMode m_sizeMode : 2; }; -inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics(): - m_sizeMode( Qt::AbsoluteSize ) +inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics() + : m_sizeMode( Qt::AbsoluteSize ) { } -inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics( qreal width, Qt::SizeMode sizeMode ): - m_widths( width ), - m_sizeMode( sizeMode ) +inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics( + qreal width, Qt::SizeMode sizeMode ) + : m_widths( width ) + , m_sizeMode( sizeMode ) { } inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics( - const QskMargins& widths, Qt::SizeMode sizeMode ): - m_widths( widths ), - m_sizeMode( sizeMode ) + const QskMargins& widths, Qt::SizeMode sizeMode ) + : m_widths( widths ) + , m_sizeMode( sizeMode ) { } -inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics( qreal left, qreal top, - qreal right, qreal bottom, Qt::SizeMode sizeMode ): - m_widths( left, top, right, bottom ), - m_sizeMode( sizeMode ) +inline constexpr QskBoxBorderMetrics::QskBoxBorderMetrics( + qreal left, qreal top, qreal right, qreal bottom, Qt::SizeMode sizeMode ) + : m_widths( left, top, right, bottom ) + , m_sizeMode( sizeMode ) { } diff --git a/src/common/QskBoxShapeMetrics.cpp b/src/common/QskBoxShapeMetrics.cpp index b9f3aa783..41ec0b4e8 100644 --- a/src/common/QskBoxShapeMetrics.cpp +++ b/src/common/QskBoxShapeMetrics.cpp @@ -29,9 +29,9 @@ static inline qreal qskAbsoluted( qreal length, qreal percentage ) } QskBoxShapeMetrics::QskBoxShapeMetrics( - qreal radiusX, qreal radiusY, Qt::SizeMode sizeMode ): - m_sizeMode( sizeMode ), - m_aspectRatioMode( Qt::KeepAspectRatio ) + qreal radiusX, qreal radiusY, Qt::SizeMode sizeMode ) + : m_sizeMode( sizeMode ) + , m_aspectRatioMode( Qt::KeepAspectRatio ) { setRadius( radiusX, radiusY ); } @@ -50,7 +50,7 @@ bool QskBoxShapeMetrics::operator==( const QskBoxShapeMetrics& other ) const for ( size_t i = 0; i < 4; i++ ) { - if ( m_radii[i] != other.m_radii[i] ) + if ( m_radii[ i ] != other.m_radii[ i ] ) return false; } @@ -68,8 +68,10 @@ void QskBoxShapeMetrics::setAspectRatioMode( Qt::AspectRatioMode aspectRatioMode } void QskBoxShapeMetrics::setRadius( - qreal topLeftX, qreal topLeftY, qreal topRightX, qreal topRightY, - qreal bottomLeftX, qreal bottomLeftY, qreal bottomRightX, qreal bottomRightY ) + qreal topLeftX, qreal topLeftY, + qreal topRightX, qreal topRightY, + qreal bottomLeftX, qreal bottomLeftY, + qreal bottomRightX, qreal bottomRightY ) { m_radii[ Qt::TopLeftCorner ].setWidth( qMax( topLeftX, 0.0 ) ); m_radii[ Qt::TopLeftCorner ].setHeight( qMax( topLeftY, 0.0 ) ); @@ -96,23 +98,23 @@ void QskBoxShapeMetrics::setRadius( Qt::Corner corner, qreal radiusX, qreal radi bool QskBoxShapeMetrics::isRectellipse() const { const QSizeF* r = m_radii; - return ( r[1] == r[0] ) && ( r[2] == r[1] ) && ( r[3] == r[2] ); + return ( r[ 1 ] == r[ 0 ] ) && ( r[ 2 ] == r[ 1 ] ) && ( r[ 3 ] == r[ 2 ] ); } bool QskBoxShapeMetrics::isRectangle() const { const QSizeF* r = m_radii; - if ( ( r[0].width() > 0.0 ) || ( r[0].height() > 0.0 ) ) + if ( ( r[ 0 ].width() > 0.0 ) || ( r[ 0 ].height() > 0.0 ) ) return false; - if ( ( r[1].width() > 0.0 ) || ( r[1].height() > 0.0 ) ) + if ( ( r[ 1 ].width() > 0.0 ) || ( r[ 1 ].height() > 0.0 ) ) return false; - if ( ( r[2].width() > 0.0 ) || ( r[2].height() > 0.0 ) ) + if ( ( r[ 2 ].width() > 0.0 ) || ( r[ 2 ].height() > 0.0 ) ) return false; - if ( ( r[3].width() > 0.0 ) || ( r[3].height() > 0.0 ) ) + if ( ( r[ 3 ].width() > 0.0 ) || ( r[ 3 ].height() > 0.0 ) ) return false; return true; @@ -123,7 +125,7 @@ QskBoxShapeMetrics QskBoxShapeMetrics::rotated() const QskBoxShapeMetrics other; for ( int i = 0; i < 4; i++ ) - other.m_radii[i] = m_radii[i].transposed(); + other.m_radii[ i ] = m_radii[ i ].transposed(); other.m_sizeMode = m_sizeMode; @@ -151,7 +153,7 @@ QskBoxShapeMetrics QskBoxShapeMetrics::toAbsolute( const QSizeF& size ) const const qreal rx = qskAbsoluted( size.width(), radii.width() ); const qreal ry = qskAbsoluted( size.height(), radii.height() ); - switch( m_aspectRatioMode ) + switch ( m_aspectRatioMode ) { case Qt::IgnoreAspectRatio: { @@ -185,17 +187,17 @@ QskBoxShapeMetrics QskBoxShapeMetrics::interpolated( if ( ( *this == to ) || ( m_sizeMode != to.m_sizeMode ) ) return to; - QSizeF radii[4]; - radii[0] = qskInterpolatedSize( m_radii[0], to.m_radii[0], ratio ); - radii[1] = qskInterpolatedSize( m_radii[1], to.m_radii[1], ratio ); - radii[2] = qskInterpolatedSize( m_radii[2], to.m_radii[2], ratio ); - radii[3] = qskInterpolatedSize( m_radii[3], to.m_radii[3], ratio ); + QSizeF radii[ 4 ]; + radii[ 0 ] = qskInterpolatedSize( m_radii[ 0 ], to.m_radii[ 0 ], ratio ); + radii[ 1 ] = qskInterpolatedSize( m_radii[ 1 ], to.m_radii[ 1 ], ratio ); + radii[ 2 ] = qskInterpolatedSize( m_radii[ 2 ], to.m_radii[ 2 ], ratio ); + radii[ 3 ] = qskInterpolatedSize( m_radii[ 3 ], to.m_radii[ 3 ], ratio ); return QskBoxShapeMetrics( to.m_sizeMode, radii ); } -QVariant QskBoxShapeMetrics::interpolate( const QskBoxShapeMetrics& from, - const QskBoxShapeMetrics& to, qreal progress ) +QVariant QskBoxShapeMetrics::interpolate( + const QskBoxShapeMetrics& from, const QskBoxShapeMetrics& to, qreal progress ) { return QVariant::fromValue( from.interpolated( to, progress ) ); } @@ -232,4 +234,3 @@ QDebug operator<<( QDebug debug, const QskBoxShapeMetrics& metrics ) } #endif - diff --git a/src/common/QskBoxShapeMetrics.h b/src/common/QskBoxShapeMetrics.h index e36e27970..afa1dc62b 100644 --- a/src/common/QskBoxShapeMetrics.h +++ b/src/common/QskBoxShapeMetrics.h @@ -8,8 +8,8 @@ #include "QskGlobal.h" -#include #include +#include #include class QVariant; @@ -17,8 +17,9 @@ class QMarginsF; class QSK_EXPORT QskBoxShapeMetrics { -public: + public: constexpr QskBoxShapeMetrics(); + constexpr QskBoxShapeMetrics( qreal topLeft, qreal topRight, qreal bottomLeft, qreal bottomRight, Qt::SizeMode = Qt::AbsoluteSize ); @@ -62,8 +63,11 @@ class QSK_EXPORT QskBoxShapeMetrics void setAspectRatioMode( Qt::AspectRatioMode ); Qt::AspectRatioMode aspectRatioMode() const; - QskBoxShapeMetrics interpolated( const QskBoxShapeMetrics&, qreal value ) const; - QskBoxShapeMetrics toAbsolute ( const QSizeF& ) const; + QskBoxShapeMetrics interpolated( + const QskBoxShapeMetrics&, qreal value ) const; + + QskBoxShapeMetrics toAbsolute( const QSizeF& ) const; + QskBoxShapeMetrics rotated() const; QMarginsF padding( const QSizeF& ) const; @@ -73,11 +77,11 @@ class QSK_EXPORT QskBoxShapeMetrics static QVariant interpolate( const QskBoxShapeMetrics&, const QskBoxShapeMetrics&, qreal progress ); -private: - inline constexpr QskBoxShapeMetrics( Qt::SizeMode sizeMode, const QSizeF radii[4] ): - m_radii{ radii[0], radii[1], radii[2], radii[3] }, - m_sizeMode( sizeMode ), - m_aspectRatioMode( Qt::KeepAspectRatio ) + private: + inline constexpr QskBoxShapeMetrics( Qt::SizeMode sizeMode, const QSizeF radii[ 4 ] ) + : m_radii{ radii[ 0 ], radii[ 1 ], radii[ 2 ], radii[ 3 ] } + , m_sizeMode( sizeMode ) + , m_aspectRatioMode( Qt::KeepAspectRatio ) { } @@ -86,24 +90,24 @@ class QSK_EXPORT QskBoxShapeMetrics Qt::AspectRatioMode m_aspectRatioMode : 2; }; -inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics(): - m_radii{ { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } }, - m_sizeMode( Qt::AbsoluteSize ), - m_aspectRatioMode( Qt::KeepAspectRatio ) +inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics() + : m_radii{ { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } } + , m_sizeMode( Qt::AbsoluteSize ) + , m_aspectRatioMode( Qt::KeepAspectRatio ) { } -inline QskBoxShapeMetrics::QskBoxShapeMetrics( qreal radius, Qt::SizeMode sizeMode ): - QskBoxShapeMetrics( radius, radius, sizeMode ) +inline QskBoxShapeMetrics::QskBoxShapeMetrics( qreal radius, Qt::SizeMode sizeMode ) + : QskBoxShapeMetrics( radius, radius, sizeMode ) { } inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics( qreal topLeft, qreal topRight, - qreal bottomLeft, qreal bottomRight, Qt::SizeMode sizeMode ): - m_radii{ { topLeft, topLeft }, { topRight, topRight }, - { bottomLeft, bottomLeft }, { bottomRight, bottomRight } }, - m_sizeMode( sizeMode ), - m_aspectRatioMode( Qt::KeepAspectRatio ) + qreal bottomLeft, qreal bottomRight, Qt::SizeMode sizeMode ) + : m_radii{ { topLeft, topLeft }, { topRight, topRight }, + { bottomLeft, bottomLeft }, { bottomRight, bottomRight } } + , m_sizeMode( sizeMode ) + , m_aspectRatioMode( Qt::KeepAspectRatio ) { } @@ -145,8 +149,7 @@ inline void QskBoxShapeMetrics::setRadius( Qt::Corner corner, const QSizeF& radi } inline void QskBoxShapeMetrics::setRadius( - qreal topLeft, qreal topRight, - qreal bottomLeft, qreal bottomRight ) + qreal topLeft, qreal topRight, qreal bottomLeft, qreal bottomRight ) { setRadius( topLeft, topLeft, topRight, topRight, bottomLeft, bottomLeft, bottomRight, bottomRight ); diff --git a/src/common/QskCorner.cpp b/src/common/QskCorner.cpp index 2b6e3bb8f..f806e59ff 100644 --- a/src/common/QskCorner.cpp +++ b/src/common/QskCorner.cpp @@ -32,7 +32,7 @@ Qt::SizeMode QskCorner::sizeMode() const void QskCorner::setAspectRatioMode( Qt::AspectRatioMode mode ) { m_metrics.setAspectRatioMode( mode ); -} +} Qt::AspectRatioMode QskCorner::aspectRatioMode() const { diff --git a/src/common/QskCorner.h b/src/common/QskCorner.h index b63f0aef0..978bdf728 100644 --- a/src/common/QskCorner.h +++ b/src/common/QskCorner.h @@ -23,7 +23,7 @@ class QSK_EXPORT QskCorner Q_PROPERTY( Qt::SizeMode sizeMode READ sizeMode WRITE setSizeMode ) Q_PROPERTY( Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode ) -public: + public: QskCorner(); QskCorner( Qt::SizeMode, qreal radius ); @@ -38,7 +38,7 @@ class QSK_EXPORT QskCorner const QskBoxShapeMetrics& metrics() const; -private: + private: // QskCorner could be replaced by QskBoxShapeMetrics TODO ... QskBoxShapeMetrics m_metrics; }; diff --git a/src/common/QskFunctions.cpp b/src/common/QskFunctions.cpp index 8050e7fec..7c3b47f01 100644 --- a/src/common/QskFunctions.cpp +++ b/src/common/QskFunctions.cpp @@ -1,8 +1,8 @@ #include "QskFunctions.h" #include -#include #include +#include template< class Rect, class Value > static inline Rect qskAlignedRect( const Rect& outerRect, @@ -12,7 +12,7 @@ static inline Rect qskAlignedRect( const Rect& outerRect, Rect r( 0, 0, width, height ); - switch( alignment & Qt::AlignHorizontal_Mask ) + switch ( alignment & Qt::AlignHorizontal_Mask ) { case Qt::AlignLeft: { @@ -31,7 +31,7 @@ static inline Rect qskAlignedRect( const Rect& outerRect, } } - switch( alignment & Qt::AlignVertical_Mask ) + switch ( alignment & Qt::AlignVertical_Mask ) { case Qt::AlignTop: { @@ -86,26 +86,26 @@ QRectF qskValidOrEmptyInnerRect( const QRectF& rect, const QMarginsF& margins ) { x = rect.x() + rect.width() * ( margins.left() / marginsWidth ); w = 0; - } + } else { x = rect.x() + margins.left(); w = rect.width() - marginsWidth; - } - + } + if ( marginsHeight > rect.height() ) { y = rect.y() + rect.height() * ( margins.top() / marginsHeight ); h = 0; - } + } else { y = rect.y() + margins.top(); h = rect.height() - marginsHeight; - } + } return QRectF( x, y, w, h ); -} +} qreal qskDpiScaled( qreal value ) { diff --git a/src/common/QskFunctions.h b/src/common/QskFunctions.h index 90cb30275..0e32d4b4c 100644 --- a/src/common/QskFunctions.h +++ b/src/common/QskFunctions.h @@ -41,8 +41,7 @@ inline QMarginsF qskMargins( const QRectF& rect, const QRectF& innerRect ) innerRect.left() - rect.left(), innerRect.top() - rect.top(), rect.right() - innerRect.right(), - rect.bottom() - innerRect.bottom() - ); + rect.bottom() - innerRect.bottom() ); } #endif diff --git a/src/common/QskGlobal.h b/src/common/QskGlobal.h index a083fdb04..217e92cc0 100644 --- a/src/common/QskGlobal.h +++ b/src/common/QskGlobal.h @@ -6,8 +6,8 @@ #ifndef QSK_GLOBAL_H #define QSK_GLOBAL_H -#include #include +#include // QSK_VERSION is (major << 16) + (minor << 8) + patch. @@ -39,19 +39,20 @@ #define QSK_QT_PRIVATE_END \ QT_WARNING_POP -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) #define qskAsConst qAsConst #else -template struct QskAddConst { typedef const T Type; }; +template < typename T > +struct QskAddConst { typedef const T Type; }; -template -constexpr typename QskAddConst::Type &qskAsConst( T &t ) noexcept { return t; } +template < typename T > +constexpr typename QskAddConst< T >::Type& qskAsConst( T& t ) noexcept { return t; } -template -void qskAsConst( const T && ) = delete; +template< typename T > +void qskAsConst( const T&& ) = delete; #endif diff --git a/src/common/QskGradient.cpp b/src/common/QskGradient.cpp index 3466ec7e1..887528565 100644 --- a/src/common/QskGradient.cpp +++ b/src/common/QskGradient.cpp @@ -6,8 +6,8 @@ #include "QskGradient.h" #include "QskRgbValue.h" -#include #include +#include static void qskRegisterGradient() { @@ -21,8 +21,7 @@ static inline bool qskIsGradientValid( const QVector< QskGradientStop >& stops ) if ( stops.size() < 2 ) return false; - if ( stops.first().position() != 0.0 || - stops.last().position() != 1.0 ) + if ( stops.first().position() != 0.0 || stops.last().position() != 1.0 ) { return false; } @@ -32,10 +31,10 @@ static inline bool qskIsGradientValid( const QVector< QskGradientStop >& stops ) for ( int i = 1; i < stops.size(); i++ ) { - if ( stops[i].position() < stops[i - 1].position() ) + if ( stops[ i ].position() < stops[ i - 1 ].position() ) return false; - if ( !stops[i].color().isValid() ) + if ( !stops[ i ].color().isValid() ) return false; } @@ -46,7 +45,7 @@ static inline bool qskIsMonochrome( const QVector< QskGradientStop >& stops ) { for ( int i = 1; i < stops.size(); i++ ) { - if ( stops[i].color() != stops[0].color() ) + if ( stops[ i ].color() != stops[ 0 ].color() ) return false; } @@ -72,7 +71,7 @@ static inline bool qskComparePositions( // the first is always at 0.0, the last at 1.0 for ( int i = 1; i < s1.count() - 1; i++ ) { - if ( s1[i].position() != s2[i].position() ) + if ( s1[ i ].position() != s2[ i ].position() ) return false; } @@ -92,16 +91,16 @@ static inline QVector< QskGradientStop > qskExpandedStops( stops += s1.first(); int i = 1, j = 1; - while( ( i < s1.count() - 1 ) || ( j < s2.count() - 1 ) ) + while ( ( i < s1.count() - 1 ) || ( j < s2.count() - 1 ) ) { - if ( s1[i].position() < s2[j].position() ) + if ( s1[ i ].position() < s2[ j ].position() ) { - stops += s1[i++]; + stops += s1[ i++ ]; } else { - const qreal pos = s2[j++].position(); - stops += QskGradientStop( pos, qskInterpolated( s1[i - 1], s1[i], pos ) ); + const qreal pos = s2[ j++ ].position(); + stops += QskGradientStop( pos, qskInterpolated( s1[ i - 1 ], s1[ i ], pos ) ); } } @@ -110,14 +109,14 @@ static inline QVector< QskGradientStop > qskExpandedStops( return stops; } -QskGradientStop::QskGradientStop(): - m_position( -1.0 ) +QskGradientStop::QskGradientStop() + : m_position( -1.0 ) { } -QskGradientStop::QskGradientStop( qreal position, const QColor& color ): - m_position( position ), - m_color( color ) +QskGradientStop::QskGradientStop( qreal position, const QColor& color ) + : m_position( position ) + , m_color( color ) { } @@ -169,28 +168,28 @@ QColor QskGradientStop::interpolated( return QskRgbValue::interpolated( min->color(), max->color(), r ); } -QskGradient::QskGradient(): - m_orientation( Vertical ) +QskGradient::QskGradient() + : m_orientation( Vertical ) { } -QskGradient::QskGradient( const QColor& color ): - m_orientation( Vertical ) +QskGradient::QskGradient( const QColor& color ) + : m_orientation( Vertical ) { setColor( color ); } QskGradient::QskGradient( Orientation orientation, - const QColor& startColor, const QColor& stopColor ): - m_orientation( orientation ) + const QColor& startColor, const QColor& stopColor ) + : m_orientation( orientation ) { setColors( startColor, stopColor ); } QskGradient::QskGradient( Orientation orientation, - const QVector< QskGradientStop >& stops ): - m_orientation( orientation ), - m_stops( stops ) + const QVector< QskGradientStop >& stops ) + : m_orientation( orientation ) + , m_stops( stops ) { } @@ -249,10 +248,10 @@ void QskGradient::setColor( const QColor& color ) void QskGradient::setColors( const QColor& startColor, const QColor& stopColor ) { m_stops.resize( 2 ); - m_stops[0].setPosition( 0.0 ); - m_stops[0].setColor( startColor ); - m_stops[1].setPosition( 1.0 ); - m_stops[1].setColor( stopColor ); + m_stops[ 0 ].setPosition( 0.0 ); + m_stops[ 0 ].setColor( startColor ); + m_stops[ 1 ].setPosition( 1.0 ); + m_stops[ 1 ].setColor( stopColor ); } void QskGradient::setStops( const QVector< QskGradientStop >& stops ) @@ -283,7 +282,7 @@ void QskGradient::setStopAt( int index, qreal stop ) if ( index >= m_stops.size() ) m_stops.resize( index + 1 ); - m_stops[index].setPosition( stop ); + m_stops[ index ].setPosition( stop ); } qreal QskGradient::stopAt( int index ) const @@ -291,7 +290,7 @@ qreal QskGradient::stopAt( int index ) const if ( index >= m_stops.size() ) return -1.0; - return m_stops[index].position(); + return m_stops[ index ].position(); } void QskGradient::setColorAt( int index, const QColor& color ) @@ -305,7 +304,7 @@ void QskGradient::setColorAt( int index, const QColor& color ) if ( index >= m_stops.size() ) m_stops.resize( index + 1 ); - m_stops[index].setColor( color ); + m_stops[ index ].setColor( color ); } QColor QskGradient::colorAt( int index ) const @@ -313,7 +312,7 @@ QColor QskGradient::colorAt( int index ) const if ( index >= m_stops.size() ) return QColor(); - return m_stops[index].color(); + return m_stops[ index ].color(); } void QskGradient::setAlpha( int alpha ) @@ -367,15 +366,15 @@ QskGradient QskGradient::interpolated( { // we can ignore our stops - const QColor c = m_stops[0].color(); + const QColor c = m_stops[ 0 ].color(); QVector< QskGradientStop > s2 = to.m_stops; for ( int i = 0; i < s2.count(); i++ ) { const QColor c2 = QskRgbValue::interpolated( - c, s2[i].color(), value ); + c, s2[ i ].color(), value ); - s2[i].setColor( c2 ); + s2[ i ].setColor( c2 ); } return QskGradient( to.m_orientation, s2 ); @@ -385,15 +384,15 @@ QskGradient QskGradient::interpolated( { // we can ignore the stops of to - const QColor c = to.m_stops[0].color(); + const QColor c = to.m_stops[ 0 ].color(); QVector< QskGradientStop > s2 = m_stops; for ( int i = 0; i < s2.count(); i++ ) { const QColor c2 = QskRgbValue::interpolated( - s2[i].color(), c, value ); + s2[ i ].color(), c, value ); - s2[i].setColor( c2 ); + s2[ i ].setColor( c2 ); } return QskGradient( m_orientation, s2 ); @@ -406,15 +405,15 @@ QskGradient QskGradient::interpolated( at the same positions */ - const QVector< QskGradientStop > s1 = qskExpandedStops( m_stops, to.m_stops ); - QVector< QskGradientStop > s2 = qskExpandedStops( to.m_stops, m_stops ); + const auto s1 = qskExpandedStops( m_stops, to.m_stops ); + auto s2 = qskExpandedStops( to.m_stops, m_stops ); for ( int i = 0; i < s1.count(); i++ ) { const QColor c2 = QskRgbValue::interpolated( - s1[i].color(), s2[i].color(), value ); + s1[ i ].color(), s2[ i ].color(), value ); - s2[i].setColor( c2 ); + s2[ i ].setColor( c2 ); } return QskGradient( m_orientation, s2 ); @@ -428,7 +427,7 @@ QskGradient QskGradient::interpolated( final gradient. */ - const QColor c = m_stops[0].color(); + const QColor c = m_stops[ 0 ].color(); if ( value <= 0.5 ) { @@ -437,9 +436,9 @@ QskGradient QskGradient::interpolated( for ( int i = 0; i < s2.count(); i++ ) { const QColor c2 = QskRgbValue::interpolated( - s2[i].color(), c, 2 * value ); + s2[ i ].color(), c, 2 * value ); - s2[i].setColor( c2 ); + s2[ i ].setColor( c2 ); } return QskGradient( m_orientation, s2 ); @@ -451,9 +450,9 @@ QskGradient QskGradient::interpolated( for ( int i = 0; i < s2.count(); i++ ) { const QColor c2 = QskRgbValue::interpolated( - c, s2[i].color(), 2 * ( value - 0.5 ) ); + c, s2[ i ].color(), 2 * ( value - 0.5 ) ); - s2[i].setColor( c2 ); + s2[ i ].setColor( c2 ); } return QskGradient( to.m_orientation, s2 ); @@ -467,7 +466,6 @@ QVariant QskGradient::interpolate( return QVariant::fromValue( from.interpolated( to, progress ) ); } - #ifndef QT_NO_DEBUG_STREAM #include diff --git a/src/common/QskGradient.h b/src/common/QskGradient.h index 89097bc38..ac1cc7c07 100644 --- a/src/common/QskGradient.h +++ b/src/common/QskGradient.h @@ -8,8 +8,8 @@ #include "QskGlobal.h" -#include #include +#include #include class QDebug; @@ -22,7 +22,7 @@ class QSK_EXPORT QskGradientStop Q_PROPERTY( qreal position READ position WRITE setPosition RESET resetPosition ) Q_PROPERTY( QColor color READ color WRITE setColor RESET resetColor ) -public: + public: QskGradientStop(); QskGradientStop( qreal position, const QColor& color ); @@ -42,7 +42,7 @@ class QSK_EXPORT QskGradientStop uint hash( uint seed ) const; -private: + private: qreal m_position; QColor m_color; }; @@ -54,7 +54,7 @@ class QSK_EXPORT QskGradient Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) Q_PROPERTY( QVector< QskGradientStop > stops READ stops WRITE setStops ) -public: + public: // TODO: radial/canonical gradients + other diagonal linear gradients enum Orientation { @@ -108,7 +108,7 @@ class QSK_EXPORT QskGradient uint hash( uint seed ) const; -private: + private: void setStopAt( int index, qreal stop ); qreal stopAt( int index ) const; @@ -119,13 +119,13 @@ class QSK_EXPORT QskGradient QVector< QskGradientStop > m_stops; }; -inline QskGradient::QskGradient( Qt::GlobalColor color ): - QskGradient( QColor( color ) ) +inline QskGradient::QskGradient( Qt::GlobalColor color ) + : QskGradient( QColor( color ) ) { } -inline QskGradient::QskGradient( QRgb rgb ): - QskGradient( QColor::fromRgba( rgb ) ) +inline QskGradient::QskGradient( QRgb rgb ) + : QskGradient( QColor::fromRgba( rgb ) ) { } diff --git a/src/common/QskMargins.cpp b/src/common/QskMargins.cpp index e4305122a..0b95a338e 100644 --- a/src/common/QskMargins.cpp +++ b/src/common/QskMargins.cpp @@ -46,7 +46,7 @@ void QskMargins::setMarginsAt( Qt::Edges edges, qreal value ) noexcept qreal QskMargins::marginAt( Qt::Edge edge ) const noexcept { - switch( edge ) + switch ( edge ) { case Qt::LeftEdge: return left(); @@ -63,4 +63,3 @@ qreal QskMargins::marginAt( Qt::Edge edge ) const noexcept return 0.0; } - diff --git a/src/common/QskMargins.h b/src/common/QskMargins.h index 685af8890..4fe4559d9 100644 --- a/src/common/QskMargins.h +++ b/src/common/QskMargins.h @@ -9,8 +9,8 @@ #include "QskGlobal.h" #include -#include #include +#include class QVariant; @@ -21,7 +21,7 @@ class QVariant; */ class QSK_EXPORT QskMargins : public QMarginsF { -public: + public: constexpr QskMargins() noexcept = default; constexpr QskMargins( const QMarginsF& ) noexcept; constexpr QskMargins( const QMargins& ) noexcept; @@ -52,29 +52,30 @@ class QSK_EXPORT QskMargins : public QMarginsF const QskMargins&, qreal progress ) noexcept; }; -constexpr inline QskMargins::QskMargins( qreal margin ) noexcept: - QskMargins( margin, margin, margin, margin ) +constexpr inline QskMargins::QskMargins( qreal margin ) noexcept + : QskMargins( margin, margin, margin, margin ) { } -constexpr inline QskMargins::QskMargins( qreal horizontal, qreal vertical ) noexcept: - QskMargins( horizontal, vertical, horizontal, vertical ) +constexpr inline QskMargins::QskMargins( + qreal horizontal, qreal vertical ) noexcept + : QskMargins( horizontal, vertical, horizontal, vertical ) { } constexpr QskMargins::QskMargins( - qreal left, qreal top, qreal right, qreal bottom ) noexcept: - QMarginsF( left, top, right, bottom ) + qreal left, qreal top, qreal right, qreal bottom ) noexcept + : QMarginsF( left, top, right, bottom ) { } -constexpr inline QskMargins::QskMargins( const QMarginsF& margins ) noexcept: - QMarginsF( margins ) +constexpr inline QskMargins::QskMargins( const QMarginsF& margins ) noexcept + : QMarginsF( margins ) { } -constexpr inline QskMargins::QskMargins( const QMargins& margins ) noexcept: - QMarginsF( margins ) +constexpr inline QskMargins::QskMargins( const QMargins& margins ) noexcept + : QMarginsF( margins ) { } @@ -96,7 +97,7 @@ inline void QskMargins::setMargins( qreal horizontal, qreal vertical ) noexcept inline QskMargins QskMargins::mirrored( Qt::Orientations orientations ) const noexcept { - switch( int( orientations ) ) + switch ( int( orientations ) ) { case Qt::Vertical: return QskMargins( left(), bottom(), right(), top() ); diff --git a/src/common/QskMetaFunction.cpp b/src/common/QskMetaFunction.cpp index 217e28850..768a8dbc9 100644 --- a/src/common/QskMetaFunction.cpp +++ b/src/common/QskMetaFunction.cpp @@ -7,9 +7,9 @@ #include "QskMetaFunction.h" #include -#include #include #include +#include QSK_QT_PRIVATE_BEGIN #include @@ -50,8 +50,8 @@ int QskMetaFunction::FunctionCall::typeInfo() const int value; - reinterpret_cast< SlotObject* >( that )->invoke( TypeInfo, that, - nullptr, reinterpret_cast< void** >( &value ), nullptr ); + reinterpret_cast< SlotObject* >( that )->invoke( + TypeInfo, that, nullptr, reinterpret_cast< void** >( &value ), nullptr ); return value; } @@ -62,27 +62,27 @@ int QskMetaFunction::FunctionCall::refCount() const return reinterpret_cast< SlotObject* >( that )->ref.load(); } -QskMetaFunction::QskMetaFunction(): - m_functionCall( nullptr ) +QskMetaFunction::QskMetaFunction() + : m_functionCall( nullptr ) { } -QskMetaFunction::QskMetaFunction( FunctionCall* functionCall ): - m_functionCall( functionCall ) +QskMetaFunction::QskMetaFunction( FunctionCall* functionCall ) + : m_functionCall( functionCall ) { if ( m_functionCall ) m_functionCall->ref(); } -QskMetaFunction::QskMetaFunction( const QskMetaFunction& other ): - m_functionCall( other.m_functionCall ) +QskMetaFunction::QskMetaFunction( const QskMetaFunction& other ) + : m_functionCall( other.m_functionCall ) { if ( m_functionCall ) m_functionCall->ref(); } -QskMetaFunction::QskMetaFunction( QskMetaFunction&& other ): - m_functionCall( other.m_functionCall ) +QskMetaFunction::QskMetaFunction( QskMetaFunction&& other ) + : m_functionCall( other.m_functionCall ) { other.m_functionCall = nullptr; } @@ -177,8 +177,8 @@ QskMetaFunction::Type QskMetaFunction::functionType() const return static_cast< QskMetaFunction::Type >( m_functionCall->typeInfo() ); } -void QskMetaFunction::invoke( - QObject* object, void* argv[], Qt::ConnectionType connectionType ) +void QskMetaFunction::invoke( QObject* object, + void* argv[], Qt::ConnectionType connectionType ) { #if 1 /* @@ -202,7 +202,7 @@ void QskMetaFunction::invoke( ? Qt::QueuedConnection : Qt::DirectConnection; } - switch( invokeType ) + switch ( invokeType ) { case Qt::DirectConnection: { @@ -211,8 +211,8 @@ void QskMetaFunction::invoke( } case Qt::BlockingQueuedConnection: { - if ( receiver.isNull() - || ( receiver->thread() == QThread::currentThread() ) ) + if ( receiver.isNull() || + ( receiver->thread() == QThread::currentThread() ) ) { // We would end up in a deadlock, better do nothing return; @@ -220,8 +220,8 @@ void QskMetaFunction::invoke( QSemaphore semaphore; - qskInvokeFunctionQueued( receiver, m_functionCall, - 0, nullptr, argv, &semaphore ); + qskInvokeFunctionQueued( receiver, + m_functionCall, 0, nullptr, argv, &semaphore ); semaphore.acquire(); @@ -239,21 +239,21 @@ void QskMetaFunction::invoke( auto types = static_cast< int* >( malloc( argc * sizeof( int ) ) ); auto arguments = static_cast< void** >( malloc( argc * sizeof( void* ) ) ); - types[0] = QMetaType::UnknownType; - arguments[0] = nullptr; + types[ 0 ] = QMetaType::UnknownType; + arguments[ 0 ] = nullptr; const int* parameterTypes = m_functionCall->parameterTypes(); for ( uint i = 1; i < argc; i++ ) { - if ( argv[i] == nullptr ) + if ( argv[ i ] == nullptr ) { - Q_ASSERT( arguments[i] != nullptr ); + Q_ASSERT( arguments[ i ] != nullptr ); receiver = nullptr; break; } - types[i] = parameterTypes[i - 1]; - arguments[i] = QMetaType::create( types[i], argv[i] ); + types[ i ] = parameterTypes[ i - 1 ]; + arguments[ i ] = QMetaType::create( types[ i ], argv[ i ] ); } if ( receiver.isNull() ) diff --git a/src/common/QskMetaFunction.h b/src/common/QskMetaFunction.h index 065d07e58..337d5b5a7 100644 --- a/src/common/QskMetaFunction.h +++ b/src/common/QskMetaFunction.h @@ -59,20 +59,20 @@ namespace QskMetaFunctionTraits template< typename T, size_t i, IsMemberFunction< T >* = nullptr > constexpr typename std::enable_if < i < argumentCount< T >(), int >::type argumentType() { - return ConnectionTypes< typename FunctionPointer< T >::Arguments >::types()[i]; + return ConnectionTypes< typename FunctionPointer< T >::Arguments >::types()[ i ]; } template< typename T, size_t i, IsStaticFunction< T >* = nullptr > constexpr typename std::enable_if < i < argumentCount< T >(), int >::type argumentType() { - return ConnectionTypes< typename FunctionPointer< T >::Arguments >::types()[i]; + return ConnectionTypes< typename FunctionPointer< T >::Arguments >::types()[ i ]; } template< typename T, size_t i, IsFunctor< T >* = nullptr > constexpr typename std::enable_if < i < argumentCount< T >(), int >::type argumentType() { using Traits = FunctionPointer< decltype( &T::operator() ) >; - return ConnectionTypes< typename Traits::Arguments >::types()[i]; + return ConnectionTypes< typename Traits::Arguments >::types()[ i ]; } } @@ -80,7 +80,7 @@ class QSK_EXPORT QskMetaFunction { Q_GADGET -public: + public: enum Type { Invalid = -1, @@ -135,10 +135,10 @@ class QSK_EXPORT QskMetaFunction class FunctionCall; FunctionCall* functionCall() const; -protected: + protected: QskMetaFunction( FunctionCall* ); -private: + private: FunctionCall* m_functionCall; }; diff --git a/src/common/QskMetaInvokable.cpp b/src/common/QskMetaInvokable.cpp index b39af8367..5455556d3 100644 --- a/src/common/QskMetaInvokable.cpp +++ b/src/common/QskMetaInvokable.cpp @@ -8,10 +8,9 @@ #include #include - -#include #include #include +#include QSK_QT_PRIVATE_BEGIN #include @@ -23,9 +22,9 @@ namespace class Function : public QskMetaFunction { - public: - inline Function( void* functionCall ): - QskMetaFunction( static_cast< FunctionCall* >( functionCall ) ) + public: + inline Function( void* functionCall ) + : QskMetaFunction( static_cast< FunctionCall* >( functionCall ) ) { } @@ -44,15 +43,16 @@ namespace class MetaCallEvent final : public QMetaCallEvent { - public: - MetaCallEvent( QMetaObject::Call call, CallFunction callFunction, - ushort offset, ushort index, - int nargs, int* types, void* args[], QSemaphore* semaphore = nullptr ): - QMetaCallEvent( offset, index, callFunction, nullptr, -1, - nargs, types, args, semaphore ), - m_call( call ), - m_callFunction( callFunction ), - m_index( index ) + public: + MetaCallEvent( + QMetaObject::Call call, CallFunction callFunction, ushort offset, + ushort index, int nargs, int* types, void* args[], + QSemaphore* semaphore = nullptr ) + : QMetaCallEvent( offset, index, callFunction, nullptr, -1, + nargs, types, args, semaphore ) + , m_call( call ) + , m_callFunction( callFunction ) + , m_index( index ) { } @@ -61,7 +61,7 @@ namespace m_callFunction( object, m_call, m_index, args() ); } - private: + private: const QMetaObject::Call m_call; // as those members from QMetaCallEvent are not accessible @@ -70,9 +70,10 @@ namespace }; } -static inline void qskInvokeMetaCallQueued( QObject* object, - QMetaObject::Call call, ushort offset, ushort index, - int nargs, int* types, void* args[], QSemaphore* semaphore = nullptr ) +static inline void qskInvokeMetaCallQueued( + QObject* object, QMetaObject::Call call, ushort offset, + ushort index, int nargs, int* types, void* args[], + QSemaphore* semaphore = nullptr ) { const auto callFunction = object->metaObject()->d.static_metacall; @@ -97,12 +98,12 @@ QMetaMethod qskMetaMethod( const QMetaObject* metaObject, const char* methodName int index = -1; - if( methodName[0] == signalIndicator ) + if ( methodName[ 0 ] == signalIndicator ) { - auto signature = QMetaObject::normalizedSignature( methodName + 1 ); + auto signature = QMetaObject::normalizedSignature( methodName + 1 ); index = metaObject->indexOfSignal( signature ); } - else if ( methodName[0] == slotIndicator ) + else if ( methodName[ 0 ] == slotIndicator ) { auto signature = QMetaObject::normalizedSignature( methodName + 1 ); index = metaObject->indexOfSlot( signature ); @@ -136,9 +137,10 @@ QMetaMethod qskNotifySignal( const QMetaObject* metaObject, const char* property return QMetaMethod(); } -static void qskInvokeMetaCall( QObject* object, - const QMetaObject* metaObject, QMetaObject::Call call, - int offset, int index, void* argv[], Qt::ConnectionType connectionType ) +static void qskInvokeMetaCall( + QObject* object, const QMetaObject* metaObject, + QMetaObject::Call call, int offset, int index, void* argv[], + Qt::ConnectionType connectionType ) { QPointer< QObject > receiver( object ); @@ -150,7 +152,7 @@ static void qskInvokeMetaCall( QObject* object, ? Qt::QueuedConnection : Qt::DirectConnection; } - switch( invokeType ) + switch ( invokeType ) { case Qt::DirectConnection: { @@ -172,8 +174,8 @@ static void qskInvokeMetaCall( QObject* object, } case Qt::BlockingQueuedConnection: { - if ( receiver.isNull() - || ( receiver->thread() == QThread::currentThread() ) ) + if ( receiver.isNull() || + ( receiver->thread() == QThread::currentThread() ) ) { // We would end up in a deadlock, better do nothing return; @@ -181,8 +183,8 @@ static void qskInvokeMetaCall( QObject* object, QSemaphore semaphore; - qskInvokeMetaCallQueued( receiver, call, offset, index, - 0, nullptr, argv, &semaphore ); + qskInvokeMetaCallQueued( receiver, call, + offset, index, 0, nullptr, argv, &semaphore ); semaphore.acquire(); @@ -213,20 +215,20 @@ static void qskInvokeMetaCall( QObject* object, invalid for Queued Connections. */ - types[0] = QMetaType::UnknownType; - arguments[0] = nullptr; + types[ 0 ] = QMetaType::UnknownType; + arguments[ 0 ] = nullptr; for ( int i = 1; i < argc; i++ ) { - if ( argv[i] == nullptr ) + if ( argv[ i ] == nullptr ) { - Q_ASSERT( argv[i] != nullptr ); + Q_ASSERT( argv[ i ] != nullptr ); receiver = nullptr; break; } - types[i] = method.parameterType( i - 1 ); - arguments[i] = QMetaType::create( types[i], argv[i] ); + types[ i ] = method.parameterType( i - 1 ); + arguments[ i ] = QMetaType::create( types[ i ], argv[ i ] ); } } else @@ -239,8 +241,8 @@ static void qskInvokeMetaCall( QObject* object, types = static_cast< int* >( malloc( argc * sizeof( int ) ) ); arguments = static_cast< void** >( malloc( argc * sizeof( void* ) ) ); - types[0] = property.userType(); - arguments[0] = QMetaType::create( types[0], argv[0] ); + types[ 0 ] = property.userType(); + arguments[ 0 ] = QMetaType::create( types[ 0 ], argv[ 0 ] ); } if ( receiver.isNull() ) @@ -260,21 +262,20 @@ static void qskInvokeMetaCall( QObject* object, } } -void qskInvokeMetaPropertyWrite( QObject* context, - const QMetaProperty& property, void* args[], Qt::ConnectionType connectionType ) +void qskInvokeMetaPropertyWrite( QObject* context, const QMetaProperty& property, + void* args[], Qt::ConnectionType connectionType ) { qskInvokeMetaPropertyWrite( context, property.enclosingMetaObject(), property.propertyIndex(), args, connectionType ); } -void qskInvokeMetaPropertyWrite( QObject* context, - const QMetaObject* metaObject, int propertyIndex, - void* args[], Qt::ConnectionType connectionType ) +void qskInvokeMetaPropertyWrite( QObject* context, const QMetaObject* metaObject, + int propertyIndex, void* args[], Qt::ConnectionType connectionType ) { // check for is writable ??? - if ( metaObject && ( propertyIndex >= 0 ) - && ( propertyIndex < metaObject->propertyCount() ) ) + if ( metaObject && ( propertyIndex >= 0 ) && + ( propertyIndex < metaObject->propertyCount() ) ) { const auto offset = metaObject->propertyOffset(); const auto index = propertyIndex - offset; @@ -296,10 +297,9 @@ void qskInvokeMetaMethod( QObject* object, const QMetaObject* metaObject, int methodIndex, void* argv[], Qt::ConnectionType connectionType ) { - if ( metaObject && ( methodIndex >= 0 ) - && ( methodIndex < metaObject->methodCount() ) ) + if ( metaObject && ( methodIndex >= 0 ) && + ( methodIndex < metaObject->methodCount() ) ) { - const auto offset = metaObject->methodOffset(); const auto index = methodIndex - offset; @@ -308,39 +308,39 @@ void qskInvokeMetaMethod( QObject* object, } } -QskMetaInvokable::QskMetaInvokable( const QMetaMethod& method ): - m_metaData { method.enclosingMetaObject(), method.methodIndex() }, - m_type( MetaMethod ) +QskMetaInvokable::QskMetaInvokable( const QMetaMethod& method ) + : m_metaData{ method.enclosingMetaObject(), method.methodIndex() } + , m_type( MetaMethod ) { } -QskMetaInvokable::QskMetaInvokable( const QObject* object, const char* methodName ): - QskMetaInvokable( qskMetaMethod( object, methodName ) ) +QskMetaInvokable::QskMetaInvokable( const QObject* object, const char* methodName ) + : QskMetaInvokable( qskMetaMethod( object, methodName ) ) { } -QskMetaInvokable::QskMetaInvokable( const QMetaObject* metaObject, const char* methodName ): - QskMetaInvokable( qskMetaMethod( metaObject, methodName ) ) +QskMetaInvokable::QskMetaInvokable( const QMetaObject* metaObject, const char* methodName ) + : QskMetaInvokable( qskMetaMethod( metaObject, methodName ) ) { } -QskMetaInvokable::QskMetaInvokable( const QMetaProperty& property ): - m_metaData { property.enclosingMetaObject(), property.propertyIndex() }, - m_type( MetaProperty ) +QskMetaInvokable::QskMetaInvokable( const QMetaProperty& property ) + : m_metaData{ property.enclosingMetaObject(), property.propertyIndex() } + , m_type( MetaProperty ) { } -QskMetaInvokable::QskMetaInvokable( const QskMetaFunction& function ): - m_functionData { function.functionCall() }, - m_type( MetaFunction ) +QskMetaInvokable::QskMetaInvokable( const QskMetaFunction& function ) + : m_functionData{ function.functionCall() } + , m_type( MetaFunction ) { Function::ref( m_functionData.functionCall ); } -QskMetaInvokable::QskMetaInvokable( const QskMetaInvokable& other ): - m_type( other.m_type ) +QskMetaInvokable::QskMetaInvokable( const QskMetaInvokable& other ) + : m_type( other.m_type ) { - switch( m_type ) + switch ( m_type ) { case MetaMethod: case MetaProperty: @@ -371,7 +371,7 @@ QskMetaInvokable::~QskMetaInvokable() QskMetaInvokable& QskMetaInvokable::operator=( const QskMetaInvokable& other ) { - switch( other.m_type ) + switch ( other.m_type ) { case MetaMethod: case MetaProperty: @@ -386,7 +386,7 @@ QskMetaInvokable& QskMetaInvokable::operator=( const QskMetaInvokable& other ) } case MetaFunction: { - if ( m_type == MetaFunction ) + if ( m_type == MetaFunction ) Function::deref( m_functionData.functionCall ); m_functionData.functionCall = other.m_functionData.functionCall; @@ -410,13 +410,13 @@ bool QskMetaInvokable::operator==( const QskMetaInvokable& other ) const if ( m_type != other.m_type ) return false; - switch( m_type ) + switch ( m_type ) { case MetaMethod: case MetaProperty: { - return ( m_metaData.metaObject == other.m_metaData.metaObject ) - && ( m_metaData.index == other.m_metaData.index ); + return ( m_metaData.metaObject == other.m_metaData.metaObject ) && + ( m_metaData.index == other.m_metaData.index ); } case MetaFunction: { @@ -431,7 +431,7 @@ bool QskMetaInvokable::operator==( const QskMetaInvokable& other ) const bool QskMetaInvokable::isNull() const { - switch( m_type ) + switch ( m_type ) { case MetaMethod: case MetaProperty: @@ -466,7 +466,7 @@ void QskMetaInvokable::reset() int QskMetaInvokable::parameterCount() const { - switch( m_type ) + switch ( m_type ) { case MetaMethod: { @@ -491,7 +491,7 @@ int QskMetaInvokable::parameterCount() const int QskMetaInvokable::parameterType( int index ) const { - switch( m_type ) + switch ( m_type ) { case MetaMethod: { @@ -506,7 +506,7 @@ int QskMetaInvokable::parameterType( int index ) const case MetaFunction: { auto types = function().parameterTypes(); - return types[index]; + return types[ index ]; } default: { @@ -517,7 +517,7 @@ int QskMetaInvokable::parameterType( int index ) const int QskMetaInvokable::returnType() const { - switch( m_type ) + switch ( m_type ) { case MetaMethod: { @@ -540,7 +540,7 @@ int QskMetaInvokable::returnType() const QByteArray QskMetaInvokable::name() const { - switch( m_type ) + switch ( m_type ) { case MetaMethod: { @@ -595,7 +595,7 @@ void QskMetaInvokable::invoke( QObject* object, void* args[], if ( isNull() ) return; - switch( m_type ) + switch ( m_type ) { case MetaMethod: { @@ -606,9 +606,8 @@ void QskMetaInvokable::invoke( QObject* object, void* args[], } case MetaProperty: { - qskInvokeMetaPropertyWrite( object, - m_metaData.metaObject, m_metaData.index, - args, connectionType ); + qskInvokeMetaPropertyWrite( + object, m_metaData.metaObject, m_metaData.index, args, connectionType ); break; } diff --git a/src/common/QskMetaInvokable.h b/src/common/QskMetaInvokable.h index d770e2694..aa3ca110f 100644 --- a/src/common/QskMetaInvokable.h +++ b/src/common/QskMetaInvokable.h @@ -20,7 +20,7 @@ class QByteArray; class QSK_EXPORT QskMetaInvokable { -public: + public: enum Type { Invalid = 0, @@ -75,7 +75,7 @@ class QSK_EXPORT QskMetaInvokable QMetaProperty property() const; QskMetaFunction function() const; -private: + private: struct FunctionData { void* functionCall; @@ -96,8 +96,8 @@ class QSK_EXPORT QskMetaInvokable int m_type : 3; }; -inline QskMetaInvokable::QskMetaInvokable(): - m_type( Invalid ) +inline QskMetaInvokable::QskMetaInvokable() + : m_type( Invalid ) { } @@ -135,11 +135,9 @@ QSK_EXPORT void qskInvokeMetaPropertyWrite( const QObject* object, const QMetaProperty&, void* args[], Qt::ConnectionType = Qt::AutoConnection ); - QSK_EXPORT QMetaMethod qskNotifySignal( const QMetaObject*, const char* propertyName ); QSK_EXPORT QMetaMethod qskNotifySignal( const QObject*, const char* propertyName ); - Q_DECLARE_METATYPE( QskMetaInvokable ) #endif diff --git a/src/common/QskModule.cpp b/src/common/QskModule.cpp index e11136fc4..7a613e16a 100644 --- a/src/common/QskModule.cpp +++ b/src/common/QskModule.cpp @@ -5,33 +5,34 @@ #include "QskModule.h" -#include "QskSetup.h" -#include "QskSkinManager.h" -#include "QskSkin.h" -#include "QskPushButton.h" #include "QskCorner.h" #include "QskDialog.h" #include "QskDialogButton.h" #include "QskDialogButtonBox.h" -#include "QskDialogWindow.h" #include "QskDialogSubWindow.h" +#include "QskDialogWindow.h" #include "QskFocusIndicator.h" #include "QskGradient.h" #include "QskGraphicLabel.h" #include "QskGridBox.h" -#include "QskVirtualKeyboard.h" +#include "QskLinearBox.h" +#include "QskMessageWindow.h" +#include "QskPopup.h" +#include "QskPushButton.h" #include "QskRgbValue.h" -#include "QskScrollView.h" #include "QskScrollArea.h" +#include "QskScrollView.h" +#include "QskSelectionWindow.h" #include "QskSeparator.h" -#include "QskSimpleListBox.h" +#include "QskSetup.h" #include "QskShortcut.h" +#include "QskSimpleListBox.h" +#include "QskSkin.h" +#include "QskSkinManager.h" #include "QskSlider.h" #include "QskStackBox.h" #include "QskStandardSymbol.h" #include "QskStatusIndicator.h" -#include "QskLinearBox.h" -#include "QskPopup.h" #include "QskSubWindow.h" #include "QskSubWindowArea.h" #include "QskTabBar.h" @@ -39,17 +40,16 @@ #include "QskTabView.h" #include "QskTextLabel.h" #include "QskTextOptions.h" -#include "QskMessageWindow.h" -#include "QskSelectionWindow.h" +#include "QskVirtualKeyboard.h" #include "QskWindow.h" -#include -#include #include +#include +#include QSK_QT_PRIVATE_BEGIN -#include #include +#include #include QSK_QT_PRIVATE_END @@ -93,7 +93,7 @@ QSK_QT_PRIVATE_END template< typename Type, typename Gadget > class ValueProvider : public QQmlValueTypeProvider { -public: + public: const QMetaObject* getMetaObjectForMetaType( int id ) override { if ( id == qMetaTypeId< Type >() ) @@ -105,9 +105,10 @@ class ValueProvider : public QQmlValueTypeProvider // Expose values in QskRgbValue to QML struct QskRgbValue_Gadget { - enum Enum { -#define RGB(name, value) name = value, -QSK_RGB_VALUES + enum Enum + { +#define RGB( name, value ) name = value, + QSK_RGB_VALUES #undef RGB }; @@ -136,10 +137,10 @@ Q_DECLARE_METATYPE( QMarginsF ) class QskSetupFlagsProvider : public QskSetup::Flags { Q_GADGET -public: - template< typename ... Args > - QskSetupFlagsProvider( Args&& ... args ): - QskSetup::Flags( std::forward< Args >( args ) ... ) + public: + template< typename... Args > + QskSetupFlagsProvider( Args&&... args ) + : QskSetup::Flags( std::forward< Args >( args )... ) { } @@ -148,7 +149,7 @@ class QskSetupFlagsProvider : public QskSetup::Flags class QskMain : public QObject { -public: + public: Q_OBJECT Q_PRIVATE_PROPERTY( setup(), QString skin READ skinName @@ -162,9 +163,9 @@ class QskMain : public QObject Q_PROPERTY( QQmlListProperty< QObject > data READ data ) Q_CLASSINFO( "DefaultProperty", "data" ) -public: - QskMain( QObject* parent = nullptr ): - QObject( parent ) + public: + QskMain( QObject* parent = nullptr ) + : QObject( parent ) { // how to supress warnings about a missing skinListChanged // as we don't have it ?? @@ -186,22 +187,22 @@ class QskMain : public QObject { return QQmlListProperty< QObject >( this, nullptr, - [] ( QQmlListProperty< QObject >* property, QObject* value ) + []( QQmlListProperty< QObject >* property, QObject* value ) { QskMain* main = static_cast< QskMain* >( property->object ); main->m_data.append( value ); }, - [] ( QQmlListProperty< QObject >* property ) + []( QQmlListProperty< QObject >* property ) { const QskMain* main = static_cast< const QskMain* >( property->object ); return main->m_data.count(); }, - [] ( QQmlListProperty< QObject >* property, int index ) + []( QQmlListProperty< QObject >* property, int index ) { const QskMain* main = static_cast< const QskMain* >( property->object ); return main->m_data.at( index ); }, - [] ( QQmlListProperty< QObject >* property ) + []( QQmlListProperty< QObject >* property ) { QskMain* main = static_cast< QskMain* >( property->object ); main->m_data.clear(); @@ -209,13 +210,13 @@ class QskMain : public QObject ); } -Q_SIGNALS: + Q_SIGNALS: void skinListChanged(); // never emitted void skinChanged(); void inputPanelChanged(); void controlFlagsChanged(); -private: + private: static inline QskSetup* setup() { return QskSetup::instance(); } QObjectList m_data; @@ -290,31 +291,31 @@ void QskModule::registerTypes() // Support (lists of) GradientStop QMetaType::registerConverter< QJSValue, QskGradientStop >( - [] (const QJSValue& value) -> QskGradientStop + [](const QJSValue& value) -> QskGradientStop { return { - value.property( QLatin1String("position") ).toNumber(), - value.property( QLatin1String("color") ).toVariant().value< QColor >() + value.property( QLatin1String( "position" ) ).toNumber(), + value.property( QLatin1String( "color" ) ).toVariant().value< QColor >() }; } ); QMetaType::registerConverter< QJSValue, QVector< QskGradientStop > >( - [] ( const QJSValue& value ) + []( const QJSValue& value ) { QVector< QskGradientStop > stops; if ( value.isArray() ) { - QJSValueIterator it(value); + QJSValueIterator it( value ); while ( it.next() && it.hasNext() ) { auto source = it.value(); auto target = QskGradientStop(); - QMetaType::convert(&source, qMetaTypeId< decltype( source ) >(), + QMetaType::convert( &source, qMetaTypeId< decltype( source ) >(), &target, qMetaTypeId< decltype( target ) >() ); - stops.append(target); + stops.append( target ); } } return stops; @@ -326,7 +327,7 @@ void QskModule::registerTypes() QQmlMetaType::registerCustomStringConverter( qMetaTypeId< QMarginsF >(), - [] ( const QString& rhs ) + []( const QString& rhs ) { auto margin = rhs.toDouble(); return QVariant::fromValue( QMarginsF( margin, margin, margin, margin ) ); @@ -334,26 +335,26 @@ void QskModule::registerTypes() ); QMetaType::registerConverter< int, QMarginsF >( - [] ( int value ) { return QMarginsF( value, value, value, value ); } ); + []( int value ) { return QMarginsF( value, value, value, value ); } ); QMetaType::registerConverter< qreal, QMarginsF >( - [] ( qreal value ) { return QMarginsF( value, value, value, value ); } ); + []( qreal value ) { return QMarginsF( value, value, value, value ); } ); qRegisterAnimationInterpolator( []( const QMarginsF& from, const QMarginsF& to, qreal progress ) { - return QVariant::fromValue(QMarginsF( + return QVariant::fromValue( QMarginsF( _q_interpolate( from.left(), to.left(), progress ), _q_interpolate( from.top(), to.top(), progress ), _q_interpolate( from.right(), to.right(), progress ), _q_interpolate( from.bottom(), to.bottom(), progress ) - )); + ) ); } ); // Support QskSizePolicy in QML user properties QMetaType::registerConverter< QJSValue, QskSizePolicy >( - [] ( const QJSValue& value ) + []( const QJSValue& value ) { return QskSizePolicy( static_cast< QskSizePolicy::Policy >( value.property( 0 ).toInt() ), @@ -362,7 +363,7 @@ void QskModule::registerTypes() ); QMetaType::registerConverter< int, QskSizePolicy >( - [] ( int value ) + []( int value ) { const auto policy = static_cast< QskSizePolicy::Policy >( value ); return QskSizePolicy( policy, policy ); diff --git a/src/common/QskObjectCounter.cpp b/src/common/QskObjectCounter.cpp index 87de8ef7c..785a0852b 100644 --- a/src/common/QskObjectCounter.cpp +++ b/src/common/QskObjectCounter.cpp @@ -5,13 +5,13 @@ #include "QskObjectCounter.h" -#include #include +#include QSK_QT_PRIVATE_BEGIN #include -#include #include +#include QSK_QT_PRIVATE_END static inline bool qskIsItem( const QObject* object ) @@ -34,23 +34,23 @@ static void qskRemoveObjectHook( QObject* ); class QskObjectCounterHook { -public: + public: QskObjectCounterHook() { - m_otherStartup = qtHookData[QHooks::Startup]; - m_otherAddObject = qtHookData[QHooks::AddQObject]; - m_otherRemoveObject = qtHookData[QHooks::RemoveQObject]; + m_otherStartup = qtHookData[ QHooks::Startup ]; + m_otherAddObject = qtHookData[ QHooks::AddQObject ]; + m_otherRemoveObject = qtHookData[ QHooks::RemoveQObject ]; - qtHookData[QHooks::Startup] = reinterpret_cast< quintptr >( &qskStartupHook ); - qtHookData[QHooks::AddQObject] = reinterpret_cast< quintptr >( &qskAddObjectHook ); - qtHookData[QHooks::RemoveQObject] = reinterpret_cast< quintptr >( &qskRemoveObjectHook ); + qtHookData[ QHooks::Startup ] = reinterpret_cast< quintptr >( &qskStartupHook ); + qtHookData[ QHooks::AddQObject ] = reinterpret_cast< quintptr >( &qskAddObjectHook ); + qtHookData[ QHooks::RemoveQObject ] = reinterpret_cast< quintptr >( &qskRemoveObjectHook ); } ~QskObjectCounterHook() { - qtHookData[QHooks::Startup] = m_otherStartup; - qtHookData[QHooks::AddQObject] = m_otherAddObject; - qtHookData[QHooks::RemoveQObject] = m_otherRemoveObject; + qtHookData[ QHooks::Startup ] = m_otherStartup; + qtHookData[ QHooks::AddQObject ] = m_otherAddObject; + qtHookData[ QHooks::RemoveQObject ] = m_otherRemoveObject; } void registerCounter( QskObjectCounter* counter, bool on ) @@ -100,7 +100,7 @@ class QskObjectCounterHook static bool autoDelete; -private: + private: QSet< QskObjectCounter* > m_counterSet; quintptr m_otherStartup; @@ -148,8 +148,8 @@ static void qskInstallCleanupHookHandler() Q_COREAPP_STARTUP_FUNCTION( qskInstallCleanupHookHandler ) -QskObjectCounter::QskObjectCounter( bool debugAtDestruction ): - m_debugAtDestruction( debugAtDestruction ) +QskObjectCounter::QskObjectCounter( bool debugAtDestruction ) + : m_debugAtDestruction( debugAtDestruction ) { setActive( true ); } @@ -192,49 +192,49 @@ bool QskObjectCounter::isActive() const void QskObjectCounter::addObject( QObject* object ) { - m_counter[Objects].increment(); + m_counter[ Objects ].increment(); if ( qskIsItem( object ) ) - m_counter[Items].increment(); + m_counter[ Items ].increment(); } void QskObjectCounter::removeObject( QObject* object ) { - m_counter[Objects].decrement(); + m_counter[ Objects ].decrement(); if ( qskIsItem( object ) ) - m_counter[Items].decrement(); + m_counter[ Items ].decrement(); } void QskObjectCounter::reset() { - m_counter[Objects].reset(); - m_counter[Items].reset(); + m_counter[ Objects ].reset(); + m_counter[ Items ].reset(); } int QskObjectCounter::created( ObjectType objectType ) const { - return m_counter[objectType].created; + return m_counter[ objectType ].created; } int QskObjectCounter::destroyed( ObjectType objectType ) const { - return m_counter[objectType].destroyed; + return m_counter[ objectType ].destroyed; } int QskObjectCounter::current( ObjectType objectType ) const { - return m_counter[objectType].current; + return m_counter[ objectType ].current; } int QskObjectCounter::maximum( ObjectType objectType ) const { - return m_counter[objectType].maximum; + return m_counter[ objectType ].maximum; } void QskObjectCounter::debugStatistics( QDebug debug, ObjectType objectType ) const { - const Counter& c = m_counter[objectType]; + const Counter& c = m_counter[ objectType ]; QDebugStateSaver saver( debug ); debug.nospace(); @@ -271,4 +271,3 @@ QDebug operator<<( QDebug debug, const QskObjectCounter& counter ) } #endif - diff --git a/src/common/QskObjectCounter.h b/src/common/QskObjectCounter.h index 5ec527513..8eaea8ea3 100644 --- a/src/common/QskObjectCounter.h +++ b/src/common/QskObjectCounter.h @@ -14,7 +14,7 @@ class QskObjectCounterHook; class QSK_EXPORT QskObjectCounter { -public: + public: enum ObjectType { Objects, @@ -37,7 +37,7 @@ class QSK_EXPORT QskObjectCounter void debugStatistics( QDebug, ObjectType = Objects ) const; void dump() const; -private: + private: friend class QskObjectCounterHook; void addObject( QObject* ); @@ -45,7 +45,7 @@ class QSK_EXPORT QskObjectCounter class Counter { - public: + public: Counter() { reset(); @@ -77,7 +77,7 @@ class QSK_EXPORT QskObjectCounter int maximum; }; - Counter m_counter[2]; + Counter m_counter[ 2 ]; const bool m_debugAtDestruction; }; diff --git a/src/common/QskSizePolicy.h b/src/common/QskSizePolicy.h index 1494946da..d59e529c5 100644 --- a/src/common/QskSizePolicy.h +++ b/src/common/QskSizePolicy.h @@ -7,6 +7,7 @@ #define QSK_SIZE_POLICY_H_ #include "QskGlobal.h" + #include class QDebug; @@ -15,10 +16,13 @@ class QSK_EXPORT QskSizePolicy { Q_GADGET - Q_PROPERTY( Policy horizontalPolicy READ horizontalPolicy WRITE setHorizontalPolicy ) - Q_PROPERTY( Policy verticalPolicy READ verticalPolicy WRITE setVerticalPolicy ) + Q_PROPERTY( Policy horizontalPolicy + READ horizontalPolicy WRITE setHorizontalPolicy ) + + Q_PROPERTY( Policy verticalPolicy + READ verticalPolicy WRITE setVerticalPolicy ) -public: + public: enum Flag { GrowFlag = 1, @@ -57,27 +61,28 @@ class QSK_EXPORT QskSizePolicy Policy policy( Qt::Orientation ) const; void setPolicy( Qt::Orientation, Policy ); -private: + private: quint32 m_horizontalPolicy : 4; quint32 m_verticalPolicy : 4; }; -inline QskSizePolicy::QskSizePolicy(): - m_horizontalPolicy( Ignored ), - m_verticalPolicy( Ignored ) +inline QskSizePolicy::QskSizePolicy() + : m_horizontalPolicy( Ignored ) + , m_verticalPolicy( Ignored ) { } -inline QskSizePolicy::QskSizePolicy( Policy horizontalPolicy, Policy verticalPolicy ): - m_horizontalPolicy( horizontalPolicy ), - m_verticalPolicy( verticalPolicy ) +inline QskSizePolicy::QskSizePolicy( + Policy horizontalPolicy, Policy verticalPolicy ) + : m_horizontalPolicy( horizontalPolicy ) + , m_verticalPolicy( verticalPolicy ) { } inline bool QskSizePolicy::operator==( const QskSizePolicy& other ) const { - return ( other.m_horizontalPolicy == m_horizontalPolicy ) - && ( other.m_verticalPolicy == m_verticalPolicy ); + return ( other.m_horizontalPolicy == m_horizontalPolicy ) && + ( other.m_verticalPolicy == m_verticalPolicy ); } inline bool QskSizePolicy::operator!=( const QskSizePolicy& other ) const diff --git a/src/common/QskTextColors.cpp b/src/common/QskTextColors.cpp index e4c70da69..7857b7b2a 100644 --- a/src/common/QskTextColors.cpp +++ b/src/common/QskTextColors.cpp @@ -6,18 +6,12 @@ #include "QskTextColors.h" #include "QskRgbValue.h" -#include #include +#include uint QskTextColors::hash( uint seed ) const { - const QRgb rgb[] = - { - textColor.rgba(), - styleColor.rgba(), - linkColor.rgba() - }; - + const QRgb rgb[] = { textColor.rgba(), styleColor.rgba(), linkColor.rgba() }; return qHashBits( rgb, sizeof( rgb ), seed ); } @@ -30,11 +24,10 @@ QskTextColors QskTextColors::interpolated( colors.linkColor = QskRgbValue::interpolated( linkColor, to.linkColor, ratio ); return colors; - } -QVariant QskTextColors::interpolate( const QskTextColors& from, - const QskTextColors& to, qreal ratio ) +QVariant QskTextColors::interpolate( + const QskTextColors& from, const QskTextColors& to, qreal ratio ) { return QVariant::fromValue( from.interpolated( to, ratio ) ); } @@ -74,5 +67,3 @@ QDebug operator<<( QDebug debug, const QskTextColors& colors ) } #endif - - diff --git a/src/common/QskTextColors.h b/src/common/QskTextColors.h index 54da05554..291a5de8c 100644 --- a/src/common/QskTextColors.h +++ b/src/common/QskTextColors.h @@ -7,6 +7,7 @@ #define QSK_TEXT_COLORS_H #include "QskGlobal.h" + #include #include @@ -15,7 +16,7 @@ class QVariant; class QSK_EXPORT QskTextColors { -public: + public: QskTextColors( const QColor& text = QColor(), const QColor& style = QColor(), const QColor& link = QColor() ); @@ -32,10 +33,10 @@ class QSK_EXPORT QskTextColors }; inline QskTextColors::QskTextColors( - const QColor& text, const QColor& style, const QColor& link ): - textColor( text ), - styleColor( style ), - linkColor( link ) + const QColor& text, const QColor& style, const QColor& link ) + : textColor( text ) + , styleColor( style ) + , linkColor( link ) { } diff --git a/src/common/QskTextOptions.cpp b/src/common/QskTextOptions.cpp index 7c4d7ac0a..9ae56256d 100644 --- a/src/common/QskTextOptions.cpp +++ b/src/common/QskTextOptions.cpp @@ -7,12 +7,12 @@ #include #include -QskTextOptions::QskTextOptions(): - m_maximumLineCount( std::numeric_limits< int >::max() ), - m_fontSizeMode( QskTextOptions::FixedSize ), - m_wrapMode( QskTextOptions::NoWrap ), - m_format( PlainText ), // AutoText ??? - m_elideMode( Qt::ElideNone ) +QskTextOptions::QskTextOptions() + : m_maximumLineCount( std::numeric_limits< int >::max() ) + , m_fontSizeMode( QskTextOptions::FixedSize ) + , m_wrapMode( QskTextOptions::NoWrap ) + , m_format( PlainText ) // AutoText ??? + , m_elideMode( Qt::ElideNone ) { } @@ -49,10 +49,10 @@ QskTextOptions::WrapMode QskTextOptions::wrapMode() const void QskTextOptions::setFontSizeMode( FontSizeMode fontSizeMode ) { m_fontSizeMode = fontSizeMode; -} - +} + QskTextOptions::FontSizeMode QskTextOptions::fontSizeMode() const -{ +{ return m_fontSizeMode; } @@ -70,9 +70,9 @@ int QskTextOptions::textFlags() const { int flags = 0; - switch( m_wrapMode ) + switch ( m_wrapMode ) { - case QTextOption::NoWrap: + case QskTextOptions::NoWrap: { flags |= Qt::TextSingleLine; break; @@ -101,11 +101,11 @@ int QskTextOptions::textFlags() const bool QskTextOptions::operator==( const QskTextOptions& other ) const { - return ( m_format == other.m_format ) - && ( m_elideMode == other.m_elideMode ) - && ( m_wrapMode == other.m_wrapMode ) - && ( m_fontSizeMode == other.m_fontSizeMode ) - && ( m_maximumLineCount == other.m_maximumLineCount ); + return ( m_format == other.m_format ) && + ( m_elideMode == other.m_elideMode ) && + ( m_wrapMode == other.m_wrapMode ) && + ( m_fontSizeMode == other.m_fontSizeMode ) && + ( m_maximumLineCount == other.m_maximumLineCount ); } QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text ) const @@ -119,7 +119,7 @@ QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text return m_format; } -uint qHash( const QskTextOptions &options, uint seed ) noexcept +uint qHash( const QskTextOptions& options, uint seed ) noexcept { uint hash; diff --git a/src/common/QskTextOptions.h b/src/common/QskTextOptions.h index 854008e1a..db15718b5 100644 --- a/src/common/QskTextOptions.h +++ b/src/common/QskTextOptions.h @@ -22,9 +22,9 @@ class QSK_EXPORT QskTextOptions Q_PROPERTY( FontSizeMode fontSizeMode READ fontSizeMode WRITE setFontSizeMode ) Q_PROPERTY( int maximumLineCount READ maximumLineCount WRITE setMaximumLineCount ) -public: + public: enum FontSizeMode - { + { FixedSize, HorizontalFit, VerticalFit, @@ -73,7 +73,7 @@ class QSK_EXPORT QskTextOptions int textFlags() const; -private: + private: int m_maximumLineCount; FontSizeMode m_fontSizeMode : 2; WrapMode m_wrapMode : 4; @@ -86,7 +86,7 @@ inline bool QskTextOptions::operator!=( const QskTextOptions& other ) const return !( *this == other ); } -QSK_EXPORT uint qHash( const QskTextOptions &, uint seed = 0) noexcept; +QSK_EXPORT uint qHash( const QskTextOptions&, uint seed = 0 ) noexcept; #ifndef QT_NO_DEBUG_STREAM QSK_EXPORT QDebug operator<<( QDebug, const QskTextOptions& ); diff --git a/src/controls/QskAbstractButton.cpp b/src/controls/QskAbstractButton.cpp index ead37b98d..1344fe1b3 100644 --- a/src/controls/QskAbstractButton.cpp +++ b/src/controls/QskAbstractButton.cpp @@ -36,27 +36,27 @@ static QskAbstractButton* qskCheckedSibling( const QskAbstractButton* button ) class QskAbstractButton::PrivateData { -public: - PrivateData(): - autoRepeatDelay( 300 ), - autoRepeatInterval( 100 ), - exclusive( false ), - autoRepeat( false ) + public: + PrivateData() + : autoRepeatDelay( 300 ) + , autoRepeatInterval( 100 ) + , exclusive( false ) + , autoRepeat( false ) { } QBasicTimer repeatTimer; - int autoRepeatDelay; // milliseconds + int autoRepeatDelay; // milliseconds int autoRepeatInterval; // milliseconds bool exclusive : 1; bool autoRepeat : 1; }; -QskAbstractButton::QskAbstractButton( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskAbstractButton::QskAbstractButton( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setFocusPolicy( Qt::StrongFocus ); setAcceptedMouseButtons( Qt::LeftButton ); @@ -247,7 +247,7 @@ bool QskAbstractButton::exclusive() const bool QskAbstractButton::event( QEvent* event ) { const auto eventType = static_cast< int >( event->type() ); - switch( eventType ) + switch ( eventType ) { case QEvent::Shortcut: { diff --git a/src/controls/QskAbstractButton.h b/src/controls/QskAbstractButton.h index 61e6da8e3..11e40468a 100644 --- a/src/controls/QskAbstractButton.h +++ b/src/controls/QskAbstractButton.h @@ -13,23 +13,30 @@ class QSK_EXPORT QskAbstractButton : public QskControl { Q_OBJECT - Q_PROPERTY( bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL ) + Q_PROPERTY( bool checkable READ isCheckable + WRITE setCheckable NOTIFY checkableChanged FINAL ) + + Q_PROPERTY( bool autoRepeat READ autoRepeat + WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL ) - Q_PROPERTY( bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL ) Q_PROPERTY( int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay NOTIFY autoRepeatDelayChanged FINAL ) + Q_PROPERTY( int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval NOTIFY autoRepeatIntervalChanged FINAL ) Q_PROPERTY( bool exclusive READ exclusive WRITE setExclusive NOTIFY exclusiveChanged FINAL ) - Q_PROPERTY( bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL ) - Q_PROPERTY( bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL ) + Q_PROPERTY( bool pressed READ isPressed + WRITE setPressed NOTIFY pressedChanged FINAL ) + + Q_PROPERTY( bool checked READ isChecked + WRITE setChecked NOTIFY checkedChanged FINAL ) using Inherited = QskControl; -public: + public: QSK_STATES( Flat, Checked, Pressed, Checkable ) QskAbstractButton( QQuickItem* parent = nullptr ); @@ -55,12 +62,12 @@ class QSK_EXPORT QskAbstractButton : public QskControl void setExclusive( bool ); bool exclusive() const; -public Q_SLOTS: + public Q_SLOTS: void toggle(); void click(); void setChecked( bool ); -Q_SIGNALS: + Q_SIGNALS: void pressed(); void released(); void canceled(); @@ -77,7 +84,7 @@ public Q_SLOTS: void exclusiveChanged( bool ); -protected: + protected: bool event( QEvent* ) override; void keyPressEvent( QKeyEvent* ) override; @@ -95,7 +102,7 @@ public Q_SLOTS: virtual void setCheckedState( bool on ); -private: + private: void releaseButton(); class PrivateData; diff --git a/src/controls/QskAnimationHint.h b/src/controls/QskAnimationHint.h index 73061e86e..2193f2eb8 100644 --- a/src/controls/QskAnimationHint.h +++ b/src/controls/QskAnimationHint.h @@ -13,17 +13,17 @@ class QSK_EXPORT QskAnimationHint { -public: - inline constexpr QskAnimationHint() noexcept: - duration( 0 ), - type( QEasingCurve::Linear ) + public: + inline constexpr QskAnimationHint() noexcept + : duration( 0 ) + , type( QEasingCurve::Linear ) { } inline constexpr QskAnimationHint( uint duration, - QEasingCurve::Type type = QEasingCurve::Linear ) noexcept: - duration( duration ), - type( type ) + QEasingCurve::Type type = QEasingCurve::Linear ) noexcept + : duration( duration ) + , type( type ) { } diff --git a/src/controls/QskAnimator.cpp b/src/controls/QskAnimator.cpp index de780c658..69bfedbfb 100644 --- a/src/controls/QskAnimator.cpp +++ b/src/controls/QskAnimator.cpp @@ -5,11 +5,11 @@ #include "QskAnimator.h" -#include -#include -#include #include #include +#include +#include +#include #ifndef QT_NO_DEBUG_STREAM #include @@ -19,14 +19,14 @@ namespace { class Statistics { - public: + public: inline Statistics() { reset(); } #ifndef QT_NO_DEBUG_STREAM - void debugStatistics( QDebug debug ) + void debugStatistics( QDebug debug ) { QDebugStateSaver saver( debug ); debug.nospace(); @@ -75,7 +75,7 @@ class QskAnimatorDriver final : public QObject { Q_OBJECT -public: + public: QskAnimatorDriver(); void registerAnimator( QskAnimator* ); @@ -83,11 +83,11 @@ class QskAnimatorDriver final : public QObject qint64 referenceTime() const; -Q_SIGNALS: + Q_SIGNALS: void advanced( QQuickWindow* ); void terminated( QQuickWindow* ); -private: + private: void advanceAnimators( QQuickWindow* ); void removeWindow( QQuickWindow* ); void scheduleUpdate( QQuickWindow* ); @@ -106,8 +106,8 @@ class QskAnimatorDriver final : public QObject mutable int m_index; // current value, when iterating }; -QskAnimatorDriver::QskAnimatorDriver(): - m_index( -1 ) +QskAnimatorDriver::QskAnimatorDriver() + : m_index( -1 ) { m_referenceTime.start(); } @@ -169,7 +169,7 @@ void QskAnimatorDriver::removeWindow( QQuickWindow* window ) for ( auto it = m_animators.begin(); it != m_animators.end(); ) { - if ( (*it)->window() == window ) + if ( ( *it )->window() == window ) it = m_animators.erase( it ); else ++it; @@ -198,7 +198,7 @@ void QskAnimatorDriver::advanceAnimators( QQuickWindow* window ) // Advancing animators might create/remove animators, what is handled by // adjusting m_index in register/unregister - QskAnimator* animator = m_animators[m_index]; + auto animator = m_animators[ m_index ]; if ( animator->window() == window ) { hasAnimators = true; @@ -213,7 +213,7 @@ void QskAnimatorDriver::advanceAnimators( QQuickWindow* window ) } } - m_index = -1; + m_index = -1; if ( !hasAnimators ) { @@ -230,10 +230,10 @@ void QskAnimatorDriver::advanceAnimators( QQuickWindow* window ) Q_GLOBAL_STATIC( QskAnimatorDriver, qskAnimatorDriver ) Q_GLOBAL_STATIC( Statistics, qskStatistics ) -QskAnimator::QskAnimator(): - m_window( nullptr ), - m_duration( 200 ), - m_startTime( -1 ) +QskAnimator::QskAnimator() + : m_window( nullptr ) + , m_duration( 200 ) + , m_startTime( -1 ) { if ( qskStatistics ) qskStatistics->increment(); @@ -276,7 +276,7 @@ void QskAnimator::setEasingCurve( QEasingCurve::Type type ) static QEasingCurve curveTable[ QEasingCurve::Custom ]; if ( curveTable[ type ].type() != type ) - curveTable[ type ].setType( type ); + curveTable[ type ].setType( type ); m_easingCurve = curveTable[ type ]; } @@ -362,23 +362,23 @@ void QskAnimator::done() // we should also have functor based callbacks too. TODO ... #endif -QMetaObject::Connection QskAnimator::addCleanupHandler( QObject* receiver, - const char* method, Qt::ConnectionType type ) +QMetaObject::Connection QskAnimator::addCleanupHandler( + QObject* receiver, const char* method, Qt::ConnectionType type ) { return QObject::connect( qskAnimatorDriver, SIGNAL(terminated(QQuickWindow*)), receiver, method, type ); } -QMetaObject::Connection QskAnimator::addAdvanceHandler( QObject* receiver, - const char* method, Qt::ConnectionType type ) -{ +QMetaObject::Connection QskAnimator::addAdvanceHandler( + QObject* receiver, const char* method, Qt::ConnectionType type ) +{ return QObject::connect( qskAnimatorDriver, SIGNAL(advanced(QQuickWindow*)), receiver, method, type ); } #ifndef QT_NO_DEBUG_STREAM -void QskAnimator::debugStatistics( QDebug debug ) +void QskAnimator::debugStatistics( QDebug debug ) { if ( qskStatistics ) qskStatistics->debugStatistics( debug ); diff --git a/src/controls/QskAnimator.h b/src/controls/QskAnimator.h index da914f493..645bf483b 100644 --- a/src/controls/QskAnimator.h +++ b/src/controls/QskAnimator.h @@ -16,7 +16,7 @@ class QDebug; class QSK_EXPORT QskAnimator { -public: + public: QskAnimator(); virtual ~QskAnimator(); @@ -38,22 +38,24 @@ class QSK_EXPORT QskAnimator void stop(); void update(); - static QMetaObject::Connection addCleanupHandler( QObject* receiver, - const char* method, Qt::ConnectionType type = Qt::AutoConnection ); + static QMetaObject::Connection addCleanupHandler( + QObject* receiver, const char* method, + Qt::ConnectionType type = Qt::AutoConnection ); - static QMetaObject::Connection addAdvanceHandler( QObject* receiver, - const char* method, Qt::ConnectionType type = Qt::AutoConnection ); + static QMetaObject::Connection addAdvanceHandler( + QObject* receiver, const char* method, + Qt::ConnectionType type = Qt::AutoConnection ); #ifndef QT_NO_DEBUG_STREAM static void debugStatistics( QDebug ); #endif -protected: + protected: virtual void setup(); virtual void advance( qreal value ) = 0; virtual void done(); -private: + private: QQuickWindow* m_window; int m_duration; @@ -72,4 +74,3 @@ inline int QskAnimator::duration() const } #endif - diff --git a/src/controls/QskBox.cpp b/src/controls/QskBox.cpp index 0af35c433..b4f2bcadf 100644 --- a/src/controls/QskBox.cpp +++ b/src/controls/QskBox.cpp @@ -7,8 +7,8 @@ QSK_SUBCONTROL( QskBox, Panel ) -QskBox::QskBox( QQuickItem* parent ): - Inherited( parent ) +QskBox::QskBox( QQuickItem* parent ) + : Inherited( parent ) { } @@ -17,7 +17,7 @@ QskBox::~QskBox() } QRectF QskBox::layoutRect() const -{ +{ return innerBox( Panel, subControlRect( Panel ) ); } @@ -28,19 +28,19 @@ QSizeF QskBox::contentsSizeHint() const if ( autoLayoutChildren() ) { const QSizeF hint = Inherited::contentsSizeHint(); - + if ( hint.width() > 0 ) size.setWidth( hint.width() ); - + if ( hint.height() > 0 ) size.setHeight( hint.height() ); - } + } const QSizeF minSize( metric( Panel | QskAspect::MinimumWidth ), metric( Panel | QskAspect::MinimumHeight ) ); return outerBoxSize( Panel, size ).expandedTo( minSize ); -} +} #include "moc_QskBox.cpp" diff --git a/src/controls/QskBox.h b/src/controls/QskBox.h index 787012e0e..a591943ba 100644 --- a/src/controls/QskBox.h +++ b/src/controls/QskBox.h @@ -14,7 +14,7 @@ class QSK_EXPORT QskBox : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel ) QskBox( QQuickItem* parent = nullptr ); diff --git a/src/controls/QskBoxSkinlet.cpp b/src/controls/QskBoxSkinlet.cpp index 5afc2f24c..d9d46a5da 100644 --- a/src/controls/QskBoxSkinlet.cpp +++ b/src/controls/QskBoxSkinlet.cpp @@ -6,8 +6,8 @@ #include "QskBoxSkinlet.h" #include "QskBox.h" -QskBoxSkinlet::QskBoxSkinlet( QskSkin* skin ): - Inherited( skin ) +QskBoxSkinlet::QskBoxSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole } ); } @@ -18,20 +18,20 @@ QskBoxSkinlet::~QskBoxSkinlet() QRectF QskBoxSkinlet::subControlRect( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const -{ +{ if ( subControl == QskBox::Panel ) { const auto box = static_cast< const QskBox* >( skinnable ); return box->contentsRect(); } - + return Inherited::subControlRect( skinnable, subControl ); -} +} QSGNode* QskBoxSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { diff --git a/src/controls/QskBoxSkinlet.h b/src/controls/QskBoxSkinlet.h index f75c1631d..086c680dc 100644 --- a/src/controls/QskBoxSkinlet.h +++ b/src/controls/QskBoxSkinlet.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskBoxSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole, @@ -33,4 +33,3 @@ class QSK_EXPORT QskBoxSkinlet : public QskSkinlet }; #endif - diff --git a/src/controls/QskControl.cpp b/src/controls/QskControl.cpp index 15abd3423..d0147a807 100644 --- a/src/controls/QskControl.cpp +++ b/src/controls/QskControl.cpp @@ -4,17 +4,17 @@ *****************************************************************************/ #include "QskControl.h" -#include "QskQuick.h" #include "QskAspect.h" -#include "QskSetup.h" -#include "QskEvent.h" #include "QskDirtyItemFilter.h" -#include "QskSkinHintTable.h" +#include "QskEvent.h" +#include "QskQuick.h" +#include "QskSetup.h" #include "QskSkin.h" +#include "QskSkinHintTable.h" +#include #include #include -#include QSK_QT_PRIVATE_BEGIN #include @@ -32,7 +32,7 @@ QSK_STATE( QskControl, Focused, QskAspect::LastSystemState ) // QGridLayoutEngine internally uses FLT_MAX static constexpr qreal qskSizeHintMax = std::numeric_limits< float >::max(); -static QSizeF qskDefaultSizeHints[3] = +static QSizeF qskDefaultSizeHints[ 3 ] = { { 0, 0 }, { -1, -1 }, { qskSizeHintMax, qskSizeHintMax } }; typedef quint16 controlFlags_t; @@ -69,10 +69,10 @@ namespace */ class QskWindowStore { - public: - QskWindowStore(): - m_refCount( 0 ), - m_window( nullptr ) + public: + QskWindowStore() + : m_refCount( 0 ) + , m_window( nullptr ) { } @@ -101,14 +101,14 @@ namespace return w; } - private: + private: int m_refCount; QQuickWindow* m_window; }; class QskControlRegistry { - public: + public: QskControlRegistry() { /* @@ -116,10 +116,10 @@ namespace of setting up direct connections between qskSetup and each control */ QObject::connect( qskSetup, &QskSetup::controlFlagsChanged, - [this] { updateControlFlags(); } ); + [ this ] { updateControlFlags(); } ); QObject::connect( qskSetup, &QskSetup::skinChanged, - [this] { updateSkin(); } ); + [ this ] { updateSkin(); } ); } inline void insert( QskControl* control ) @@ -151,7 +151,7 @@ namespace } } - private: + private: std::unordered_set< QskControl* > m_controls; }; } @@ -163,30 +163,30 @@ class QskControlPrivate final : public QQuickItemPrivate { Q_DECLARE_PUBLIC( QskControl ) -public: + public: class ExplicitSizeData { - public: - QSizeF sizeHints[3] = - { qskDefaultSizeHints[0], qskDefaultSizeHints[1], qskDefaultSizeHints[2] }; + public: + QSizeF sizeHints[ 3 ] = + { qskDefaultSizeHints[ 0 ], qskDefaultSizeHints[ 1 ], qskDefaultSizeHints[ 2 ] }; }; - QskControlPrivate(): - explicitSizeData( nullptr ), - sizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred ), - controlFlags( qskControlFlags() ), - controlFlagsMask( 0 ), - explicitLocale( false ), - autoFillBackground( false ), - autoLayoutChildren( false ), - polishOnResize( false ), - blockedPolish( false ), - blockedImplicitSize( true ), - clearPreviousNodes( false ), - blockImplicitSizeNotification( false ), - isInitiallyPainted( false ), - focusPolicy( Qt::NoFocus ), - isWheelEnabled( false ) + QskControlPrivate() + : explicitSizeData( nullptr ) + , sizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred ) + , controlFlags( qskControlFlags() ) + , controlFlagsMask( 0 ) + , explicitLocale( false ) + , autoFillBackground( false ) + , autoLayoutChildren( false ) + , polishOnResize( false ) + , blockedPolish( false ) + , blockedImplicitSize( true ) + , clearPreviousNodes( false ) + , blockImplicitSizeNotification( false ) + , isInitiallyPainted( false ) + , focusPolicy( Qt::NoFocus ) + , isWheelEnabled( false ) { if ( controlFlags & QskControl::DeferredLayout ) { @@ -273,12 +273,11 @@ class QskControlPrivate final : public QQuickItemPrivate return qskDefaultSizeHints[ whichHint ]; } - bool maybeGesture( QQuickItem* child, QEvent* event ) { Q_Q( QskControl ); - switch( event->type() ) + switch ( event->type() ) { case QEvent::MouseButtonPress: { @@ -329,10 +328,10 @@ class QskControlPrivate final : public QQuickItemPrivate } } -private: + private: ExplicitSizeData* explicitSizeData; -public: + public: QLocale locale; QskSizePolicy sizePolicy; @@ -364,8 +363,8 @@ static void qskUpdateControlFlags( QskControl::Flags flags, QskControl* control d->updateControlFlags( flags ); } -QskControl::QskControl( QQuickItem* parent ): - Inherited( *( new QskControlPrivate() ), parent ) +QskControl::QskControl( QQuickItem* parent ) + : Inherited( *( new QskControlPrivate() ), parent ) { setFlag( QQuickItem::ItemHasContents, true ); QQuickItem::setActiveFocusOnTab( false ); @@ -384,7 +383,7 @@ QskControl::QskControl( QQuickItem* parent ): avoid this penalty also for earlier Qt versions. */ connect( this, &QQuickItem::enabledChanged, - [this] { setSkinStateFlag( Disabled, !isEnabled() ); } ); + [ this ] { setSkinStateFlag( Disabled, !isEnabled() ); } ); #endif Q_D( QskControl ); @@ -672,8 +671,8 @@ void QskControl::updateControlFlag( uint flag, bool on ) { Q_D( QskControl ); - if ( ( flag > std::numeric_limits< controlFlags_t >::max() ) - || ( bool( d->controlFlags & flag ) == on ) ) + if ( ( flag > std::numeric_limits< controlFlags_t >::max() ) || + ( bool( d->controlFlags & flag ) == on ) ) { return; } @@ -683,7 +682,7 @@ void QskControl::updateControlFlag( uint flag, bool on ) else d->controlFlags &= ~flag; - switch( flag ) + switch ( flag ) { case QskControl::DeferredUpdate: { @@ -884,7 +883,7 @@ void QskControl::setLayoutMirroring( bool on, bool recursive ) Q_D( QskControl ); - if ( recursive != d->inheritMirrorFromItem) + if ( recursive != d->inheritMirrorFromItem ) { d->inheritMirrorFromItem = recursive; d->resolveLayoutMirror(); @@ -904,10 +903,10 @@ void QskControl::resetLayoutMirroring() { Q_D( QskControl ); - if ( d && !d->isMirrorImplicit) + if ( d && !d->isMirrorImplicit ) { d->isMirrorImplicit = true; - //d->inheritMirrorFromItem = false; + // d->inheritMirrorFromItem = false; d->resolveLayoutMirror(); } } @@ -982,7 +981,7 @@ void QskControl::initSizePolicy( Sometimes it is even worse as the parent might not be even prepared to handle the LayouRequest event. */ - + d->sizePolicy.setHorizontalPolicy( horizontalPolicy ); d->sizePolicy.setVerticalPolicy( verticalPolicy ); } @@ -1119,8 +1118,8 @@ void QskControl::setFixedWidth( qreal width ) auto size = d->explicitSizeHint( Qt::PreferredSize ); - if ( ( d->sizePolicy.horizontalPolicy() != QskSizePolicy::Fixed ) - || ( size.width() != width ) ) + if ( ( d->sizePolicy.horizontalPolicy() != QskSizePolicy::Fixed ) || + ( size.width() != width ) ) { size.setWidth( width ); @@ -1140,8 +1139,8 @@ void QskControl::setFixedHeight( qreal height ) auto size = d->explicitSizeHint( Qt::PreferredSize ); - if ( ( d->sizePolicy.verticalPolicy() != QskSizePolicy::Fixed ) - || ( size.height() != height ) ) + if ( ( d->sizePolicy.verticalPolicy() != QskSizePolicy::Fixed ) || + ( size.height() != height ) ) { size.setHeight( height ); @@ -1270,28 +1269,28 @@ qreal QskControl::heightForWidth( qreal width ) const qreal QskControl::widthForHeight( qreal height ) const { qreal w = -1; - + if ( d_func()->autoLayoutChildren ) { const auto innerSize = layoutRect().size(); const auto outerSize = size(); - + height -= outerSize.height() - innerSize.height(); - + const auto children = childItems(); for ( auto child : children ) - { + { if ( auto control = qobject_cast< const QskControl* >( child ) ) - { + { if ( !control->isTransparentForPositioner() ) w = qMax( w, control->widthForHeight( height ) ); } } - + if ( w >= 0 ) w += outerSize.width() - innerSize.width(); } - + return w; } @@ -1299,7 +1298,7 @@ bool QskControl::event( QEvent* event ) { const int eventType = event->type(); - switch( eventType ) + switch ( eventType ) { #if 0 case QEvent::PolishRequest: @@ -1328,7 +1327,7 @@ bool QskControl::event( QEvent* event ) } } - switch( eventType ) + switch ( eventType ) { case QEvent::StyleChange: { @@ -1491,7 +1490,7 @@ void QskControl::itemChange( QQuickItem::ItemChange change, Q_D( QskControl ); - switch( change ) + switch ( change ) { case QQuickItem::ItemParentHasChanged: { @@ -1577,7 +1576,7 @@ void QskControl::itemChange( QQuickItem::ItemChange change, setSkinStateFlag( Focused, hasActiveFocus() ); break; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) case QQuickItem::ItemEnabledHasChanged: { setSkinStateFlag( Disabled, !value.boolValue ); @@ -1807,8 +1806,8 @@ bool QskControl::isUpdateNodeScheduled() const { Q_D( const QskControl ); - return ( d->dirtyAttributes & QQuickItemPrivate::ContentUpdateMask ) - && ( d->flags & QQuickItem::ItemHasContents ); + return ( d->dirtyAttributes & QQuickItemPrivate::ContentUpdateMask ) && + ( d->flags & QQuickItem::ItemHasContents ); } bool QskControl::isInitiallyPainted() const diff --git a/src/controls/QskControl.h b/src/controls/QskControl.h index 84ef2d8bb..06687d823 100644 --- a/src/controls/QskControl.h +++ b/src/controls/QskControl.h @@ -7,13 +7,13 @@ #define QSK_CONTROL_H 1 #include "QskGlobal.h" -#include "QskSkinnable.h" +#include "QskAspect.h" #include "QskGradient.h" #include "QskSizePolicy.h" -#include "QskAspect.h" +#include "QskSkinnable.h" -#include #include +#include #include @@ -60,15 +60,18 @@ class QSK_EXPORT QskControl : public QQuickItem, public QskSkinnable WRITE setBackground RESET resetBackground NOTIFY backgroundChanged ) Q_PROPERTY( QskSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy ) + Q_PROPERTY( QSizeF minimumSize READ minimumSize WRITE setMinimumSize ) + Q_PROPERTY( QSizeF maximumSize READ maximumSize WRITE setMaximumSize ) + Q_PROPERTY( QSizeF preferredSize READ preferredSize WRITE setPreferredSize ) Q_PROPERTY( QRectF geometry READ geometry WRITE setGeometry ) using Inherited = QQuickItem; -public: + public: QSK_STATES( Disabled, Hovered, Focused ) enum Flag @@ -207,7 +210,7 @@ class QSK_EXPORT QskControl : public QQuickItem, public QskSkinnable QVector< QskAspect::Subcontrol > subControls() const; -Q_SIGNALS: + Q_SIGNALS: void backgroundChanged(); void marginsChanged(); void focusIndicatorRectChanged(); @@ -216,7 +219,7 @@ class QSK_EXPORT QskControl : public QQuickItem, public QskSkinnable void focusPolicyChanged(); void wheelEnabledChanged(); -public Q_SLOTS: + public Q_SLOTS: void setGeometry( const QRectF& ); void setLocale( const QLocale& ); @@ -226,7 +229,7 @@ public Q_SLOTS: void resetImplicitSize(); -protected: + protected: bool event( QEvent* ) override; virtual void changeEvent( QEvent* ); @@ -250,14 +253,14 @@ public Q_SLOTS: void cleanupNodes(); - virtual void aboutToShow(); // called in updatePolish + virtual void aboutToShow(); // called in updatePolish virtual void updateLayout(); // called in updatePolish -private: + private: // don't use boundingRect - it seems to be deprecated QRectF boundingRect() const override final { return rect(); } - void setActiveFocusOnTab( bool ) = delete; // use setFocusPolicy + void setActiveFocusOnTab( bool ) = delete; // use setFocusPolicy void updateInputMethod( Qt::InputMethodQueries ) = delete; // use qskUpdateInputMethod QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override final; @@ -270,7 +273,7 @@ public Q_SLOTS: void updateControlFlag( uint flag, bool on ); -private: + private: Q_DECLARE_PRIVATE( QskControl ) }; diff --git a/src/controls/QskDirtyItemFilter.cpp b/src/controls/QskDirtyItemFilter.cpp index bea4a3b48..0b9052ab9 100644 --- a/src/controls/QskDirtyItemFilter.cpp +++ b/src/controls/QskDirtyItemFilter.cpp @@ -7,8 +7,8 @@ #include "QskControl.h" QSK_QT_PRIVATE_BEGIN -#include #include +#include QSK_QT_PRIVATE_END static inline bool qskIsUpdateBlocked( const QQuickItem* item ) @@ -33,7 +33,7 @@ static inline bool qskIsUpdateBlocked( const QQuickItem* item ) return !itemRect.intersects( sceneRect ); } #endif - + return false; } @@ -51,9 +51,9 @@ namespace { class ResetBlockedDirtyJob final : public QRunnable { - public: - inline ResetBlockedDirtyJob( QQuickWindow* window ): - m_window( window ) + public: + inline ResetBlockedDirtyJob( QQuickWindow* window ) + : m_window( window ) { } @@ -62,13 +62,13 @@ namespace qskBlockDirty( m_window->contentItem(), false ); } - private: + private: const QQuickWindow* m_window; }; } -QskDirtyItemFilter::QskDirtyItemFilter( QObject* parent ): - QObject( parent ) +QskDirtyItemFilter::QskDirtyItemFilter( QObject* parent ) + : QObject( parent ) { } @@ -120,8 +120,8 @@ void QskDirtyItemFilter::beforeSynchronizing( QQuickWindow* window ) } } -void QskDirtyItemFilter::filterDirtyList( QQuickWindow* window, - bool ( *isBlocked )( const QQuickItem* ) ) +void QskDirtyItemFilter::filterDirtyList( + QQuickWindow* window, bool ( *isBlocked )( const QQuickItem* ) ) { if ( window == nullptr ) return; @@ -137,4 +137,3 @@ void QskDirtyItemFilter::filterDirtyList( QQuickWindow* window, item = nextItem; } } - diff --git a/src/controls/QskDirtyItemFilter.h b/src/controls/QskDirtyItemFilter.h index 7001abd7e..b28d6fbb9 100644 --- a/src/controls/QskDirtyItemFilter.h +++ b/src/controls/QskDirtyItemFilter.h @@ -18,7 +18,7 @@ class QSK_EXPORT QskDirtyItemFilter : public QObject { using Inherited = QObject; -public: + public: QskDirtyItemFilter( QObject* parent = nullptr ); ~QskDirtyItemFilter() override; @@ -27,7 +27,7 @@ class QSK_EXPORT QskDirtyItemFilter : public QObject static void filterDirtyList( QQuickWindow*, bool ( *isBlocked )( const QQuickItem* ) ); -private: + private: void beforeSynchronizing( QQuickWindow* ); QSet< QObject* > m_windows; diff --git a/src/controls/QskEvent.cpp b/src/controls/QskEvent.cpp index 3eb261671..df755c8c5 100644 --- a/src/controls/QskEvent.cpp +++ b/src/controls/QskEvent.cpp @@ -1,3 +1,8 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the QSkinny License, Version 1.0 + *****************************************************************************/ + #include "QskEvent.h" #include "QskGesture.h" @@ -26,7 +31,7 @@ int qskTabChainIncrement( const QEvent* event ) const auto keyEvent = static_cast< const QKeyEvent* >( event ); if ( !( keyEvent->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ) { - switch( keyEvent->key() ) + switch ( keyEvent->key() ) { case Qt::Key_Tab: return 1; @@ -40,18 +45,18 @@ int qskTabChainIncrement( const QEvent* event ) return 0; } -QskEvent::QskEvent( QskEvent::Type type ): - QEvent( static_cast< QEvent::Type >( type ) ) +QskEvent::QskEvent( QskEvent::Type type ) + : QEvent( static_cast< QEvent::Type >( type ) ) { } // -- QskGeometryChangeEvent QskGeometryChangeEvent::QskGeometryChangeEvent( - const QRectF& rect, const QRectF& oldRect ): - QskEvent( QskEvent::GeometryChange ), - m_rect( rect ), - m_oldRect( oldRect ) + const QRectF& rect, const QRectF& oldRect ) + : QskEvent( QskEvent::GeometryChange ) + , m_rect( rect ) + , m_oldRect( oldRect ) { } @@ -70,19 +75,20 @@ bool QskGeometryChangeEvent::isMoved() const // -- QskWindowChangeEvent QskWindowChangeEvent::QskWindowChangeEvent( - QQuickWindow* oldWindow, QQuickWindow* window ): - QskEvent( QskEvent::WindowChange ), - m_oldWindow( oldWindow ), - m_window( window ) + QQuickWindow* oldWindow, QQuickWindow* window ) + : QskEvent( QskEvent::WindowChange ) + , m_oldWindow( oldWindow ) + , m_window( window ) { } // -- QskGestureEvent -QskGestureEvent::QskGestureEvent( const QskGesture* gesture, bool ownedByEvent ): - QskEvent( QskEvent::Gesture ), - m_gesture( gesture ), - m_gestureOwnedByEvent( ownedByEvent ) +QskGestureEvent::QskGestureEvent( + const QskGesture* gesture, bool ownedByEvent ) + : QskEvent( QskEvent::Gesture ) + , m_gesture( gesture ) + , m_gestureOwnedByEvent( ownedByEvent ) { } @@ -94,10 +100,10 @@ QskGestureEvent::~QskGestureEvent() // -- QskAnimatorEvent -QskAnimatorEvent::QskAnimatorEvent( QskAspect::Aspect aspect, State state ): - QskEvent( QskEvent::Animator ), - m_aspect( aspect ), - m_state( state ) +QskAnimatorEvent::QskAnimatorEvent( QskAspect::Aspect aspect, State state ) + : QskEvent( QskEvent::Animator ) + , m_aspect( aspect ) + , m_state( state ) { } diff --git a/src/controls/QskEvent.h b/src/controls/QskEvent.h index b3495fb01..6cbb849e7 100644 --- a/src/controls/QskEvent.h +++ b/src/controls/QskEvent.h @@ -17,7 +17,7 @@ class QQuickWindow; class QSK_EXPORT QskEvent : public QEvent { -public: + public: enum Type { NoEvent = 53800, @@ -37,7 +37,7 @@ class QSK_EXPORT QskEvent : public QEvent class QSK_EXPORT QskGeometryChangeEvent : public QskEvent { -public: + public: QskGeometryChangeEvent( const QRectF& rect, const QRectF& oldRect ); inline const QRectF& rect() const { return m_rect; } @@ -46,42 +46,41 @@ class QSK_EXPORT QskGeometryChangeEvent : public QskEvent bool isResized() const; bool isMoved() const; -private: + private: const QRectF m_rect; const QRectF m_oldRect; }; class QSK_EXPORT QskWindowChangeEvent : public QskEvent { -public: - QskWindowChangeEvent( QQuickWindow* oldWindow, - QQuickWindow* window ); + public: + QskWindowChangeEvent( QQuickWindow* oldWindow, QQuickWindow* window ); inline QQuickWindow* window() const { return m_window; } inline QQuickWindow* oldWindow() const { return m_oldWindow; } -private: + private: QQuickWindow* const m_oldWindow; QQuickWindow* const m_window; }; class QSK_EXPORT QskGestureEvent : public QskEvent { -public: + public: QskGestureEvent( const QskGesture* gesture, bool ownedByEvent = true ); ~QskGestureEvent() override; inline const QskGesture* gesture() const { return m_gesture; } inline bool isGestureOwnedByEvent() const { return m_gestureOwnedByEvent; } -private: + private: const QskGesture* m_gesture; bool m_gestureOwnedByEvent; }; class QSK_EXPORT QskAnimatorEvent : public QskEvent { -public: + public: enum State { Started, @@ -94,7 +93,7 @@ class QSK_EXPORT QskAnimatorEvent : public QskEvent inline QskAspect::Aspect aspect() const { return m_aspect; } inline State state() const { return m_state; } -private: + private: const QskAspect::Aspect m_aspect; const State m_state; }; diff --git a/src/controls/QskFlickAnimator.cpp b/src/controls/QskFlickAnimator.cpp index d9db07390..18c0b199d 100644 --- a/src/controls/QskFlickAnimator.cpp +++ b/src/controls/QskFlickAnimator.cpp @@ -20,11 +20,11 @@ static inline qreal qskAligned( qreal value ) return value; } -QskFlickAnimator::QskFlickAnimator(): - m_velocity{ 0.0, 0.0 }, - m_degrees( 0.0 ), - m_cos( 1.0 ), - m_sin( 0.0 ) +QskFlickAnimator::QskFlickAnimator() + : m_velocity{ 0.0, 0.0 } + , m_degrees( 0.0 ) + , m_cos( 1.0 ) + , m_sin( 0.0 ) { setDuration( 1000 ); setEasingCurve( QEasingCurve::OutCubic ); @@ -43,23 +43,23 @@ void QskFlickAnimator::flick( qreal degrees, qreal velocity ) setAngle( degrees ); - m_velocity[0] = velocity; - m_velocity[1] = 0.0; + m_velocity[ 0 ] = velocity; + m_velocity[ 1 ] = 0.0; - if ( m_velocity[0] > 0.0 ) + if ( m_velocity[ 0 ] > 0.0 ) start(); } void QskFlickAnimator::accelerate( qreal degrees, qreal velocity ) { - if ( isRunning() && !qFuzzyIsNull( m_velocity[1] ) ) + if ( isRunning() && !qFuzzyIsNull( m_velocity[ 1 ] ) ) { const qreal delta = qDegreesToRadians( degrees - m_degrees ); if ( qFuzzyIsNull( delta ) ) { // the same as below, but faster to calculate: exp2( 2.0 * cos( 0.0 ) - velocity += 4.0 * m_velocity[1]; + velocity += 4.0 * m_velocity[ 1 ]; } else { @@ -67,7 +67,7 @@ void QskFlickAnimator::accelerate( qreal degrees, qreal velocity ) if ( cos >= 0.0 ) { // boosting the current velocity - velocity += exp2( 2.0 * cos ) * m_velocity[1]; + velocity += exp2( 2.0 * cos ) * m_velocity[ 1 ]; } else { @@ -82,7 +82,7 @@ void QskFlickAnimator::accelerate( qreal degrees, qreal velocity ) void QskFlickAnimator::done() { - m_velocity[1] = 0.0; + m_velocity[ 1 ] = 0.0; m_elapsed = 0.0; } @@ -101,27 +101,27 @@ void QskFlickAnimator::setAngle( qreal degrees ) void QskFlickAnimator::setVelocity( qreal velocity ) { - m_velocity[0] = velocity; + m_velocity[ 0 ] = velocity; } void QskFlickAnimator::setup() { m_elapsed = 0; - m_velocity[1] = m_velocity[0]; + m_velocity[ 1 ] = m_velocity[ 0 ]; } void QskFlickAnimator::advance( qreal value ) { - const qreal oldVelocity = m_velocity[1]; + const qreal oldVelocity = m_velocity[ 1 ]; const int oldElapsed = m_elapsed; - m_velocity[1] = m_velocity[0] * ( 1.0 - value ); + m_velocity[ 1 ] = m_velocity[ 0 ] * ( 1.0 - value ); m_elapsed = elapsed(); const qreal duration = ( m_elapsed - oldElapsed ) / 1000.0; // in seconds if ( duration > 0.0 ) { - const qreal velocity = 0.5 * ( m_velocity[1] + oldVelocity ); // average + const qreal velocity = 0.5 * ( m_velocity[ 1 ] + oldVelocity ); // average /* Using the average velocity is not accurate, when having a non linear diff --git a/src/controls/QskFlickAnimator.h b/src/controls/QskFlickAnimator.h index a245df8f3..5a2640cbc 100644 --- a/src/controls/QskFlickAnimator.h +++ b/src/controls/QskFlickAnimator.h @@ -11,7 +11,7 @@ class QSK_EXPORT QskFlickAnimator : public QskAnimator { -public: + public: QskFlickAnimator(); ~QskFlickAnimator() override; @@ -26,15 +26,15 @@ class QSK_EXPORT QskFlickAnimator : public QskAnimator void flick( qreal degrees, qreal velocity ); void accelerate( qreal degrees, qreal velocity ); -protected: + protected: void setup() override; void advance( qreal value ) override final; void done() override; virtual void translate( qreal dx, qreal dy ) = 0; -private: - qreal m_velocity[2]; + private: + qreal m_velocity[ 2 ]; qreal m_degrees; qreal m_cos; @@ -50,12 +50,12 @@ inline qreal QskFlickAnimator::angle() const inline qreal QskFlickAnimator::velocity() const { - return m_velocity[0]; + return m_velocity[ 0 ]; } inline qreal QskFlickAnimator::animatedVelocity() const { - return m_velocity[1]; + return m_velocity[ 1 ]; } #endif diff --git a/src/controls/QskFocusIndicator.cpp b/src/controls/QskFocusIndicator.cpp index fddd11138..4794b7121 100644 --- a/src/controls/QskFocusIndicator.cpp +++ b/src/controls/QskFocusIndicator.cpp @@ -4,9 +4,9 @@ *****************************************************************************/ #include "QskFocusIndicator.h" -#include "QskQuick.h" #include "QskAspect.h" #include "QskEvent.h" +#include "QskQuick.h" #include @@ -26,7 +26,7 @@ static inline QRectF qskFocusIndicatorRect( const QQuickItem* item ) class QskFocusIndicator::PrivateData { -public: + public: void resetConnections() { for ( const auto& connection : connections ) @@ -38,9 +38,9 @@ class QskFocusIndicator::PrivateData QVector< QMetaObject::Connection > connections; }; -QskFocusIndicator::QskFocusIndicator( QQuickItem* parent ): - Inherited( parent ), // parentItem() might change, but parent() stays - m_data( new PrivateData() ) +QskFocusIndicator::QskFocusIndicator( QQuickItem* parent ) + : Inherited( parent ) // parentItem() might change, but parent() stays + , m_data( new PrivateData() ) { setTransparentForPositioner( true ); connectWindow( window(), true ); @@ -145,8 +145,8 @@ QRectF QskFocusIndicator::focusRect() const { const QQuickItem* item = window()->activeFocusItem(); - if ( item && ( item != this ) && item->isVisible() - && ( item != window()->contentItem() ) ) + if ( item && ( item != this ) && item->isVisible() && + ( item != window()->contentItem() ) ) { const auto rect = qskFocusIndicatorRect( item ); return parentItem()->mapRectFromItem( item, rect ); diff --git a/src/controls/QskFocusIndicator.h b/src/controls/QskFocusIndicator.h index f541bbcd6..56232f5e1 100644 --- a/src/controls/QskFocusIndicator.h +++ b/src/controls/QskFocusIndicator.h @@ -16,17 +16,17 @@ class QSK_EXPORT QskFocusIndicator : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel ) QskFocusIndicator( QQuickItem* parent = nullptr ); ~QskFocusIndicator() override; -protected: + protected: void windowChangeEvent( QskWindowChangeEvent* ) override; virtual QRectF focusRect() const; -private: + private: void onFocusItemGeometryChanged(); void onWindowSizeChanged( int ); diff --git a/src/controls/QskFocusIndicatorSkinlet.cpp b/src/controls/QskFocusIndicatorSkinlet.cpp index 2005c4ffe..f75dceeec 100644 --- a/src/controls/QskFocusIndicatorSkinlet.cpp +++ b/src/controls/QskFocusIndicatorSkinlet.cpp @@ -6,8 +6,8 @@ #include "QskFocusIndicatorSkinlet.h" #include "QskFocusIndicator.h" -QskFocusIndicatorSkinlet::QskFocusIndicatorSkinlet( QskSkin* skin ): - Inherited( skin ) +QskFocusIndicatorSkinlet::QskFocusIndicatorSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { FrameRole } ); } @@ -16,23 +16,23 @@ QskFocusIndicatorSkinlet::~QskFocusIndicatorSkinlet() = default; QRectF QskFocusIndicatorSkinlet::subControlRect( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const -{ +{ const auto indicator = static_cast< const QskFocusIndicator* >( skinnable ); - + if ( subControl == QskFocusIndicator::Panel ) { return indicator->rect(); } - + return Inherited::subControlRect( skinnable, subControl ); -} +} QSGNode* QskFocusIndicatorSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { const auto indicator = static_cast< const QskFocusIndicator* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case FrameRole: { diff --git a/src/controls/QskFocusIndicatorSkinlet.h b/src/controls/QskFocusIndicatorSkinlet.h index 7f273996d..d0816d512 100644 --- a/src/controls/QskFocusIndicatorSkinlet.h +++ b/src/controls/QskFocusIndicatorSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskFocusIndicatorSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { FrameRole @@ -29,13 +29,12 @@ class QSK_EXPORT QskFocusIndicatorSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QSGNode* updateFrameNode( const QskFocusIndicator*, QSGNode* ) const; }; #endif - diff --git a/src/controls/QskGesture.cpp b/src/controls/QskGesture.cpp index c7667ba2b..090f4c83b 100644 --- a/src/controls/QskGesture.cpp +++ b/src/controls/QskGesture.cpp @@ -5,9 +5,9 @@ #include "QskGesture.h" -QskGesture::QskGesture( Type type ): - m_type( type ), - m_state( NoGesture ) +QskGesture::QskGesture( Type type ) + : m_type( type ) + , m_state( NoGesture ) { } @@ -20,8 +20,8 @@ void QskGesture::setState( State state ) m_state = state; } -QskTapGesture::QskTapGesture(): - QskGesture( Tap ) +QskTapGesture::QskTapGesture() + : QskGesture( Tap ) { } @@ -34,9 +34,9 @@ void QskTapGesture::setPosition( const QPointF& position ) m_position = position; } -QskTapAndHoldGesture::QskTapAndHoldGesture(): - QskGesture( TapAndHold ), - m_timeout( 0 ) +QskTapAndHoldGesture::QskTapAndHoldGesture() + : QskGesture( TapAndHold ) + , m_timeout( 0 ) { } @@ -54,10 +54,10 @@ void QskTapAndHoldGesture::setTimeout( int timeout ) m_timeout = timeout; } -QskPanGesture::QskPanGesture(): - QskGesture( Pan ), - m_angle( 0.0 ), - m_velocity( 0.0 ) +QskPanGesture::QskPanGesture() + : QskGesture( Pan ) + , m_angle( 0.0 ) + , m_velocity( 0.0 ) { } @@ -90,10 +90,10 @@ void QskPanGesture::setPosition( const QPointF& pos ) m_position = pos; } -QskSwipeGesture::QskSwipeGesture(): - QskGesture( Swipe ), - m_velocity( 0.0 ), - m_angle( 0.0 ) +QskSwipeGesture::QskSwipeGesture() + : QskGesture( Swipe ) + , m_velocity( 0.0 ) + , m_angle( 0.0 ) { } diff --git a/src/controls/QskGesture.h b/src/controls/QskGesture.h index 090338cd6..ce9e23eb8 100644 --- a/src/controls/QskGesture.h +++ b/src/controls/QskGesture.h @@ -8,14 +8,14 @@ #include "QskGlobal.h" -#include #include +#include class QSK_EXPORT QskGesture { Q_GADGET -public: + public: enum Type { NoType = -1, @@ -51,7 +51,7 @@ class QSK_EXPORT QskGesture void setState( State ); inline State state() const { return m_state; } -protected: + protected: QskGesture( Type type ); const Type m_type; @@ -62,14 +62,14 @@ class QSK_EXPORT QskTapGesture : public QskGesture { using Inherited = QskGesture; -public: + public: QskTapGesture(); ~QskTapGesture() override; void setPosition( const QPointF& pos ); inline QPointF position() const { return m_position; } -private: + private: QPointF m_position; }; @@ -77,7 +77,7 @@ class QSK_EXPORT QskTapAndHoldGesture : public QskGesture { using Inherited = QskGesture; -public: + public: QskTapAndHoldGesture(); ~QskTapAndHoldGesture() override; @@ -87,7 +87,7 @@ class QSK_EXPORT QskTapAndHoldGesture : public QskGesture void setTimeout( int msecs ); inline int timeout() const { return m_timeout; } -private: + private: QPointF m_position; int m_timeout; }; @@ -96,7 +96,7 @@ class QskPanGesture : public QskGesture { using Inherited = QskGesture; -public: + public: QskPanGesture(); ~QskPanGesture() override; @@ -117,7 +117,7 @@ class QskPanGesture : public QskGesture inline QPointF delta() const { return m_position - m_lastPosition; } -private: + private: qreal m_angle; qreal m_velocity; @@ -130,7 +130,7 @@ class QskSwipeGesture : public QskGesture { using Inherited = QskGesture; -public: + public: QskSwipeGesture(); ~QskSwipeGesture() override; @@ -140,7 +140,7 @@ class QskSwipeGesture : public QskGesture void setAngle( qreal angle ); inline qreal angle() const; -private: + private: qreal m_velocity; qreal m_angle; }; diff --git a/src/controls/QskGestureRecognizer.cpp b/src/controls/QskGestureRecognizer.cpp index 7a3043cf7..f04eb2baf 100644 --- a/src/controls/QskGestureRecognizer.cpp +++ b/src/controls/QskGestureRecognizer.cpp @@ -1,10 +1,10 @@ #include "QskGestureRecognizer.h" -#include -#include +#include #include #include -#include +#include +#include #include #include @@ -41,7 +41,7 @@ namespace class Timer final : public QObject { - public: + public: void start( int ms, QskGestureRecognizer* recognizer ) { if ( m_timer.isActive() ) @@ -62,7 +62,7 @@ namespace return m_recognizer; } - protected: + protected: void timerEvent( QTimerEvent* ) override { m_timer.stop(); @@ -82,7 +82,7 @@ namespace class TimerTable { - public: + public: ~TimerTable() { qDeleteAll( m_table ); @@ -94,8 +94,8 @@ namespace for ( auto t : qskAsConst( m_table ) ) { - if ( t->recognizer() == nullptr - || t->recognizer() == recognizer ) + if ( t->recognizer() == nullptr || + t->recognizer() == recognizer ) { timer = t; break; @@ -124,7 +124,7 @@ namespace } } - private: + private: /* Usually we have not more than one entry. Only when having more than one screen we @@ -136,7 +136,7 @@ namespace class PendingEvents : public QVector< QMouseEvent* > { - public: + public: ~PendingEvents() { qDeleteAll( *this ); @@ -154,15 +154,15 @@ Q_GLOBAL_STATIC( TimerTable, qskTimerTable ) class QskGestureRecognizer::PrivateData { -public: - PrivateData(): - watchedItem( nullptr ), - timestamp( 0 ), - timestampProcessed( 0 ), - timeout( -1 ), - buttons( Qt::NoButton ), - state( QskGestureRecognizer::Idle ), - isReplayingEvents( false ) + public: + PrivateData() + : watchedItem( nullptr ) + , timestamp( 0 ) + , timestampProcessed( 0 ) + , timeout( -1 ) + , buttons( Qt::NoButton ) + , state( QskGestureRecognizer::Idle ) + , isReplayingEvents( false ) { } @@ -180,8 +180,8 @@ class QskGestureRecognizer::PrivateData bool isReplayingEvents : 1; // not exception safe !!! }; -QskGestureRecognizer::QskGestureRecognizer(): - m_data( new PrivateData() ) +QskGestureRecognizer::QskGestureRecognizer() + : m_data( new PrivateData() ) { } @@ -265,8 +265,8 @@ bool QskGestureRecognizer::processEvent( auto& watchedItem = m_data->watchedItem; - if ( watchedItem == nullptr || !watchedItem->isEnabled() - || !watchedItem->isVisible() || watchedItem->window() == nullptr ) + if ( watchedItem == nullptr || !watchedItem->isEnabled() || + !watchedItem->isVisible() || watchedItem->window() == nullptr ) { reset(); return false; @@ -350,7 +350,7 @@ bool QskGestureRecognizer::processEvent( if ( ( item == watchedItem ) && ( m_data->state > Idle ) ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::MouseButtonPress: { @@ -442,7 +442,8 @@ void QskGestureRecognizer::reject() if ( window->mouseGrabberItem() == m_data->watchedItem ) m_data->watchedItem->ungrabMouse(); - if ( !events.isEmpty() && events[0]->type() == QEvent::MouseButtonPress ) + if ( !events.isEmpty() && + ( events[ 0 ]->type() == QEvent::MouseButtonPress ) ) { /* In a situation of several recognizers ( f.e a vertical @@ -454,7 +455,7 @@ void QskGestureRecognizer::reject() m_data->timestampProcessed = events.last()->timestamp(); - QCoreApplication::sendEvent( window, events[0] ); + QCoreApplication::sendEvent( window, events[ 0 ] ); /* After resending the initial press someone else @@ -464,7 +465,7 @@ void QskGestureRecognizer::reject() if ( window->mouseGrabberItem() ) { for ( int i = 1; i < events.size(); i++ ) - QCoreApplication::sendEvent( window, events[i] ); + QCoreApplication::sendEvent( window, events[ i ] ); } } diff --git a/src/controls/QskGestureRecognizer.h b/src/controls/QskGestureRecognizer.h index 8858f2a57..f0c8e16e3 100644 --- a/src/controls/QskGestureRecognizer.h +++ b/src/controls/QskGestureRecognizer.h @@ -17,7 +17,7 @@ class QMouseEvent; class QSK_EXPORT QskGestureRecognizer { -public: + public: enum State { Idle, @@ -52,14 +52,14 @@ class QSK_EXPORT QskGestureRecognizer bool isReplaying() const; bool hasProcessedBefore( const QMouseEvent* ) const; -protected: + protected: virtual void pressEvent( const QMouseEvent* ); virtual void moveEvent( const QMouseEvent* ); virtual void releaseEvent( const QMouseEvent* ); virtual void stateChanged( State from, State to ); -private: + private: void setState( State ); void reset(); diff --git a/src/controls/QskGraphicLabel.cpp b/src/controls/QskGraphicLabel.cpp index a626cdf8e..94addfd1d 100644 --- a/src/controls/QskGraphicLabel.cpp +++ b/src/controls/QskGraphicLabel.cpp @@ -4,25 +4,25 @@ *****************************************************************************/ #include "QskGraphicLabel.h" +#include "QskAspect.h" +#include "QskColorFilter.h" #include "QskGraphic.h" #include "QskGraphicProvider.h" -#include "QskAspect.h" #include "QskSetup.h" #include "QskSkin.h" -#include "QskColorFilter.h" QSK_SUBCONTROL( QskGraphicLabel, Graphic ) class QskGraphicLabel::PrivateData { -public: - PrivateData( const QUrl& sourceUrl ): - source( sourceUrl ), - sourceSize( -1, -1 ), - alignment( Qt::AlignLeft | Qt::AlignVCenter ), - fillMode( QskGraphicLabel::PreserveAspectFit ), - mirror( false ), - isSourceDirty( !sourceUrl.isEmpty() ) + public: + PrivateData( const QUrl& sourceUrl ) + : source( sourceUrl ) + , sourceSize( -1, -1 ) + , alignment( Qt::AlignLeft | Qt::AlignVCenter ) + , fillMode( QskGraphicLabel::PreserveAspectFit ) + , mirror( false ) + , isSourceDirty( !sourceUrl.isEmpty() ) { } @@ -38,9 +38,9 @@ class QskGraphicLabel::PrivateData bool isSourceDirty : 1; }; -QskGraphicLabel::QskGraphicLabel( const QUrl& source, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData( source ) ) +QskGraphicLabel::QskGraphicLabel( const QUrl& source, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( source ) ) { initSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Expanding ); @@ -48,18 +48,18 @@ QskGraphicLabel::QskGraphicLabel( const QUrl& source, QQuickItem* parent ): polish(); } -QskGraphicLabel::QskGraphicLabel( QQuickItem* parent ): - QskGraphicLabel( QUrl(), parent ) +QskGraphicLabel::QskGraphicLabel( QQuickItem* parent ) + : QskGraphicLabel( QUrl(), parent ) { } -QskGraphicLabel::QskGraphicLabel( const QString& source, QQuickItem* parent ): - QskGraphicLabel( QUrl( source ), parent ) +QskGraphicLabel::QskGraphicLabel( const QString& source, QQuickItem* parent ) + : QskGraphicLabel( QUrl( source ), parent ) { } -QskGraphicLabel::QskGraphicLabel( const QskGraphic& graphic, QQuickItem* parent ): - QskGraphicLabel( parent ) +QskGraphicLabel::QskGraphicLabel( const QskGraphic& graphic, QQuickItem* parent ) + : QskGraphicLabel( parent ) { m_data->graphic = graphic; } diff --git a/src/controls/QskGraphicLabel.h b/src/controls/QskGraphicLabel.h index 924257804..87898c800 100644 --- a/src/controls/QskGraphicLabel.h +++ b/src/controls/QskGraphicLabel.h @@ -17,6 +17,7 @@ class QSK_EXPORT QskGraphicLabel : public QskControl Q_OBJECT Q_PROPERTY( QUrl source READ source WRITE setSource NOTIFY sourceChanged ) + Q_PROPERTY( bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged ) Q_PROPERTY( QSize sourceSize READ sourceSize @@ -33,7 +34,7 @@ class QSK_EXPORT QskGraphicLabel : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Graphic ) enum FillMode @@ -87,7 +88,7 @@ class QSK_EXPORT QskGraphicLabel : public QskControl void setGraphicRole( int role ); int graphicRole() const; -Q_SIGNALS: + Q_SIGNALS: void sourceChanged(); void mirrorChanged(); void sourceSizeChanged(); @@ -95,15 +96,15 @@ class QSK_EXPORT QskGraphicLabel : public QskControl void alignmentChanged(); void fillModeChanged(); -public Q_SLOTS: + public Q_SLOTS: void setGraphic( const QskGraphic& ); -protected: + protected: void changeEvent( QEvent* ) override; void updateLayout() override; virtual QskGraphic loadSource( const QUrl& ) const; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskGraphicLabelSkinlet.cpp b/src/controls/QskGraphicLabelSkinlet.cpp index 297315faa..3c9c9a214 100644 --- a/src/controls/QskGraphicLabelSkinlet.cpp +++ b/src/controls/QskGraphicLabelSkinlet.cpp @@ -4,15 +4,15 @@ *****************************************************************************/ #include "QskGraphicLabelSkinlet.h" -#include "QskGraphicLabel.h" #include "QskAspect.h" -#include "QskGraphic.h" #include "QskColorFilter.h" -#include "QskTextureNode.h" #include "QskFunctions.h" +#include "QskGraphic.h" +#include "QskGraphicLabel.h" +#include "QskTextureNode.h" -QskGraphicLabelSkinlet::QskGraphicLabelSkinlet( QskSkin* skin ): - Inherited( skin ) +QskGraphicLabelSkinlet::QskGraphicLabelSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { GraphicRole } ); } @@ -37,7 +37,7 @@ QSGNode* QskGraphicLabelSkinlet::updateSubNode( { const auto label = static_cast< const QskGraphicLabel* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case GraphicRole: { @@ -74,7 +74,7 @@ QRect QskGraphicLabelSkinlet::graphicRect( const QskGraphicLabel* label ) const } return qskAlignedRect( graphicRect, - ( int )sz.width(), ( int )sz.height(), label->alignment() ); + ( int ) sz.width(), ( int ) sz.height(), label->alignment() ); } QSGNode* QskGraphicLabelSkinlet::updateGraphicNode( diff --git a/src/controls/QskGraphicLabelSkinlet.h b/src/controls/QskGraphicLabelSkinlet.h index 7eea5f021..bd0fad99c 100644 --- a/src/controls/QskGraphicLabelSkinlet.h +++ b/src/controls/QskGraphicLabelSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskGraphicLabelSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { GraphicRole @@ -29,14 +29,13 @@ class QSK_EXPORT QskGraphicLabelSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: - QSGNode* updateSubNode( - const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; + protected: + QSGNode* updateSubNode( const QskSkinnable*, + quint8 nodeRole, QSGNode* ) const override; -private: + private: QRect graphicRect( const QskGraphicLabel* ) const; QSGNode* updateGraphicNode( const QskGraphicLabel*, QSGNode* ) const; }; #endif - diff --git a/src/controls/QskHintAnimator.cpp b/src/controls/QskHintAnimator.cpp index 82f0f3191..59abcb78d 100644 --- a/src/controls/QskHintAnimator.cpp +++ b/src/controls/QskHintAnimator.cpp @@ -11,9 +11,9 @@ #include #include +#include #include #include -#include #define ALIGN_VALUES 0 @@ -42,7 +42,7 @@ static inline QskMargins qskAligned05( const QskMargins& margins ) static inline QVariant qskAligned05( const QVariant& value ) { - if( value.canConvert< QskBoxBorderMetrics >() ) + if ( value.canConvert< QskBoxBorderMetrics >() ) { auto metrics = value.value< QskBoxBorderMetrics >(); @@ -139,7 +139,7 @@ namespace { Q_OBJECT - public: + public: AnimatorGuard() { QskAnimator::addCleanupHandler( this, @@ -160,10 +160,10 @@ namespace m_tables.erase( it ); } - private Q_SLOTS: + private Q_SLOTS: void cleanup() { - for( auto it = m_tables.begin(); it != m_tables.end(); ) + for ( auto it = m_tables.begin(); it != m_tables.end(); ) { if ( ( *it )->cleanup() ) it = m_tables.erase( it ); @@ -172,7 +172,7 @@ namespace } } - private: + private: // a vector as iteration is more important than insertion std::vector< QskHintAnimatorTable* > m_tables; }; @@ -182,14 +182,14 @@ namespace class QskHintAnimatorTable::PrivateData { -public: + public: // we won't have many entries, so we prefer less memory over // using a hash table std::map< QskAspect::Aspect, QskHintAnimator > map; }; -QskHintAnimatorTable::QskHintAnimatorTable(): - m_data( nullptr ) +QskHintAnimatorTable::QskHintAnimatorTable() + : m_data( nullptr ) { } @@ -269,7 +269,7 @@ bool QskHintAnimatorTable::cleanup() if ( m_data == nullptr ) return true; - for( auto it = m_data->map.begin(); it != m_data->map.end(); ) + for ( auto it = m_data->map.begin(); it != m_data->map.end(); ) { // remove all terminated animators if ( !it->second.isRunning() ) diff --git a/src/controls/QskHintAnimator.h b/src/controls/QskHintAnimator.h index 3d3277f1e..e44d4caec 100644 --- a/src/controls/QskHintAnimator.h +++ b/src/controls/QskHintAnimator.h @@ -7,8 +7,8 @@ #define QSK_HINT_ANIMATOR_H #include "QskGlobal.h" -#include "QskVariantAnimator.h" #include "QskAspect.h" +#include "QskVariantAnimator.h" #include @@ -19,7 +19,7 @@ class QSK_EXPORT QskHintAnimator : public QskVariantAnimator { using Inherited = QskVariantAnimator; -public: + public: QskHintAnimator(); ~QskHintAnimator() override; @@ -31,14 +31,14 @@ class QSK_EXPORT QskHintAnimator : public QskVariantAnimator void advance( qreal value ) override; -private: + private: QskAspect::Aspect m_aspect; QPointer< QskControl > m_control; }; class QSK_EXPORT QskHintAnimatorTable { -public: + public: QskHintAnimatorTable(); ~QskHintAnimatorTable(); @@ -50,7 +50,7 @@ class QSK_EXPORT QskHintAnimatorTable bool cleanup(); -private: + private: void reset(); class PrivateData; diff --git a/src/controls/QskInputGrabber.cpp b/src/controls/QskInputGrabber.cpp index b6632e87e..08c48d8d9 100644 --- a/src/controls/QskInputGrabber.cpp +++ b/src/controls/QskInputGrabber.cpp @@ -15,9 +15,9 @@ QSK_QT_PRIVATE_END class QskInputGrabber::PrivateData final : public QQuickItemChangeListener { -public: - PrivateData( QskInputGrabber* grabber ): - m_grabber( grabber ) + public: + PrivateData( QskInputGrabber* grabber ) + : m_grabber( grabber ) { } @@ -72,9 +72,8 @@ class QskInputGrabber::PrivateData final : public QQuickItemChangeListener } } -private: - -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + private: +#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) void itemGeometryChanged( QQuickItem* item, QQuickGeometryChange change, const QRectF& ) override { @@ -87,7 +86,6 @@ class QskInputGrabber::PrivateData final : public QQuickItemChangeListener if ( doUpdate ) m_grabber->updateGeometry(); - } #else void itemGeometryChanged( @@ -99,7 +97,7 @@ class QskInputGrabber::PrivateData final : public QQuickItemChangeListener doUpdate = newRect.size() != oldRect.size(); else doUpdate = newRect.topLeft() != oldRect.topLeft(); - + if ( doUpdate ) m_grabber->updateGeometry(); } @@ -116,17 +114,17 @@ class QskInputGrabber::PrivateData final : public QQuickItemChangeListener QskInputGrabber* m_grabber; -public: + public: QPointer< QQuickItem > itemAbove; QPointer< QQuickItem > itemBelow; }; -QskInputGrabber::QskInputGrabber( QQuickItem* parent ) : - Inherited( parent ), - m_data( new PrivateData( this ) ) +QskInputGrabber::QskInputGrabber( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( this ) ) { setAcceptedMouseButtons( Qt::AllButtons ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) setAcceptTouchEvents( true ); #endif setAcceptHoverEvents( true ); @@ -153,20 +151,20 @@ bool QskInputGrabber::event( QEvent* event ) case QEvent::MouseMove: case QEvent::MouseButtonRelease: { - const auto ev = static_cast< QMouseEvent* > ( event ); + const auto ev = static_cast< QMouseEvent* >( event ); doBlock = isBlocking( ev->localPos() ); break; } case QEvent::Wheel: { - const auto ev = static_cast< QWheelEvent* > ( event ); + const auto ev = static_cast< QWheelEvent* >( event ); doBlock = isBlocking( ev->posF() ); break; } case QEvent::HoverEnter: case QEvent::HoverLeave: { - const auto ev = static_cast< QHoverEvent* > ( event ); + const auto ev = static_cast< QHoverEvent* >( event ); doBlock = isBlocking( ev->posF() ); break; } diff --git a/src/controls/QskInputGrabber.h b/src/controls/QskInputGrabber.h index 81ff4667e..297098221 100644 --- a/src/controls/QskInputGrabber.h +++ b/src/controls/QskInputGrabber.h @@ -9,26 +9,26 @@ #include "QskGlobal.h" #include "QskControl.h" -class QskInputGrabber: public QskControl +class QskInputGrabber : public QskControl { Q_OBJECT using Inherited = QskControl; -public: + public: QskInputGrabber( QQuickItem* parent = nullptr ); ~QskInputGrabber() override; virtual QRectF grabberRect() const; virtual bool isBlocking( const QPointF& ) const; -public Q_SLOTS: + public Q_SLOTS: void updateGeometry(); -protected: + protected: bool event( QEvent* ) override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskListView.cpp b/src/controls/QskListView.cpp index e590670ea..3cd6287ea 100644 --- a/src/controls/QskListView.cpp +++ b/src/controls/QskListView.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskListView.h" -#include "QskColorFilter.h" #include "QskAspect.h" +#include "QskColorFilter.h" QSK_SUBCONTROL( QskListView, Cell ) QSK_SUBCONTROL( QskListView, Text ) @@ -14,12 +14,12 @@ QSK_SUBCONTROL( QskListView, TextSelected ) class QskListView::PrivateData { -public: - PrivateData(): - preferredWidthFromColumns( false ), - alternatingRowColors( false ), - selectionMode( QskListView::SingleSelection ), - selectedRow( -1 ) + public: + PrivateData() + : preferredWidthFromColumns( false ) + , alternatingRowColors( false ) + , selectionMode( QskListView::SingleSelection ) + , selectedRow( -1 ) { } @@ -31,9 +31,9 @@ class QskListView::PrivateData int selectedRow; }; -QskListView::QskListView( QQuickItem* parent ): - QskScrollView( parent ), - m_data( new PrivateData() ) +QskListView::QskListView( QQuickItem* parent ) + : QskScrollView( parent ) + , m_data( new PrivateData() ) { } diff --git a/src/controls/QskListView.h b/src/controls/QskListView.h index bf3cb5cca..19bc30fa1 100644 --- a/src/controls/QskListView.h +++ b/src/controls/QskListView.h @@ -30,7 +30,7 @@ class QSK_EXPORT QskListView : public QskScrollView using Inherited = QskScrollView; -public: + public: /* Everything, that can have a skin state, needs to be a QskSkinnable. Of course this is no option for the cells considering that we might @@ -81,10 +81,10 @@ class QSK_EXPORT QskListView : public QskScrollView QSizeF contentsSizeHint() const override; -public Q_SLOTS: + public Q_SLOTS: void setSelectedRow( int row ); -Q_SIGNALS: + Q_SIGNALS: void selectedRowChanged( int row ); void selectionModeChanged(); @@ -92,7 +92,7 @@ public Q_SLOTS: void preferredWidthFromColumnsChanged(); void textOptionsChanged(); -protected: + protected: void keyPressEvent( QKeyEvent* ) override; void keyReleaseEvent( QKeyEvent* ) override; @@ -103,7 +103,7 @@ public Q_SLOTS: void componentComplete() override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskListViewSkinlet.cpp b/src/controls/QskListViewSkinlet.cpp index a60fcf41c..26018dc14 100644 --- a/src/controls/QskListViewSkinlet.cpp +++ b/src/controls/QskListViewSkinlet.cpp @@ -4,22 +4,22 @@ *****************************************************************************/ #include "QskListViewSkinlet.h" -#include "QskListView.h" #include "QskColorFilter.h" #include "QskGraphic.h" +#include "QskListView.h" +#include #include #include #include -#include class QskListViewNode final : public QSGTransformNode { -public: - inline QskListViewNode( int columnCount ): - columnCount( columnCount ), - m_rowMin( -1 ), - m_rowMax( -1 ) + public: + inline QskListViewNode( int columnCount ) + : columnCount( columnCount ) + , m_rowMin( -1 ) + , m_rowMax( -1 ) { m_backgroundNode.setFlag( QSGNode::OwnedByParent, false ); appendChildNode( &m_backgroundNode ); @@ -71,7 +71,7 @@ class QskListViewNode final : public QSGTransformNode const int columnCount; -private: + private: int m_rowMin; int m_rowMax; @@ -79,8 +79,8 @@ class QskListViewNode final : public QSGTransformNode QSGNode m_foregroundNode; }; -QskListViewSkinlet::QskListViewSkinlet( QskSkin* skin ): - Inherited( skin ) +QskListViewSkinlet::QskListViewSkinlet( QskSkin* skin ) + : Inherited( skin ) { } @@ -436,8 +436,7 @@ QSGNode* QskListViewSkinlet::updateCellNode( const QskListView* listView, */ #endif const auto alignment = listView->flagHint< Qt::Alignment >( - QskListView::Cell | QskAspect::Alignment, - Qt::AlignVCenter | Qt::AlignLeft ); + QskListView::Cell | QskAspect::Alignment, Qt::AlignVCenter | Qt::AlignLeft ); const QVariant value = listView->valueAt( row, col ); @@ -448,8 +447,8 @@ QSGNode* QskListViewSkinlet::updateCellNode( const QskListView* listView, const auto colorFilter = listView->graphicFilterAt( row, col ); - newNode = updateGraphicNode( listView, newNode, value.value< QskGraphic >(), - colorFilter, rect, alignment ); + newNode = updateGraphicNode( listView, newNode, + value.value< QskGraphic >(), colorFilter, rect, alignment ); if ( newNode ) setNodeRole( newNode, GraphicRole ); diff --git a/src/controls/QskListViewSkinlet.h b/src/controls/QskListViewSkinlet.h index 5bae6ab54..8d385dbab 100644 --- a/src/controls/QskListViewSkinlet.h +++ b/src/controls/QskListViewSkinlet.h @@ -24,11 +24,11 @@ class QSK_EXPORT QskListViewSkinlet : public QskScrollViewSkinlet using Inherited = QskScrollViewSkinlet; -public: + public: Q_INVOKABLE QskListViewSkinlet( QskSkin* = nullptr ); ~QskListViewSkinlet() override; -protected: + protected: enum NodeRole { TextRole, @@ -41,7 +41,7 @@ class QSK_EXPORT QskListViewSkinlet : public QskScrollViewSkinlet virtual QSGNode* updateCellNode( const QskListView*, QSGNode*, const QRectF&, int row, int col ) const; -private: + private: void updateForegroundNodes( const QskListView*, QskListViewNode* ) const; void updateBackgroundNodes( const QskListView*, QskListViewNode* ) const; diff --git a/src/controls/QskObjectTree.cpp b/src/controls/QskObjectTree.cpp index a0f961fdc..7fcee5c67 100644 --- a/src/controls/QskObjectTree.cpp +++ b/src/controls/QskObjectTree.cpp @@ -5,9 +5,9 @@ #include "QskObjectTree.h" -#include -#include #include +#include +#include bool QskObjectTree::isRoot( const QObject* object ) { @@ -28,7 +28,7 @@ QObjectList QskObjectTree::childNodes( const QObject* object ) { const auto childObjects = object->children(); - for ( QObject* child : childObjects ) + for ( QObject* child : childObjects ) { if ( child->isWindowType() ) { @@ -62,7 +62,6 @@ QObject* QskObjectTree::parentNode( const QObject* object ) QObject* parentObject = object->parent(); if ( parentObject == nullptr ) return QGuiApplication::instance(); - } if ( const QQuickItem* item = qobject_cast< const QQuickItem* >( object ) ) @@ -97,4 +96,3 @@ void QskObjectTree::traverseUp( QObject* object, Visitor& visitor ) traverseUp( parent, visitor ); } } - diff --git a/src/controls/QskObjectTree.h b/src/controls/QskObjectTree.h index d7100da9e..c235807d8 100644 --- a/src/controls/QskObjectTree.h +++ b/src/controls/QskObjectTree.h @@ -16,7 +16,7 @@ namespace QskObjectTree { class Visitor { - public: + public: virtual ~Visitor() = default; virtual bool visitDown( QObject* object ) = 0; @@ -33,9 +33,9 @@ namespace QskObjectTree template< class T > class ResolveVisitor : public Visitor { - public: - ResolveVisitor( const char* propertyName ): - m_propertyName( propertyName ) + public: + ResolveVisitor( const char* propertyName ) + : m_propertyName( propertyName ) { } @@ -55,7 +55,7 @@ namespace QskObjectTree return setImplicitValue( control, m_value ); if ( QskWindow* window = qobject_cast< QskWindow* >( object ) ) - return setImplicitValue( window, m_value ); + return setImplicitValue( window, m_value ); return !setProperty( object, m_propertyName.constData(), m_value ); } @@ -80,9 +80,9 @@ namespace QskObjectTree return getProperty( object, m_propertyName, m_value ); } - private: - inline bool getProperty( - const QObject* object, const char* name, T& value ) const + private: + inline bool getProperty( const QObject* object, + const char* name, T& value ) const { if ( !m_propertyName.isEmpty() ) { @@ -97,8 +97,8 @@ namespace QskObjectTree return false; } - inline bool setProperty( - QObject* object, const char* name, const T& value ) const + inline bool setProperty( QObject* object, + const char* name, const T& value ) const { T oldValue; if ( !getProperty( object, name, oldValue ) || oldValue == value ) @@ -114,11 +114,10 @@ namespace QskObjectTree virtual T value( const QskControl* ) const = 0; virtual T value( const QskWindow* ) const = 0; - private: + private: const QByteArray m_propertyName; T m_value; }; } #endif - diff --git a/src/controls/QskPageIndicator.cpp b/src/controls/QskPageIndicator.cpp index 61c860f95..eb68bfcbc 100644 --- a/src/controls/QskPageIndicator.cpp +++ b/src/controls/QskPageIndicator.cpp @@ -12,11 +12,11 @@ QSK_SUBCONTROL( QskPageIndicator, Highlighted ) class QskPageIndicator::PrivateData { -public: - PrivateData( int count ): - count ( count ), - currentIndex( -1 ), - orientation( Qt::Horizontal ) + public: + PrivateData( int count ) + : count( count ) + , currentIndex( -1 ) + , orientation( Qt::Horizontal ) { } @@ -25,16 +25,16 @@ class QskPageIndicator::PrivateData Qt::Orientation orientation : 2; }; -QskPageIndicator::QskPageIndicator( int count, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData( count ) ) +QskPageIndicator::QskPageIndicator( int count, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( count ) ) { // as we don't stretch the bullets initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); } -QskPageIndicator::QskPageIndicator( QQuickItem* parent ): - QskPageIndicator( 0, parent ) +QskPageIndicator::QskPageIndicator( QQuickItem* parent ) + : QskPageIndicator( 0, parent ) { } @@ -59,7 +59,7 @@ Qt::Orientation QskPageIndicator::orientation() const void QskPageIndicator::setOrientation( Qt::Orientation orientation ) { - if (orientation != m_data->orientation ) + if ( orientation != m_data->orientation ) { m_data->orientation = orientation; @@ -88,7 +88,7 @@ void QskPageIndicator::setCurrentIndex( qreal index ) if ( index < 0 || index >= m_data->count ) index = -1; - if (index != m_data->currentIndex ) + if ( index != m_data->currentIndex ) { m_data->currentIndex = index; update(); @@ -118,7 +118,6 @@ QSizeF QskPageIndicator::contentsSizeHint() const if ( n > 1 ) w += ( n - 1 ) * ( sizeBullet + spacing ); - } h = qMax( sizeCurrent, sizeBullet ); diff --git a/src/controls/QskPageIndicator.h b/src/controls/QskPageIndicator.h index 96b1ec7ed..ef8eabaff 100644 --- a/src/controls/QskPageIndicator.h +++ b/src/controls/QskPageIndicator.h @@ -14,13 +14,18 @@ class QSK_EXPORT QskPageIndicator : public QskControl { Q_OBJECT - Q_PROPERTY ( int count READ count WRITE setCount NOTIFY countChanged FINAL ) - Q_PROPERTY ( qreal currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL ) - Q_PROPERTY ( Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL ) + Q_PROPERTY( int count READ count + WRITE setCount NOTIFY countChanged FINAL ) + + Q_PROPERTY( qreal currentIndex READ currentIndex + WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL ) + + Q_PROPERTY( Qt::Orientation orientation READ orientation + WRITE setOrientation NOTIFY orientationChanged FINAL ) using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel, Bullet, Highlighted ) QskPageIndicator( QQuickItem* parent = nullptr ); @@ -37,16 +42,16 @@ class QSK_EXPORT QskPageIndicator : public QskControl QSizeF contentsSizeHint() const override; -Q_SIGNALS: + Q_SIGNALS: void countChanged(); void currentIndexChanged(); void orientationChanged(); -public Q_SLOTS: + public Q_SLOTS: void setCount( int count ); void setCurrentIndex( qreal index ); -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskPageIndicatorSkinlet.cpp b/src/controls/QskPageIndicatorSkinlet.cpp index 3bbcdf632..e0335b0c8 100644 --- a/src/controls/QskPageIndicatorSkinlet.cpp +++ b/src/controls/QskPageIndicatorSkinlet.cpp @@ -4,11 +4,11 @@ *****************************************************************************/ #include "QskPageIndicatorSkinlet.h" -#include "QskPageIndicator.h" #include "QskBoxNode.h" +#include "QskPageIndicator.h" -QskPageIndicatorSkinlet::QskPageIndicatorSkinlet( QskSkin* skin ): - QskSkinlet(skin) +QskPageIndicatorSkinlet::QskPageIndicatorSkinlet( QskSkin* skin ) + : QskSkinlet( skin ) { setNodeRoles( { PanelRole, BulletsRole } ); } @@ -30,12 +30,12 @@ QRectF QskPageIndicatorSkinlet::subControlRect( return Inherited::subControlRect( skinnable, subControl ); } -QSGNode* QskPageIndicatorSkinlet::updateSubNode( const QskSkinnable* skinnable, - quint8 nodeRole, QSGNode* node ) const +QSGNode* QskPageIndicatorSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { const auto indicator = static_cast< const QskPageIndicator* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { @@ -54,12 +54,15 @@ QSGNode* QskPageIndicatorSkinlet::updateSubNode( const QskSkinnable* skinnable, QRectF QskPageIndicatorSkinlet::bulletRect( const QskPageIndicator* indicator, const QRectF& rect, int index ) const { - const qreal szNormal = indicator->metric( QskPageIndicator::Bullet | QskAspect::Size ); - const qreal szHighlighted = indicator->metric( QskPageIndicator::Highlighted | QskAspect::Size ); + const qreal szNormal = + indicator->metric( QskPageIndicator::Bullet | QskAspect::Size ); + + const qreal szHighlighted = + indicator->metric( QskPageIndicator::Highlighted | QskAspect::Size ); // scale bullet size if we are in between a transition: qreal indexDiff = qAbs( indicator->currentIndex() - index ); - if (indexDiff > ( indicator->count() - 1 ) ) + if ( indexDiff > ( indicator->count() - 1 ) ) indexDiff = ( indicator->count() - indicator->currentIndex() ); // wrapping const qreal sz = ( indexDiff < 1 ) ? @@ -92,7 +95,7 @@ QRectF QskPageIndicatorSkinlet::bulletRect( s2 = szNormal + qAbs( szHighlighted - szNormal ) * indexDiff; } else if ( ( indicator->currentIndex() > ( indicator->count() - 1 ) && - index > ( indicator->currentIndex() - indicator->count() + 1 ) ) ) + index > ( indicator->currentIndex() - indicator->count() + 1 ) ) ) { // wrapping case: qreal wrappingDiff = indexDiff; @@ -125,7 +128,7 @@ QRectF QskPageIndicatorSkinlet::bulletRect( } QSGNode* QskPageIndicatorSkinlet::updateBulletsNode( - const QskPageIndicator* indicator, QSGNode* node) const + const QskPageIndicator* indicator, QSGNode* node ) const { if ( indicator->count() == 0 ) return nullptr; diff --git a/src/controls/QskPageIndicatorSkinlet.h b/src/controls/QskPageIndicatorSkinlet.h index d520b8f3a..836be92c8 100644 --- a/src/controls/QskPageIndicatorSkinlet.h +++ b/src/controls/QskPageIndicatorSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskPageIndicatorSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole, @@ -27,14 +27,14 @@ class QSK_EXPORT QskPageIndicatorSkinlet : public QskSkinlet Q_INVOKABLE QskPageIndicatorSkinlet( QskSkin* = nullptr ); ~QskPageIndicatorSkinlet() override; - QRectF subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QSGNode* updateBulletsNode( const QskPageIndicator*, QSGNode* ) const; QRectF bulletRect( const QskPageIndicator*, const QRectF&, int index ) const; }; diff --git a/src/controls/QskPanGestureRecognizer.cpp b/src/controls/QskPanGestureRecognizer.cpp index a74680198..238ba8b2b 100644 --- a/src/controls/QskPanGestureRecognizer.cpp +++ b/src/controls/QskPanGestureRecognizer.cpp @@ -1,14 +1,14 @@ #include "QskPanGestureRecognizer.h" -#include "QskGesture.h" #include "QskEvent.h" +#include "QskGesture.h" -#include #include -#include #include +#include +#include -static inline qreal qskDistance( const QPointF& from, const QPointF& to, - Qt::Orientations orientations ) +static inline qreal qskDistance( + const QPointF& from, const QPointF& to, Qt::Orientations orientations ) { if ( orientations == Qt::Horizontal ) return to.x() - from.x(); @@ -22,8 +22,8 @@ static inline qreal qskDistance( const QPointF& from, const QPointF& to, return qSqrt( dx * dx + dy * dy ); } -static inline qreal qskAngle( const QPointF& from, const QPointF& to, - Qt::Orientations orientations ) +static inline qreal qskAngle( + const QPointF& from, const QPointF& to, Qt::Orientations orientations ) { if ( orientations == Qt::Horizontal ) return ( to.x() >= from.x() ) ? 0.0 : 180.0; @@ -56,7 +56,7 @@ namespace { class VelocityTracker { - public: + public: VelocityTracker() { reset(); @@ -64,14 +64,14 @@ namespace void record( int elapsed, qreal velocity ) { - if ( ( velocity != 0.0 ) && ( m_values[m_pos].velocity != 0.0 ) ) + if ( ( velocity != 0.0 ) && ( m_values[ m_pos ].velocity != 0.0 ) ) { - if ( ( velocity > 0.0 ) != ( m_values[m_pos].velocity > 0.0 ) ) + if ( ( velocity > 0.0 ) != ( m_values[ m_pos ].velocity > 0.0 ) ) reset(); // direction has changed } - m_values[m_pos].elapsed = elapsed; - m_values[m_pos].velocity = velocity; + m_values[ m_pos ].elapsed = elapsed; + m_values[ m_pos ].velocity = velocity; m_pos = ( m_pos + 1 ) % Count; } @@ -80,8 +80,8 @@ namespace { for ( int i = 0; i < Count; i++ ) { - m_values[i].elapsed = -1; - m_values[i].velocity = 0; + m_values[ i ].elapsed = -1; + m_values[ i ].velocity = 0; } m_pos = 0; } @@ -93,7 +93,7 @@ namespace for ( int i = 0; i < Count; i++ ) { - const auto& v = m_values[i]; + const auto& v = m_values[ i ]; // only swipe events within the last 500 ms will be considered if ( v.elapsed > 0 && ( elapsed - v.elapsed ) <= 500 ) @@ -106,7 +106,7 @@ namespace return ( numVelocities > 0 ) ? ( sum / numVelocities ) : 0.0; } - private: + private: int m_pos; enum { Count = 3 }; @@ -120,12 +120,12 @@ namespace class QskPanGestureRecognizer::PrivateData { -public: - PrivateData(): - orientations( Qt::Horizontal | Qt::Vertical ), - minDistance( 15 ), - timestamp( 0.0 ), - angle( 0.0 ) + public: + PrivateData() + : orientations( Qt::Horizontal | Qt::Vertical ) + , minDistance( 15 ) + , timestamp( 0.0 ) + , angle( 0.0 ) { } @@ -137,13 +137,13 @@ class QskPanGestureRecognizer::PrivateData qreal angle; QPointF origin; - QPointF pos; // position of the last mouse event + QPointF pos; // position of the last mouse event VelocityTracker velocityTracker; }; -QskPanGestureRecognizer::QskPanGestureRecognizer(): - m_data( new PrivateData() ) +QskPanGestureRecognizer::QskPanGestureRecognizer() + : m_data( new PrivateData() ) { } diff --git a/src/controls/QskPanGestureRecognizer.h b/src/controls/QskPanGestureRecognizer.h index b692573d1..f10f9a797 100644 --- a/src/controls/QskPanGestureRecognizer.h +++ b/src/controls/QskPanGestureRecognizer.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskPanGestureRecognizer : public QskGestureRecognizer { using Inherited = QskGestureRecognizer; -public: + public: QskPanGestureRecognizer(); ~QskPanGestureRecognizer() override; @@ -25,7 +25,7 @@ class QSK_EXPORT QskPanGestureRecognizer : public QskGestureRecognizer void setOrientations( Qt::Orientations ); Qt::Orientations orientations() const; -private: + private: void pressEvent( const QMouseEvent* ) override; void moveEvent( const QMouseEvent* ) override; void releaseEvent( const QMouseEvent* ) override; diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index 05913f618..5ad076a32 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -4,10 +4,10 @@ *****************************************************************************/ #include "QskPopup.h" -#include "QskInputGrabber.h" #include "QskAspect.h" -#include "QskWindow.h" +#include "QskInputGrabber.h" #include "QskQuick.h" +#include "QskWindow.h" QSK_QT_PRIVATE_BEGIN #include @@ -43,14 +43,14 @@ namespace { using Inherited = QskInputGrabber; - public: - InputGrabber( QskPopup* parent ): - Inherited( parent ) + public: + InputGrabber( QskPopup* parent ) + : Inherited( parent ) { } - void geometryChanged( - const QRectF& newGeometry, const QRectF& oldGeometry ) override + void geometryChanged( const QRectF& newGeometry, + const QRectF& oldGeometry ) override { Inherited::geometryChanged( newGeometry, oldGeometry ); @@ -84,14 +84,14 @@ namespace class QskPopup::PrivateData { -public: - PrivateData(): - inputGrabber( nullptr ), - flags( 0 ), - isModal( false ), - isOpen( false ), - autoGrabFocus( true ), - handoverFocus( true ) + public: + PrivateData() + : inputGrabber( nullptr ) + , flags( 0 ) + , isModal( false ) + , isOpen( false ) + , autoGrabFocus( true ) + , handoverFocus( true ) { } @@ -105,9 +105,9 @@ class QskPopup::PrivateData const bool handoverFocus : 1; }; -QskPopup::QskPopup( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskPopup::QskPopup( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { // we need to stop event propagation setAcceptedMouseButtons( Qt::AllButtons ); @@ -166,8 +166,8 @@ QRectF QskPopup::overlayRect() const void QskPopup::updateInputGrabber() { - if ( parentItem() && isVisible() - && ( isModal() || testPopupFlag( CloseOnPressOutside ) ) ) + if ( parentItem() && isVisible() && + ( isModal() || testPopupFlag( CloseOnPressOutside ) ) ) { if ( m_data->inputGrabber == nullptr ) { @@ -292,7 +292,7 @@ bool QskPopup::event( QEvent* event ) { bool ok = Inherited::event( event ); - switch( event->type() ) + switch ( event->type() ) { case QEvent::KeyPress: case QEvent::KeyRelease: @@ -370,12 +370,12 @@ QQuickItem* QskPopup::focusSuccessor() const if ( const auto scope = qskNearestFocusScope( this ) ) { const auto children = qskPaintOrderChildItems( scope ); - for ( auto it = children.crbegin(); it != children.crend(); ++it) + for ( auto it = children.crbegin(); it != children.crend(); ++it ) { auto child = *it; - if ( ( child != this ) && child->isFocusScope() - && child->activeFocusOnTab() && child->isVisible() ) + if ( ( child != this ) && child->isFocusScope() && + child->activeFocusOnTab() && child->isVisible() ) { return child; } diff --git a/src/controls/QskPopup.h b/src/controls/QskPopup.h index 0eed76bec..c9a147303 100644 --- a/src/controls/QskPopup.h +++ b/src/controls/QskPopup.h @@ -18,7 +18,7 @@ class QSK_EXPORT QskPopup : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Overlay ) enum PopupFlag @@ -50,22 +50,22 @@ class QSK_EXPORT QskPopup : public QskControl bool isOpen() const; -public Q_SLOTS: + public Q_SLOTS: void open(); void close(); -Q_SIGNALS: + Q_SIGNALS: void closed(); void modalChanged( bool ); void overlayChanged( bool ); -protected: + protected: void aboutToShow() override; virtual void setFading( bool on ); bool event( QEvent* ) override; - void focusInEvent( QFocusEvent * ) override; - void focusOutEvent( QFocusEvent * ) override; + void focusInEvent( QFocusEvent* ) override; + void focusOutEvent( QFocusEvent* ) override; void itemChange( QQuickItem::ItemChange, const QQuickItem::ItemChangeData& ) override; @@ -74,7 +74,7 @@ public Q_SLOTS: void grabFocus( bool ); -private: + private: void updateInputGrabber(); class PrivateData; diff --git a/src/controls/QskPopupSkinlet.cpp b/src/controls/QskPopupSkinlet.cpp index bb307b531..4bfd0b0ae 100644 --- a/src/controls/QskPopupSkinlet.cpp +++ b/src/controls/QskPopupSkinlet.cpp @@ -6,8 +6,8 @@ #include "QskPopupSkinlet.h" #include "QskPopup.h" -QskPopupSkinlet::QskPopupSkinlet( QskSkin* skin ): - Inherited( skin ) +QskPopupSkinlet::QskPopupSkinlet( QskSkin* skin ) + : Inherited( skin ) { appendNodeRoles( { OverlayRole } ); } @@ -25,10 +25,10 @@ QRectF QskPopupSkinlet::subControlRect( return Inherited::subControlRect( skinnable, subControl ); } -QSGNode* QskPopupSkinlet::updateSubNode( const QskSkinnable* skinnable, - quint8 nodeRole, QSGNode* node ) const +QSGNode* QskPopupSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { - switch( nodeRole ) + switch ( nodeRole ) { case OverlayRole: return updateBoxNode( skinnable, node, QskPopup::Overlay ); diff --git a/src/controls/QskPopupSkinlet.h b/src/controls/QskPopupSkinlet.h index f91c0acc0..fc997d197 100644 --- a/src/controls/QskPopupSkinlet.h +++ b/src/controls/QskPopupSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskPopupSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { OverlayRole @@ -29,11 +29,11 @@ class QSK_EXPORT QskPopupSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QSGNode* updateOverlayNode( const QskPopup*, QSGNode* ) const; }; diff --git a/src/controls/QskPushButton.cpp b/src/controls/QskPushButton.cpp index 757ecc704..f0962a703 100644 --- a/src/controls/QskPushButton.cpp +++ b/src/controls/QskPushButton.cpp @@ -5,14 +5,14 @@ #include "QskPushButton.h" #include "QskAspect.h" -#include "QskCorner.h" #include "QskBoxShapeMetrics.h" +#include "QskCorner.h" #include "QskGraphic.h" #include "QskGraphicProvider.h" -#include "QskTextOptions.h" -#include "QskSkin.h" #include "QskSetup.h" +#include "QskSkin.h" #include "QskSkinlet.h" +#include "QskTextOptions.h" #include @@ -22,10 +22,10 @@ QSK_SUBCONTROL( QskPushButton, Graphic ) class QskPushButton::PrivateData { -public: - PrivateData( const QString& txt ): - text( txt ), - isGraphicSourceDirty( false ) + public: + PrivateData( const QString& txt ) + : text( txt ) + , isGraphicSourceDirty( false ) { textOptions.setElideMode( Qt::ElideMiddle ); } @@ -39,14 +39,14 @@ class QskPushButton::PrivateData bool isGraphicSourceDirty : 1; }; -QskPushButton::QskPushButton( QQuickItem* parent ): - QskPushButton( QString(), parent ) +QskPushButton::QskPushButton( QQuickItem* parent ) + : QskPushButton( QString(), parent ) { } -QskPushButton::QskPushButton( const QString& text, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData( text ) ) +QskPushButton::QskPushButton( const QString& text, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( text ) ) { initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed ); } @@ -158,7 +158,7 @@ void QskPushButton::setGraphicSource( const QUrl& url ) Q_EMIT graphicSourceChanged(); } -void QskPushButton::setGraphicSource(const QString &source) +void QskPushButton::setGraphicSource( const QString& source ) { setGraphicSource( QUrl( source ) ); } @@ -250,12 +250,12 @@ QSizeF QskPushButton::contentsSizeHint() const void QskPushButton::changeEvent( QEvent* event ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::StyleChange: { - if ( !m_data->graphicSource.isEmpty() - && qskSetup->skin()->hasGraphicProvider() ) + if ( !m_data->graphicSource.isEmpty() && + qskSetup->skin()->hasGraphicProvider() ) { // we might need to reload from a different skin m_data->isGraphicSourceDirty = true; diff --git a/src/controls/QskPushButton.h b/src/controls/QskPushButton.h index 91042c833..1c1fa1557 100644 --- a/src/controls/QskPushButton.h +++ b/src/controls/QskPushButton.h @@ -32,7 +32,7 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton using Inherited = QskAbstractButton; -public: + public: QSK_SUBCONTROLS( Panel, Text, Graphic ) QskPushButton( QQuickItem* parent = nullptr ); @@ -60,13 +60,13 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton QSizeF contentsSizeHint() const override; QRectF layoutRect() const override; -public Q_SLOTS: + public Q_SLOTS: void setText( const QString& text ); void setGraphicSource( const QUrl& url ); void setGraphicSource( const QString& source ); void setGraphic( const QskGraphic& ); -Q_SIGNALS: + Q_SIGNALS: void cornerChanged(); void borderWidthChanged(); void textChanged(); @@ -77,7 +77,7 @@ public Q_SLOTS: void hovered( bool ); -protected: + protected: void hoverEnterEvent( QHoverEvent* ) override; void hoverLeaveEvent( QHoverEvent* ) override; void changeEvent( QEvent* ) override; @@ -85,7 +85,7 @@ public Q_SLOTS: void updateLayout() override; virtual QskGraphic loadGraphic( const QUrl& ) const; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskPushButtonSkinlet.cpp b/src/controls/QskPushButtonSkinlet.cpp index a942a6aaf..2870686f3 100644 --- a/src/controls/QskPushButtonSkinlet.cpp +++ b/src/controls/QskPushButtonSkinlet.cpp @@ -11,8 +11,8 @@ #include #include -QskPushButtonSkinlet::QskPushButtonSkinlet( QskSkin* skin ): - Inherited( skin ) +QskPushButtonSkinlet::QskPushButtonSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole, GraphicRole, TextRole } ); } @@ -45,7 +45,7 @@ QSGNode* QskPushButtonSkinlet::updateSubNode( { const auto button = static_cast< const QskPushButton* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { @@ -93,8 +93,8 @@ QRectF QskPushButtonSkinlet::graphicRect( const QskPushButton* button ) const if ( !button->text().isEmpty() ) { - qreal h = textRect( button ).height() - + button->metric( QskPushButton::Panel | QskAspect::Spacing ); + qreal h = textRect( button ).height() + + button->metric( QskPushButton::Panel | QskAspect::Spacing ); if ( h < r.height() ) r.setBottom( r.bottom() - h ); diff --git a/src/controls/QskPushButtonSkinlet.h b/src/controls/QskPushButtonSkinlet.h index f3e0d959e..5245d1ab5 100644 --- a/src/controls/QskPushButtonSkinlet.h +++ b/src/controls/QskPushButtonSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskPushButtonSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole, @@ -28,14 +28,14 @@ class QSK_EXPORT QskPushButtonSkinlet : public QskSkinlet Q_INVOKABLE QskPushButtonSkinlet( QskSkin* = nullptr ); ~QskPushButtonSkinlet() override; - QRectF subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QRectF textRect( const QskPushButton* ) const; QRectF graphicRect( const QskPushButton* ) const; @@ -43,4 +43,3 @@ class QSK_EXPORT QskPushButtonSkinlet : public QskSkinlet }; #endif - diff --git a/src/controls/QskQuick.cpp b/src/controls/QskQuick.cpp index f5c3949b7..e45136d7b 100644 --- a/src/controls/QskQuick.cpp +++ b/src/controls/QskQuick.cpp @@ -8,12 +8,12 @@ #include QSK_QT_PRIVATE_BEGIN -#include #include +#include QSK_QT_PRIVATE_END -#include #include +#include QRectF qskItemRect( const QQuickItem* item ) { @@ -50,7 +50,7 @@ bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child ) if ( item == nullptr || child == nullptr ) return false; -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) return item->isAncestorOf( child ); #else while ( child ) @@ -199,10 +199,9 @@ void qskUpdateInputMethod( const QQuickItem* item, Qt::InputMethodQueries querie inputContext directly. */ - inputContext->metaObject()->method( methodId ).invoke( - inputContext, Qt::DirectConnection, - Q_ARG( const QQuickItem*, item ), - Q_ARG( Qt::InputMethodQueries, queries ) ); + const auto method = inputContext->metaObject()->method( methodId ); + method.invoke( inputContext, Qt::DirectConnection, + Q_ARG( const QQuickItem*, item ), Q_ARG( Qt::InputMethodQueries, queries ) ); } else { @@ -233,10 +232,9 @@ void qskInputMethodSetVisible( const QQuickItem* item, bool on ) if ( methodId >= 0 ) { - inputContext->metaObject()->method( methodId ).invoke( - inputContext, Qt::DirectConnection, - Q_ARG( const QQuickItem*, item ), - Q_ARG( bool, on ) ); + const auto method = inputContext->metaObject()->method( methodId ); + method.invoke( inputContext, Qt::DirectConnection, + Q_ARG( const QQuickItem*, item ), Q_ARG( bool, on ) ); } else { diff --git a/src/controls/QskRangeControl.cpp b/src/controls/QskRangeControl.cpp index 51a6637a7..29483b7a3 100644 --- a/src/controls/QskRangeControl.cpp +++ b/src/controls/QskRangeControl.cpp @@ -8,15 +8,15 @@ class QskRangeControl::PrivateData { -public: - PrivateData(): - minimum( 0.0 ), - maximum( 1.0 ), - value( 0.0 ), - stepSize( 0.1 ), - pageSize( 1 ), - snap( false ), - readOnly( false ) + public: + PrivateData() + : minimum( 0.0 ) + , maximum( 1.0 ) + , value( 0.0 ) + , stepSize( 0.1 ) + , pageSize( 1 ) + , snap( false ) + , readOnly( false ) { } @@ -29,9 +29,9 @@ class QskRangeControl::PrivateData bool readOnly : 1; }; -QskRangeControl::QskRangeControl( QQuickItem* parent ): - QskControl( parent ), - m_data( new PrivateData() ) +QskRangeControl::QskRangeControl( QQuickItem* parent ) + : QskControl( parent ) + , m_data( new PrivateData() ) { m_data->readOnly = true; setReadOnly( false ); @@ -277,7 +277,7 @@ void QskRangeControl::keyPressEvent( QKeyEvent* event ) void QskRangeControl::wheelEvent( QWheelEvent* event ) { - if( isReadOnly() ) + if ( isReadOnly() ) return; const int steps = event->delta() / QWheelEvent::DefaultDeltasPerStep; diff --git a/src/controls/QskRangeControl.h b/src/controls/QskRangeControl.h index b62a352da..e8057653c 100644 --- a/src/controls/QskRangeControl.h +++ b/src/controls/QskRangeControl.h @@ -24,7 +24,7 @@ class QSK_EXPORT QskRangeControl : public QskControl using Inherited = QskControl; -public: + public: QskRangeControl( QQuickItem* parent = nullptr ); ~QskRangeControl() override; @@ -47,7 +47,7 @@ class QSK_EXPORT QskRangeControl : public QskControl void setReadOnly( bool ); bool isReadOnly() const; -public Q_SLOTS: + public Q_SLOTS: void setValue( qreal ); void setMinimum( qreal ); void setMaximum( qreal ); @@ -59,7 +59,7 @@ public Q_SLOTS: void pageUp(); void pageDown(); -Q_SIGNALS: + Q_SIGNALS: void minimumChanged( qreal ); void maximumChanged( qreal ); void rangeChanged( qreal ); @@ -69,7 +69,7 @@ public Q_SLOTS: void snapChanged( bool ); void readOnlyChanged( bool ); -protected: + protected: virtual qreal fixupValue( qreal value ) const; void keyPressEvent( QKeyEvent* event ) override; @@ -79,7 +79,7 @@ public Q_SLOTS: void componentComplete() override; -private: + private: void adjustRangeAndValue( bool ); class PrivateData; diff --git a/src/controls/QskRgbValue.cpp b/src/controls/QskRgbValue.cpp index 251d944c7..f289a9bd4 100644 --- a/src/controls/QskRgbValue.cpp +++ b/src/controls/QskRgbValue.cpp @@ -16,7 +16,7 @@ namespace static inline QColor qskInterpolatedColor( const QColor& c1, const QColor& c2, qreal ratio ) { - switch( c1.spec() ) + switch ( c1.spec() ) { case QColor::Rgb: { @@ -26,38 +26,38 @@ static inline QColor qskInterpolatedColor( const int a = value( c1.alpha(), c2.alpha(), ratio ); return QColor::fromRgb( r, g, b, a ); - } + } case QColor::Hsv: { const int h = value( c1.hue(), c2.hue(), ratio ); const int s = value( c1.saturation(), c2.saturation(), ratio ); const int v = value( c1.value(), c2.value(), ratio ); const int a = value( c1.alpha(), c2.alpha(), ratio ); - + return QColor::fromHsv( h, s, v, a ); - } + } case QColor::Cmyk: { const int c = value( c1.cyan(), c2.cyan(), ratio ); - const int m = value( c1.magenta(), c2.magenta(), ratio ); + const int m = value( c1.magenta(), c2.magenta(), ratio ); const int y = value( c1.yellow(), c2.yellow(), ratio ); const int k = value( c1.black(), c2.black(), ratio ); const int a = value( c1.alpha(), c2.alpha(), ratio ); return QColor::fromCmykF( c, m, y, k, a ); - } + } case QColor::Hsl: { const int h = value( c1.hue(), c2.hue(), ratio ); const int s = value( c1.saturation(), c2.saturation(), ratio ); const int l = value( c1.lightness(), c2.lightness(), ratio ); const int a = value( c1.alpha(), c2.alpha(), ratio ); - + return QColor::fromHsl( h, s, l, a ); - } + } case QColor::Invalid: break; - } + } return c2; } diff --git a/src/controls/QskRgbValue.h b/src/controls/QskRgbValue.h index 650b7312a..9f1946102 100644 --- a/src/controls/QskRgbValue.h +++ b/src/controls/QskRgbValue.h @@ -430,8 +430,8 @@ namespace QskRgbValue { -#define RGB(name, value) static constexpr const unsigned int name = value; -QSK_RGB_VALUES +#define RGB( name, value ) static constexpr const unsigned int name = value; + QSK_RGB_VALUES #undef RGB QSK_EXPORT QRgb interpolated( QRgb rgb1, QRgb rgb2, qreal ratio ); @@ -440,7 +440,7 @@ QSK_RGB_VALUES inline QColor toTransparent( const QColor& c1, int alpha = 0 ) { const auto alphaU = static_cast< uint >( alpha ); - return QColor::fromRgba( ( c1.rgb() & ColorMask ) | ( ( alphaU & 0xffu ) << 24 ) ); + return QColor::fromRgba( ( c1.rgb() & ColorMask ) | ( ( alphaU & 0xffu ) << 24 ) ); } inline QColor toTransparent( Qt::GlobalColor color, int alpha = 0 ) diff --git a/src/controls/QskScrollArea.cpp b/src/controls/QskScrollArea.cpp index c657a0c04..8b4be2433 100644 --- a/src/controls/QskScrollArea.cpp +++ b/src/controls/QskScrollArea.cpp @@ -4,16 +4,16 @@ *****************************************************************************/ #include "QskScrollArea.h" +#include "QskEvent.h" +#include "QskLayoutConstraint.h" #include "QskQuick.h" #include "QskScrollViewSkinlet.h" -#include "QskLayoutConstraint.h" -#include "QskEvent.h" QSK_QT_PRIVATE_BEGIN -#include -#include #include +#include #include +#include QSK_QT_PRIVATE_END static QSizeF qskAdjustedSize( const QQuickItem* item, const QSizeF& targetSize ) @@ -62,9 +62,9 @@ namespace { class ViewportClipNode final : public QQuickDefaultClipNode { - public: - ViewportClipNode(): - QQuickDefaultClipNode( QRectF() ) + public: + ViewportClipNode() + : QQuickDefaultClipNode( QRectF() ) { setGeometry( nullptr ); @@ -145,7 +145,7 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi // when inheriting from QskControl we participate in node cleanups using Inherited = QskControl; -public: + public: QskScrollAreaClipItem( QskScrollArea* ); virtual ~QskScrollAreaClipItem(); @@ -167,14 +167,14 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi return scrollArea()->subControlRect( QskScrollView::Viewport ); } -protected: + protected: bool event( QEvent* event ) override; void windowChangeEvent( QskWindowChangeEvent* ) override; void itemChange( ItemChange, const ItemChangeData& ) override; void geometryChanged( const QRectF&, const QRectF& ) override; -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) void itemGeometryChanged( QQuickItem*, QQuickGeometryChange change, const QRectF& ) override { @@ -193,7 +193,7 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi void updateNode( QSGNode* ) override; -private: + private: void connectWindow( const QQuickWindow*, bool on ); void onFocusItemChanged(); @@ -210,8 +210,8 @@ class QskScrollAreaClipItem final : public QskControl, public QQuickItemChangeLi const QSGClipNode* viewPortClipNode() const; }; -QskScrollAreaClipItem::QskScrollAreaClipItem( QskScrollArea* scrollArea ): - Inherited( scrollArea ) +QskScrollAreaClipItem::QskScrollAreaClipItem( QskScrollArea* scrollArea ) + : Inherited( scrollArea ) { setObjectName( QStringLiteral( "QskScrollAreaClipItem" ) ); setClip( true ); @@ -245,8 +245,8 @@ void QskScrollAreaClipItem::updateNode( QSGNode* ) { auto* d = QQuickItemPrivate::get( this ); - if ( QQuickItemPrivate::get( scrollArea() )->dirtyAttributes - & QQuickItemPrivate::ContentUpdateMask ) + if ( QQuickItemPrivate::get( scrollArea() )->dirtyAttributes & + QQuickItemPrivate::ContentUpdateMask ) { /* The update order depends on who calls update first and we @@ -369,7 +369,7 @@ void QskScrollAreaClipItem::onFocusItemChanged() bool QskScrollAreaClipItem::event( QEvent* event ) { - if( event->type() == QEvent::LayoutRequest ) + if ( event->type() == QEvent::LayoutRequest ) { if ( scrollArea()->isItemResizable() ) scrollArea()->polish(); @@ -388,10 +388,10 @@ void QskScrollAreaClipItem::windowChangeEvent( QskWindowChangeEvent* event ) class QskScrollArea::PrivateData { -public: - PrivateData(): - isItemResizable( true ), - autoScrollFocusItem( true ) + public: + PrivateData() + : isItemResizable( true ) + , autoScrollFocusItem( true ) { } @@ -429,9 +429,9 @@ class QskScrollArea::PrivateData that references the geometry of the viewport clip node. */ -QskScrollArea::QskScrollArea( QQuickItem* parentItem ): - Inherited( parentItem ), - m_data( new PrivateData() ) +QskScrollArea::QskScrollArea( QQuickItem* parentItem ) + : Inherited( parentItem ) + , m_data( new PrivateData() ) { setPolishOnResize( true ); diff --git a/src/controls/QskScrollArea.h b/src/controls/QskScrollArea.h index 62cdf27f3..4de13d039 100644 --- a/src/controls/QskScrollArea.h +++ b/src/controls/QskScrollArea.h @@ -23,7 +23,7 @@ class QSK_EXPORT QskScrollArea : public QskScrollView using Inherited = QskScrollView; -public: + public: QskScrollArea( QQuickItem* parent = nullptr ); ~QskScrollArea() override; @@ -36,17 +36,17 @@ class QSK_EXPORT QskScrollArea : public QskScrollView void setAutoScrollFocusedItem( bool on ); bool autoScrollFocusItem() const; - void ensureItemVisible( const QQuickItem * ); + void ensureItemVisible( const QQuickItem* ); -Q_SIGNALS: + Q_SIGNALS: void itemResizableChanged(); void scrolledItemChanged(); void autoScrollFocusedItemChanged(); -protected: + protected: void updateLayout() override; -private: + private: void translateItem(); void adjustItem(); diff --git a/src/controls/QskScrollView.cpp b/src/controls/QskScrollView.cpp index abd34dc28..9b63f7d5b 100644 --- a/src/controls/QskScrollView.cpp +++ b/src/controls/QskScrollView.cpp @@ -4,13 +4,13 @@ *****************************************************************************/ #include "QskScrollView.h" -#include "QskPanGestureRecognizer.h" -#include "QskFlickAnimator.h" -#include "QskBoxBorderMetrics.h" #include "QskAnimationHint.h" -#include "QskGesture.h" #include "QskAspect.h" +#include "QskBoxBorderMetrics.h" #include "QskEvent.h" +#include "QskFlickAnimator.h" +#include "QskGesture.h" +#include "QskPanGestureRecognizer.h" QSK_SUBCONTROL( QskScrollView, Panel ) QSK_SUBCONTROL( QskScrollView, Viewport ) @@ -26,7 +26,7 @@ namespace { class FlickAnimator final : public QskFlickAnimator { - public: + public: FlickAnimator() { // skin hints: TODO @@ -45,15 +45,15 @@ namespace m_scrollView->setScrollPos( pos - QPointF( dx, -dy ) ); } - private: + private: QskScrollView* m_scrollView; }; class ScrollAnimator final : public QskAnimator { - public: - ScrollAnimator(): - m_scrollView( nullptr ) + public: + ScrollAnimator() + : m_scrollView( nullptr ) { } @@ -88,7 +88,7 @@ namespace start(); } - protected: + protected: void advance( qreal value ) override { qreal x = m_from.x() + ( m_to.x() - m_from.x() ) * value; @@ -97,7 +97,7 @@ namespace m_scrollView->setScrollPos( QPointF( x, y ) ); } - private: + private: QskScrollView* m_scrollView; QPointF m_from; @@ -107,14 +107,14 @@ namespace class QskScrollView::PrivateData { -public: - PrivateData(): - horizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ), - verticalScrollBarPolicy( Qt::ScrollBarAsNeeded ), - scrollableSize( 0.0, 0.0 ), - panRecognizerTimeout( 100 ), // value coming from the platform ??? - viewportPadding( 10 ), - isScrolling( 0 ) + public: + PrivateData() + : horizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ) + , verticalScrollBarPolicy( Qt::ScrollBarAsNeeded ) + , scrollableSize( 0.0, 0.0 ) + , panRecognizerTimeout( 100 ) // value coming from the platform ??? + , viewportPadding( 10 ) + , isScrolling( 0 ) { } @@ -136,9 +136,9 @@ class QskScrollView::PrivateData int isScrolling; }; -QskScrollView::QskScrollView( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskScrollView::QskScrollView( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { m_data->flicker.setScrollView( this ); m_data->scroller.setScrollView( this ); @@ -470,7 +470,7 @@ void QskScrollView::gestureEvent( QskGestureEvent* event ) if ( event->gesture()->type() == QskGesture::Pan ) { const auto gesture = static_cast< const QskPanGesture* >( event->gesture() ); - switch( gesture->state() ) + switch ( gesture->state() ) { case QskGesture::Updated: { @@ -513,7 +513,7 @@ void QskScrollView::wheelEvent( QWheelEvent* event ) that generates wheel events in both directions. TODO ... */ - //offset = event->pixelDelta(); + // offset = event->pixelDelta(); if ( offset.isNull() ) { @@ -537,7 +537,7 @@ void QskScrollView::wheelEvent( QWheelEvent* event ) if ( !offset.isNull() ) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) if ( event->inverted() ) offset = -offset; #endif @@ -656,7 +656,8 @@ Qt::Orientations QskScrollView::scrollableOrientations() const // we have to check the vertical once more if ( ( policyV == Qt::ScrollBarAsNeeded ) && - ( m_data->scrollableSize.height() > vr.height() - metric( HorizontalScrollBar | QskAspect::Size ) ) ) + ( m_data->scrollableSize.height() > + vr.height() - metric( HorizontalScrollBar | QskAspect::Size ) ) ) { policyV = Qt::ScrollBarAlwaysOn; } diff --git a/src/controls/QskScrollView.h b/src/controls/QskScrollView.h index 2d024f9bd..ba7c42113 100644 --- a/src/controls/QskScrollView.h +++ b/src/controls/QskScrollView.h @@ -12,7 +12,8 @@ class QSK_EXPORT QskScrollView : public QskControl { Q_OBJECT - Q_PROPERTY( QPointF scrollPos READ scrollPos WRITE setScrollPos NOTIFY scrollPosChanged FINAL ) + Q_PROPERTY( QPointF scrollPos READ scrollPos + WRITE setScrollPos NOTIFY scrollPosChanged FINAL ) Q_PROPERTY( Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy NOTIFY verticalScrollBarPolicyChanged FINAL ) @@ -25,7 +26,7 @@ class QSK_EXPORT QskScrollView : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel, Viewport, HorizontalScrollBar, HorizontalScrollHandle, VerticalScrollBar, VerticalScrollHandle ) @@ -56,7 +57,7 @@ class QSK_EXPORT QskScrollView : public QskControl QRectF viewContentsRect() const; QRectF gestureRect() const override; -Q_SIGNALS: + Q_SIGNALS: void scrolledTo( const QPointF& ); void scrollPosChanged(); @@ -65,14 +66,14 @@ class QSK_EXPORT QskScrollView : public QskControl void flickableOrientationsChanged(); -public Q_SLOTS: + public Q_SLOTS: void setScrollPos( const QPointF& ); void scrollTo( const QPointF& ); void ensureVisible( const QPointF& ); void ensureVisible( const QRectF& ); -protected: + protected: void mouseMoveEvent( QMouseEvent* ) override; void mousePressEvent( QMouseEvent* ) override; void mouseReleaseEvent( QMouseEvent* ) override; @@ -87,7 +88,7 @@ public Q_SLOTS: void setScrollableSize( const QSizeF& ); -private: + private: QPointF boundedScrollPos( const QPointF& ) const; class PrivateData; diff --git a/src/controls/QskScrollViewSkinlet.cpp b/src/controls/QskScrollViewSkinlet.cpp index 42f0789e4..2aa3df180 100644 --- a/src/controls/QskScrollViewSkinlet.cpp +++ b/src/controls/QskScrollViewSkinlet.cpp @@ -4,9 +4,9 @@ *****************************************************************************/ #include "QskScrollViewSkinlet.h" -#include "QskScrollView.h" -#include "QskQuick.h" #include "QskAspect.h" +#include "QskQuick.h" +#include "QskScrollView.h" #include @@ -36,8 +36,8 @@ static void qskAlignedHandle( qreal start, qreal end, } } -QskScrollViewSkinlet::QskScrollViewSkinlet( QskSkin* skin ): - Inherited( skin ) +QskScrollViewSkinlet::QskScrollViewSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { ViewportRole, ContentsRootRole, HorizontalScrollBarRole, HorizontalScrollHandleRole, @@ -89,7 +89,7 @@ QSGNode* QskScrollViewSkinlet::updateSubNode( { const auto scrollView = static_cast< const QskScrollView* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case ViewportRole: { diff --git a/src/controls/QskScrollViewSkinlet.h b/src/controls/QskScrollViewSkinlet.h index 6fcadc4a1..5e96a6edd 100644 --- a/src/controls/QskScrollViewSkinlet.h +++ b/src/controls/QskScrollViewSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskScrollViewSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { ViewportRole, @@ -33,17 +33,17 @@ class QSK_EXPORT QskScrollViewSkinlet : public QskSkinlet Q_INVOKABLE QskScrollViewSkinlet( QskSkin* = nullptr ); ~QskScrollViewSkinlet() override; - QRectF subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; virtual QSGNode* updateContentsNode( const QskScrollView*, QSGNode* ) const; QSGNode* contentsNode( const QskScrollView* ); -private: + private: QSGNode* updateContentsRootNode( const QskScrollView*, QSGNode* ) const; QRectF viewportRect( const QskScrollView* ) const; diff --git a/src/controls/QskSeparator.cpp b/src/controls/QskSeparator.cpp index 6ee344657..25614f3d8 100644 --- a/src/controls/QskSeparator.cpp +++ b/src/controls/QskSeparator.cpp @@ -8,14 +8,14 @@ QSK_SUBCONTROL( QskSeparator, Panel ) -QskSeparator::QskSeparator( QQuickItem* parent ): - QskSeparator( Qt::Horizontal, parent ) +QskSeparator::QskSeparator( QQuickItem* parent ) + : QskSeparator( Qt::Horizontal, parent ) { } -QskSeparator::QskSeparator( Qt::Orientation orientation, QQuickItem* parent ): - Inherited( parent ), - m_orientation( orientation ) +QskSeparator::QskSeparator( Qt::Orientation orientation, QQuickItem* parent ) + : Inherited( parent ) + , m_orientation( orientation ) { if ( orientation == Qt::Horizontal ) initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed ); diff --git a/src/controls/QskSeparator.h b/src/controls/QskSeparator.h index 87267990d..a162693bf 100644 --- a/src/controls/QskSeparator.h +++ b/src/controls/QskSeparator.h @@ -21,7 +21,7 @@ class QSK_EXPORT QskSeparator : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel ) QskSeparator( QQuickItem* parent = nullptr ); @@ -38,11 +38,11 @@ class QSK_EXPORT QskSeparator : public QskControl QSizeF contentsSizeHint() const override; QskAspect::Placement effectivePlacement() const override; -Q_SIGNALS: + Q_SIGNALS: void orientationChanged( Qt::Orientation ); void thicknessChanged(); -private: + private: Qt::Orientation m_orientation; }; diff --git a/src/controls/QskSeparatorSkinlet.cpp b/src/controls/QskSeparatorSkinlet.cpp index cb4f1f59e..a2020124b 100644 --- a/src/controls/QskSeparatorSkinlet.cpp +++ b/src/controls/QskSeparatorSkinlet.cpp @@ -4,11 +4,11 @@ *****************************************************************************/ #include "QskSeparatorSkinlet.h" -#include "QskSeparator.h" #include "QskAspect.h" +#include "QskSeparator.h" -QskSeparatorSkinlet::QskSeparatorSkinlet( QskSkin* skin ): - Inherited( skin ) +QskSeparatorSkinlet::QskSeparatorSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole } ); } @@ -17,14 +17,14 @@ QskSeparatorSkinlet::~QskSeparatorSkinlet() = default; QRectF QskSeparatorSkinlet::subControlRect( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const -{ +{ const auto separator = static_cast< const QskSeparator* >( skinnable ); - + if ( subControl == QskSeparator::Panel ) { return panelRect( separator ); } - + return Inherited::subControlRect( skinnable, subControl ); } @@ -33,7 +33,7 @@ QSGNode* QskSeparatorSkinlet::updateSubNode( { const auto separator = static_cast< const QskSeparator* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { diff --git a/src/controls/QskSeparatorSkinlet.h b/src/controls/QskSeparatorSkinlet.h index cd2c34bd7..a970c38b1 100644 --- a/src/controls/QskSeparatorSkinlet.h +++ b/src/controls/QskSeparatorSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskSeparatorSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole, @@ -29,13 +29,12 @@ class QSK_EXPORT QskSeparatorSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QRectF panelRect( const QskSeparator* ) const; }; #endif - diff --git a/src/controls/QskSetup.cpp b/src/controls/QskSetup.cpp index 915d3a6fb..0716f89f7 100644 --- a/src/controls/QskSetup.cpp +++ b/src/controls/QskSetup.cpp @@ -4,15 +4,15 @@ *****************************************************************************/ #include "QskSetup.h" +#include "QskControl.h" +#include "QskGraphicProviderMap.h" +#include "QskObjectTree.h" #include "QskSkin.h" #include "QskSkinManager.h" -#include "QskGraphicProviderMap.h" -#include "QskControl.h" #include "QskWindow.h" -#include "QskObjectTree.h" -#include #include +#include #include QskSetup* QskSetup::s_instance = nullptr; @@ -80,21 +80,21 @@ namespace { class VisitorLocale final : public QskObjectTree::ResolveVisitor< QLocale > { - public: - VisitorLocale(): - ResolveVisitor< QLocale >( "locale" ) + public: + VisitorLocale() + : ResolveVisitor< QLocale >( "locale" ) { } - private: - bool setImplicitValue( - QskControl* control, const QLocale& locale ) override + private: + bool setImplicitValue( QskControl* control, + const QLocale& locale ) override { return qskInheritLocale( control, locale ); } - bool setImplicitValue( - QskWindow* window, const QLocale& locale ) override + bool setImplicitValue( QskWindow* window, + const QLocale& locale ) override { return qskInheritLocale( window, locale ); } @@ -113,9 +113,9 @@ namespace class QskSetup::PrivateData { -public: - PrivateData(): - controlFlags( qskDefaultControlFlags() ) + public: + PrivateData() + : controlFlags( qskDefaultControlFlags() ) { } @@ -126,8 +126,8 @@ class QskSetup::PrivateData QskSetup::Flags controlFlags; }; -QskSetup::QskSetup(): - m_data( new PrivateData() ) +QskSetup::QskSetup() + : m_data( new PrivateData() ) { } @@ -266,7 +266,6 @@ QLocale QskSetup::inheritedLocale( const QObject* object ) return visitor.resolveValue(); } - void QskSetup::inheritLocale( QObject* object, const QLocale& locale ) { VisitorLocale visitor; @@ -294,7 +293,7 @@ bool QskSetup::eventFilter( QObject* object, QEvent* event ) That's why we prefer to do the focus management outside of the event handlers. */ - switch( event->type() ) + switch ( event->type() ) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: diff --git a/src/controls/QskSetup.h b/src/controls/QskSetup.h index 4b7e39428..dc5ceca37 100644 --- a/src/controls/QskSetup.h +++ b/src/controls/QskSetup.h @@ -7,8 +7,10 @@ #define QSK_SETUP_H 1 #include "QskGlobal.h" -#include + +#include #include + #include class QskSkin; @@ -27,7 +29,7 @@ class QSK_EXPORT QskSetup : public QObject { Q_OBJECT -public: + public: enum Flag { DeferredUpdate = 1 << 0, @@ -43,7 +45,7 @@ class QSK_EXPORT QskSetup : public QObject Q_ENUM( Flag ) Q_DECLARE_FLAGS( Flags, Flag ) - static QskSetup * instance(); + static QskSetup* instance(); Q_INVOKABLE void setControlFlags( Flags ); Q_INVOKABLE void resetControlFlags(); @@ -69,11 +71,11 @@ class QSK_EXPORT QskSetup : public QObject static QskSetup* qmlAttachedProperties( QObject* ); -Q_SIGNALS: + Q_SIGNALS: void skinChanged( QskSkin* ); void controlFlagsChanged(); -private: + private: QskSetup(); ~QskSetup() override; @@ -87,7 +89,7 @@ class QSK_EXPORT QskSetup : public QObject QML_DECLARE_TYPEINFO( QskSetup, QML_HAS_ATTACHED_PROPERTIES ) -inline QskSetup * QskSetup::instance() +inline QskSetup* QskSetup::instance() { Q_ASSERT( s_instance ); return s_instance; diff --git a/src/controls/QskShortcut.cpp b/src/controls/QskShortcut.cpp index 31d171c7c..2ec123635 100644 --- a/src/controls/QskShortcut.cpp +++ b/src/controls/QskShortcut.cpp @@ -34,13 +34,13 @@ static bool qskContextMatcher( QObject* object, Qt::ShortcutContext context ) class QskShortcut::PrivateData { -public: - PrivateData(): - id( 0 ), - autoRepeat( true ), - enabled( true ), - isWindowContext( true ), - isComplete( true ) + public: + PrivateData() + : id( 0 ) + , autoRepeat( true ) + , enabled( true ) + , isWindowContext( true ) + , isComplete( true ) { } @@ -81,7 +81,7 @@ class QskShortcut::PrivateData shortcut->Q_EMIT shortcutIdChanged( id ); } -public: + public: QKeySequence sequence; int id; @@ -92,21 +92,21 @@ class QskShortcut::PrivateData bool isComplete : 1; }; -QskShortcut::QskShortcut( QObject* parent ): - Inherited( parent ), - m_data( new PrivateData ) +QskShortcut::QskShortcut( QObject* parent ) + : Inherited( parent ) + , m_data( new PrivateData ) { } -QskShortcut::QskShortcut( const QKeySequence& sequence, QObject* parent ): - QskShortcut( sequence, Qt::WindowShortcut, parent ) +QskShortcut::QskShortcut( const QKeySequence& sequence, QObject* parent ) + : QskShortcut( sequence, Qt::WindowShortcut, parent ) { } QskShortcut::QskShortcut( const QKeySequence& sequence, - Qt::ShortcutContext context, QObject* parent ): - Inherited( parent ), - m_data( new PrivateData ) + Qt::ShortcutContext context, QObject* parent ) + : Inherited( parent ) + , m_data( new PrivateData ) { m_data->sequence = sequence; m_data->isWindowContext = ( context == Qt::WindowShortcut ); @@ -130,8 +130,8 @@ Qt::ShortcutContext QskShortcut::context() const void QskShortcut::setContext( Qt::ShortcutContext context ) { - if ( context == Qt::ApplicationShortcut - || context == Qt::WindowShortcut ) + if ( context == Qt::ApplicationShortcut || + context == Qt::WindowShortcut ) { const bool isWindowContext = ( context == Qt::WindowShortcut ); @@ -164,7 +164,7 @@ QKeySequence QskShortcut::sequence() const void QskShortcut::setSequenceVariant( const QVariant& sequence ) { if ( sequence.type() == QVariant::Int ) - setSequence( static_cast( sequence.toInt() ) ); + setSequence( static_cast< QKeySequence::StandardKey >( sequence.toInt() ) ); else setSequence( QKeySequence::fromString( sequence.toString() ) ); } diff --git a/src/controls/QskShortcut.h b/src/controls/QskShortcut.h index bb23da41e..3f7b8061f 100644 --- a/src/controls/QskShortcut.h +++ b/src/controls/QskShortcut.h @@ -8,9 +8,9 @@ #include "QskGlobal.h" +#include #include #include -#include #include @@ -42,7 +42,7 @@ class QSK_EXPORT QskShortcut : public QObject, public QQmlParserStatus using Inherited = QObject; -public: + public: QskShortcut( QObject* parent = nullptr ); QskShortcut( const QKeySequence&, QObject* = nullptr ); @@ -60,7 +60,7 @@ class QSK_EXPORT QskShortcut : public QObject, public QQmlParserStatus QVariant sequenceVariant() const; Qt::ShortcutContext context() const; - void setContext(Qt::ShortcutContext context); + void setContext( Qt::ShortcutContext ); void setEnabled( bool ); bool isEnabled() const; @@ -70,7 +70,7 @@ class QSK_EXPORT QskShortcut : public QObject, public QQmlParserStatus virtual bool isFocusInScope() const; -Q_SIGNALS: + Q_SIGNALS: void sequenceChanged(); void contextChanged(); void enabledChanged(); @@ -81,12 +81,12 @@ class QSK_EXPORT QskShortcut : public QObject, public QQmlParserStatus int shortcutIdChanged( int ) const; -protected: + protected: bool event( QEvent* ) override; void classBegin() override; void componentComplete() override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskShortcutMap.cpp b/src/controls/QskShortcutMap.cpp index 5190fddae..b32bffbcd 100644 --- a/src/controls/QskShortcutMap.cpp +++ b/src/controls/QskShortcutMap.cpp @@ -4,11 +4,11 @@ *****************************************************************************/ #include "QskShortcutMap.h" -#include "QskQuick.h" #include "QskMetaInvokable.h" +#include "QskQuick.h" -#include #include +#include QSK_QT_PRIVATE_BEGIN #include @@ -23,7 +23,7 @@ static inline QShortcutMap* qskShortcutMap() class QskShortcutHandler final : public QObject { -public: + public: QskShortcutHandler(); int insert( QQuickItem*, const QKeySequence&, bool autoRepeat, @@ -36,16 +36,15 @@ class QskShortcutHandler final : public QObject bool eventFilter( QObject*, QEvent* ) override; -private: - + private: void cleanUp( QObject* ); class InvokeData { - public: - InvokeData(): - item( nullptr ), - receiver( nullptr ) + public: + InvokeData() + : item( nullptr ) + , receiver( nullptr ) { } @@ -241,7 +240,7 @@ bool QskShortcutHandler::eventFilter( QObject* object, QEvent* event ) Q_ASSERT( data.item == nullptr || data.item == object ); - auto receiver = const_cast< QObject* > ( data.receiver ); + auto receiver = const_cast< QObject* >( data.receiver ); void* args[] = { nullptr }; data.invokable.invoke( receiver, args, Qt::AutoConnection ); @@ -269,8 +268,8 @@ int QskShortcutMap::addMethod( QQuickItem* item, const QKeySequence& sequence, int QskShortcutMap::addFunction( QQuickItem* item, const QKeySequence& sequence, bool autoRepeat, const QObject* receiver, const QskMetaFunction& function ) { - if ( ( receiver == nullptr ) - && ( function.functionType() == QskMetaFunction::MemberFunction ) ) + if ( ( receiver == nullptr ) && + ( function.functionType() == QskMetaFunction::MemberFunction ) ) { qDebug() << "QskShortcutMap: bad receiver for shortcut:" << sequence; return 0; @@ -331,4 +330,3 @@ bool QskShortcutMap::contextMatcher( return false; } - diff --git a/src/controls/QskShortcutMap.h b/src/controls/QskShortcutMap.h index 840954433..8e9f74c23 100644 --- a/src/controls/QskShortcutMap.h +++ b/src/controls/QskShortcutMap.h @@ -16,7 +16,7 @@ class QKeySequence; class QSK_EXPORT QskShortcutMap { -public: + public: static void setAutoRepeat( int, bool on ); static void setEnabled( int, bool on ); @@ -59,7 +59,7 @@ class QSK_EXPORT QskShortcutMap static bool contextMatcher( const QQuickItem*, Qt::ShortcutContext ); -private: + private: QskShortcutMap() = delete; ~QskShortcutMap() = delete; diff --git a/src/controls/QskSimpleListBox.cpp b/src/controls/QskSimpleListBox.cpp index c86db9194..ae6a5b5d5 100644 --- a/src/controls/QskSimpleListBox.cpp +++ b/src/controls/QskSimpleListBox.cpp @@ -16,7 +16,7 @@ static inline qreal qskMaxWidth( qreal max = 0.0; for ( int i = 0; i < list.size(); i++ ) { - const qreal w = fm.width( list[i] ); + const qreal w = fm.width( list[ i ] ); if ( w > max ) max = w; } @@ -26,10 +26,10 @@ static inline qreal qskMaxWidth( class QskSimpleListBox::PrivateData { -public: - PrivateData(): - maxTextWidth( 0.0 ), - columnWidthHint( 0.0 ) + public: + PrivateData() + : maxTextWidth( 0.0 ) + , columnWidthHint( 0.0 ) { } @@ -40,12 +40,12 @@ class QskSimpleListBox::PrivateData QStringList entries; }; -QskSimpleListBox::QskSimpleListBox( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskSimpleListBox::QskSimpleListBox( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { connect( this, &Inherited::selectedRowChanged, - this, [this]( int row ) { Q_EMIT selectedEntryChanged( entryAt( row ) ); } ); + this, [ this ]( int row ) { Q_EMIT selectedEntryChanged( entryAt( row ) ); } ); } QskSimpleListBox::~QskSimpleListBox() @@ -55,7 +55,7 @@ QskSimpleListBox::~QskSimpleListBox() QString QskSimpleListBox::entryAt( int row ) const { if ( row >= 0 && row < m_data->entries.size() ) - return m_data->entries[row]; + return m_data->entries[ row ]; return QString(); } @@ -63,7 +63,7 @@ QString QskSimpleListBox::entryAt( int row ) const QVariant QskSimpleListBox::valueAt( int row, int col ) const { if ( col == 0 && row >= 0 && row < m_data->entries.size() ) - return m_data->entries[row]; + return m_data->entries[ row ]; return QVariant(); } @@ -110,8 +110,7 @@ void QskSimpleListBox::insert( const QStringList& list, int index ) { m_data->entries = list; } - else - if ( index < 0 || index >= m_data->entries.size() ) + else if ( index < 0 || index >= m_data->entries.size() ) { m_data->entries += list; } @@ -119,7 +118,7 @@ void QskSimpleListBox::insert( const QStringList& list, int index ) { // is there no better way ??? for ( int i = 0; i < list.size(); i++ ) - m_data->entries.insert( index + i, list[i] ); + m_data->entries.insert( index + i, list[ i ] ); } propagateEntries(); @@ -170,7 +169,7 @@ void QskSimpleListBox::removeAt( int index ) if ( m_data->columnWidthHint <= 0.0 ) { const QFontMetricsF fm( effectiveFont( Cell ) ); - const auto w = fm.width( entries[index] ); + const auto w = fm.width( entries[ index ] ); if ( w >= m_data->maxTextWidth ) m_data->maxTextWidth = qskMaxWidth( effectiveFont( Text ), entries ); @@ -220,13 +219,11 @@ void QskSimpleListBox::removeBulk( int from, int to ) { row = -1; } - else - if ( row < from ) + else if ( row < from ) { // nothing to do } - else - if ( row <= to ) + else if ( row <= to ) { // we might end up here with the same row TODO ... row = qMin( from, m_data->entries.size() - 1 ); diff --git a/src/controls/QskSimpleListBox.h b/src/controls/QskSimpleListBox.h index 4377a0af2..3a64e5a2d 100644 --- a/src/controls/QskSimpleListBox.h +++ b/src/controls/QskSimpleListBox.h @@ -20,7 +20,7 @@ class QSK_EXPORT QskSimpleListBox : public QskListView using Inherited = QskListView; -public: + public: QskSimpleListBox( QQuickItem* parent = nullptr ); ~QskSimpleListBox() override; @@ -51,15 +51,15 @@ class QSK_EXPORT QskSimpleListBox : public QskListView QVariant valueAt( int row, int col ) const override final; -public Q_SLOTS: + public Q_SLOTS: void setEntries( const QStringList& ); void clear(); -Q_SIGNALS: + Q_SIGNALS: void entriesChanged(); void selectedEntryChanged( const QString& ); -private: + private: void propagateEntries(); class PrivateData; diff --git a/src/controls/QskSkin.cpp b/src/controls/QskSkin.cpp index fc610d187..942901d35 100644 --- a/src/controls/QskSkin.cpp +++ b/src/controls/QskSkin.cpp @@ -5,23 +5,23 @@ #include "QskSkin.h" +#include "QskAnimationHint.h" #include "QskAspect.h" -#include "QskGraphic.h" #include "QskColorFilter.h" +#include "QskGraphic.h" #include "QskGraphicProviderMap.h" -#include "QskAnimationHint.h" -#include "QskStandardSymbol.h" #include "QskSkinHintTable.h" +#include "QskStandardSymbol.h" QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END -#include #include +#include -#include #include +#include #include "QskBox.h" #include "QskBoxSkinlet.h" @@ -78,10 +78,10 @@ namespace { class SkinletData { - public: - SkinletData( const QMetaObject* metaObject ): - metaObject( metaObject ), - skinlet( nullptr ) + public: + SkinletData( const QMetaObject* metaObject ) + : metaObject( metaObject ) + , skinlet( nullptr ) { } @@ -97,9 +97,9 @@ namespace class QskSkin::PrivateData { -public: - PrivateData( QskSkin* skin ): - skin( skin ) + public: + PrivateData( QskSkin* skin ) + : skin( skin ) { } @@ -114,9 +114,9 @@ class QskSkin::PrivateData QskGraphicProviderMap graphicProviders; }; -QskSkin::QskSkin( QObject* parent ): - QObject( parent ), - m_data( new PrivateData( this ) ) +QskSkin::QskSkin( QObject* parent ) + : QObject( parent ) + , m_data( new PrivateData( this ) ) { declareSkinlet< QskControl, QskSkinlet >(); @@ -417,7 +417,7 @@ bool QskSkin::hasGraphicProvider() const const int* QskSkin::dialogButtonLayout( Qt::Orientation orientation ) const { - //auto policy = QPlatformDialogHelper::UnknownLayout; + // auto policy = QPlatformDialogHelper::UnknownLayout; auto policy = QPlatformDialogHelper::WinLayout; if ( const auto theme = QGuiApplicationPrivate::platformTheme() ) diff --git a/src/controls/QskSkin.h b/src/controls/QskSkin.h index 48411378f..75b66646a 100644 --- a/src/controls/QskSkin.h +++ b/src/controls/QskSkin.h @@ -9,12 +9,12 @@ #include "QskGlobal.h" #include "QskAspect.h" -#include #include +#include -#include #include #include +#include class QskControl; class QskSkinnable; @@ -40,7 +40,7 @@ class QSK_EXPORT QskSkin : public QObject using Inherited = QObject; -public: + public: enum SkinFontRole { DefaultFont = 0, @@ -57,7 +57,8 @@ class QSK_EXPORT QskSkin : public QObject QskSkin( QObject* parent = nullptr ); ~QskSkin() override; - template void declareSkinlet(); + template< typename Control, typename Skinlet > + void declareSkinlet(); virtual void resetColors( const QColor& accent ); @@ -118,7 +119,7 @@ class QSK_EXPORT QskSkin : public QObject QskGraphicProvider* graphicProvider( const QString& providerId ) const; bool hasGraphicProvider() const; - virtual const int *dialogButtonLayout( Qt::Orientation ) const; + virtual const int* dialogButtonLayout( Qt::Orientation ) const; QskSkinlet* skinlet( const QskSkinnable* ); @@ -127,7 +128,7 @@ class QSK_EXPORT QskSkin : public QObject const std::unordered_map< int, QFont >& fonts() const; const std::unordered_map< int, QskColorFilter >& graphicFilters() const; -protected: + protected: QskSkinHintTable& skinHintTable(); private: @@ -138,7 +139,7 @@ class QSK_EXPORT QskSkin : public QObject std::unique_ptr< PrivateData > m_data; }; -template +template< typename Control, typename Skinlet > inline void QskSkin::declareSkinlet() { Q_STATIC_ASSERT( ( std::is_base_of< QskControl, Control >::value ) ); diff --git a/src/controls/QskSkinFactory.cpp b/src/controls/QskSkinFactory.cpp index 33976081b..6c903e669 100644 --- a/src/controls/QskSkinFactory.cpp +++ b/src/controls/QskSkinFactory.cpp @@ -5,8 +5,8 @@ #include "QskSkinFactory.h" -QskSkinFactory::QskSkinFactory( QObject* parent ): - QObject( parent ) +QskSkinFactory::QskSkinFactory( QObject* parent ) + : QObject( parent ) { } diff --git a/src/controls/QskSkinFactory.h b/src/controls/QskSkinFactory.h index 5b8258d02..0f957e894 100644 --- a/src/controls/QskSkinFactory.h +++ b/src/controls/QskSkinFactory.h @@ -16,7 +16,7 @@ class QSK_EXPORT QskSkinFactory : public QObject { Q_OBJECT -public: + public: QskSkinFactory( QObject* parent = nullptr ); ~QskSkinFactory() override; diff --git a/src/controls/QskSkinHintTable.cpp b/src/controls/QskSkinHintTable.cpp index b49acc9a2..8080e8903 100644 --- a/src/controls/QskSkinHintTable.cpp +++ b/src/controls/QskSkinHintTable.cpp @@ -43,20 +43,20 @@ inline const QVariant* qskResolvedHint( QskAspect::Aspect aspect, } } -QskSkinHintTable::QskSkinHintTable(): - m_hints( nullptr ), - m_animatorCount( 0 ), - m_hasStates( false ) +QskSkinHintTable::QskSkinHintTable() + : m_hints( nullptr ) + , m_animatorCount( 0 ) + , m_hasStates( false ) { } -QskSkinHintTable::QskSkinHintTable( const QskSkinHintTable& other ): - m_hints( nullptr ), - m_animatorCount( other.m_animatorCount ), - m_hasStates( other.m_hasStates ) +QskSkinHintTable::QskSkinHintTable( const QskSkinHintTable& other ) + : m_hints( nullptr ) + , m_animatorCount( other.m_animatorCount ) + , m_hasStates( other.m_hasStates ) { if ( other.m_hints ) - m_hints = new HintMap( *(other.m_hints) ); + m_hints = new HintMap( *( other.m_hints ) ); } QskSkinHintTable::~QskSkinHintTable() @@ -124,7 +124,7 @@ void QskSkinHintTable::removeHint( QskAspect::Aspect aspect ) { if ( aspect.isAnimator() ) m_animatorCount--; - + if ( m_hints->empty() ) { delete m_hints; diff --git a/src/controls/QskSkinHintTable.h b/src/controls/QskSkinHintTable.h index 33d92ec3a..c0b56a31c 100644 --- a/src/controls/QskSkinHintTable.h +++ b/src/controls/QskSkinHintTable.h @@ -7,22 +7,22 @@ #define QSK_SKIN_HINT_TABLE_H #include "QskGlobal.h" +#include "QskAnimationHint.h" #include "QskAspect.h" -#include "QskMargins.h" -#include "QskGradient.h" -#include "QskBoxShapeMetrics.h" -#include "QskBoxBorderMetrics.h" #include "QskBoxBorderColors.h" -#include "QskAnimationHint.h" +#include "QskBoxBorderMetrics.h" +#include "QskBoxShapeMetrics.h" +#include "QskGradient.h" +#include "QskMargins.h" -#include #include +#include #include class QSK_EXPORT QskSkinHintTable { -public: + public: QskSkinHintTable(); QskSkinHintTable( const QskSkinHintTable& other ); @@ -83,7 +83,7 @@ class QSK_EXPORT QskSkinHintTable QskAspect::Aspect resolvedAnimator( QskAspect::Aspect, QskAnimationHint& ) const; -private: + private: static QVariant invalidHint; typedef std::unordered_map< QskAspect::Aspect, QVariant > HintMap; @@ -148,7 +148,7 @@ inline void QskSkinHintTable::setColor( inline QColor QskSkinHintTable::color( QskAspect::Aspect aspect ) const { - return hint( aspect | QskAspect::Color ).value(); + return hint( aspect | QskAspect::Color ).value< QColor >(); } inline void QskSkinHintTable::setMetric( QskAspect::Aspect aspect, qreal metric ) @@ -201,25 +201,25 @@ inline void QskSkinHintTable::setBoxBorder( using namespace QskAspect; setHint( aspect | Border | Metric, QVariant::fromValue( border ) ); } - + inline QskBoxBorderMetrics QskSkinHintTable::boxBorder( QskAspect::Aspect aspect ) const { using namespace QskAspect; return hint( aspect | Border | Metric ).value< QskBoxBorderMetrics >(); } - + inline void QskSkinHintTable::setBoxBorderColors( QskAspect::Aspect aspect, const QskBoxBorderColors& colors ) -{ +{ using namespace QskAspect; setHint( aspect | Border | Color, QVariant::fromValue( colors ) ); -} - +} + inline QskBoxBorderColors QskSkinHintTable::boxBorderColors( QskAspect::Aspect aspect ) const { using namespace QskAspect; return hint( aspect | Border | Color ).value< QskBoxBorderColors >(); -} +} inline QskAnimationHint QskSkinHintTable::animation( QskAspect::Aspect aspect ) const { @@ -244,9 +244,9 @@ inline void QskSkinHintTable::setFlagHint( QskAspect::Aspect aspect, int flag ) inline void QskSkinHintTable::setAnimation( QskAspect::Aspect aspect, QskAnimationHint animation ) -{ +{ aspect.setAnimator( true ); - setHint( aspect, QVariant::fromValue( animation ) ); + setHint( aspect, QVariant::fromValue( animation ) ); } #endif diff --git a/src/controls/QskSkinManager.cpp b/src/controls/QskSkinManager.cpp index 6ddb8f1e2..29d38b0bb 100644 --- a/src/controls/QskSkinManager.cpp +++ b/src/controls/QskSkinManager.cpp @@ -6,14 +6,14 @@ #include "QskSkinManager.h" #include "QskSkinFactory.h" -#include #include -#include -#include +#include #include +#include #include -#include +#include #include +#include /* We could use QFactoryLoader, but as it is again a "private" class @@ -21,7 +21,13 @@ from the application library path ) we prefer having our own code. */ -namespace { class SkinManager final : public QskSkinManager { }; } +namespace +{ + class SkinManager final : public QskSkinManager + { + }; +} + Q_GLOBAL_STATIC( SkinManager, qskGlobalSkinManager ) static QStringList qskPathList( const char* envName ) @@ -43,9 +49,9 @@ namespace { class FactoryLoader final : public QPluginLoader { - public: - FactoryLoader( QObject* parent = nullptr ): - QPluginLoader( parent ) + public: + FactoryLoader( QObject* parent = nullptr ) + : QPluginLoader( parent ) { } @@ -109,7 +115,7 @@ namespace return m_skinNames; } - private: + private: void setFileName( const QString& ) = delete; QObject* instance() = delete; @@ -119,12 +125,12 @@ namespace class FactoryMap { - private: + private: class Data { - public: - Data(): - loader( nullptr ) + public: + Data() + : loader( nullptr ) { } @@ -148,9 +154,9 @@ namespace QPointer< QskSkinFactory > factory; }; - public: - FactoryMap(): - m_isValid( false ) + public: + FactoryMap() + : m_isValid( false ) { } @@ -208,7 +214,7 @@ namespace return QStringList(); } - void insertFactory( FactoryLoader* loader ) + void insertFactory( FactoryLoader* loader ) { auto& data = m_factoryMap[ loader->factoryId() ]; @@ -270,7 +276,7 @@ namespace return m_factoryMap.contains( factoryId ); } - private: + private: void rebuild() { m_skinMap.clear(); @@ -315,9 +321,9 @@ namespace class QskSkinManager::PrivateData { -public: - PrivateData(): - pluginsRegistered( false ) + public: + PrivateData() + : pluginsRegistered( false ) { } @@ -360,7 +366,7 @@ class QskSkinManager::PrivateData delete loader; } -public: + public: QStringList pluginPaths; FactoryMap factoryMap; @@ -372,11 +378,11 @@ QskSkinManager* QskSkinManager::instance() return qskGlobalSkinManager; } -QskSkinManager::QskSkinManager(): - m_data( new PrivateData() ) +QskSkinManager::QskSkinManager() + : m_data( new PrivateData() ) { - setPluginPaths( qskPathList( "QSK_PLUGIN_PATH" ) - + qskPathList( "QT_PLUGIN_PATH" ) ); + setPluginPaths( qskPathList( "QSK_PLUGIN_PATH" ) + + qskPathList( "QT_PLUGIN_PATH" ) ); } QskSkinManager::~QskSkinManager() diff --git a/src/controls/QskSkinManager.h b/src/controls/QskSkinManager.h index 7acfe8b76..8cb845ff2 100644 --- a/src/controls/QskSkinManager.h +++ b/src/controls/QskSkinManager.h @@ -24,13 +24,13 @@ class QSK_EXPORT QskSkinManager : public QObject { Q_OBJECT -public: + public: static QskSkinManager* instance(); void addPluginPath( const QString& ); void removePluginPath( const QString& ); - void setPluginPaths(const QStringList& paths); + void setPluginPaths( const QStringList& ); QStringList pluginPaths() const; void registerFactory( const QString& factoryId, QskSkinFactory* ); @@ -40,7 +40,7 @@ class QSK_EXPORT QskSkinManager : public QObject QskSkin* createSkin( const QString& skinName ) const; -protected: + protected: QskSkinManager(); ~QskSkinManager() override; diff --git a/src/controls/QskSkinTransition.cpp b/src/controls/QskSkinTransition.cpp index 5ae242d37..be957bac5 100644 --- a/src/controls/QskSkinTransition.cpp +++ b/src/controls/QskSkinTransition.cpp @@ -1,16 +1,15 @@ #include "QskSkinTransition.h" +#include "QskColorFilter.h" #include "QskControl.h" +#include "QskHintAnimator.h" #include "QskSkin.h" #include "QskSkinHintTable.h" -#include "QskColorFilter.h" -#include "QskHintAnimator.h" +#include #include -#include -#include #include +#include #include -#include #include #include @@ -19,7 +18,7 @@ namespace { class UpdateInfo { - public: + public: enum UpdateMode { Polish = 1, @@ -37,14 +36,13 @@ namespace class AnimatorCandidate { - public: + public: AnimatorCandidate() = default; - inline AnimatorCandidate( QskAspect::Aspect aspect, - QVariant from, QVariant to ): - aspect( aspect ), - from( from ), - to( to ) + inline AnimatorCandidate( QskAspect::Aspect aspect, QVariant from, QVariant to ) + : aspect( aspect ) + , from( from ) + , to( to ) { } @@ -81,7 +79,7 @@ static QVector< AnimatorCandidate > qskAnimatorCandidates( if ( type == QskAspect::Flag ) { - switch( aspect.flagPrimitive() ) + switch ( aspect.flagPrimitive() ) { case QskAspect::GraphicRole: { @@ -113,8 +111,7 @@ static QVector< AnimatorCandidate > qskAnimatorCandidates( if ( f1 != f2 ) { candidates += AnimatorCandidate( aspect, - QVariant::fromValue( f1 ), - QVariant::fromValue( f2 ) ); + QVariant::fromValue( f1 ), QVariant::fromValue( f2 ) ); } } } @@ -164,15 +161,15 @@ namespace { Q_OBJECT - public: + public: AnimatorGroup() { } void start() { - m_notifyConnection = QskAnimator::addAdvanceHandler( this, - SLOT( notify( QQuickWindow* ) ) ); + m_notifyConnection = + QskAnimator::addAdvanceHandler( this, SLOT( notify( QQuickWindow* ) ) ); for ( auto& it : m_hintAnimatorMap ) it.second.start(); @@ -251,8 +248,7 @@ namespace } } - void addAnimators( QQuickItem* item, - const QskAnimationHint& animatorHint, + void addAnimators( QQuickItem* item, const QskAnimationHint& animatorHint, const QVector< AnimatorCandidate >& candidates, QskSkin* skin ) { if ( !item->isVisible() ) @@ -279,7 +275,7 @@ namespace addAnimators( child, animatorHint, candidates, skin ); } - private Q_SLOTS: + private Q_SLOTS: void notify( QQuickWindow* window ) { if ( m_updateInfos.empty() ) @@ -308,7 +304,7 @@ namespace } } - private: + private: void addControlAnimators( QskControl* control, const QskAnimationHint& animatorHint, const QVector< AnimatorCandidate >& candidates ) { @@ -425,10 +421,10 @@ namespace Q_GLOBAL_STATIC( AnimatorGroup, qskSkinAnimator ) -QskSkinTransition::QskSkinTransition(): - m_mask( QskSkinTransition::AllTypes ) +QskSkinTransition::QskSkinTransition() + : m_mask( QskSkinTransition::AllTypes ) { - m_skins[0] = m_skins[1] = nullptr; + m_skins[ 0 ] = m_skins[ 1 ] = nullptr; } QskSkinTransition::~QskSkinTransition() @@ -447,22 +443,22 @@ QskSkinTransition::Type QskSkinTransition::mask() const void QskSkinTransition::setSourceSkin( QskSkin* skin ) { - m_skins[0] = skin; + m_skins[ 0 ] = skin; } QskSkin* QskSkinTransition::sourceSkin() const { - return m_skins[0]; + return m_skins[ 0 ]; } void QskSkinTransition::setTargetSkin( QskSkin* skin ) { - m_skins[1] = skin; + m_skins[ 1 ] = skin; } QskSkin* QskSkinTransition::targetSkin() const { - return m_skins[1]; + return m_skins[ 1 ]; } void QskSkinTransition::setAnimation( QskAnimationHint animationHint ) @@ -482,7 +478,7 @@ void QskSkinTransition::updateSkin( QskSkin*, QskSkin* ) void QskSkinTransition::process() { - if ( ( m_skins[0] == nullptr ) || ( m_skins[1] == nullptr ) ) + if ( ( m_skins[ 0 ] == nullptr ) || ( m_skins[ 1 ] == nullptr ) ) { // do nothing return; @@ -493,24 +489,24 @@ void QskSkinTransition::process() if ( ( m_animationHint.duration <= 0 ) || ( m_mask == 0 ) ) { // no animations, we can apply the changes - updateSkin( m_skins[0], m_skins[1] ); + updateSkin( m_skins[ 0 ], m_skins[ 1 ] ); return; } QVector< AnimatorCandidate > candidates; - const auto oldFilters = m_skins[0]->graphicFilters(); + const auto oldFilters = m_skins[ 0 ]->graphicFilters(); { // copy out all hints before updating the skin // - would be good to have Copy on Write here - const auto oldTable = m_skins[0]->hintTable(); + const auto oldTable = m_skins[ 0 ]->hintTable(); // apply the changes - updateSkin( m_skins[0], m_skins[1] ); + updateSkin( m_skins[ 0 ], m_skins[ 1 ] ); candidates = qskAnimatorCandidates( m_mask, oldTable, oldFilters, - m_skins[1]->hintTable(), m_skins[1]->graphicFilters() ); + m_skins[ 1 ]->hintTable(), m_skins[ 1 ]->graphicFilters() ); } if ( !candidates.isEmpty() ) @@ -525,8 +521,8 @@ void QskSkinTransition::process() if ( doGraphicFilter ) { qskSkinAnimator->addGraphicFilterAnimators( - quickWindow, m_animationHint, - oldFilters, m_skins[1]->graphicFilters() ); + quickWindow, m_animationHint, oldFilters, + m_skins[ 1 ]->graphicFilters() ); doGraphicFilter = false; } @@ -537,7 +533,7 @@ void QskSkinTransition::process() */ qskSkinAnimator->addAnimators( quickWindow->contentItem(), - m_animationHint, candidates, m_skins[1] ); + m_animationHint, candidates, m_skins[ 1 ] ); } } diff --git a/src/controls/QskSkinTransition.h b/src/controls/QskSkinTransition.h index 775c03789..ee3fd84c8 100644 --- a/src/controls/QskSkinTransition.h +++ b/src/controls/QskSkinTransition.h @@ -2,15 +2,15 @@ #define QSK_SKIN_TRANSITION_H #include "QskGlobal.h" -#include "QskAspect.h" #include "QskAnimationHint.h" +#include "QskAspect.h" class QskSkin; class QVariant; class QSK_EXPORT QskSkinTransition { -public: + public: enum Type { Color = 1, @@ -40,11 +40,11 @@ class QSK_EXPORT QskSkinTransition static QVariant animatedHint( QskAspect::Aspect ); static QVariant animatedGraphicFilter( int graphicRole ); -protected: + protected: virtual void updateSkin( QskSkin*, QskSkin* ); -private: - QskSkin* m_skins[2]; + private: + QskSkin* m_skins[ 2 ]; QskAnimationHint m_animationHint; Type m_mask : 2; }; diff --git a/src/controls/QskSkinlet.cpp b/src/controls/QskSkinlet.cpp index f87ddb547..128800bcb 100644 --- a/src/controls/QskSkinlet.cpp +++ b/src/controls/QskSkinlet.cpp @@ -6,22 +6,22 @@ #include "QskSkinlet.h" #include "QskAspect.h" -#include "QskControl.h" -#include "QskBoxShapeMetrics.h" -#include "QskBoxBorderMetrics.h" #include "QskBoxBorderColors.h" -#include "QskGradient.h" -#include "QskBoxNode.h" +#include "QskBoxBorderMetrics.h" #include "QskBoxClipNode.h" -#include "QskTextNode.h" -#include "QskTextColors.h" -#include "QskTextOptions.h" +#include "QskBoxNode.h" +#include "QskBoxShapeMetrics.h" +#include "QskControl.h" +#include "QskFunctions.h" +#include "QskGradient.h" #include "QskGraphicNode.h" #include "QskGraphicTextureFactory.h" -#include "QskFunctions.h" +#include "QskTextColors.h" +#include "QskTextNode.h" +#include "QskTextOptions.h" -#include #include +#include #include static const int qskBackgroundRole = 254; @@ -48,7 +48,7 @@ static inline QSGNode* qskFindNodeByFlag( QSGNode* parent, int nodeRole ) auto node = parent->firstChild(); while ( node ) { - if ( qskRole( node ) == nodeRole) + if ( qskRole( node ) == nodeRole ) return node; node = node->nextSibling(); @@ -65,7 +65,7 @@ static qreal qskDevicePixelRatio( const QskSkinnable* skinnable ) return window->effectiveDevicePixelRatio(); } - return qGuiApp->devicePixelRatio(); + return qGuiApp->devicePixelRatio(); } static inline QSGNode* qskUpdateGraphicNode( @@ -130,10 +130,10 @@ static inline QskTextColors qskTextColors( class QskSkinlet::PrivateData { -public: - PrivateData( QskSkin* skin ): - skin( skin ), - ownedBySkinnable( false ) + public: + PrivateData( QskSkin* skin ) + : skin( skin ) + , ownedBySkinnable( false ) { } @@ -143,8 +143,8 @@ class QskSkinlet::PrivateData bool ownedBySkinnable : 1; }; -QskSkinlet::QskSkinlet( QskSkin* skin ): - m_data( new PrivateData( skin ) ) +QskSkinlet::QskSkinlet( QskSkin* skin ) + : m_data( new PrivateData( skin ) ) { } @@ -212,7 +212,7 @@ void QskSkinlet::updateNode( QskSkinnable* skinnable, QSGNode* parentNode ) cons for ( int i = 0; i < m_data->nodeRoles.size(); i++ ) { - const auto nodeRole = m_data->nodeRoles[i]; + const auto nodeRole = m_data->nodeRoles[ i ]; Q_ASSERT( nodeRole <= 245 ); // reserving 10 roles @@ -288,7 +288,7 @@ void QskSkinlet::insertRemoveNodes( QSGNode* parentNode, { qskSetRole( nodeRole, newNode ); - switch( nodeRole ) + switch ( nodeRole ) { case qskBackgroundRole: { @@ -488,7 +488,7 @@ QSGNode* QskSkinlet::updateTextNode( break; case QskTextOptions::VerticalFit: - font.setPixelSize( static_cast( rect.height() * 0.5 ) ); + font.setPixelSize( static_cast< int >( rect.height() * 0.5 ) ); break; case QskTextOptions::Fit: @@ -511,8 +511,8 @@ QSGNode* QskSkinlet::updateTextNode( const auto alignment = skinnable->flagHint< Qt::Alignment >( QskAspect::Alignment | subControl, Qt::AlignLeft ); - return updateTextNode( skinnable, node, rect, alignment, - text, textOptions, subControl ); + return updateTextNode( skinnable, node, + rect, alignment, text, textOptions, subControl ); } QSGNode* QskSkinlet::updateGraphicNode( diff --git a/src/controls/QskSkinlet.h b/src/controls/QskSkinlet.h index 943edea84..fae43f24a 100644 --- a/src/controls/QskSkinlet.h +++ b/src/controls/QskSkinlet.h @@ -32,7 +32,7 @@ class QSK_EXPORT QskSkinlet { Q_GADGET -public: + public: Q_INVOKABLE QskSkinlet( QskSkin* = nullptr ); virtual ~QskSkinlet(); @@ -47,7 +47,7 @@ class QSK_EXPORT QskSkinlet bool isOwnedBySkinnable() const; static void setNodeRole( QSGNode* node, quint8 nodeRole ); - static quint8 nodeRole( const QSGNode* node); + static quint8 nodeRole( const QSGNode* node ); static QSGNode* findNodeByRole( QSGNode* parent, quint8 nodeRole ); @@ -70,7 +70,7 @@ class QSK_EXPORT QskSkinlet static QSGNode* updateBoxClipNode( const QskSkinnable*, QSGNode*, const QRectF&, QskAspect::Subcontrol ); -protected: + protected: void setNodeRoles( const QVector< quint8 >& ); void appendNodeRoles( const QVector< quint8 >& ); @@ -98,7 +98,7 @@ class QSK_EXPORT QskSkinlet void insertRemoveNodes( QSGNode* parentNode, QSGNode* oldNode, QSGNode* newNode, quint8 nodeRole ) const; -private: + private: void insertNodeSorted( QSGNode* node, QSGNode* parentNode ) const; class PrivateData; diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 263fc9dd7..76b87e2a1 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -5,17 +5,17 @@ #include "QskSkinnable.h" +#include "QskAnimationHint.h" #include "QskAspect.h" +#include "QskColorFilter.h" +#include "QskControl.h" +#include "QskHintAnimator.h" +#include "QskMargins.h" #include "QskSetup.h" #include "QskSkin.h" #include "QskSkinHintTable.h" -#include "QskSkinlet.h" -#include "QskAnimationHint.h" -#include "QskMargins.h" -#include "QskHintAnimator.h" -#include "QskControl.h" -#include "QskColorFilter.h" #include "QskSkinTransition.h" +#include "QskSkinlet.h" #include @@ -25,7 +25,7 @@ static inline bool qskIsControl( const QskSkinnable* skinnable ) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) return skinnable->metaObject()->inherits( &QskControl::staticMetaObject ); #else for ( auto mo = skinnable->metaObject(); @@ -102,11 +102,11 @@ static inline bool qskCompareResolvedStates( class QskSkinnable::PrivateData { -public: - PrivateData(): - skinlet( nullptr ), - skinState( QskAspect::NoState ), - hasLocalSkinlet( false ) + public: + PrivateData() + : skinlet( nullptr ) + , skinState( QskAspect::NoState ) + , hasLocalSkinlet( false ) { } @@ -128,8 +128,8 @@ class QskSkinnable::PrivateData bool hasLocalSkinlet : 1; }; -QskSkinnable::QskSkinnable(): - m_data( new PrivateData() ) +QskSkinnable::QskSkinnable() + : m_data( new PrivateData() ) { } @@ -371,7 +371,7 @@ void QskSkinnable::setAnimation( } QskAnimationHint QskSkinnable::animation( - QskAspect::Aspect aspect, QskSkinHintStatus* status ) const + QskAspect::Aspect aspect, QskSkinHintStatus* status ) const { aspect.setAnimator( true ); return effectiveHint( aspect, status ).value< QskAnimationHint >(); @@ -446,7 +446,7 @@ QskSkinHintStatus QskSkinnable::hintStatus( QskAspect::Aspect aspect ) const { QskSkinHintStatus status; - (void)effectiveHint( aspect, &status ); + ( void ) effectiveHint( aspect, &status ); return status; } @@ -469,8 +469,8 @@ QVariant QskSkinnable::animatedValue( if ( !v.isValid() ) { - if ( QskSkinTransition::isRunning() - && !m_data->hintTable.hasHint( aspect ) ) + if ( QskSkinTransition::isRunning() && + !m_data->hintTable.hasHint( aspect ) ) { /* Next we check for values from the skin. Those @@ -596,13 +596,13 @@ const char* QskSkinnable::skinStateAsPrintable( QskAspect::State state ) const qskDebugState( debug, metaObject(), state ); // we should find a better way - static QByteArray bytes[10]; + static QByteArray bytes[ 10 ]; static int counter = 0; counter = ( counter + 1 ) % 10; - bytes[counter] = tmp.toUtf8(); - return bytes[counter].constData(); + bytes[ counter ] = tmp.toUtf8(); + return bytes[ counter ].constData(); } static inline QMarginsF qskEffectivePadding( const QskSkinnable* skinnable, @@ -614,7 +614,6 @@ static inline QMarginsF qskEffectivePadding( const QskSkinnable* skinnable, const auto shape = skinnable->boxShapeHint( aspect | Shape ).toAbsolute( size ); const auto borderMetrics = skinnable->boxBorderMetricsHint( aspect | Border ); - const qreal left = qMax( shape.radius( TopLeftCorner ).width(), shape.radius( BottomLeftCorner ).width() ); @@ -720,7 +719,7 @@ void QskSkinnable::startTransition( QskAspect::Aspect aspect, return; } - if( aspect.flagPrimitive() == QskAspect::GraphicRole ) + if ( aspect.flagPrimitive() == QskAspect::GraphicRole ) { const auto skin = effectiveSkin(); @@ -745,7 +744,8 @@ void QskSkinnable::startTransition( QskAspect::Aspect aspect, void QskSkinnable::setSkinStateFlag( QskAspect::State state, bool on ) { - const auto newState = on ? ( m_data->skinState | state ) + const auto newState = on + ? ( m_data->skinState | state ) : ( m_data->skinState & ~state ); if ( m_data->skinState == newState ) @@ -768,7 +768,7 @@ void QskSkinnable::setSkinStateFlag( QskAspect::State state, bool on ) { using namespace QskAspect; - Aspect aspect = subControl | placement;; + Aspect aspect = subControl | placement; const auto& skinTable = effectiveSkin()->hintTable(); @@ -878,4 +878,3 @@ void QskSkinnable::debug( QskAspect::State state ) const { qskDebugState( qDebug(), metaObject(), state ); } - diff --git a/src/controls/QskSkinnable.h b/src/controls/QskSkinnable.h index 999a18ddb..9d2992023 100644 --- a/src/controls/QskSkinnable.h +++ b/src/controls/QskSkinnable.h @@ -37,7 +37,7 @@ class QskSkinHintTable; class QSK_EXPORT QskSkinHintStatus { -public: + public: enum Source { NoSource = 0, @@ -47,8 +47,8 @@ class QSK_EXPORT QskSkinHintStatus Animator }; - QskSkinHintStatus(): - source( NoSource ) + QskSkinHintStatus() + : source( NoSource ) { } @@ -63,7 +63,7 @@ class QSK_EXPORT QskSkinHintStatus class QSK_EXPORT QskSkinnable { -public: + public: QskSkinnable(); virtual ~QskSkinnable(); @@ -90,7 +90,8 @@ class QSK_EXPORT QskSkinnable QskBoxShapeMetrics boxShapeHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const; void setBoxBorderMetricsHint( QskAspect::Aspect, const QskBoxBorderMetrics& ); - QskBoxBorderMetrics boxBorderMetricsHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const; + QskBoxBorderMetrics boxBorderMetricsHint( + QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const; void setBoxBorderColorsHint( QskAspect::Aspect, const QskBoxBorderColors& ); QskBoxBorderColors boxBorderColorsHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const; @@ -154,14 +155,14 @@ class QSK_EXPORT QskSkinnable void debug( QDebug, QskAspect::Aspect ) const; void debug( QDebug, QskAspect::State ) const; -protected: + protected: void setSkinStateFlag( QskAspect::State, bool = true ); virtual void updateNode( QSGNode* ); QskSkinHintTable& hintTable(); const QskSkinHintTable& hintTable() const; -private: + private: QVariant animatedValue( QskAspect::Aspect, QskSkinHintStatus* ) const; const QVariant& storedHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const; diff --git a/src/controls/QskSlider.cpp b/src/controls/QskSlider.cpp index 5824207be..f75d3da56 100644 --- a/src/controls/QskSlider.cpp +++ b/src/controls/QskSlider.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskSlider.h" -#include "QskAspect.h" #include "QskAnimationHint.h" +#include "QskAspect.h" QSK_SUBCONTROL( QskSlider, Panel ) QSK_SUBCONTROL( QskSlider, Groove ) @@ -19,11 +19,11 @@ QSK_STATE( QskSlider, Maximum, QskAspect::FirstSystemState << 3 ) class QskSlider::PrivateData { -public: - PrivateData( Qt::Orientation orientation ): - pressedValue( 0 ), - tracking( true ), - orientation( orientation ) + public: + PrivateData( Qt::Orientation orientation ) + : pressedValue( 0 ) + , tracking( true ) + , orientation( orientation ) { } @@ -33,17 +33,17 @@ class QskSlider::PrivateData Qt::Orientation orientation : 2; }; -QskSlider::QskSlider( QQuickItem* parent ): - QskSlider( Qt::Horizontal, parent ) +QskSlider::QskSlider( QQuickItem* parent ) + : QskSlider( Qt::Horizontal, parent ) { } -QskSlider::QskSlider( Qt::Orientation orientation, QQuickItem* parent ): - Inherited ( parent ), - m_data( new PrivateData( orientation ) ) +QskSlider::QskSlider( Qt::Orientation orientation, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( orientation ) ) { setAcceptHoverEvents( true ); - setFocusPolicy(Qt::StrongFocus); + setFocusPolicy( Qt::StrongFocus ); if ( orientation == Qt::Horizontal ) initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed ); @@ -53,10 +53,10 @@ QskSlider::QskSlider( Qt::Orientation orientation, QQuickItem* parent ): setMetric( QskSlider::Handle | QskAspect::Position, position() ); connect( this, &QskRangeControl::rangeChanged, - [this] ( qreal ) { updatePosition(); } ); + [ this ]( qreal ) { updatePosition(); } ); connect( this, &QskRangeControl::valueChanged, - [this] ( qreal ) { updatePosition(); } ); + [ this ]( qreal ) { updatePosition(); } ); } QskSlider::~QskSlider() diff --git a/src/controls/QskSlider.h b/src/controls/QskSlider.h index 466105fb2..3f6714683 100644 --- a/src/controls/QskSlider.h +++ b/src/controls/QskSlider.h @@ -24,7 +24,7 @@ class QSK_EXPORT QskSlider : public QskRangeControl using Inherited = QskRangeControl; -public: + public: QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Handle ) QSK_STATES( Pressed, Minimum, Maximum ) @@ -44,12 +44,12 @@ class QSK_EXPORT QskSlider : public QskRangeControl QSizeF contentsSizeHint() const override; QskAspect::Placement effectivePlacement() const override; -Q_SIGNALS: + Q_SIGNALS: void pressedChanged( bool ); void orientationChanged( Qt::Orientation ); void trackingChanged( bool ); -protected: + protected: void mousePressEvent( QMouseEvent* e ) override; void mouseMoveEvent( QMouseEvent* e ) override; void mouseReleaseEvent( QMouseEvent* e ) override; @@ -57,7 +57,7 @@ class QSK_EXPORT QskSlider : public QskRangeControl QSizeF handleSize() const; QRectF handleRect() const; -private: + private: void updatePosition(); class PrivateData; diff --git a/src/controls/QskSliderSkinlet.cpp b/src/controls/QskSliderSkinlet.cpp index 4eda17a88..efc8c7b81 100644 --- a/src/controls/QskSliderSkinlet.cpp +++ b/src/controls/QskSliderSkinlet.cpp @@ -4,20 +4,20 @@ *****************************************************************************/ #include "QskSliderSkinlet.h" -#include "QskSlider.h" #include "QskAspect.h" #include "QskBoxBorderMetrics.h" #include "QskFunctions.h" +#include "QskSlider.h" static QMarginsF qskPadding( const QskSlider* slider, QskAspect::Subcontrol subControl ) { - return slider->marginsHint( subControl | QskAspect::Padding ) - + slider->boxBorderMetricsHint( subControl ).widths(); + return slider->marginsHint( subControl | QskAspect::Padding ) + + slider->boxBorderMetricsHint( subControl ).widths(); } -QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin ): - Inherited( skin ) +QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole, GrooveRole, FillRole, HandleRole } ); } @@ -62,7 +62,7 @@ QSGNode* QskSliderSkinlet::updateSubNode( { const auto slider = static_cast< const QskSlider* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { @@ -115,8 +115,8 @@ QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const if ( size > 0 && size < r.height() ) { - const Qt::Alignment alignment = - slider->flagHint( subControl | Alignment ); + const Qt::Alignment alignment = + slider->flagHint< Qt::Alignment >( subControl | Alignment ); if ( slider->orientation() == Qt::Horizontal ) r = qskAlignedRectF( r, r.width(), size, alignment & Qt::AlignVertical_Mask ); @@ -127,8 +127,8 @@ QRectF QskSliderSkinlet::panelRect( const QskSlider* slider ) const return r; } -QRectF QskSliderSkinlet::innerRect( const QskSlider* slider, - QskAspect::Subcontrol subControl ) const +QRectF QskSliderSkinlet::innerRect( + const QskSlider* slider, QskAspect::Subcontrol subControl ) const { using namespace QskAspect; diff --git a/src/controls/QskSliderSkinlet.h b/src/controls/QskSliderSkinlet.h index b828857f4..48abd01f5 100644 --- a/src/controls/QskSliderSkinlet.h +++ b/src/controls/QskSliderSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskSliderSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole, @@ -32,11 +32,11 @@ class QSK_EXPORT QskSliderSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QRectF panelRect( const QskSlider* ) const; QRectF grooveRect( const QskSlider* ) const; QRectF fillRect( const QskSlider* ) const; diff --git a/src/controls/QskStatusIndicator.cpp b/src/controls/QskStatusIndicator.cpp index 8b6a82b9e..24eb7839a 100644 --- a/src/controls/QskStatusIndicator.cpp +++ b/src/controls/QskStatusIndicator.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskStatusIndicator.h" -#include "QskGraphic.h" #include "QskColorFilter.h" +#include "QskGraphic.h" #include "QskGraphicProvider.h" #include @@ -16,16 +16,16 @@ namespace { class StatusData { - public: - StatusData( const QskGraphic& graphic ): - graphic( graphic ), - isDirty( false ) + public: + StatusData( const QskGraphic& graphic ) + : graphic( graphic ) + , isDirty( false ) { } - StatusData( const QUrl& url ): - source( url ), - isDirty( !url.isEmpty() ) + StatusData( const QUrl& url ) + : source( url ) + , isDirty( !url.isEmpty() ) { } @@ -46,9 +46,9 @@ namespace class QskStatusIndicator::PrivateData { -public: - PrivateData(): - currentStatus( -1 ) + public: + PrivateData() + : currentStatus( -1 ) { } @@ -56,9 +56,9 @@ class QskStatusIndicator::PrivateData QMap< int, StatusData > map; }; -QskStatusIndicator::QskStatusIndicator( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskStatusIndicator::QskStatusIndicator( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { initSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Expanding ); } @@ -171,7 +171,7 @@ qreal QskStatusIndicator::sizeConstraint( qreal value = 0.0; - for ( auto &statusData : m_data->map ) + for ( auto& statusData : m_data->map ) { statusData.ensureGraphic( this ); @@ -199,7 +199,7 @@ QSizeF QskStatusIndicator::contentsSizeHint() const { QSizeF sz( 0, 0 ); - for ( auto &statusData : m_data->map ) + for ( auto& statusData : m_data->map ) { statusData.ensureGraphic( this ); @@ -248,7 +248,7 @@ void QskStatusIndicator::changeEvent( QEvent* event ) { if ( event->type() == QEvent::StyleChange ) { - for ( auto &statusData : m_data->map ) + for ( auto& statusData : m_data->map ) { if ( !statusData.source.isEmpty() ) { diff --git a/src/controls/QskStatusIndicator.h b/src/controls/QskStatusIndicator.h index 1bba08d15..d28dedb47 100644 --- a/src/controls/QskStatusIndicator.h +++ b/src/controls/QskStatusIndicator.h @@ -21,7 +21,7 @@ class QSK_EXPORT QskStatusIndicator : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Graphic ) QskStatusIndicator( QQuickItem* parent = nullptr ); @@ -44,17 +44,17 @@ class QSK_EXPORT QskStatusIndicator : public QskControl int status() const; bool hasStatus( int status ) const; -public Q_SLOTS: + public Q_SLOTS: void setStatus( int status ); -Q_SIGNALS: + Q_SIGNALS: void statusChanged( int status ); -protected: + protected: void changeEvent( QEvent* ) override; void updateLayout() override; -private: + private: qreal sizeConstraint( Qt::Orientation, qreal ) const; class PrivateData; diff --git a/src/controls/QskStatusIndicatorSkinlet.cpp b/src/controls/QskStatusIndicatorSkinlet.cpp index 01aebbd5b..fc312ea65 100644 --- a/src/controls/QskStatusIndicatorSkinlet.cpp +++ b/src/controls/QskStatusIndicatorSkinlet.cpp @@ -4,14 +4,14 @@ *****************************************************************************/ #include "QskStatusIndicatorSkinlet.h" -#include "QskStatusIndicator.h" -#include "QskGraphic.h" -#include "QskColorFilter.h" #include "QskAspect.h" +#include "QskColorFilter.h" #include "QskFunctions.h" +#include "QskGraphic.h" +#include "QskStatusIndicator.h" -QskStatusIndicatorSkinlet::QskStatusIndicatorSkinlet( QskSkin* skin ): - Inherited( skin ) +QskStatusIndicatorSkinlet::QskStatusIndicatorSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { GraphicRole } ); } @@ -36,7 +36,7 @@ QSGNode* QskStatusIndicatorSkinlet::updateSubNode( { const auto indicator = static_cast< const QskStatusIndicator* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case GraphicRole: { @@ -61,7 +61,7 @@ QRect QskStatusIndicatorSkinlet::graphicRect( sz.scale( graphicRect.size(), Qt::KeepAspectRatio ); return qskAlignedRect( graphicRect, - ( int )sz.width(), ( int )sz.height(), Qt::AlignCenter ); + ( int ) sz.width(), ( int ) sz.height(), Qt::AlignCenter ); } QSGNode* QskStatusIndicatorSkinlet::updateGraphicNode( diff --git a/src/controls/QskStatusIndicatorSkinlet.h b/src/controls/QskStatusIndicatorSkinlet.h index 8fba91fb0..2b0120249 100644 --- a/src/controls/QskStatusIndicatorSkinlet.h +++ b/src/controls/QskStatusIndicatorSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskStatusIndicatorSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { GraphicRole @@ -29,14 +29,13 @@ class QSK_EXPORT QskStatusIndicatorSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: - QSGNode* updateSubNode( - const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; + protected: + QSGNode* updateSubNode( const QskSkinnable*, + quint8 nodeRole, QSGNode* ) const override; -private: + private: QRect graphicRect( const QskStatusIndicator* ) const; QSGNode* updateGraphicNode( const QskStatusIndicator*, QSGNode* ) const; }; #endif - diff --git a/src/controls/QskSubWindow.cpp b/src/controls/QskSubWindow.cpp index 66b8fac0a..d7fa3a8dc 100644 --- a/src/controls/QskSubWindow.cpp +++ b/src/controls/QskSubWindow.cpp @@ -4,16 +4,16 @@ *****************************************************************************/ #include "QskSubWindow.h" -#include "QskQuick.h" #include "QskAspect.h" #include "QskFunctions.h" +#include "QskQuick.h" QSK_SUBCONTROL( QskSubWindow, Panel ) QSK_SUBCONTROL( QskSubWindow, TitleBar ) class QskSubWindow::PrivateData { -public: + public: PrivateData() { // should be available from the platform somehow. TODO ... @@ -26,9 +26,9 @@ class QskSubWindow::PrivateData QString title; }; -QskSubWindow::QskSubWindow( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskSubWindow::QskSubWindow( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setMargins( 0 ); initSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding ); @@ -174,7 +174,7 @@ void QskSubWindow::itemChange( QQuickItem::ItemChange change, { Inherited::itemChange( change, value ); - switch( change ) + switch ( change ) { case QQuickItem::ItemChildAddedChange: case QQuickItem::ItemChildRemovedChange: diff --git a/src/controls/QskSubWindow.h b/src/controls/QskSubWindow.h index 970b99af0..f18ce4236 100644 --- a/src/controls/QskSubWindow.h +++ b/src/controls/QskSubWindow.h @@ -16,13 +16,15 @@ class QSK_EXPORT QskSubWindow : public QskPopup Q_PROPERTY( bool decorated READ isDecorated WRITE setDecorated NOTIFY decoratedChanged ) - Q_PROPERTY( QString title READ title WRITE setTitle NOTIFY titleChanged ) + Q_PROPERTY( QString title READ title + WRITE setTitle NOTIFY titleChanged ) + Q_PROPERTY( WindowButtons windowButtons READ windowButtons WRITE setWindowButtons NOTIFY windowButtonsChanged ) using Inherited = QskPopup; -public: + public: enum WindowButton { MinimizeButton = 0x1, @@ -55,18 +57,18 @@ class QSK_EXPORT QskSubWindow : public QskPopup QSizeF contentsSizeHint() const override; QRectF layoutRect() const override; -Q_SIGNALS: + Q_SIGNALS: void titleChanged(); void decoratedChanged(); void windowButtonsChanged(); -protected: + protected: bool event( QEvent* ) override; void itemChange( QQuickItem::ItemChange, const QQuickItem::ItemChangeData& ) override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskSubWindowArea.cpp b/src/controls/QskSubWindowArea.cpp index 9420c0f95..5b226724e 100644 --- a/src/controls/QskSubWindowArea.cpp +++ b/src/controls/QskSubWindowArea.cpp @@ -4,9 +4,9 @@ *****************************************************************************/ #include "QskSubWindowArea.h" -#include "QskSubWindow.h" -#include "QskFunctions.h" #include "QskEvent.h" +#include "QskFunctions.h" +#include "QskSubWindow.h" #include @@ -78,10 +78,10 @@ static void qskDragWindow( const QPointF& off, Qt::Edges edges, QskSubWindow* wi class QskSubWindowArea::PrivateData { -public: - PrivateData(): - isDraggableByHeaderOnly( false ), - isDragging( false ) + public: + PrivateData() + : isDraggableByHeaderOnly( false ) + , isDragging( false ) { } @@ -93,12 +93,12 @@ class QskSubWindowArea::PrivateData QPoint mousePos; }; -QskSubWindowArea::QskSubWindowArea( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskSubWindowArea::QskSubWindowArea( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setMargins( 0 ); - //setAcceptedMouseButtons( Qt::AllButtons ); + // setAcceptedMouseButtons( Qt::AllButtons ); } QskSubWindowArea::~QskSubWindowArea() @@ -115,12 +115,12 @@ void QskSubWindowArea::geometryChangeEvent( QskGeometryChangeEvent* event ) Inherited::geometryChangeEvent( event ); } -void QskSubWindowArea::itemChange( QQuickItem::ItemChange change, - const QQuickItem::ItemChangeData& value ) +void QskSubWindowArea::itemChange( + QQuickItem::ItemChange change, const QQuickItem::ItemChangeData& value ) { Inherited::itemChange( change, value ); - switch( change ) + switch ( change ) { case QQuickItem::ItemChildAddedChange: { @@ -142,7 +142,6 @@ void QskSubWindowArea::itemChange( QQuickItem::ItemChange change, { break; } - } } @@ -189,12 +188,12 @@ bool QskSubWindowArea::mouseEventFilter( QskSubWindow* window, const QMouseEvent const QRectF cr = window->contentsRect(); - switch( event->type() ) + switch ( event->type() ) { case QEvent::MouseButtonPress: { - if ( !( cr.contains( event->localPos() ) - && event->button() == Qt::LeftButton ) ) + if ( !( cr.contains( event->localPos() ) && + event->button() == Qt::LeftButton ) ) { return false; } diff --git a/src/controls/QskSubWindowArea.h b/src/controls/QskSubWindowArea.h index df560d0ef..96fa7848b 100644 --- a/src/controls/QskSubWindowArea.h +++ b/src/controls/QskSubWindowArea.h @@ -18,13 +18,13 @@ class QSK_EXPORT QskSubWindowArea : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel ) QskSubWindowArea( QQuickItem* parent = nullptr ); ~QskSubWindowArea() override; -protected: + protected: void geometryChangeEvent( QskGeometryChangeEvent* ) override; bool eventFilter( QObject*, QEvent* ) override; @@ -32,7 +32,7 @@ class QSK_EXPORT QskSubWindowArea : public QskControl void itemChange( ItemChange, const ItemChangeData& ) override; -private: + private: virtual void setDragging( QskSubWindow*, bool ); virtual void setActive( QskSubWindow*, bool ); diff --git a/src/controls/QskSubWindowAreaSkinlet.cpp b/src/controls/QskSubWindowAreaSkinlet.cpp index b7ac20f03..9161baa2f 100644 --- a/src/controls/QskSubWindowAreaSkinlet.cpp +++ b/src/controls/QskSubWindowAreaSkinlet.cpp @@ -6,8 +6,8 @@ #include "QskSubWindowAreaSkinlet.h" #include "QskSubWindowArea.h" -QskSubWindowAreaSkinlet::QskSubWindowAreaSkinlet( QskSkin* skin ): - Inherited( skin ) +QskSubWindowAreaSkinlet::QskSubWindowAreaSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole } ); } @@ -16,19 +16,19 @@ QskSubWindowAreaSkinlet::~QskSubWindowAreaSkinlet() = default; QRectF QskSubWindowAreaSkinlet::subControlRect( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const -{ +{ const auto area = static_cast< const QskSubWindowArea* >( skinnable ); - + if ( subControl == QskSubWindowArea::Panel ) return area->contentsRect(); - + return Inherited::subControlRect( skinnable, subControl ); } QSGNode* QskSubWindowAreaSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: return updateBoxNode( skinnable, node, QskSubWindowArea::Panel ); diff --git a/src/controls/QskSubWindowAreaSkinlet.h b/src/controls/QskSubWindowAreaSkinlet.h index 24f7382db..890be6e2a 100644 --- a/src/controls/QskSubWindowAreaSkinlet.h +++ b/src/controls/QskSubWindowAreaSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskSubWindowAreaSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole @@ -29,13 +29,12 @@ class QSK_EXPORT QskSubWindowAreaSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QSGNode* updatePanelNode( const QskSubWindowArea*, QSGNode* ) const; }; #endif - diff --git a/src/controls/QskSubWindowSkinlet.cpp b/src/controls/QskSubWindowSkinlet.cpp index a610811f2..a9ba83935 100644 --- a/src/controls/QskSubWindowSkinlet.cpp +++ b/src/controls/QskSubWindowSkinlet.cpp @@ -4,14 +4,14 @@ *****************************************************************************/ #include "QskSubWindowSkinlet.h" -#include "QskSubWindow.h" #include "QskAspect.h" #include "QskBoxBorderMetrics.h" +#include "QskSubWindow.h" #include -QskSubWindowSkinlet::QskSubWindowSkinlet( QskSkin* skin ): - Inherited( skin ) +QskSubWindowSkinlet::QskSubWindowSkinlet( QskSkin* skin ) + : Inherited( skin ) { appendNodeRoles( { PanelRole, TitleBarRole } ); } @@ -36,12 +36,12 @@ QRectF QskSubWindowSkinlet::subControlRect( return Inherited::subControlRect( skinnable, subControl ); } -QSGNode* QskSubWindowSkinlet::updateSubNode( const QskSkinnable* skinnable, - quint8 nodeRole, QSGNode* node ) const +QSGNode* QskSubWindowSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { const auto subWindow = static_cast< const QskSubWindow* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: return updateBoxNode( subWindow, node, QskSubWindow::Panel ); @@ -76,7 +76,7 @@ qreal QskSubWindowSkinlet::titleBarHeight( const QskSubWindow* subWindow ) const const qreal height = fm.height() + margins.top() + margins.bottom(); const qreal minHeight = subWindow->metric( QskSubWindow::TitleBar | MinimumHeight ); - return qMax( height, minHeight); + return qMax( height, minHeight ); } #include "moc_QskSubWindowSkinlet.cpp" diff --git a/src/controls/QskSubWindowSkinlet.h b/src/controls/QskSubWindowSkinlet.h index 06ac5e115..7f1656490 100644 --- a/src/controls/QskSubWindowSkinlet.h +++ b/src/controls/QskSubWindowSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskSubWindowSkinlet : public QskPopupSkinlet using Inherited = QskPopupSkinlet; -public: + public: enum NodeRole { PanelRole = QskPopupSkinlet::OverlayRole + 1, @@ -27,18 +27,16 @@ class QSK_EXPORT QskSubWindowSkinlet : public QskPopupSkinlet Q_INVOKABLE QskSubWindowSkinlet( QskSkin* = nullptr ); ~QskSubWindowSkinlet() override; - QRectF subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: qreal titleBarHeight( const QskSubWindow* ) const; QRectF titleBarRect( const QskSubWindow* ) const; - }; #endif - diff --git a/src/controls/QskTabBar.cpp b/src/controls/QskTabBar.cpp index 8c4fa68aa..c600e0333 100644 --- a/src/controls/QskTabBar.cpp +++ b/src/controls/QskTabBar.cpp @@ -4,19 +4,19 @@ *****************************************************************************/ #include "QskTabBar.h" +#include "QskAspect.h" #include "QskLinearBox.h" #include "QskTabButton.h" #include "QskTextOptions.h" -#include "QskAspect.h" QSK_SUBCONTROL( QskTabBar, Panel ) class QskTabBar::PrivateData { -public: - PrivateData(): - currentIndex( -1 ), - layoutBox( nullptr ) + public: + PrivateData() + : currentIndex( -1 ) + , layoutBox( nullptr ) { } @@ -25,14 +25,14 @@ class QskTabBar::PrivateData QskLinearBox* layoutBox; }; -QskTabBar::QskTabBar( QQuickItem* parent ): - QskTabBar( Qt::Horizontal, parent ) +QskTabBar::QskTabBar( QQuickItem* parent ) + : QskTabBar( Qt::Horizontal, parent ) { } -QskTabBar::QskTabBar( Qt::Orientation orientation, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskTabBar::QskTabBar( Qt::Orientation orientation, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { m_data->layoutBox = new QskLinearBox( orientation, this ); m_data->layoutBox->setObjectName( QStringLiteral( "QskTabBarLayoutBox" ) ); diff --git a/src/controls/QskTabBar.h b/src/controls/QskTabBar.h index e0539b95a..573f2c950 100644 --- a/src/controls/QskTabBar.h +++ b/src/controls/QskTabBar.h @@ -29,7 +29,7 @@ class QSK_EXPORT QskTabBar : public QskBox using Inherited = QskBox; -public: + public: QSK_SUBCONTROLS( Panel ) QskTabBar( QQuickItem* parent = nullptr ); @@ -73,19 +73,19 @@ class QSK_EXPORT QskTabBar : public QskBox QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol ) const override; -public Q_SLOTS: + public Q_SLOTS: void setCurrentIndex( int index ); -Q_SIGNALS: + Q_SIGNALS: void currentIndexChanged( int index ); void countChanged(); void textOptionsChanged(); void orientationChanged(); -protected: + protected: void componentComplete() override; -private: + private: void restack(); class PrivateData; diff --git a/src/controls/QskTabButton.cpp b/src/controls/QskTabButton.cpp index 64c6279e4..1b8d497d8 100644 --- a/src/controls/QskTabButton.cpp +++ b/src/controls/QskTabButton.cpp @@ -4,9 +4,9 @@ *****************************************************************************/ #include "QskTabButton.h" +#include "QskSkinlet.h" #include "QskTabBar.h" #include "QskTextOptions.h" -#include "QskSkinlet.h" #include #include @@ -16,9 +16,9 @@ QSK_SUBCONTROL( QskTabButton, Text ) class QskTabButton::PrivateData { -public: - PrivateData( const QString& txt ): - text( txt ) + public: + PrivateData( const QString& txt ) + : text( txt ) { } @@ -27,14 +27,14 @@ class QskTabButton::PrivateData QPointer< QskTabBar > tabBar; }; -QskTabButton::QskTabButton( QQuickItem* parent ): - QskTabButton( QString(), parent ) +QskTabButton::QskTabButton( QQuickItem* parent ) + : QskTabButton( QString(), parent ) { } -QskTabButton::QskTabButton( const QString& text, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData( text ) ) +QskTabButton::QskTabButton( const QString& text, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( text ) ) { resolveTabBar(); @@ -119,7 +119,7 @@ QskTabBar* QskTabButton::tabBar() const void QskTabButton::changeEvent( QEvent* event ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::LocaleChange: { diff --git a/src/controls/QskTabButton.h b/src/controls/QskTabButton.h index 178642cb6..f2f60fb4c 100644 --- a/src/controls/QskTabButton.h +++ b/src/controls/QskTabButton.h @@ -16,12 +16,13 @@ class QSK_EXPORT QskTabButton : public QskAbstractButton Q_OBJECT Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged FINAL ) + Q_PROPERTY( QskTextOptions textOptions READ textOptions WRITE setTextOptions NOTIFY textOptionsChanged ) using Inherited = QskAbstractButton; -public: + public: QSK_SUBCONTROLS( Panel, Text ) QskTabButton( QQuickItem* parent = nullptr ); @@ -41,14 +42,14 @@ class QSK_EXPORT QskTabButton : public QskAbstractButton QskTabBar* tabBar() const; -Q_SIGNALS: + Q_SIGNALS: void textChanged( const QString& text ); void textOptionsChanged(); -protected: + protected: void changeEvent( QEvent* ) override; -private: + private: void resolveTabBar(); class PrivateData; diff --git a/src/controls/QskTabButtonSkinlet.cpp b/src/controls/QskTabButtonSkinlet.cpp index 21eb34e7c..ddc2cce88 100644 --- a/src/controls/QskTabButtonSkinlet.cpp +++ b/src/controls/QskTabButtonSkinlet.cpp @@ -7,8 +7,8 @@ #include "QskTabButton.h" #include "QskTextOptions.h" -QskTabButtonSkinlet::QskTabButtonSkinlet( QskSkin* skin ): - Inherited( skin ) +QskTabButtonSkinlet::QskTabButtonSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole, TextRole } ); } @@ -40,7 +40,7 @@ QSGNode* QskTabButtonSkinlet::updateSubNode( { const auto tabButton = static_cast< const QskTabButton* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { diff --git a/src/controls/QskTabButtonSkinlet.h b/src/controls/QskTabButtonSkinlet.h index 962f4c833..2dca3db87 100644 --- a/src/controls/QskTabButtonSkinlet.h +++ b/src/controls/QskTabButtonSkinlet.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskTabButtonSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole, @@ -25,12 +25,12 @@ class QSK_EXPORT QskTabButtonSkinlet : public QskSkinlet Q_INVOKABLE QskTabButtonSkinlet( QskSkin* = nullptr ); ~QskTabButtonSkinlet() override; - QRectF subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + QskAspect::Subcontrol ) const override; -protected: - QSGNode* updateSubNode( - const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; + protected: + QSGNode* updateSubNode( const QskSkinnable*, + quint8 nodeRole, QSGNode* ) const override; }; #endif diff --git a/src/controls/QskTabView.cpp b/src/controls/QskTabView.cpp index 7b6c41775..a221e7424 100644 --- a/src/controls/QskTabView.cpp +++ b/src/controls/QskTabView.cpp @@ -4,12 +4,12 @@ *****************************************************************************/ #include "QskTabView.h" -#include "QskTabBar.h" -#include "QskTabButton.h" +#include "QskAnimationHint.h" +#include "QskAspect.h" #include "QskStackBox.h" #include "QskStackBoxAnimator.h" -#include "QskAspect.h" -#include "QskAnimationHint.h" +#include "QskTabBar.h" +#include "QskTabButton.h" QSK_SUBCONTROL( QskTabView, TabBar ) QSK_SUBCONTROL( QskTabView, Page ) @@ -21,10 +21,10 @@ static inline Qt::Orientation qskTransposed( Qt::Orientation orientation ) class QskTabView::PrivateData { -public: - PrivateData(): - tabBar( nullptr ), - stackBox( nullptr ) + public: + PrivateData() + : tabBar( nullptr ) + , stackBox( nullptr ) { } @@ -32,14 +32,14 @@ class QskTabView::PrivateData QskStackBox* stackBox; }; -QskTabView::QskTabView( QQuickItem* parent ): - QskTabView( Qt::Vertical, parent ) +QskTabView::QskTabView( QQuickItem* parent ) + : QskTabView( Qt::Vertical, parent ) { } -QskTabView::QskTabView( Qt::Orientation orientation, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskTabView::QskTabView( Qt::Orientation orientation, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setPolishOnResize( true ); @@ -59,7 +59,7 @@ QskTabView::QskTabView( Qt::Orientation orientation, QQuickItem* parent ): auto animator = new QskStackBoxAnimator3( m_data->stackBox ); animator->setDuration( hint.duration ); animator->setEasingCurve( hint.type ); - + m_data->stackBox->setAnimator( animator ); } #endif @@ -202,7 +202,7 @@ void QskTabView::setCurrentIndex( int index ) bool QskTabView::event( QEvent* event ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::LayoutRequest: { diff --git a/src/controls/QskTabView.h b/src/controls/QskTabView.h index 985d50626..7b22d33c3 100644 --- a/src/controls/QskTabView.h +++ b/src/controls/QskTabView.h @@ -19,12 +19,13 @@ class QSK_EXPORT QskTabView : public QskControl WRITE setOrientation NOTIFY orientationChanged ) Q_PROPERTY( int count READ count NOTIFY countChanged FINAL ) + Q_PROPERTY( int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL ) typedef QskControl Inherited; -public: + public: QSK_SUBCONTROLS( TabBar, Page ) QskTabView( QQuickItem* parent = nullptr ); @@ -62,19 +63,19 @@ class QSK_EXPORT QskTabView : public QskControl QSizeF contentsSizeHint() const override; -public Q_SLOTS: + public Q_SLOTS: void setCurrentIndex( int index ); -Q_SIGNALS: + Q_SIGNALS: void currentIndexChanged( int index ); void countChanged(); void orientationChanged(); -protected: + protected: bool event( QEvent* event ) override; void updateLayout() override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskTabViewSkinlet.cpp b/src/controls/QskTabViewSkinlet.cpp index 928ad27df..b6377e34c 100644 --- a/src/controls/QskTabViewSkinlet.cpp +++ b/src/controls/QskTabViewSkinlet.cpp @@ -4,11 +4,11 @@ *****************************************************************************/ #include "QskTabViewSkinlet.h" -#include "QskTabView.h" #include "QskTabBar.h" +#include "QskTabView.h" -QskTabViewSkinlet::QskTabViewSkinlet( QskSkin* skin ): - Inherited( skin ) +QskTabViewSkinlet::QskTabViewSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PageRole } ); } @@ -33,10 +33,10 @@ QRectF QskTabViewSkinlet::subControlRect( return Inherited::subControlRect( skinnable, subControl ); } -QSGNode* QskTabViewSkinlet::updateSubNode( const QskSkinnable* skinnable, - quint8 nodeRole, QSGNode* node ) const +QSGNode* QskTabViewSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { - switch( nodeRole ) + switch ( nodeRole ) { case PageRole: { diff --git a/src/controls/QskTabViewSkinlet.h b/src/controls/QskTabViewSkinlet.h index df99fa2ba..758fe38ee 100644 --- a/src/controls/QskTabViewSkinlet.h +++ b/src/controls/QskTabViewSkinlet.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskTabViewSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PageRole @@ -26,14 +26,14 @@ class QSK_EXPORT QskTabViewSkinlet : public QskSkinlet Q_INVOKABLE QskTabViewSkinlet( QskSkin* = nullptr ); ~QskTabViewSkinlet() override; - QRectF subControlRect( - const QskSkinnable*, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, + QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; -private: + private: QRectF pageRect( const QskTabView* ) const; QRectF tabBarRect( const QskTabView* ) const; }; diff --git a/src/controls/QskTextInput.cpp b/src/controls/QskTextInput.cpp index 997789251..15b978280 100644 --- a/src/controls/QskTextInput.cpp +++ b/src/controls/QskTextInput.cpp @@ -29,13 +29,13 @@ QSK_SUBCONTROL( QskTextInput, TextSelected ) QSK_STATE( QskTextInput, ReadOnly, QskAspect::FirstSystemState << 1 ) QSK_STATE( QskTextInput, Editing, QskAspect::FirstSystemState << 2 ) -static inline void qskBindSignals( const QQuickTextInput* wrappedInput, - QskTextInput* input ) +static inline void qskBindSignals( + const QQuickTextInput* wrappedInput, QskTextInput* input ) { QObject::connect( wrappedInput, &QQuickTextInput::textChanged, input, [ input ] { input->Q_EMIT textChanged( input->text() ); } ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) QObject::connect( wrappedInput, &QQuickTextInput::textEdited, input, [ input ] { input->Q_EMIT textEdited( input->text() ); } ); #endif @@ -49,7 +49,7 @@ static inline void qskBindSignals( const QQuickTextInput* wrappedInput, QObject::connect( wrappedInput, &QQuickTextInput::readOnlyChanged, input, &QskTextInput::readOnlyChanged ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) QObject::connect( wrappedInput, &QQuickTextInput::overwriteModeChanged, input, &QskTextInput::overwriteModeChanged ); #endif @@ -79,7 +79,7 @@ namespace { using Inherited = QQuickTextInput; - public: + public: TextInput( QskTextInput* ); void setEditing( bool on ); @@ -134,8 +134,8 @@ namespace } }; - TextInput::TextInput( QskTextInput* textInput ): - QQuickTextInput( textInput ) + TextInput::TextInput( QskTextInput* textInput ) + : QQuickTextInput( textInput ) { classBegin(); @@ -157,7 +157,7 @@ namespace return; setCursorVisible( on ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) d->setBlinkingCursorEnabled( on ); #endif @@ -223,16 +223,16 @@ namespace class QskTextInput::PrivateData { -public: + public: TextInput* textInput; QString description; // f.e. used as prompt in QskInputPanel unsigned int activationModes : 3; }; -QskTextInput::QskTextInput( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskTextInput::QskTextInput( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { m_data->activationModes = ActivationOnMouse | ActivationOnKey; @@ -257,8 +257,8 @@ QskTextInput::QskTextInput( QQuickItem* parent ): initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed ); } -QskTextInput::QskTextInput( const QString& text, QQuickItem* parent ): - QskTextInput( parent ) +QskTextInput::QskTextInput( const QString& text, QQuickItem* parent ) + : QskTextInput( parent ) { m_data->textInput->setText( text ); } @@ -285,7 +285,7 @@ void QskTextInput::keyPressEvent( QKeyEvent* event ) { if ( isEditing() ) { - switch( event->key() ) + switch ( event->key() ) { case Qt::Key_Enter: case Qt::Key_Return: @@ -367,7 +367,7 @@ void QskTextInput::focusInEvent( QFocusEvent* event ) { if ( m_data->activationModes & ActivationOnFocus ) { - switch( event->reason() ) + switch ( event->reason() ) { case Qt::ActiveWindowFocusReason: case Qt::PopupFocusReason: @@ -383,7 +383,7 @@ void QskTextInput::focusInEvent( QFocusEvent* event ) void QskTextInput::focusOutEvent( QFocusEvent* event ) { - switch( event->reason() ) + switch ( event->reason() ) { case Qt::ActiveWindowFocusReason: case Qt::PopupFocusReason: @@ -486,7 +486,7 @@ void QskTextInput::setFontRole( int role ) resetImplicitSize(); Qt::InputMethodQueries queries = Qt::ImCursorRectangle | Qt::ImFont; -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) queries |= Qt::ImAnchorRectangle; #endif @@ -599,7 +599,7 @@ int QskTextInput::cursorPosition() const return m_data->textInput->cursorPosition(); } -void QskTextInput::setCursorPosition(int pos) +void QskTextInput::setCursorPosition( int pos ) { m_data->textInput->setCursorPosition( pos ); } @@ -609,7 +609,7 @@ int QskTextInput::maxLength() const return m_data->textInput->maxLength(); } -void QskTextInput::setMaxLength(int length) +void QskTextInput::setMaxLength( int length ) { m_data->textInput->setMaxLength( length ); } @@ -693,7 +693,7 @@ QString QskTextInput::preeditText() const return d->m_textLayout.preeditAreaText(); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) bool QskTextInput::overwriteMode() const { @@ -718,19 +718,19 @@ bool QskTextInput::fixup() } QVariant QskTextInput::inputMethodQuery( - Qt::InputMethodQuery property) const + Qt::InputMethodQuery property ) const { return inputMethodQuery( property, QVariant() ); } QVariant QskTextInput::inputMethodQuery( - Qt::InputMethodQuery query, QVariant argument) const + Qt::InputMethodQuery query, QVariant argument ) const { - switch( query ) + switch ( query ) { case Qt::ImEnabled: { - return QVariant( (bool)( flags() & ItemAcceptsInputMethod ) ); + return QVariant( ( bool ) ( flags() & ItemAcceptsInputMethod ) ); } case Qt::ImFont: { @@ -741,7 +741,7 @@ QVariant QskTextInput::inputMethodQuery( return locale(); } case Qt::ImCursorRectangle: -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) case Qt::ImInputItemClipRectangle: #endif { @@ -774,7 +774,7 @@ Qt::InputMethodHints QskTextInput::inputMethodHints() const return m_data->textInput->inputMethodHints(); } -void QskTextInput::setInputMethodHints(Qt::InputMethodHints hints ) +void QskTextInput::setInputMethodHints( Qt::InputMethodHints hints ) { if ( m_data->textInput->inputMethodHints() != hints ) { diff --git a/src/controls/QskTextInput.h b/src/controls/QskTextInput.h index 7bfcf39e8..711386a5b 100644 --- a/src/controls/QskTextInput.h +++ b/src/controls/QskTextInput.h @@ -44,7 +44,7 @@ class QSK_EXPORT QskTextInput : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Panel, Text, PanelSelected, TextSelected ) QSK_STATES( ReadOnly, Editing ) @@ -71,7 +71,7 @@ class QSK_EXPORT QskTextInput : public QskControl PasswordEchoOnEdit }; - Q_ENUM(EchoMode) + Q_ENUM( EchoMode ) QskTextInput( QQuickItem* parent = nullptr ); QskTextInput( const QString& text, QQuickItem* parent = nullptr ); @@ -99,7 +99,7 @@ class QSK_EXPORT QskTextInput : public QskControl QFont font() const; bool isReadOnly() const; - void setReadOnly(bool); + void setReadOnly( bool ); int cursorPosition() const; void setCursorPosition( int ); @@ -127,7 +127,7 @@ class QSK_EXPORT QskTextInput : public QskControl QString displayText() const; QString preeditText() const; -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) bool overwriteMode() const; void setOverwriteMode( bool ); #endif @@ -136,7 +136,7 @@ class QSK_EXPORT QskTextInput : public QskControl virtual bool fixup(); QVariant inputMethodQuery( Qt::InputMethodQuery ) const override; - QVariant inputMethodQuery( Qt::InputMethodQuery, QVariant argument) const; + QVariant inputMethodQuery( Qt::InputMethodQuery, QVariant argument ) const; bool canUndo() const; bool canRedo() const; @@ -148,11 +148,11 @@ class QSK_EXPORT QskTextInput : public QskControl QSizeF contentsSizeHint() const override; -public Q_SLOTS: + public Q_SLOTS: void setText( const QString& ); void setEditing( bool ); -Q_SIGNALS: + Q_SIGNALS: void editingChanged( bool ); void activationModesChanged(); @@ -160,7 +160,7 @@ public Q_SLOTS: void textChanged( const QString& ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) void textEdited( const QString& ); #endif @@ -170,7 +170,7 @@ public Q_SLOTS: void fontRoleChanged(); void alignmentChanged(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) void overwriteModeChanged( bool ); #endif @@ -183,7 +183,7 @@ public Q_SLOTS: void validatorChanged(); void inputMaskChanged( const QString& ); -protected: + protected: bool event( QEvent* ) override; void inputMethodEvent( QInputMethodEvent* ) override; @@ -200,9 +200,9 @@ public Q_SLOTS: void keyReleaseEvent( QKeyEvent* ) override; void updateLayout() override; - void updateNode( QSGNode*) override; + void updateNode( QSGNode* ) override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskTextInputSkinlet.cpp b/src/controls/QskTextInputSkinlet.cpp index 133b9b630..94f88e2b0 100644 --- a/src/controls/QskTextInputSkinlet.cpp +++ b/src/controls/QskTextInputSkinlet.cpp @@ -6,8 +6,8 @@ #include "QskTextInputSkinlet.h" #include "QskTextInput.h" -QskTextInputSkinlet::QskTextInputSkinlet( QskSkin* skin ): - Inherited( skin ) +QskTextInputSkinlet::QskTextInputSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { PanelRole } ); } @@ -36,7 +36,7 @@ QRectF QskTextInputSkinlet::subControlRect( QSGNode* QskTextInputSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { - switch( nodeRole ) + switch ( nodeRole ) { case PanelRole: { diff --git a/src/controls/QskTextInputSkinlet.h b/src/controls/QskTextInputSkinlet.h index 2ae7b6aa4..e76e566f0 100644 --- a/src/controls/QskTextInputSkinlet.h +++ b/src/controls/QskTextInputSkinlet.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskTextInputSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { PanelRole @@ -27,10 +27,9 @@ class QSK_EXPORT QskTextInputSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; }; #endif - diff --git a/src/controls/QskTextLabel.cpp b/src/controls/QskTextLabel.cpp index 5666d4608..1dd9eafa7 100644 --- a/src/controls/QskTextLabel.cpp +++ b/src/controls/QskTextLabel.cpp @@ -15,9 +15,9 @@ QSK_SUBCONTROL( QskTextLabel, Text ) class QskTextLabel::PrivateData { -public: - PrivateData( const QString& txt ): - text( txt ) + public: + PrivateData( const QString& txt ) + : text( txt ) { effectiveTextFormat = textOptions.format(); } @@ -42,14 +42,14 @@ class QskTextLabel::PrivateData mutable QskTextOptions::TextFormat effectiveTextFormat; }; -QskTextLabel::QskTextLabel( QQuickItem* parent ): - QskTextLabel( QString(), parent ) +QskTextLabel::QskTextLabel( QQuickItem* parent ) + : QskTextLabel( QString(), parent ) { } -QskTextLabel::QskTextLabel( const QString& text, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData( text ) ) +QskTextLabel::QskTextLabel( const QString& text, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( text ) ) { initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed ); } @@ -163,7 +163,7 @@ void QskTextLabel::setAlignment( Qt::Alignment alignment ) Q_EMIT alignmentChanged(); } -QFont QskTextLabel::font() const +QFont QskTextLabel::font() const { return effectiveFont( QskTextLabel::Text ); } @@ -199,8 +199,8 @@ qreal QskTextLabel::heightForWidth( qreal width ) const } QSizeF size( width, maxHeight ); - size = QskTextRenderer::textSize( m_data->text, font, - m_data->effectiveOptions(), size ); + size = QskTextRenderer::textSize( + m_data->text, font, m_data->effectiveOptions(), size ); return qCeil( size.height() ); } @@ -225,7 +225,7 @@ qreal QskTextLabel::widthForHeight( qreal height ) const void QskTextLabel::changeEvent( QEvent* event ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::LocaleChange: { diff --git a/src/controls/QskTextLabel.h b/src/controls/QskTextLabel.h index 5da50174d..b9a857fbf 100644 --- a/src/controls/QskTextLabel.h +++ b/src/controls/QskTextLabel.h @@ -30,7 +30,7 @@ class QSK_EXPORT QskTextLabel : public QskControl using Inherited = QskControl; -public: + public: QSK_SUBCONTROLS( Text ) QskTextLabel( QQuickItem* parent = nullptr ); @@ -59,20 +59,20 @@ class QSK_EXPORT QskTextLabel : public QskControl QFont font() const; -Q_SIGNALS: + Q_SIGNALS: void textChanged( const QString& ); void textColorChanged(); void textOptionsChanged(); void fontRoleChanged(); void alignmentChanged(); -public Q_SLOTS: + public Q_SLOTS: void setText( const QString& ); -protected: + protected: void changeEvent( QEvent* ) override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/controls/QskTextLabelSkinlet.cpp b/src/controls/QskTextLabelSkinlet.cpp index 853fec1fd..4e9a864c9 100644 --- a/src/controls/QskTextLabelSkinlet.cpp +++ b/src/controls/QskTextLabelSkinlet.cpp @@ -7,8 +7,8 @@ #include "QskTextLabel.h" #include "QskTextOptions.h" -QskTextLabelSkinlet::QskTextLabelSkinlet( QskSkin* skin ): - Inherited( skin ) +QskTextLabelSkinlet::QskTextLabelSkinlet( QskSkin* skin ) + : Inherited( skin ) { setNodeRoles( { TextRole } ); } @@ -17,9 +17,9 @@ QskTextLabelSkinlet::~QskTextLabelSkinlet() = default; QRectF QskTextLabelSkinlet::subControlRect( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const -{ +{ const auto label = static_cast< const QskTextLabel* >( skinnable ); - + if ( subControl == QskTextLabel::Text ) { return label->contentsRect(); @@ -28,12 +28,12 @@ QRectF QskTextLabelSkinlet::subControlRect( return Inherited::subControlRect( skinnable, subControl ); } -QSGNode* QskTextLabelSkinlet::updateSubNode( const QskSkinnable* skinnable, - quint8 nodeRole, QSGNode* node ) const +QSGNode* QskTextLabelSkinlet::updateSubNode( + const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { const auto label = static_cast< const QskTextLabel* >( skinnable ); - switch( nodeRole ) + switch ( nodeRole ) { case TextRole: { diff --git a/src/controls/QskTextLabelSkinlet.h b/src/controls/QskTextLabelSkinlet.h index 931a7c29a..c5e73b7bb 100644 --- a/src/controls/QskTextLabelSkinlet.h +++ b/src/controls/QskTextLabelSkinlet.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskTextLabelSkinlet : public QskSkinlet using Inherited = QskSkinlet; -public: + public: enum NodeRole { TextRole @@ -27,7 +27,7 @@ class QSK_EXPORT QskTextLabelSkinlet : public QskSkinlet QRectF subControlRect( const QskSkinnable*, QskAspect::Subcontrol ) const override; -protected: + protected: QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; }; diff --git a/src/controls/QskVariantAnimator.cpp b/src/controls/QskVariantAnimator.cpp index 97492e1e2..07d802c56 100644 --- a/src/controls/QskVariantAnimator.cpp +++ b/src/controls/QskVariantAnimator.cpp @@ -4,12 +4,12 @@ *****************************************************************************/ #include "QskVariantAnimator.h" -#include "QskColorFilter.h" -#include "QskMargins.h" -#include "QskBoxShapeMetrics.h" -#include "QskBoxBorderMetrics.h" #include "QskBoxBorderColors.h" +#include "QskBoxBorderMetrics.h" +#include "QskBoxShapeMetrics.h" +#include "QskColorFilter.h" #include "QskGradient.h" +#include "QskMargins.h" #include "QskTextColors.h" // Even if we don't use the standard Qt animation system we @@ -24,21 +24,21 @@ QSK_QT_PRIVATE_END #if 1 static void qskRegisterInterpolator() { - qRegisterAnimationInterpolator( QskColorFilter::interpolate ); - qRegisterAnimationInterpolator( QskMargins::interpolate ); - qRegisterAnimationInterpolator( QskGradient::interpolate ); - qRegisterAnimationInterpolator( QskBoxShapeMetrics::interpolate ); - qRegisterAnimationInterpolator( QskBoxBorderMetrics::interpolate ); - qRegisterAnimationInterpolator( QskBoxBorderColors::interpolate ); - qRegisterAnimationInterpolator( QskTextColors::interpolate ); + qRegisterAnimationInterpolator< QskColorFilter >( QskColorFilter::interpolate ); + qRegisterAnimationInterpolator< QskMargins >( QskMargins::interpolate ); + qRegisterAnimationInterpolator< QskGradient >( QskGradient::interpolate ); + qRegisterAnimationInterpolator< QskBoxShapeMetrics >( QskBoxShapeMetrics::interpolate ); + qRegisterAnimationInterpolator< QskBoxBorderMetrics >( QskBoxBorderMetrics::interpolate ); + qRegisterAnimationInterpolator< QskBoxBorderColors >( QskBoxBorderColors::interpolate ); + qRegisterAnimationInterpolator< QskTextColors >( QskTextColors::interpolate ); } Q_CONSTRUCTOR_FUNCTION( qskRegisterInterpolator ) #endif -#if defined(Q_CC_CLANG) -#if __has_feature(address_sanitizer) -#define QSK_DECL_INSANE __attribute__ ( ( no_sanitize ("undefined") ) ) +#if defined( Q_CC_CLANG ) +#if __has_feature( address_sanitizer ) +#define QSK_DECL_INSANE __attribute__( ( no_sanitize( "undefined" ) ) ) #endif #endif @@ -46,8 +46,8 @@ Q_CONSTRUCTOR_FUNCTION( qskRegisterInterpolator ) #define QSK_DECL_INSANE #endif -QSK_DECL_INSANE static inline QVariant qskInterpolate ( - void( *interpolator )(), const QVariant& from, const QVariant& to, qreal progress ) +QSK_DECL_INSANE static inline QVariant qskInterpolate( + void ( *interpolator )(), const QVariant& from, const QVariant& to, qreal progress ) { #if 1 /* @@ -60,8 +60,8 @@ QSK_DECL_INSANE static inline QVariant qskInterpolate ( return f( from.constData(), to.constData(), progress ); } -QskVariantAnimator::QskVariantAnimator(): - m_interpolator( nullptr ) +QskVariantAnimator::QskVariantAnimator() + : m_interpolator( nullptr ) { } @@ -92,7 +92,8 @@ void QskVariantAnimator::setup() if ( type == m_endValue.userType() ) { // all what has been registered by qRegisterAnimationInterpolator - m_interpolator = reinterpret_cast< void (*)() >( QVariantAnimationPrivate::getInterpolator( type ) ); + m_interpolator = reinterpret_cast< void ( * )() >( + QVariantAnimationPrivate::getInterpolator( type ) ); } m_currentValue = m_interpolator ? m_startValue : m_endValue; diff --git a/src/controls/QskVariantAnimator.h b/src/controls/QskVariantAnimator.h index 5270012d3..c1c5a113a 100644 --- a/src/controls/QskVariantAnimator.h +++ b/src/controls/QskVariantAnimator.h @@ -12,7 +12,7 @@ class QSK_EXPORT QskVariantAnimator : public QskAnimator { -public: + public: QskVariantAnimator(); ~QskVariantAnimator() override; @@ -25,17 +25,17 @@ class QSK_EXPORT QskVariantAnimator : public QskAnimator void setEndValue( const QVariant& ); QVariant endValue() const; -protected: + protected: void setup() override; void advance( qreal value ) override; void done() override; -private: + private: QVariant m_startValue; QVariant m_endValue; QVariant m_currentValue; - void( *m_interpolator )(); + void ( *m_interpolator )(); }; inline QVariant QskVariantAnimator::startValue() const diff --git a/src/controls/QskWindow.cpp b/src/controls/QskWindow.cpp index ff823b707..161446212 100644 --- a/src/controls/QskWindow.cpp +++ b/src/controls/QskWindow.cpp @@ -5,9 +5,9 @@ #include "QskWindow.h" #include "QskControl.h" +#include "QskEvent.h" #include "QskQuick.h" #include "QskSetup.h" -#include "QskEvent.h" #include #include @@ -31,7 +31,7 @@ static inline void qskSendEventTo( QObject* object, QEvent::Type type ) static QQuickItem* qskDefaultFocusItem( QQuickWindow* window ) { const auto children = qskPaintOrderChildItems( window->contentItem() ); - for ( auto it = children.crbegin(); it != children.crend(); ++it) + for ( auto it = children.crbegin(); it != children.crend(); ++it ) { auto child = *it; @@ -49,7 +49,7 @@ namespace { class ChildListener final : public QQuickItemChangeListener { - public: + public: void setEnabled( QQuickItem* item, bool on ) { m_item = item; @@ -73,7 +73,7 @@ namespace } } - private: + private: QQuickItem* m_item; }; } @@ -87,7 +87,7 @@ static inline int qskToIntegerConstraint( qreal valueF ) if ( valueF >= std::numeric_limits< int >::max() ) value = std::numeric_limits< int >::max(); else - value = ( int )qCeil( valueF ); + value = ( int ) qCeil( valueF ); } return value; @@ -97,13 +97,13 @@ class QskWindowPrivate : public QQuickWindowPrivate { Q_DECLARE_PUBLIC( QskWindow ) -public: - QskWindowPrivate(): - preferredSize( -1, -1 ), - eventAcceptance( QskWindow::EventProcessed ), - explicitLocale( false ), - deleteOnClose( false ), - autoLayoutChildren( true ) + public: + QskWindowPrivate() + : preferredSize( -1, -1 ) + , eventAcceptance( QskWindow::EventProcessed ) + , explicitLocale( false ) + , deleteOnClose( false ) + , autoLayoutChildren( true ) { } @@ -120,8 +120,8 @@ class QskWindowPrivate : public QQuickWindowPrivate bool autoLayoutChildren : 1; }; -QskWindow::QskWindow( QWindow* parent ): - Inherited( *( new QskWindowPrivate() ), parent ) +QskWindow::QskWindow( QWindow* parent ) + : Inherited( *( new QskWindowPrivate() ), parent ) { QSurfaceFormat fmt = format(); fmt.setSamples( 4 ); @@ -227,12 +227,12 @@ bool QskWindow::event( QEvent* event ) interested and when to do some fallback handling. To improve the situation we add an extra flag in QskWindow, while the right class to solve this shortcoming would be QQuickWindow. - */ + */ Q_D( QskWindow ); d->eventAcceptance = EventProcessed; - switch( event->type() ) + switch ( event->type() ) { case QEvent::Show: { @@ -464,10 +464,10 @@ void QskWindow::setCustomRenderMode( const char* mode ) { class RenderJob final : public QRunnable { - public: - RenderJob( QQuickWindow* window, const QByteArray mode ): - m_window( window ), - m_mode( mode ) + public: + RenderJob( QQuickWindow* window, const QByteArray mode ) + : m_window( window ) + , m_mode( mode ) { } @@ -487,7 +487,7 @@ void QskWindow::setCustomRenderMode( const char* mode ) } } - private: + private: QQuickWindow* m_window; const QByteArray m_mode; }; @@ -529,7 +529,7 @@ void QskWindow::enforceSkin() // let's create a default skin on the GUI thread - whatever it is // good for. - (void) qskSetup->skin(); + ( void ) qskSetup->skin(); qskEnforcedSkin = true; } @@ -539,7 +539,6 @@ void QskWindow::enforceSkin() void QskWindow::setEventAcceptance( EventAcceptance acceptance ) { d_func()->eventAcceptance = acceptance; - } QskWindow::EventAcceptance QskWindow::eventAcceptance() const diff --git a/src/controls/QskWindow.h b/src/controls/QskWindow.h index dfb4914c9..0a6e9d8a6 100644 --- a/src/controls/QskWindow.h +++ b/src/controls/QskWindow.h @@ -27,7 +27,7 @@ class QSK_EXPORT QskWindow : public QQuickWindow using Inherited = QQuickWindow; -public: + public: enum EventAcceptance { EventProcessed = 0, @@ -64,26 +64,26 @@ class QSK_EXPORT QskWindow : public QQuickWindow void setEventAcceptance( EventAcceptance ); EventAcceptance eventAcceptance() const; -Q_SIGNALS: + Q_SIGNALS: void localeChanged( const QLocale& ); void autoLayoutChildrenChanged(); void deleteOnCloseChanged(); -public Q_SLOTS: + public Q_SLOTS: void setLocale( const QLocale& ); void resizeF( const QSizeF& ); -protected: + protected: bool event( QEvent* ) override; void resizeEvent( QResizeEvent* ) override; void exposeEvent( QExposeEvent* ) override; - void keyPressEvent(QKeyEvent *) override; - void keyReleaseEvent(QKeyEvent *) override; + void keyPressEvent( QKeyEvent* ) override; + void keyReleaseEvent( QKeyEvent* ) override; virtual void layoutItems(); virtual void ensureFocus( Qt::FocusReason ); -private: + private: void enforceSkin(); Q_DECLARE_PRIVATE( QskWindow ) diff --git a/src/dialogs/QskDialog.cpp b/src/dialogs/QskDialog.cpp index f6adaa005..891f491dd 100644 --- a/src/dialogs/QskDialog.cpp +++ b/src/dialogs/QskDialog.cpp @@ -6,18 +6,18 @@ #include "QskDialog.h" #include "QskDialogButtonBox.h" -#include "QskMessageWindow.h" #include "QskMessageSubWindow.h" +#include "QskMessageWindow.h" -#include "QskSelectionWindow.h" #include "QskSelectionSubWindow.h" +#include "QskSelectionWindow.h" #include "QskFocusIndicator.h" #include "QskStandardSymbol.h" +#include #include #include -#include static QskDialog::DialogCode qskExec( QskDialogWindow* dialogWindow ) { @@ -48,9 +48,9 @@ static QQuickWindow* qskSomeQuickWindow() return nullptr; } -static void qskSetupSubWindow( const QString& title, - QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton, - QskInputSubWindow* subWindow ) +static void qskSetupSubWindow( + const QString& title, QskDialog::StandardButtons buttons, + QskDialog::StandardButton defaultButton, QskInputSubWindow* subWindow ) { subWindow->setModal( true ); subWindow->setTitle( title ); @@ -98,17 +98,17 @@ static void qskSetupWindow( window->setModality( Qt::ApplicationModal ); } - -static QskDialog::StandardButton qskMessageSubWindow( QQuickWindow* window, - const QString& title, const QString& text, int symbolType, - QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton ) +static QskDialog::StandardButton qskMessageSubWindow( + QQuickWindow* window, const QString& title, + const QString& text, int symbolType, QskDialog::StandardButtons buttons, + QskDialog::StandardButton defaultButton ) { QskMessageSubWindow subWindow( window->contentItem() ); subWindow.setSymbolType( symbolType ); subWindow.setInfoText( text ); qskSetupSubWindow( title, buttons, defaultButton, &subWindow ); - (void) subWindow.exec(); + ( void ) subWindow.exec(); QskDialog::StandardButton clickedButton = subWindow.clickedButton(); if ( clickedButton == QskDialog::NoButton ) @@ -120,9 +120,10 @@ static QskDialog::StandardButton qskMessageSubWindow( QQuickWindow* window, return clickedButton; } -static QskDialog::StandardButton qskMessageWindow( QWindow* transientParent, - const QString& title, const QString& text, int symbolType, - QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton ) +static QskDialog::StandardButton qskMessageWindow( + QWindow* transientParent, const QString& title, + const QString& text, int symbolType, QskDialog::StandardButtons buttons, + QskDialog::StandardButton defaultButton ) { QskMessageWindow messageWindow; messageWindow.setSymbolType( symbolType ); @@ -141,8 +142,8 @@ static QskDialog::StandardButton qskMessageWindow( QWindow* transientParent, return clickedButton; } -static QString qskSelectSubWindow( QQuickWindow* window, - const QString& title, const QString& text, +static QString qskSelectSubWindow( + QQuickWindow* window, const QString& title, const QString& text, QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton, const QStringList& entries, int selectedRow ) { @@ -160,8 +161,8 @@ static QString qskSelectSubWindow( QQuickWindow* window, return selectedEntry; } -static QString qskSelectWindow( QWindow* transientParent, - const QString& title, const QString& text, +static QString qskSelectWindow( + QWindow* transientParent, const QString& title, const QString& text, QskDialog::StandardButtons buttons, QskDialog::StandardButton defaultButton, const QStringList& entries, int selectedRow ) { @@ -181,9 +182,9 @@ static QString qskSelectWindow( QWindow* transientParent, class QskDialog::PrivateData { -public: - PrivateData(): - policy( QskDialog::TopLevelWindow ) + public: + PrivateData() + : policy( QskDialog::TopLevelWindow ) { } @@ -191,8 +192,8 @@ class QskDialog::PrivateData QskDialog::Policy policy : 2; }; -QskDialog::QskDialog(): - m_data( new PrivateData ) +QskDialog::QskDialog() + : m_data( new PrivateData ) { } @@ -243,8 +244,7 @@ QskDialog::StandardButton QskDialog::message( { if ( m_data->policy == EmbeddedBox ) { - QQuickWindow* quickWindow = - qobject_cast< QQuickWindow* >( m_data->transientParent ); + auto quickWindow = qobject_cast< QQuickWindow* >( m_data->transientParent ); if ( quickWindow == nullptr ) quickWindow = qskSomeQuickWindow(); @@ -304,8 +304,7 @@ QString QskDialog::select( if ( m_data->policy == EmbeddedBox ) { - QQuickWindow* quickWindow = - qobject_cast< QQuickWindow* >( m_data->transientParent ); + auto quickWindow = qobject_cast< QQuickWindow* >( m_data->transientParent ); if ( quickWindow == nullptr ) quickWindow = qskSomeQuickWindow(); diff --git a/src/dialogs/QskDialog.h b/src/dialogs/QskDialog.h index 7db948735..dfdc972c2 100644 --- a/src/dialogs/QskDialog.h +++ b/src/dialogs/QskDialog.h @@ -30,7 +30,7 @@ class QSK_EXPORT QskDialog : public QObject Q_PROPERTY( QWindow* transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged ) -public: + public: enum Policy { EmbeddedBox, @@ -112,33 +112,26 @@ class QSK_EXPORT QskDialog : public QObject ) const; Q_INVOKABLE StandardButton warning( - const QString &title, const QString &text, - StandardButtons buttons = Ok, - StandardButton = NoButton - ) const; + const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton = NoButton ) const; Q_INVOKABLE StandardButton critical( - const QString &title, const QString &text, - StandardButtons buttons = Ok, - StandardButton = NoButton - ) const; + const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton = NoButton ) const; Q_INVOKABLE StandardButton question( - const QString &title, const QString &text, - StandardButtons = StandardButtons( Yes | No ), - StandardButton = NoButton - ) const; + const QString& title, const QString& text, + StandardButtons = StandardButtons( Yes | No ), StandardButton = NoButton ) const; Q_INVOKABLE QString select( const QString& title, const QString& text, - const QStringList& entries, int selectedRow = 0 - ) const; + const QStringList& entries, int selectedRow = 0 ) const; -Q_SIGNALS: + Q_SIGNALS: void transientParentChanged(); void policyChanged(); -private: + private: QskDialog(); ~QskDialog() override; diff --git a/src/dialogs/QskDialogButton.cpp b/src/dialogs/QskDialogButton.cpp index ebf26f8a8..32f14094b 100644 --- a/src/dialogs/QskDialogButton.cpp +++ b/src/dialogs/QskDialogButton.cpp @@ -11,15 +11,15 @@ QSK_SUBCONTROL( QskDialogButton, Text ) QSK_SUBCONTROL( QskDialogButton, Graphic ) QskDialogButton::QskDialogButton( - QskDialog::StandardButton standardButton, QQuickItem* parent ): - QskPushButton( parent ), - m_buttonType( standardButton ) + QskDialog::StandardButton standardButton, QQuickItem* parent ) + : QskPushButton( parent ) + , m_buttonType( standardButton ) { setText( QskDialogButtonBox::buttonText( m_buttonType ) ); } -QskDialogButton::QskDialogButton( QQuickItem* parent ): - QskDialogButton( QskDialog::NoButton, parent ) +QskDialogButton::QskDialogButton( QQuickItem* parent ) + : QskDialogButton( QskDialog::NoButton, parent ) { } @@ -67,5 +67,3 @@ void QskDialogButton::changeEvent( QEvent* event ) } #include "moc_QskDialogButton.cpp" - - diff --git a/src/dialogs/QskDialogButton.h b/src/dialogs/QskDialogButton.h index ab7dbc608..6af49bf19 100644 --- a/src/dialogs/QskDialogButton.h +++ b/src/dialogs/QskDialogButton.h @@ -6,9 +6,8 @@ #ifndef QSK_DIALOG_BUTTON_H #define QSK_DIALOG_BUTTON_H -#include "QskGlobal.h" -#include "QskPushButton.h" #include "QskDialog.h" +#include "QskPushButton.h" class QSK_EXPORT QskDialogButton : public QskPushButton { @@ -19,7 +18,7 @@ class QSK_EXPORT QskDialogButton : public QskPushButton using Inherited = QskPushButton; -public: + public: QSK_SUBCONTROLS( Panel, Text, Graphic ) QskDialogButton( QskDialog::StandardButton, QQuickItem* parent = nullptr ); @@ -33,13 +32,13 @@ class QSK_EXPORT QskDialogButton : public QskPushButton QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol ) const override; -Q_SIGNALS: + Q_SIGNALS: void standardButtonChanged(); -protected: + protected: void changeEvent( QEvent* ) override; -private: + private: QskDialog::StandardButton m_buttonType; }; diff --git a/src/dialogs/QskDialogButtonBox.cpp b/src/dialogs/QskDialogButtonBox.cpp index 7b2835a7d..195386bba 100644 --- a/src/dialogs/QskDialogButtonBox.cpp +++ b/src/dialogs/QskDialogButtonBox.cpp @@ -9,8 +9,8 @@ #include "QskSkin.h" #include -#include #include +#include QSK_QT_PRIVATE_BEGIN #include @@ -41,29 +41,29 @@ static void qskAddToLayout( const QList< QskPushButton* >& buttonList, if ( reverse ) { for ( int i = buttonList.count() - 1; i >= 0; i-- ) - layoutBox->addItem( buttonList[i] ); + layoutBox->addItem( buttonList[ i ] ); } else { for ( int i = 0; i < buttonList.count(); i++ ) - layoutBox->addItem( buttonList[i] ); + layoutBox->addItem( buttonList[ i ] ); } } class QskDialogButtonBox::PrivateData { -public: - PrivateData(): - layoutBox( nullptr ), - centeredButtons( false ), - dirtyLayout( false ), - clickedButton( QskDialog::NoButton ) + public: + PrivateData() + : layoutBox( nullptr ) + , centeredButtons( false ) + , dirtyLayout( false ) + , clickedButton( QskDialog::NoButton ) { } QskLinearBox* layoutBox; - QList< QskPushButton* > buttonLists[QskDialog::NButtonRoles]; + QList< QskPushButton* > buttonLists[ QskDialog::NButtonRoles ]; bool centeredButtons : 1; bool dirtyLayout : 1; @@ -71,14 +71,14 @@ class QskDialogButtonBox::PrivateData QskDialog::StandardButton clickedButton; }; -QskDialogButtonBox::QskDialogButtonBox( QQuickItem* parent ): - QskDialogButtonBox( Qt::Horizontal, parent ) +QskDialogButtonBox::QskDialogButtonBox( QQuickItem* parent ) + : QskDialogButtonBox( Qt::Horizontal, parent ) { } -QskDialogButtonBox::QskDialogButtonBox( Qt::Orientation orientation, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskDialogButtonBox::QskDialogButtonBox( Qt::Orientation orientation, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setPolishOnResize( true ); setOrientation( orientation ); @@ -188,7 +188,7 @@ void QskDialogButtonBox::rearrangeButtons() } case QPlatformDialogHelper::AcceptRole: { - const QList< QskPushButton* >& buttons = m_data->buttonLists[role]; + const auto& buttons = m_data->buttonLists[ role ]; if ( !buttons.isEmpty() ) layoutBox->addItem( buttons.first() ); @@ -197,8 +197,7 @@ void QskDialogButtonBox::rearrangeButtons() } case QPlatformDialogHelper::AlternateRole: { - const QList< QskPushButton* >& buttons = - m_data->buttonLists[QskDialog::AcceptRole]; + const auto& buttons = m_data->buttonLists[ QskDialog::AcceptRole ]; if ( buttons.size() > 1 ) qskAddToLayout( buttons.mid( 1 ), reverse, layoutBox ); @@ -214,7 +213,7 @@ void QskDialogButtonBox::rearrangeButtons() case QPlatformDialogHelper::ApplyRole: case QPlatformDialogHelper::ResetRole: { - const QList< QskPushButton* > buttons = m_data->buttonLists[role]; + const auto& buttons = m_data->buttonLists[ role ]; if ( !buttons.isEmpty() ) qskAddToLayout( buttons, reverse, layoutBox ); @@ -263,7 +262,7 @@ void QskDialogButtonBox::addButton( QskPushButton* button, QskDialog::ButtonRole connect( button, &QskPushButton::clicked, this, &QskDialogButtonBox::onButtonClicked ); - m_data->buttonLists[role] += button; + m_data->buttonLists[ role ] += button; invalidateLayout(); } } @@ -284,7 +283,7 @@ void QskDialogButtonBox::removeButton( QskPushButton* button ) for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) { - QList< QskPushButton* >& buttons = m_data->buttonLists[i]; + auto& buttons = m_data->buttonLists[ i ]; if ( buttons.removeOne( button ) ) { disconnect( button, &QskPushButton::clicked, @@ -306,19 +305,18 @@ void QskDialogButtonBox::clear() { for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) { - for ( const QQuickItem* button : qskAsConst( m_data->buttonLists[i] ) ) + for ( auto button : qskAsConst( m_data->buttonLists[ i ] ) ) delete button; } invalidateLayout(); } -void QskDialogButtonBox::setStandardButtons( - QskDialog::StandardButtons standardButton ) +void QskDialogButtonBox::setStandardButtons( QskDialog::StandardButtons standardButton ) { for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) { - for ( const QQuickItem* button : qskAsConst( m_data->buttonLists[i] ) ) + for ( auto button : qskAsConst( m_data->buttonLists[ i ] ) ) delete button; } @@ -337,7 +335,7 @@ QList< QskPushButton* > QskDialogButtonBox::buttons() const QList< QskPushButton* > buttons; for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) - buttons += m_data->buttonLists[i]; + buttons += m_data->buttonLists[ i ]; return buttons; } @@ -346,9 +344,9 @@ QskDialog::ButtonRole QskDialogButtonBox::buttonRole( const QskPushButton* butto { for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) { - const QList< QskPushButton* >& buttons = m_data->buttonLists[i]; + const auto& buttons = m_data->buttonLists[ i ]; - for ( const QskPushButton* btn : buttons ) + for ( const auto btn : buttons ) { if ( button == btn ) return static_cast< QskDialog::ButtonRole >( i ); @@ -389,7 +387,7 @@ void QskDialogButtonBox::onButtonClicked() if ( button == nullptr ) return; - switch( buttonRole( button ) ) + switch ( buttonRole( button ) ) { case QskDialog::AcceptRole: case QskDialog::YesRole: @@ -426,9 +424,9 @@ QskDialog::StandardButtons QskDialogButtonBox::standardButtons() const for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) { - const QList< QskPushButton* >& buttons = m_data->buttonLists[i]; + const auto& buttons = m_data->buttonLists[ i ]; - for ( const QskPushButton* btn : buttons ) + for ( const auto btn : buttons ) standardButtons |= this->standardButton( btn ); } @@ -450,13 +448,12 @@ QskDialog::StandardButton QskDialogButtonBox::standardButton( const QskPushButto return QskDialog::NoButton; } -QskPushButton* QskDialogButtonBox::button( - QskDialog::StandardButton standardButton ) const +QskPushButton* QskDialogButtonBox::button( QskDialog::StandardButton standardButton ) const { for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) { - const QList< QskPushButton* >& buttons = m_data->buttonLists[i]; - for ( QskPushButton* btn : buttons ) + const auto& buttons = m_data->buttonLists[ i ]; + for ( auto btn : buttons ) { if ( this->standardButton( btn ) == standardButton ) return btn; @@ -471,7 +468,7 @@ QskPushButton* QskDialogButtonBox::buttonFromRole( QskDialog::ButtonRole role ) if ( role < 0 || role >= QskDialog::NButtonRoles ) return nullptr; - const auto& buttonList = m_data->buttonLists[role]; + const auto& buttonList = m_data->buttonLists[ role ]; return buttonList.isEmpty() ? nullptr : buttonList.first(); } diff --git a/src/dialogs/QskDialogButtonBox.h b/src/dialogs/QskDialogButtonBox.h index 2b767424a..88c6405e3 100644 --- a/src/dialogs/QskDialogButtonBox.h +++ b/src/dialogs/QskDialogButtonBox.h @@ -6,9 +6,9 @@ #ifndef QSK_DIALOG_BUTTON_BOX_H #define QSK_DIALOG_BUTTON_BOX_H -#include "QskGlobal.h" -#include "QskDialog.h" #include "QskBox.h" +#include "QskDialog.h" +#include "QskGlobal.h" class QskPushButton; @@ -24,7 +24,7 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox using Inherited = QskBox; -public: + public: QSK_SUBCONTROLS( Panel ) QskDialogButtonBox( QQuickItem* parent = nullptr ); @@ -65,7 +65,7 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox static bool isDefaultButtonKeyEvent( const QKeyEvent* ); static QString buttonText( QskDialog::StandardButton ); -Q_SIGNALS: + Q_SIGNALS: void clicked( QskPushButton* button ); void accepted(); void rejected(); @@ -73,7 +73,7 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox void centeredButtonsChanged(); void orientationChanged(); -protected: + protected: bool event( QEvent* event ) override; void updateLayout() override; @@ -81,10 +81,10 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox void invalidateLayout(); -private Q_SLOTS: + private Q_SLOTS: void onButtonClicked(); -private: + private: void rearrangeButtons(); class PrivateData; diff --git a/src/dialogs/QskDialogSubWindow.cpp b/src/dialogs/QskDialogSubWindow.cpp index 05064819e..ae771ef69 100644 --- a/src/dialogs/QskDialogSubWindow.cpp +++ b/src/dialogs/QskDialogSubWindow.cpp @@ -22,9 +22,9 @@ static inline void qskSetRejectOnClose( QskDialogSubWindow* subWindow, bool on ) } } -QskDialogSubWindow::QskDialogSubWindow( QQuickItem* parent ): - Inherited( parent ), - m_result( QskDialog::Rejected ) +QskDialogSubWindow::QskDialogSubWindow( QQuickItem* parent ) + : Inherited( parent ) + , m_result( QskDialog::Rejected ) { qskSetRejectOnClose( this, true ); } diff --git a/src/dialogs/QskDialogSubWindow.h b/src/dialogs/QskDialogSubWindow.h index 4471d0ab0..b04b06785 100644 --- a/src/dialogs/QskDialogSubWindow.h +++ b/src/dialogs/QskDialogSubWindow.h @@ -6,9 +6,8 @@ #ifndef QSK_DIALOG_SUB_WINDOW_H #define QSK_DIALOG_SUB_WINDOW_H 1 -#include "QskGlobal.h" -#include "QskSubWindow.h" #include "QskDialog.h" +#include "QskSubWindow.h" class QSK_EXPORT QskDialogSubWindow : public QskSubWindow { @@ -16,30 +15,30 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow using Inherited = QskSubWindow; -public: + public: QskDialogSubWindow( QQuickItem* parent = nullptr ); ~QskDialogSubWindow() override; Q_INVOKABLE QskDialog::DialogCode result() const; Q_INVOKABLE QskDialog::DialogCode exec(); -Q_SIGNALS: + Q_SIGNALS: void finished( QskDialog::DialogCode ); void accepted(); void rejected(); -public Q_SLOTS: + public Q_SLOTS: void done( QskDialog::DialogCode ); void accept(); void reject(); -protected: + protected: void setResult( QskDialog::DialogCode r ); void keyPressEvent( QKeyEvent* ) override; void aboutToShow() override; -private: + private: QskDialog::DialogCode m_result; }; diff --git a/src/dialogs/QskDialogWindow.cpp b/src/dialogs/QskDialogWindow.cpp index fdc0c1b2a..0c20f270b 100644 --- a/src/dialogs/QskDialogWindow.cpp +++ b/src/dialogs/QskDialogWindow.cpp @@ -9,10 +9,10 @@ class QskDialogWindow::PrivateData { -public: - PrivateData(): - result( QskDialog::Rejected ), - inDone( false ) + public: + PrivateData() + : result( QskDialog::Rejected ) + , inDone( false ) { } @@ -20,12 +20,12 @@ class QskDialogWindow::PrivateData bool inDone : 1; // flag blocking recursive done calls }; -QskDialogWindow::QskDialogWindow( QWindow* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskDialogWindow::QskDialogWindow( QWindow* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { - setFlags( Qt::Dialog | Qt::WindowTitleHint | Qt::WindowCloseButtonHint - | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint ); + setFlags( Qt::Dialog | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | + Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint ); } QskDialogWindow::~QskDialogWindow() diff --git a/src/dialogs/QskDialogWindow.h b/src/dialogs/QskDialogWindow.h index ac51bf0cb..f2a690c9e 100644 --- a/src/dialogs/QskDialogWindow.h +++ b/src/dialogs/QskDialogWindow.h @@ -6,9 +6,9 @@ #ifndef QSK_DIALOG_WINDOW_H #define QSK_DIALOG_WINDOW_H 1 -#include "QskGlobal.h" -#include "QskWindow.h" #include "QskDialog.h" +#include "QskWindow.h" + #include class QSK_EXPORT QskDialogWindow : public QskWindow @@ -17,30 +17,30 @@ class QSK_EXPORT QskDialogWindow : public QskWindow using Inherited = QskWindow; -public: + public: QskDialogWindow( QWindow* parent = nullptr ); ~QskDialogWindow() override; Q_INVOKABLE QskDialog::DialogCode result() const; Q_INVOKABLE QskDialog::DialogCode exec(); -Q_SIGNALS: + Q_SIGNALS: void finished( QskDialog::DialogCode result ); void accepted(); void rejected(); -public Q_SLOTS: + public Q_SLOTS: void done( QskDialog::DialogCode ); void accept(); void reject(); -protected: + protected: void setResult( QskDialog::DialogCode r ); bool event( QEvent* ) override; void keyPressEvent( QKeyEvent* ) override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/dialogs/QskInputSubWindow.cpp b/src/dialogs/QskInputSubWindow.cpp index 2e9827806..2f193587f 100644 --- a/src/dialogs/QskInputSubWindow.cpp +++ b/src/dialogs/QskInputSubWindow.cpp @@ -4,23 +4,23 @@ *****************************************************************************/ #include "QskInputSubWindow.h" -#include "QskTextOptions.h" +#include "QskDialogButtonBox.h" #include "QskGraphic.h" -#include "QskPushButton.h" -#include "QskTextLabel.h" #include "QskGraphicLabel.h" -#include "QskDialogButtonBox.h" #include "QskLinearBox.h" +#include "QskPushButton.h" #include "QskSkin.h" +#include "QskTextLabel.h" +#include "QskTextOptions.h" -#include #include +#include namespace { class TextLabel final : public QskTextLabel { - public: + public: TextLabel( QskInputSubWindow* box ) { setObjectName( QStringLiteral( "QskInputSubWindowTextLabel" ) ); @@ -30,24 +30,24 @@ namespace setTextOptions( options ); - connect( this, SIGNAL( textChanged(QString) ), - box, SIGNAL( infoTextChanged() ) ); + connect( this, &QskTextLabel::textChanged, + box, &QskInputSubWindow::infoTextChanged ); - connect( this, SIGNAL( textOptionsChanged() ), - box, SIGNAL( infoTextOptionsChanged() ) ); + connect( this, &QskTextLabel::textOptionsChanged, + box, &QskInputSubWindow::infoTextOptionsChanged ); } }; class SymbolLabel final : public QskGraphicLabel { - public: + public: SymbolLabel( QskInputSubWindow* ) { setObjectName( QStringLiteral( "QskInputSubWindowSymbolLabel" ) ); updateSourceSize(); } - protected: + protected: void changeEvent( QEvent* event ) override { if ( event->type() == QEvent::FontChange ) @@ -56,7 +56,7 @@ namespace QskGraphicLabel::changeEvent( event ); } - private: + private: void updateSourceSize() { // when there is no explicit size known, @@ -73,11 +73,11 @@ namespace class QskInputSubWindow::PrivateData { -public: - PrivateData(): - standardButtons( QskDialog::NoButton ), - defaultButton( QskDialog::NoButton ), - inputControl( nullptr ) + public: + PrivateData() + : standardButtons( QskDialog::NoButton ) + , defaultButton( QskDialog::NoButton ) + , inputControl( nullptr ) { } @@ -92,9 +92,9 @@ class QskInputSubWindow::PrivateData QskLinearBox* layoutBox; }; -QskInputSubWindow::QskInputSubWindow( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskInputSubWindow::QskInputSubWindow( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { m_data->infoTextLabel = new TextLabel( this ); m_data->infoTextLabel->setSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred ); @@ -146,7 +146,7 @@ void QskInputSubWindow::setStandardButtons( QskDialog::StandardButtons buttons ) #if 1 const QList< QskPushButton* > b = m_data->buttonBox->buttons(); if ( !b.isEmpty() ) - b[0]->setFocus( true ); + b[ 0 ]->setFocus( true ); #endif } diff --git a/src/dialogs/QskInputSubWindow.h b/src/dialogs/QskInputSubWindow.h index ceef3169c..ecc50e23b 100644 --- a/src/dialogs/QskInputSubWindow.h +++ b/src/dialogs/QskInputSubWindow.h @@ -6,7 +6,6 @@ #ifndef QSK_INPUT_SUB_WINDOW_H #define QSK_INPUT_SUB_WINDOW_H 1 -#include "QskGlobal.h" #include "QskDialogSubWindow.h" class QskGraphic; @@ -28,7 +27,7 @@ class QSK_EXPORT QskInputSubWindow : public QskDialogSubWindow using Inherited = QskDialogSubWindow; -public: + public: QskInputSubWindow( QQuickItem* parent = nullptr ); ~QskInputSubWindow() override; @@ -56,21 +55,21 @@ class QSK_EXPORT QskInputSubWindow : public QskDialogSubWindow QskDialogButtonBox* buttonBox(); const QskDialogButtonBox* buttonBox() const; -public Q_SLOTS: + public Q_SLOTS: void setInfoText( const QString& ); -Q_SIGNALS: + Q_SIGNALS: void infoTextChanged(); void infoTextOptionsChanged(); void symbolSourceChanged(); -protected: + protected: void setInputControl( QskControl* ); QskControl* inputControl() const; void keyPressEvent( QKeyEvent* ) override; -private: + private: void updateTitleBox(); class PrivateData; diff --git a/src/dialogs/QskInputWindow.cpp b/src/dialogs/QskInputWindow.cpp index f61ed7d8c..1f7d72608 100644 --- a/src/dialogs/QskInputWindow.cpp +++ b/src/dialogs/QskInputWindow.cpp @@ -4,16 +4,16 @@ *****************************************************************************/ #include "QskInputWindow.h" +#include "QskGraphic.h" #include "QskInputSubWindow.h" #include "QskTextOptions.h" -#include "QskGraphic.h" -QskInputWindow::QskInputWindow( QWindow* parent ): - QskDialogWindow( parent ), - m_subWindow( nullptr ) +QskInputWindow::QskInputWindow( QWindow* parent ) + : QskDialogWindow( parent ) + , m_subWindow( nullptr ) { - setFlags( Qt::Dialog | Qt::WindowTitleHint - | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint ); + setFlags( Qt::Dialog | Qt::WindowTitleHint | + Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint ); setAutoLayoutChildren( true ); } diff --git a/src/dialogs/QskInputWindow.h b/src/dialogs/QskInputWindow.h index cc6d94583..a5797d720 100644 --- a/src/dialogs/QskInputWindow.h +++ b/src/dialogs/QskInputWindow.h @@ -6,7 +6,6 @@ #ifndef QSK_INPUT_WINDOW_H #define QSK_INPUT_WINDOW_H 1 -#include "QskGlobal.h" #include "QskDialogWindow.h" class QskGraphic; @@ -30,7 +29,7 @@ class QSK_EXPORT QskInputWindow : public QskDialogWindow using Inherited = QskDialogWindow; -public: + public: QskInputWindow( QWindow* parent = nullptr ); ~QskInputWindow() override; @@ -58,19 +57,19 @@ class QSK_EXPORT QskInputWindow : public QskDialogWindow QskDialogButtonBox* buttonBox(); const QskDialogButtonBox* buttonBox() const; -public Q_SLOTS: + public Q_SLOTS: void setInfoText( const QString& ); -Q_SIGNALS: + Q_SIGNALS: void infoTextChanged(); void infoTextOptionsChanged(); void symbolSourceChanged(); -protected: + protected: void setSubWindow( QskInputSubWindow* ); QskInputSubWindow* subWindow() const; -private: + private: QskInputSubWindow* m_subWindow; }; diff --git a/src/dialogs/QskMessageSubWindow.cpp b/src/dialogs/QskMessageSubWindow.cpp index ddc90191d..741d10485 100644 --- a/src/dialogs/QskMessageSubWindow.cpp +++ b/src/dialogs/QskMessageSubWindow.cpp @@ -5,8 +5,8 @@ #include "QskMessageSubWindow.h" -QskMessageSubWindow::QskMessageSubWindow( QQuickItem* parent ): - Inherited( parent ) +QskMessageSubWindow::QskMessageSubWindow( QQuickItem* parent ) + : Inherited( parent ) { } diff --git a/src/dialogs/QskMessageSubWindow.h b/src/dialogs/QskMessageSubWindow.h index d68c466ae..71f6a0055 100644 --- a/src/dialogs/QskMessageSubWindow.h +++ b/src/dialogs/QskMessageSubWindow.h @@ -15,7 +15,7 @@ class QSK_EXPORT QskMessageSubWindow : public QskInputSubWindow using Inherited = QskInputSubWindow; -public: + public: QskMessageSubWindow( QQuickItem* parent = nullptr ); ~QskMessageSubWindow() override; }; diff --git a/src/dialogs/QskMessageWindow.cpp b/src/dialogs/QskMessageWindow.cpp index a8eb045e1..d4ba408cb 100644 --- a/src/dialogs/QskMessageWindow.cpp +++ b/src/dialogs/QskMessageWindow.cpp @@ -6,8 +6,8 @@ #include "QskMessageWindow.h" #include "QskMessageSubWindow.h" -QskMessageWindow::QskMessageWindow( QWindow* parent ): - Inherited( parent ) +QskMessageWindow::QskMessageWindow( QWindow* parent ) + : Inherited( parent ) { setSubWindow( new QskMessageSubWindow() ); } diff --git a/src/dialogs/QskMessageWindow.h b/src/dialogs/QskMessageWindow.h index 289524bc6..334238d76 100644 --- a/src/dialogs/QskMessageWindow.h +++ b/src/dialogs/QskMessageWindow.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskMessageWindow : public QskInputWindow using Inherited = QskInputWindow; -public: + public: QskMessageWindow( QWindow* parent = nullptr ); ~QskMessageWindow() override; }; diff --git a/src/dialogs/QskSelectionSubWindow.cpp b/src/dialogs/QskSelectionSubWindow.cpp index e09856ebb..ddd2d4ca3 100644 --- a/src/dialogs/QskSelectionSubWindow.cpp +++ b/src/dialogs/QskSelectionSubWindow.cpp @@ -10,19 +10,19 @@ namespace { class ListBox final : public QskSimpleListBox { - public: - ListBox( QskSelectionSubWindow* window ) + public: + ListBox( QskSelectionSubWindow* subWindow ) { setObjectName( QStringLiteral( "QskSelectionSubWindowListBox" ) ); - connect( this, SIGNAL( selectedRowChanged(int) ), - window, SIGNAL( selectedRowChanged(int) ) ); + connect( this, &QskSimpleListBox::selectedRowChanged, + subWindow, &QskSelectionSubWindow::selectedRowChanged ); - connect( this, SIGNAL( selectedEntryChanged(const QString&) ), - window, SIGNAL( selectedEntryChanged(const QString&) ) ); + connect( this, &QskSimpleListBox::selectedEntryChanged, + subWindow, &QskSelectionSubWindow::selectedEntryChanged ); - connect( this, SIGNAL( entriesChanged() ), - window, SIGNAL( entriesChanged() ) ); + connect( this, &QskSimpleListBox::entriesChanged, + subWindow, &QskSelectionSubWindow::entriesChanged ); } #if 1 @@ -35,8 +35,8 @@ namespace }; } -QskSelectionSubWindow::QskSelectionSubWindow( QQuickItem* parent ): - Inherited( parent ) +QskSelectionSubWindow::QskSelectionSubWindow( QQuickItem* parent ) + : Inherited( parent ) { setInputControl( new ListBox( this ) ); setStandardButtons( QskDialog::Ok | QskDialog::Cancel ); diff --git a/src/dialogs/QskSelectionSubWindow.h b/src/dialogs/QskSelectionSubWindow.h index 08e06b0e3..0d3b615e2 100644 --- a/src/dialogs/QskSelectionSubWindow.h +++ b/src/dialogs/QskSelectionSubWindow.h @@ -23,7 +23,7 @@ class QSK_EXPORT QskSelectionSubWindow : public QskInputSubWindow using Inherited = QskInputSubWindow; -public: + public: QskSelectionSubWindow( QQuickItem* parent = nullptr ); ~QskSelectionSubWindow() override; @@ -31,11 +31,11 @@ class QSK_EXPORT QskSelectionSubWindow : public QskInputSubWindow Q_INVOKABLE int selectedRow() const; Q_INVOKABLE QString selectedEntry() const; -public Q_SLOTS: + public Q_SLOTS: void setEntries( const QStringList& ); void setSelectedRow( int row ); -Q_SIGNALS: + Q_SIGNALS: void selectedRowChanged( int ); void selectedEntryChanged( const QString& ); void entriesChanged(); diff --git a/src/dialogs/QskSelectionWindow.cpp b/src/dialogs/QskSelectionWindow.cpp index 70d125c78..a798c63cc 100644 --- a/src/dialogs/QskSelectionWindow.cpp +++ b/src/dialogs/QskSelectionWindow.cpp @@ -6,8 +6,8 @@ #include "QskSelectionWindow.h" #include "QskSelectionSubWindow.h" -QskSelectionWindow::QskSelectionWindow( QWindow* parent ): - Inherited( parent ) +QskSelectionWindow::QskSelectionWindow( QWindow* parent ) + : Inherited( parent ) { auto subWindow = new QskSelectionSubWindow(); diff --git a/src/dialogs/QskSelectionWindow.h b/src/dialogs/QskSelectionWindow.h index 6328aa586..6153ad5e5 100644 --- a/src/dialogs/QskSelectionWindow.h +++ b/src/dialogs/QskSelectionWindow.h @@ -23,7 +23,7 @@ class QSK_EXPORT QskSelectionWindow : public QskInputWindow using Inherited = QskInputWindow; -public: + public: QskSelectionWindow( QWindow* parent = nullptr ); ~QskSelectionWindow() override; @@ -31,11 +31,11 @@ class QSK_EXPORT QskSelectionWindow : public QskInputWindow Q_INVOKABLE int selectedRow() const; Q_INVOKABLE QString selectedEntry() const; -public Q_SLOTS: + public Q_SLOTS: void setEntries( const QStringList& ); void setSelectedRow( int row ); -Q_SIGNALS: + Q_SIGNALS: void selectedRowChanged( int ); void selectedEntryChanged( const QString& ); void entriesChanged(); diff --git a/src/graphic/QskColorFilter.cpp b/src/graphic/QskColorFilter.cpp index cab4004d6..e9993b44b 100644 --- a/src/graphic/QskColorFilter.cpp +++ b/src/graphic/QskColorFilter.cpp @@ -6,8 +6,8 @@ #include "QskColorFilter.h" #include "QskRgbValue.h" -#include #include +#include #include static inline QRgb qskSubstitutedRgb( @@ -22,8 +22,8 @@ static inline QRgb qskSubstitutedRgb( { if ( rgb == s.first ) { - return ( s.second & QskRgbValue::ColorMask ) - | ( rgba & QskRgbValue::AlphaMask ); + return ( s.second & QskRgbValue::ColorMask ) | + ( rgba & QskRgbValue::AlphaMask ); } } @@ -49,10 +49,10 @@ static inline QBrush qskSubstitutedBrush( QGradientStops stops = gradient->stops(); for ( int i = 0; i < stops.size(); i++ ) { - const QColor c = qskSubstitutedColor( substitions, stops[i].second ); - if ( c != stops[i].second ) + const QColor c = qskSubstitutedColor( substitions, stops[ i ].second ); + if ( c != stops[ i ].second ) { - stops[i].second = c; + stops[ i ].second = c; isModified = true; } } @@ -79,7 +79,7 @@ static inline QBrush qskSubstitutedBrush( } static inline QskColorFilter qskInterpolatedFilter( - const QskColorFilter &from, const QskColorFilter &to, qreal progress ) + const QskColorFilter& from, const QskColorFilter& to, qreal progress ) { if ( progress <= 0.0 ) return from; @@ -155,9 +155,9 @@ void QskColorFilter::addColorSubstitution( QRgb from, QRgb to ) { for ( int i = 0; i < m_substitutions.size(); i++ ) { - if ( m_substitutions[i].first == from ) + if ( m_substitutions[ i ].first == from ) { - m_substitutions[i].second = to; + m_substitutions[ i ].second = to; return; } } @@ -215,8 +215,8 @@ QskColorFilter QskColorFilter::interpolated( return qskInterpolatedFilter( *this, other, progress ); } -QVariant QskColorFilter::interpolate( const QskColorFilter &from, - const QskColorFilter &to, qreal progress ) +QVariant QskColorFilter::interpolate( + const QskColorFilter& from, const QskColorFilter& to, qreal progress ) { return QVariant::fromValue( qskInterpolatedFilter( from, to, progress ) ); } @@ -234,11 +234,10 @@ QDebug operator<<( QDebug debug, const QskColorFilter& filter ) debug << "Filter" << '('; for ( int i = 0; i < s.count(); i++ ) - debug << '[' << s[i].first << "->" << s[i].second << "]"; + debug << '[' << s[ i ].first << "->" << s[ i ].second << "]"; debug << ')'; return debug; } #endif - diff --git a/src/graphic/QskColorFilter.h b/src/graphic/QskColorFilter.h index 359e43512..caed1a8bc 100644 --- a/src/graphic/QskColorFilter.h +++ b/src/graphic/QskColorFilter.h @@ -9,9 +9,9 @@ #include "QskGlobal.h" #include -#include -#include #include +#include +#include class QPen; class QBrush; @@ -20,7 +20,7 @@ class QDebug; class QSK_EXPORT QskColorFilter { -public: + public: QskColorFilter(); ~QskColorFilter(); @@ -48,10 +48,10 @@ class QSK_EXPORT QskColorFilter const QskColorFilter&, qreal value ) const; // can be registered by qRegisterAnimationInterpolator - static QVariant interpolate( const QskColorFilter &, - const QskColorFilter &, qreal progress ); + static QVariant interpolate( + const QskColorFilter&, const QskColorFilter&, qreal progress ); -private: + private: QVector< QPair< QRgb, QRgb > > m_substitutions; }; diff --git a/src/graphic/QskGraphic.cpp b/src/graphic/QskGraphic.cpp index 5a86384e6..a5ffb732b 100644 --- a/src/graphic/QskGraphic.cpp +++ b/src/graphic/QskGraphic.cpp @@ -4,17 +4,17 @@ *****************************************************************************/ #include "QskGraphic.h" -#include "QskGraphicPaintEngine.h" #include "QskColorFilter.h" +#include "QskGraphicPaintEngine.h" #include "QskPainterCommand.h" -#include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include static inline qreal qskDevicePixelRatio() { @@ -74,7 +74,7 @@ static inline void qskExecCommand( const QTransform& transform, const QTransform* initialTransform ) { - switch( cmd.type() ) + switch ( cmd.type() ) { case QskPainterCommand::Path: { @@ -217,18 +217,18 @@ namespace { class PathInfo { - public: - PathInfo(): - m_scalablePen( false ) + public: + PathInfo() + : m_scalablePen( false ) { // QVector needs a default constructor } PathInfo( const QRectF& pointRect, - const QRectF& boundingRect, bool scalablePen ): - m_pointRect( pointRect ), - m_boundingRect( boundingRect ), - m_scalablePen( scalablePen ) + const QRectF& boundingRect, bool scalablePen ) + : m_pointRect( pointRect ) + , m_boundingRect( boundingRect ) + , m_scalablePen( scalablePen ) { } @@ -271,8 +271,8 @@ namespace const qreal l = qAbs( pathRect.left() - p0.x() ); const qreal r = qAbs( pathRect.right() - p0.x() ); - const double w = 2.0 * qMin( l, r ) - * targetRect.width() / pathRect.width(); + const double w = 2.0 * qMin( l, r ) * + targetRect.width() / pathRect.width(); double sx; if ( scalePens && m_scalablePen ) @@ -302,8 +302,8 @@ namespace const qreal t = qAbs( pathRect.top() - p0.y() ); const qreal b = qAbs( pathRect.bottom() - p0.y() ); - const double h = 2.0 * qMin( t, b ) - * targetRect.height() / pathRect.height(); + const double h = 2.0 * qMin( t, b ) * + targetRect.height() / pathRect.height(); double sy; if ( scalePens && m_scalablePen ) @@ -322,7 +322,7 @@ namespace return sy; } - private: + private: QRectF m_pointRect; QRectF m_boundingRect; bool m_scalablePen; @@ -331,24 +331,24 @@ namespace class QskGraphic::PrivateData : public QSharedData { -public: - PrivateData(): - boundingRect( 0.0, 0.0, -1.0, -1.0 ), - pointRect( 0.0, 0.0, -1.0, -1.0 ), - hasRasterData( false ), - renderHints( 0 ) + public: + PrivateData() + : boundingRect( 0.0, 0.0, -1.0, -1.0 ) + , pointRect( 0.0, 0.0, -1.0, -1.0 ) + , hasRasterData( false ) + , renderHints( 0 ) { } - PrivateData( const PrivateData& other ): - QSharedData( other ), - defaultSize( other.defaultSize ), - commands( other.commands ), - pathInfos( other.pathInfos ), - boundingRect( other.boundingRect ), - pointRect( other.pointRect ), - hasRasterData( other.hasRasterData ), - renderHints( other.renderHints ) + PrivateData( const PrivateData& other ) + : QSharedData( other ) + , defaultSize( other.defaultSize ) + , commands( other.commands ) + , pathInfos( other.pathInfos ) + , boundingRect( other.boundingRect ) + , pointRect( other.pointRect ) + , hasRasterData( other.hasRasterData ) + , renderHints( other.renderHints ) { } @@ -358,8 +358,8 @@ class QskGraphic::PrivateData : public QSharedData inline bool operator==( const PrivateData& other ) const { - return ( renderHints == other.renderHints ) - && ( commands == other.commands ); + return ( renderHints == other.renderHints ) && + ( commands == other.commands ); } QSizeF defaultSize; @@ -373,22 +373,22 @@ class QskGraphic::PrivateData : public QSharedData uint renderHints : 4; }; -QskGraphic::QskGraphic(): - m_data( new PrivateData() ), - m_paintEngine( nullptr ) +QskGraphic::QskGraphic() + : m_data( new PrivateData() ) + , m_paintEngine( nullptr ) { } -QskGraphic::QskGraphic( const QskGraphic& other ): - QPaintDevice(), - m_data( other.m_data ), - m_paintEngine( nullptr ) +QskGraphic::QskGraphic( const QskGraphic& other ) + : QPaintDevice() + , m_data( other.m_data ) + , m_paintEngine( nullptr ) { } -QskGraphic::QskGraphic( QskGraphic&& other ): - m_data( std::move( other.m_data ) ), - m_paintEngine( nullptr ) +QskGraphic::QskGraphic( QskGraphic&& other ) + : m_data( std::move( other.m_data ) ) + , m_paintEngine( nullptr ) { } @@ -551,7 +551,7 @@ QRectF QskGraphic::scaledBoundingRect( qreal sx, qreal sy ) const QRectF rect = transform.mapRect( m_data->pointRect ); for ( int i = 0; i < m_data->pathInfos.size(); i++ ) - rect |= m_data->pathInfos[i].scaledBoundingRect( sx, sy, scalePens ); + rect |= m_data->pathInfos[ i ].scaledBoundingRect( sx, sy, scalePens ); return rect; } @@ -584,7 +584,7 @@ void QskGraphic::render( QPainter* painter ) const } void QskGraphic::render( QPainter* painter, - const QskColorFilter& colorFilter, QTransform *initialTransform ) const + const QskColorFilter& colorFilter, QTransform* initialTransform ) const { if ( isNull() ) return; @@ -599,7 +599,7 @@ void QskGraphic::render( QPainter* painter, for ( int i = 0; i < numCommands; i++ ) { - qskExecCommand( painter, commands[i], colorFilter, + qskExecCommand( painter, commands[ i ], colorFilter, renderHints, transform, initialTransform ); } @@ -638,7 +638,7 @@ void QskGraphic::render( QPainter* painter, const QRectF& rect, for ( int i = 0; i < m_data->pathInfos.size(); i++ ) { - const PathInfo info = m_data->pathInfos[i]; + const PathInfo info = m_data->pathInfos[ i ]; const double ssx = info.scaleFactorX( m_data->pointRect, rect, scalePens ); @@ -831,8 +831,8 @@ void QskGraphic::drawPath( const QPainterPath& path ) QRectF pointRect = scaledPath.boundingRect(); QRectF boundingRect = pointRect; - if ( painter->pen().style() != Qt::NoPen - && painter->pen().brush().style() != Qt::NoBrush ) + if ( painter->pen().style() != Qt::NoPen && + painter->pen().brush().style() != Qt::NoBrush ) { boundingRect = qskStrokedPathRect( painter, path ); } @@ -926,11 +926,14 @@ void QskGraphic::setCommands( const QVector< QskPainterCommand >& commands ) const QskPainterCommand* cmds = commands.constData(); + const QskColorFilter noFilter; + const QTransform noTransform; + QPainter painter( this ); for ( int i = 0; i < numCommands; i++ ) { - qskExecCommand( &painter, cmds[i], - QskColorFilter(), RenderHints(), QTransform(), NULL ); + qskExecCommand( &painter, cmds[ i ], + noFilter, RenderHints(), noTransform, nullptr ); } painter.end(); diff --git a/src/graphic/QskGraphic.h b/src/graphic/QskGraphic.h index 0232be22e..987fa52cf 100644 --- a/src/graphic/QskGraphic.h +++ b/src/graphic/QskGraphic.h @@ -8,8 +8,8 @@ #include "QskGlobal.h" -#include #include +#include #include class QskPainterCommand; @@ -23,7 +23,7 @@ class QPaintEngineState; class QSK_EXPORT QskGraphic : public QPaintDevice { -public: + public: enum RenderHint { RenderPensUnscaled = 0x1 @@ -54,28 +54,28 @@ class QSK_EXPORT QskGraphic : public QPaintDevice QTransform* initialTransform = nullptr ) const; void render( QPainter*, const QSizeF&, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; + Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; void render( QPainter*, const QPointF&, Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const; void render( QPainter*, const QRectF&, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; + Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; - void render( QPainter*, const QRectF&, const QskColorFilter& filter, - Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; + void render( QPainter*, const QRectF&, const QskColorFilter&, + Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const; QPixmap toPixmap( qreal devicePixelRatio = 0.0 ) const; QPixmap toPixmap( const QSize&, Qt::AspectRatioMode = Qt::IgnoreAspectRatio, - qreal devicePixelRatio = 0.0 ) const; + qreal devicePixelRatio = 0.0 ) const; QImage toImage( qreal devicePixelRatio = 0.0 ) const; QImage toImage( const QSize&, Qt::AspectRatioMode = Qt::IgnoreAspectRatio, - qreal devicePixelRatio = 0.0 ) const; + qreal devicePixelRatio = 0.0 ) const; QRectF scaledBoundingRect( qreal sx, qreal sy ) const; @@ -99,7 +99,7 @@ class QSK_EXPORT QskGraphic : public QPaintDevice static QskGraphic fromImage( const QImage& ); static QskGraphic fromPixmap( const QPixmap& ); -protected: + protected: friend class QskGraphicPaintEngine; virtual QSize sizeMetrics() const; @@ -114,7 +114,7 @@ class QSK_EXPORT QskGraphic : public QPaintDevice virtual void updateState( const QPaintEngineState& state ); -private: + private: void updateBoundingRect( const QRectF& ); void updateControlPointRect( const QRectF& ); diff --git a/src/graphic/QskGraphicIO.cpp b/src/graphic/QskGraphicIO.cpp index df7022330..06f9d2f9e 100644 --- a/src/graphic/QskGraphicIO.cpp +++ b/src/graphic/QskGraphicIO.cpp @@ -6,10 +6,12 @@ #include "QskGraphicIO.h" #include "QskGraphic.h" #include "QskPainterCommand.h" -#include + #include #include +#include #include + #include static const char qskMagicNumber[] = "QSKG"; @@ -221,7 +223,7 @@ QskGraphic QskGraphicIO::read( QIODevice* dev ) QDataStream stream( dev ); stream.setByteOrder( QDataStream::BigEndian ); - char magicNumber[4]; + char magicNumber[ 4 ]; stream.readRawData( magicNumber, 4 ); if ( memcmp( magicNumber, qskMagicNumber, 4 ) != 0 ) { @@ -240,7 +242,7 @@ QskGraphic QskGraphicIO::read( QIODevice* dev ) quint8 type; stream >> type; - switch( type ) + switch ( type ) { case QskPainterCommand::Path: { @@ -273,7 +275,6 @@ QskGraphic QskGraphicIO::read( QIODevice* dev ) return graphic; } - bool QskGraphicIO::write( const QskGraphic& graphic, const QString& fileName ) { QFile file( fileName ); @@ -298,7 +299,7 @@ bool QskGraphicIO::write( const QskGraphic& graphic, QIODevice* dev ) return false; QDataStream stream( dev ); - stream.setByteOrder( QDataStream::BigEndian ), + stream.setByteOrder( QDataStream::BigEndian ); stream.writeRawData( qskMagicNumber, 4 ); const int numCommands = graphic.commands().size(); @@ -308,27 +309,28 @@ bool QskGraphicIO::write( const QskGraphic& graphic, QIODevice* dev ) for ( int i = 0; i < numCommands; i++ ) { - stream << static_cast< quint8 > ( cmds[i].type() ); - switch( cmds[i].type() ) + stream << static_cast< quint8 >( cmds[ i ].type() ); + + switch ( cmds[ i ].type() ) { case QskPainterCommand::Path: { - qskWritePathData( *cmds[i].path(), stream ); + qskWritePathData( *cmds[ i ].path(), stream ); break; } case QskPainterCommand::Pixmap: { - qskWritePixmapData( *cmds[i].pixmapData(), stream ); + qskWritePixmapData( *cmds[ i ].pixmapData(), stream ); break; } case QskPainterCommand::Image: { - qskWriteImageData( *cmds[i].imageData(), stream ); + qskWriteImageData( *cmds[ i ].imageData(), stream ); break; } case QskPainterCommand::State: { - qskWriteStateData( *cmds[i].stateData(), stream ); + qskWriteStateData( *cmds[ i ].stateData(), stream ); break; } default: diff --git a/src/graphic/QskGraphicImageProvider.cpp b/src/graphic/QskGraphicImageProvider.cpp index 257c2f66e..b941d36be 100644 --- a/src/graphic/QskGraphicImageProvider.cpp +++ b/src/graphic/QskGraphicImageProvider.cpp @@ -4,14 +4,14 @@ *****************************************************************************/ #include "QskGraphicImageProvider.h" -#include "QskGraphicTextureFactory.h" -#include "QskGraphicProvider.h" #include "QskGraphic.h" +#include "QskGraphicProvider.h" +#include "QskGraphicTextureFactory.h" QskGraphicImageProvider::QskGraphicImageProvider( - const QString& providerId, ImageType type ): - QQuickImageProvider( type, 0 ), - m_providerId( providerId ) + const QString& providerId, ImageType type ) + : QQuickImageProvider( type, 0 ) + , m_providerId( providerId ) { } @@ -24,8 +24,8 @@ QString QskGraphicImageProvider::graphicProviderId() const return m_providerId; } -QImage QskGraphicImageProvider::requestImage( const QString& id, - QSize* size, const QSize& requestedSize ) +QImage QskGraphicImageProvider::requestImage( + const QString& id, QSize* size, const QSize& requestedSize ) { // mutex ??? @@ -39,7 +39,7 @@ QImage QskGraphicImageProvider::requestImage( const QString& id, return dummy; } - const QskGraphic* graphic = requestGraphic( id ); + const QskGraphic* graphic = requestGraphic( id ); if ( graphic == nullptr ) return QImage(); @@ -51,8 +51,8 @@ QImage QskGraphicImageProvider::requestImage( const QString& id, return graphic->toImage( sz, Qt::KeepAspectRatio ); } -QPixmap QskGraphicImageProvider::requestPixmap( const QString& id, - QSize* size, const QSize& requestedSize ) +QPixmap QskGraphicImageProvider::requestPixmap( + const QString& id, QSize* size, const QSize& requestedSize ) { if ( requestedSize.width() == 0 || requestedSize.height() == 0 ) { @@ -64,7 +64,7 @@ QPixmap QskGraphicImageProvider::requestPixmap( const QString& id, return dummy; } - const QskGraphic* graphic = requestGraphic( id ); + const QskGraphic* graphic = requestGraphic( id ); if ( graphic == nullptr ) return QPixmap(); @@ -82,7 +82,7 @@ QQuickTextureFactory* QskGraphicImageProvider::requestTexture( if ( requestedSize.width() == 0 || requestedSize.height() == 0 ) return nullptr; - const QskGraphic* graphic = requestGraphic( id ); + const QskGraphic* graphic = requestGraphic( id ); if ( graphic == nullptr ) return nullptr; @@ -119,7 +119,7 @@ QSize QskGraphicImageProvider::effectiveSize( { const auto f = requestedSize.width() / defaultSize.width(); return QSize( requestedSize.width(), - static_cast( f * defaultSize.height() ) ); + static_cast< int >( f * defaultSize.height() ) ); } if ( requestedSize.width() < 0 ) @@ -131,4 +131,3 @@ QSize QskGraphicImageProvider::effectiveSize( return defaultSize.toSize(); } - diff --git a/src/graphic/QskGraphicImageProvider.h b/src/graphic/QskGraphicImageProvider.h index 3feb0375f..23a68625c 100644 --- a/src/graphic/QskGraphicImageProvider.h +++ b/src/graphic/QskGraphicImageProvider.h @@ -13,7 +13,7 @@ class QskGraphic; class QSK_EXPORT QskGraphicImageProvider : public QQuickImageProvider { -public: + public: QskGraphicImageProvider( const QString& providerId, ImageType ); ~QskGraphicImageProvider() override; @@ -31,7 +31,7 @@ class QSK_EXPORT QskGraphicImageProvider : public QQuickImageProvider QString graphicProviderId() const; -protected: + protected: const QskGraphic* requestGraphic( const QString& id ) const; QSize effectiveSize( const QSize& requestedSize, const QSizeF& defaultSize ) const; diff --git a/src/graphic/QskGraphicPaintEngine.cpp b/src/graphic/QskGraphicPaintEngine.cpp index abe74e3df..19fa4117f 100644 --- a/src/graphic/QskGraphicPaintEngine.cpp +++ b/src/graphic/QskGraphicPaintEngine.cpp @@ -14,8 +14,8 @@ static inline QskGraphic* qskGraphic( QskGraphicPaintEngine* engine ) return static_cast< QskGraphic* >( engine->paintDevice() ); } -QskGraphicPaintEngine::QskGraphicPaintEngine(): - QPaintEngine( QPaintEngine::AllFeatures ) +QskGraphicPaintEngine::QskGraphicPaintEngine() + : QPaintEngine( QPaintEngine::AllFeatures ) { } @@ -35,7 +35,7 @@ bool QskGraphicPaintEngine::end() return true; } -QPaintEngine::Type QskGraphicPaintEngine::type () const +QPaintEngine::Type QskGraphicPaintEngine::type() const { return QPaintEngine::User; } @@ -54,8 +54,8 @@ void QskGraphicPaintEngine::drawPath( const QPainterPath& path ) graphic->drawPath( path ); } -void QskGraphicPaintEngine::drawPolygon( const QPointF* points, - int pointCount, PolygonDrawMode mode ) +void QskGraphicPaintEngine::drawPolygon( + const QPointF* points, int pointCount, PolygonDrawMode mode ) { QskGraphic* graphic = qskGraphic( this ); if ( graphic ) @@ -64,9 +64,9 @@ void QskGraphicPaintEngine::drawPolygon( const QPointF* points, if ( pointCount > 0 ) { - path.moveTo( points[0] ); + path.moveTo( points[ 0 ] ); for ( int i = 1; i < pointCount; i++ ) - path.lineTo( points[i] ); + path.lineTo( points[ i ] ); if ( mode != PolylineMode ) path.closeSubpath(); @@ -76,8 +76,8 @@ void QskGraphicPaintEngine::drawPolygon( const QPointF* points, } } -void QskGraphicPaintEngine::drawPolygon( const QPoint* points, - int pointCount, PolygonDrawMode mode ) +void QskGraphicPaintEngine::drawPolygon( + const QPoint* points, int pointCount, PolygonDrawMode mode ) { QskGraphic* graphic = qskGraphic( this ); if ( graphic ) @@ -86,9 +86,9 @@ void QskGraphicPaintEngine::drawPolygon( const QPoint* points, if ( pointCount > 0 ) { - path.moveTo( points[0] ); + path.moveTo( points[ 0 ] ); for ( int i = 1; i < pointCount; i++ ) - path.lineTo( points[i] ); + path.lineTo( points[ i ] ); if ( mode != PolylineMode ) path.closeSubpath(); @@ -107,11 +107,10 @@ void QskGraphicPaintEngine::drawPixmap( } void QskGraphicPaintEngine::drawImage( - const QRectF& rect, const QImage& image, const QRectF& subRect, - Qt::ImageConversionFlags flags ) + const QRectF& rect, const QImage& image, + const QRectF& subRect, Qt::ImageConversionFlags flags ) { QskGraphic* graphic = qskGraphic( this ); if ( graphic ) graphic->drawImage( rect, image, subRect, flags ); } - diff --git a/src/graphic/QskGraphicPaintEngine.h b/src/graphic/QskGraphicPaintEngine.h index d6883db09..96da3d6f6 100644 --- a/src/graphic/QskGraphicPaintEngine.h +++ b/src/graphic/QskGraphicPaintEngine.h @@ -11,14 +11,14 @@ class QSK_EXPORT QskGraphicPaintEngine final : public QPaintEngine { -public: + public: QskGraphicPaintEngine(); ~QskGraphicPaintEngine() override; bool begin( QPaintDevice* ) override; bool end() override; - Type type () const override; + Type type() const override; void updateState( const QPaintEngineState& state ) override; diff --git a/src/graphic/QskGraphicProvider.cpp b/src/graphic/QskGraphicProvider.cpp index cafabd633..04436d97c 100644 --- a/src/graphic/QskGraphicProvider.cpp +++ b/src/graphic/QskGraphicProvider.cpp @@ -8,19 +8,19 @@ #include "QskSetup.h" #include -#include #include +#include class QskGraphicProvider::PrivateData { -public: + public: // caching of graphics QCache< QString, const QskGraphic > cache; }; -QskGraphicProvider::QskGraphicProvider( QObject* parent ): - QObject( parent ), - m_data( new PrivateData() ) +QskGraphicProvider::QskGraphicProvider( QObject* parent ) + : QObject( parent ) + , m_data( new PrivateData() ) { } @@ -48,7 +48,7 @@ void QskGraphicProvider::clearCache() const QskGraphic* QskGraphicProvider::requestGraphic( const QString& id ) const { - const QskGraphic* graphic = m_data->cache.object( id ); + const QskGraphic* graphic = m_data->cache.object( id ); if ( graphic == nullptr ) { @@ -66,7 +66,8 @@ const QskGraphic* QskGraphicProvider::requestGraphic( const QString& id ) const return graphic; } -void Qsk::addGraphicProvider( const QString& providerId, QskGraphicProvider* provider ) +void Qsk::addGraphicProvider( + const QString& providerId, QskGraphicProvider* provider ) { qskSetup->addGraphicProvider( providerId, provider ); } @@ -85,21 +86,20 @@ QskGraphic Qsk::loadGraphic( const QUrl& url ) { static QskGraphic nullGraphic; - QString imageId = url.toString( QUrl::RemoveScheme - | QUrl::RemoveAuthority | QUrl::NormalizePathSegments ); + QString imageId = url.toString( QUrl::RemoveScheme | + QUrl::RemoveAuthority | QUrl::NormalizePathSegments ); if ( imageId.isEmpty() ) return nullGraphic; - if ( imageId[0] == '/' ) + if ( imageId[ 0 ] == '/' ) imageId = imageId.mid( 1 ); const QString providerId = url.host(); - + const QskGraphic* graphic = nullptr; - const QskGraphicProvider* provider = qskSetup->graphicProvider( providerId ); - if ( provider ) + if ( const auto provider = qskSetup->graphicProvider( providerId ) ) graphic = provider->requestGraphic( imageId ); return graphic ? *graphic : nullGraphic; diff --git a/src/graphic/QskGraphicProvider.h b/src/graphic/QskGraphicProvider.h index 96cd0608a..59d0bb84d 100644 --- a/src/graphic/QskGraphicProvider.h +++ b/src/graphic/QskGraphicProvider.h @@ -13,9 +13,9 @@ class QskGraphic; class QUrl; -class QSK_EXPORT QskGraphicProvider: public QObject +class QSK_EXPORT QskGraphicProvider : public QObject { -public: + public: QskGraphicProvider( QObject* parent = nullptr ); ~QskGraphicProvider() override; @@ -26,7 +26,7 @@ class QSK_EXPORT QskGraphicProvider: public QObject const QskGraphic* requestGraphic( const QString& id ) const; -protected: + protected: virtual const QskGraphic* loadGraphic( const QString& id ) const = 0; class PrivateData; diff --git a/src/graphic/QskGraphicProviderMap.cpp b/src/graphic/QskGraphicProviderMap.cpp index 781f4abb0..25b76ba98 100644 --- a/src/graphic/QskGraphicProviderMap.cpp +++ b/src/graphic/QskGraphicProviderMap.cpp @@ -6,9 +6,9 @@ #include "QskGraphicProviderMap.h" #include "QskGraphicProvider.h" -#include #include #include +#include static inline QString qskKey( const QString& providerId ) { @@ -17,12 +17,12 @@ static inline QString qskKey( const QString& providerId ) class QskGraphicProviderMap::PrivateData { -public: + public: QHash< QString, QPointer< QskGraphicProvider > > hashTab; }; -QskGraphicProviderMap::QskGraphicProviderMap(): - m_data( new PrivateData() ) +QskGraphicProviderMap::QskGraphicProviderMap() + : m_data( new PrivateData() ) { } diff --git a/src/graphic/QskGraphicProviderMap.h b/src/graphic/QskGraphicProviderMap.h index 9a5c9dda2..6d9ec38f7 100644 --- a/src/graphic/QskGraphicProviderMap.h +++ b/src/graphic/QskGraphicProviderMap.h @@ -14,7 +14,7 @@ class QString; class QSK_EXPORT QskGraphicProviderMap { -public: + public: QskGraphicProviderMap(); ~QskGraphicProviderMap(); @@ -29,7 +29,7 @@ class QSK_EXPORT QskGraphicProviderMap int size() const; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/graphic/QskGraphicTextureFactory.cpp b/src/graphic/QskGraphicTextureFactory.cpp index 18faac79c..c1b5faf95 100644 --- a/src/graphic/QskGraphicTextureFactory.cpp +++ b/src/graphic/QskGraphicTextureFactory.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include // VS2012+ disable keyword macroizing unless _ALLOW_KEYWORD_MACROS is set #ifdef _MSC_VER @@ -68,8 +68,8 @@ static uint qskTextureFBO( const QRect targetRect( sourceRect.x(), sourceRect.bottom() + 1, sourceRect.width(), -sourceRect.height() ); - QOpenGLFramebufferObject::blitFramebuffer( &fbo, sourceRect, - &multisampledFbo, targetRect ); + QOpenGLFramebufferObject::blitFramebuffer( + &fbo, sourceRect, &multisampledFbo, targetRect ); return fbo.takeTexture(); } @@ -105,9 +105,9 @@ QskGraphicTextureFactory::QskGraphicTextureFactory() } QskGraphicTextureFactory::QskGraphicTextureFactory( - const QskGraphic& graphic, const QSize& size ): - m_graphic( graphic ), - m_size( size ) + const QskGraphic& graphic, const QSize& size ) + : m_graphic( graphic ) + , m_size( size ) { } diff --git a/src/graphic/QskGraphicTextureFactory.h b/src/graphic/QskGraphicTextureFactory.h index 06a303524..4e79dc1af 100644 --- a/src/graphic/QskGraphicTextureFactory.h +++ b/src/graphic/QskGraphicTextureFactory.h @@ -6,14 +6,13 @@ #ifndef QSK_GRAPHIC_TEXTURE_FACTORY_H #define QSK_GRAPHIC_TEXTURE_FACTORY_H -#include "QskGlobal.h" -#include "QskGraphic.h" #include "QskColorFilter.h" +#include "QskGraphic.h" #include class QSK_EXPORT QskGraphicTextureFactory : public QQuickTextureFactory { -public: + public: enum RenderMode { Raster, @@ -40,11 +39,10 @@ class QSK_EXPORT QskGraphicTextureFactory : public QQuickTextureFactory QImage image() const override; - static uint createTexture( - RenderMode, const QRect& rect, Qt::AspectRatioMode, - const QskGraphic& , const QskColorFilter& ); + static uint createTexture( RenderMode, const QRect& rect, + Qt::AspectRatioMode, const QskGraphic&, const QskColorFilter& ); -private: + private: QskGraphic m_graphic; QskColorFilter m_colorFilter; QSize m_size; @@ -71,7 +69,6 @@ inline const QskColorFilter& QskGraphicTextureFactory::colorFilter() const return m_colorFilter; } - inline void QskGraphicTextureFactory::setSize( const QSize& size ) { m_size = size; diff --git a/src/graphic/QskPainterCommand.cpp b/src/graphic/QskPainterCommand.cpp index 8dbe222c4..7150a897d 100644 --- a/src/graphic/QskPainterCommand.cpp +++ b/src/graphic/QskPainterCommand.cpp @@ -5,20 +5,20 @@ #include "QskPainterCommand.h" -QskPainterCommand::QskPainterCommand(): - m_type( Invalid ) +QskPainterCommand::QskPainterCommand() + : m_type( Invalid ) { } -QskPainterCommand::QskPainterCommand( const QPainterPath& path ): - m_type( Path ) +QskPainterCommand::QskPainterCommand( const QPainterPath& path ) + : m_type( Path ) { m_path = new QPainterPath( path ); } QskPainterCommand::QskPainterCommand( const QRectF& rect, - const QPixmap& pixmap, const QRectF& subRect ): - m_type( Pixmap ) + const QPixmap& pixmap, const QRectF& subRect ) + : m_type( Pixmap ) { m_pixmapData = new PixmapData(); m_pixmapData->rect = rect; @@ -27,9 +27,8 @@ QskPainterCommand::QskPainterCommand( const QRectF& rect, } QskPainterCommand::QskPainterCommand( const QRectF& rect, - const QImage& image, const QRectF& subRect, - Qt::ImageConversionFlags flags ): - m_type( Image ) + const QImage& image, const QRectF& subRect, Qt::ImageConversionFlags flags ) + : m_type( Image ) { m_imageData = new ImageData(); m_imageData->rect = rect; @@ -38,14 +37,14 @@ QskPainterCommand::QskPainterCommand( const QRectF& rect, m_imageData->flags = flags; } -QskPainterCommand::QskPainterCommand( const QskPainterCommand::StateData& data ): - m_type( State ) +QskPainterCommand::QskPainterCommand( const QskPainterCommand::StateData& data ) + : m_type( State ) { m_stateData = new StateData( data ); } -QskPainterCommand::QskPainterCommand( const QPaintEngineState& state ): - m_type( State ) +QskPainterCommand::QskPainterCommand( const QPaintEngineState& state ) + : m_type( State ) { m_stateData = new StateData(); @@ -120,7 +119,7 @@ bool QskPainterCommand::operator==( const QskPainterCommand& other ) const if ( m_type != other.m_type ) return false; - switch( m_type ) + switch ( m_type ) { case Path: { @@ -168,8 +167,8 @@ bool QskPainterCommand::operator==( const QskPainterCommand& other ) const if ( sd.flags & QPaintEngine::DirtyBackground ) { - if ( sd.backgroundMode != osd.backgroundMode - || sd.backgroundBrush != osd.backgroundBrush ) + if ( sd.backgroundMode != osd.backgroundMode || + sd.backgroundBrush != osd.backgroundBrush ) { return false; } @@ -189,8 +188,8 @@ bool QskPainterCommand::operator==( const QskPainterCommand& other ) const if ( sd.flags & QPaintEngine::DirtyClipRegion ) { - if ( sd.clipRegion != osd.clipRegion - || sd.clipOperation != osd.clipOperation ) + if ( sd.clipRegion != osd.clipRegion || + sd.clipOperation != osd.clipOperation ) { return false; } @@ -198,8 +197,8 @@ bool QskPainterCommand::operator==( const QskPainterCommand& other ) const if ( sd.flags & QPaintEngine::DirtyClipPath ) { - if ( sd.clipPath != osd.clipPath - || sd.clipOperation != osd.clipOperation ) + if ( sd.clipPath != osd.clipPath || + sd.clipOperation != osd.clipOperation ) { return false; } @@ -236,7 +235,7 @@ void QskPainterCommand::copy( const QskPainterCommand& other ) { m_type = other.m_type; - switch( other.m_type ) + switch ( other.m_type ) { case Path: { @@ -265,7 +264,7 @@ void QskPainterCommand::copy( const QskPainterCommand& other ) void QskPainterCommand::reset() { - switch( m_type ) + switch ( m_type ) { case Path: { diff --git a/src/graphic/QskPainterCommand.h b/src/graphic/QskPainterCommand.h index ab78c615c..8f5b327ec 100644 --- a/src/graphic/QskPainterCommand.h +++ b/src/graphic/QskPainterCommand.h @@ -7,14 +7,15 @@ #define QSK_PAINTER_COMMAND_H #include "QskGlobal.h" -#include -#include + #include +#include #include +#include class QSK_EXPORT QskPainterCommand { -public: + public: //! Type of the paint command enum Type { @@ -54,12 +55,12 @@ class QSK_EXPORT QskPainterCommand //! Attributes of a state change class StateData { - public: - StateData(): - backgroundMode( Qt::TransparentMode ), - clipOperation( Qt::NoClip ), - isClipEnabled( false ), - compositionMode( QPainter::CompositionMode_SourceOver ) + public: + StateData() + : backgroundMode( Qt::TransparentMode ) + , clipOperation( Qt::NoClip ) + , isClipEnabled( false ) + , compositionMode( QPainter::CompositionMode_SourceOver ) { } @@ -106,7 +107,6 @@ class QSK_EXPORT QskPainterCommand bool operator==( const QskPainterCommand& other ) const; bool operator!=( const QskPainterCommand& other ) const; - Type type() const; QPainterPath* path(); @@ -121,7 +121,7 @@ class QSK_EXPORT QskPainterCommand StateData* stateData(); const StateData* stateData() const; -private: + private: void copy( const QskPainterCommand& ); void reset(); diff --git a/src/graphic/QskStandardSymbol.cpp b/src/graphic/QskStandardSymbol.cpp index 6153f0191..81f6824c0 100644 --- a/src/graphic/QskStandardSymbol.cpp +++ b/src/graphic/QskStandardSymbol.cpp @@ -66,7 +66,7 @@ static void qskCriticalGraphic( QPainter* painter ) path.addRect( 5, 22, 30, 5 ); painter->setPen( Qt::NoPen ); - //painter->setBrush( QColor( Qt::black ) ); + // painter->setBrush( QColor( Qt::black ) ); painter->setBrush( QColor( Qt::red ) ); painter->drawPath( path ); } @@ -192,12 +192,12 @@ QskGraphic QskStandardSymbol::graphic( Type symbolType ) if ( symbolType < 0 || symbolType >= SymbolTypeCount ) return QskGraphic(); - if ( graphics[symbolType].isNull() ) + if ( graphics[ symbolType ].isNull() ) { - QPainter painter( &graphics[symbolType] ); + QPainter painter( &graphics[ symbolType ] ); painter.setRenderHint( QPainter::Antialiasing, true ); - switch( symbolType ) + switch ( symbolType ) { case QskStandardSymbol::Ok: { @@ -233,7 +233,7 @@ QskGraphic QskStandardSymbol::graphic( Type symbolType ) } } - return graphics[symbolType]; + return graphics[ symbolType ]; } #include "moc_QskStandardSymbol.cpp" diff --git a/src/graphic/QskStandardSymbol.h b/src/graphic/QskStandardSymbol.h index 5b2a8a0c2..fa0124236 100644 --- a/src/graphic/QskStandardSymbol.h +++ b/src/graphic/QskStandardSymbol.h @@ -15,7 +15,7 @@ class QskStandardSymbol { Q_GADGET -public: + public: enum Type { NoSymbol = -1, diff --git a/src/inputpanel/QskInputContext.cpp b/src/inputpanel/QskInputContext.cpp index 5d9c78be3..91573f0bd 100644 --- a/src/inputpanel/QskInputContext.cpp +++ b/src/inputpanel/QskInputContext.cpp @@ -7,30 +7,30 @@ #include "QskInputPanel.h" #include "QskInputPanelBox.h" -#include "QskLinearBox.h" #include "QskDialog.h" +#include "QskLinearBox.h" #include "QskPopup.h" -#include "QskWindow.h" #include "QskQuick.h" +#include "QskWindow.h" -#include #include #include +#include QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END -#include #include +#include namespace { class Panel final : public QskInputPanel { - public: - Panel( QQuickItem* parent = nullptr ): - QskInputPanel( parent ) + public: + Panel( QQuickItem* parent = nullptr ) + : QskInputPanel( parent ) { setAutoLayoutChildren( true ); @@ -68,13 +68,13 @@ namespace m_box->setPrediction( prediction ); } - private: + private: QskInputPanelBox* m_box; }; class Channel { - public: + public: // item receiving the input QPointer< QQuickItem > item; @@ -88,7 +88,7 @@ namespace class ChannelTable { - public: + public: inline Channel* currentChannel() const { const auto object = QGuiApplication::focusObject(); @@ -126,10 +126,9 @@ namespace { if ( const auto panel = it.value().panel ) { - if ( ( item == panel ) - || qskIsAncestorOf( panel, item ) ) + if ( ( item == panel ) || qskIsAncestorOf( panel, item ) ) { - return const_cast< Channel*>( &it.value() ); + return const_cast< Channel* >( &it.value() ); } } } @@ -147,7 +146,7 @@ namespace m_map.remove( window ); } - private: + private: QMap< const QQuickWindow*, Channel > m_map; }; } @@ -194,8 +193,7 @@ QskInputContext* QskInputContext::instance() class QskInputContext::PrivateData { -public: - + public: inline QskInputPanel* createPanel( QskInputContext* context ) const { QskInputPanel* panel = nullptr; @@ -229,7 +227,7 @@ class QskInputContext::PrivateData const auto alignment = panel->alignment() & Qt::AlignVertical_Mask; popup->setOverlay( alignment == Qt::AlignVCenter ); - switch( alignment ) + switch ( alignment ) { case Qt::AlignTop: { @@ -257,11 +255,11 @@ class QskInputContext::PrivateData auto window = new QskWindow(); window->setFlags( window->flags() & Qt::Dialog ); - //window->setModality( Qt::ApplicationModal ); + // window->setModality( Qt::ApplicationModal ); window->setAutoLayoutChildren( true ); - #if 0 +#if 0 window->setFlags( Qt::Tool | Qt::WindowDoesNotAcceptFocus ); - #endif +#endif panel->setParentItem( window->contentItem() ); @@ -272,8 +270,8 @@ class QskInputContext::PrivateData QPointer< QskInputContextFactory > factory; }; -QskInputContext::QskInputContext(): - m_data( new PrivateData() ) +QskInputContext::QskInputContext() + : m_data( new PrivateData() ) { setObjectName( "InputContext" ); } @@ -342,7 +340,7 @@ QRectF QskInputContext::panelRect() const As we can have more than panel at the same time we better don't return any geometry */ - + return QRectF(); } @@ -368,7 +366,7 @@ void QskInputContext::showPanel( const QQuickItem* item ) auto panel = m_data->createPanel( this ); auto channel = m_data->channels.insert( item->window() ); - channel->item = const_cast< QQuickItem*>( item ); + channel->item = const_cast< QQuickItem* >( item ); channel->panel = panel; if ( QskDialog::instance()->policy() == QskDialog::TopLevelWindow ) @@ -478,8 +476,8 @@ void QskInputContext::commitPrediction( bool ) */ } -QskInputContextFactory::QskInputContextFactory( QObject* parent ): - QObject( parent ) +QskInputContextFactory::QskInputContextFactory( QObject* parent ) + : QObject( parent ) { } diff --git a/src/inputpanel/QskInputContext.h b/src/inputpanel/QskInputContext.h index 3a37d8249..d10b1e1f0 100644 --- a/src/inputpanel/QskInputContext.h +++ b/src/inputpanel/QskInputContext.h @@ -8,9 +8,9 @@ #include "QskGlobal.h" -#include -#include #include +#include +#include #include @@ -25,7 +25,7 @@ class QSK_EXPORT QskInputContextFactory : public QObject { Q_OBJECT -public: + public: QskInputContextFactory( QObject* parent = nullptr ); ~QskInputContextFactory() override; @@ -39,7 +39,7 @@ class QSK_EXPORT QskInputContext : public QObject using Inherited = QObject; -public: + public: QskInputContext(); virtual ~QskInputContext(); @@ -60,15 +60,15 @@ class QSK_EXPORT QskInputContext : public QObject QskTextPredictor* textPredictor( const QLocale& locale ); -Q_SIGNALS: + Q_SIGNALS: void activeChanged(); void panelRectChanged(); -protected: + protected: virtual void showPanel( const QQuickItem* ); virtual void hidePanel( const QQuickItem* ); -private: + private: friend class QskPlatformInputContext; // called from QskPlatformInputContext diff --git a/src/inputpanel/QskInputPanel.cpp b/src/inputpanel/QskInputPanel.cpp index fae0a65a4..bedff8f3c 100644 --- a/src/inputpanel/QskInputPanel.cpp +++ b/src/inputpanel/QskInputPanel.cpp @@ -26,8 +26,8 @@ static inline bool qskUsePrediction( Qt::InputMethodHints hints ) return ( hints & mask ) == 0; } -static inline void qskSendText( QQuickItem* receiver, - const QString& text, bool isFinal ) +static inline void qskSendText( + QQuickItem* receiver, const QString& text, bool isFinal ) { if ( receiver == nullptr ) return; @@ -76,7 +76,6 @@ static inline void qskSendReplaceText( QQuickItem* receiver, const QString& text qskSendText( receiver, text, true ); } - static inline void qskSendKey( QQuickItem* receiver, int key ) { if ( receiver == nullptr ) @@ -93,7 +92,7 @@ namespace { class KeyProcessor { - public: + public: struct Result { int key = 0; @@ -151,7 +150,7 @@ namespace } } - if( !( inputHints & Qt::ImhMultiLine ) ) + if ( !( inputHints & Qt::ImhMultiLine ) ) { result.key = Qt::Key_Return; return result; @@ -163,7 +162,7 @@ namespace { if ( predictor ) { - if ( !m_preedit.isEmpty() && spaceLeft) + if ( !m_preedit.isEmpty() && spaceLeft ) { m_preedit += keyString( key ); m_preedit = m_preedit.left( spaceLeft ); @@ -223,7 +222,7 @@ namespace m_preedit.clear(); } - private: + private: inline QString keyString( int keyCode ) const { // Special case entry codes here, else default to the symbol @@ -256,7 +255,7 @@ namespace class QskInputPanel::PrivateData { -public: + public: KeyProcessor keyProcessor; QPointer< QQuickItem > inputItem; @@ -267,9 +266,9 @@ class QskInputPanel::PrivateData bool hasPredictorLocale = false; }; -QskInputPanel::QskInputPanel( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskInputPanel::QskInputPanel( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setAutoLayoutChildren( true ); initSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Constrained ); @@ -317,7 +316,7 @@ void QskInputPanel::attachInputItem( QQuickItem* item ) if ( inputProxy() ) { - /* + /* Hiding the cursor in item. We use postEvent so that everything on the item is done, when receiving the event. @@ -357,13 +356,13 @@ void QskInputPanel::updateInputPanel( Qt::InputMethodQueries queries ) setLocale( event.value( Qt::ImPreferredLanguage ).toLocale() ); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 ) if ( queries & Qt::ImInputItemClipRectangle ) { /* Could be used to move the panel, so that it does not hide the item. - */ + */ } #endif } @@ -497,7 +496,7 @@ void QskInputPanel::commitKey( int key ) const auto result = m_data->keyProcessor.processKey( key, m_data->inputHints, predictor, spaceLeft ); - switch( result.key ) + switch ( result.key ) { case 0: { diff --git a/src/inputpanel/QskInputPanel.h b/src/inputpanel/QskInputPanel.h index 50f062537..ecaf01fd1 100644 --- a/src/inputpanel/QskInputPanel.h +++ b/src/inputpanel/QskInputPanel.h @@ -6,7 +6,6 @@ #ifndef QSK_INPUT_PANEL_H #define QSK_INPUT_PANEL_H -#include "QskGlobal.h" #include "QskControl.h" #include @@ -20,7 +19,7 @@ class QSK_EXPORT QskInputPanel : public QskControl using Inherited = QskControl; -public: + public: QskInputPanel( QQuickItem* parent = nullptr ); ~QskInputPanel() override; @@ -32,23 +31,23 @@ class QSK_EXPORT QskInputPanel : public QskControl virtual Qt::Alignment alignment() const; -public Q_SLOTS: + public Q_SLOTS: void commitKey( int keyCode ); void commitPredictiveText( int index ); -Q_SIGNALS: + Q_SIGNALS: void keySelected( int keyCode ); void predictiveTextSelected( int ); -public Q_SLOTS: + public Q_SLOTS: virtual void setPrompt( const QString& ); virtual void setPrediction( const QStringList& ); virtual void setPredictionEnabled( bool ); -protected: + protected: virtual void attachItem( QQuickItem* ) = 0; -private: + private: void resetPredictor( const QLocale& ); void updatePrediction(); diff --git a/src/inputpanel/QskInputPanelBox.cpp b/src/inputpanel/QskInputPanelBox.cpp index e726f8608..043cd97fd 100644 --- a/src/inputpanel/QskInputPanelBox.cpp +++ b/src/inputpanel/QskInputPanelBox.cpp @@ -4,23 +4,24 @@ *****************************************************************************/ #include "QskInputPanelBox.h" -#include "QskVirtualKeyboard.h" #include "QskInputPredictionBar.h" +#include "QskLinearBox.h" #include "QskTextInput.h" #include "QskTextLabel.h" -#include "QskLinearBox.h" +#include "QskVirtualKeyboard.h" -#include #include +#include namespace { class TextInputProxy final : public QskTextInput { - public: - TextInputProxy( QskInputPanelBox* panelBox, QQuickItem* parentItem = nullptr ): - QskTextInput( parentItem ), - m_panelBox( panelBox ) + public: + TextInputProxy( QskInputPanelBox* panelBox, + QQuickItem* parentItem = nullptr ) + : QskTextInput( parentItem ) + , m_panelBox( panelBox ) { setObjectName( "InputBoxProxy" ); setFocusPolicy( Qt::NoFocus ); @@ -38,7 +39,7 @@ namespace return subControl; } - protected: + protected: void focusInEvent( QFocusEvent* ) override { } @@ -47,7 +48,7 @@ namespace { } - private: + private: QskInputPanelBox* m_panelBox; }; } @@ -58,7 +59,7 @@ QSK_SUBCONTROL( QskInputPanelBox, ProxyText ) class QskInputPanelBox::PrivateData { -public: + public: QPointer< QQuickItem > inputItem; QskLinearBox* layout; @@ -70,9 +71,9 @@ class QskInputPanelBox::PrivateData QskInputPanelBox::PanelHints panelHints = QskInputPanelBox::InputProxy; }; -QskInputPanelBox::QskInputPanelBox( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskInputPanelBox::QskInputPanelBox( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setAutoLayoutChildren( true ); @@ -128,8 +129,8 @@ void QskInputPanelBox::setPanelHints( PanelHints hints ) m_data->inputProxy->setVisible( hints & QskInputPanelBox::InputProxy ); m_data->predictionBar->setVisible( hints & QskInputPanelBox::Prediction ); - const bool showPrompt = ( hints & QskInputPanelBox::InputProxy ) - && !m_data->prompt->text().isEmpty(); + const bool showPrompt = ( hints & QskInputPanelBox::InputProxy ) && + !m_data->prompt->text().isEmpty(); m_data->prompt->setVisible( showPrompt ); @@ -174,15 +175,15 @@ QQuickItem* QskInputPanelBox::inputProxy() const QskAspect::Subcontrol QskInputPanelBox::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const { - if( subControl == QskBox::Panel ) + if ( subControl == QskBox::Panel ) return QskInputPanelBox::Panel; #if 1 // TODO ... - if( subControl == QskInputPanelBox::ProxyPanel ) + if ( subControl == QskInputPanelBox::ProxyPanel ) return QskTextInput::Panel; - if( subControl == QskInputPanelBox::ProxyText ) + if ( subControl == QskInputPanelBox::ProxyText ) return QskTextInput::Text; #endif @@ -218,7 +219,7 @@ void QskInputPanelBox::keyPressEvent( QKeyEvent* event ) { int keyCode = -1; - switch( event->key() ) + switch ( event->key() ) { case Qt::Key_Return: case Qt::Key_Escape: @@ -232,7 +233,7 @@ void QskInputPanelBox::keyPressEvent( QKeyEvent* event ) const auto text = event->text(); if ( !text.isEmpty() ) - keyCode = text[0].unicode(); + keyCode = text[ 0 ].unicode(); else keyCode = event->key(); } diff --git a/src/inputpanel/QskInputPanelBox.h b/src/inputpanel/QskInputPanelBox.h index 665675db4..a72cb3b4a 100644 --- a/src/inputpanel/QskInputPanelBox.h +++ b/src/inputpanel/QskInputPanelBox.h @@ -26,7 +26,7 @@ class QSK_EXPORT QskInputPanelBox : public QskBox Q_PROPERTY( QString inputPrompt READ inputPrompt WRITE setInputPrompt NOTIFY inputPromptChanged ) -public: + public: QSK_SUBCONTROLS( Panel, ProxyPanel, ProxyText ) enum PanelHint @@ -56,21 +56,21 @@ class QSK_EXPORT QskInputPanelBox : public QskBox QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol ) const override; -Q_SIGNALS: + Q_SIGNALS: void panelHintsChanged(); void inputPromptChanged( const QString& ); void keySelected( int keyCode ); void predictiveTextSelected( int ); -public Q_SLOTS: + public Q_SLOTS: void setInputPrompt( const QString& ); void setPrediction( const QStringList& ); -protected: + protected: void keyPressEvent( QKeyEvent* ) override; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/inputpanel/QskInputPredictionBar.cpp b/src/inputpanel/QskInputPredictionBar.cpp index 033056d52..941133756 100644 --- a/src/inputpanel/QskInputPredictionBar.cpp +++ b/src/inputpanel/QskInputPredictionBar.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskInputPredictionBar.h" -#include "QskPushButton.h" #include "QskLinearBox.h" +#include "QskPushButton.h" #include "QskTextOptions.h" #include @@ -19,9 +19,9 @@ namespace { class Button final : public QskPushButton { - public: - Button( QQuickItem* parent ): - QskPushButton( parent ) + public: + Button( QQuickItem* parent ) + : QskPushButton( parent ) { QskTextOptions options; options.setElideMode( Qt::ElideRight ); @@ -45,10 +45,10 @@ namespace QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol subControl ) const override { - if( subControl == QskPushButton::Panel ) + if ( subControl == QskPushButton::Panel ) return QskInputPredictionBar::ButtonPanel; - if( subControl == QskPushButton::Text ) + if ( subControl == QskPushButton::Text ) return QskInputPredictionBar::ButtonText; return subControl; @@ -58,7 +58,7 @@ namespace class QskInputPredictionBar::PrivateData { -public: + public: QskLinearBox* layoutBox; QStringList candidates; @@ -66,16 +66,16 @@ class QskInputPredictionBar::PrivateData const int buttonCount = 12; }; -QskInputPredictionBar::QskInputPredictionBar( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData ) +QskInputPredictionBar::QskInputPredictionBar( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData ) { setAutoLayoutChildren( true ); initSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Fixed ); m_data->layoutBox = new QskLinearBox( Qt::Horizontal, this ); - for( int i = 0; i < m_data->buttonCount; i++ ) + for ( int i = 0; i < m_data->buttonCount; i++ ) { auto button = new Button( m_data->layoutBox ); button->setVisible( false ); @@ -99,7 +99,7 @@ QskInputPredictionBar::~QskInputPredictionBar() QskAspect::Subcontrol QskInputPredictionBar::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const { - if( subControl == QskBox::Panel ) + if ( subControl == QskBox::Panel ) return QskInputPredictionBar::Panel; return subControl; @@ -107,7 +107,7 @@ QskAspect::Subcontrol QskInputPredictionBar::effectiveSubcontrol( void QskInputPredictionBar::setPrediction( const QStringList& candidates ) { - if( m_data->candidates != candidates ) + if ( m_data->candidates != candidates ) { m_data->candidates = candidates; setScrollOffset( 0 ); @@ -128,29 +128,29 @@ void QskInputPredictionBar::setScrollOffset( int offset ) const bool continueLeft = m_data->scrollOffset > 0; const bool continueRight = ( candidateCount - m_data->scrollOffset ) > count; - for( int i = 0; i < count; i++ ) + for ( int i = 0; i < count; i++ ) { auto button = qobject_cast< QskPushButton* >( m_data->layoutBox->itemAtIndex( i ) ); - if( continueLeft && i == 0 ) + if ( continueLeft && i == 0 ) { button->setText( QChar( 0x2B05 ) ); } - else if( continueRight && ( i == m_data->buttonCount - 1 ) ) + else if ( continueRight && ( i == m_data->buttonCount - 1 ) ) { button->setText( QChar( 0x27A1 ) ); } else { const int index = i + m_data->scrollOffset; - button->setText( m_data->candidates[index] ); + button->setText( m_data->candidates[ index ] ); } button->setVisible( true ); } - for( int i = count; i < m_data->buttonCount; ++i ) + for ( int i = count; i < m_data->buttonCount; ++i ) m_data->layoutBox->itemAtIndex( i )->setVisible( false ); } diff --git a/src/inputpanel/QskInputPredictionBar.h b/src/inputpanel/QskInputPredictionBar.h index 599aa0d20..42616e041 100644 --- a/src/inputpanel/QskInputPredictionBar.h +++ b/src/inputpanel/QskInputPredictionBar.h @@ -14,7 +14,7 @@ class QSK_EXPORT QskInputPredictionBar : public QskBox using Inherited = QskBox; -public: + public: QSK_SUBCONTROLS( Panel, ButtonPanel, ButtonText ) QskInputPredictionBar( QQuickItem* parent = nullptr ); @@ -25,13 +25,13 @@ class QSK_EXPORT QskInputPredictionBar : public QskBox QStringList candidates() const; -Q_SIGNALS: + Q_SIGNALS: void predictiveTextSelected( int ); -public Q_SLOTS: + public Q_SLOTS: void setPrediction( const QStringList& ); -private: + private: void buttonClicked(); void setScrollOffset( int ); diff --git a/src/inputpanel/QskTextPredictor.cpp b/src/inputpanel/QskTextPredictor.cpp index 50f76f984..d66fb0052 100644 --- a/src/inputpanel/QskTextPredictor.cpp +++ b/src/inputpanel/QskTextPredictor.cpp @@ -5,10 +5,9 @@ #include "QskTextPredictor.h" -QskTextPredictor::QskTextPredictor( - Attributes attributes, QObject* parent ): - QObject( parent ), - m_attributes( attributes ) +QskTextPredictor::QskTextPredictor( Attributes attributes, QObject* parent ) + : QObject( parent ) + , m_attributes( attributes ) { } @@ -28,7 +27,7 @@ QStringList QskTextPredictor::candidates() const QStringList candidates; candidates.reserve( count ); - for( int i = 0; i < count; i++ ) + for ( int i = 0; i < count; i++ ) candidates += candidate( i ); return candidates; diff --git a/src/inputpanel/QskTextPredictor.h b/src/inputpanel/QskTextPredictor.h index 660b2944b..e3c849ef6 100644 --- a/src/inputpanel/QskTextPredictor.h +++ b/src/inputpanel/QskTextPredictor.h @@ -17,7 +17,7 @@ class QSK_EXPORT QskTextPredictor : public QObject { Q_OBJECT -public: + public: enum Attribute { Words = 1 << 0 @@ -38,13 +38,13 @@ class QSK_EXPORT QskTextPredictor : public QObject Attributes attributes() const; -Q_SIGNALS: + Q_SIGNALS: void predictionChanged(); -protected: + protected: QskTextPredictor( Attributes, QObject* ); -private: + private: const Attributes m_attributes; }; diff --git a/src/inputpanel/QskVirtualKeyboard.cpp b/src/inputpanel/QskVirtualKeyboard.cpp index 1e8b42e93..6160ab7b9 100644 --- a/src/inputpanel/QskVirtualKeyboard.cpp +++ b/src/inputpanel/QskVirtualKeyboard.cpp @@ -8,8 +8,8 @@ #include "QskTextOptions.h" #include -#include #include +#include namespace { @@ -23,11 +23,11 @@ namespace class Button final : public QskPushButton { - public: - Button( int row, int column, QskVirtualKeyboard* parent ): - QskPushButton( parent ), - m_row( row ), - m_column( column ) + public: + Button( int row, int column, QskVirtualKeyboard* parent ) + : QskPushButton( parent ) + , m_row( row ) + , m_column( column ) { QskTextOptions options; options.setFontSizeMode( QskTextOptions::VerticalFit ); @@ -39,7 +39,7 @@ namespace QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol subControl ) const override { - auto keyBoard = static_cast< const QskVirtualKeyboard*>( parent() ); + auto keyBoard = static_cast< const QskVirtualKeyboard* >( parent() ); if ( subControl == QskPushButton::Panel ) return keyBoard->effectiveSubcontrol( QskVirtualKeyboard::ButtonPanel ); @@ -53,7 +53,7 @@ namespace int row() const { return m_row; } int column() const { return m_column; } - private: + private: const int m_row; const int m_column; }; @@ -94,7 +94,7 @@ struct QskVirtualKeyboardLayouts Layout zh; // Chinese }; -#define LOWER(x) int(x + 32) // Convert an uppercase key to lowercase +#define LOWER( x ) int( x + 32 ) // Convert an uppercase key to lowercase static constexpr const QskVirtualKeyboardLayouts qskKeyboardLayouts = { #include "QskVirtualKeyboardLayouts.cpp" @@ -103,7 +103,7 @@ static constexpr const QskVirtualKeyboardLayouts qskKeyboardLayouts = static qreal qskKeyStretch( int key ) { - switch( key ) + switch ( key ) { case Qt::Key_Backspace: case Qt::Key_Shift: @@ -128,9 +128,9 @@ static qreal qskRowStretch( const KeyRow& keyRow ) { qreal stretch = 0; - for( const auto& key : keyRow ) + for ( const auto& key : keyRow ) { - if( !key ) + if ( !key ) { continue; } @@ -138,7 +138,7 @@ static qreal qskRowStretch( const KeyRow& keyRow ) stretch += qskKeyStretch( key ); } - if( stretch == 0.0 ) + if ( stretch == 0.0 ) { stretch = ColumnCount; } @@ -149,7 +149,7 @@ static qreal qskRowStretch( const KeyRow& keyRow ) static QString qskTextForKey( int key ) { // Special cases - switch( key ) + switch ( key ) { case Qt::Key_Backspace: case Qt::Key_Muhenkan: @@ -189,9 +189,12 @@ static QString qskTextForKey( int key ) static bool qskIsAutorepeat( int key ) { - return ( key != Qt::Key_Return && key != Qt::Key_Enter - && key != Qt::Key_Shift && key != Qt::Key_CapsLock - && key != Qt::Key_Mode_switch ); + return ( + ( key != Qt::Key_Return ) && + ( key != Qt::Key_Enter ) && + ( key != Qt::Key_Shift ) && + ( key != Qt::Key_CapsLock ) && + ( key != Qt::Key_Mode_switch ) ); } static QSet< int > qskKeyCodes( const QskVirtualKeyboardLayouts::Layout& layout ) @@ -203,7 +206,7 @@ static QSet< int > qskKeyCodes( const QskVirtualKeyboardLayouts::Layout& layout { const auto& keyCodes = layout[ mode ]; - for( int row = 0; row < RowCount; row++ ) + for ( int row = 0; row < RowCount; row++ ) { const auto& keys = keyCodes.data[ row ]; @@ -221,7 +224,7 @@ QSK_SUBCONTROL( QskVirtualKeyboard, ButtonText ) class QskVirtualKeyboard::PrivateData { -public: + public: const QskVirtualKeyboardLayouts::Layout* currentLayout = nullptr; QskVirtualKeyboard::Mode mode = QskVirtualKeyboard::LowercaseMode; @@ -229,9 +232,9 @@ class QskVirtualKeyboard::PrivateData QSet< int > keyCodes; }; -QskVirtualKeyboard::QskVirtualKeyboard( QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData ) +QskVirtualKeyboard::QskVirtualKeyboard( QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData ) { setPolishOnResize( true ); initSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Constrained ); @@ -272,15 +275,15 @@ QskVirtualKeyboard::~QskVirtualKeyboard() QskAspect::Subcontrol QskVirtualKeyboard::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const { - if( subControl == QskBox::Panel ) + if ( subControl == QskBox::Panel ) return QskVirtualKeyboard::Panel; #if 1 // TODO ... - if( subControl == QskVirtualKeyboard::ButtonPanel ) + if ( subControl == QskVirtualKeyboard::ButtonPanel ) return QskPushButton::Panel; - if( subControl == QskVirtualKeyboard::ButtonText ) + if ( subControl == QskVirtualKeyboard::ButtonText ) return QskPushButton::Text; #endif @@ -347,7 +350,7 @@ qreal QskVirtualKeyboard::widthForHeight( qreal height ) const void QskVirtualKeyboard::updateLayout() { const auto r = layoutRect(); - if( r.isEmpty() ) + if ( r.isEmpty() ) return; const auto spacing = metric( Panel | QskAspect::Spacing ); @@ -359,7 +362,7 @@ void QskVirtualKeyboard::updateLayout() qreal yPos = r.top(); - for( int row = 0; row < RowCount; row++ ) + for ( int row = 0; row < RowCount; row++ ) { const auto& keys = keyCodes.data[ row ]; @@ -418,7 +421,7 @@ void QskVirtualKeyboard::buttonPressed() const int key = keyCodes.data[ button->row() ][ button->column() ]; // Mode-switching keys - switch( key ) + switch ( key ) { case Qt::Key_CapsLock: case Qt::Key_Kana_Lock: @@ -438,7 +441,7 @@ void QskVirtualKeyboard::buttonPressed() { setMode( static_cast< QskVirtualKeyboard::Mode >( m_data->mode ? ( ( m_data->mode + 1 ) % QskVirtualKeyboard::ModeCount ) - : SpecialCharacterMode ) ); + : SpecialCharacterMode ) ); break; } @@ -453,7 +456,7 @@ void QskVirtualKeyboard::updateLocale( const QLocale& locale ) { const QskVirtualKeyboardLayouts::Layout* newLayout = nullptr; - switch( locale.language() ) + switch ( locale.language() ) { case QLocale::Bulgarian: newLayout = &qskKeyboardLayouts.bg; @@ -477,7 +480,7 @@ void QskVirtualKeyboard::updateLocale( const QLocale& locale ) case QLocale::English: { - switch( locale.country() ) + switch ( locale.country() ) { case QLocale::Canada: case QLocale::UnitedStates: @@ -538,7 +541,7 @@ void QskVirtualKeyboard::updateLocale( const QLocale& locale ) newLayout = &qskKeyboardLayouts.ro; break; - case QLocale::Russia: + case QLocale::Russian: newLayout = &qskKeyboardLayouts.ru; break; diff --git a/src/inputpanel/QskVirtualKeyboard.h b/src/inputpanel/QskVirtualKeyboard.h index 62ffe429e..c81ffb1c6 100644 --- a/src/inputpanel/QskVirtualKeyboard.h +++ b/src/inputpanel/QskVirtualKeyboard.h @@ -14,7 +14,7 @@ class QSK_EXPORT QskVirtualKeyboard : public QskBox using Inherited = QskBox; -public: + public: QSK_SUBCONTROLS( Panel, ButtonPanel, ButtonText ) enum Mode @@ -45,14 +45,14 @@ class QSK_EXPORT QskVirtualKeyboard : public QskBox bool hasKey( int keyCode ) const; -Q_SIGNALS: + Q_SIGNALS: void modeChanged( Mode ); void keySelected( int keyCode ); -protected: + protected: void updateLayout() override; -private: + private: void buttonPressed(); class PrivateData; diff --git a/src/layouts/QskGridBox.cpp b/src/layouts/QskGridBox.cpp index 34607ca98..c357a378e 100644 --- a/src/layouts/QskGridBox.cpp +++ b/src/layouts/QskGridBox.cpp @@ -4,15 +4,15 @@ *****************************************************************************/ #include "QskGridBox.h" -#include "QskLayoutItem.h" #include "QskLayoutEngine.h" +#include "QskLayoutItem.h" class QskGridBox::PrivateData { -public: - PrivateData(): - isExpanding( false ), - unlimitedSpanned( 0 ) + public: + PrivateData() + : isExpanding( false ) + , unlimitedSpanned( 0 ) { } @@ -20,9 +20,9 @@ class QskGridBox::PrivateData unsigned int unlimitedSpanned; }; -QskGridBox::QskGridBox( QQuickItem* parent ): - QskLayout( parent ), - m_data( new PrivateData() ) +QskGridBox::QskGridBox( QQuickItem* parent ) + : QskLayout( parent ) + , m_data( new PrivateData() ) { } @@ -34,8 +34,7 @@ void QskGridBox::addItem( QQuickItem* item, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment ) { - QskLayoutItem* layoutItem = - new QskLayoutItem( item, row, column, rowSpan, columnSpan ); + auto layoutItem = new QskLayoutItem( item, row, column, rowSpan, columnSpan ); layoutItem->setAlignment( alignment ); const int index = itemCount(); // position and index doesn't match @@ -169,8 +168,8 @@ void QskGridBox::layoutItemRemoved( QskLayoutItem* layoutItem, int index ) if ( m_data->unlimitedSpanned > 0 ) engine.adjustSpans( cells.height(), cells.width() ); - engine.removeRows( cells.width(), numPendingColumns, Qt::Horizontal ); - engine.removeRows( cells.height(), numPendingRows, Qt::Vertical ); + engine.removeRows( cells.width(), numPendingColumns, Qt::Horizontal ); + engine.removeRows( cells.height(), numPendingRows, Qt::Vertical ); } } @@ -431,13 +430,13 @@ QSizeF QskGridBox::contentsSizeHint() const if ( !isActive() ) return QSizeF( -1, -1 ); - if ( itemCount() == 0 ) + if ( itemCount() == 0 ) return QSizeF( 0, 0 ); - + return engine().sizeHint( Qt::PreferredSize ); } -qreal QskGridBox::heightForWidth( qreal width ) const +qreal QskGridBox::heightForWidth( qreal width ) const { const QSizeF constraint( width, -1 ); return engine().sizeHint( Qt::PreferredSize, constraint ).height(); diff --git a/src/layouts/QskGridBox.h b/src/layouts/QskGridBox.h index 26ef57d62..7f43592fd 100644 --- a/src/layouts/QskGridBox.h +++ b/src/layouts/QskGridBox.h @@ -23,7 +23,7 @@ class QSK_EXPORT QskGridBox : public QskLayout using Inherited = QskLayout; -public: + public: explicit QskGridBox( QQuickItem* parent = nullptr ); ~QskGridBox() override; @@ -119,16 +119,16 @@ class QSK_EXPORT QskGridBox : public QskLayout QSizeF contentsSizeHint() const override; -Q_SIGNALS: + Q_SIGNALS: void verticalSpacingChanged(); void horizontalSpacingChanged(); -protected: + protected: void setupLayoutItem( QskLayoutItem*, int index ) override; void layoutItemInserted( QskLayoutItem*, int index ) override; void layoutItemRemoved( QskLayoutItem*, int index ) override; -private: + private: void setRowSizeHint( Qt::SizeHint which, int row, qreal size, Qt::Orientation orientation ); diff --git a/src/layouts/QskIndexedLayoutBox.cpp b/src/layouts/QskIndexedLayoutBox.cpp index 3441ca1fa..af70d3393 100644 --- a/src/layouts/QskIndexedLayoutBox.cpp +++ b/src/layouts/QskIndexedLayoutBox.cpp @@ -4,17 +4,17 @@ *****************************************************************************/ #include "QskIndexedLayoutBox.h" -#include "QskQuick.h" #include "QskLayoutEngine.h" #include "QskLayoutItem.h" +#include "QskQuick.h" class QskIndexedLayoutBox::PrivateData { -public: - PrivateData(): - autoAddChildren( true ), - blockChildAdded( false ), - defaultAlignment( Qt::AlignLeft | Qt::AlignVCenter ) + public: + PrivateData() + : autoAddChildren( true ) + , blockChildAdded( false ) + , defaultAlignment( Qt::AlignLeft | Qt::AlignVCenter ) { } @@ -36,9 +36,9 @@ class QskIndexedLayoutBox::PrivateData Qt::Alignment defaultAlignment; }; -QskIndexedLayoutBox::QskIndexedLayoutBox( QQuickItem* parent ): - QskLayout( parent ), - m_data( new PrivateData() ) +QskIndexedLayoutBox::QskIndexedLayoutBox( QQuickItem* parent ) + : QskLayout( parent ) + , m_data( new PrivateData() ) { // classBegin/componentComplete -> setActive( false/true ) ? } @@ -110,7 +110,7 @@ void QskIndexedLayoutBox::insertItem( if ( item->parentItem() == this ) { const int oldIndex = indexOf( item ); - if ( oldIndex >= 0 ) + if ( oldIndex >= 0 ) { // the item has been inserted before @@ -199,7 +199,7 @@ void QskIndexedLayoutBox::insertLayoutItem( void QskIndexedLayoutBox::itemChange( QQuickItem::ItemChange change, const QQuickItem::ItemChangeData& value ) { - switch( change ) + switch ( change ) { case QQuickItem::ItemChildAddedChange: { diff --git a/src/layouts/QskIndexedLayoutBox.h b/src/layouts/QskIndexedLayoutBox.h index 4a6411245..8dfb2ffe0 100644 --- a/src/layouts/QskIndexedLayoutBox.h +++ b/src/layouts/QskIndexedLayoutBox.h @@ -21,7 +21,7 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskLayout using Inherited = QskLayout; -public: + public: explicit QskIndexedLayoutBox( QQuickItem* parent = nullptr ); ~QskIndexedLayoutBox() override; @@ -31,10 +31,11 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskLayout void setDefaultAlignment( Qt::Alignment ); Qt::Alignment defaultAlignment() const; - Q_INVOKABLE void addItem( QQuickItem*, Qt::Alignment alignment = Qt::Alignment() ); + Q_INVOKABLE void addItem( + QQuickItem*, Qt::Alignment alignment = Qt::Alignment() ); - Q_INVOKABLE void insertItem( int index, QQuickItem*, - Qt::Alignment alignment = Qt::Alignment() ); + Q_INVOKABLE void insertItem( + int index, QQuickItem*, Qt::Alignment alignment = Qt::Alignment() ); Q_INVOKABLE void setAlignment( int index, Qt::Alignment ); Q_INVOKABLE Qt::Alignment alignment( int index ) const; @@ -45,15 +46,15 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskLayout Q_INVOKABLE void setAlignment( QQuickItem*, Qt::Alignment ); Q_INVOKABLE Qt::Alignment alignment( QQuickItem* ) const; -Q_SIGNALS: + Q_SIGNALS: void autoAddChildrenChanged(); void defaultAlignmentChanged(); -protected: + protected: void itemChange( ItemChange, const ItemChangeData& ) override; void insertLayoutItem( QskLayoutItem*, int index ); -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/layouts/QskLayout.cpp b/src/layouts/QskLayout.cpp index 53edc76d2..900a82da5 100644 --- a/src/layouts/QskLayout.cpp +++ b/src/layouts/QskLayout.cpp @@ -4,15 +4,15 @@ *****************************************************************************/ #include "QskLayout.h" -#include "QskLayoutItem.h" -#include "QskLayoutEngine.h" #include "QskEvent.h" +#include "QskLayoutEngine.h" +#include "QskLayoutItem.h" class QskLayout::PrivateData { -public: - PrivateData(): - isActive( true ) + public: + PrivateData() + : isActive( true ) { } @@ -21,9 +21,9 @@ class QskLayout::PrivateData QskLayoutEngine engine; }; -QskLayout::QskLayout( QQuickItem* parent ): - QskControl( parent ), - m_data( new PrivateData() ) +QskLayout::QskLayout( QQuickItem* parent ) + : QskControl( parent ) + , m_data( new PrivateData() ) { } @@ -294,7 +294,7 @@ void QskLayout::itemChange( ItemChange change, const ItemChangeData& value ) { Inherited::itemChange( change, value ); - switch( change ) + switch ( change ) { case ItemChildRemovedChange: { @@ -320,7 +320,7 @@ void QskLayout::itemChange( ItemChange change, const ItemChangeData& value ) bool QskLayout::event( QEvent* event ) { - switch( event->type() ) + switch ( event->type() ) { case QEvent::LayoutRequest: { diff --git a/src/layouts/QskLayout.h b/src/layouts/QskLayout.h index 77f90ff09..e66bd5000 100644 --- a/src/layouts/QskLayout.h +++ b/src/layouts/QskLayout.h @@ -6,7 +6,6 @@ #ifndef QSK_LAYOUT_H #define QSK_LAYOUT_H -#include "QskGlobal.h" #include "QskControl.h" class QskLayoutEngine; @@ -19,7 +18,7 @@ class QSK_EXPORT QskLayout : public QskControl using Inherited = QskControl; -public: + public: explicit QskLayout( QQuickItem* parent = 0 ); ~QskLayout() override; @@ -40,11 +39,11 @@ class QSK_EXPORT QskLayout : public QskControl void adjustItem( const QQuickItem* ); void adjustItemAt( int index ); -public Q_SLOTS: + public Q_SLOTS: void activate(); void invalidate(); -protected: + protected: bool event( QEvent* ) override; void geometryChangeEvent( QskGeometryChangeEvent* ) override; @@ -64,7 +63,7 @@ public Q_SLOTS: virtual QRectF alignedLayoutRect( const QRectF& ) const; -private: + private: class PrivateData; std::unique_ptr< PrivateData > m_data; }; diff --git a/src/layouts/QskLayoutConstraint.cpp b/src/layouts/QskLayoutConstraint.cpp index 6f626cf76..009761311 100644 --- a/src/layouts/QskLayoutConstraint.cpp +++ b/src/layouts/QskLayoutConstraint.cpp @@ -7,8 +7,8 @@ #include "QskControl.h" #include "QskSizePolicy.h" -static inline qreal qskHintFor( const QQuickItem* item, - const char* method, qreal widthOrHeight ) +static inline qreal qskHintFor( + const QQuickItem* item, const char* method, qreal widthOrHeight ) { if ( item->metaObject()->indexOfMethod( method ) >= 0 ) { @@ -83,11 +83,11 @@ QSizeF QskLayoutConstraint::effectiveConstraint( "maximumSize" }; - const QVariant v = item->property( properties[whichHint] ); + const QVariant v = item->property( properties[ whichHint ] ); if ( v.canConvert( QMetaType::QSizeF ) ) constraint = v.toSizeF(); - switch( whichHint ) + switch ( whichHint ) { case Qt::MinimumSize: { @@ -141,5 +141,3 @@ QskSizePolicy QskLayoutConstraint::sizePolicy( const QQuickItem* item ) return QskSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred ); } - - diff --git a/src/layouts/QskLayoutEngine.cpp b/src/layouts/QskLayoutEngine.cpp index 1db8e9f66..605690c80 100644 --- a/src/layouts/QskLayoutEngine.cpp +++ b/src/layouts/QskLayoutEngine.cpp @@ -13,7 +13,7 @@ static inline bool qskIsColliding( { for ( int col = item->firstColumn(); col <= item->lastColumn(); col++ ) { - if ( engine->itemAt(row, col) ) + if ( engine->itemAt( row, col ) ) return true; } } @@ -25,7 +25,7 @@ namespace { class MessageHandler { - public: + public: MessageHandler() { m_defaultHandler = qInstallMessageHandler( suppressWarning ); @@ -36,7 +36,7 @@ namespace qInstallMessageHandler( m_defaultHandler ); } - private: + private: static void suppressWarning( QtMsgType type, const QMessageLogContext& context, const QString& message ) { @@ -54,7 +54,7 @@ namespace class LayoutStyleInfo final : public QAbstractLayoutStyleInfo { - public: + public: LayoutStyleInfo() { } @@ -78,8 +78,8 @@ namespace }; } -QskLayoutEngine::QskLayoutEngine(): - QGridLayoutEngine( Qt::AlignVCenter, true /*snapToPixelGrid*/ ) +QskLayoutEngine::QskLayoutEngine() + : QGridLayoutEngine( Qt::AlignVCenter, true /*snapToPixelGrid*/ ) { } @@ -124,7 +124,7 @@ QskLayoutItem* QskLayoutEngine::layoutItemAt( int index ) const if ( index < 0 || index >= q_items.count() ) return nullptr; - return static_cast< QskLayoutItem* >( q_items[index] ); + return static_cast< QskLayoutItem* >( q_items[ index ] ); } QskLayoutItem* QskLayoutEngine::layoutItemAt( int row, int column ) const @@ -151,7 +151,7 @@ int QskLayoutEngine::indexOf( const QQuickItem* item ) const for ( int i = q_items.count() - 1; i >= 0; --i ) { - const auto layoutItem = static_cast< const QskLayoutItem* >( q_items[i] ); + const auto layoutItem = static_cast< const QskLayoutItem* >( q_items[ i ] ); if ( layoutItem->item() == item ) return i; } @@ -220,4 +220,3 @@ void QskLayoutEngine::adjustSpans( int numRows, int numColumns ) } #endif - diff --git a/src/layouts/QskLayoutEngine.h b/src/layouts/QskLayoutEngine.h index 797f736b0..0c3083e16 100644 --- a/src/layouts/QskLayoutEngine.h +++ b/src/layouts/QskLayoutEngine.h @@ -17,13 +17,12 @@ QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END - class QskLayoutItem; class QQuickItem; class QskLayoutEngine : public QGridLayoutEngine { -public: + public: QskLayoutEngine(); ~QskLayoutEngine(); diff --git a/src/layouts/QskLayoutItem.cpp b/src/layouts/QskLayoutItem.cpp index a37a1a46d..8134a3fcb 100644 --- a/src/layouts/QskLayoutItem.cpp +++ b/src/layouts/QskLayoutItem.cpp @@ -5,32 +5,31 @@ #include "QskLayoutItem.h" #include "QskControl.h" -#include "QskQuick.h" #include "QskLayoutConstraint.h" +#include "QskQuick.h" -QskLayoutItem::QskLayoutItem( QQuickItem* item, - int row, int column, int rowSpan, int columnSpan ): - Inherited( row, column, qMax( rowSpan, 1 ), qMax( columnSpan, 1 ), Qt::Alignment() ), - m_isGeometryDirty( false ), - m_isStretchable( false ), - m_retainSizeWhenHidden( false ), - m_unlimitedRowSpan( rowSpan <= 0 ), - m_unlimitedColumnSpan( columnSpan <= 0 ), - m_updateMode( UpdateWhenVisible ), - m_item( item ) +QskLayoutItem::QskLayoutItem( QQuickItem* item, int row, int column, int rowSpan, int columnSpan ) + : Inherited( row, column, qMax( rowSpan, 1 ), qMax( columnSpan, 1 ), Qt::Alignment() ) + , m_isGeometryDirty( false ) + , m_isStretchable( false ) + , m_retainSizeWhenHidden( false ) + , m_unlimitedRowSpan( rowSpan <= 0 ) + , m_unlimitedColumnSpan( columnSpan <= 0 ) + , m_updateMode( UpdateWhenVisible ) + , m_item( item ) { } -QskLayoutItem::QskLayoutItem( const QSizeF& size, int stretch, int row, int column ): - Inherited( row, column, 1, 1, Qt::Alignment() ), - m_isGeometryDirty( false ), - m_isStretchable( stretch > 0 ), - m_retainSizeWhenHidden( false ), - m_unlimitedRowSpan( false ), - m_unlimitedColumnSpan( false ), - m_updateMode( UpdateWhenVisible ), - m_spacingHint( size ), - m_item( nullptr ) +QskLayoutItem::QskLayoutItem( const QSizeF& size, int stretch, int row, int column ) + : Inherited( row, column, 1, 1, Qt::Alignment() ) + , m_isGeometryDirty( false ) + , m_isStretchable( stretch > 0 ) + , m_retainSizeWhenHidden( false ) + , m_unlimitedRowSpan( false ) + , m_unlimitedColumnSpan( false ) + , m_updateMode( UpdateWhenVisible ) + , m_spacingHint( size ) + , m_item( nullptr ) { } @@ -152,7 +151,7 @@ void QskLayoutItem::setGeometry( const QRectF& rect ) if ( m_item == nullptr ) return; - if( m_updateMode == UpdateNone ) + if ( m_updateMode == UpdateNone ) { if ( !m_isGeometryDirty ) m_isGeometryDirty = ( rect != qskItemGeometry( m_item ) ); diff --git a/src/layouts/QskLayoutItem.h b/src/layouts/QskLayoutItem.h index 4b4550464..5913140be 100644 --- a/src/layouts/QskLayoutItem.h +++ b/src/layouts/QskLayoutItem.h @@ -23,7 +23,7 @@ class QskLayoutItem : public QGridLayoutItem { using Inherited = QGridLayoutItem; -public: + public: enum UpdateMode { UpdateNone, @@ -65,7 +65,7 @@ class QskLayoutItem : public QGridLayoutItem bool hasUnlimitedSpan() const; bool hasUnlimitedSpan( Qt::Orientation orientation ) const; -private: + private: bool m_isGeometryDirty : 1; bool m_isStretchable : 1; bool m_retainSizeWhenHidden : 1; diff --git a/src/layouts/QskLinearBox.cpp b/src/layouts/QskLinearBox.cpp index 58523aec9..277e8c2ed 100644 --- a/src/layouts/QskLinearBox.cpp +++ b/src/layouts/QskLinearBox.cpp @@ -4,18 +4,18 @@ *****************************************************************************/ #include "QskLinearBox.h" -#include "QskLayoutItem.h" #include "QskLayoutEngine.h" +#include "QskLayoutItem.h" #include class QskLinearBox::PrivateData { -public: - PrivateData( Qt::Orientation orient, uint dim ): - dimension( dim ), - orientation( orient ), - transposeAlignments( false ) + public: + PrivateData( Qt::Orientation orient, uint dim ) + : dimension( dim ) + , orientation( orient ) + , transposeAlignments( false ) { } @@ -26,20 +26,20 @@ class QskLinearBox::PrivateData bool transposeAlignments : 1; }; -QskLinearBox::QskLinearBox( QQuickItem* parent ): - QskLinearBox( Qt::Horizontal, std::numeric_limits< uint >::max(), parent ) +QskLinearBox::QskLinearBox( QQuickItem* parent ) + : QskLinearBox( Qt::Horizontal, std::numeric_limits< uint >::max(), parent ) { } -QskLinearBox::QskLinearBox( Qt::Orientation orientation, QQuickItem* parent ): - QskLinearBox( orientation, std::numeric_limits< uint >::max(), parent ) +QskLinearBox::QskLinearBox( Qt::Orientation orientation, QQuickItem* parent ) + : QskLinearBox( orientation, std::numeric_limits< uint >::max(), parent ) { } -QskLinearBox::QskLinearBox( Qt::Orientation orientation, - uint dimension, QQuickItem* parent ): - Inherited( parent ), - m_data ( new PrivateData( orientation, dimension ) ) +QskLinearBox::QskLinearBox( + Qt::Orientation orientation, uint dimension, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData( orientation, dimension ) ) { } @@ -327,17 +327,17 @@ QSizeF QskLinearBox::contentsSizeHint() const if ( itemCount() == 0 ) return QSizeF( 0, 0 ); - + return engine().sizeHint( Qt::PreferredSize ); } -qreal QskLinearBox::heightForWidth( qreal width ) const +qreal QskLinearBox::heightForWidth( qreal width ) const { const QSizeF constraint( width, -1 ); return engine().sizeHint( Qt::PreferredSize, constraint ).height(); } -qreal QskLinearBox::widthForHeight( qreal height ) const +qreal QskLinearBox::widthForHeight( qreal height ) const { const QSizeF constraint( -1, height ); return engine().sizeHint( Qt::PreferredSize, constraint ).width(); @@ -383,8 +383,8 @@ void QskLinearBox::rearrange() QskLayoutItem* layoutItem = engine().layoutItemAt( i ); - if ( layoutItem->firstRow( Qt::Horizontal ) != col - || layoutItem->firstRow( Qt::Vertical ) != row ) + if ( layoutItem->firstRow( Qt::Horizontal ) != col || + layoutItem->firstRow( Qt::Vertical ) != row ) { engine().removeItem( layoutItem ); diff --git a/src/layouts/QskLinearBox.h b/src/layouts/QskLinearBox.h index f27168cc5..0ac7ff7c9 100644 --- a/src/layouts/QskLinearBox.h +++ b/src/layouts/QskLinearBox.h @@ -28,7 +28,7 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox using Inherited = QskIndexedLayoutBox; -public: + public: explicit QskLinearBox( QQuickItem* parent = nullptr ); explicit QskLinearBox( Qt::Orientation, QQuickItem* parent = nullptr ); @@ -92,19 +92,19 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox Q_INVOKABLE int columnStretchFactor( int column ) const; #endif -public Q_SLOTS: + public Q_SLOTS: void transpose(); -Q_SIGNALS: + Q_SIGNALS: void orientationChanged(); void dimensionChanged(); void spacingChanged(); void extraSpacingAtChanged(); -protected: + protected: QRectF alignedLayoutRect( const QRectF& ) const override; -private: + private: void setupLayoutItem( QskLayoutItem*, int index ) override; void layoutItemInserted( QskLayoutItem*, int index ) override; void layoutItemRemoved( QskLayoutItem*, int index ) override; diff --git a/src/layouts/QskStackBox.cpp b/src/layouts/QskStackBox.cpp index b29ea5f52..246b033ff 100644 --- a/src/layouts/QskStackBox.cpp +++ b/src/layouts/QskStackBox.cpp @@ -4,18 +4,18 @@ *****************************************************************************/ #include "QskStackBox.h" -#include "QskStackBoxAnimator.h" -#include "QskLayoutItem.h" -#include "QskLayoutEngine.h" #include "QskLayoutConstraint.h" +#include "QskLayoutEngine.h" +#include "QskLayoutItem.h" +#include "QskStackBoxAnimator.h" #include class QskStackBox::PrivateData { -public: - PrivateData(): - currentIndex( -1 ) + public: + PrivateData() + : currentIndex( -1 ) { } @@ -23,14 +23,14 @@ class QskStackBox::PrivateData QPointer< QskStackBoxAnimator > animator; }; -QskStackBox::QskStackBox( QQuickItem* parent ): - QskStackBox( false, parent ) +QskStackBox::QskStackBox( QQuickItem* parent ) + : QskStackBox( false, parent ) { } -QskStackBox::QskStackBox( bool autoAddChildren, QQuickItem* parent ): - Inherited( parent ), - m_data( new PrivateData() ) +QskStackBox::QskStackBox( bool autoAddChildren, QQuickItem* parent ) + : Inherited( parent ) + , m_data( new PrivateData() ) { setAutoAddChildren( autoAddChildren ); } @@ -101,7 +101,6 @@ void QskStackBox::layoutItemRemoved( QskLayoutItem*, int index ) if ( newIndex >= 0 ) setCurrentIndex( index ); - } else if ( index > m_data->currentIndex ) { diff --git a/src/layouts/QskStackBox.h b/src/layouts/QskStackBox.h index 27c205dcc..04317ca9e 100644 --- a/src/layouts/QskStackBox.h +++ b/src/layouts/QskStackBox.h @@ -23,7 +23,7 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox using Inherited = QskIndexedLayoutBox; -public: + public: explicit QskStackBox( QQuickItem* parent = nullptr ); QskStackBox( bool autoAddChildren, QQuickItem* parent = nullptr ); @@ -41,18 +41,18 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox const QskStackBoxAnimator* animator() const; QskStackBoxAnimator* animator(); -public Q_SLOTS: + public Q_SLOTS: void setCurrentIndex( int index ); void setCurrentItem( const QQuickItem* ); -Q_SIGNALS: + Q_SIGNALS: void currentIndexChanged( int index ); void currentItemChanged( QQuickItem* ); -protected: + protected: QskStackBoxAnimator* effectiveAnimator(); -private: + private: friend class QskStackBoxAnimator; void layoutItemInserted( QskLayoutItem*, int index ) override; diff --git a/src/layouts/QskStackBoxAnimator.cpp b/src/layouts/QskStackBoxAnimator.cpp index 3d71ef152..0c65cca75 100644 --- a/src/layouts/QskStackBoxAnimator.cpp +++ b/src/layouts/QskStackBoxAnimator.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskStackBoxAnimator.h" -#include "QskLayoutItem.h" #include "QskLayoutEngine.h" +#include "QskLayoutItem.h" #include "QskStackBox.h" static Qsk::Direction qskDirection( @@ -13,7 +13,7 @@ static Qsk::Direction qskDirection( { Qsk::Direction direction; - if ( orientation == Qt::Horizontal ) + if ( orientation == Qt::Horizontal ) { direction = Qsk::RightToLeft; @@ -55,10 +55,10 @@ static Qsk::Direction qskDirection( return direction; } -QskStackBoxAnimator::QskStackBoxAnimator( QskStackBox* parent ): - QObject( parent ), - m_startIndex( -1 ), - m_endIndex( -1 ) +QskStackBoxAnimator::QskStackBoxAnimator( QskStackBox* parent ) + : QObject( parent ) + , m_startIndex( -1 ) + , m_endIndex( -1 ) { } @@ -97,9 +97,9 @@ QskLayoutItem* QskStackBoxAnimator::layoutItemAt( int index ) const ( index == 0 ) ? m_startIndex : m_endIndex ); } -QskStackBoxAnimator1::QskStackBoxAnimator1( QskStackBox* parent ): - QskStackBoxAnimator( parent ), - m_orientation( Qt::Horizontal ) +QskStackBoxAnimator1::QskStackBoxAnimator1( QskStackBox* parent ) + : QskStackBoxAnimator( parent ) + , m_orientation( Qt::Horizontal ) { } @@ -138,7 +138,8 @@ void QskStackBoxAnimator1::setup() QQuickItem* item = layoutItem->item(); const Qt::Orientation orientation = this->orientation(); - m_itemOffset[i] = ( orientation == Qt::Horizontal ) ? item->x() : item->y(); + m_itemOffset[ i ] = + ( orientation == Qt::Horizontal ) ? item->x() : item->y(); if ( i == 1 ) { @@ -185,7 +186,8 @@ void QskStackBoxAnimator1::advance( qreal value ) stackBox->adjustItemAt( ( i == 0 ) ? startIndex() : endIndex() ); QQuickItem* item = layoutItem->item(); - m_itemOffset[i] = ( m_orientation == Qt::Horizontal ) ? item->x() : item->y(); + m_itemOffset[ i ] = + ( m_orientation == Qt::Horizontal ) ? item->x() : item->y(); } QQuickItem* item = layoutItem->item(); @@ -195,18 +197,18 @@ void QskStackBoxAnimator1::advance( qreal value ) const qreal off = stackBox->width() * ( value - i ); if ( m_direction == Qsk::LeftToRight ) - item->setX( m_itemOffset[i] - off ); + item->setX( m_itemOffset[ i ] - off ); else - item->setX( m_itemOffset[i] + off ); + item->setX( m_itemOffset[ i ] + off ); } else { const qreal off = stackBox->height() * ( value - i ); if ( m_direction == Qsk::TopToBottom ) - item->setY( m_itemOffset[i] + off ); + item->setY( m_itemOffset[ i ] + off ); else - item->setY( m_itemOffset[i] - off ); + item->setY( m_itemOffset[ i ] - off ); } } } @@ -226,8 +228,8 @@ void QskStackBoxAnimator1::done() stackBox()->setClip( false ); } -QskStackBoxAnimator3::QskStackBoxAnimator3( QskStackBox* parent ): - QskStackBoxAnimator( parent ) +QskStackBoxAnimator3::QskStackBoxAnimator3( QskStackBox* parent ) + : QskStackBoxAnimator( parent ) { } diff --git a/src/layouts/QskStackBoxAnimator.h b/src/layouts/QskStackBoxAnimator.h index 43ddd32d9..be776f649 100644 --- a/src/layouts/QskStackBoxAnimator.h +++ b/src/layouts/QskStackBoxAnimator.h @@ -6,9 +6,9 @@ #ifndef QSK_STACK_BOX_ANIMATOR_H #define QSK_STACK_BOX_ANIMATOR_H +#include "QskAnimator.h" #include "QskGlobal.h" #include "QskNamespace.h" -#include "QskAnimator.h" #include class QskStackBox; @@ -18,7 +18,7 @@ class QSK_EXPORT QskStackBoxAnimator : public QObject, public QskAnimator { Q_OBJECT -public: + public: QskStackBoxAnimator( QskStackBox* parent ); ~QskStackBoxAnimator() override; @@ -28,12 +28,12 @@ class QSK_EXPORT QskStackBoxAnimator : public QObject, public QskAnimator int startIndex() const; int endIndex() const; -protected: + protected: QskStackBox* stackBox() const; QskLayoutItem* layoutItemAt( int index ) const; void resizeItemAt( int index ); -private: + private: int m_startIndex; int m_endIndex; }; @@ -42,20 +42,20 @@ class QSK_EXPORT QskStackBoxAnimator1 : public QskStackBoxAnimator { Q_OBJECT -public: + public: QskStackBoxAnimator1( QskStackBox* parent ); ~QskStackBoxAnimator1() override; void setOrientation( Qt::Orientation ); Qt::Orientation orientation() const; -protected: + protected: void setup() override; void advance( qreal value ) override; void done() override; -private: - qreal m_itemOffset[2]; + private: + qreal m_itemOffset[ 2 ]; Qt::Orientation m_orientation : 2; Qsk::Direction m_direction : 4; @@ -66,11 +66,11 @@ class QSK_EXPORT QskStackBoxAnimator3 : public QskStackBoxAnimator { Q_OBJECT -public: + public: QskStackBoxAnimator3( QskStackBox* parent ); ~QskStackBoxAnimator3() override; -protected: + protected: void setup() override; void advance( qreal value ) override; void done() override; diff --git a/src/nodes/QskBoxClipNode.cpp b/src/nodes/QskBoxClipNode.cpp index 81149da3d..9408e22aa 100644 --- a/src/nodes/QskBoxClipNode.cpp +++ b/src/nodes/QskBoxClipNode.cpp @@ -4,13 +4,13 @@ *****************************************************************************/ #include "QskBoxClipNode.h" +#include "QskBoxBorderMetrics.h" #include "QskBoxRenderer.h" #include "QskBoxShapeMetrics.h" -#include "QskBoxBorderMetrics.h" #include "QskFunctions.h" -static inline uint qskMetricsHash( const QskBoxShapeMetrics& shape, - const QskBoxBorderMetrics& border ) +static inline uint qskMetricsHash( + const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border ) { uint hash = 13000; @@ -18,9 +18,9 @@ static inline uint qskMetricsHash( const QskBoxShapeMetrics& shape, return border.hash( hash ); } -QskBoxClipNode::QskBoxClipNode(): - m_hash( 0 ), - m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) +QskBoxClipNode::QskBoxClipNode() + : m_hash( 0 ) + , m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) { setGeometry( &m_geometry ); } diff --git a/src/nodes/QskBoxClipNode.h b/src/nodes/QskBoxClipNode.h index 0c838dc54..0eb6d05d3 100644 --- a/src/nodes/QskBoxClipNode.h +++ b/src/nodes/QskBoxClipNode.h @@ -14,14 +14,14 @@ class QskBoxBorderMetrics; class QSK_EXPORT QskBoxClipNode : public QSGClipNode { -public: + public: QskBoxClipNode(); ~QskBoxClipNode() override; void setBox( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics& ); -private: + private: uint m_hash; QRectF m_rect; diff --git a/src/nodes/QskBoxNode.cpp b/src/nodes/QskBoxNode.cpp index 41d0193f5..eb4f54efa 100644 --- a/src/nodes/QskBoxNode.cpp +++ b/src/nodes/QskBoxNode.cpp @@ -4,20 +4,20 @@ *****************************************************************************/ #include "QskBoxNode.h" +#include "QskBoxBorderColors.h" +#include "QskBoxBorderMetrics.h" #include "QskBoxRenderer.h" #include "QskBoxShapeMetrics.h" -#include "QskBoxBorderMetrics.h" -#include "QskBoxBorderColors.h" #include "QskGradient.h" -#include -#include #include +#include +#include Q_GLOBAL_STATIC( QSGVertexColorMaterial, qskMaterialVertex ) -static inline uint qskMetricsHash( const QskBoxShapeMetrics& shape, - const QskBoxBorderMetrics& borderMetrics ) +static inline uint qskMetricsHash( + const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics ) { uint hash = 13000; @@ -25,18 +25,18 @@ static inline uint qskMetricsHash( const QskBoxShapeMetrics& shape, return borderMetrics.hash( hash ); } -static inline uint qskColorsHash( const QskBoxBorderColors& borderColors, - const QskGradient& fillGradient ) +static inline uint qskColorsHash( + const QskBoxBorderColors& borderColors, const QskGradient& fillGradient ) { uint hash = 13000; hash = borderColors.hash( hash ); return fillGradient.hash( hash ); } -QskBoxNode::QskBoxNode(): - m_metricsHash( 0 ), - m_colorsHash( 0 ), - m_geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 ) +QskBoxNode::QskBoxNode() + : m_metricsHash( 0 ) + , m_colorsHash( 0 ) + , m_geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 ) { setMaterial( qskMaterialVertex ); setGeometry( &m_geometry ); @@ -127,8 +127,9 @@ void QskBoxNode::setBoxData( const QRectF& rect, if ( maybeFlat ) { - if ( ( hasFill && hasBorder ) || ( hasFill && !isFillMonochrome ) - || ( hasBorder && !isBorderMonochrome ) ) + if ( ( hasFill && hasBorder ) || + ( hasFill && !isFillMonochrome ) || + ( hasBorder && !isBorderMonochrome ) ) { maybeFlat = false; } @@ -148,7 +149,7 @@ void QskBoxNode::setBoxData( const QRectF& rect, // all is done with one color setMonochrome( true ); - auto* flatMaterial = static_cast< QSGFlatColorMaterial *>( material() ); + auto* flatMaterial = static_cast< QSGFlatColorMaterial* >( material() ); if ( hasFill ) { @@ -177,7 +178,7 @@ void QskBoxNode::setMonochrome( bool on ) setMaterial( new QSGFlatColorMaterial() ); const QSGGeometry g( QSGGeometry::defaultAttributes_Point2D(), 0 ); - memcpy( (void *)&m_geometry, (void *)&g, sizeof( QSGGeometry ) ); + memcpy( ( void* ) &m_geometry, ( void* ) &g, sizeof( QSGGeometry ) ); } else { @@ -185,6 +186,6 @@ void QskBoxNode::setMonochrome( bool on ) delete material; const QSGGeometry g( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 ); - memcpy( (void *)&m_geometry, (void *)&g, sizeof( QSGGeometry ) ); + memcpy( ( void* ) &m_geometry, ( void* ) &g, sizeof( QSGGeometry ) ); } } diff --git a/src/nodes/QskBoxNode.h b/src/nodes/QskBoxNode.h index 0f6e00ecc..a9b5a59f7 100644 --- a/src/nodes/QskBoxNode.h +++ b/src/nodes/QskBoxNode.h @@ -16,17 +16,17 @@ class QskGradient; class QSK_EXPORT QskBoxNode : public QSGGeometryNode { -public: + public: QskBoxNode(); ~QskBoxNode() override; - void setBoxData( const QRectF& rect, + void setBoxData( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, const QskBoxBorderColors&, const QskGradient& ); void setBoxData( const QRectF& rect, const QskGradient& ); -private: + private: void setMonochrome( bool on ); uint m_metricsHash; diff --git a/src/nodes/QskBoxRenderer.h b/src/nodes/QskBoxRenderer.h index 3498706f9..811f9722b 100644 --- a/src/nodes/QskBoxRenderer.h +++ b/src/nodes/QskBoxRenderer.h @@ -6,7 +6,6 @@ #ifndef QSK_BOX_RENDERER_H #define QSK_BOX_RENDERER_H -#include "QskGlobal.h" #include "QskBoxShapeMetrics.h" #include @@ -24,7 +23,7 @@ namespace QskVertex class QSK_EXPORT QskBoxRenderer { -public: + public: void renderBorder( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& ); @@ -37,31 +36,34 @@ class QSK_EXPORT QskBoxRenderer class Quad { - public: - inline constexpr Quad(): - left( 0.0 ), - top( 0.0 ), - right( 0.0 ), - bottom( 0.0 ), - width( 0.0 ), - height( 0.0 ) + public: + inline constexpr Quad() + : left( 0.0 ) + , top( 0.0 ) + , right( 0.0 ) + , bottom( 0.0 ) + , width( 0.0 ) + , height( 0.0 ) { } - inline Quad( const QRectF& rect ): - left( rect.left() ), - top( rect.top() ), - right( rect.right() ), - bottom( rect.bottom() ), - width( rect.width() ), - height( rect.height() ) + inline Quad( const QRectF& rect ) + : left( rect.left() ) + , top( rect.top() ) + , right( rect.right() ) + , bottom( rect.bottom() ) + , width( rect.width() ) + , height( rect.height() ) { } inline bool operator==( const Quad& other ) const { - return ( left == other.left ) && ( right == other.right ) - && ( top == other.top ) && ( bottom == other.bottom ); + return + ( left == other.left ) && + ( right == other.right ) && + ( top == other.top ) && + ( bottom == other.bottom ); } inline bool operator!=( const Quad& other ) const @@ -79,7 +81,7 @@ class QSK_EXPORT QskBoxRenderer class Metrics { - public: + public: Metrics( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics& ); Quad outerQuad; @@ -97,14 +99,14 @@ class QSK_EXPORT QskBoxRenderer int stepCount; - } corner[4]; + } corner[ 4 ]; bool isBorderRegular; bool isRadiusRegular; bool isTotallyCropped; }; -private: + private: void renderRectFill( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& ); diff --git a/src/nodes/QskBoxRendererColorMap.h b/src/nodes/QskBoxRendererColorMap.h index 97b79c9cd..4cb25d418 100644 --- a/src/nodes/QskBoxRendererColorMap.h +++ b/src/nodes/QskBoxRendererColorMap.h @@ -7,8 +7,9 @@ #define QSK_BOX_RENDERER_COLOR_MAP_H #include -#include #include +#include + #include class QskBoxShapeMetrics; @@ -17,7 +18,7 @@ namespace QskVertex { class ColorMapNone { - public: + public: constexpr inline Color colorAt( qreal ) const { return Color(); @@ -26,9 +27,9 @@ namespace QskVertex class ColorMapSolid { - public: - constexpr inline ColorMapSolid( Color color ): - m_color( color ) + public: + constexpr inline ColorMapSolid( Color color ) + : m_color( color ) { } @@ -37,16 +38,16 @@ namespace QskVertex return m_color; } - private: + private: const Color m_color; }; class ColorMapGradient { - public: - inline ColorMapGradient( Color color1, Color color2 ): - m_color1( color1 ), - m_color2( color2 ) + public: + inline ColorMapGradient( Color color1, Color color2 ) + : m_color1( color1 ) + , m_color2( color2 ) { } @@ -55,14 +56,14 @@ namespace QskVertex return m_color1.interpolatedTo( m_color2, value ); } - private: + private: const Color m_color1; const Color m_color2; }; class ColorIterator { - public: + public: static inline bool advance() { return false; @@ -88,135 +89,135 @@ namespace QskVertex class SolidColorIterator : public ColorIterator { - public: - inline SolidColorIterator( const QColor& color ): - m_color( color ) - { + public: + inline SolidColorIterator( const QColor& color ) + : m_color( color ) + { } - + inline Color colorAt( qreal ) const { return m_color; - } - - private: + } + + private: const Color m_color; - }; + }; class TwoColorIterator01 : public ColorIterator { - public: - inline TwoColorIterator01( const QColor& color1, const QColor& color2 ): - m_color1( color1 ), - m_color2( color2 ) - { - } - + public: + inline TwoColorIterator01( const QColor& color1, const QColor& color2 ) + : m_color1( color1 ) + , m_color2( color2 ) + { + } + inline Color colorAt( qreal value ) const { return m_color1.interpolatedTo( m_color2, value ); - } - - private: + } + + private: const Color m_color1, m_color2; - }; + }; class TwoColorIterator : public ColorIterator { - public: + public: inline TwoColorIterator( qreal value1, qreal value2, - const QColor& color1, const QColor& color2 ): - m_value1( value1 ), - m_range( value2 - value1 ), - m_color1( color1 ), - m_color2( color2 ) - { - } - + const QColor& color1, const QColor& color2 ) + : m_value1( value1 ) + , m_range( value2 - value1 ) + , m_color1( color1 ) + , m_color2( color2 ) + { + } + inline Color colorAt( qreal value ) const { const qreal r = ( value - m_value1 ) / m_range; return m_color1.interpolatedTo( m_color2, r ); - } - - private: + } + + private: const qreal m_value1, m_range; const Color m_color1, m_color2; - }; + }; class GradientColorIterator : public ColorIterator { - public: + public: inline GradientColorIterator( qreal value1, qreal value2, - const QVector< QskGradientStop > stops ): - m_value1( value1 ), - m_value2( value2 ), - m_stops( stops ) - { + const QVector< QskGradientStop > stops ) + : m_value1( value1 ) + , m_value2( value2 ) + , m_stops( stops ) + { Q_ASSERT( stops.size() > 2 ); - - m_color1 = stops[0].color(); - m_color2 = stops[1].color(); - + + m_color1 = stops[ 0 ].color(); + m_color2 = stops[ 1 ].color(); + m_valueStep1 = value1; - m_valueStep2 = valueAt( stops[1].position() ); + m_valueStep2 = valueAt( stops[ 1 ].position() ); m_stepSize = m_valueStep2 - m_valueStep1; - + m_index = 1; - } - + } + inline qreal value() const { return m_valueStep2; - } - + } + inline Color color() const { return m_color2; - } - + } + inline Color colorAt( qreal value ) const { const qreal r = ( value - m_valueStep1 ) / m_stepSize; return m_color1.interpolatedTo( m_color2, r ); - } + } inline bool advance() { const auto& stop = m_stops[ ++m_index ]; - + m_color1 = m_color2; m_color2 = stop.color(); - + m_valueStep1 = m_valueStep2; m_valueStep2 = valueAt( stop.position() ); m_stepSize = m_valueStep2 - m_valueStep1; - + return !isDone(); - } - + } + inline bool isDone() const { return m_index >= m_stops.count() - 1; - } - - private: + } + + private: inline qreal valueAt( qreal pos ) const { return m_value1 + pos * ( ( m_value2 - m_value1 ) ); - } - + } + const qreal m_value1, m_value2; QVector< QskGradientStop > m_stops; - + int m_index; qreal m_valueStep1, m_valueStep2, m_stepSize; Color m_color1, m_color2; - }; + }; template< class ContourIterator, class ColorIterator > ColoredLine* fillOrdered( ContourIterator& contourIt, - ColorIterator& colorIt, ColoredLine* line ) + ColorIterator& colorIt, ColoredLine* line ) { do { diff --git a/src/nodes/QskBoxRendererDEllipse.cpp b/src/nodes/QskBoxRendererDEllipse.cpp index d87ff006d..13f2cbc35 100644 --- a/src/nodes/QskBoxRendererDEllipse.cpp +++ b/src/nodes/QskBoxRendererDEllipse.cpp @@ -4,9 +4,9 @@ *****************************************************************************/ #include "QskBoxRenderer.h" -#include "QskVertex.h" #include "QskBoxRendererColorMap.h" #include "QskGradient.h" +#include "QskVertex.h" #include @@ -16,7 +16,7 @@ namespace class ContourLine { - public: + public: inline void setLine( qreal x1, qreal y1, qreal value1, qreal x2, qreal y2, qreal value2 ) { @@ -35,12 +35,15 @@ namespace return QPointF( p1.x + r * ( p2.x - p1.x ), p1.y + r * ( p2.y - p1.y ) ); } - struct { qreal x, y, v; } p1, p2; + struct + { + qreal x, y, v; + } p1, p2; }; class ValueCurve { - public: + public: ValueCurve( const QskBoxRenderer::Metrics& m ) { /* @@ -57,7 +60,7 @@ namespace qreal xt, yt; { - const auto& c = m.corner[Qt::TopLeftCorner]; + const auto& c = m.corner[ Qt::TopLeftCorner ]; const qreal k = c.radiusInnerY / c.radiusInnerX * md; const qreal u = ::sqrt( 1.0 + k * k ); @@ -110,17 +113,17 @@ namespace return m_coeff_0 + x * m_coeff_x + y * m_coeff_y; } - private: + private: qreal m_coeff_0, m_coeff_x, m_coeff_y; }; class ContourIterator { - public: - ContourIterator(): - m_clockwise( true ), - m_isLeading( true ), - m_isDone( false ) + public: + ContourIterator() + : m_clockwise( true ) + , m_isLeading( true ) + , m_isDone( false ) { } @@ -180,13 +183,13 @@ namespace if ( m_clockwise ) { - switch( m_corner ) + switch ( m_corner ) { case TopLeftCorner: { if ( p.x >= c.centerX ) { - p.x = corners[TopRightCorner].centerX; + p.x = corners[ TopRightCorner ].centerX; p.y = metrics.innerQuad.top; setCorner( TopRightCorner, metrics ); @@ -197,7 +200,7 @@ namespace p.x = c.centerX - m_cos * c.radiusInnerX; p.y = c.centerY - m_sin * c.radiusInnerY; - if ( p.x >= corners[TopRightCorner].centerX ) + if ( p.x >= corners[ TopRightCorner ].centerX ) setCorner( TopRightCorner, metrics ); } @@ -208,7 +211,7 @@ namespace if ( p.y >= c.centerY ) { p.x = metrics.innerQuad.right; - p.y = corners[BottomRightCorner].centerY; + p.y = corners[ BottomRightCorner ].centerY; setCorner( BottomRightCorner, metrics ); } @@ -218,7 +221,7 @@ namespace p.x = c.centerX + m_cos * c.radiusInnerX; p.y = c.centerY - m_sin * c.radiusInnerY; - if ( p.y >= corners[BottomRightCorner].centerY ) + if ( p.y >= corners[ BottomRightCorner ].centerY ) setCorner( BottomRightCorner, metrics ); } @@ -242,14 +245,14 @@ namespace } else { - switch( m_corner ) + switch ( m_corner ) { case TopLeftCorner: { if ( p.y >= c.centerY ) { p.x = metrics.innerQuad.left; - p.y = corners[BottomLeftCorner].centerY; + p.y = corners[ BottomLeftCorner ].centerY; setCorner( BottomLeftCorner, metrics ); } @@ -259,7 +262,7 @@ namespace p.x = c.centerX - m_cos * c.radiusInnerX; p.y = c.centerY - m_sin * c.radiusInnerY; - if ( p.y >= corners[BottomLeftCorner].centerY ) + if ( p.y >= corners[ BottomLeftCorner ].centerY ) setCorner( BottomLeftCorner, metrics ); } @@ -269,7 +272,7 @@ namespace { if ( p.x >= c.centerX ) { - p.x = corners[BottomRightCorner].centerX; + p.x = corners[ BottomRightCorner ].centerX; p.y = metrics.innerQuad.bottom; setCorner( BottomRightCorner, metrics ); @@ -280,7 +283,7 @@ namespace p.x = c.centerX - m_cos * c.radiusInnerX; p.y = c.centerY + m_sin * c.radiusInnerY; - if ( p.x >= corners[BottomRightCorner].centerX ) + if ( p.x >= corners[ BottomRightCorner ].centerX ) setCorner( BottomRightCorner, metrics ); } @@ -290,7 +293,7 @@ namespace { increment(); - p.x = c.centerX + m_cos * c.radiusInnerX;; + p.x = c.centerX + m_cos * c.radiusInnerX; p.y = c.centerY + m_sin * c.radiusInnerY; break; @@ -311,11 +314,11 @@ namespace } } - private: + private: static constexpr qreal m_eps = 1e-4; - inline void setCorner( Qt::Corner corner, - const QskBoxRenderer::Metrics& metrics ) + inline void setCorner( + Qt::Corner corner, const QskBoxRenderer::Metrics& metrics ) { m_corner = corner; const auto& c = metrics.corner[ corner ]; @@ -408,13 +411,13 @@ namespace class OutlineIterator { - public: + public: OutlineIterator( const QskBoxRenderer::Metrics& metrics, - const ValueCurve& curve, bool clockwise ): - m_metrics( metrics ), - m_curve( curve ) + const ValueCurve& curve, bool clockwise ) + : m_metrics( metrics ) + , m_curve( curve ) { - const auto& c = metrics.corner[Qt::TopLeftCorner]; + const auto& c = metrics.corner[ Qt::TopLeftCorner ]; #if 1 // This does not need to be done twice !!! @@ -448,25 +451,25 @@ namespace { if ( clockwise ) { - m_iterator[0].setup( metrics, true, true, + m_iterator[ 0 ].setup( metrics, true, true, cos1, cosStep, sin1, sinStep, x2, y2, v2, x1, y1, v1 ); - m_iterator[1].setup( metrics, false, false, + m_iterator[ 1 ].setup( metrics, false, false, cos2, cosStep, sin2, sinStep, x1, y1, v1, x2, y2, v2 ); } else { - m_iterator[0].setup( metrics, true, false, + m_iterator[ 0 ].setup( metrics, true, false, cos2, cosStep, sin2, sinStep, x1, y1, v1, x2, y2, v2 ); - m_iterator[1].setup( metrics, false, true, + m_iterator[ 1 ].setup( metrics, false, true, cos1, cosStep, sin1, sinStep, x2, y2, v2, x1, y1, v1 ); } - while ( !m_iterator[1].isDone() - && m_iterator[0].value() > m_iterator[1].value() ) + while ( !m_iterator[ 1 ].isDone() && + ( m_iterator[ 0 ].value() > m_iterator[ 1 ].value() ) ) { - m_iterator[1].advance( metrics, m_curve ); + m_iterator[ 1 ].advance( metrics, m_curve ); } return; @@ -483,9 +486,9 @@ namespace inline void advance() { - m_iterator[0].advance( m_metrics, m_curve ); + m_iterator[ 0 ].advance( m_metrics, m_curve ); - if ( !m_iterator[0].isDone() ) + if ( !m_iterator[ 0 ].isDone() ) { /* adjusting the counter vertex until its top value is above @@ -494,33 +497,33 @@ namespace border point by cutting the counter vertex. */ - while ( !m_iterator[1].isDone() && - ( m_iterator[0].value() > m_iterator[1].value() ) ) + while ( !m_iterator[ 1 ].isDone() && + ( m_iterator[ 0 ].value() > m_iterator[ 1 ].value() ) ) { - m_iterator[1].advance( m_metrics, m_curve ); + m_iterator[ 1 ].advance( m_metrics, m_curve ); } } } inline bool isDone() const { - return m_iterator[0].isDone(); + return m_iterator[ 0 ].isDone(); } inline qreal value() const { - return m_iterator[0].value(); + return m_iterator[ 0 ].value(); } inline void setLineAt( qreal value, Color color, ColoredLine* line ) { - const auto& contourLine1 = m_iterator[0].contourLine(); - const auto& contourLine2 = m_iterator[1].contourLine(); + const auto& contourLine1 = m_iterator[ 0 ].contourLine(); + const auto& contourLine2 = m_iterator[ 1 ].contourLine(); const QPointF pos = contourLine1.pointAt( value ); const QPointF cPos = contourLine2.pointAt( value ); - if ( m_iterator[0].isClockwise() ) + if ( m_iterator[ 0 ].isClockwise() ) setLine( cPos.x(), cPos.y(), pos.x(), pos.y(), color, line ); else setLine( pos.x(), pos.y(), cPos.x(), cPos.y(), color, line ); @@ -528,18 +531,18 @@ namespace inline void setLine( Color color, ColoredLine* line ) { - const auto& contourLine1 = m_iterator[0].contourLine(); - const auto& contourLine2 = m_iterator[1].contourLine(); + const auto& contourLine1 = m_iterator[ 0 ].contourLine(); + const auto& contourLine2 = m_iterator[ 1 ].contourLine(); const QPointF cPos = contourLine2.pointAt( contourLine1.p2.v ); - if ( m_iterator[0].isClockwise() ) + if ( m_iterator[ 0 ].isClockwise() ) setLine( cPos.x(), cPos.y(), contourLine1.p2.x, contourLine1.p2.y, color, line ); else setLine( contourLine1.p2.x, contourLine1.p2.y, cPos.x(), cPos.y(), color, line ); } - private: + private: inline void setLine( qreal x1, qreal y1, qreal x2, qreal y2, Color color, ColoredLine* line ) { @@ -554,16 +557,16 @@ namespace half of the ellipse. The other one is for finding the corresponing point at the other side. */ - ContourIterator m_iterator[2]; + ContourIterator m_iterator[ 2 ]; }; class DRectellipseIterator { - public: - DRectellipseIterator( const QskBoxRenderer::Metrics& metrics, - const ValueCurve& curve ): - m_left( metrics, curve, false ), - m_right( metrics, curve, true ) + public: + DRectellipseIterator( + const QskBoxRenderer::Metrics& metrics, const ValueCurve& curve ) + : m_left( metrics, curve, false ) + , m_right( metrics, curve, true ) { m_next = ( m_left.value() < m_right.value() ) ? &m_left : &m_right; } @@ -593,7 +596,7 @@ namespace return !m_next->isDone(); } - private: + private: OutlineIterator m_left, m_right; OutlineIterator* m_next; }; @@ -619,7 +622,7 @@ void QskBoxRenderer::renderDiagonalFill( const QskBoxRenderer::Metrics& metrics, while ( line - lines < fillLineCount ) { - line[0] = line[-1]; + line[ 0 ] = line[ -1 ]; line++; } } diff --git a/src/nodes/QskBoxRendererEllipse.cpp b/src/nodes/QskBoxRendererEllipse.cpp index c969397f7..d872934d0 100644 --- a/src/nodes/QskBoxRendererEllipse.cpp +++ b/src/nodes/QskBoxRendererEllipse.cpp @@ -6,13 +6,13 @@ #include "QskBoxRenderer.h" #include "QskGradient.h" -#include "QskBoxRendererColorMap.h" -#include "QskBoxBorderMetrics.h" #include "QskBoxBorderColors.h" +#include "QskBoxBorderMetrics.h" +#include "QskBoxRendererColorMap.h" #include "QskBoxShapeMetrics.h" -#include #include +#include using namespace QskVertex; @@ -28,7 +28,7 @@ namespace class ArcIterator { - public: + public: inline ArcIterator() = default; inline ArcIterator( int stepCount, bool inverted = false ) @@ -59,7 +59,6 @@ namespace m_sinStep = qFastSin( angleStep ); } - inline bool isInverted() const { return m_inverted; } inline double cos() const { return m_cos; } @@ -87,7 +86,7 @@ namespace return qBound( 3, qCeil( arcLength / 3.0 ), 18 ); // every 3 pixels } - private: + private: double m_cos; double m_sin; @@ -104,11 +103,11 @@ namespace { class BorderValuesUniform { - public: - inline BorderValuesUniform( const QskBoxRenderer::Metrics& metrics ): - m_corner( metrics.corner[0] ), - m_dx1( m_corner.radiusInnerX ), - m_dy1( m_corner.radiusInnerY ) + public: + inline BorderValuesUniform( const QskBoxRenderer::Metrics& metrics ) + : m_corner( metrics.corner[ 0 ] ) + , m_dx1( m_corner.radiusInnerX ) + , m_dy1( m_corner.radiusInnerY ) { } @@ -116,7 +115,7 @@ namespace { if ( !m_corner.isCropped ) { - m_dx1 = cos * m_corner.radiusInnerX;; + m_dx1 = cos * m_corner.radiusInnerX; m_dy1 = sin * m_corner.radiusInnerY; } @@ -129,21 +128,21 @@ namespace inline qreal dx2( int ) const { return m_dx2; } inline qreal dy2( int ) const { return m_dy2; } - private: + private: const QskBoxRenderer::Metrics::Corner& m_corner; qreal m_dx1, m_dy1, m_dx2, m_dy2; }; class BorderValues { - public: - inline BorderValues( const QskBoxRenderer::Metrics& metrics ): - m_uniform( metrics.isRadiusRegular ) + public: + inline BorderValues( const QskBoxRenderer::Metrics& metrics ) + : m_uniform( metrics.isRadiusRegular ) { for ( int i = 0; i < 4; i++ ) { - const auto& c = metrics.corner[i]; - auto& v = m_inner[i]; + const auto& c = metrics.corner[ i ]; + auto& v = m_inner[ i ]; if ( c.radiusInnerX >= 0.0 ) { @@ -167,40 +166,40 @@ namespace v.ry = 0.0; } - m_outer[i].x0 = m_outer[i].y0 = 0.0; - m_outer[i].rx = c.radiusX; - m_outer[i].ry = c.radiusY; + m_outer[ i ].x0 = m_outer[ i ].y0 = 0.0; + m_outer[ i ].rx = c.radiusX; + m_outer[ i ].ry = c.radiusY; } } inline void setAngle( qreal cos, qreal sin ) { - m_inner[0].setAngle( cos, sin ); - m_inner[1].setAngle( cos, sin ); - m_inner[2].setAngle( cos, sin ); - m_inner[3].setAngle( cos, sin ); + m_inner[ 0 ].setAngle( cos, sin ); + m_inner[ 1 ].setAngle( cos, sin ); + m_inner[ 2 ].setAngle( cos, sin ); + m_inner[ 3 ].setAngle( cos, sin ); - m_outer[0].setAngle( cos, sin ); + m_outer[ 0 ].setAngle( cos, sin ); if ( !m_uniform ) { - m_outer[1].setAngle( cos, sin ); - m_outer[2].setAngle( cos, sin ); - m_outer[3].setAngle( cos, sin ); + m_outer[ 1 ].setAngle( cos, sin ); + m_outer[ 2 ].setAngle( cos, sin ); + m_outer[ 3 ].setAngle( cos, sin ); } } - inline qreal dx1( int pos ) const { return m_inner[pos].dx; } - inline qreal dy1( int pos ) const { return m_inner[pos].dy; } + inline qreal dx1( int pos ) const { return m_inner[ pos] .dx; } + inline qreal dy1( int pos ) const { return m_inner[ pos ].dy; } inline qreal dx2( int pos ) const - { return m_uniform ? m_outer[0].dx : m_outer[pos].dx; } + { return m_uniform ? m_outer[ 0 ].dx : m_outer[ pos ].dx; } inline qreal dy2( int pos ) const - { return m_uniform ? m_outer[0].dy : m_outer[pos].dy; } + { return m_uniform ? m_outer[ 0 ].dy : m_outer[ pos ].dy; } - private: + private: bool m_uniform; class Values { - public: + public: inline void setAngle( qreal cos, qreal sin ) { dx = x0 + cos * rx; @@ -211,19 +210,19 @@ namespace qreal x0, y0, rx, ry; }; - Values m_inner[4]; - Values m_outer[4]; + Values m_inner[ 4 ]; + Values m_outer[ 4 ]; }; class FillValues { - public: + public: inline FillValues( const QskBoxRenderer::Metrics& metrics ) { for ( int i = 0; i < 4; i++ ) { - const auto& c = metrics.corner[i]; - auto& v = m_inner[i]; + const auto& c = metrics.corner[ i ]; + auto& v = m_inner[ i ]; if ( c.radiusInnerX >= 0.0 ) { @@ -251,19 +250,19 @@ namespace inline void setAngle( qreal cos, qreal sin ) { - m_inner[0].setAngle( cos, sin ); - m_inner[1].setAngle( cos, sin ); - m_inner[2].setAngle( cos, sin ); - m_inner[3].setAngle( cos, sin ); + m_inner[ 0 ].setAngle( cos, sin ); + m_inner[ 1 ].setAngle( cos, sin ); + m_inner[ 2 ].setAngle( cos, sin ); + m_inner[ 3 ].setAngle( cos, sin ); } - inline qreal dx( int pos ) const { return m_inner[pos].dx; } - inline qreal dy( int pos ) const { return m_inner[pos].dy; } + inline qreal dx( int pos ) const { return m_inner[ pos ].dx; } + inline qreal dy( int pos ) const { return m_inner[ pos ].dy; } - private: + private: class Values { - public: + public: inline void setAngle( qreal cos, qreal sin ) { dx = x0 + cos * rx; @@ -274,7 +273,7 @@ namespace qreal x0, y0, rx, ry; }; - Values m_inner[4]; + Values m_inner[ 4 ]; }; } @@ -282,32 +281,32 @@ namespace { class VRectEllipseIterator { - public: - VRectEllipseIterator( const QskBoxRenderer::Metrics& metrics ): - m_metrics( metrics ), - m_values( metrics ) + public: + VRectEllipseIterator( const QskBoxRenderer::Metrics& metrics ) + : m_metrics( metrics ) + , m_values( metrics ) { const auto& c = metrics.corner; - m_v[0].left = c[TopLeft].centerX; - m_v[0].right = c[TopRight].centerX; - m_v[0].y = metrics.innerQuad.top; + m_v[ 0 ].left = c[ TopLeft ].centerX; + m_v[ 0 ].right = c[ TopRight ].centerX; + m_v[ 0 ].y = metrics.innerQuad.top; - m_v[1] = m_v[0]; + m_v[ 1 ] = m_v[ 0 ]; - m_leadingCorner = ( c[TopLeft].stepCount >= c[TopRight].stepCount ) + m_leadingCorner = ( c[ TopLeft ].stepCount >= c[ TopRight ].stepCount ) ? TopLeft : TopRight; - m_arcIterator.reset( c[m_leadingCorner].stepCount, false ); + m_arcIterator.reset( c[ m_leadingCorner ].stepCount, false ); } template< class ColorIterator > inline void setGradientLine( const ColorIterator& it, ColoredLine* line ) { const qreal y = it.value(); - const qreal f = ( y - m_v[0].y ) / ( m_v[1].y - m_v[0].y ); - const qreal left = m_v[0].left + f * ( m_v[1].left - m_v[0].left ); - const qreal right = m_v[0].right + f * ( m_v[1].right - m_v[0].right ); + const qreal f = ( y - m_v[ 0 ].y ) / ( m_v[ 1 ].y - m_v[ 0 ].y ); + const qreal left = m_v[ 0 ].left + f * ( m_v[ 1 ].left - m_v[ 0 ].left ); + const qreal right = m_v[ 0 ].right + f * ( m_v[ 1 ].right - m_v[ 0 ].right ); line->setLine( left, y, right, y, it.color() ); } @@ -315,13 +314,13 @@ namespace template< class ColorIterator > inline void setContourLine( const ColorIterator& it, ColoredLine* line ) { - line->setLine( m_v[1].left, m_v[1].y, - m_v[1].right, m_v[1].y, it.colorAt( m_v[1].y ) ); + line->setLine( m_v[ 1 ].left, m_v[ 1 ].y, + m_v[ 1 ].right, m_v[ 1 ].y, it.colorAt( m_v[ 1 ].y ) ); } inline qreal value() const { - return m_v[1].y; + return m_v[ 1 ].y; } inline bool advance() @@ -334,18 +333,18 @@ namespace if ( m_arcIterator.isInverted() ) return false; - m_leadingCorner = ( c[BottomLeft].stepCount >= c[BottomRight].stepCount ) + m_leadingCorner = ( c[ BottomLeft ].stepCount >= c[ BottomRight ].stepCount ) ? BottomLeft : BottomRight; - m_arcIterator.reset( c[m_leadingCorner].stepCount, true ); + m_arcIterator.reset( c[ m_leadingCorner ].stepCount, true ); if ( centerQuad.top < centerQuad.bottom ) { - m_v[0] = m_v[1]; + m_v[ 0 ] = m_v[ 1 ]; - m_v[1].left = m_metrics.innerQuad.left; - m_v[1].right = m_metrics.innerQuad.right; - m_v[1].y = centerQuad.bottom; + m_v[ 1 ].left = m_metrics.innerQuad.left; + m_v[ 1 ].right = m_metrics.innerQuad.right; + m_v[ 1 ].y = centerQuad.bottom; return true; } @@ -354,60 +353,60 @@ namespace m_arcIterator.increment(); m_values.setAngle( m_arcIterator.cos(), m_arcIterator.sin() ); - m_v[0] = m_v[1]; + m_v[ 0 ] = m_v[ 1 ]; if ( m_arcIterator.isInverted() ) { - m_v[1].left = c[BottomLeft].centerX - m_values.dx( BottomLeft ); - m_v[1].right = c[BottomRight].centerX + m_values.dx( BottomRight ); - m_v[1].y = c[ m_leadingCorner ].centerY + m_values.dy( m_leadingCorner ); + m_v[ 1 ].left = c[ BottomLeft ].centerX - m_values.dx( BottomLeft ); + m_v[ 1 ].right = c[ BottomRight ].centerX + m_values.dx( BottomRight ); + m_v[ 1 ].y = c[ m_leadingCorner ].centerY + m_values.dy( m_leadingCorner ); } else { - m_v[1].left = c[TopLeft].centerX - m_values.dx( TopLeft ); - m_v[1].right = c[TopRight].centerX + m_values.dx( TopRight ); - m_v[1].y = c[ m_leadingCorner ].centerY - m_values.dy( m_leadingCorner ); + m_v[ 1 ].left = c[ TopLeft ].centerX - m_values.dx( TopLeft ); + m_v[ 1 ].right = c[ TopRight ].centerX + m_values.dx( TopRight ); + m_v[ 1 ].y = c[ m_leadingCorner ].centerY - m_values.dy( m_leadingCorner ); } return true; } - private: + private: const QskBoxRenderer::Metrics& m_metrics; ArcIterator m_arcIterator; int m_leadingCorner; FillValues m_values; - struct { qreal left, right, y; } m_v[2]; + struct { qreal left, right, y; } m_v[ 2 ]; }; class HRectEllipseIterator { - public: - HRectEllipseIterator( const QskBoxRenderer::Metrics& metrics ): - m_metrics( metrics ), - m_values( metrics ) + public: + HRectEllipseIterator( const QskBoxRenderer::Metrics& metrics ) + : m_metrics( metrics ) + , m_values( metrics ) { const auto& c = metrics.corner; - m_v[0].top = c[TopLeft].centerY; - m_v[0].bottom = c[BottomLeft].centerY; - m_v[0].x = metrics.innerQuad.left; + m_v[ 0 ].top = c[ TopLeft ].centerY; + m_v[ 0 ].bottom = c[ BottomLeft ].centerY; + m_v[ 0 ].x = metrics.innerQuad.left; - m_v[1] = m_v[0]; + m_v[ 1 ] = m_v[ 0 ]; - m_leadingCorner = ( c[TopLeft].stepCount >= c[BottomLeft].stepCount ) + m_leadingCorner = ( c[ TopLeft ].stepCount >= c[ BottomLeft ].stepCount ) ? TopLeft : BottomLeft; - m_arcIterator.reset( c[m_leadingCorner].stepCount, true ); + m_arcIterator.reset( c[ m_leadingCorner ].stepCount, true ); } template< class ColorIterator > inline void setGradientLine( const ColorIterator& it, ColoredLine* line ) { const qreal x = it.value(); - const qreal f = ( x - m_v[0].x ) / ( m_v[1].x - m_v[0].x ); - const qreal top = m_v[0].top + f * ( m_v[1].top - m_v[0].top ); - const qreal bottom = m_v[0].bottom + f * ( m_v[1].bottom - m_v[0].bottom ); + const qreal f = ( x - m_v[ 0 ].x ) / ( m_v[ 1 ].x - m_v[ 0 ].x ); + const qreal top = m_v[ 0 ].top + f * ( m_v[ 1 ].top - m_v[ 0 ].top ); + const qreal bottom = m_v[ 0 ].bottom + f * ( m_v[ 1 ].bottom - m_v[ 0 ].bottom ); line->setLine( x, top, x, bottom, it.color() ); } @@ -415,13 +414,13 @@ namespace template< class ColorIterator > inline void setContourLine( const ColorIterator& it, ColoredLine* line ) { - line->setLine( m_v[1].x, m_v[1].top, - m_v[1].x, m_v[1].bottom, it.colorAt( m_v[1].x ) ); + line->setLine( m_v[ 1 ].x, m_v[ 1 ].top, + m_v[ 1 ].x, m_v[ 1 ].bottom, it.colorAt( m_v[ 1 ].x ) ); } inline qreal value() const { - return m_v[1].x; + return m_v[ 1 ].x; } inline bool advance() @@ -434,17 +433,17 @@ namespace if ( !m_arcIterator.isInverted() ) return false; - m_leadingCorner = ( c[TopRight].stepCount >= c[BottomRight].stepCount ) + m_leadingCorner = ( c[ TopRight ].stepCount >= c[ BottomRight ].stepCount ) ? TopRight : BottomRight; - m_arcIterator.reset( c[m_leadingCorner].stepCount, false ); + m_arcIterator.reset( c[ m_leadingCorner ].stepCount, false ); if ( centerQuad.left < centerQuad.right ) { - m_v[0] = m_v[1]; + m_v[ 0 ] = m_v[ 1 ]; - m_v[1].top = m_metrics.innerQuad.top; - m_v[1].bottom = m_metrics.innerQuad.bottom; - m_v[1].x = centerQuad.right; + m_v[ 1 ].top = m_metrics.innerQuad.top; + m_v[ 1 ].bottom = m_metrics.innerQuad.bottom; + m_v[ 1 ].x = centerQuad.right; return true; } @@ -453,30 +452,30 @@ namespace m_arcIterator.increment(); m_values.setAngle( m_arcIterator.cos(), m_arcIterator.sin() ); - m_v[0] = m_v[1]; + m_v[ 0 ] = m_v[ 1 ]; if ( m_arcIterator.isInverted() ) { - m_v[1].top = c[TopLeft].centerY - m_values.dy( TopLeft ); - m_v[1].bottom = c[BottomLeft].centerY + m_values.dy( BottomLeft ); - m_v[1].x = c[m_leadingCorner].centerX - m_values.dx( m_leadingCorner ); + m_v[ 1 ].top = c[ TopLeft ].centerY - m_values.dy( TopLeft ); + m_v[ 1 ].bottom = c[ BottomLeft ].centerY + m_values.dy( BottomLeft ); + m_v[ 1 ].x = c[ m_leadingCorner ].centerX - m_values.dx( m_leadingCorner ); } else { - m_v[1].top = c[TopRight].centerY - m_values.dy( TopRight ); - m_v[1].bottom = c[BottomRight].centerY + m_values.dy( BottomRight ); - m_v[1].x = c[m_leadingCorner].centerX + m_values.dx( m_leadingCorner ); + m_v[ 1 ].top = c[ TopRight ].centerY - m_values.dy( TopRight ); + m_v[ 1 ].bottom = c[ BottomRight ].centerY + m_values.dy( BottomRight ); + m_v[ 1 ].x = c[ m_leadingCorner ].centerX + m_values.dx( m_leadingCorner ); } return true; } - private: + private: const QskBoxRenderer::Metrics& m_metrics; ArcIterator m_arcIterator; int m_leadingCorner; FillValues m_values; - struct { qreal top, bottom, x; } m_v[2]; + struct { qreal top, bottom, x; } m_v[ 2 ]; }; } @@ -484,15 +483,15 @@ namespace { class BorderMapNone { - public: + public: static inline constexpr Color colorAt( int ) { return Color(); } }; class BorderMapSolid { - public: - inline BorderMapSolid( QRgb rgb ): - m_color( rgb ) + public: + inline BorderMapSolid( QRgb rgb ) + : m_color( rgb ) { } @@ -503,11 +502,11 @@ namespace class BorderMapGradient { - public: - inline BorderMapGradient( int stepCount, QRgb rgb1, QRgb rgb2 ): - m_stepCount( stepCount ), - m_color1( rgb1 ), - m_color2( rgb2 ) + public: + inline BorderMapGradient( int stepCount, QRgb rgb1, QRgb rgb2 ) + : m_stepCount( stepCount ) + , m_color1( rgb1 ) + , m_color2( rgb2 ) { } @@ -516,7 +515,7 @@ namespace return m_color1.interpolatedTo( m_color2, step / m_stepCount ); } - private: + private: const qreal m_stepCount; const Color m_color1, m_color2; }; @@ -524,9 +523,9 @@ namespace template< class Line, class BorderValues > class Stroker { - public: - inline Stroker( const QskBoxRenderer::Metrics& metrics ): - m_metrics( metrics ) + public: + inline Stroker( const QskBoxRenderer::Metrics& metrics ) + : m_metrics( metrics ) { } @@ -539,10 +538,10 @@ namespace const auto& c = m_metrics.corner; #if 1 // TODO ... - const int stepCount = c[0].stepCount; + const int stepCount = c[ 0 ].stepCount; #endif - Line* linesBR, * linesTR, * linesTL, * linesBL; + Line *linesBR, *linesTR, *linesTL, *linesBL; linesBR = linesTR = linesTL = linesBL = nullptr; const int numCornerLines = stepCount + 1; @@ -599,44 +598,44 @@ namespace { constexpr auto corner = TopLeft; - linesTL[j].setLine( - c[corner].centerX - v.dx1( corner ), - c[corner].centerY - v.dy1( corner ), - c[corner].centerX - v.dx2( corner ), - c[corner].centerY - v.dy2( corner ), + linesTL[ j ].setLine( + c[ corner ].centerX - v.dx1( corner ), + c[ corner ].centerY - v.dy1( corner ), + c[ corner ].centerX - v.dx2( corner ), + c[ corner ].centerY - v.dy2( corner ), borderMapTL.colorAt( j ) ); } { constexpr auto corner = TopRight; - linesTR[k].setLine( - c[corner].centerX + v.dx1( corner ), - c[corner].centerY - v.dy1( corner ), - c[corner].centerX + v.dx2( corner ), - c[corner].centerY - v.dy2( corner ), + linesTR[ k ].setLine( + c[ corner ].centerX + v.dx1( corner ), + c[ corner ].centerY - v.dy1( corner ), + c[ corner ].centerX + v.dx2( corner ), + c[ corner ].centerY - v.dy2( corner ), borderMapTR.colorAt( k ) ); } { constexpr auto corner = BottomLeft; - linesBL[k].setLine( - c[corner].centerX - v.dx1( corner ), - c[corner].centerY + v.dy1( corner ), - c[corner].centerX - v.dx2( corner ), - c[corner].centerY + v.dy2( corner ), + linesBL[ k ].setLine( + c[ corner ].centerX - v.dx1( corner ), + c[ corner ].centerY + v.dy1( corner ), + c[ corner ].centerX - v.dx2( corner ), + c[ corner ].centerY + v.dy2( corner ), borderMapBL.colorAt( k ) ); } { constexpr auto corner = BottomRight; - linesBR[j].setLine( - c[corner].centerX + v.dx1( corner ), - c[corner].centerY + v.dy1( corner ), - c[corner].centerX + v.dx2( corner ), - c[corner].centerY + v.dy2( corner ), + linesBR[ j ].setLine( + c[ corner ].centerX + v.dx1( corner ), + c[ corner ].centerY + v.dy1( corner ), + c[ corner ].centerX + v.dx2( corner ), + c[ corner ].centerY + v.dy2( corner ), borderMapBR.colorAt( j ) ); } } @@ -650,36 +649,36 @@ namespace const int j = it.step(); const int k = numFillLines - it.step() - 1; - const qreal x11 = c[TopLeft].centerX - v.dx1( TopLeft ); - const qreal x12 = c[TopRight].centerX + v.dx1( TopRight ); - const qreal y1 = c[TopLeft].centerY - v.dy1( TopLeft ); + const qreal x11 = c[ TopLeft ].centerX - v.dx1( TopLeft ); + const qreal x12 = c[ TopRight ].centerX + v.dx1( TopRight ); + const qreal y1 = c[ TopLeft ].centerY - v.dy1( TopLeft ); const auto c1 = fillMap.colorAt( ( y1 - ri.top ) / ri.height ); - const qreal x21 = c[BottomLeft].centerX - v.dx1( BottomLeft ); - const qreal x22 = c[BottomRight].centerX + v.dx1( BottomRight ); - const qreal y2 = c[BottomLeft].centerY + v.dy1( BottomLeft ); + const qreal x21 = c[ BottomLeft ].centerX - v.dx1( BottomLeft ); + const qreal x22 = c[ BottomRight ].centerX + v.dx1( BottomRight ); + const qreal y2 = c[ BottomLeft ].centerY + v.dy1( BottomLeft ); const auto c2 = fillMap.colorAt( ( y2 - ri.top ) / ri.height ); - fillLines[j].setLine( x11, y1, x12, y1, c1 ); - fillLines[k].setLine( x21, y2, x22, y2, c2 ); + fillLines[ j ].setLine( x11, y1, x12, y1, c1 ); + fillLines[ k ].setLine( x21, y2, x22, y2, c2 ); } else { const int j = stepCount - it.step(); const int k = numFillLines - 1 - stepCount + it.step(); - const qreal x1 = c[TopLeft].centerX - v.dx1( TopLeft ); - const qreal y11 = c[TopLeft].centerY - v.dy1( TopLeft ); - const qreal y12 = c[BottomLeft].centerY + v.dy1( BottomLeft );; + const qreal x1 = c[ TopLeft ].centerX - v.dx1( TopLeft ); + const qreal y11 = c[ TopLeft ].centerY - v.dy1( TopLeft ); + const qreal y12 = c[ BottomLeft ].centerY + v.dy1( BottomLeft ); const auto c1 = fillMap.colorAt( ( x1 - ri.left ) / ri.width ); - const qreal x2 = c[TopRight].centerX + v.dx1( TopRight ); - const qreal y21 = c[TopRight].centerY - v.dy1( TopRight ); - const qreal y22 = c[BottomRight].centerY + v.dy1( BottomRight );; + const qreal x2 = c[ TopRight ].centerX + v.dx1( TopRight ); + const qreal y21 = c[ TopRight ].centerY - v.dy1( TopRight ); + const qreal y22 = c[ BottomRight ].centerY + v.dy1( BottomRight ); const auto c2 = fillMap.colorAt( ( x2 - ri.left ) / ri.width ); - fillLines[j].setLine( x1, y11, x1, y12, c1 ); - fillLines[k].setLine( x2, y21, x2, y22, c2 ); + fillLines[ j ].setLine( x1, y11, x1, y12, c1 ); + fillLines[ k ].setLine( x2, y21, x2, y22, c2 ); } } } @@ -690,14 +689,14 @@ namespace const int k = 4 * numCornerLines; if ( orientation == Qt::Vertical ) - borderLines[k] = borderLines[0]; + borderLines[ k ] = borderLines[ 0 ]; else - borderLines[0] = borderLines[k]; + borderLines[ 0 ] = borderLines[ k ]; } #endif } - private: + private: const QskBoxRenderer::Metrics& m_metrics; }; } @@ -705,7 +704,7 @@ namespace static inline int qskFillLineCount( const QskBoxRenderer::Metrics& metrics, const QskGradient& gradient ) { - const int stepCount = metrics.corner[0].stepCount; + const int stepCount = metrics.corner[ 0 ].stepCount; if ( !gradient.isVisible() ) return 0; @@ -782,7 +781,8 @@ static inline int qskFillLineCount( } template< class Line, class BorderMap, class FillMap > -static inline void qskRenderLines( const QskBoxRenderer::Metrics& metrics, +static inline void qskRenderLines( + const QskBoxRenderer::Metrics& metrics, Qt::Orientation orientation, Line* borderLines, const BorderMap& borderMapTL, const BorderMap& borderMapTR, const BorderMap& borderMapBL, const BorderMap& borderMapBR, @@ -793,28 +793,32 @@ static inline void qskRenderLines( const QskBoxRenderer::Metrics& metrics, // the same border width for all edges Stroker< Line, BorderValuesUniform > stroker( metrics ); - stroker.createLines( orientation, borderLines, borderMapTL, borderMapTR, - borderMapBL, borderMapBR, fillLines, fillMap ); + stroker.createLines( orientation, borderLines, + borderMapTL, borderMapTR, borderMapBL, borderMapBR, + fillLines, fillMap ); } else { Stroker< Line, BorderValues > stroker( metrics ); - stroker.createLines( orientation, borderLines, borderMapTL, borderMapTR, - borderMapBL, borderMapBR, fillLines, fillMap ); + stroker.createLines( orientation, borderLines, + borderMapTL, borderMapTR, borderMapBL, borderMapBR, + fillLines, fillMap ); } } template< class Line, class BorderMap, class FillMap > -static inline void qskRenderLines( const QskBoxRenderer::Metrics& metrics, - Qt::Orientation orientation, Line* borderLines, - const BorderMap& borderMap, Line* fillLines, const FillMap& fillMap ) +static inline void qskRenderLines( + const QskBoxRenderer::Metrics& metrics, Qt::Orientation orientation, + Line* borderLines, const BorderMap& borderMap, Line* fillLines, + const FillMap& fillMap ) { - qskRenderLines( metrics, orientation, borderLines, borderMap, borderMap, - borderMap, borderMap, fillLines, fillMap ); + qskRenderLines( metrics, orientation, borderLines, + borderMap, borderMap, borderMap, borderMap, fillLines, fillMap ); } template< class Line, class BorderMap > -static inline void qskRenderBorderLines( const QskBoxRenderer::Metrics& metrics, +static inline void qskRenderBorderLines( + const QskBoxRenderer::Metrics& metrics, Qt::Orientation orientation, Line* lines, const BorderMap& borderMapTL, const BorderMap& borderMapTR, const BorderMap& borderMapBL, const BorderMap& borderMapBR ) @@ -824,7 +828,8 @@ static inline void qskRenderBorderLines( const QskBoxRenderer::Metrics& metrics, } template< class Line, class BorderMap > -static inline void qskRenderBorderLines( const QskBoxRenderer::Metrics& metrics, +static inline void qskRenderBorderLines( + const QskBoxRenderer::Metrics& metrics, Qt::Orientation orientation, Line* lines, const BorderMap& borderMap ) { qskRenderBorderLines( metrics, orientation, lines, @@ -850,24 +855,24 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics, } else { - const int stepCount = metrics.corner[0].stepCount; + const int stepCount = metrics.corner[ 0 ].stepCount; qskRenderBorderLines( metrics, orientation, line, BorderMapGradient( stepCount, c.rgb( Qsk::Top ), c.rgb( Qsk::Left ) ), BorderMapGradient( stepCount, c.rgb( Qsk::Right ), c.rgb( Qsk::Top ) ), BorderMapGradient( stepCount, c.rgb( Qsk::Left ), c.rgb( Qsk::Bottom ) ), - BorderMapGradient( stepCount, c.rgb( Qsk::Bottom ), c.rgb( Qsk::Right ) ) - ); + BorderMapGradient( stepCount, c.rgb( Qsk::Bottom ), c.rgb( Qsk::Right ) ) ); } } -static inline void qskRenderFillRandom( const QskBoxRenderer::Metrics& metrics, +static inline void qskRenderFillRandom( + const QskBoxRenderer::Metrics& metrics, const QskGradient& gradient, ColoredLine* line ) { if ( gradient.isMonochrome() ) { const ColorMapSolid map( gradient.startColor() ); - qskRenderFillLines( metrics, Qt::Vertical, line, map ); + qskRenderFillLines( metrics, Qt::Vertical, line, map ); } else { @@ -905,7 +910,7 @@ static inline void qskRenderBoxRandom( } else { - const int n = metrics.corner[0].stepCount; + const int n = metrics.corner[ 0 ].stepCount; const BorderMapGradient tl( n, bc.rgb( Qsk::Top ), bc.rgb( Qsk::Left ) ); const BorderMapGradient tr( n, bc.rgb( Qsk::Right ), bc.rgb( Qsk::Top ) ); @@ -928,7 +933,8 @@ static inline void qskRenderBoxRandom( } } -static inline void qskRenderFillOrdered( const QskBoxRenderer::Metrics& metrics, +static inline void qskRenderFillOrdered( + const QskBoxRenderer::Metrics& metrics, const QskGradient& gradient, ColoredLine* lines ) { const auto& r = metrics.innerQuad; @@ -938,7 +944,7 @@ static inline void qskRenderFillOrdered( const QskBoxRenderer::Metrics& metrics, implemented TODO ... */ - if( gradient.orientation() == QskGradient::Horizontal ) + if ( gradient.orientation() == QskGradient::Horizontal ) { HRectEllipseIterator it( metrics ); QskVertex::fillOrdered( it, r.left, r.right, gradient, lines ); @@ -951,21 +957,21 @@ static inline void qskRenderFillOrdered( const QskBoxRenderer::Metrics& metrics, } QskBoxRenderer::Metrics::Metrics( const QRectF& rect, - const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border ): - outerQuad( rect ) + const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border ) + : outerQuad( rect ) { isRadiusRegular = shape.isRectellipse(); for ( int i = 0; i < 4; i++ ) { - auto& c = corner[i]; + auto& c = corner[ i ]; const QSizeF radius = shape.radius( static_cast< Qt::Corner >( i ) ); c.radiusX = qBound( 0.0, radius.width(), 0.5 * outerQuad.width ); c.radiusY = qBound( 0.0, radius.height(), 0.5 * outerQuad.height ); c.stepCount = ArcIterator::segmentHint( qMax( c.radiusX, c.radiusY ) ); - switch( i ) + switch ( i ) { case TopLeft: c.centerX = outerQuad.left + c.radiusX; @@ -989,16 +995,16 @@ QskBoxRenderer::Metrics::Metrics( const QRectF& rect, } } - centerQuad.left = qMax( corner[ TopLeft].centerX, + centerQuad.left = qMax( corner[ TopLeft ].centerX, corner[ BottomLeft ].centerX ); - centerQuad.right = qMin( corner[ TopRight].centerX, + centerQuad.right = qMin( corner[ TopRight ].centerX, corner[ BottomRight ].centerX ); - centerQuad.top = qMax( corner[ TopLeft].centerY, + centerQuad.top = qMax( corner[ TopLeft ].centerY, corner[ TopRight ].centerY ); - centerQuad.bottom = qMin( corner[ BottomLeft].centerY, + centerQuad.bottom = qMin( corner[ BottomLeft ].centerY, corner[ BottomRight ].centerY ); centerQuad.width = centerQuad.right - centerQuad.left; @@ -1040,17 +1046,17 @@ QskBoxRenderer::Metrics::Metrics( const QRectF& rect, for ( int i = 0; i < 4; i++ ) { - auto& c = corner[i]; + auto& c = corner[ i ]; - switch( i ) + switch ( i ) { case TopLeft: { c.radiusInnerX = c.radiusX - borderLeft; c.radiusInnerY = c.radiusY - borderTop; - c.isCropped = ( c.centerX <= innerQuad.left ) - || ( c.centerY <= innerQuad.top ); + c.isCropped = ( c.centerX <= innerQuad.left ) || + ( c.centerY <= innerQuad.top ); break; } @@ -1059,8 +1065,8 @@ QskBoxRenderer::Metrics::Metrics( const QRectF& rect, c.radiusInnerX = c.radiusX - borderRight; c.radiusInnerY = c.radiusY - borderTop; - c.isCropped = ( c.centerX >= innerQuad.right ) - || ( c.centerY <= innerQuad.top ); + c.isCropped = ( c.centerX >= innerQuad.right ) || + ( c.centerY <= innerQuad.top ); break; } case BottomLeft: @@ -1068,8 +1074,8 @@ QskBoxRenderer::Metrics::Metrics( const QRectF& rect, c.radiusInnerX = c.radiusX - borderLeft; c.radiusInnerY = c.radiusY - borderBottom; - c.isCropped = ( c.centerX <= innerQuad.left ) - || ( c.centerY >= innerQuad.bottom ); + c.isCropped = ( c.centerX <= innerQuad.left ) || + ( c.centerY >= innerQuad.bottom ); break; } case BottomRight: @@ -1077,8 +1083,8 @@ QskBoxRenderer::Metrics::Metrics( const QRectF& rect, c.radiusInnerX = c.radiusX - borderRight; c.radiusInnerY = c.radiusY - borderBottom; - c.isCropped = ( c.centerX >= innerQuad.right ) - || ( c.centerY >= innerQuad.bottom ); + c.isCropped = ( c.centerX >= innerQuad.right ) || + ( c.centerY >= innerQuad.bottom ); break; } } @@ -1092,8 +1098,10 @@ QskBoxRenderer::Metrics::Metrics( const QRectF& rect, // number of steps for iterating over the corners - isBorderRegular = ( borderLeft == borderTop ) - && ( borderTop == borderRight ) && ( borderRight == borderBottom ); + isBorderRegular = + ( borderLeft == borderTop ) && + ( borderTop == borderRight ) && + ( borderRight == borderBottom ); } void QskBoxRenderer::renderRectellipseBorder( @@ -1108,7 +1116,7 @@ void QskBoxRenderer::renderRectellipseBorder( return; } - const int stepCount = metrics.corner[0].stepCount; + const int stepCount = metrics.corner[ 0 ].stepCount; const int lineCount = 4 * ( stepCount + 1 ) + 1; const auto line = allocateLines< Line >( geometry, lineCount ); @@ -1140,7 +1148,7 @@ void QskBoxRenderer::renderRectellipseFill( return; } - const int stepCount = metrics.corner[0].stepCount; + const int stepCount = metrics.corner[ 0 ].stepCount; int lineCount = 2 * ( stepCount + 1 ); if ( metrics.centerQuad.top >= metrics.centerQuad.bottom ) @@ -1191,7 +1199,7 @@ void QskBoxRenderer::renderRectellipse( const QRectF& rect, } } - const int stepCount = metrics.corner[0].stepCount; + const int stepCount = metrics.corner[ 0 ].stepCount; int borderLineCount = 0; if ( borderColors.isVisible() && metrics.innerQuad != metrics.outerQuad ) @@ -1250,8 +1258,8 @@ void QskBoxRenderer::renderRectellipse( const QRectF& rect, { if ( fillRandom ) { - qskRenderBoxRandom( metrics, borderColors, gradient, - line, line + fillLineCount ); + qskRenderBoxRandom( metrics, borderColors, + gradient, line, line + fillLineCount ); } else { @@ -1280,8 +1288,8 @@ void QskBoxRenderer::renderRectellipse( const QRectF& rect, if ( extraLine ) { const auto l = line + fillLineCount; - l[0].p1 = l[-1].p2; - l[0].p2 = l[1].p1; + l[ 0 ].p1 = l[ -1 ].p2; + l[ 0 ].p2 = l[ 1 ].p1; } } } diff --git a/src/nodes/QskBoxRendererRect.cpp b/src/nodes/QskBoxRendererRect.cpp index 95009a54f..990a9db87 100644 --- a/src/nodes/QskBoxRendererRect.cpp +++ b/src/nodes/QskBoxRendererRect.cpp @@ -3,12 +3,12 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ +#include "QskBoxBorderColors.h" +#include "QskBoxBorderMetrics.h" #include "QskBoxRenderer.h" #include "QskBoxRendererColorMap.h" -#include "QskBoxBorderMetrics.h" -#include "QskBoxBorderColors.h" -#include "QskGradient.h" #include "QskFunctions.h" +#include "QskGradient.h" #include "QskVertex.h" using namespace QskVertex; @@ -17,10 +17,10 @@ namespace { class VRectIterator { - public: - inline VRectIterator( const QskBoxRenderer::Quad& rect ): - m_rect( rect ), - m_value( rect.top ) + public: + inline VRectIterator( const QskBoxRenderer::Quad& rect ) + : m_rect( rect ) + , m_value( rect.top ) { } @@ -52,17 +52,17 @@ namespace return false; } - private: + private: const QskBoxRenderer::Quad& m_rect; qreal m_value; }; class HRectIterator { - public: - inline HRectIterator( const QskBoxRenderer::Quad& rect ): - m_rect( rect ), - m_value( rect.left ) + public: + inline HRectIterator( const QskBoxRenderer::Quad& rect ) + : m_rect( rect ) + , m_value( rect.left ) { } @@ -94,17 +94,17 @@ namespace return false; } - private: + private: const QskBoxRenderer::Quad& m_rect; qreal m_value; }; class DSquareIterator { - public: - inline DSquareIterator( const QskBoxRenderer::Quad& rect ): - m_rect( rect ), - m_step( 0 ) + public: + inline DSquareIterator( const QskBoxRenderer::Quad& rect ) + : m_rect( rect ) + , m_step( 0 ) { Q_ASSERT( rect.width == rect.height ); } @@ -140,7 +140,7 @@ namespace const auto color = it.colorAt( value() ); const auto& r = m_rect; - switch( m_step ) + switch ( m_step ) { case 0: { @@ -170,17 +170,17 @@ namespace return ++m_step <= 2; } - private: + private: const QskBoxRenderer::Quad& m_rect; int m_step; }; class DRectIterator { - public: - inline DRectIterator( const QskBoxRenderer::Quad& rect ): - m_rect( rect ), - m_step( 0 ) + public: + inline DRectIterator( const QskBoxRenderer::Quad& rect ) + : m_rect( rect ) + , m_step( 0 ) { const qreal w = rect.width; const qreal h = rect.height; @@ -207,7 +207,7 @@ namespace const auto color = it.color(); const auto& r = m_rect; - switch( m_step ) + switch ( m_step ) { case 1: { @@ -247,7 +247,7 @@ namespace { const auto& r = m_rect; - switch( m_step ) + switch ( m_step ) { case 0: { @@ -310,7 +310,7 @@ namespace inline qreal value() const { - switch( m_step ) + switch ( m_step ) { case 0: return 0.0; @@ -331,7 +331,7 @@ namespace return ++m_step <= 3; } - private: + private: const QskBoxRenderer::Quad& m_rect; qreal m_fx, m_fy; @@ -345,7 +345,7 @@ namespace static inline void qskCreateFillOrdered( const QskBoxRenderer::Quad& rect, const QskGradient& gradient, ColoredLine* line ) { - switch( gradient.orientation() ) + switch ( gradient.orientation() ) { case QskGradient::Horizontal: { @@ -380,7 +380,8 @@ static inline void qskCreateFillOrdered( const QskBoxRenderer::Quad& rect, } template< class ColorMap, class Line > -static inline void qskCreateFillRandom( QskGradient::Orientation orientation, +static inline void qskCreateFillRandom( + QskGradient::Orientation orientation, const QskBoxRenderer::Quad& r, const ColorMap& map, Line* line ) { if ( orientation == QskGradient::Vertical ) @@ -413,12 +414,13 @@ static inline void qskCreateBorder( ( l++ )->setLine( in.left, in.top, out.left, out.top, color ); ( l++ )->setLine( in.right, in.top, out.right, out.top, color ); - *l = line[0]; + *l = line[ 0 ]; } template< class Line > -static inline void qskCreateBorder( const QskBoxRenderer::Quad& out, - const QskBoxRenderer::Quad& in, const QskBoxBorderColors& colors, Line* line ) +static inline void qskCreateBorder( + const QskBoxRenderer::Quad& out, const QskBoxRenderer::Quad& in, + const QskBoxBorderColors& colors, Line* line ) { const Color colorLeft = colors.rgb( Qsk::Left ); const Color colorRight = colors.rgb( Qsk::Right ); @@ -483,10 +485,10 @@ void QskBoxRenderer::renderRectFill( in, ColorMapSolid( Color() ), line ); } -void QskBoxRenderer::renderRect(const QRectF& rect, - const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border, - const QskBoxBorderColors& borderColors, const QskGradient& gradient, - QSGGeometry& geometry ) +void QskBoxRenderer::renderRect( + const QRectF& rect, const QskBoxShapeMetrics& shape, + const QskBoxBorderMetrics& border, const QskBoxBorderColors& borderColors, + const QskGradient& gradient, QSGGeometry& geometry ) { Q_UNUSED( shape ); diff --git a/src/nodes/QskGraphicNode.cpp b/src/nodes/QskGraphicNode.cpp index 19657f0e3..bbf29f3d1 100644 --- a/src/nodes/QskGraphicNode.cpp +++ b/src/nodes/QskGraphicNode.cpp @@ -1,3 +1,8 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the QSkinny License, Version 1.0 + *****************************************************************************/ + #include "QskGraphicNode.h" static inline uint qskHash( @@ -10,7 +15,7 @@ static inline uint qskHash( if ( substitutions.size() > 0 ) { hash = qHashBits( substitutions.constData(), - substitutions.size() * sizeof( substitutions[0] ), hash ); + substitutions.size() * sizeof( substitutions[ 0 ] ), hash ); } const auto& commands = graphic.commands(); @@ -29,8 +34,8 @@ static inline uint qskHash( return hash; } -QskGraphicNode::QskGraphicNode(): - m_hash( 0 ) +QskGraphicNode::QskGraphicNode() + : m_hash( 0 ) { } @@ -47,8 +52,8 @@ void QskGraphicNode::setGraphic( if ( !isTextureDirty ) { const auto oldRect = QskTextureNode::rect(); - isTextureDirty = ( rect.width() != static_cast( oldRect.width() ) ) - || ( rect.height() != static_cast( oldRect.height() ) ); + isTextureDirty = ( rect.width() != static_cast< int >( oldRect.width() ) ) || + ( rect.height() != static_cast< int >( oldRect.height() ) ); } QskTextureNode::setRect( rect ); @@ -64,8 +69,8 @@ void QskGraphicNode::setGraphic( { const QRect textureRect( 0, 0, rect.width(), rect.height() ); - uint textureId = QskGraphicTextureFactory::createTexture( renderMode, - textureRect, Qt::IgnoreAspectRatio, graphic, colorFilter ); + uint textureId = QskGraphicTextureFactory::createTexture( + renderMode, textureRect, Qt::IgnoreAspectRatio, graphic, colorFilter ); QskTextureNode::setTextureId( textureId ); } diff --git a/src/nodes/QskGraphicNode.h b/src/nodes/QskGraphicNode.h index 91730433f..3c9078b43 100644 --- a/src/nodes/QskGraphicNode.h +++ b/src/nodes/QskGraphicNode.h @@ -7,24 +7,24 @@ #define QSK_GRAPHIC_NODE_H #include "QskGlobal.h" -#include "QskTextureNode.h" #include "QskGraphicTextureFactory.h" +#include "QskTextureNode.h" class QskGraphic; class QskColorFilter; class QSK_EXPORT QskGraphicNode : public QskTextureNode { -public: + public: QskGraphicNode(); ~QskGraphicNode() override; void setGraphic( const QskGraphic&, const QskColorFilter&, QskGraphicTextureFactory::RenderMode, const QRect& ); -private: + private: void setTextureId( int ) = delete; - void setRect(const QRectF& ) = delete; + void setRect( const QRectF& ) = delete; uint m_hash; }; diff --git a/src/nodes/QskPlainTextRenderer.cpp b/src/nodes/QskPlainTextRenderer.cpp index 6c674a96b..6659b7737 100644 --- a/src/nodes/QskPlainTextRenderer.cpp +++ b/src/nodes/QskPlainTextRenderer.cpp @@ -8,8 +8,8 @@ #include "QskTextOptions.h" #include -#include #include +#include QSK_QT_PRIVATE_BEGIN #include @@ -26,15 +26,16 @@ QSK_QT_PRIVATE_END #define GlyphFlag static_cast< QSGNode::Flag >( 0x800 ) -QSizeF QskPlainTextRenderer::textSize( const QString& text, - const QFont& font, const QskTextOptions& options ) +QSizeF QskPlainTextRenderer::textSize( + const QString& text, const QFont& font, const QskTextOptions& options ) { // result differs from QskTextRenderer::implicitSizeHint ??? return textRect( text, font, options, QSizeF( 10e6, 10e6 ) ).size(); } -QRectF QskPlainTextRenderer::textRect( const QString& text, - const QFont& font, const QskTextOptions& options, const QSizeF& size ) +QRectF QskPlainTextRenderer::textRect( + const QString& text, const QFont& font, const QskTextOptions& options, + const QSizeF& size ) { const QFontMetricsF fm( font ); const QRectF r( 0, 0, size.width(), size.height() ); @@ -196,11 +197,14 @@ void QskPlainTextRenderer::updateNode( const QString& text, yBaseline = ( bh % 2 ) ? qFloor( yBaseline ) : qCeil( yBaseline ); } - qskRenderText( const_cast< QQuickItem* >( item ), node, layout, yBaseline, - colors.textColor, static_cast< QQuickText::TextStyle >( style ), colors.styleColor ); + qskRenderText( + const_cast< QQuickItem* >( item ), node, layout, yBaseline, + colors.textColor, static_cast< QQuickText::TextStyle >( style ), + colors.styleColor ); } -void QskPlainTextRenderer::updateNodeColor( QSGNode* parentNode, const QColor& textColor, +void QskPlainTextRenderer::updateNodeColor( + QSGNode* parentNode, const QColor& textColor, Qsk::TextStyle style, const QColor& styleColor ) { auto glyphNode = static_cast< QSGGlyphNode* >( parentNode->firstChild() ); diff --git a/src/nodes/QskPlainTextRenderer.h b/src/nodes/QskPlainTextRenderer.h index 839f12a34..fb192d233 100644 --- a/src/nodes/QskPlainTextRenderer.h +++ b/src/nodes/QskPlainTextRenderer.h @@ -24,16 +24,20 @@ class QSGNode; namespace QskPlainTextRenderer { - QSK_EXPORT void updateNode( const QString&, const QFont&, const QskTextOptions&, + QSK_EXPORT void updateNode( + const QString&, const QFont&, const QskTextOptions&, Qsk::TextStyle, const QskTextColors&, Qt::Alignment, const QRectF&, const QQuickItem*, QSGTransformNode* ); - QSK_EXPORT void updateNodeColor( QSGNode* parentNode, - const QColor& textColor, Qsk::TextStyle, const QColor& styleColor ); + QSK_EXPORT void updateNodeColor( + QSGNode* parentNode, const QColor& textColor, + Qsk::TextStyle, const QColor& styleColor ); - QSK_EXPORT QSizeF textSize( const QString&, const QFont&, const QskTextOptions& ); - QSK_EXPORT QRectF textRect( const QString&, const QFont&, - const QskTextOptions&, const QSizeF& ); + QSK_EXPORT QSizeF textSize( const QString&, + const QFont&, const QskTextOptions& ); + + QSK_EXPORT QRectF textRect( const QString&, + const QFont&, const QskTextOptions&, const QSizeF& ); } #endif diff --git a/src/nodes/QskRichTextRenderer.cpp b/src/nodes/QskRichTextRenderer.cpp index 7854c4e01..c32f01f1c 100644 --- a/src/nodes/QskRichTextRenderer.cpp +++ b/src/nodes/QskRichTextRenderer.cpp @@ -8,8 +8,8 @@ #include "QskTextOptions.h" #include -#include #include +#include class QQuickWindow; @@ -22,7 +22,7 @@ namespace { class TextItem final : public QQuickText { - public: + public: TextItem() { // fonts are supposed to be defined in the application skin and we @@ -67,8 +67,8 @@ namespace inline void setAlignment( Qt::Alignment alignment ) { - setHAlign( ( QQuickText::HAlignment ) ( int( alignment ) & 0x0f ) ); - setVAlign( ( QQuickText::VAlignment ) ( int( alignment ) & 0xf0 ) ); + setHAlign( ( QQuickText::HAlignment )( int( alignment ) & 0x0f ) ); + setVAlign( ( QQuickText::VAlignment )( int( alignment ) & 0xf0 ) ); } inline void setOptions( const QskTextOptions& options ) @@ -116,7 +116,7 @@ namespace QQuickItemPrivate::get( this )->derefWindow(); } - protected: + protected: QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override { Q_ASSERT( false ); @@ -126,7 +126,7 @@ namespace class TextItemMap { - public: + public: ~TextItemMap() { qDeleteAll( m_hash ); @@ -143,7 +143,7 @@ namespace { auto textItem = new TextItem(); QObject::connect( thread, &QThread::finished, - textItem, [this, thread] { removeItem( thread ); } ); + textItem, [ this, thread ] { removeItem( thread ); } ); m_hash.insert( thread, textItem ); return textItem; @@ -152,7 +152,7 @@ namespace return it.value(); } - private: + private: void removeItem( const QThread* thread ) { auto textItem = m_hash.take( thread ); @@ -172,8 +172,8 @@ namespace */ Q_GLOBAL_STATIC( TextItemMap, qskTextItemMap ) -QSizeF QskRichTextRenderer::textSize( const QString& text, - const QFont& font, const QskTextOptions& options ) +QSizeF QskRichTextRenderer::textSize( + const QString& text, const QFont& font, const QskTextOptions& options ) { auto& textItem = *qskTextItemMap->item(); @@ -194,8 +194,9 @@ QSizeF QskRichTextRenderer::textSize( const QString& text, return sz; } -QRectF QskRichTextRenderer::textRect( const QString& text, - const QFont& font, const QskTextOptions& options, const QSizeF& size ) +QRectF QskRichTextRenderer::textRect( + const QString& text, const QFont& font, + const QskTextOptions& options, const QSizeF& size ) { auto& textItem = *qskTextItemMap->item(); @@ -219,11 +220,11 @@ QRectF QskRichTextRenderer::textRect( const QString& text, return rect; } -void QskRichTextRenderer::updateNode( const QString& text, - const QFont& font, const QskTextOptions& options, - Qsk::TextStyle style, const QskTextColors& colors, - Qt::Alignment alignment, const QRectF& rect, - const QQuickItem* item, QSGTransformNode* node ) +void QskRichTextRenderer::updateNode( + const QString& text, const QFont& font, + const QskTextOptions& options, Qsk::TextStyle style, + const QskTextColors& colors, Qt::Alignment alignment, + const QRectF& rect, const QQuickItem* item, QSGTransformNode* node ) { // are we killing internal caches of QQuickText, when always using // the same item for the creation the text nodes. TODO ... diff --git a/src/nodes/QskRichTextRenderer.h b/src/nodes/QskRichTextRenderer.h index 17bb6ff1a..9d46c4d82 100644 --- a/src/nodes/QskRichTextRenderer.h +++ b/src/nodes/QskRichTextRenderer.h @@ -22,14 +22,16 @@ class QSGTransformNode; namespace QskRichTextRenderer { - QSK_EXPORT void updateNode( const QString&, const QFont&, const QskTextOptions&, - Qsk::TextStyle, const QskTextColors&, Qt::Alignment, const QRectF&, - const QQuickItem*, QSGTransformNode* ); + QSK_EXPORT void updateNode( + const QString&, const QFont&, const QskTextOptions&, + Qsk::TextStyle, const QskTextColors&, Qt::Alignment, + const QRectF&, const QQuickItem*, QSGTransformNode* ); - QSK_EXPORT QSizeF textSize( const QString&, const QFont&, const QskTextOptions& ); + QSK_EXPORT QSizeF textSize( + const QString&, const QFont&, const QskTextOptions& ); - QSK_EXPORT QRectF textRect( const QString&, const QFont&, - const QskTextOptions&, const QSizeF& ); + QSK_EXPORT QRectF textRect( + const QString&, const QFont&, const QskTextOptions&, const QSizeF& ); } #endif diff --git a/src/nodes/QskTextNode.cpp b/src/nodes/QskTextNode.cpp index 54a856cff..be154d2f0 100644 --- a/src/nodes/QskTextNode.cpp +++ b/src/nodes/QskTextNode.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskTextNode.h" -#include "QskTextOptions.h" #include "QskTextColors.h" +#include "QskTextOptions.h" #include "QskTextRenderer.h" #include @@ -17,20 +17,20 @@ static inline uint qskHash( Qt::Alignment alignment, Qsk::TextStyle textStyle ) { uint hash = 11000; - + hash = qHash( text, hash ); hash = qHash( font, hash ); hash = qHash( options, hash ); hash = qHash( alignment, hash ); - hash = qHash( textStyle, hash ); - hash = colors.hash( hash ); + hash = qHash( textStyle, hash ); + hash = colors.hash( hash ); hash = qHashBits( &size, sizeof( QSizeF ), hash ); return hash; } -QskTextNode::QskTextNode(): - m_hash( 0 ) +QskTextNode::QskTextNode() + : m_hash( 0 ) { } @@ -38,9 +38,9 @@ QskTextNode::~QskTextNode() { } -void QskTextNode::setTextData( const QQuickItem* item, - const QString& text, const QRectF& rect, const QFont& font, - const QskTextOptions& options, const QskTextColors& colors, +void QskTextNode::setTextData( + const QQuickItem* item, const QString& text, const QRectF& rect, + const QFont& font, const QskTextOptions& options, const QskTextColors& colors, Qt::Alignment alignment, Qsk::TextStyle textStyle ) { QMatrix4x4 matrix; diff --git a/src/nodes/QskTextNode.h b/src/nodes/QskTextNode.h index 1843908c8..e4fab7503 100644 --- a/src/nodes/QskTextNode.h +++ b/src/nodes/QskTextNode.h @@ -9,8 +9,8 @@ #include "QskGlobal.h" #include "QskNamespace.h" -#include #include +#include class QskTextOptions; class QskTextColors; @@ -20,7 +20,7 @@ class QQuickItem; class QSK_EXPORT QskTextNode : public QSGTransformNode { -public: + public: QskTextNode(); ~QskTextNode() override; @@ -29,7 +29,7 @@ class QSK_EXPORT QskTextNode : public QSGTransformNode const QskTextOptions&, const QskTextColors&, Qt::Alignment, Qsk::TextStyle ); -private: + private: uint m_hash; }; diff --git a/src/nodes/QskTextRenderer.cpp b/src/nodes/QskTextRenderer.cpp index e69cae8b0..261feac2d 100644 --- a/src/nodes/QskTextRenderer.cpp +++ b/src/nodes/QskTextRenderer.cpp @@ -4,8 +4,8 @@ *****************************************************************************/ #include "QskTextRenderer.h" -#include "QskRichTextRenderer.h" #include "QskPlainTextRenderer.h" +#include "QskRichTextRenderer.h" #include "QskTextOptions.h" #include @@ -14,8 +14,8 @@ Since Qt 5.7 QQuickTextNode is exported as Q_QUICK_PRIVATE_EXPORT and could be used. TODO ... */ -QSizeF QskTextRenderer::textSize( const QString& text, - const QFont& font, const QskTextOptions& options ) +QSizeF QskTextRenderer::textSize( + const QString& text, const QFont& font, const QskTextOptions& options ) { if ( options.effectiveFormat( text ) == QskTextOptions::PlainText ) return QskPlainTextRenderer::textSize( text, font, options ); @@ -23,8 +23,9 @@ QSizeF QskTextRenderer::textSize( const QString& text, return QskRichTextRenderer::textSize( text, font, options ); } -QSizeF QskTextRenderer::textSize( const QString& text, - const QFont& font, const QskTextOptions& options, const QSizeF& size ) +QSizeF QskTextRenderer::textSize( + const QString& text, const QFont& font, const QskTextOptions& options, + const QSizeF& size ) { if ( options.effectiveFormat( text ) == QskTextOptions::PlainText ) return QskPlainTextRenderer::textRect( text, font, options, size ).size(); @@ -32,20 +33,19 @@ QSizeF QskTextRenderer::textSize( const QString& text, return QskRichTextRenderer::textRect( text, font, options, size ).size(); } -void QskTextRenderer::updateNode( const QString& text, - const QFont& font, const QskTextOptions& options, - Qsk::TextStyle style, const QskTextColors& colors, - Qt::Alignment alignment, const QRectF& rect, - const QQuickItem* item, QSGTransformNode* node ) +void QskTextRenderer::updateNode( + const QString& text, const QFont& font, const QskTextOptions& options, + Qsk::TextStyle style, const QskTextColors& colors, Qt::Alignment alignment, + const QRectF& rect, const QQuickItem* item, QSGTransformNode* node ) { if ( options.format() == QskTextOptions::PlainText ) { - QskPlainTextRenderer::updateNode( text, font, options, style, - colors, alignment, rect, item, node ); + QskPlainTextRenderer::updateNode( + text, font, options, style, colors, alignment, rect, item, node ); } else { - QskRichTextRenderer::updateNode( text, font, options, style, - colors, alignment, rect, item, node ); + QskRichTextRenderer::updateNode( + text, font, options, style, colors, alignment, rect, item, node ); } } diff --git a/src/nodes/QskTextRenderer.h b/src/nodes/QskTextRenderer.h index 7415c2304..888e69459 100644 --- a/src/nodes/QskTextRenderer.h +++ b/src/nodes/QskTextRenderer.h @@ -8,6 +8,7 @@ #include "QskGlobal.h" #include "QskNamespace.h" + #include class QskTextColors; @@ -22,14 +23,16 @@ class QSGTransformNode; namespace QskTextRenderer { - QSK_EXPORT void updateNode( const QString&, const QFont&, const QskTextOptions&, - Qsk::TextStyle, const QskTextColors&, Qt::Alignment, const QRectF&, + QSK_EXPORT void updateNode( + const QString&, const QFont&, const QskTextOptions&, Qsk::TextStyle, + const QskTextColors&, Qt::Alignment, const QRectF&, const QQuickItem*, QSGTransformNode* ); - QSK_EXPORT QSizeF textSize( const QString&, const QFont&, const QskTextOptions& ); + QSK_EXPORT QSizeF textSize( + const QString&, const QFont&, const QskTextOptions& ); - QSK_EXPORT QSizeF textSize( const QString&, const QFont&, - const QskTextOptions&, const QSizeF& ); + QSK_EXPORT QSizeF textSize( + const QString&, const QFont&, const QskTextOptions&, const QSizeF& ); } #endif diff --git a/src/nodes/QskTextureNode.cpp b/src/nodes/QskTextureNode.cpp index 31d4f1254..ad305d2d6 100644 --- a/src/nodes/QskTextureNode.cpp +++ b/src/nodes/QskTextureNode.cpp @@ -1,17 +1,17 @@ #include "QskTextureNode.h" +#include #include #include -#include #include #if 1 -#include -#include #include +#include #include +#include static inline qreal qskDevicePixelRatio() { @@ -21,9 +21,9 @@ static inline qreal qskDevicePixelRatio() if ( context->surface()->surfaceClass() == QSurface::Window ) { - auto *window = static_cast< QWindow* >( context->surface() ); + auto* window = static_cast< QWindow* >( context->surface() ); - if ( auto* quickWindow = qobject_cast< QQuickWindow *>( window ) ) + if ( auto* quickWindow = qobject_cast< QQuickWindow* >( window ) ) ratio = quickWindow->effectiveDevicePixelRatio(); else ratio = window->devicePixelRatio(); @@ -45,16 +45,16 @@ namespace { class MaterialShader final : public QSGMaterialShader { - public: + public: MaterialShader( bool isOpaque ); char const* const* attributeNames() const override; void updateState( const RenderState&, QSGMaterial*, QSGMaterial* ) override; - protected: + protected: void initialize() override; - private: + private: int m_matrixId; int m_opacityId; @@ -63,7 +63,7 @@ namespace class Material final : public QSGMaterial { - public: + public: Material( bool isOpaque ); QSGMaterialType* type() const override; @@ -72,26 +72,26 @@ namespace void setTextureId( uint ); uint textureId() const; - int compare(const QSGMaterial* ) const override; + int compare( const QSGMaterial* ) const override; - private: + private: uint m_textureId; const bool m_isOpaque : 1; }; - MaterialShader::MaterialShader( bool isOpaque ): - m_isOpaque( isOpaque ) + MaterialShader::MaterialShader( bool isOpaque ) + : m_isOpaque( isOpaque ) { - setShaderSourceFile(QOpenGLShader::Vertex, - QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert") ); + setShaderSourceFile( QOpenGLShader::Vertex, + QStringLiteral( ":/qt-project.org/scenegraph/shaders/opaquetexture.vert" ) ); - setShaderSourceFile(QOpenGLShader::Fragment, - QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.frag") ); + setShaderSourceFile( QOpenGLShader::Fragment, + QStringLiteral( ":/qt-project.org/scenegraph/shaders/opaquetexture.frag" ) ); if ( !m_isOpaque ) { - setShaderSourceFile(QOpenGLShader::Fragment, - QStringLiteral(":/qt-project.org/scenegraph/shaders/texture.frag") ); + setShaderSourceFile( QOpenGLShader::Fragment, + QStringLiteral( ":/qt-project.org/scenegraph/shaders/texture.frag" ) ); } } @@ -101,8 +101,8 @@ namespace return attr; } - void MaterialShader::updateState( const RenderState& state, - QSGMaterial* newMaterial, QSGMaterial* oldMaterial) + void MaterialShader::updateState( + const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial ) { if ( !m_isOpaque && state.isOpacityDirty() ) program()->setUniformValue( m_opacityId, state.opacity() ); @@ -110,8 +110,8 @@ namespace auto* materialOld = static_cast< Material* >( oldMaterial ); auto* materialNew = static_cast< Material* >( newMaterial ); - if ( ( materialOld == nullptr ) - || ( materialOld->textureId() != materialNew->textureId() ) ) + if ( ( materialOld == nullptr ) || + ( materialOld->textureId() != materialNew->textureId() ) ) { auto funcs = QOpenGLContext::currentContext()->functions(); funcs->glBindTexture( GL_TEXTURE_2D, materialNew->textureId() ); @@ -123,17 +123,17 @@ namespace void MaterialShader::initialize() { - m_matrixId = program()->uniformLocation("qt_Matrix"); + m_matrixId = program()->uniformLocation( "qt_Matrix" ); if ( !m_isOpaque ) - m_opacityId = program()->uniformLocation("opacity"); + m_opacityId = program()->uniformLocation( "opacity" ); } - Material::Material( bool isOpaque ) : - m_textureId(0), - m_isOpaque( isOpaque ) + Material::Material( bool isOpaque ) + : m_textureId( 0 ) + , m_isOpaque( isOpaque ) { - setFlag(Blending, true ); // alpha blending + setFlag( Blending, true ); // alpha blending } void Material::setTextureId( uint id ) @@ -178,11 +178,11 @@ namespace class QskTextureNodePrivate final : public QSGGeometryNodePrivate { -public: - QskTextureNodePrivate(): - geometry( QSGGeometry::defaultAttributes_TexturedPoint2D(), 4 ), - opaqueMaterial( true ), - material( false ) + public: + QskTextureNodePrivate() + : geometry( QSGGeometry::defaultAttributes_TexturedPoint2D(), 4 ) + , opaqueMaterial( true ) + , material( false ) { } @@ -195,8 +195,8 @@ class QskTextureNodePrivate final : public QSGGeometryNodePrivate Qt::Orientations mirrorOrientations; }; -QskTextureNode::QskTextureNode() : - QSGGeometryNode( *new QskTextureNodePrivate ) +QskTextureNode::QskTextureNode() + : QSGGeometryNode( *new QskTextureNodePrivate ) { Q_D( QskTextureNode ); @@ -226,11 +226,11 @@ QskTextureNode::~QskTextureNode() } } -void QskTextureNode::setRect(const QRectF& r) +void QskTextureNode::setRect( const QRectF& r ) { Q_D( QskTextureNode ); - if ( d->rect == r) + if ( d->rect == r ) return; d->rect = r; @@ -289,7 +289,7 @@ void QskTextureNode::setMirrored( Qt::Orientations orientations ) d->mirrorOrientations = orientations; updateTexture(); - markDirty(DirtyMaterial); + markDirty( DirtyMaterial ); } Qt::Orientations QskTextureNode::mirrored() const diff --git a/src/nodes/QskTextureNode.h b/src/nodes/QskTextureNode.h index 933a23907..440bdeada 100644 --- a/src/nodes/QskTextureNode.h +++ b/src/nodes/QskTextureNode.h @@ -8,18 +8,18 @@ #include "QskGlobal.h" -#include #include +#include class QskTextureNodePrivate; class QSK_EXPORT QskTextureNode : public QSGGeometryNode { -public: + public: QskTextureNode(); ~QskTextureNode() override; - void setRect(const QRectF& rect); + void setRect( const QRectF& ); QRectF rect() const; void setTextureId( uint id ); @@ -28,7 +28,7 @@ class QSK_EXPORT QskTextureNode : public QSGGeometryNode void setMirrored( Qt::Orientations ); Qt::Orientations mirrored() const; -private: + private: void updateTexture(); Q_DECLARE_PRIVATE( QskTextureNode ) diff --git a/src/nodes/QskVertex.cpp b/src/nodes/QskVertex.cpp index 2218cd07e..794ed7ea6 100644 --- a/src/nodes/QskVertex.cpp +++ b/src/nodes/QskVertex.cpp @@ -65,4 +65,3 @@ void QskVertex::debugGeometry( const QSGGeometry& geometry ) qskDebugGeometry( lines, lineCount ); } } - diff --git a/src/nodes/QskVertex.h b/src/nodes/QskVertex.h index c9073304e..5937ffa9a 100644 --- a/src/nodes/QskVertex.h +++ b/src/nodes/QskVertex.h @@ -8,15 +8,16 @@ #include "QskGlobal.h" -#include #include +#include namespace QskVertex { class QSK_EXPORT Color { - public: + public: constexpr Color(); + constexpr Color( unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha ); @@ -33,7 +34,7 @@ namespace QskVertex class QSK_EXPORT Line { - public: + public: inline void setLine( float x1, float y1, float x2, float y2 ) { p1.set( x1, y1 ); @@ -64,7 +65,7 @@ namespace QskVertex class QSK_EXPORT ColoredLine { - public: + public: inline void setLine( float x1, float y1, Color c1, float x2, float y2, Color c2 ) { @@ -100,20 +101,20 @@ namespace QskVertex void QSK_EXPORT debugGeometry( const QSGGeometry& ); - inline constexpr Color::Color(): - r( 0 ), - g( 0 ), - b( 0 ), - a( 255 ) + inline constexpr Color::Color() + : r( 0 ) + , g( 0 ) + , b( 0 ) + , a( 255 ) { } inline constexpr Color::Color( unsigned char red, unsigned char green, - unsigned char blue, unsigned char alpha ): - r( red ), - g( green ), - b( blue ), - a( alpha ) + unsigned char blue, unsigned char alpha ) + : r( red ) + , g( green ) + , b( blue ) + , a( alpha ) { } @@ -134,8 +135,8 @@ namespace QskVertex } } - inline Color::Color( const QColor& color ): - Color( color.rgba() ) + inline Color::Color( const QColor& color ) + : Color( color.rgba() ) { } @@ -167,9 +168,9 @@ namespace QskVertex } #ifndef QT_NO_DEBUG_STREAM - QDebug operator<<( QDebug debug, QskVertex::Color ); - QDebug operator<<( QDebug debug, QskVertex::ColoredLine ); - QDebug operator<<( QDebug debug, QskVertex::Line ); +QDebug operator<<( QDebug debug, QskVertex::Color ); +QDebug operator<<( QDebug debug, QskVertex::ColoredLine ); +QDebug operator<<( QDebug debug, QskVertex::Line ); #endif #endif