1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ProgressIndicator.h"
21 #include <QProgressBar>
22 #include <QVBoxLayout>
23 #include <QApplication>
25 IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_ProgressIndicator, Message_ProgressIndicator)
27 HYDROGUI_ProgressIndicator::HYDROGUI_ProgressIndicator( QWidget* theParent, const QString& theName )
28 : QtxDialog( theParent, true, false, QtxDialog::Cancel ), myUserBreak(false)
30 setWindowTitle( theName );
32 QVBoxLayout* aLayout = new QVBoxLayout( mainFrame() );
33 aLayout->setMargin( 5 );
34 aLayout->setSpacing( 5 );
36 myBar = new QProgressBar( mainFrame() );
38 aLayout->addWidget( myBar );
40 setButtonText( Cancel, tr("CANCEL") );
41 setButtonPosition( Center, Cancel );
42 setMinimumWidth( 350 );
45 HYDROGUI_ProgressIndicator::~HYDROGUI_ProgressIndicator()
49 Standard_Boolean HYDROGUI_ProgressIndicator::Show(const Standard_Boolean theForce)
51 Standard_Real aPosition = GetPosition();
52 Standard_Boolean isUserBreak = UserBreak();
54 bool isFinished = aPosition >= 1 || ( isUserBreak && GetNbScopes() < 2 );
56 if ( result() != Accepted ) {
59 } else if (!isVisible()) {
65 int aNbSteps = myBar->maximum() - myBar->minimum();
66 int aValue = int( aPosition * aNbSteps );
67 myBar->setValue(aValue);
70 QApplication::processEvents();
76 Standard_Boolean HYDROGUI_ProgressIndicator::UserBreak()
81 void HYDROGUI_ProgressIndicator::Reset()
83 Message_ProgressIndicator::Reset();
84 setButtonText( Cancel, tr("CANCEL") );
85 setButtonEnabled( true, Cancel );
89 void HYDROGUI_ProgressIndicator::reject()
92 setButtonText( Cancel, tr("CANCELLING") );
93 setButtonEnabled( false, Cancel );
94 QApplication::processEvents();