-// VISU VISUGUI : GUI of VISU component
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 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.
//
-// 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
//
-//
-//
+
+// VISU VISUGUI : GUI of VISU component
// File : VisuGUI_BuildProgressDlg.cxx
// Author : Oleg UVAROV
// Module : VISU
-
+//
#include "VisuGUI_BuildProgressDlg.h"
#include "VisuGUI.h"
#include <vtkTimerLog.h>
-#include <qcheckbox.h>
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qlcdnumber.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qtimer.h>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLCDNumber>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QTimer>
+#include <QKeyEvent>
/*!
* Constructor
*/
VisuGUI_BuildProgressDlg::VisuGUI_BuildProgressDlg( QWidget* theParent ):
- QDialog( theParent,
- "VisuGUI_BuildProgressBar",
- false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+ QDialog( theParent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
myIsRaiseColor( false )
{
- setCaption( tr( "DLG_BUILD_PROGRESS_TITLE" ) );
+ setAttribute( Qt::WA_DeleteOnClose );
+ setWindowTitle( tr( "DLG_BUILD_PROGRESS_TITLE" ) );
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
QVBoxLayout* aTopLayout = new QVBoxLayout( this );
aTopLayout->setSpacing( 6 );
aTopLayout->setMargin( 6 );
- aTopLayout->setAutoAdd( true );
+ //aTopLayout->setAutoAdd( true );
// Settings
mySettingsBox = new QGroupBox( tr( "IMPORT_SETTINGS" ), this );
- mySettingsBox->setColumnLayout( 0, Qt::Vertical );
- mySettingsBox->layout()->setSpacing( 0 );
- mySettingsBox->layout()->setMargin( 0 );
+ aTopLayout->addWidget( mySettingsBox );
+ //mySettingsBox->setColumnLayout( 0, Qt::Vertical );
+ //mySettingsBox->layout()->setSpacing( 0 );
+ //mySettingsBox->layout()->setMargin( 0 );
- QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox->layout() );
+ QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
aSettingsLayout->setSpacing( 6 );
aSettingsLayout->setMargin( 11 );
myCloseCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "close_at_finish", true ) );
aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
- aSettingsLayout->addMultiCellWidget( myFileNameLineEdit, 1, 1, 0, 1 );
+ aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
//aSettingsLayout->addWidget( aFileNameButton, 1, 2 );
aSettingsLayout->addWidget( myBuildAllCheckBox, 2, 0 );
aSettingsLayout->addWidget( myBuildAtOnceCheckBox, 3, 0 );
// Progress
myProgressBox = new QGroupBox( tr( "IMPORT_PROGRESS" ), this );
- myProgressBox->setColumnLayout( 0, Qt::Vertical );
- myProgressBox->layout()->setSpacing( 0 );
- myProgressBox->layout()->setMargin( 0 );
+ aTopLayout->addWidget( myProgressBox );
+ //myProgressBox->setColumnLayout( 0, Qt::Vertical );
+ //myProgressBox->layout()->setSpacing( 0 );
+ //myProgressBox->layout()->setMargin( 0 );
- QGridLayout* aProgressLayout = new QGridLayout( myProgressBox->layout() );
+ QGridLayout* aProgressLayout = new QGridLayout( myProgressBox );
aProgressLayout->setSpacing( 6 );
aProgressLayout->setMargin( 11 );
myBuildEntitiesButton = new QPushButton( myProgressBox );
myBuildEntitiesButton->setEnabled( false );
myBuildEntitiesButton->setFixedSize( 30, 30 );
- myBuildEntitiesButton->setPaletteBackgroundColor( Qt::red );
+ QPalette aPal = myBuildEntitiesButton->palette();
+ aPal.setColor( myBuildEntitiesButton->backgroundRole(), Qt::red );
+ myBuildEntitiesButton->setPalette( aPal );
myBuildFieldsCheckBox = new QCheckBox( tr( "BUILD_FIELDS" ), myProgressBox );
myBuildFieldsCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "build_fields", true ) );
myBuildFieldsButton = new QPushButton( myProgressBox );
myBuildFieldsButton->setEnabled( false );
myBuildFieldsButton->setFixedSize( 30, 30 );
- myBuildFieldsButton->setPaletteBackgroundColor( Qt::red );
+ aPal = myBuildFieldsButton->palette();
+ aPal.setColor( myBuildFieldsButton->backgroundRole(), myBuildFieldsCheckBox->isChecked() ? Qt::red : Qt::gray );
+ myBuildFieldsButton->setPalette( aPal );
+
connect( myBuildFieldsCheckBox, SIGNAL( clicked() ), this, SLOT( onBuildCheckBoxClicked() ) );
myBuildMinMaxCheckBox = new QCheckBox( tr( "BUILD_MINMAX" ), myProgressBox );
myBuildMinMaxButton = new QPushButton( myProgressBox );
myBuildMinMaxButton->setEnabled( false );
myBuildMinMaxButton->setFixedSize( 30, 30 );
- myBuildMinMaxButton->setPaletteBackgroundColor( Qt::red );
+ aPal = myBuildMinMaxButton->palette();
+ aPal.setColor( myBuildMinMaxButton->backgroundRole(), myBuildMinMaxCheckBox->isChecked() ? Qt::red : Qt::gray );
+ myBuildMinMaxButton->setPalette( aPal );
+
connect( myBuildMinMaxCheckBox, SIGNAL( clicked() ), this, SLOT( onBuildCheckBoxClicked() ) );
myBuildGroupsCheckBox = new QCheckBox( tr( "BUILD_GROUPS" ), myProgressBox );
myBuildGroupsButton = new QPushButton( myProgressBox );
myBuildGroupsButton->setEnabled( false );
myBuildGroupsButton->setFixedSize( 30, 30 );
- myBuildGroupsButton->setPaletteBackgroundColor( Qt::red );
+ aPal = myBuildGroupsButton->palette();
+ aPal.setColor( myBuildGroupsButton->backgroundRole(), myBuildGroupsCheckBox->isChecked() ? Qt::red : Qt::gray );
+ myBuildGroupsButton->setPalette( aPal );
+
connect( myBuildGroupsCheckBox, SIGNAL( clicked() ), this, SLOT( onBuildCheckBoxClicked() ) );
aProgressLayout->addWidget( aBuildEntitiesLabel, 0, 0 );
aProgressLayout->addWidget( myBuildGroupsButton, 3, 1 );
// Time
+ myTime = QTime( 0, 0, 0, 0 );
+
myTimeBox = new QGroupBox( tr( "IMPORT_TIME" ), this );
- myTimeBox->setColumnLayout( 0, Qt::Vertical );
- myTimeBox->layout()->setSpacing( 0 );
- myTimeBox->layout()->setMargin( 0 );
+ aTopLayout->addWidget( myTimeBox );
+ //myTimeBox->setColumnLayout( 0, Qt::Vertical );
+ //myTimeBox->layout()->setSpacing( 0 );
+ //myTimeBox->layout()->setMargin( 0 );
- QGridLayout* aTimeLayout = new QGridLayout( myTimeBox->layout() );
+ QGridLayout* aTimeLayout = new QGridLayout( myTimeBox );
aTimeLayout->setSpacing( 6 );
aTimeLayout->setMargin( 11 );
myTimeLCDNumber = new QLCDNumber( myTimeBox );
myTimeLCDNumber->setSegmentStyle( QLCDNumber::Filled );
- myTimeLCDNumber->setPaletteBackgroundColor( Qt::black );
- myTimeLCDNumber->setPaletteForegroundColor( Qt::white );
+ myTimeLCDNumber->setStyleSheet( "color: white; background-color: black" );
+ //QPalette aPal = myTimeLCDNumber->palette();
+ //aPal.setColor( myTimeLCDNumber->backgroundRole(), Qt::black );
+ //aPal.setColor( myTimeLCDNumber->foregroundRole(), Qt::white );
+ //myTimeLCDNumber->setPalette( aPal );
+
myTimeLCDNumber->setNumDigits( 8 );
myTimeLCDNumber->display( myTime.toString( "hh:mm:ss.zzz" ) );
// Start / Close
QGroupBox* CommonGroup = new QGroupBox( this );
- CommonGroup->setColumnLayout(0, Qt::Vertical );
- CommonGroup->layout()->setSpacing( 0 );
- CommonGroup->layout()->setMargin( 0 );
- QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup->layout() );
+ aTopLayout->addWidget( CommonGroup );
+ //CommonGroup->setColumnLayout(0, Qt::Vertical );
+ //CommonGroup->layout()->setSpacing( 0 );
+ //CommonGroup->layout()->setMargin( 0 );
+ QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
CommonGroupLayout->setAlignment( Qt::AlignTop );
CommonGroupLayout->setSpacing( 6 );
CommonGroupLayout->setMargin( 11 );
if( myFileName.isNull() )
return;
- myResult = myGenerator->CreateResult( myFileName );
+ myResult = myGenerator->CreateResult( (const char*)myFileName.toLatin1() );
if (CORBA::is_nil(myResult.in())) {
- SUIT_MessageBox::warn1(this,
- tr("WRN_VISU"),
- tr("ERR_ERROR_IN_THE_FILE"),
- tr("BUT_OK"));
+ SUIT_MessageBox::warning(this,
+ tr("WRN_VISU"),
+ tr("ERR_ERROR_IN_THE_FILE"),
+ tr("BUT_OK"));
onClose();
}else{
myResult->SetBuildFields( myBuildFieldsCheckBox->isChecked(), myBuildMinMaxCheckBox->isChecked() );
bool aBuildAtOnce = myBuildAtOnceCheckBox->isChecked();
if( aBuildAtOnce )
{
- QApplication::setOverrideCursor( Qt::waitCursor );
- myCurrentTime = vtkTimerLog::GetCurrentTime();
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ myCurrentTime = vtkTimerLog::GetUniversalTime();
}
myTime.setHMS( 0, 0, 0 );
app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
}
else {
- QString platform;
+ QString platform;
#ifdef WIN32
- platform = "winapplication";
+ platform = "winapplication";
#else
- platform = "application";
+ platform = "application";
#endif
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
+ SUIT_MessageBox::warning(0, ("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
+ tr("BUT_OK"));
}
}
{
myTime = myTime.addMSecs( 100 );
if( myTime.minute() > 9 && myTimeLCDNumber->numDigits() < 9 )
- myTimeLCDNumber->setNumDigits( 9 );
+ myTimeLCDNumber->setNumDigits( 9 );
myTimeLCDNumber->display( myTime.toString( "m:ss.zzz" ) );
bool isEntitiesDone = myResult->IsEntitiesDone();
if( aBuildAtOnce )
{
- QApplication::restoreOverrideCursor();
-
- QTime aTime;
- int mSecs = ( int )( 1000 * ( vtkTimerLog::GetCurrentTime() - myCurrentTime ) );
- aTime = aTime.addMSecs( mSecs );
- if( aTime.minute() > 9 )
- myTimeLCDNumber->setNumDigits( 9 );
- myTimeLCDNumber->display( aTime.toString( "m:ss.zzz" ) );
+ updateButton( myBuildEntitiesButton, true );
+ updateButton( myBuildFieldsButton, true );
+ updateButton( myBuildMinMaxButton, true );
+ updateButton( myBuildGroupsButton, true );
+
+ QApplication::restoreOverrideCursor();
+
+ QTime aTime;
+ int mSecs = ( int )( 1000 * ( vtkTimerLog::GetUniversalTime() - myCurrentTime ) );
+ aTime = aTime.addMSecs( mSecs );
+ if( aTime.minute() > 9 )
+ myTimeLCDNumber->setNumDigits( 9 );
+ myTimeLCDNumber->display( aTime.toString( "m:ss.zzz" ) );
}
if( myCloseCheckBox->isChecked() )
- done( 0 );
+ done( 0 );
else
- SUIT_MessageBox::warn1( this, tr( "INF_VISU" ), tr( "IMPORT_DONE" ), tr( "BUT_OK" ) );
+ SUIT_MessageBox::warning( this,
+ tr( "INF_VISU" ),
+ tr( "IMPORT_DONE" ),
+ tr( "BUT_OK" ) );
}
}
catch( ... ) {
void VisuGUI_BuildProgressDlg::updateButton( QPushButton* theButton, bool theIsDone )
{
- QColor aCurrentColor = theButton->paletteBackgroundColor();
+ QPalette aPal = theButton->palette();
+ QColor aCurrentColor = aPal.color( theButton->backgroundRole() );
if( aCurrentColor == Qt::gray || aCurrentColor == Qt::green )
return;
int gNew = g + ( myIsRaiseColor ? 1 : -1 ) * 51;
- aNewColor.setRgb( 255, gNew, 0 );
+ aNewColor.setRgb( 255, gNew, 0 );
}
-
- theButton->setPaletteBackgroundColor( aNewColor );
+ aPal.setColor( theButton->backgroundRole(), aNewColor );
+ theButton->setPalette( aPal );
}
void VisuGUI_BuildProgressDlg::done( int r )
}
else if( aCheckBox == myBuildFieldsCheckBox )
{
- myBuildFieldsButton->setPaletteBackgroundColor( aColor );
+ QPalette aPal = myBuildFieldsButton->palette();
+ aPal.setColor( myBuildFieldsButton->backgroundRole(), aColor );
+ myBuildFieldsButton->setPalette( aPal );
if( !anIsChecked && myBuildMinMaxCheckBox->isChecked() )
myBuildMinMaxCheckBox->animateClick();
}
else if( aCheckBox == myBuildMinMaxCheckBox )
{
- myBuildMinMaxButton->setPaletteBackgroundColor( aColor );
+ QPalette aPal = myBuildMinMaxButton->palette();
+ aPal.setColor( myBuildMinMaxButton->backgroundRole(), aColor );
+ myBuildMinMaxButton->setPalette( aPal );
if( anIsChecked && !myBuildFieldsCheckBox->isChecked() )
myBuildFieldsCheckBox->animateClick();
}
else if( aCheckBox == myBuildGroupsCheckBox )
- myBuildGroupsButton->setPaletteBackgroundColor( aColor );
+ {
+ QPalette aPal = myBuildGroupsButton->palette();
+ aPal.setColor( myBuildGroupsButton->backgroundRole(), aColor );
+ myBuildGroupsButton->setPalette( aPal );
+ }
}
if ( e->isAccepted() )
return;
- if ( e->key() == Key_F1 )
+ if ( e->key() == Qt::Key_F1 )
{
e->accept();
onHelp();