30 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
36 #include <qpushbutton.h>
39 #include <qgroupbox.h>
41 #include <qlineedit.h>
42 #include <qfiledialog.h>
63 G4OpenGLQtMovieDialog::G4OpenGLQtMovieDialog(
64 G4OpenGLQtViewer* parentViewer,
68 fParentViewer(parentViewer)
71 setWindowTitle( tr(
" Save as movie" ));
75 QVBoxLayout* globalVLayout =
new QVBoxLayout(
this);
76 globalVLayout->setMargin(10);
77 globalVLayout->setSpacing(10);
80 QGroupBox *encoderGroupBox =
new QGroupBox(tr(
"Encoder path"),
this);
81 QVBoxLayout *encoderVGroupBoxLayout =
new QVBoxLayout(encoderGroupBox);
84 QWidget *encoderHBox =
new QWidget(encoderGroupBox);
85 QHBoxLayout *encoderHBoxLayout =
new QHBoxLayout(encoderHBox);
86 fEncoderPath =
new QLineEdit(
"",encoderHBox);
88 QPushButton *encoderButton =
new QPushButton(tr(
"..."),encoderHBox);
89 encoderButton->setMaximumWidth (30);
91 fEncoderStatus =
new QLabel(encoderGroupBox);
93 fEncoderStatus->setWordWrap(
true);
94 encoderVGroupBoxLayout->setMargin(15);
96 fEncoderStatus->setText(
"");
98 encoderHBoxLayout->addWidget(fEncoderPath);
99 encoderHBoxLayout->addWidget(encoderButton);
100 encoderVGroupBoxLayout->addWidget(encoderHBox);
101 encoderVGroupBoxLayout->addWidget(fEncoderStatus);
103 encoderGroupBox->setLayout(encoderVGroupBoxLayout);
104 globalVLayout->addWidget(encoderGroupBox);
106 connect( encoderButton, SIGNAL( clicked( ) ),
this, SLOT(selectEncoderPathAction() ) );
110 QGroupBox *tempFolderGroupBox =
new QGroupBox(tr(
"Temporary folder path"),
this);
111 QVBoxLayout *tempFolderVGroupBoxLayout =
new QVBoxLayout(tempFolderGroupBox);
114 QWidget *tempFolderHBox =
new QWidget(tempFolderGroupBox);
115 QHBoxLayout *tempFolderHBoxLayout =
new QHBoxLayout(tempFolderHBox);
117 fTempFolderPath =
new QLineEdit(
"",tempFolderHBox);
119 QPushButton *tempButton =
new QPushButton(tr(
"..."),tempFolderHBox);
120 tempButton->setMaximumWidth (30);
122 fTempFolderStatus =
new QLabel(tempFolderGroupBox);
123 fTempFolderStatus->setWordWrap(
true);
124 tempFolderVGroupBoxLayout->setMargin(15);
125 fTempFolderStatus->setText(
"");
127 tempFolderHBoxLayout->addWidget(fTempFolderPath);
128 tempFolderHBoxLayout->addWidget(tempButton);
129 tempFolderVGroupBoxLayout->addWidget(tempFolderHBox);
130 tempFolderVGroupBoxLayout->addWidget(fTempFolderStatus);
132 tempFolderGroupBox->setLayout(tempFolderVGroupBoxLayout);
133 globalVLayout->addWidget(tempFolderGroupBox);
135 connect( tempButton, SIGNAL( clicked( ) ),
this, SLOT(selectTempPathAction() ) );
141 QGroupBox *saveFileGroupBox =
new QGroupBox(tr(
"Save as"),
this);
142 QVBoxLayout *saveFileVGroupBoxLayout =
new QVBoxLayout(saveFileGroupBox);
145 QWidget *saveFileHBox =
new QWidget(saveFileGroupBox);
146 QHBoxLayout *saveFileHBoxLayout =
new QHBoxLayout(saveFileHBox);
148 fSaveFileName =
new QLineEdit(
"G4Movie.mpeg",saveFileHBox);
150 QPushButton *saveButton =
new QPushButton(tr(
"..."),saveFileHBox);
151 saveButton->setMaximumWidth (30);
153 fSaveFileStatus =
new QLabel(saveFileGroupBox);
154 fSaveFileStatus->setWordWrap(
true);
155 saveFileVGroupBoxLayout->setMargin(15);
156 fSaveFileStatus->setText(
"");
158 saveFileHBoxLayout->addWidget(fSaveFileName);
159 saveFileHBoxLayout->addWidget(saveButton);
160 saveFileVGroupBoxLayout->addWidget(saveFileHBox);
161 saveFileVGroupBoxLayout->addWidget(fSaveFileStatus);
163 saveFileGroupBox->setLayout(saveFileVGroupBoxLayout);
164 globalVLayout->addWidget(saveFileGroupBox);
166 connect( saveButton, SIGNAL( clicked( ) ),
this, SLOT(selectSaveFileNameAction() ) );
172 QLabel *infoLabel =
new QLabel(
" Press SPACE to Start/Pause video recording \n Press RETURN to Stop video recording",
this);
175 QGroupBox *statusGroupBox =
new QGroupBox(tr(
"Status"),
this);
176 QVBoxLayout *statusVGroupBoxLayout =
new QVBoxLayout(statusGroupBox);
178 fRecordingStatus =
new QLabel(statusGroupBox);
179 statusVGroupBoxLayout->setMargin(15);
180 fRecordingStatus->setWordWrap(
true);
181 QPalette mypalette( fRecordingStatus->palette() );
182 mypalette.setColor( QPalette::Text, Qt::green);
183 fRecordingStatus->setPalette(mypalette);
185 fRecordingInfos =
new QLabel(statusGroupBox);
186 fRecordingInfos->setWordWrap(
true);
187 setRecordingInfos(
"");
189 statusVGroupBoxLayout->addWidget(fRecordingStatus);
190 statusVGroupBoxLayout->addWidget(fRecordingInfos);
192 statusGroupBox->setLayout(statusVGroupBoxLayout);
193 globalVLayout->addWidget(infoLabel);
194 globalVLayout->addWidget(statusGroupBox);
197 QWidget *buttonBox =
new QWidget(
this);
199 QHBoxLayout *buttonBoxLayout =
new QHBoxLayout(buttonBox);
201 QPushButton *buttonReset =
new QPushButton( tr(
"&Reset" ),buttonBox );
202 buttonReset->setAutoDefault(
TRUE );
203 buttonBoxLayout->addWidget(buttonReset);
205 fButtonStartPause =
new QPushButton( tr(
" &Start " ),buttonBox );
206 fButtonStartPause->setEnabled(
true);
207 fButtonStartPause->setAutoDefault(
TRUE );
208 buttonBoxLayout->addWidget(fButtonStartPause);
210 fButtonStopFinishClose =
new QPushButton( tr(
"&Stop" ),buttonBox );
211 fButtonStopFinishClose->setEnabled(
false);
212 fButtonStopFinishClose->setAutoDefault(
TRUE );
213 buttonBoxLayout->addWidget(fButtonStopFinishClose);
215 fButtonSave =
new QPushButton( tr(
"&Save" ),buttonBox );
216 fButtonSave->setEnabled(
false);
217 fButtonSave->setAutoDefault(
TRUE );
218 buttonBoxLayout->addWidget(fButtonSave);
220 QPushButton *buttonCancel =
new QPushButton( tr(
"&Cancel" ),buttonBox );
221 buttonCancel->setAutoDefault(
TRUE );
222 buttonBoxLayout->addWidget(buttonCancel);
224 buttonBox->setLayout(buttonBoxLayout);
225 globalVLayout->addWidget(buttonBox);
229 setLayout(globalVLayout);
232 connect( fButtonStartPause, SIGNAL( clicked() ), fParentViewer, SLOT( startPauseVideo() ) );
233 connect( buttonReset, SIGNAL( clicked() ),
this, SLOT( resetRecording() ) );
234 connect( buttonCancel, SIGNAL( clicked() ),
this, SLOT( reject() ) );
235 connect( fButtonStopFinishClose, SIGNAL( clicked() ),
this, SLOT( stopFinishClose() ) );
236 connect( fButtonSave, SIGNAL( clicked() ),
this, SLOT( save() ) );
239 setRecordingStatus(
"");
240 fEncoderPath->setText(fParentViewer->getEncoderPath());
241 fTempFolderPath->setText(fParentViewer->getTempFolderPath());
244 connect (fEncoderPath,SIGNAL(textChanged (
const QString&)),
this,SLOT(checkEncoderSwParameters()));
245 connect (fTempFolderPath,SIGNAL(textChanged (
const QString&)),
this,SLOT(checkTempFolderParameters()));
246 connect (fSaveFileName,SIGNAL(textChanged (
const QString&)),
this,SLOT(checkSaveFileNameParameters()));
248 connect (fEncoderPath,SIGNAL(editingFinished ()),
this,SLOT(checkEncoderSwParameters()));
249 connect (fTempFolderPath,SIGNAL(editingFinished ()),
this,SLOT(checkTempFolderParameters()));
250 connect (fSaveFileName,SIGNAL(editingFinished ()),
this,SLOT(checkSaveFileNameParameters()));
256 G4OpenGLQtMovieDialog::~G4OpenGLQtMovieDialog()
260 void G4OpenGLQtMovieDialog::selectEncoderPathAction()
262 QString nomFich = QFileDialog::getOpenFileName (
this,
263 "Select your encoder",
264 tr(
"Select your encoder ..."));
270 fEncoderPath->setText(nomFich);
271 checkEncoderSwParameters();
275 void G4OpenGLQtMovieDialog::selectTempPathAction()
277 QString nomFich = QFileDialog::getExistingDirectory (
this,
278 "Select temporary folder",
279 tr(
"Select temporary folder ..."));
284 fTempFolderPath->setText(nomFich);
285 checkTempFolderParameters();
289 void G4OpenGLQtMovieDialog::selectSaveFileNameAction()
291 QString nomFich = QFileDialog::getSaveFileName (
this,
293 tr(
"Select saved file ..."));
298 fSaveFileName->setText(nomFich);
299 checkSaveFileNameParameters();
303 void G4OpenGLQtMovieDialog::stopFinishClose() {
304 fParentViewer->stopVideo();
307 void G4OpenGLQtMovieDialog::save() {
308 if (((fParentViewer->isPaused()) || fParentViewer->isRecording() || fParentViewer->isStopped())) {
309 fParentViewer->saveVideo();
317 bool G4OpenGLQtMovieDialog::checkEncoderSwParameters() {
320 QPalette mypalette( fEncoderPath->palette() );
322 QString temp = fParentViewer->setEncoderPath(fEncoderPath->text());
323 setRecordingInfos(
"");
324 fEncoderStatus->setText(temp);
326 mypalette.setColor( QPalette::Base, Qt::red);
327 if (fParentViewer->isReadyToEncode()) {
328 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");
332 mypalette.setColor( QPalette::Base, Qt::white);
333 fEncoderPath->setText(fParentViewer->getEncoderPath());
335 fEncoderPath->setPalette(mypalette);
344 bool G4OpenGLQtMovieDialog::checkTempFolderParameters() {
347 QPalette mypalette( fTempFolderPath->palette() );
349 QString temp = fParentViewer->setTempFolderPath(fTempFolderPath->text());
350 fTempFolderStatus->setText(temp);
352 mypalette.setColor( QPalette::Base, Qt::red);
355 mypalette.setColor( QPalette::Base, Qt::white);
356 fTempFolderPath->setText(fParentViewer->getTempFolderPath());
358 fTempFolderPath->setPalette(mypalette);
367 bool G4OpenGLQtMovieDialog::checkSaveFileNameParameters() {
370 QPalette mypalette( fSaveFileName->palette() );
372 QString temp = fParentViewer->setSaveFileName(fSaveFileName->text());
373 fSaveFileStatus->setText(temp);
375 mypalette.setColor( QPalette::Base, Qt::red);
378 mypalette.setColor( QPalette::Base, Qt::white);
379 fSaveFileName->setText(fParentViewer->getSaveFileName());
381 fSaveFileName->setPalette(mypalette);
386 void G4OpenGLQtMovieDialog::resetRecording() {
387 fParentViewer->resetRecording();
391 void G4OpenGLQtMovieDialog::setRecordingStatus(QString txt) {
392 fRecordingStatus->setText(txt);
393 if (fParentViewer->isWaiting()) {
394 fButtonStartPause->setText(
" &Start ");
395 fButtonStartPause->setEnabled(
true);
396 fButtonStopFinishClose->setEnabled(
false);
397 fButtonSave->setEnabled(
false);
399 }
else if (fParentViewer->isPaused()) {
401 fButtonStartPause->setText(
" &Continue ");
402 fButtonStartPause->setEnabled(
true);
403 fButtonStopFinishClose->setEnabled(
true);
404 fButtonSave->setEnabled(
false);
406 }
else if (fParentViewer->isRecording()) {
408 fButtonStartPause->setText(
" &Pause ");
409 fButtonStartPause->setEnabled(
true);
410 fButtonStopFinishClose->setEnabled(
true);
411 fButtonSave->setEnabled(
false);
413 }
else if (fParentViewer->isBadOutput()) {
415 fButtonStartPause->setText(
" &Start ");
416 fButtonStartPause->setEnabled(
true);
417 fButtonStopFinishClose->setEnabled(
false);
418 fButtonSave->setEnabled(
false);
420 }
else if (fParentViewer->isBadTmp()) {
422 fButtonStartPause->setText(
" &Start ");
423 fButtonStartPause->setEnabled(
false);
424 fButtonStopFinishClose->setEnabled(
false);
425 fButtonSave->setEnabled(
false);
427 }
else if (fParentViewer->isBadEncoder()) {
429 fButtonStartPause->setText(
" &Start ");
430 fButtonStartPause->setEnabled(
true);
431 fButtonStopFinishClose->setEnabled(
false);
432 fButtonSave->setEnabled(
false);
434 }
else if (fParentViewer->isSuccess()) {
436 fButtonStartPause->setText(
" &Start ");
437 fButtonStartPause->setEnabled(
false);
438 fButtonStopFinishClose->setEnabled(
false);
439 fButtonSave->setEnabled(
false);
441 }
else if (fParentViewer->isFailed()) {
443 fButtonStartPause->setText(
" &Start ");
444 fButtonStartPause->setEnabled(
false);
445 fButtonStopFinishClose->setEnabled(
false);
446 fButtonSave->setEnabled(
false);
448 }
else if (fParentViewer->isStopped()) {
450 fButtonStartPause->setText(
" &Start ");
451 fButtonStartPause->setEnabled(
false);
452 fButtonStopFinishClose->setEnabled(
false);
453 fButtonSave->setEnabled(
true);
458 void G4OpenGLQtMovieDialog::setRecordingInfos(QString txt) {
459 fRecordingInfos->setText(txt);
463 void G4OpenGLQtMovieDialog::enabledApplyButton() {
464 fButtonStartPause->setEnabled(
true);