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

List:       kde-devel
Subject:    [PATCH]  br#54143, saving configuration
From:       Edwin Schepers <yez () home ! nl>
Date:       2004-05-09 20:50:57
Message-ID: 200405092250.58208.yez () home ! nl
[Download RAW message or body]

Hi,
This patch resolves http://bugs.kde.org/show_bug.cgi?id=54143
ok to commit?

Regards,
Edwin

["kimgalleryplugin.patch" (text/x-diff)]

Index: kimgalleryplugin/imgallerydialog.cpp
===================================================================
RCS file: /home/kdecvs/kde/kdeaddons/konq-plugins/kimgalleryplugin/imgallerydialog.cpp,v
 retrieving revision 1.22
diff -u -p -u -r1.22 imgallerydialog.cpp
--- a/kimgalleryplugin/imgallerydialog.cpp	6 Apr 2004 10:09:17 -0000	1.22
+++ b/kimgalleryplugin/imgallerydialog.cpp	9 May 2004 20:44:27 -0000
@@ -39,6 +39,7 @@ Boston, MA 02111-1307, USA.
 #include <kcolorbutton.h>
 #include <kurlrequester.h>
 #include <kglobalsettings.h>
+#include <kconfig.h>
 
 #include "imgallerydialog.h"
 #include "imgallerydialog.moc"
@@ -50,6 +51,7 @@ KIGPDialog::KIGPDialog(QWidget *parent, 
 {
     setCaption(i18n("Create Image Gallery"));
     setButtonOKText( i18n("Create") );
+    m_config = new KConfig("kimgallerypluginrc", false, false);
     setupLookPage(path);
     setupDirectoryPage(path);
     setupThumbnailPage(path);
@@ -59,6 +61,7 @@ void KIGPDialog::setupLookPage(const QSt
     QFrame *page = addPage( i18n("Look"), i18n("Page Look"),
                             BarIcon("colorize", KIcon::SizeMedium ) );
 
+    m_config->setGroup("Look");
     QVBoxLayout *vlay = new QVBoxLayout( page, 0, spacingHint() );
 
     QLabel *label;
@@ -70,7 +73,7 @@ void KIGPDialog::setupLookPage(const QSt
     vlay->addWidget( m_title );
     label->setBuddy(m_title);
 
-    m_imagesPerRow = new KIntNumInput(4, page);
+    m_imagesPerRow = new KIntNumInput(m_config->readNumEntry("ImagesPerRow", 4), \
page);  m_imagesPerRow->setRange(1, 8, 1, true );
     m_imagesPerRow->setLabel( i18n("I&mages per row:") );
     vlay->addWidget( m_imagesPerRow );
@@ -79,15 +82,15 @@ void KIGPDialog::setupLookPage(const QSt
     vlay->addLayout( grid );
 
     m_imageName = new QCheckBox( i18n("Show image file &name"), page);
-    m_imageName->setChecked( true );
+    m_imageName->setChecked( m_config->readBoolEntry("ImageName", true) );
     grid->addWidget( m_imageName, 0, 0 );
 
     m_imageSize = new QCheckBox( i18n("Show image file &size"), page);
-    m_imageSize->setChecked( false );
+    m_imageSize->setChecked( m_config->readBoolEntry("ImageSize", false) );
     grid->addWidget( m_imageSize, 0, 1 );
 
     m_imageProperty = new QCheckBox( i18n("Show image &dimensions"), page);
-    m_imageProperty->setChecked( false );
+    m_imageProperty->setChecked( m_config->readBoolEntry("ImageProperty", false) );
     grid->addWidget( m_imageProperty, 1, 0 );
 
     QHBoxLayout *hlay11  = new QHBoxLayout( );
@@ -97,7 +100,7 @@ void KIGPDialog::setupLookPage(const QSt
     QStringList standardFonts;
     KFontChooser::getFontList(standardFonts, 0);
     m_fontName->insertStringList( standardFonts );
-    m_fontName->setCurrentText( KGlobalSettings::generalFont().family());
+    m_fontName->setCurrentText( m_config->readEntry("FontName", \
KGlobalSettings::generalFont().family() ) );  
     label = new QLabel( i18n("Fon&t name:"), page );
     label->setBuddy( m_fontName );
@@ -109,7 +112,7 @@ void KIGPDialog::setupLookPage(const QSt
     vlay->addLayout( hlay12 );
 
     m_fontSize = new QSpinBox( 6, 15, 1, page );
-    m_fontSize->setValue( 14 );
+    m_fontSize->setValue( m_config->readNumEntry("FontSize", 14) );
 
     label = new QLabel( i18n("Font si&ze:"), page );
     label->setBuddy( m_fontSize );
@@ -121,7 +124,7 @@ void KIGPDialog::setupLookPage(const QSt
     vlay->addLayout( hlay1 );
 
     m_foregroundColor = new KColorButton(page);
-    m_foregroundColor->setColor(QColor("#d0ffd0"));
+    m_foregroundColor->setColor( QColor( m_config->readEntry("ForegroundColor", \
"#d0ffd0") ) );  
     label = new QLabel( i18n("&Foreground color:"), page);
     label->setBuddy( m_foregroundColor );
@@ -133,7 +136,7 @@ void KIGPDialog::setupLookPage(const QSt
     vlay->addLayout( hlay2 );
 
     m_backgroundColor = new KColorButton(page);
-    m_backgroundColor->setColor(QColor("#333333"));
+    m_backgroundColor->setColor( QColor(m_config->readEntry("BackgroundColor", \
"#333333") ) );  
     label = new QLabel( i18n("&Background color:"), page);
     hlay2->addWidget( label );
@@ -148,6 +151,7 @@ void KIGPDialog::setupDirectoryPage(cons
     QFrame *page = addPage( i18n("Folders"), i18n("Folders"),
                             BarIcon("folder", KIcon::SizeMedium ) );
 
+    m_config->setGroup("Directory");
     QVBoxLayout *dvlay = new QVBoxLayout( page, 0, spacingHint() );
 
     QLabel *label;
@@ -164,17 +168,20 @@ void KIGPDialog::setupDirectoryPage(cons
              this, SLOT(imageUrlChanged(const QString&)) );
     QWhatsThis::add( m_imageNameReq, whatsThis );
 
+    const bool recurseSubDir = m_config->readBoolEntry("RecurseSubDirectories", \
false);  m_recurseSubDir = new QCheckBox(i18n("&Recurse subfolders"), page);
-    m_recurseSubDir->setChecked(false);
+    m_recurseSubDir->setChecked( recurseSubDir );
     whatsThis = i18n("<p>Whether subfolders should be included for the "
                      "image gallery creation or not.");
     QWhatsThis::add( m_recurseSubDir, whatsThis );
 
-    m_recursionLevel = new KIntNumInput( page );
+    const int recursionLevel = m_config->readNumEntry("RecursionLevel", 0);
+    m_recursionLevel = new KIntNumInput( recursionLevel, page );
     m_recursionLevel->setRange( 0, 99, 1, true );
     m_recursionLevel->setLabel( i18n("Rec&ursion depth:") );
-    m_recursionLevel->setSpecialValueText( i18n("Endless"));
-    m_recursionLevel->setEnabled(false);
+    if ( recursionLevel == 0 )
+      m_recursionLevel->setSpecialValueText( i18n("Endless"));
+    m_recursionLevel->setEnabled(recurseSubDir);
     whatsThis = i18n("<p>You can limit the number of folders the "
                      "image gallery creator will traverse to by setting an "
                      "upper bound for the recursion depth.");
@@ -188,15 +195,16 @@ void KIGPDialog::setupDirectoryPage(cons
     dvlay->addWidget(m_recursionLevel);
 
     m_copyOriginalFiles = new QCheckBox(i18n("Copy or&iginal files"), page);
-    m_copyOriginalFiles->setChecked(false);
+    m_copyOriginalFiles->setChecked(m_config->readBoolEntry("CopyOriginalFiles", \
false) );  dvlay->addWidget(m_copyOriginalFiles);
     whatsThis = i18n("<p>This makes a copy of all images and the gallery will refer \
"  "to these copies instead of the original images.");
     QWhatsThis::add( m_copyOriginalFiles, whatsThis );
 
 
+    const bool useCommentFile = m_config->readBoolEntry("UseCommentFile", false);
     m_useCommentFile = new QCheckBox(i18n("Use &comment file"), page);
-    m_useCommentFile->setChecked(false);
+    m_useCommentFile->setChecked(useCommentFile);
     dvlay->addWidget(m_useCommentFile);
 
     whatsThis = i18n("<p>If you enable this option you can specify "
@@ -207,7 +215,7 @@ void KIGPDialog::setupDirectoryPage(cons
     QWhatsThis::add( m_useCommentFile, whatsThis );
 
     label = new QLabel(i18n("Comments &file:"), page);
-    label->setEnabled( false );
+    label->setEnabled( useCommentFile );
     dvlay->addWidget( label );
     whatsThis = i18n("<p>You can specify the name of the comment file here. "
                      "The comment file contains the subtitles for the images. "
@@ -222,7 +230,7 @@ void KIGPDialog::setupDirectoryPage(cons
     QWhatsThis::add( label, whatsThis );
 
     m_commentFileReq = new KURLRequester(path + "comments", page);
-    m_commentFileReq->setEnabled(false);
+    m_commentFileReq->setEnabled(useCommentFile);
     label->setBuddy( m_commentFileReq );
     dvlay->addWidget(m_commentFileReq);
     QWhatsThis::add( m_commentFileReq, whatsThis );
@@ -239,6 +247,7 @@ void KIGPDialog::setupThumbnailPage(cons
     QFrame *page = addPage( i18n("Thumbnails"), i18n("Thumbnails"),
                             BarIcon("thumbnail", KIcon::SizeMedium ) );
 
+    m_config->setGroup("Thumbnails");
     QLabel *label;
 
     QVBoxLayout *vlay = new QVBoxLayout( page, 0, spacingHint() );
@@ -249,6 +258,7 @@ void KIGPDialog::setupThumbnailPage(cons
     m_imageFormat = new QComboBox(false, page);
     m_imageFormat->insertItem("JPEG");
     m_imageFormat->insertItem("PNG");
+    m_imageFormat->setCurrentText( m_config->readEntry("ImageFormat", "JPEG") );
 
     label = new QLabel( i18n("Image format f&or the thumbnails:"), page);
     hlay3->addWidget( label );
@@ -256,7 +266,7 @@ void KIGPDialog::setupThumbnailPage(cons
     hlay3->addStretch( 1 );
     hlay3->addWidget(m_imageFormat);
 
-    m_thumbnailSize = new KIntNumInput(140, page);
+    m_thumbnailSize = new KIntNumInput(m_config->readNumEntry("ThumbnailSize", 140), \
page);  m_thumbnailSize->setRange(10, 1000, 1, true );
     m_thumbnailSize->setLabel( i18n("Thumbnail size:") );
     vlay->addWidget( m_thumbnailSize );
@@ -266,8 +276,9 @@ void KIGPDialog::setupThumbnailPage(cons
 
     QHBoxLayout *hlay4 = new QHBoxLayout( spacingHint() );
     vlay->addLayout( hlay4 );
+    const bool colorDepthSet = m_config->readBoolEntry("ColorDepthSet", false);
     m_colorDepthSet = new QCheckBox(i18n("&Set different color depth:"), page);
-    m_colorDepthSet->setChecked(false);
+    m_colorDepthSet->setChecked(colorDepthSet);
     hlay4->addWidget( m_colorDepthSet );
 
     m_colorDepth = new QComboBox(false, page);
@@ -275,8 +286,8 @@ void KIGPDialog::setupThumbnailPage(cons
     m_colorDepth->insertItem("8");
     m_colorDepth->insertItem("16");
     m_colorDepth->insertItem("32");
-    m_colorDepth->setCurrentText("8");
-    m_colorDepth->setEnabled(false);
+    m_colorDepth->setCurrentText(m_config->readEntry("ColorDepth", "8"));
+    m_colorDepth->setEnabled(colorDepthSet);
     hlay4->addWidget( m_colorDepth );
 
     connect(m_colorDepthSet, SIGNAL( toggled(bool) ),
@@ -286,6 +297,32 @@ void KIGPDialog::setupThumbnailPage(cons
 
 }
 
+void KIGPDialog::writeConfig()
+{
+ m_config->setGroup("Look");
+ m_config->writeEntry("ImagesPerRow", getImagesPerRow());
+ m_config->writeEntry("ImageName", printImageName());
+ m_config->writeEntry("ImageSize", printImageSize());
+ m_config->writeEntry("ImageProperty", printImageProperty());
+ m_config->writeEntry("FontName", getFontName());
+ m_config->writeEntry("FontSize", getFontSize());
+ m_config->writeEntry("ForegroundColor", getForegroundColor().name() );
+ m_config->writeEntry("BackgroundColor", getBackgroundColor().name());
+
+ m_config->setGroup("Directory");
+ m_config->writeEntry("RecurseSubDirectories", recurseSubDirectories());
+ m_config->writeEntry("RecursionLevel", recursionLevel());
+ m_config->writeEntry("CopyOriginalFiles", copyOriginalFiles());
+ m_config->writeEntry("UseCommentFile", useCommentFile());
+
+ m_config->setGroup("Thumbnails");
+ m_config->writeEntry("ThumbnailSize", getThumbnailSize());
+ m_config->writeEntry("ColorDepth", getColorDepth());
+ m_config->writeEntry("ColorDepthSet", colorDepthSet());
+ m_config->writeEntry("ImageFormat", getImageFormat());
+ m_config->sync();
+}
+
 KIGPDialog::~KIGPDialog()
 {
 }
Index: kimgalleryplugin/imgallerydialog.h
===================================================================
RCS file: /home/kdecvs/kde/kdeaddons/konq-plugins/kimgalleryplugin/imgallerydialog.h,v
 retrieving revision 1.12
diff -u -p -u -r1.12 imgallerydialog.h
--- a/kimgalleryplugin/imgallerydialog.h	24 Aug 2003 13:52:20 -0000	1.12
+++ b/kimgalleryplugin/imgallerydialog.h	9 May 2004 20:44:27 -0000
@@ -32,6 +32,7 @@ class QLineEdit;
 class KURLRequester;
 class QSpinBox;
 class KColorButton;
+class KConfig;
 
 typedef QMap<QString,QString> CommentMap;
 
@@ -68,6 +69,7 @@ class KIGPDialog : public KDialogBase
 
   const QString getImageFormat() const;
 
+  void writeConfig();
  protected slots:
   void imageUrlChanged(const QString & );
 
@@ -98,6 +100,8 @@ class KIGPDialog : public KDialogBase
   KURLRequester *m_commentFileReq;
   bool m_dialogOk;
 
+  KConfig *m_config;
+
  private:
   void setupLookPage(const QString& path);
   void setupDirectoryPage(const QString& path);
Index: kimgalleryplugin/imgalleryplugin.cpp
===================================================================
RCS file: /home/kdecvs/kde/kdeaddons/konq-plugins/kimgalleryplugin/imgalleryplugin.cpp,v
 retrieving revision 1.53
diff -u -p -u -r1.53 imgalleryplugin.cpp
--- a/kimgalleryplugin/imgalleryplugin.cpp	14 Apr 2004 11:02:08 -0000	1.53
+++ b/kimgalleryplugin/imgalleryplugin.cpp	9 May 2004 20:44:28 -0000
@@ -72,6 +72,7 @@ void KImGalleryPlugin::slotExecute()
 
     if ( m_configDlg->exec() == QDialog::Accepted ) {
         kdDebug(90170) << "dialog is ok" << endl;
+        m_configDlg->writeConfig();
         m_copyFiles = m_configDlg->copyOriginalFiles();
         m_recurseSubDirectories = m_configDlg->recurseSubDirectories();
         m_useCommentFile = m_configDlg->useCommentFile();



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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