Salome HOME
Merge branch 'master' into pre/V8_2_BR
[modules/gui.git] / src / Qtx / QtxDialog.cxx
index 3200b78516ab5213c68eec21dadd1ab95cdade92..0479b99f5c8248720d7df53eb81ab210c7e2c625 100755 (executable)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File:      QtxDialog.cxx
 // Author:    Sergey TELKOV
 //
@@ -260,7 +261,7 @@ void QtxDialog::Area::layoutButtons()
     {
       buttonId[mit.value()] = mit.key();
       if ( mit.key() >= 0 )
-       src.append( mit.value() );
+        src.append( mit.value() );
     }
   }
 
@@ -321,7 +322,7 @@ void QtxDialog::Area::layoutButtons()
     {
       buttonLayout->addWidget( other[i] );
       if ( aPolicy == QtxDialog::Uniform && i < (int)other.count() - 1  )
-       buttonLayout->addStretch( 1 );
+        buttonLayout->addStretch( 1 );
     }
   }
 
@@ -440,16 +441,16 @@ QSize QtxDialog::Border::minimumSizeHint() const
   \param wf dialog box flags (Qt::WindowFlags)
 */
 QtxDialog::QtxDialog( QWidget* parent, bool modal, bool allowResize, const int f, Qt::WindowFlags wf )
-: QDialog( parent, (Qt::WindowFlags)( wf | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::Dialog |
+: QDialog( parent, (Qt::WindowFlags)( wf | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | Qt::Dialog |
 #ifdef WIN32
            ( allowResize ? 0 : Qt::FramelessWindowHint ) |
 #endif
            ( ( allowResize 
 #ifdef WIN32 
-              // in qwidget_win.cpp flag WStyle_ContextHelp will be unset in WStyle_MinMax in switched ON
-              && !( wf & Qt::WindowContextHelpButtonHint )
+               // in qwidget_win.cpp flag WStyle_ContextHelp will be unset in WStyle_MinMax in switched ON
+               && !( wf & Qt::WindowContextHelpButtonHint )
 #endif
-              ) ? Qt::WindowMaximizeButtonHint : 0 ) ) ),
+               ) ? Qt::WindowMaximizeButtonHint : 0 ) ) ),
   myInited( false ),
   mySender( 0 ),
   myAlignment( 0 ),
@@ -1051,7 +1052,7 @@ void QtxDialog::removeButton( const int id )
     for ( ButtonMap::Iterator it = myButton.begin(); it != myButton.end(); ++it )
     {
       if ( it.key() < 0 )
-       map.insert( it.key(), it.value() );
+        map.insert( it.key(), it.value() );
     }
   }
   else if ( myButton.contains( id ) )
@@ -1212,7 +1213,7 @@ QtxDialog::ButtonMap QtxDialog::buttons( const int f ) const
   {
     for ( ButtonMap::ConstIterator it = myButton.begin(); it != myButton.end(); ++it )
       if ( f == -1 || ( it.key() >= 0 && f & it.key() ) )
-       retmap.insert( it.key(), it.value() );
+        retmap.insert( it.key(), it.value() );
   }
   return retmap;
 }
@@ -1326,9 +1327,12 @@ void QtxDialog::keyPressEvent( QKeyEvent* e )
 
   if ( e->key() == Qt::Key_Tab && e->modifiers() & Qt::ControlModifier )
   {
-    QObject* tab = qFindChild<QTabWidget*>( this );
-    if ( tab )
+    QObject* tab = this->findChild<QTabWidget*>();
+    if ( tab && !property( "in_tab_event" ).toBool() ) {
+      setProperty( "in_tab_event", true );
       QApplication::sendEvent( tab, e );
+      setProperty( "in_tab_event", false );
+    }
   }
 }
 
@@ -1438,8 +1442,9 @@ void QtxDialog::reject()
 void QtxDialog::emitSignal()
 {
   QApplication::instance()->processEvents();
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   QApplication::syncX();
-
+#endif
   int id = buttonId( (QAbstractButton*)mySender );
   mySender = 0;
 
@@ -1541,7 +1546,7 @@ void QtxDialog::adjustButtons()
     const QList<QAbstractButton*>& lst = aIt.value()->buttons();
     for ( QList<QAbstractButton*>::const_iterator bIt = lst.begin(); bIt != lst.end(); ++bIt )
       if ( (*bIt)->isVisibleTo( this ) )
-       minWidth = qMax( minWidth, (*bIt)->sizeHint().width() );
+        minWidth = qMax( minWidth, (*bIt)->sizeHint().width() );
   }
 
   for ( AreaMap::Iterator aItr = myArea.begin(); aItr != myArea.end(); ++aItr )
@@ -1549,7 +1554,7 @@ void QtxDialog::adjustButtons()
     const QList<QAbstractButton*>& lst = aItr.value()->buttons();
     for ( QList<QAbstractButton*>::const_iterator bItr = lst.begin(); bItr != lst.end(); ++bItr )
       if ( (*bItr)->isVisibleTo( this ) )
-       (*bItr)->setMinimumWidth( minWidth );
+        (*bItr)->setMinimumWidth( minWidth );
   }
 }