299 connect(filesTable, SIGNAL(cellChanged(int,int)), this, SLOT(cellChanged(int, int))); |
299 connect(filesTable, SIGNAL(cellChanged(int,int)), this, SLOT(cellChanged(int, int))); |
300 connect(filesTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentCellChanged(int,int,int,int))); |
300 connect(filesTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentCellChanged(int,int,int,int))); |
301 connect(btnPlay, SIGNAL(clicked()), this, SLOT(playSelectedFile())); |
301 connect(btnPlay, SIGNAL(clicked()), this, SLOT(playSelectedFile())); |
302 connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteSelectedFiles())); |
302 connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteSelectedFiles())); |
303 connect(btnOpenDir, SIGNAL(clicked()), this, SLOT(openVideosDirectory())); |
303 connect(btnOpenDir, SIGNAL(clicked()), this, SLOT(openVideosDirectory())); |
|
304 } |
|
305 |
|
306 PageVideos::PageVideos(QWidget* parent) : AbstractPage(parent), |
|
307 config(0) |
|
308 { |
|
309 nameChangedFromCode = false; |
|
310 numRecorders = 0; |
|
311 initPage(); |
|
312 } |
|
313 |
|
314 void PageVideos::init(GameUIConfig * config) |
|
315 { |
|
316 this->config = config; |
304 |
317 |
305 QString path = cfgdir->absolutePath() + "/Videos"; |
318 QString path = cfgdir->absolutePath() + "/Videos"; |
306 QFileSystemWatcher * pWatcher = new QFileSystemWatcher(this); |
319 QFileSystemWatcher * pWatcher = new QFileSystemWatcher(this); |
307 pWatcher->addPath(path); |
320 pWatcher->addPath(path); |
308 connect(pWatcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(updateFileList(const QString &))); |
321 connect(pWatcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(updateFileList(const QString &))); |
309 updateFileList(path); |
322 updateFileList(path); |
310 } |
323 |
311 |
324 startEncoding(); // this is for videos recorded from demos which were executed directly (without frontend) |
312 PageVideos::PageVideos(QWidget* parent) : AbstractPage(parent), |
|
313 config(0) |
|
314 { |
|
315 nameChangedFromCode = false; |
|
316 numRecorders = 0; |
|
317 initPage(); |
|
318 } |
325 } |
319 |
326 |
320 // user changed file format, we need to update list of codecs |
327 // user changed file format, we need to update list of codecs |
321 void PageVideos::changeAVFormat(int index) |
328 void PageVideos::changeAVFormat(int index) |
322 { |
329 { |
842 if (!item->ready()) |
849 if (!item->ready()) |
843 list += item->name + " (" + QString::number(progress, 'f', 2) + "%)\n"; |
850 list += item->name + " (" + QString::number(progress, 'f', 2) + "%)\n"; |
844 } |
851 } |
845 return list; |
852 return list; |
846 } |
853 } |
|
854 |
|
855 void PageVideos::startEncoding(const QByteArray & record) |
|
856 { |
|
857 QDir videoTempDir(cfgdir->absolutePath() + "/VideoTemp/"); |
|
858 QStringList files = videoTempDir.entryList(QStringList("*.txtout"), QDir::Files); |
|
859 foreach (const QString & str, files) |
|
860 { |
|
861 QString prefix = str; |
|
862 prefix.chop(7); // remove ".txtout" |
|
863 videoTempDir.rename(prefix + ".txtout", prefix + ".txtin"); // rename this file to not open it twice |
|
864 |
|
865 HWRecorder* pRecorder = new HWRecorder(config, prefix); |
|
866 |
|
867 if (!record.isEmpty()) |
|
868 pRecorder->EncodeVideo(record); |
|
869 else |
|
870 { |
|
871 // this is for videos recorded from demos which were executed directly (without frontend) |
|
872 QFile demofile(videoTempDir.absoluteFilePath(prefix + ".hwd")); |
|
873 if (!demofile.open(QIODevice::ReadOnly)) |
|
874 continue; |
|
875 QByteArray demo = demofile.readAll(); |
|
876 if (demo.isEmpty()) |
|
877 continue; |
|
878 pRecorder->EncodeVideo(demo); |
|
879 } |
|
880 addRecorder(pRecorder); |
|
881 } |
|
882 } |