9 #include <fwCore/base.hpp> 11 #include <fwGui/registry/macros.hpp> 12 #include <fwGui/container/fwContainer.hpp> 13 #include <fwGui/IFrameSrv.hpp> 15 #include "fwGuiQt/dialog/ProgressDialog.hpp" 29 m_pprogressbar ( NULL ),
30 m_pcancelButton ( NULL ),
31 m_pmainWindow ( NULL )
36 QWidget *activeWindow = ::fwGuiQt::container::QtContainer::dynamicCast( progressWidget )->getQtContainer();
37 m_pmainWindow = qobject_cast< QMainWindow * >( activeWindow );
52 m_pcancelButton =
new QPushButton(
"Cancel");
53 QObject::connect( m_pcancelButton, SIGNAL(clicked()),
this, SLOT(cancelPressed()) );
57 m_pprogressbar =
new QProgressBar();
58 m_pprogressbar->setRange(0,100);
59 m_pprogressbar->setValue(0);
60 m_pmainWindow->statusBar()->addPermanentWidget(m_pprogressbar,0);
61 m_pmainWindow->statusBar()->addPermanentWidget(m_pcancelButton,0);
62 m_pmainWindow->statusBar()->setMinimumHeight(25);
63 m_pmainWindow->statusBar()->setMaximumHeight(25);
67 m_pdialog =
new QProgressDialog( 0, Qt::WindowStaysOnTopHint );
72 m_pdialog->setWindowModality(Qt::NonModal);
73 m_pdialog->setMinimum(0);
74 m_pdialog->setMaximum(100);
75 m_pdialog->setValue(0);
76 m_pdialog->setCancelButton(m_pcancelButton);
87 ProgressDialog::~ProgressDialog()
89 QObject::disconnect( m_pcancelButton, SIGNAL(clicked()),
this, SLOT(cancelPressed()) );
99 else if ( m_pprogressbar )
101 m_pmainWindow->statusBar()->removeWidget( m_pprogressbar );
102 m_pmainWindow->statusBar()->removeWidget( m_pcancelButton );
103 m_pcancelButton->hide();
104 delete m_pcancelButton;
105 m_pprogressbar->hide();
106 delete m_pprogressbar;
117 SLM_ASSERT(
"m_pdialog or m_pprogressbar not instanced", m_pprogressbar || m_pdialog);
118 int value = (int)(percent*100);
121 OSLM_TRACE(
"ProgressDialog msg" << msg <<
" : " << value <<
"%");
124 if ( m_pprogressbar )
126 m_pprogressbar->setValue(value);
128 else if ( m_pdialog )
130 m_pdialog->setValue(value);
133 if ( m_processUserEvents )
135 QCoreApplication::processEvents(QEventLoop::AllEvents);
139 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
150 m_title = QString::fromStdString(title);
151 if ( m_pprogressbar )
153 m_pmainWindow->statusBar()->showMessage(m_title);
155 else if ( m_pdialog )
157 m_pdialog->setWindowTitle(m_title);
166 if (!m_title.isEmpty())
172 message += QString::fromStdString(msg);
173 if ( m_pprogressbar )
175 m_pmainWindow->statusBar()->showMessage(message);
177 else if ( m_pdialog )
179 m_pdialog->setLabelText(message);
185 void ProgressDialog::cancelPressed()
187 IProgressDialog::cancelPressed();
191 void ProgressDialog::hideCancelButton()
193 m_pcancelButton->hide();
FWGUI_API void setTitle(const std::string &title) override
set the title for the dialog
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
This class allows us to select an acquisition in a patient data base.
#define OSLM_TRACE(message)
static FWGUI_API const FactoryRegistryKeyType REGISTRY_KEY
this unique key should be used for all factory for specific LocationDialog(qt,wx,...)
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
FWGUI_API void setMessage(const std::string &message) override
set the message for the dialog
FWGUI_API void operator()(float percent, std::string msg) override
action called by fwTools::ProgressAdviser
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWGUI_API::fwGui::container::fwContainer::sptr getProgressWidget()
Get widget defined for progress bar.
int m_value
progress bar's current value: [0-100]