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

List:       kde-commits
Subject:    extragear/network/konversation/src
From:       Dario Abatianni <eisfuchs () tigress ! com>
Date:       2006-01-14 3:11:58
Message-ID: 1137208318.551285.18936.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 497872 by abatianni:

converted themes prefs page to new load/save system

 M  +39 -42    ex_theme_preferences.cpp  
 M  +10 -7     ex_theme_preferences.h  
 M  +1 -1      konvisettingsdialog.cpp  


--- trunk/extragear/network/konversation/src/ex_theme_preferences.cpp #497871:497872
@@ -46,28 +46,52 @@
 Theme_Config_Ext::Theme_Config_Ext(QWidget* parent, const char* name)
   : Theme_Config( parent, name)
 {
+    loadSettings();
 
-    updateList();
-    updateButtons();
-
     m_oldTheme = Preferences::iconThemeName();
 
     connect(kcfg_IconThemeIndex,SIGNAL(highlighted(int)),this,SLOT(updatePreview(int)));
     connect(kcfg_IconThemeIndex,SIGNAL(currentChanged(QListBoxItem*)),this,SLOT(updateButtons()));
     connect(installButton,SIGNAL(clicked()),this,SLOT(installTheme()));
     connect(removeButton,SIGNAL(clicked()),this,SLOT(removeTheme()));
-
-    KConfigDialog *conf = static_cast<KConfigDialog *>(parent);
-    connect( conf, SIGNAL(applyClicked()), this, SLOT(applyPreferences()));
-    connect( conf, SIGNAL(okClicked()), this, SLOT(applyPreferences()));
 }
 
 Theme_Config_Ext::~Theme_Config_Ext()
 {
 }
 
-void Theme_Config_Ext::applyPreferences()
+void Theme_Config_Ext::loadSettings()
 {
+    QString themeName, themeComment;
+    QString currentTheme = Preferences::iconThemeName();
+    int index = Preferences::iconThemeIndex();
+
+    m_dirs = KGlobal::dirs()->findAllResources("data","konversation/themes/*/index.desktop");
+
+    if(m_dirs.count() > 0)
+    {
+        kcfg_IconThemeIndex->clear();
+
+        for(QStringList::ConstIterator it = m_dirs.begin(); it != m_dirs.end(); ++it)
+        {
+            KDesktopFile themeRC(*it);
+            themeName = themeRC.readName();
+            themeComment = themeRC.readComment();
+
+            if(!themeComment.isEmpty())
+                themeName = themeName+" ( "+themeComment+" )";
+
+            kcfg_IconThemeIndex->insertItem(themeName);
+        }
+
+        kcfg_IconThemeIndex->setSelected(index, true);
+        updatePreview(index);
+    }
+    updateButtons();
+}
+
+void Theme_Config_Ext::saveSettings()
+{
     if(kcfg_IconThemeIndex->count())
     {
         QString theme;
@@ -75,7 +99,6 @@
         theme = theme.section('/',-2,-2);
         if(m_oldTheme != theme)
         {
-            kdDebug() << "New Theme :" << theme << endl;
 	    KConfig* config = kapp->config();
 	    config->setGroup("Themes");
 	    config->writeEntry("IconThemeName",theme);
@@ -87,6 +110,11 @@
     }
 }
 
+void Theme_Config_Ext::restorePageToDefaults()
+{
+    // FIXME!
+}
+
 void Theme_Config_Ext::installTheme()
 {
     KURL themeURL = KFileDialog::getOpenURL(QString::null,
@@ -154,8 +182,7 @@
         themeArchive.close();
     }
 
-    updateList();
-    updateButtons();
+    loadSettings();
     KIO::NetAccess::removeTempFile(tmpThemeFile);
 
 }
@@ -178,8 +205,7 @@
     {
         unlink(QFile::encodeName(dir));
         KIO::del(KURL(dir.remove("index.desktop")));
-        updateList();
-        updateButtons();
+        loadSettings();
     }
 }
 
@@ -199,35 +225,6 @@
     previewLabel7->setPixmap(overlayPixmaps(normal,QPixmap(dir+"/irc_owner.png")));
 }
 
-void Theme_Config_Ext::updateList()
-{
-    QString themeName, themeComment;
-    QString currentTheme = Preferences::iconThemeName();
-    int index = Preferences::iconThemeIndex();
-
-    m_dirs = KGlobal::dirs()->findAllResources("data","konversation/themes/*/index.desktop");
-
-    if(m_dirs.count() > 0)
-    {
-        kcfg_IconThemeIndex->clear();
-
-        for(QStringList::ConstIterator it = m_dirs.begin(); it != m_dirs.end(); ++it)
-        {
-            KDesktopFile themeRC(*it);
-            themeName = themeRC.readName();
-            themeComment = themeRC.readComment();
-
-            if(!themeComment.isEmpty())
-                themeName = themeName+" ( "+themeComment+" )";
-
-            kcfg_IconThemeIndex->insertItem(themeName);
-        }
-
-        kcfg_IconThemeIndex->setSelected(index, true);
-        updatePreview(index);
-    }
-}
-
 void Theme_Config_Ext::updateButtons()
 {
     if(kcfg_IconThemeIndex->count() < 2)
--- trunk/extragear/network/konversation/src/ex_theme_preferences.h #497871:497872
@@ -13,18 +13,23 @@
 #define PREFSPAGETHEMES_H
 
 #include "theme_preferences.h"
+#include "konvisettingspage.h"
 
 class QStringList;
 
-class Theme_Config_Ext : public Theme_Config
+class Theme_Config_Ext : public Theme_Config, public KonviSettingsPage
 {
-  Q_OBJECT
+    Q_OBJECT
+
     public:
-  Theme_Config_Ext(QWidget* parent, const char* name=NULL);
-	~Theme_Config_Ext();
+        Theme_Config_Ext(QWidget* parent, const char* name=NULL);
+        ~Theme_Config_Ext();
 
+        virtual void restorePageToDefaults();
+        virtual void saveSettings();
+        virtual void loadSettings();
+
     protected slots:
-	void applyPreferences();
         void updatePreview(int id);
         void updateButtons();
         void installTheme();
@@ -33,7 +38,5 @@
     private:
         QStringList m_dirs;
         QString m_oldTheme;
-
-        void updateList();
 };
 #endif
--- trunk/extragear/network/konversation/src/konvisettingsdialog.cpp #497871:497872
@@ -110,6 +110,7 @@
   pagePath.clear();
   pagePath << i18n("Appearance") << i18n("Themes");
   addPage ( m_confThemeWdg, pagePath, "iconthemes", i18n("Themes") );
+  m_indexToPageMapping.insert(lastAddedIndex(), m_confThemeWdg);
 
   //Appearance/Colors
   m_confColorsAppearanceWdg = new ColorsAppearance_Config( this, "ColorsAppearance" );
@@ -157,7 +158,6 @@
   addPage ( m_confAliasWdg, pagePath, "editcopy", i18n(" Command Aliases") );
   m_indexToPageMapping.insert(lastAddedIndex(), m_confAliasWdg);
   connect(m_confAliasWdg, SIGNAL(modified()), this, SLOT(modifiedSlot()));
-    
 
   //Behaviour/Quick Buttons
   m_confQuickButtonsWdg = new QuickButtons_Config( this, "QuickButtons" );
[prev in list] [next in list] [prev in thread] [next in thread] 

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