From 6f74463a80d608808c2136c617bd2672da9dacd9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Aug 2019 21:00:36 +0200 Subject: [PATCH] [libcalamaresui] Apply coding style to utils/ --- src/libcalamaresui/utils/CalamaresUtilsGui.cpp | 18 ++++++++++++++---- src/libcalamaresui/utils/CalamaresUtilsGui.h | 12 +++++------- src/libcalamaresui/utils/ImageRegistry.cpp | 2 +- src/libcalamaresui/utils/ImageRegistry.h | 2 +- src/libcalamaresui/utils/PythonQtUtils.cpp | 4 +++- src/libcalamaresui/utils/PythonQtUtils.h | 4 ++-- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index 808c805cb..b6c927763 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -34,11 +34,10 @@ namespace CalamaresUtils { -static int s_defaultFontSize = 0; +static int s_defaultFontSize = 0; static int s_defaultFontHeight = 0; - QPixmap defaultPixmap( ImageType type, ImageMode mode, const QSize& size ) { @@ -152,11 +151,15 @@ createRoundedImage( const QPixmap& pixmap, const QSize& size, float frameWidthPc } if ( !height || !width ) + { return QPixmap(); + } QPixmap scaledAvatar = pixmap.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); if ( frameWidthPct == 0.00f ) + { return scaledAvatar; + } QPixmap frame( width, height ); frame.fill( Qt::transparent ); @@ -172,7 +175,8 @@ createRoundedImage( const QPixmap& pixmap, const QSize& size, float frameWidthPc painter.setBrush( brush ); painter.setPen( pen ); - painter.drawRoundedRect( outerRect, qreal( frameWidthPct ) * 100.0, qreal( frameWidthPct ) * 100.0, Qt::RelativeSize ); + painter.drawRoundedRect( + outerRect, qreal( frameWidthPct ) * 100.0, qreal( frameWidthPct ) * 100.0, Qt::RelativeSize ); return frame; } @@ -189,7 +193,9 @@ unmarginLayout( QLayout* layout ) { QLayout* childLayout = layout->itemAt( i )->layout(); if ( childLayout ) + { unmarginLayout( childLayout ); + } } } @@ -255,13 +261,17 @@ clearLayout( QLayout* layout ) while ( QLayoutItem* item = layout->takeAt( 0 ) ) { if ( QWidget* widget = item->widget() ) + { widget->deleteLater(); + } if ( QLayout* childLayout = item->layout() ) + { clearLayout( childLayout ); + } delete item; } } -} // namespace +} // namespace CalamaresUtils diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index 72430a083..012795e34 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -56,7 +56,7 @@ enum ImageType : int PartitionTable, BootEnvironment, Squid, - StatusOk, // Icons for the requirements checker + StatusOk, // Icons for the requirements checker StatusWarning, StatusError }; @@ -94,9 +94,7 @@ UIDLLEXPORT QPixmap defaultPixmap( ImageType type, * @return the transformed pixmap. * This one is currently unused. */ -UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, - const QSize& size, - float frameWidthPct = 0.20f ); +UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f ); /** * @brief unmarginLayout recursively walks the QLayout tree and removes all margins. @@ -112,8 +110,8 @@ UIDLLEXPORT void unmarginLayout( QLayout* layout ); UIDLLEXPORT void clearLayout( QLayout* layout ); UIDLLEXPORT void setDefaultFontSize( int points ); -UIDLLEXPORT int defaultFontSize(); // in points -UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific +UIDLLEXPORT int defaultFontSize(); // in points +UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific UIDLLEXPORT QFont defaultFont(); UIDLLEXPORT QFont largeFont(); UIDLLEXPORT QSize defaultIconSize(); @@ -128,4 +126,4 @@ constexpr int windowPreferredHeight = 520; } // namespace CalamaresUtils -#endif // CALAMARESUTILSGUI_H +#endif // CALAMARESUTILSGUI_H diff --git a/src/libcalamaresui/utils/ImageRegistry.cpp b/src/libcalamaresui/utils/ImageRegistry.cpp index 5cffac11c..1c3b9433e 100644 --- a/src/libcalamaresui/utils/ImageRegistry.cpp +++ b/src/libcalamaresui/utils/ImageRegistry.cpp @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPLv3+ * License-Filename: LICENSES/GPLv3+-ImageRegistry - * + * * Copyright 2019, Adriaan de Groot */ diff --git a/src/libcalamaresui/utils/ImageRegistry.h b/src/libcalamaresui/utils/ImageRegistry.h index 06ab45831..454cb500d 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPLv3+ * License-Filename: LICENSES/GPLv3+-ImageRegistry - * + * * Copyright 2019, Adriaan de Groot */ diff --git a/src/libcalamaresui/utils/PythonQtUtils.cpp b/src/libcalamaresui/utils/PythonQtUtils.cpp index 201fe6635..3a60839a4 100644 --- a/src/libcalamaresui/utils/PythonQtUtils.cpp +++ b/src/libcalamaresui/utils/PythonQtUtils.cpp @@ -34,11 +34,13 @@ lookupAndCall( PyObject* object, { PythonQtObjectPtr callable = PythonQt::self()->lookupCallable( object, name ); if ( callable ) + { return callable.call( args, kwargs ); + } } // If we haven't found a callable with the given names, we force an error: return PythonQt::self()->call( object, candidateNames.first(), args, kwargs ); } -} +} // namespace CalamaresUtils diff --git a/src/libcalamaresui/utils/PythonQtUtils.h b/src/libcalamaresui/utils/PythonQtUtils.h index 22a248cea..dc889b2d0 100644 --- a/src/libcalamaresui/utils/PythonQtUtils.h +++ b/src/libcalamaresui/utils/PythonQtUtils.h @@ -33,6 +33,6 @@ QVariant lookupAndCall( PyObject* object, const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap() ); -} //ns +} // namespace CalamaresUtils -#endif // PYTHONQTUTILS_H +#endif // PYTHONQTUTILS_H