Enable video capture with Qt4 front-end (Windows only right now.)
parent
180e4fd9c2
commit
3da6f3715c
|
@ -383,8 +383,10 @@ RESOURCES = \
|
|||
|
||||
FORMS = \
|
||||
celestia/qt/addbookmark.ui \
|
||||
celestia/qt/newbookmarkfolder.ui \
|
||||
celestia/qt/organizebookmarks.ui
|
||||
celestia/qt/newbookmarkfolder.ui \
|
||||
celestia/qt/organizebookmarks.ui \
|
||||
celestia/qt/preferences.ui
|
||||
|
||||
|
||||
UI_HEADERS_DIR = celestia/qt/ui
|
||||
UI_SOURCES_DIR = celestia/qt/ui
|
||||
|
@ -412,7 +414,11 @@ win32 {
|
|||
-llibjpeg2 \
|
||||
-lintl \
|
||||
-llua5.1 \
|
||||
-lcspice
|
||||
-lcspice \
|
||||
-lvfw32
|
||||
|
||||
SOURCES += celestia/avicapture.cpp
|
||||
HEADERS += celestia/avicapture.h
|
||||
|
||||
RC_FILE = celestia/qt/celestia.rc
|
||||
DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// avicapture.cpp
|
||||
//
|
||||
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
|
||||
// Copyright (C) 2001-2008, Chris Laurel <claurel@shatters.net>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
|
@ -63,10 +63,10 @@ bool AVICapture::start(const string& filename,
|
|||
int rowBytes = (width * 3 + 3) & ~0x3;
|
||||
image = new unsigned char[rowBytes * height];
|
||||
|
||||
HRESULT hr = AVIFileOpen(&aviFile,
|
||||
filename.c_str(),
|
||||
OF_WRITE | OF_CREATE,
|
||||
NULL);
|
||||
HRESULT hr = AVIFileOpenA(&aviFile,
|
||||
filename.c_str(),
|
||||
OF_WRITE | OF_CREATE,
|
||||
NULL);
|
||||
if (hr != AVIERR_OK)
|
||||
{
|
||||
DPRINTF(0, "Erroring creating avi file for capture.\n");
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
<ui version="4.0" >
|
||||
<class>preferencesDialog</class>
|
||||
<widget class="QDialog" name="preferencesDialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>461</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget" >
|
||||
<property name="tabShape" >
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="renderQualityTab" >
|
||||
<attribute name="title" >
|
||||
<string>Render Quality</string>
|
||||
</attribute>
|
||||
<widget class="QCheckBox" name="aaLinesCheckBox" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>336</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Antialiased lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="renderPathLabel" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>336</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>33</y>
|
||||
<width>281</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Texture Resolution</string>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="lowResButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>24</y>
|
||||
<width>314</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Low</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="mediumResButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>48</y>
|
||||
<width>314</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Medium</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="highResButton" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>72</y>
|
||||
<width>314</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>High</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Render Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="renderPathCombo" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="timeTab" >
|
||||
<attribute name="title" >
|
||||
<string>Time</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>331</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Time Zone Format</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QRadioButton" name="localFormatButton" >
|
||||
<property name="text" >
|
||||
<string>Local Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="timeZoneNameButton" >
|
||||
<property name="text" >
|
||||
<string>Time Zone Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="utcOffsetButton" >
|
||||
<property name="text" >
|
||||
<string>UTC Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>preferencesDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>preferencesDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -59,6 +59,10 @@
|
|||
#include "celengine/glext.h"
|
||||
#include "qtbookmark.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "celestia/avicapture.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
@ -138,6 +142,7 @@ CelestiaAppWindow::CelestiaAppWindow() :
|
|||
infoPanel(NULL),
|
||||
eventFinder(NULL),
|
||||
alerter(NULL),
|
||||
m_preferencesDialog(NULL),
|
||||
m_bookmarkManager(NULL),
|
||||
m_bookmarkToolBar(NULL)
|
||||
{
|
||||
|
@ -597,7 +602,71 @@ void CelestiaAppWindow::slotCaptureVideo()
|
|||
dir = QDir::current().path();
|
||||
}
|
||||
|
||||
//TODO
|
||||
int videoSizes[8][2] =
|
||||
{
|
||||
{ 160, 120 },
|
||||
{ 320, 240 },
|
||||
{ 640, 480 },
|
||||
{ 720, 480 },
|
||||
{ 720, 576 },
|
||||
{ 1024, 768 },
|
||||
{ 1280, 720 },
|
||||
{ 1920, 1080 }
|
||||
};
|
||||
|
||||
float videoFrameRates[5] = { 15.0f, 24.0f, 25.0f, 29.97f, 30.0f };
|
||||
|
||||
#ifdef _WIN32
|
||||
QString saveAsName = QFileDialog::getSaveFileName(this,
|
||||
tr("Capture Video"),
|
||||
dir,
|
||||
tr("Video (*.avi)"));
|
||||
if (!saveAsName.isEmpty())
|
||||
{
|
||||
QDialog videoInfoDialog(this);
|
||||
videoInfoDialog.setWindowTitle("Capture Video");
|
||||
|
||||
QGridLayout* layout = new QGridLayout(&videoInfoDialog);
|
||||
|
||||
QComboBox* resolutionCombo = new QComboBox(&videoInfoDialog);
|
||||
layout->addWidget(new QLabel(tr("Resolution:"), &videoInfoDialog), 0, 0);
|
||||
layout->addWidget(resolutionCombo, 0, 1);
|
||||
for (unsigned int i = 0; i < sizeof(videoSizes) / sizeof(videoSizes[0]); i++)
|
||||
{
|
||||
resolutionCombo->addItem(QString("%1 x %2").arg(videoSizes[i][0]).arg(videoSizes[i][1]), QSize(videoSizes[i][0], videoSizes[i][1]));
|
||||
}
|
||||
|
||||
QComboBox* frameRateCombo = new QComboBox(&videoInfoDialog);
|
||||
layout->addWidget(new QLabel(tr("Frame rate:"), &videoInfoDialog), 1, 0);
|
||||
layout->addWidget(frameRateCombo, 1, 1);
|
||||
for (unsigned int i = 0; i < sizeof(videoFrameRates) / sizeof(videoFrameRates[0]); i++)
|
||||
{
|
||||
frameRateCombo->addItem(QString("%1").arg(videoFrameRates[i]), videoFrameRates[i]);
|
||||
}
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &videoInfoDialog);
|
||||
connect(buttons, SIGNAL(accepted()), &videoInfoDialog, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), &videoInfoDialog, SLOT(reject()));
|
||||
layout->addWidget(buttons, 2, 0, 1, 2);
|
||||
|
||||
videoInfoDialog.setLayout(layout);
|
||||
|
||||
if (videoInfoDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
QSize videoSize = resolutionCombo->itemData(resolutionCombo->currentIndex()).toSize();
|
||||
double frameRate = frameRateCombo->itemData(frameRateCombo->currentIndex()).toDouble();
|
||||
|
||||
MovieCapture* movieCapture = new AVICapture();
|
||||
bool ok = movieCapture->start(saveAsName.toAscii().data(),
|
||||
videoSize.width(), videoSize.height(),
|
||||
(float) frameRate);
|
||||
if (ok)
|
||||
m_appCore->initMovieCapture(movieCapture);
|
||||
else
|
||||
delete movieCapture;
|
||||
}
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
settings.endGroup();
|
||||
}
|
||||
|
@ -666,10 +735,18 @@ void CelestiaAppWindow::gotoSelection()
|
|||
|
||||
void CelestiaAppWindow::slotPreferences()
|
||||
{
|
||||
PreferencesDialog dlg(this, m_appCore);
|
||||
PreferencesDialog dlg(this, m_appCore);
|
||||
dlg.exec();
|
||||
#if 0
|
||||
if (m_preferencesDialog == NULL)
|
||||
{
|
||||
m_preferencesDialog = new PreferencesDialog(this, m_appCore);
|
||||
}
|
||||
|
||||
dlg.exec();
|
||||
//resyncMenus();
|
||||
m_preferencesDialog->syncState();
|
||||
|
||||
m_preferencesDialog->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CelestiaAppWindow::slotSplitViewVertically()
|
||||
|
@ -944,7 +1021,7 @@ void CelestiaAppWindow::createMenus()
|
|||
|
||||
QAction* captureVideoAction = new QAction(QIcon(":data/capture-video.png"),
|
||||
tr("Capture &video"), this);
|
||||
captureVideoAction->setShortcut(tr("F11"));
|
||||
//captureVideoAction->setShortcut(tr("F11"));
|
||||
connect(captureVideoAction, SIGNAL(triggered()), this, SLOT(slotCaptureVideo()));
|
||||
fileMenu->addAction(captureVideoAction);
|
||||
|
||||
|
@ -976,7 +1053,7 @@ void CelestiaAppWindow::createMenus()
|
|||
fileMenu->addSeparator();
|
||||
|
||||
QAction* prefAct = new QAction(QIcon(":data/preferences.png"),
|
||||
tr("&Preferences"), this);
|
||||
tr("&Preferences..."), this);
|
||||
connect(prefAct, SIGNAL(triggered()), this, SLOT(slotPreferences()));
|
||||
fileMenu->addAction(prefAct);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ class EventFinder;
|
|||
class CelestiaActions;
|
||||
|
||||
|
||||
class PreferencesDialog;
|
||||
class BookmarkManager;
|
||||
class BookmarkToolBar;
|
||||
class QUrl;
|
||||
|
@ -130,6 +131,7 @@ class CelestiaAppWindow : public QMainWindow
|
|||
|
||||
CelestiaCore::Alerter* alerter;
|
||||
|
||||
PreferencesDialog* m_preferencesDialog;
|
||||
BookmarkManager* m_bookmarkManager;
|
||||
BookmarkToolBar* m_bookmarkToolBar;
|
||||
|
||||
|
|
Loading…
Reference in New Issue