diff -r 1dbf3f4340e0 -r 0e55228e1303 QTfrontend/ui/page/pagevideos.cpp --- a/QTfrontend/ui/page/pagevideos.cpp Fri Jul 06 13:22:33 2012 +0400 +++ b/QTfrontend/ui/page/pagevideos.cpp Fri Jul 06 19:15:44 2012 +0400 @@ -44,6 +44,7 @@ #include "libav_iteraction.h" #include "gameuiconfig.h" #include "recorder.h" +#include "ask_quit.h" const int ThumbnailSize = 400; @@ -70,6 +71,7 @@ HWRecorder * pRecorder; // non NULL if file is being encoded bool seen; // used when updating directory float lastSizeUpdate; + float progress; bool ready() { return !pRecorder; } @@ -84,6 +86,7 @@ this->name = name; pRecorder = NULL; lastSizeUpdate = 0; + progress = 0; } VideoItem::~VideoItem() @@ -300,6 +303,7 @@ config(0) { nameChangedFromCode = false; + numRecorders = 0; initPage(); } @@ -496,6 +500,8 @@ connect(pRecorder, SIGNAL(onProgress(float)), this, SLOT(updateProgress(float))); connect(pRecorder, SIGNAL(encodingFinished(bool)), this, SLOT(encodingFinished(bool))); filesTable->setCellWidget(row, vcProgress, progressBar); + + numRecorders++; } void PageVideos::updateProgress(float value) @@ -515,10 +521,13 @@ QProgressBar * progressBar = (QProgressBar*)filesTable->cellWidget(row, vcProgress); progressBar->setValue(value*10000); progressBar->setFormat(QString("%1%").arg(value*100, 0, 'f', 2)); + item->progress = value; } void PageVideos::encodingFinished(bool success) { + numRecorders--; + HWRecorder * pRecorder = (HWRecorder*)sender(); VideoItem * item = (VideoItem*)pRecorder->item; int row = filesTable->row(item); @@ -583,6 +592,7 @@ setName(item, oldName); } } + updateDescription(); } void PageVideos::setName(VideoItem * item, const QString & newName) @@ -616,8 +626,6 @@ item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); filesTable->setItem(row, vcProgress, item); - // filesTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - return row; } @@ -763,3 +771,32 @@ { QDesktopServices::openUrl(QUrl("file:///"+cfgdir->absolutePath() + "/Videos")); } + +bool PageVideos::tryQuit(HWForm * form) +{ + if (numRecorders == 0) + return true; + + // ask user what to do - abort or wait + HWAskQuitDialog * askd = new HWAskQuitDialog(this, form); + bool answer = askd->exec(); + delete askd; + return answer; +} + +// returns multi-line string with list of videos in progress +QString PageVideos::getVideosInProgress() +{ + QString list = ""; + int count = filesTable->rowCount(); + for (int i = 0; i < count; i++) + { + VideoItem * item = nameItem(i); + float progress = 100*item->progress; + if (progress > 99.99) + progress = 99.99; // displaying 100% may be confusing + if (!item->ready()) + list += item->name + " (" + QString::number(progress, 'f', 2) + "%)\n"; + } + return list; +}