[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [k3b/kf5] src: Fix loading themes in ThemeManager.
From:       Johannes Obermayr <johannesobermayr () gmx ! de>
Date:       2016-01-11 23:59:56
Message-ID: E1aImNQ-00007Q-5K () scm ! kde ! org
[Download RAW message or body]

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 = QStandardPaths::locate( QStandardPaths::GenericDataLocation, \
"k3b/pics/" + name + "/k3b.theme" ); +    if( !path.isEmpty() )
+        m_path = 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" << name << "in" \
<< m_path;  
     return m_emptyPixmap;
 }
@@ -276,7 +285,7 @@ void K3b::ThemeManager::loadThemes()
         QStringList entries = dir.entryList( QDir::Dirs|QDir::NoDotAndDotDot );
         // every theme dir needs to contain a k3b.theme file
         for( QStringList::const_iterator entryIt = entries.constBegin(); entryIt != \
                entries.constEnd(); ++entryIt ) {
-            QString themeDir = *dirIt + *entryIt + '/';
+            QString themeDir = *dirIt + '/' + *entryIt + '/';
             if( !themeNames.contains( *entryIt ) && QFile::exists( themeDir + \
"k3b.theme" ) ) {  bool themeValid = true;
 
@@ -306,16 +315,13 @@ void K3b::ThemeManager::loadThemes()
 
 void K3b::ThemeManager::loadTheme( const QString& name )
 {
-    QString path = QStandardPaths::locate( QStandardPaths::GenericDataLocation, \
                "k3b/pics/" + name + "/k3b.theme" );
-    if( !path.isEmpty() ) {
-        K3b::Theme* t = new K3b::Theme();
+    K3b::Theme* t = new K3b::Theme( name );
+    if( !t->m_path.isEmpty() ) {
         t->m_name = name;
-        t->m_path = path.left( path.length() - 9 );
-        QFileInfo fi( t->m_path );
-        t->m_local = fi.isWritable();
+        t->m_local = QFileInfo( t->m_path ).isWritable();
 
         // load the stuff
-        KConfig cfg( path );
+        KConfig cfg( t->m_path + "/k3b.theme" );
         KConfigGroup group(&cfg,"");
         t->m_author = group.readEntry( "Author" );
         t->m_comment = group.readEntry( "Comment" );
@@ -325,8 +331,6 @@ void K3b::ThemeManager::loadTheme( const QString& name )
         t->m_bgMode = ( group.readEntry( "BackgroundMode" ) == "Scaled" ? \
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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic