Commit c6b840ab authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Fix setting serialization in the KDE version.

BUG: 270712
FIXED-IN: 1.1.0
(cherry picked from commit 68de7475)
parent 3ab98936
......@@ -296,20 +296,22 @@ void OverviewMap::setSettings( QHash<QString,QVariant> settings )
if( !settings.contains( "height" ) ) {
settings.insert( "height", m_defaultSize.toSize().height() );
}
// FIXME add SVGs for other planets
QHash<QString, QVariant> paths;
foreach( const QString& planet, Planet::planetList() ) {
paths[planet] = MarbleDirs::path( "svg/worldmap.svg" );
QString const worldmap = MarbleDirs::path( "svg/worldmap.svg" );
QStringList const planets = Planet::planetList();
if ( !settings.contains( "path_" + m_planetID[2] ) ) {
settings.insert( "path_" + m_planetID[2], worldmap );
}
paths[m_planetID[2]] = MarbleDirs::path( "svg/worldmap.svg" );
paths[m_planetID[10]] = MarbleDirs::path( "svg/lunarmap.svg" );
if( !settings.contains( "paths" ) ) {
settings.insert( "paths", paths );
if ( !settings.contains( "path_" + m_planetID[10] ) ) {
settings.insert( "path_" + m_planetID[10], MarbleDirs::path( "svg/lunarmap.svg" ) );
}
foreach( const QString& planet, planets ) {
if ( !settings.contains( "path_" + planet ) ) {
settings.insert( "path_" + planet, worldmap );
}
}
if( !settings.contains( "posColor" ) ) {
settings.insert( "posColor", QColor( Qt::white ) );
settings.insert( "posColor", QColor( Qt::white ).name() );
}
m_settings = settings;
......@@ -326,7 +328,7 @@ void OverviewMap::readSettings() const
ui_configWidget->m_widthBox->setValue( m_settings.value( "width" ).toInt() );
ui_configWidget->m_heightBox->setValue( m_settings.value( "height" ).toInt() );
QPalette palette = ui_configWidget->m_colorChooserButton->palette();
palette.setColor( QPalette::Button, m_settings.value( "posColor" ).value<QColor>() );
palette.setColor( QPalette::Button, QColor( m_settings.value( "posColor" ).toString() ) );
ui_configWidget->m_colorChooserButton->setPalette( palette );
}
......@@ -338,16 +340,25 @@ void OverviewMap::writeSettings()
m_settings.insert( "width", contentRect().width() );
m_settings.insert( "height", contentRect().height() );
m_settings.insert( "paths", m_svgPaths );
m_settings.insert( "posColor", m_posColor );
QStringList const planets = Planet::planetList();
foreach( const QString &planet, planets ) {
m_settings.insert( "path_" + planet, m_svgPaths[planet] );
}
m_settings.insert( "posColor", m_posColor.name() );
emit settingsChanged( nameId() );
}
void OverviewMap::updateSettings()
{
m_svgPaths = m_settings.value( "paths" ).toHash();
m_posColor = m_settings.value( "posColor" ).value<QColor>();
QStringList const planets = Planet::planetList();
foreach( const QString &planet, planets ) {
m_svgPaths.insert( planet, m_settings.value( "path_" + planet, QString() ).toString() );
}
m_posColor = QColor( m_settings.value( "posColor" ).toString() );
loadPlanetMaps();
if ( !m_configDialog ) {
......@@ -407,7 +418,7 @@ bool OverviewMap::eventFilter( QObject *object, QEvent *e )
void OverviewMap::changeBackground( const QString& target ) const
{
delete m_svgobj;
m_svgobj = new QSvgRenderer( m_svgPaths[target].toString() );
m_svgobj = new QSvgRenderer( m_svgPaths[target] );
}
QSvgWidget *OverviewMap::currentWidget() const
......@@ -427,7 +438,7 @@ void OverviewMap::setCurrentWidget( QSvgWidget *widget ) const
void OverviewMap::loadPlanetMaps() const
{
foreach( const QString& planet, m_planetID ) {
m_svgWidgets[planet] = new QSvgWidget( m_svgPaths[planet].toString() );
m_svgWidgets[planet] = new QSvgWidget( m_svgPaths[planet] );
}
}
......
......@@ -101,7 +101,7 @@ class OverviewMap : public AbstractFloatItem
QString m_target;
mutable QSvgRenderer *m_svgobj;
mutable QHash<QString, QSvgWidget *> m_svgWidgets;
mutable QHash<QString, QVariant> m_svgPaths;
mutable QHash<QString, QString> m_svgPaths;
mutable QStringList m_planetID;
QPixmap m_worldmap;
QHash<QString,QVariant> m_settings;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment