[uim-commit] r2586 - trunk/qt

ekato at freedesktop.org ekato at freedesktop.org
Thu Dec 15 02:58:45 PST 2005


Author: ekato
Date: 2005-12-15 02:58:40 -0800 (Thu, 15 Dec 2005)
New Revision: 2586

Modified:
   trunk/qt/pref-customwidgets.cpp
   trunk/qt/pref-customwidgets.h
Log:
* qt/pref-customwidgets.cpp : Hack to enable file dialog to select
  both files and directories.  I think uim-custom should
  distinguish pathname and filename for GUI toolkit.
(CustomPathnameEdit::slotPathnameButtonClicked) : Set default mode
  to QFileDialog::ExistingFile.
(CustomPathnameEdit::slotFileDialogFilterSelecte) : New.  Set mode
  to QFileDialog::Directory if "Directories" filter is selected.
* qt/pref-customwidgets.h (class CustomPathnameEdit) : Add
  slotFileDialogFilterSelected() and m_fileDailog memeber.


Modified: trunk/qt/pref-customwidgets.cpp
===================================================================
--- trunk/qt/pref-customwidgets.cpp	2005-12-15 02:37:40 UTC (rev 2585)
+++ trunk/qt/pref-customwidgets.cpp	2005-12-15 10:58:40 UTC (rev 2586)
@@ -198,14 +198,20 @@
 
 void CustomPathnameEdit::slotPathnameButtonClicked()
 {
-    QFileDialog* fd = new QFileDialog( this, "file dialog" );
-    fd->setMode( QFileDialog::Directory );
-    if ( fd->exec() == QDialog::Accepted )
+    m_fileDialog = new QFileDialog( this, "file dialog" );
+    QObject::connect( m_fileDialog, SIGNAL(filterSelected(const QString&)),
+                      this, SLOT(slotFileDialogFilterSelected(const QString&)) );
+
+
+    m_fileDialog->setMode( QFileDialog::ExistingFile );
+    m_fileDialog->addFilter( "Directories" );
+    m_fileDialog->setSelectedFilter( "All Files (*)" );
+    if ( m_fileDialog->exec() == QDialog::Accepted )
     {
-        QString fileName = fd->selectedFile();
+        QString fileName = m_fileDialog->selectedFile();
         m_lineEdit->setText( fileName );
     }
-    delete fd;
+    delete m_fileDialog;
 }
 
 void CustomPathnameEdit::slotCustomTextChanged( const QString & text )
@@ -218,6 +224,14 @@
     setCustom( m_custom );
 }
 
+void CustomPathnameEdit::slotFileDialogFilterSelected( const QString & text )
+{
+    if (text == "Directories")
+        m_fileDialog->setMode( QFileDialog::Directory );
+    else
+        m_fileDialog->setMode( QFileDialog::ExistingFile );
+}
+
 //----------------------------------------------------------------------------------------
 CustomChoiceCombo::CustomChoiceCombo( struct uim_custom *c, QWidget *parent, const char *name)
     : QComboBox( parent, name ),

Modified: trunk/qt/pref-customwidgets.h
===================================================================
--- trunk/qt/pref-customwidgets.h	2005-12-15 02:37:40 UTC (rev 2585)
+++ trunk/qt/pref-customwidgets.h	2005-12-15 10:58:40 UTC (rev 2586)
@@ -176,9 +176,11 @@
 protected slots:
     void slotPathnameButtonClicked();
     void slotCustomTextChanged( const QString & text );
+    void slotFileDialogFilterSelected( const QString & text );
 private:
     QLineEdit *m_lineEdit;
     QPushButton *m_fileButton;
+    QFileDialog *m_fileDialog;
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:



More information about the uim-commit mailing list