[uim-commit] r592 - trunk/qt

kzk at freedesktop.org kzk at freedesktop.org
Mon Feb 7 00:28:09 PST 2005


Author: kzk
Date: 2005-02-07 00:28:06 -0800 (Mon, 07 Feb 2005)
New Revision: 592

Modified:
   trunk/qt/pref-customwidgets.cpp
   trunk/qt/pref-qt.cpp
   trunk/qt/pref-qt.h
Log:
* qt/pref-qt.cpp
* qt/pref-qt.h
  - add waning of ~/.uim existance.
  - (UimPrefDialog::checkDotUimFile): new func
  - (QConfirmDialog): reorganized
  - delete dialog after it is excuted

* qt/pref-customwidgets.cpp
  - delete dialog after it is excuted


Modified: trunk/qt/pref-customwidgets.cpp
===================================================================
--- trunk/qt/pref-customwidgets.cpp	2005-02-07 07:39:09 UTC (rev 591)
+++ trunk/qt/pref-customwidgets.cpp	2005-02-07 08:28:06 UTC (rev 592)
@@ -205,6 +205,7 @@
         QString fileName = fd->selectedFile();
         m_lineEdit->setText( fileName );
     }
+    delete fd;
 }
 
 void CustomPathnameEdit::slotCustomTextChanged( const QString & text )
@@ -488,6 +489,8 @@
         /* reload */
         update();
     }
+
+    delete d;
 }
 
 void CustomOrderedListEdit::updateText()
@@ -727,6 +730,8 @@
         setCustom( m_custom );
         update();
     }
+
+    delete d;
 }
 
 KeyEditForm::KeyEditForm( QWidget *parent, const char *name )
@@ -780,6 +785,7 @@
             addKeyItem( keystr );
         }
     }
+    delete d;
 }
 
 void KeyEditForm::slotRemoveClicked()
@@ -805,6 +811,7 @@
                 selectedItem->setText( 0, keystr );
             }
         }
+        delete d;
     }
 }
 

Modified: trunk/qt/pref-qt.cpp
===================================================================
--- trunk/qt/pref-qt.cpp	2005-02-07 07:39:09 UTC (rev 591)
+++ trunk/qt/pref-qt.cpp	2005-02-07 08:28:06 UTC (rev 592)
@@ -53,10 +53,14 @@
 #include <qcombobox.h>
 #include <qlayout.h>
 #include <qobjectlist.h>
+#include <qfile.h>
+#include <qmessagebox.h>
+#include <qsettings.h>
 
 #include "uim/config.h"
 #include "qtgettext.h"
 
+#include <stdlib.h>
 #include <locale.h>
 
 #define _FU8(String) QString::fromUtf8(String)
@@ -67,11 +71,12 @@
 {
     uim_init();
     if (uim_custom_enable()) {
-      setupWidgets();
+        checkDotUimFile();        
+        setupWidgets();
     } else {
-      qDebug("uim_custom_enable() failed.");
-      uim_quit();
-      QApplication::exit( -1 );
+        qDebug("uim_custom_enable() failed.");
+        uim_quit();
+        QApplication::exit( -1 );
     }
 
     setCaption( "uim-pref-qt" );
@@ -82,6 +87,35 @@
     uim_quit();
 }
 
+void UimPrefDialog::checkDotUimFile()
+{
+    /* Check Config */
+    QSettings settings;
+    bool isShowOnStartup = settings.readBoolEntry( "/uim/qt/warnDotUim", true );
+    if( !isShowOnStartup )
+        return;
+
+    /* Check File Existance */
+    QString homeDir = getenv( "HOME" );
+    if( homeDir.isEmpty() )
+        return;
+
+    QString dotUim = homeDir + "/.uim";
+    if( QFile::exists( dotUim ) )
+    {
+        QString msg = N_("The user customize file \"~/.uim\" is found.\n"
+                         "This file will override all conflicted settings set by\n"
+                         "this tool (stored in ~/.uim.d/customs/*.scm).\n"
+                         "Please check the file if you find your settings aren't applied");
+        QConfirmDialog *d = new QConfirmDialog( msg,
+                                                "/uim/qt/warnDotUim",
+                                                this );
+        d->setCaption( _("~/.uim exists!") );
+        d->exec();
+        delete d;
+    }
+}
+
 /*
  * Building up GUI
  */
@@ -196,15 +230,19 @@
 
 void UimPrefDialog::confirmChange()
 {
-    QConfirmDialog *cDialog = new QConfirmDialog( _("The value was changed.\nSave?"),
-                                                  this );
-    if( cDialog->exec() == QDialog::Accepted )
+    int result = QMessageBox::question( this,
+                                        _("Save Confirm"),
+                                        _("The value was changed.\nSave?"),
+                                        _("OK"),
+                                        _("Cancel") );
+    switch(result)
     {
+    case 0:
         slotApply();
-    }
-    else
-    {
+        break;
+    case 1:
         m_isValueChanged = false;
+        break;
     }
 }
 
@@ -251,25 +289,57 @@
 }
 
 //-------------------------------------------------------------------------------------
-QConfirmDialog::QConfirmDialog( const QString &msg, QWidget *parent, const char *name )
-    : QDialog( parent, name )
+QConfirmDialog::QConfirmDialog( const QString &msg, const QString &confname, QWidget *parent, const char *name )
+    : QDialog( parent, name ),
+      m_confname( confname )
 {
-    QVBoxLayout *vLayout = new QVBoxLayout( this );
-    vLayout->setSpacing( 6 );
-    vLayout->setMargin( 10 );
+    QSettings settings;
+    bool isShowOnStartup = settings.readBoolEntry( m_confname, true );
+    if( isShowOnStartup )
+        setupWidgets( msg );
+}
+
+void QConfirmDialog::setupWidgets( const QString&msg )
+{
+    QVBoxLayout *vbox = new QVBoxLayout( this );
+    vbox->setSpacing( 6 );
+    vbox->setMargin( 6 );
+
     QLabel *msgLabel = new QLabel( msg, this );
-    QHBox *buttonHBox = new QHBox( this );
-    QPushButton *okButton = new QPushButton( _("OK"), buttonHBox );
-    QPushButton *cancelButton = new QPushButton( _("Cancel"), buttonHBox );
-    vLayout->addWidget( msgLabel );
-    vLayout->addWidget( buttonHBox );
+    KSeparator *sep = new KSeparator( this );
 
-    QObject::connect( okButton, SIGNAL(clicked()),
+    QHBoxLayout *buttonHBox = new QHBoxLayout(vbox, 4);
+
+    QCheckBox *checkBox = new QCheckBox( _("Show this dialog on startup"), this );
+    QSettings settings;
+    bool isWarnDotUim = settings.readBoolEntry( m_confname, true );
+    checkBox->setChecked( isWarnDotUim );
+
+    QPushButton *ok = new QPushButton( _("OK"), this );
+    ok->setDefault(true);
+    buttonHBox->addWidget( checkBox );
+    buttonHBox->addStretch();
+    buttonHBox->addWidget( ok );
+
+    vbox->addWidget( msgLabel );
+    vbox->addWidget( sep );
+    vbox->addLayout( buttonHBox );
+
+    QObject::connect( ok, SIGNAL(clicked()),
                       this, SLOT(accept()) );
-    QObject::connect( cancelButton, SIGNAL(clicked()),
-                      this, SLOT(reject()) );
+    QObject::connect( checkBox, SIGNAL(toggled(bool)),
+                      this, SLOT(showOnStart(bool)) );
 }
 
+void QConfirmDialog::showOnStart( bool isShowOnStart )
+{
+    QSettings settings;
+    settings.writeEntry( m_confname, isShowOnStart );
+
+    qDebug("show on start = %d", isShowOnStart );
+}
+
+
 //-----------------------------------------------------------------------------------
 
 GroupPageWidget::GroupPageWidget( QWidget *parent, const char *group_name )

Modified: trunk/qt/pref-qt.h
===================================================================
--- trunk/qt/pref-qt.h	2005-02-07 07:39:09 UTC (rev 591)
+++ trunk/qt/pref-qt.h	2005-02-07 08:28:06 UTC (rev 592)
@@ -61,6 +61,8 @@
     ~UimPrefDialog();
 
 protected:
+    void checkDotUimFile();
+    
     void setupWidgets();
     void createMainWidgets();
     void createGroupWidgets();
@@ -93,7 +95,16 @@
     Q_OBJECT
 
 public:
-    QConfirmDialog( const QString &msg, QWidget *parent = 0, const char *name = 0 );
+    QConfirmDialog( const QString &msg, const QString &confname, QWidget *parent, const char *name = 0 );
+
+protected:
+    void setupWidgets( const QString& msg );
+
+protected slots:
+    void showOnStart( bool isShowOnStart );
+
+protected:
+    QString m_confname;
 };
 
 //---------------------------------------------------------------------------------



More information about the Uim-commit mailing list