]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Added dialog flag "SetFocus"
authorstv <stv@opencascade.com>
Wed, 13 Jul 2005 04:29:48 +0000 (04:29 +0000)
committerstv <stv@opencascade.com>
Wed, 13 Jul 2005 04:29:48 +0000 (04:29 +0000)
src/Qtx/QtxDialog.cxx
src/Qtx/QtxDialog.h

index fc2120544789be06cc29f27dac77d47e4f043863..9b612a2139a3b0206df56b7ec93f61ae2ae80c88 100755 (executable)
@@ -335,9 +335,9 @@ QtxDialog::QtxDialog( QWidget* parent, const char* name,
            wf | WStyle_NormalBorder | WStyle_Customize | WStyle_Title | WStyle_SysMenu ),
 #endif
 mySender( 0 ),
+myAlignment( 0 ),
 myInited( false ),
-myDialogFlags( Accept ),
-myAlignment( 0 )
+myDialogFlags( Accept | SetFocus )
 {
        QVBoxLayout* base = new QVBoxLayout( this, 5, 0 );
        QtxGroupBox* main = new QtxGroupBox( 1, Qt::Horizontal, "", this );
@@ -478,7 +478,9 @@ bool QtxDialog::testButtonFlags( const int f ) const
                  Following flags can be used:
                        Accept    - Allow to control dialog accepting. See also acceptData().
                        Reject    - Allow to control dialog rejecting. See also rejectData().
-                       AlignOnce - Allow to align dialog only whem it first time shown.
+                       AlignOnce - Allow to align dialog only when it first time shown.
+                       SetFocus  - Allow to set focus on dialog when it shown. User can use
+                  setFocusProxy() and specify own initial focus widget.
 */
 
 void QtxDialog::setDialogFlags( const int f )
@@ -827,7 +829,9 @@ void QtxDialog::show()
 {
        QDialog::show();
 
-       setFocus();
+       if ( testDialogFlags( SetFocus ) )
+         setFocus();
+
        myInited = true;
 }
 
index 5c7725ae5a0f467d00e4eee094dfa14236f0a679..848341c09b597920cd742a78550f454e4048945f 100755 (executable)
@@ -22,8 +22,8 @@ class QTX_EXPORT QtxDialog : public QDialog
 {
          Q_OBJECT
 
-       class Area;
-       class Border;
+         class Area;
+         class Border;
 
 public:
     typedef enum { Position, Expand, Uniform } PlacePolicy;
@@ -44,67 +44,68 @@ public:
                    All       = Standard | YesNo | Apply | Close } ButtonFlags;
 
     typedef enum { Accept    = 0x000001,
-                                  Reject    = 0x000002,
-                                  AlignOnce = 0x000004 } DialogFlags;
+                                          Reject    = 0x000002,
+                                          AlignOnce = 0x000004,
+                   SetFocus  = 0x000008 } DialogFlags;
 
 public:
     QtxDialog( QWidget* = 0, const char* = 0, bool = false,
                bool = false, const int = Standard, WFlags = 0 );
     virtual ~QtxDialog();
-    
+
     void             setDialogFlags( const int );
     void             clearDialogFlags( const int );
     bool             testDialogFlags( const int ) const;
-    
+
     void             setButtonFlags( const int );
     void             clearButtonFlags( const int );
     bool             testButtonFlags( const int ) const;
-    
+
     int              buttonPosition( const int ) const;
     void             setButtonPosition( const int, const int = -1 );
     void             setPlacePosition( const int, const int );
-    
+
     int              placePolicy( const int ) const;
     void             setPlacePolicy( const int, const int );
     void             setButtonPlace( const int, const int );
-    
+
     QString          buttonText( const int );
     void             setButtonText( const int, const QString& text );
-    
+
     void             setButtonFocus( const int );
     bool             hasButtonFocus( const int ) const;
-    
+
     bool             isButtonEnabled( const int ) const;
     void             setButtonEnabled( const bool, const int );
-    
+
     bool             isBorderEnabled( const int ) const;
     void             setBorderEnabled( const bool, const int );
-    
+
     void             removeButton( const int );
     int              insertButton( const QString&, const int = BottomArea );
-    
+
     QValueList<int>  userButtonIds() const;
     QButton*         userButton( const int ) const;
-    
+
     virtual void     show();
     virtual void     hide();
-    
+
     uint             setAlignment( uint align );
     static  void     setUnits( QLabel*, const QString& );
-    
+
 signals:
     void             dlgButton( int );
     void             dlgParamChanged();
-    
+
     void             dlgHelp();
     void             dlgApply();
-    
+
     void             dlgOk();
     void             dlgNo();
     void             dlgYes();
     void             dlgClose();
     void             dlgCancel();
-    
+
 public slots:
     void             update();
 
@@ -118,44 +119,44 @@ private slots:
     void             onButton();
     void             onSizeGripDestroyed();
     void             onDestroyed( QObject* );
-    
+
 protected:
     typedef QMap<int, QButton*> ButtonMap;
-    
+
 protected:
     QFrame*          mainFrame() const;
-    
+
     virtual bool     acceptData() const;
     virtual bool     rejectData() const;
-    
+
     virtual QButton* createButton( QWidget* );
-    
+
     QButton*         button( const int ) const;
     ButtonMap        buttons( const int = All ) const;
     int              buttonId( const QButton* ) const;
     int              buttonPosition( QButton* ) const;
-    
+
     virtual void     showEvent( QShowEvent* );
     virtual void     hideEvent( QHideEvent* );
     virtual void     closeEvent( QCloseEvent* );
     virtual void     childEvent( QChildEvent* );
     virtual void     keyPressEvent( QKeyEvent* );
-    
+
 private:
-       void             adjustButtons();
+         void             adjustButtons();
     void             emitSignal();
-    
+
 private:
     typedef QMap<int, Area*> AreaMap;
     typedef QMap<int, int>   PositionMap;
-    
+
     friend class Area;
-    
+
 private:
     AreaMap          myArea;
     ButtonMap        myButton;
     PositionMap      myPosition;
-    
+
     bool             myInited;
     const QObject*   mySender;
     uint             myAlignment;