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

View File

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

View File

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

View File

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