[libcalamaresui] Apply coding style to remainder

This commit is contained in:
Adriaan de Groot 2019-08-13 21:07:46 +02:00
parent d44e8f6115
commit e7dedbbfe0
5 changed files with 56 additions and 31 deletions

View File

@ -52,6 +52,8 @@ Branding::instance()
}
// *INDENT-OFF*
// clang-format off
const QStringList Branding::s_stringEntryStrings =
{
"productName",
@ -82,15 +84,21 @@ const QStringList Branding::s_styleEntryStrings =
"sidebarTextSelect",
"sidebarTextHighlight"
};
// clang-format on
// *INDENT-ON*
const NamedEnumTable<Branding::WindowDimensionUnit>&
Branding::WindowDimension::suffixes()
{
using Unit = Branding::WindowDimensionUnit;
// *INDENT-OFF*
// clang-format off
static const NamedEnumTable<Unit> names{
{"px", Unit::Pixies},
{"em", Unit::Fonties}
};
// clang-format on
// *INDENT-ON*
return names;
}

View File

@ -25,13 +25,13 @@
#include "utils/NamedSuffix.h"
#include <QMap>
#include <QObject>
#include <QStringList>
#include <QMap>
namespace YAML
{
class Node;
class Node;
}
namespace Calamares
@ -79,27 +79,39 @@ public:
};
/** @brief Setting for how much the main window may expand. */
enum class WindowExpansion { Normal, Fullscreen, Fixed } ;
enum class WindowExpansion
{
Normal,
Fullscreen,
Fixed
};
/** @brief Setting for the main window size.
*
* The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which
* we suffix as "em", e.g. "600px" or "32em".
*/
enum class WindowDimensionUnit { None, Pixies, Fonties };
class WindowDimension : public NamedSuffix<WindowDimensionUnit, WindowDimensionUnit::None>
enum class WindowDimensionUnit
{
None,
Pixies,
Fonties
};
class WindowDimension : public NamedSuffix< WindowDimensionUnit, WindowDimensionUnit::None >
{
public:
static const NamedEnumTable< WindowDimensionUnit >& suffixes();
static const NamedEnumTable< WindowDimensionUnit >& suffixes();
bool isValid() const;
using NamedSuffix::NamedSuffix;
WindowDimension( const QString& s ) : NamedSuffix( suffixes(), s ) {}
} ;
WindowDimension( const QString& s )
: NamedSuffix( suffixes(), s )
{
}
};
static Branding* instance();
explicit Branding( const QString& brandingFilePath,
QObject* parent = nullptr );
explicit Branding( const QString& brandingFilePath, QObject* parent = nullptr );
/** @brief Complete path of the branding descriptor file. */
QString descriptorPath() const { return m_descriptorPath; }
@ -184,11 +196,14 @@ private:
WindowExpansion m_windowExpansion;
WindowDimension m_windowHeight, m_windowWidth;
};
template<typename U> inline QString operator*(U e) { return Branding::instance()->string( e ); }
template < typename U >
inline QString operator*( U e )
{
return Branding::instance()->string( e );
}
#endif // BRANDING_H
} // namespace Calamares
#endif // BRANDING_H

View File

@ -23,10 +23,10 @@
#include "Branding.h"
#include "Job.h"
#include "JobQueue.h"
#include "modulesystem/Module.h"
#include "modulesystem/ModuleManager.h"
#include "Settings.h"
#include "ViewManager.h"
#include "modulesystem/Module.h"
#include "modulesystem/ModuleManager.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Dirs.h"
@ -56,7 +56,7 @@ callQMLFunction( QQuickItem* qmlObject, const char* method )
QByteArray methodSignature( method );
methodSignature.append( "()" );
if ( qmlObject && qmlObject->metaObject()->indexOfMethod( methodSignature ) >= 0 )
if ( qmlObject && qmlObject->metaObject()->indexOfMethod( methodSignature ) >= 0 )
{
QVariant returnValue;
QMetaObject::invokeMethod( qmlObject, method, Q_RETURN_ARG( QVariant, returnValue ) );
@ -117,9 +117,7 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
QString
ExecutionViewStep::prettyName() const
{
return Calamares::Settings::instance()->isSetupMode()
? tr( "Set up" )
: tr( "Install" );
return Calamares::Settings::instance()->isSetupMode() ? tr( "Set up" ) : tr( "Install" );
}
@ -176,8 +174,7 @@ ExecutionViewStep::loadQmlV2()
{
m_qmlComponent = new QQmlComponent( m_qmlShow->engine(),
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ),
QQmlComponent::CompilationMode::Asynchronous
);
QQmlComponent::CompilationMode::Asynchronous );
connect( m_qmlComponent, &QQmlComponent::statusChanged, this, &ExecutionViewStep::loadQmlV2Complete );
}
}
@ -194,14 +191,17 @@ ExecutionViewStep::loadQmlV2Complete()
QObject* o = m_qmlComponent->create();
m_qmlObject = qobject_cast< QQuickItem* >( o );
if ( !m_qmlObject )
{
delete o;
}
else
{
// setContent() is public API, but not documented publicly.
// It is marked \internal in the Qt sources, but does exactly
// what is needed: sets up visual parent by replacing the root
// item, and handling resizes.
m_qmlShow->setContent( QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), m_qmlComponent, m_qmlObject );
m_qmlShow->setContent(
QUrl::fromLocalFile( Calamares::Branding::instance()->slideshowPath() ), m_qmlComponent, m_qmlObject );
if ( ViewManager::instance()->currentStep() == this )
{
// We're alreay visible! Must have been slow QML loading, and we
@ -235,8 +235,10 @@ ExecutionViewStep::onActivate()
auto jl = module->jobs();
if ( module->isEmergency() )
{
for( auto& j : jl )
for ( auto& j : jl )
{
j->setEmergency( true );
}
}
queue->enqueue( jl );
}
@ -279,4 +281,4 @@ ExecutionViewStep::onLeave()
}
}
} // namespace
} // namespace Calamares

View File

@ -77,6 +77,6 @@ private:
void updateFromJobQueue( qreal percent, const QString& message );
};
}
} // namespace Calamares
#endif /* EXECUTIONVIEWSTEP_H */

View File

@ -22,11 +22,11 @@
#include <QtCore/qglobal.h>
#ifndef UIDLLEXPORT
# if defined (UIDLLEXPORT_PRO)
# define UIDLLEXPORT Q_DECL_EXPORT
# else
# define UIDLLEXPORT Q_DECL_IMPORT
# endif
#if defined( UIDLLEXPORT_PRO )
#define UIDLLEXPORT Q_DECL_EXPORT
#else
#define UIDLLEXPORT Q_DECL_IMPORT
#endif
#endif
#endif