From: stv Date: Wed, 13 Jul 2005 04:29:48 +0000 (+0000) Subject: Added dialog flag "SetFocus" X-Git-Tag: V3_0_1~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1fc22ac8222b163806309e19d37c4715fa189dce;p=modules%2Fgui.git Added dialog flag "SetFocus" --- diff --git a/src/Qtx/QtxDialog.cxx b/src/Qtx/QtxDialog.cxx index fc2120544..9b612a213 100755 --- a/src/Qtx/QtxDialog.cxx +++ b/src/Qtx/QtxDialog.cxx @@ -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; } diff --git a/src/Qtx/QtxDialog.h b/src/Qtx/QtxDialog.h index 5c7725ae5..848341c09 100755 --- a/src/Qtx/QtxDialog.h +++ b/src/Qtx/QtxDialog.h @@ -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 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 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 AreaMap; typedef QMap PositionMap; - + friend class Area; - + private: AreaMap myArea; ButtonMap myButton; PositionMap myPosition; - + bool myInited; const QObject* mySender; uint myAlignment;