Merge branch 'brand-language'
This commit is contained in:
commit
4c6218f005
@ -129,16 +129,16 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
, m_welcomeExpandingLogo( true )
|
, m_welcomeExpandingLogo( true )
|
||||||
{
|
{
|
||||||
cDebug() << "Using Calamares branding file at" << brandingFilePath;
|
cDebug() << "Using Calamares branding file at" << brandingFilePath;
|
||||||
|
|
||||||
|
QDir componentDir( componentDirectory() );
|
||||||
|
if ( !componentDir.exists() )
|
||||||
|
bail( "Bad component directory path." );
|
||||||
|
|
||||||
QFile file( brandingFilePath );
|
QFile file( brandingFilePath );
|
||||||
if ( file.exists() && file.open( QFile::ReadOnly | QFile::Text ) )
|
if ( file.exists() && file.open( QFile::ReadOnly | QFile::Text ) )
|
||||||
{
|
{
|
||||||
QByteArray ba = file.readAll();
|
QByteArray ba = file.readAll();
|
||||||
|
|
||||||
QFileInfo fi ( m_descriptorPath );
|
|
||||||
QDir componentDir = fi.absoluteDir();
|
|
||||||
if ( !componentDir.exists() )
|
|
||||||
bail( "Bad component directory path." );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
YAML::Node doc = YAML::Load( ba.constData() );
|
YAML::Node doc = YAML::Load( ba.constData() );
|
||||||
@ -146,7 +146,7 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
|
|
||||||
m_componentName = QString::fromStdString( doc[ "componentName" ]
|
m_componentName = QString::fromStdString( doc[ "componentName" ]
|
||||||
.as< std::string >() );
|
.as< std::string >() );
|
||||||
if ( m_componentName != QFileInfo( m_descriptorPath ).absoluteDir().dirName() )
|
if ( m_componentName != componentDir.dirName() )
|
||||||
bail( "The branding component name should match the name of the "
|
bail( "The branding component name should match the name of the "
|
||||||
"component directory." );
|
"component directory." );
|
||||||
|
|
||||||
@ -186,6 +186,7 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
loadStrings( m_images, doc, "images",
|
loadStrings( m_images, doc, "images",
|
||||||
[&]( const QString& s ) -> QString
|
[&]( const QString& s ) -> QString
|
||||||
{
|
{
|
||||||
|
// See also image()
|
||||||
const QString imageName( expand( s ) );
|
const QString imageName( expand( s ) );
|
||||||
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
||||||
if ( !imageFi.exists() )
|
if ( !imageFi.exists() )
|
||||||
@ -314,6 +315,22 @@ Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap
|
||||||
|
Branding::image(const QString& imageName, const QSize& size) const
|
||||||
|
{
|
||||||
|
QDir componentDir( componentDirectory() );
|
||||||
|
QFileInfo imageFi( componentDir.absoluteFilePath( imageName ) );
|
||||||
|
if ( !imageFi.exists() )
|
||||||
|
{
|
||||||
|
const auto icon = QIcon::fromTheme( imageName );
|
||||||
|
// Not found, bail out with the filename used
|
||||||
|
if ( icon.isNull() )
|
||||||
|
return QPixmap();
|
||||||
|
return icon.pixmap( size );
|
||||||
|
}
|
||||||
|
return ImageRegistry::instance()->pixmap( imageFi.absoluteFilePath(), size );
|
||||||
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Branding::stylesheet() const
|
Branding::stylesheet() const
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,16 @@ public:
|
|||||||
QString styleString( Branding::StyleEntry styleEntry ) const;
|
QString styleString( Branding::StyleEntry styleEntry ) const;
|
||||||
QString imagePath( Branding::ImageEntry imageEntry ) const;
|
QString imagePath( Branding::ImageEntry imageEntry ) const;
|
||||||
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
|
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
|
||||||
|
|
||||||
|
/** @brief Look up an image in the branding directory or as an icon
|
||||||
|
*
|
||||||
|
* The @p name is checked in the branding directory: if it is an image
|
||||||
|
* file, return the pixmap from that file, at the requested size.
|
||||||
|
* If it isn't a file, look it up as an icon name in the current theme.
|
||||||
|
* May return a null pixmap if nothing is found.
|
||||||
|
*/
|
||||||
|
QPixmap image( const QString& name, const QSize& size ) const;
|
||||||
|
|
||||||
/** @brief Stylesheet to apply for this branding. May be empty.
|
/** @brief Stylesheet to apply for this branding. May be empty.
|
||||||
*
|
*
|
||||||
* The file is loaded every time this function is called, so
|
* The file is loaded every time this function is called, so
|
||||||
|
@ -270,6 +270,12 @@ WelcomePage::externallySelectedLanguage( int row )
|
|||||||
ui->languageWidget->setCurrentIndex( row );
|
ui->languageWidget->setCurrentIndex( row );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WelcomePage::setLanguageIcon( QPixmap i )
|
||||||
|
{
|
||||||
|
ui->languageIcon->setPixmap( i );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocaleTwoColumnDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
LocaleTwoColumnDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
|
@ -42,6 +42,8 @@ public:
|
|||||||
void setUpLinks( bool showSupportUrl,
|
void setUpLinks( bool showSupportUrl,
|
||||||
bool showKnownIssuesUrl,
|
bool showKnownIssuesUrl,
|
||||||
bool showReleaseNotesUrl );
|
bool showReleaseNotesUrl );
|
||||||
|
/// @brief Set international language-selector icon
|
||||||
|
void setLanguageIcon( QPixmap );
|
||||||
|
|
||||||
/// @brief Results of requirements checking
|
/// @brief Results of requirements checking
|
||||||
bool verdict() const;
|
bool verdict() const;
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="languageIcon">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select language</string>
|
<string>Select language</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
|
|
||||||
#include "geoip/Handler.h"
|
#include "geoip/Handler.h"
|
||||||
#include "locale/Lookup.h"
|
#include "locale/Lookup.h"
|
||||||
#include "modulesystem/ModuleManager.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
|
#include "Branding.h"
|
||||||
|
#include "modulesystem/ModuleManager.h"
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@ -137,6 +139,15 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
} );
|
} );
|
||||||
future->setFuture( handler->queryRaw() );
|
future->setFuture( handler->queryRaw() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString language = CalamaresUtils::getString( configurationMap, "languageIcon" );
|
||||||
|
if ( !language.isEmpty() )
|
||||||
|
{
|
||||||
|
auto icon = Calamares::Branding::instance()->image( language, QSize( 48, 48 ) );
|
||||||
|
if ( !icon.isNull() )
|
||||||
|
m_widget->setLanguageIcon( icon );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::RequirementsList
|
Calamares::RequirementsList
|
||||||
|
@ -64,3 +64,16 @@ geoip:
|
|||||||
style: "none"
|
style: "none"
|
||||||
url: "https://geoip.kde.org/v1/ubiquity" # extended XML format
|
url: "https://geoip.kde.org/v1/ubiquity" # extended XML format
|
||||||
selector: "CountryCode" # blank uses default, which is wrong
|
selector: "CountryCode" # blank uses default, which is wrong
|
||||||
|
|
||||||
|
# User interface
|
||||||
|
#
|
||||||
|
# The "select language" icon is an international standard, but it
|
||||||
|
# might not theme very well with your desktop environment.
|
||||||
|
# Fill in an icon name (following FreeDesktop standards) to
|
||||||
|
# use that named icon instead of the usual one.
|
||||||
|
#
|
||||||
|
# Leave blank or unset to use the international standard.
|
||||||
|
#
|
||||||
|
# Known icons in this space are "set-language" and "config-language".
|
||||||
|
#
|
||||||
|
# languageIcon: set-language
|
||||||
|
Loading…
Reference in New Issue
Block a user