30#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
36#include <qpushbutton.h>
42#include <qfiledialog.h>
46#include "moc_G4OpenGLQtMovieDialog.cpp"
66G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(
67 G4OpenGLQtViewer* parentViewer,
71 fParentViewer(parentViewer)
74 setWindowTitle( tr(
" Save as movie" ));
78 QVBoxLayout* globalVLayout =
new QVBoxLayout(
this);
79 globalVLayout->setMargin(10);
80 globalVLayout->setSpacing(10);
83 QGroupBox *encoderGroupBox =
new QGroupBox(tr(
"Encoder path"),
this);
84 QVBoxLayout *encoderVGroupBoxLayout =
new QVBoxLayout(encoderGroupBox);
87 QWidget *encoderHBox =
new QWidget(encoderGroupBox);
88 QHBoxLayout *encoderHBoxLayout =
new QHBoxLayout(encoderHBox);
89 fEncoderPath =
new QLineEdit(
"",encoderHBox);
91 QPushButton *encoderButton =
new QPushButton(tr(
"..."),encoderHBox);
92 encoderButton->setMaximumWidth (30);
94 fEncoderStatus =
new QLabel(encoderGroupBox);
96 fEncoderStatus->setWordWrap(
true);
97 encoderVGroupBoxLayout->setMargin(15);
99 fEncoderStatus->setText(
"");
101 encoderHBoxLayout->addWidget(fEncoderPath);
102 encoderHBoxLayout->addWidget(encoderButton);
103 encoderVGroupBoxLayout->addWidget(encoderHBox);
104 encoderVGroupBoxLayout->addWidget(fEncoderStatus);
106 encoderGroupBox->setLayout(encoderVGroupBoxLayout);
107 globalVLayout->addWidget(encoderGroupBox);
109 connect( encoderButton, SIGNAL( clicked( ) ),
this, SLOT(selectEncoderPathAction() ) );
113 QGroupBox *tempFolderGroupBox =
new QGroupBox(tr(
"Temporary folder path"),
this);
114 QVBoxLayout *tempFolderVGroupBoxLayout =
new QVBoxLayout(tempFolderGroupBox);
117 QWidget *tempFolderHBox =
new QWidget(tempFolderGroupBox);
118 QHBoxLayout *tempFolderHBoxLayout =
new QHBoxLayout(tempFolderHBox);
120 fTempFolderPath =
new QLineEdit(
"",tempFolderHBox);
122 QPushButton *tempButton =
new QPushButton(tr(
"..."),tempFolderHBox);
123 tempButton->setMaximumWidth (30);
125 fTempFolderStatus =
new QLabel(tempFolderGroupBox);
126 fTempFolderStatus->setWordWrap(
true);
127 tempFolderVGroupBoxLayout->setMargin(15);
128 fTempFolderStatus->setText(
"");
130 tempFolderHBoxLayout->addWidget(fTempFolderPath);
131 tempFolderHBoxLayout->addWidget(tempButton);
132 tempFolderVGroupBoxLayout->addWidget(tempFolderHBox);
133 tempFolderVGroupBoxLayout->addWidget(fTempFolderStatus);
135 tempFolderGroupBox->setLayout(tempFolderVGroupBoxLayout);
136 globalVLayout->addWidget(tempFolderGroupBox);
138 connect( tempButton, SIGNAL( clicked( ) ),
this, SLOT(selectTempPathAction() ) );
144 QGroupBox *saveFileGroupBox =
new QGroupBox(tr(
"Save as"),
this);
145 QVBoxLayout *saveFileVGroupBoxLayout =
new QVBoxLayout(saveFileGroupBox);
148 QWidget *saveFileHBox =
new QWidget(saveFileGroupBox);
149 QHBoxLayout *saveFileHBoxLayout =
new QHBoxLayout(saveFileHBox);
151 fSaveFileName =
new QLineEdit(
"G4Movie.mpeg",saveFileHBox);
153 QPushButton *saveButton =
new QPushButton(tr(
"..."),saveFileHBox);
154 saveButton->setMaximumWidth (30);
156 fSaveFileStatus =
new QLabel(saveFileGroupBox);
157 fSaveFileStatus->setWordWrap(
true);
158 saveFileVGroupBoxLayout->setMargin(15);
159 fSaveFileStatus->setText(
"");
161 saveFileHBoxLayout->addWidget(fSaveFileName);
162 saveFileHBoxLayout->addWidget(saveButton);
163 saveFileVGroupBoxLayout->addWidget(saveFileHBox);
164 saveFileVGroupBoxLayout->addWidget(fSaveFileStatus);
166 saveFileGroupBox->setLayout(saveFileVGroupBoxLayout);
167 globalVLayout->addWidget(saveFileGroupBox);
169 connect( saveButton, SIGNAL( clicked( ) ),
this, SLOT(selectSaveFileNameAction() ) );
175 QLabel *infoLabel =
new QLabel(
" Press SPACE to Start/Pause video recording \n Press RETURN to Stop video recording",
this);
178 QGroupBox *statusGroupBox =
new QGroupBox(tr(
"Status"),
this);
179 QVBoxLayout *statusVGroupBoxLayout =
new QVBoxLayout(statusGroupBox);
181 fRecordingStatus =
new QLabel(statusGroupBox);
182 statusVGroupBoxLayout->setMargin(15);
183 fRecordingStatus->setWordWrap(
true);
184 QPalette mypalette( fRecordingStatus->palette() );
185 mypalette.setColor( QPalette::Text, Qt::green);
186 fRecordingStatus->setPalette(mypalette);
188 fRecordingInfos =
new QLabel(statusGroupBox);
189 fRecordingInfos->setWordWrap(
true);
190 setRecordingInfos(
"");
192 statusVGroupBoxLayout->addWidget(fRecordingStatus);
193 statusVGroupBoxLayout->addWidget(fRecordingInfos);
195 statusGroupBox->setLayout(statusVGroupBoxLayout);
196 globalVLayout->addWidget(infoLabel);
197 globalVLayout->addWidget(statusGroupBox);
200 QWidget *buttonBox =
new QWidget(
this);
202 QHBoxLayout *buttonBoxLayout =
new QHBoxLayout(buttonBox);
204 QPushButton *buttonReset =
new QPushButton( tr(
"&Reset" ),buttonBox );
205 buttonReset->setAutoDefault(
TRUE );
206 buttonBoxLayout->addWidget(buttonReset);
208 fButtonStartPause =
new QPushButton( tr(
" &Start " ),buttonBox );
209 fButtonStartPause->setEnabled(
true);
210 fButtonStartPause->setAutoDefault(
TRUE );
211 buttonBoxLayout->addWidget(fButtonStartPause);
213 fButtonStopFinishClose =
new QPushButton( tr(
"&Stop" ),buttonBox );
214 fButtonStopFinishClose->setEnabled(
false);
215 fButtonStopFinishClose->setAutoDefault(
TRUE );
216 buttonBoxLayout->addWidget(fButtonStopFinishClose);
218 fButtonSave =
new QPushButton( tr(
"&Save" ),buttonBox );
219 fButtonSave->setEnabled(
false);
220 fButtonSave->setAutoDefault(
TRUE );
221 buttonBoxLayout->addWidget(fButtonSave);
223 QPushButton *buttonCancel =
new QPushButton( tr(
"&Cancel" ),buttonBox );
224 buttonCancel->setAutoDefault(
TRUE );
225 buttonBoxLayout->addWidget(buttonCancel);
227 buttonBox->setLayout(buttonBoxLayout);
228 globalVLayout->addWidget(buttonBox);
232 setLayout(globalVLayout);
235 connect( fButtonStartPause, SIGNAL( clicked() ), fParentViewer, SLOT( startPauseVideo() ) );
236 connect( buttonReset, SIGNAL( clicked() ),
this, SLOT( resetRecording() ) );
237 connect( buttonCancel, SIGNAL( clicked() ),
this, SLOT( reject() ) );
238 connect( fButtonStopFinishClose, SIGNAL( clicked() ),
this, SLOT( stopFinishClose() ) );
239 connect( fButtonSave, SIGNAL( clicked() ),
this, SLOT( save() ) );
242 setRecordingStatus(
"");
243 fEncoderPath->setText(fParentViewer->getEncoderPath());
244 fTempFolderPath->setText(fParentViewer->getTempFolderPath());
247 connect (fEncoderPath,SIGNAL(textChanged (
const QString&)),
this,SLOT(checkEncoderSwParameters()));
248 connect (fTempFolderPath,SIGNAL(textChanged (
const QString&)),
this,SLOT(checkTempFolderParameters()));
249 connect (fSaveFileName,SIGNAL(textChanged (
const QString&)),
this,SLOT(checkSaveFileNameParameters()));
251 connect (fEncoderPath,SIGNAL(editingFinished ()),
this,SLOT(checkEncoderSwParameters()));
252 connect (fTempFolderPath,SIGNAL(editingFinished ()),
this,SLOT(checkTempFolderParameters()));
253 connect (fSaveFileName,SIGNAL(editingFinished ()),
this,SLOT(checkSaveFileNameParameters()));
259G4OpenGLQtMovieDialog::~G4OpenGLQtMovieDialog()
263void G4OpenGLQtMovieDialog::selectEncoderPathAction()
265 QString nomFich = QFileDialog::getOpenFileName (
this,
266 "Select your encoder",
267 tr(
"Select your encoder ..."));
273 fEncoderPath->setText(nomFich);
274 checkEncoderSwParameters();
278void G4OpenGLQtMovieDialog::selectTempPathAction()
280 QString nomFich = QFileDialog::getExistingDirectory (
this,
281 "Select temporary folder",
282 tr(
"Select temporary folder ..."));
287 fTempFolderPath->setText(nomFich);
288 checkTempFolderParameters();
292void G4OpenGLQtMovieDialog::selectSaveFileNameAction()
294 QString nomFich = QFileDialog::getSaveFileName (
this,
296 tr(
"Select saved file ..."));
301 fSaveFileName->setText(nomFich);
302 checkSaveFileNameParameters();
306void G4OpenGLQtMovieDialog::stopFinishClose() {
307 fParentViewer->stopVideo();
310void G4OpenGLQtMovieDialog::save() {
311 if (((fParentViewer->isPaused()) || fParentViewer->isRecording() || fParentViewer->isStopped())) {
312 fParentViewer->saveVideo();
320bool G4OpenGLQtMovieDialog::checkEncoderSwParameters() {
323 QPalette mypalette( fEncoderPath->palette() );
325 QString temp = fParentViewer->setEncoderPath(fEncoderPath->text());
326 setRecordingInfos(
"");
327 fEncoderStatus->setText(temp);
329 mypalette.setColor( QPalette::Base, Qt::red);
330 if (fParentViewer->isReadyToEncode()) {
331 setRecordingInfos(
"No valid encode defined, screen capture had been saved in the temp folder in ppm format.\nPlease define a encoder and clic on Apply button");
335 mypalette.setColor( QPalette::Base, Qt::white);
336 fEncoderPath->setText(fParentViewer->getEncoderPath());
338 fEncoderPath->setPalette(mypalette);
347bool G4OpenGLQtMovieDialog::checkTempFolderParameters() {
350 QPalette mypalette( fTempFolderPath->palette() );
352 QString temp = fParentViewer->setTempFolderPath(fTempFolderPath->text());
353 fTempFolderStatus->setText(temp);
355 mypalette.setColor( QPalette::Base, Qt::red);
358 mypalette.setColor( QPalette::Base, Qt::white);
359 fTempFolderPath->setText(fParentViewer->getTempFolderPath());
361 fTempFolderPath->setPalette(mypalette);
370bool G4OpenGLQtMovieDialog::checkSaveFileNameParameters() {
373 QPalette mypalette( fSaveFileName->palette() );
375 QString temp = fParentViewer->setSaveFileName(fSaveFileName->text());
376 fSaveFileStatus->setText(temp);
378 mypalette.setColor( QPalette::Base, Qt::red);
381 mypalette.setColor( QPalette::Base, Qt::white);
382 fSaveFileName->setText(fParentViewer->getSaveFileName());
384 fSaveFileName->setPalette(mypalette);
389void G4OpenGLQtMovieDialog::resetRecording() {
390 fParentViewer->resetRecording();
394void G4OpenGLQtMovieDialog::setRecordingStatus(QString txt) {
395 fRecordingStatus->setText(txt);
396 if (fParentViewer->isWaiting()) {
397 fButtonStartPause->setText(
" &Start ");
398 fButtonStartPause->setEnabled(
true);
399 fButtonStopFinishClose->setEnabled(
false);
400 fButtonSave->setEnabled(
false);
402 }
else if (fParentViewer->isPaused()) {
404 fButtonStartPause->setText(
" &Continue ");
405 fButtonStartPause->setEnabled(
true);
406 fButtonStopFinishClose->setEnabled(
true);
407 fButtonSave->setEnabled(
false);
409 }
else if (fParentViewer->isRecording()) {
411 fButtonStartPause->setText(
" &Pause ");
412 fButtonStartPause->setEnabled(
true);
413 fButtonStopFinishClose->setEnabled(
true);
414 fButtonSave->setEnabled(
false);
416 }
else if (fParentViewer->isBadOutput()) {
418 fButtonStartPause->setText(
" &Start ");
419 fButtonStartPause->setEnabled(
true);
420 fButtonStopFinishClose->setEnabled(
false);
421 fButtonSave->setEnabled(
false);
423 }
else if (fParentViewer->isBadTmp()) {
425 fButtonStartPause->setText(
" &Start ");
426 fButtonStartPause->setEnabled(
false);
427 fButtonStopFinishClose->setEnabled(
false);
428 fButtonSave->setEnabled(
false);
430 }
else if (fParentViewer->isBadEncoder()) {
432 fButtonStartPause->setText(
" &Start ");
433 fButtonStartPause->setEnabled(
true);
434 fButtonStopFinishClose->setEnabled(
false);
435 fButtonSave->setEnabled(
false);
437 }
else if (fParentViewer->isSuccess()) {
439 fButtonStartPause->setText(
" &Start ");
440 fButtonStartPause->setEnabled(
false);
441 fButtonStopFinishClose->setEnabled(
false);
442 fButtonSave->setEnabled(
false);
444 }
else if (fParentViewer->isFailed()) {
446 fButtonStartPause->setText(
" &Start ");
447 fButtonStartPause->setEnabled(
false);
448 fButtonStopFinishClose->setEnabled(
false);
449 fButtonSave->setEnabled(
false);
451 }
else if (fParentViewer->isStopped()) {
453 fButtonStartPause->setText(
" &Start ");
454 fButtonStartPause->setEnabled(
false);
455 fButtonStopFinishClose->setEnabled(
false);
456 fButtonSave->setEnabled(
true);
461void G4OpenGLQtMovieDialog::setRecordingInfos(QString txt) {
462 fRecordingInfos->setText(txt);
466void G4OpenGLQtMovieDialog::enabledApplyButton() {
467 fButtonStartPause->setEnabled(
true);