Git commit ba43de4f1a82f8d0480149a1db05144282fbcea8 by Johannes Obermayr. Committed on 11/01/2016 at 23:58. Pushed by jobermayr into branch 'kf5'. Fix loading themes in ThemeManager. M +17 -13 src/k3bthememanager.cpp M +1 -0 src/k3bthememanager.h http://commits.kde.org/k3b/ba43de4f1a82f8d0480149a1db05144282fbcea8 diff --git a/src/k3bthememanager.cpp b/src/k3bthememanager.cpp index c7caffa..9c916cd 100644 --- a/src/k3bthememanager.cpp +++ b/src/k3bthememanager.cpp @@ -34,6 +34,15 @@ K3b::Theme::Theme() } = = +K3b::Theme::Theme( QString name) + : m_bgMode(BG_TILE) +{ + QString path =3D QStandardPaths::locate( QStandardPaths::GenericDataLo= cation, "k3b/pics/" + name + "/k3b.theme" ); + if( !path.isEmpty() ) + m_path =3D path.left( path.length() - 9 ); +} + + QColor K3b::Theme::backgroundColor() const { if( m_bgColor.isValid() ) @@ -65,7 +74,7 @@ QPixmap K3b::Theme::pixmap( const QString& name ) const return *m_pixmapMap.insert( name, pix ); } = - qDebug() << "(K3b::Theme) " << m_name << ": could not load image " << = name; + qDebug() << "(K3b::Theme)" << m_name << ": could not load image" << na= me << "in" << m_path; = return m_emptyPixmap; } @@ -276,7 +285,7 @@ void K3b::ThemeManager::loadThemes() QStringList entries =3D dir.entryList( QDir::Dirs|QDir::NoDotAndDo= tDot ); // every theme dir needs to contain a k3b.theme file for( QStringList::const_iterator entryIt =3D entries.constBegin();= entryIt !=3D entries.constEnd(); ++entryIt ) { - QString themeDir =3D *dirIt + *entryIt + '/'; + QString themeDir =3D *dirIt + '/' + *entryIt + '/'; if( !themeNames.contains( *entryIt ) && QFile::exists( themeDi= r + "k3b.theme" ) ) { bool themeValid =3D true; = @@ -306,16 +315,13 @@ void K3b::ThemeManager::loadThemes() = void K3b::ThemeManager::loadTheme( const QString& name ) { - QString path =3D QStandardPaths::locate( QStandardPaths::GenericDataLo= cation, "k3b/pics/" + name + "/k3b.theme" ); - if( !path.isEmpty() ) { - K3b::Theme* t =3D new K3b::Theme(); + K3b::Theme* t =3D new K3b::Theme( name ); + if( !t->m_path.isEmpty() ) { t->m_name =3D name; - t->m_path =3D path.left( path.length() - 9 ); - QFileInfo fi( t->m_path ); - t->m_local =3D fi.isWritable(); + t->m_local =3D QFileInfo( t->m_path ).isWritable(); = // load the stuff - KConfig cfg( path ); + KConfig cfg( t->m_path + "/k3b.theme" ); KConfigGroup group(&cfg,""); t->m_author =3D group.readEntry( "Author" ); t->m_comment =3D group.readEntry( "Comment" ); @@ -325,8 +331,6 @@ void K3b::ThemeManager::loadTheme( const QString& name ) t->m_bgMode =3D ( group.readEntry( "BackgroundMode" ) =3D=3D "Scal= ed" ? K3b::Theme::BG_SCALE : K3b::Theme::BG_TILE ); = d->themes.append( t ); - } + } else + delete t; } - - - diff --git a/src/k3bthememanager.h b/src/k3bthememanager.h index 6afef5a..c3b3ca7 100644 --- a/src/k3bthememanager.h +++ b/src/k3bthememanager.h @@ -29,6 +29,7 @@ namespace K3b { { public: Theme(); + Theme( QString name ); = QColor backgroundColor() const; QColor foregroundColor() const;