Google Code-in: Move video preferences in settings tab
Moves the video recording preferences out of the video recording page into their own tab in the settings page.
https://google-melange.appspot.com/gci/task/view/google/gci2012/7968230
--- a/QTfrontend/gameuiconfig.cpp Fri Nov 30 20:00:53 2012 -0500
+++ b/QTfrontend/gameuiconfig.cpp Sat Dec 01 21:24:25 2012 -0500
@@ -139,26 +139,26 @@
void GameUIConfig::reloadVideosValues(void)
{
- Form->ui.pageVideos->framerateBox->setValue(value("videorec/fps",25).toUInt());
- Form->ui.pageVideos->bitrateBox->setValue(value("videorec/bitrate",400).toUInt());
+ Form->ui.pageOptions->framerateBox->setValue(value("videorec/fps",25).toUInt());
+ Form->ui.pageOptions->bitrateBox->setValue(value("videorec/bitrate",400).toUInt());
bool useGameRes = value("videorec/usegameres",true).toBool();
if (useGameRes)
{
QRect res = vid_Resolution();
- Form->ui.pageVideos->widthEdit->setText(QString::number(res.width()));
- Form->ui.pageVideos->heightEdit->setText(QString::number(res.height()));
+ Form->ui.pageOptions->widthEdit->setText(QString::number(res.width()));
+ Form->ui.pageOptions->heightEdit->setText(QString::number(res.height()));
}
else
{
- Form->ui.pageVideos->widthEdit->setText(value("videorec/width","800").toString());
- Form->ui.pageVideos->heightEdit->setText(value("videorec/height","600").toString());
+ Form->ui.pageOptions->widthEdit->setText(value("videorec/width","800").toString());
+ Form->ui.pageOptions->heightEdit->setText(value("videorec/height","600").toString());
}
- Form->ui.pageVideos->checkUseGameRes->setChecked(useGameRes);
- Form->ui.pageVideos->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
- if (!Form->ui.pageVideos->tryCodecs(value("videorec/format","no").toString(),
+ Form->ui.pageOptions->checkUseGameRes->setChecked(useGameRes);
+ Form->ui.pageOptions->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
+ if (!Form->ui.pageOptions->tryCodecs(value("videorec/format","no").toString(),
value("videorec/videocodec","no").toString(),
value("videorec/audiocodec","no").toString()))
- Form->ui.pageVideos->setDefaultCodecs();
+ Form->ui.pageOptions->setDefaultCodecs();
}
QStringList GameUIConfig::GetTeamsList()
@@ -283,7 +283,7 @@
setValue("videorec/bitrate", rec_Bitrate());
setValue("videorec/width", res.width());
setValue("videorec/height", res.height());
- setValue("videorec/usegameres", Form->ui.pageVideos->checkUseGameRes->isChecked());
+ setValue("videorec/usegameres", Form->ui.pageOptions->checkUseGameRes->isChecked());
setValue("videorec/audio", recordAudio());
Form->gameSettings->sync();
@@ -487,40 +487,40 @@
QString GameUIConfig::AVFormat()
{
- return Form->ui.pageVideos->format();
+ return Form->ui.pageOptions->format();
}
QString GameUIConfig::videoCodec()
{
- return Form->ui.pageVideos->videoCodec();
+ return Form->ui.pageOptions->videoCodec();
}
QString GameUIConfig::audioCodec()
{
- return Form->ui.pageVideos->audioCodec();
+ return Form->ui.pageOptions->audioCodec();
}
QRect GameUIConfig::rec_Resolution()
{
- if (Form->ui.pageVideos->checkUseGameRes->isChecked())
+ if (Form->ui.pageOptions->checkUseGameRes->isChecked())
return vid_Resolution();
QRect res(0,0,0,0);
- res.setWidth(Form->ui.pageVideos->widthEdit->text().toUInt());
- res.setHeight(Form->ui.pageVideos->heightEdit->text().toUInt());
+ res.setWidth(Form->ui.pageOptions->widthEdit->text().toUInt());
+ res.setHeight(Form->ui.pageOptions->heightEdit->text().toUInt());
return res;
}
int GameUIConfig::rec_Framerate()
{
- return Form->ui.pageVideos->framerateBox->value();
+ return Form->ui.pageOptions->framerateBox->value();
}
int GameUIConfig::rec_Bitrate()
{
- return Form->ui.pageVideos->bitrateBox->value();
+ return Form->ui.pageOptions->bitrateBox->value();
}
bool GameUIConfig::recordAudio()
{
- return Form->ui.pageVideos->checkRecordAudio->isChecked();
+ return Form->ui.pageOptions->checkRecordAudio->isChecked();
}
--- a/QTfrontend/hwform.cpp Fri Nov 30 20:00:53 2012 -0500
+++ b/QTfrontend/hwform.cpp Sat Dec 01 21:24:25 2012 -0500
@@ -141,7 +141,9 @@
config = new GameUIConfig(this, "physfs://hedgewars.ini");
- ui.pageVideos->init(config);
+#ifdef VIDEOREC
+ ui.pageOptions->setConfig(config);
+#endif
#ifdef __APPLE__
panel = new M3Panel;
--- a/QTfrontend/ui/page/pageoptions.cpp Fri Nov 30 20:00:53 2012 -0500
+++ b/QTfrontend/ui/page/pageoptions.cpp Sat Dec 01 21:24:25 2012 -0500
@@ -33,10 +33,12 @@
#include <QStandardItemModel>
#include "pageoptions.h"
+#include "gameuiconfig.h"
#include "hwconsts.h"
#include "fpsedit.h"
#include "igbox.h"
#include "DataManager.h"
+#include "LibavInteraction.h"
// TODO cleanup
QLayout * PageOptions::bodyLayoutDefinition()
@@ -50,6 +52,11 @@
tabs->addTab(page1, tr("General"));
tabs->addTab(page2, tr("Advanced"));
+#ifdef VIDEOREC
+ QWidget * page3 = new QWidget(this);
+ tabs->addTab(page3, tr("Video Recording"));
+#endif
+
{ // page 1
QGridLayout * page1Layout = new QGridLayout(page1);
//gbTBLayout->setMargin(0);
@@ -477,6 +484,119 @@
page2Layout->addWidget(new QWidget(this), 2, 0);
}
+#ifdef VIDEOREC
+ { // page 3
+ QGridLayout * page3Layout = new QGridLayout(page3);
+
+ IconedGroupBox* pOptionsGroup = new IconedGroupBox(this);
+ pOptionsGroup->setIcon(QIcon(":/res/Settings.png")); // FIXME
+ pOptionsGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ pOptionsGroup->setTitle(QGroupBox::tr("Video recording options"));
+ QGridLayout * pOptLayout = new QGridLayout(pOptionsGroup);
+
+ // label for format
+ QLabel *labelFormat = new QLabel(pOptionsGroup);
+ labelFormat->setText(QLabel::tr("Format"));
+ pOptLayout->addWidget(labelFormat, 0, 0);
+
+ // list of supported formats
+ comboAVFormats = new QComboBox(pOptionsGroup);
+ pOptLayout->addWidget(comboAVFormats, 0, 1, 1, 4);
+ LibavInteraction::instance().fillFormats(comboAVFormats);
+
+ // separator
+ QFrame * hr = new QFrame(pOptionsGroup);
+ hr->setFrameStyle(QFrame::HLine);
+ hr->setLineWidth(3);
+ hr->setFixedHeight(10);
+ pOptLayout->addWidget(hr, 1, 0, 1, 5);
+
+ // label for audio codec
+ QLabel *labelACodec = new QLabel(pOptionsGroup);
+ labelACodec->setText(QLabel::tr("Audio codec"));
+ pOptLayout->addWidget(labelACodec, 2, 0);
+
+ // list of supported audio codecs
+ comboAudioCodecs = new QComboBox(pOptionsGroup);
+ pOptLayout->addWidget(comboAudioCodecs, 2, 1, 1, 3);
+
+ // checkbox 'record audio'
+ checkRecordAudio = new QCheckBox(pOptionsGroup);
+ checkRecordAudio->setText(QCheckBox::tr("Record audio"));
+ pOptLayout->addWidget(checkRecordAudio, 2, 4);
+
+ // separator
+ hr = new QFrame(pOptionsGroup);
+ hr->setFrameStyle(QFrame::HLine);
+ hr->setLineWidth(3);
+ hr->setFixedHeight(10);
+ pOptLayout->addWidget(hr, 3, 0, 1, 5);
+
+ // label for video codec
+ QLabel *labelVCodec = new QLabel(pOptionsGroup);
+ labelVCodec->setText(QLabel::tr("Video codec"));
+ pOptLayout->addWidget(labelVCodec, 4, 0);
+
+ // list of supported video codecs
+ comboVideoCodecs = new QComboBox(pOptionsGroup);
+ pOptLayout->addWidget(comboVideoCodecs, 4, 1, 1, 4);
+
+ // label for resolution
+ QLabel *labelRes = new QLabel(pOptionsGroup);
+ labelRes->setText(QLabel::tr("Resolution"));
+ pOptLayout->addWidget(labelRes, 5, 0);
+
+ // width
+ widthEdit = new QLineEdit(pOptionsGroup);
+ widthEdit->setValidator(new QIntValidator(this));
+ pOptLayout->addWidget(widthEdit, 5, 1);
+
+ // x
+ QLabel *labelX = new QLabel(pOptionsGroup);
+ labelX->setText("X");
+ pOptLayout->addWidget(labelX, 5, 2);
+
+ // height
+ heightEdit = new QLineEdit(pOptionsGroup);
+ heightEdit->setValidator(new QIntValidator(pOptionsGroup));
+ pOptLayout->addWidget(heightEdit, 5, 3);
+
+ // checkbox 'use game resolution'
+ checkUseGameRes = new QCheckBox(pOptionsGroup);
+ checkUseGameRes->setText(QCheckBox::tr("Use game resolution"));
+ pOptLayout->addWidget(checkUseGameRes, 5, 4);
+
+ // label for framerate
+ QLabel *labelFramerate = new QLabel(pOptionsGroup);
+ labelFramerate->setText(QLabel::tr("Framerate"));
+ pOptLayout->addWidget(labelFramerate, 6, 0);
+
+ // framerate
+ framerateBox = new QSpinBox(pOptionsGroup);
+ framerateBox->setRange(1, 200);
+ framerateBox->setSingleStep(1);
+ pOptLayout->addWidget(framerateBox, 6, 1);
+
+ // label for Bitrate
+ QLabel *labelBitrate = new QLabel(pOptionsGroup);
+ labelBitrate->setText(QLabel::tr("Bitrate (Kbps)"));
+ pOptLayout->addWidget(labelBitrate, 6, 2);
+
+ // bitrate
+ bitrateBox = new QSpinBox(pOptionsGroup);
+ bitrateBox->setRange(100, 5000);
+ bitrateBox->setSingleStep(100);
+ pOptLayout->addWidget(bitrateBox, 6, 3);
+
+ // button 'set default options'
+ btnDefaults = new QPushButton(pOptionsGroup);
+ btnDefaults->setText(QPushButton::tr("Set default options"));
+ btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters"));
+ pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5);
+
+ page3Layout->addWidget(pOptionsGroup, 1, 0);
+ }
+#endif
previousQuality = this->SLQuality->value();
previousResolutionIndex = this->CBResolution->currentIndex();
@@ -492,6 +612,13 @@
void PageOptions::connectSignals()
{
+#ifdef VIDEOREC
+ connect(checkUseGameRes, SIGNAL(stateChanged(int)), this, SLOT(changeUseGameRes(int)));
+ connect(checkRecordAudio, SIGNAL(stateChanged(int)), this, SLOT(changeRecordAudio(int)));
+ connect(comboAVFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAVFormat(int)));
+ connect(btnDefaults, SIGNAL(clicked()), this, SLOT(setDefaultOptions()));
+#endif
+
connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int)));
connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int)));
connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int)));
@@ -500,7 +627,7 @@
connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int)));
}
-PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent)
+PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent), config(0)
{
initPage();
}
@@ -619,3 +746,128 @@
leProxyLogin->setEnabled(b);
leProxyPassword->setEnabled(b);
}
+
+// Video Recording
+
+void PageOptions::setConfig(GameUIConfig * config)
+{
+ this->config = config;
+}
+
+// user changed file format, we need to update list of codecs
+void PageOptions::changeAVFormat(int index)
+{
+ // remember selected codecs
+ QString prevVCodec = videoCodec();
+ QString prevACodec = audioCodec();
+
+ // clear lists of codecs
+ comboVideoCodecs->clear();
+ comboAudioCodecs->clear();
+
+ // get list of codecs for specified format
+ LibavInteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs);
+
+ // disable audio if there is no audio codec
+ if (comboAudioCodecs->count() == 0)
+ {
+ checkRecordAudio->setChecked(false);
+ checkRecordAudio->setEnabled(false);
+ }
+ else
+ checkRecordAudio->setEnabled(true);
+
+ // restore selected codecs if possible
+ int iVCodec = comboVideoCodecs->findData(prevVCodec);
+ if (iVCodec != -1)
+ comboVideoCodecs->setCurrentIndex(iVCodec);
+ int iACodec = comboAudioCodecs->findData(prevACodec);
+ if (iACodec != -1)
+ comboAudioCodecs->setCurrentIndex(iACodec);
+}
+
+// user switched checkbox 'use game resolution'
+void PageOptions::changeUseGameRes(int state)
+{
+ if (state && config)
+ {
+ // set resolution to game resolution
+ QRect resolution = config->vid_Resolution();
+ widthEdit->setText(QString::number(resolution.width()));
+ heightEdit->setText(QString::number(resolution.height()));
+ }
+ widthEdit->setEnabled(!state);
+ heightEdit->setEnabled(!state);
+}
+
+// user switched checkbox 'record audio'
+void PageOptions::changeRecordAudio(int state)
+{
+ comboAudioCodecs->setEnabled(!!state);
+}
+
+void PageOptions::setDefaultCodecs()
+{
+ // VLC should be able to handle any of these configurations
+ // Quicktime X only opens the first one
+ // Windows Media Player TODO
+ if (tryCodecs("mp4", "libx264", "aac"))
+ return;
+ if (tryCodecs("mp4", "libx264", "libfaac"))
+ return;
+ if (tryCodecs("mp4", "libx264", "libmp3lame"))
+ return;
+ if (tryCodecs("mp4", "libx264", "mp2"))
+ return;
+ if (tryCodecs("avi", "libxvid", "libmp3lame"))
+ return;
+ if (tryCodecs("avi", "libxvid", "ac3_fixed"))
+ return;
+ if (tryCodecs("avi", "libxvid", "mp2"))
+ return;
+ if (tryCodecs("avi", "mpeg4", "libmp3lame"))
+ return;
+ if (tryCodecs("avi", "mpeg4", "ac3_fixed"))
+ return;
+ if (tryCodecs("avi", "mpeg4", "mp2"))
+ return;
+
+ // this shouldn't happen, just in case
+ if (tryCodecs("ogg", "libtheora", "libvorbis"))
+ return;
+ tryCodecs("ogg", "libtheora", "flac");
+}
+
+void PageOptions::setDefaultOptions()
+{
+ framerateBox->setValue(30);
+ bitrateBox->setValue(1000);
+ checkRecordAudio->setChecked(true);
+ checkUseGameRes->setChecked(true);
+ setDefaultCodecs();
+}
+
+bool PageOptions::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec)
+{
+ // first we should change format
+ int iFormat = comboAVFormats->findData(format);
+ if (iFormat == -1)
+ return false;
+ comboAVFormats->setCurrentIndex(iFormat);
+ // format was changed, so lists of codecs were automatically updated to codecs supported by this format
+
+ // try to find video codec
+ int iVCodec = comboVideoCodecs->findData(vcodec);
+ if (iVCodec == -1)
+ return false;
+ comboVideoCodecs->setCurrentIndex(iVCodec);
+
+ // try to find audio codec
+ int iACodec = comboAudioCodecs->findData(acodec);
+ if (iACodec == -1 && checkRecordAudio->isChecked())
+ return false;
+ if (iACodec != -1)
+ comboAudioCodecs->setCurrentIndex(iACodec);
+
+ return true;
+}
--- a/QTfrontend/ui/page/pageoptions.h Fri Nov 30 20:00:53 2012 -0500
+++ b/QTfrontend/ui/page/pageoptions.h Sat Dec 01 21:24:25 2012 -0500
@@ -21,6 +21,7 @@
#include "AbstractPage.h"
+class GameUIConfig;
class FPSEdit;
class IconedGroupBox;
class QSignalMapper;
@@ -84,6 +85,28 @@
QLineEdit * leProxyLogin;
QLineEdit * leProxyPassword;
+#ifdef VIDEOREC
+ QSpinBox *framerateBox;
+ QSpinBox *bitrateBox;
+ QLineEdit *widthEdit;
+ QLineEdit *heightEdit;
+ QCheckBox *checkUseGameRes;
+ QCheckBox *checkRecordAudio;
+
+ QString format()
+ { return comboAVFormats->itemData(comboAVFormats->currentIndex()).toString(); }
+
+ QString videoCodec()
+ { return comboVideoCodecs->itemData(comboVideoCodecs->currentIndex()).toString(); }
+
+ QString audioCodec()
+ { return comboAudioCodecs->itemData(comboAudioCodecs->currentIndex()).toString(); }
+
+ void setDefaultCodecs();
+ bool tryCodecs(const QString & format, const QString & vcodec, const QString & acodec);
+ void setConfig(GameUIConfig * config);
+#endif
+
void setTeamOptionsEnabled(bool enabled);
signals:
@@ -106,6 +129,14 @@
QPushButton *BtnDeleteTeam;
QList<QPushButton *> m_colorButtons;
+#ifdef VIDEOREC
+ QComboBox *comboAVFormats;
+ QComboBox *comboVideoCodecs;
+ QComboBox *comboAudioCodecs;
+ QPushButton *btnDefaults;
+ GameUIConfig * config;
+#endif
+
private slots:
void forceFullscreen(int index);
void setFullscreen(int state);
@@ -118,6 +149,12 @@
void colorButtonClicked(int i);
void onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
void onProxyTypeChanged();
+#ifdef VIDEOREC
+ void changeAVFormat(int index);
+ void changeUseGameRes(int state);
+ void changeRecordAudio(int state);
+ void setDefaultOptions();
+#endif
};
#endif
--- a/QTfrontend/ui/page/pagevideos.cpp Fri Nov 30 20:00:53 2012 -0500
+++ b/QTfrontend/ui/page/pagevideos.cpp Sat Dec 01 21:24:25 2012 -0500
@@ -109,119 +109,6 @@
QGridLayout * pPageLayout = new QGridLayout();
pPageLayout->setColumnStretch(0, 1);
pPageLayout->setColumnStretch(1, 2);
- pPageLayout->setRowStretch(0, 1);
- pPageLayout->setRowStretch(1, 1);
-
- // options
- {
- IconedGroupBox* pOptionsGroup = new IconedGroupBox(this);
- pOptionsGroup->setIcon(QIcon(":/res/Settings.png")); // FIXME
- pOptionsGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- pOptionsGroup->setTitle(QGroupBox::tr("Video recording options"));
- QGridLayout * pOptLayout = new QGridLayout(pOptionsGroup);
-
- // label for format
- QLabel *labelFormat = new QLabel(pOptionsGroup);
- labelFormat->setText(QLabel::tr("Format"));
- pOptLayout->addWidget(labelFormat, 0, 0);
-
- // list of supported formats
- comboAVFormats = new QComboBox(pOptionsGroup);
- pOptLayout->addWidget(comboAVFormats, 0, 1, 1, 4);
- LibavInteraction::instance().fillFormats(comboAVFormats);
-
- // separator
- QFrame * hr = new QFrame(pOptionsGroup);
- hr->setFrameStyle(QFrame::HLine);
- hr->setLineWidth(3);
- hr->setFixedHeight(10);
- pOptLayout->addWidget(hr, 1, 0, 1, 5);
-
- // label for audio codec
- QLabel *labelACodec = new QLabel(pOptionsGroup);
- labelACodec->setText(QLabel::tr("Audio codec"));
- pOptLayout->addWidget(labelACodec, 2, 0);
-
- // list of supported audio codecs
- comboAudioCodecs = new QComboBox(pOptionsGroup);
- pOptLayout->addWidget(comboAudioCodecs, 2, 1, 1, 3);
-
- // checkbox 'record audio'
- checkRecordAudio = new QCheckBox(pOptionsGroup);
- checkRecordAudio->setText(QCheckBox::tr("Record audio"));
- pOptLayout->addWidget(checkRecordAudio, 2, 4);
-
- // separator
- hr = new QFrame(pOptionsGroup);
- hr->setFrameStyle(QFrame::HLine);
- hr->setLineWidth(3);
- hr->setFixedHeight(10);
- pOptLayout->addWidget(hr, 3, 0, 1, 5);
-
- // label for video codec
- QLabel *labelVCodec = new QLabel(pOptionsGroup);
- labelVCodec->setText(QLabel::tr("Video codec"));
- pOptLayout->addWidget(labelVCodec, 4, 0);
-
- // list of supported video codecs
- comboVideoCodecs = new QComboBox(pOptionsGroup);
- pOptLayout->addWidget(comboVideoCodecs, 4, 1, 1, 4);
-
- // label for resolution
- QLabel *labelRes = new QLabel(pOptionsGroup);
- labelRes->setText(QLabel::tr("Resolution"));
- pOptLayout->addWidget(labelRes, 5, 0);
-
- // width
- widthEdit = new QLineEdit(pOptionsGroup);
- widthEdit->setValidator(new QIntValidator(this));
- pOptLayout->addWidget(widthEdit, 5, 1);
-
- // x
- QLabel *labelX = new QLabel(pOptionsGroup);
- labelX->setText("X");
- pOptLayout->addWidget(labelX, 5, 2);
-
- // height
- heightEdit = new QLineEdit(pOptionsGroup);
- heightEdit->setValidator(new QIntValidator(pOptionsGroup));
- pOptLayout->addWidget(heightEdit, 5, 3);
-
- // checkbox 'use game resolution'
- checkUseGameRes = new QCheckBox(pOptionsGroup);
- checkUseGameRes->setText(QCheckBox::tr("Use game resolution"));
- pOptLayout->addWidget(checkUseGameRes, 5, 4);
-
- // label for framerate
- QLabel *labelFramerate = new QLabel(pOptionsGroup);
- labelFramerate->setText(QLabel::tr("Framerate"));
- pOptLayout->addWidget(labelFramerate, 6, 0);
-
- // framerate
- framerateBox = new QSpinBox(pOptionsGroup);
- framerateBox->setRange(1, 200);
- framerateBox->setSingleStep(1);
- pOptLayout->addWidget(framerateBox, 6, 1);
-
- // label for Bitrate
- QLabel *labelBitrate = new QLabel(pOptionsGroup);
- labelBitrate->setText(QLabel::tr("Bitrate (Kbps)"));
- pOptLayout->addWidget(labelBitrate, 6, 2);
-
- // bitrate
- bitrateBox = new QSpinBox(pOptionsGroup);
- bitrateBox->setRange(100, 5000);
- bitrateBox->setSingleStep(100);
- pOptLayout->addWidget(bitrateBox, 6, 3);
-
- // button 'set default options'
- btnDefaults = new QPushButton(pOptionsGroup);
- btnDefaults->setText(QPushButton::tr("Set default options"));
- btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters"));
- pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5);
-
- pPageLayout->addWidget(pOptionsGroup, 1, 0);
- }
// list of videos
{
@@ -257,7 +144,7 @@
box->addWidget(filesTable);
box->addWidget(btnOpenDir);
- pPageLayout->addWidget(pTableGroup, 0, 1, 2, 1);
+ pPageLayout->addWidget(pTableGroup, 0, 1);
}
// description
@@ -327,10 +214,6 @@
void PageVideos::connectSignals()
{
- connect(checkUseGameRes, SIGNAL(stateChanged(int)), this, SLOT(changeUseGameRes(int)));
- connect(checkRecordAudio, SIGNAL(stateChanged(int)), this, SLOT(changeRecordAudio(int)));
- connect(comboAVFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAVFormat(int)));
- connect(btnDefaults, SIGNAL(clicked()), this, SLOT(setDefaultOptions()));
connect(filesTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(cellDoubleClicked(int, int)));
connect(filesTable, SIGNAL(cellChanged(int,int)), this, SLOT(cellChanged(int, int)));
connect(filesTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentCellChanged()));
@@ -362,124 +245,6 @@
startEncoding(); // this is for videos recorded from demos which were executed directly (without frontend)
}
-// user changed file format, we need to update list of codecs
-void PageVideos::changeAVFormat(int index)
-{
- // remember selected codecs
- QString prevVCodec = videoCodec();
- QString prevACodec = audioCodec();
-
- // clear lists of codecs
- comboVideoCodecs->clear();
- comboAudioCodecs->clear();
-
- // get list of codecs for specified format
- LibavInteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs);
-
- // disable audio if there is no audio codec
- if (comboAudioCodecs->count() == 0)
- {
- checkRecordAudio->setChecked(false);
- checkRecordAudio->setEnabled(false);
- }
- else
- checkRecordAudio->setEnabled(true);
-
- // restore selected codecs if possible
- int iVCodec = comboVideoCodecs->findData(prevVCodec);
- if (iVCodec != -1)
- comboVideoCodecs->setCurrentIndex(iVCodec);
- int iACodec = comboAudioCodecs->findData(prevACodec);
- if (iACodec != -1)
- comboAudioCodecs->setCurrentIndex(iACodec);
-}
-
-// user switched checkbox 'use game resolution'
-void PageVideos::changeUseGameRes(int state)
-{
- if (state && config)
- {
- // set resolution to game resolution
- QRect resolution = config->vid_Resolution();
- widthEdit->setText(QString::number(resolution.width()));
- heightEdit->setText(QString::number(resolution.height()));
- }
- widthEdit->setEnabled(!state);
- heightEdit->setEnabled(!state);
-}
-
-// user switched checkbox 'record audio'
-void PageVideos::changeRecordAudio(int state)
-{
- comboAudioCodecs->setEnabled(!!state);
-}
-
-void PageVideos::setDefaultCodecs()
-{
- // VLC should be able to handle any of these configurations
- // Quicktime X only opens the first one
- // Windows Media Player TODO
- if (tryCodecs("mp4", "libx264", "aac"))
- return;
- if (tryCodecs("mp4", "libx264", "libfaac"))
- return;
- if (tryCodecs("mp4", "libx264", "libmp3lame"))
- return;
- if (tryCodecs("mp4", "libx264", "mp2"))
- return;
- if (tryCodecs("avi", "libxvid", "libmp3lame"))
- return;
- if (tryCodecs("avi", "libxvid", "ac3_fixed"))
- return;
- if (tryCodecs("avi", "libxvid", "mp2"))
- return;
- if (tryCodecs("avi", "mpeg4", "libmp3lame"))
- return;
- if (tryCodecs("avi", "mpeg4", "ac3_fixed"))
- return;
- if (tryCodecs("avi", "mpeg4", "mp2"))
- return;
-
- // this shouldn't happen, just in case
- if (tryCodecs("ogg", "libtheora", "libvorbis"))
- return;
- tryCodecs("ogg", "libtheora", "flac");
-}
-
-void PageVideos::setDefaultOptions()
-{
- framerateBox->setValue(30);
- bitrateBox->setValue(1000);
- checkRecordAudio->setChecked(true);
- checkUseGameRes->setChecked(true);
- setDefaultCodecs();
-}
-
-bool PageVideos::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec)
-{
- // first we should change format
- int iFormat = comboAVFormats->findData(format);
- if (iFormat == -1)
- return false;
- comboAVFormats->setCurrentIndex(iFormat);
- // format was changed, so lists of codecs were automatically updated to codecs supported by this format
-
- // try to find video codec
- int iVCodec = comboVideoCodecs->findData(vcodec);
- if (iVCodec == -1)
- return false;
- comboVideoCodecs->setCurrentIndex(iVCodec);
-
- // try to find audio codec
- int iACodec = comboAudioCodecs->findData(acodec);
- if (iACodec == -1 && checkRecordAudio->isChecked())
- return false;
- if (iACodec != -1)
- comboAudioCodecs->setCurrentIndex(iACodec);
-
- return true;
-}
-
// get file size as string
static QString FileSizeStr(const QString & path)
{
--- a/QTfrontend/ui/page/pagevideos.h Fri Nov 30 20:00:53 2012 -0500
+++ b/QTfrontend/ui/page/pagevideos.h Sat Dec 01 21:24:25 2012 -0500
@@ -36,24 +36,6 @@
public:
PageVideos(QWidget* parent = 0);
- QSpinBox *framerateBox;
- QSpinBox *bitrateBox;
- QLineEdit *widthEdit;
- QLineEdit *heightEdit;
- QCheckBox *checkUseGameRes;
- QCheckBox *checkRecordAudio;
-
- QString format()
- { return comboAVFormats->itemData(comboAVFormats->currentIndex()).toString(); }
-
- QString videoCodec()
- { return comboVideoCodecs->itemData(comboVideoCodecs->currentIndex()).toString(); }
-
- QString audioCodec()
- { return comboAudioCodecs->itemData(comboAudioCodecs->currentIndex()).toString(); }
-
- void setDefaultCodecs();
- bool tryCodecs(const QString & format, const QString & vcodec, const QString & acodec);
void addRecorder(HWRecorder* pRecorder);
bool tryQuit(HWForm *form);
QString getVideosInProgress(); // get multi-line string with list of videos in progress
@@ -83,12 +65,6 @@
GameUIConfig * config;
QNetworkAccessManager* netManager;
- // options group
- QComboBox *comboAVFormats;
- QComboBox *comboVideoCodecs;
- QComboBox *comboAudioCodecs;
- QPushButton *btnDefaults;
-
// file list group
QTableWidget *filesTable;
QPushButton *btnOpenDir;
@@ -105,10 +81,6 @@
int numRecorders, numUploads;
private slots:
- void changeAVFormat(int index);
- void changeUseGameRes(int state);
- void changeRecordAudio(int state);
- void setDefaultOptions();
void encodingFinished(bool success);
void updateProgress(float value);
void cellDoubleClicked(int row, int column);