Added an option to save the log automatically.

This commit is contained in:
LoRd_MuldeR 2012-04-30 19:26:41 +02:00
parent 1cb2b2b4c8
commit 7effdd62d8
7 changed files with 87 additions and 8 deletions

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>379</width> <width>379</width>
<height>260</height> <height>292</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -47,7 +47,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" rowspan="8"> <item row="1" column="0" rowspan="10">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -63,7 +63,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="6" rowspan="8"> <item row="1" column="6" rowspan="10">
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -155,14 +155,14 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="8" column="1"> <item row="10" column="1">
<widget class="QCheckBox" name="checkShutdownComputer"> <widget class="QCheckBox" name="checkShutdownComputer">
<property name="text"> <property name="text">
<string notr="true"/> <string notr="true"/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="2" colspan="4"> <item row="10" column="2" colspan="4">
<widget class="QLabel" name="labelShutdownComputer"> <widget class="QLabel" name="labelShutdownComputer">
<property name="text"> <property name="text">
<string>Shutdown computer as soon as the last job has completed</string> <string>Shutdown computer as soon as the last job has completed</string>
@ -185,7 +185,7 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="9" column="1" colspan="5"> <item row="11" column="1" colspan="5">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -258,6 +258,36 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="8" column="1">
<widget class="QCheckBox" name="checkSaveLogFiles">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="2" colspan="4">
<widget class="QLabel" name="labelSaveLogFiles">
<property name="text">
<string>Automatically save output to log file when a job has finished</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="5">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -180,6 +180,7 @@ void EncodeThread::encode(void)
QDateTime startTime = QDateTime::currentDateTime(); QDateTime startTime = QDateTime::currentDateTime();
//Print some basic info //Print some basic info
log(tr("Simple x264 Launcher (Build #%1), built %2\n").arg(QString::number(x264_version_build()), x264_version_date().toString(Qt::ISODate)));
log(tr("Job started at %1, %2.\n").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate))); log(tr("Job started at %1, %2.\n").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate)));
log(tr("Source file: %1").arg(m_sourceFileName)); log(tr("Source file: %1").arg(m_sourceFileName));
log(tr("Output file: %1").arg(m_outputFileName)); log(tr("Output file: %1").arg(m_outputFileName));

View File

@ -22,7 +22,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 0 #define VER_X264_MINOR 0
#define VER_X264_PATCH 4 #define VER_X264_PATCH 4
#define VER_X264_BUILD 312 #define VER_X264_BUILD 325
#define VER_X264_MINIMUM_REV 2189 #define VER_X264_MINIMUM_REV 2189
#define VER_X264_CURRENT_API 124 #define VER_X264_CURRENT_API 124

View File

@ -40,6 +40,7 @@
#include <QProcess> #include <QProcess>
#include <QProgressDialog> #include <QProgressDialog>
#include <QScrollBar> #include <QScrollBar>
#include <QTextStream>
#include <Mmsystem.h> #include <Mmsystem.h>
@ -392,6 +393,7 @@ void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &
{ {
if(m_preferences.autoRunNextJob) QTimer::singleShot(0, this, SLOT(launchNextJob())); if(m_preferences.autoRunNextJob) QTimer::singleShot(0, this, SLOT(launchNextJob()));
if(m_preferences.shutdownComputer) QTimer::singleShot(0, this, SLOT(shutdownComputer())); if(m_preferences.shutdownComputer) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
if(m_preferences.saveLogFiles) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
} }
} }
} }
@ -538,7 +540,6 @@ void MainWindow::launchNextJob(void)
{ {
qDebug("launchNextJob(void)"); qDebug("launchNextJob(void)");
const int rows = m_jobList->rowCount(QModelIndex()); const int rows = m_jobList->rowCount(QModelIndex());
if(countRunningJobs() >= m_preferences.maxRunningJobCount) if(countRunningJobs() >= m_preferences.maxRunningJobCount)
@ -566,6 +567,39 @@ void MainWindow::launchNextJob(void)
qWarning("No enqueued jobs left!"); qWarning("No enqueued jobs left!");
} }
/*
* Save log to text file
*/
void MainWindow::saveLogFile(const QModelIndex &index)
{
if(index.isValid())
{
if(LogFileModel *log = m_jobList->getLogFile(index))
{
QDir(QString("%1/logs").arg(x264_data_path())).mkpath(".");
QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-"));
QFile outFile(logFilePath);
if(outFile.open(QIODevice::WriteOnly))
{
QTextStream outStream(&outFile);
outStream.setCodec("UTF-8");
outStream.setGenerateByteOrderMark(true);
const int rows = log->rowCount(QModelIndex());
for(int i = 0; i < rows; i++)
{
outStream << log->data(log->index(i, 0, QModelIndex()), Qt::DisplayRole).toString() << QLatin1String("\r\n");
}
outFile.close();
}
else
{
qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
}
}
}
}
/* /*
* Shut down the computer (with countdown) * Shut down the computer (with countdown)
*/ */
@ -748,12 +782,17 @@ void MainWindow::init(void)
if(val != 1) { close(); qApp->exit(-1); return; } if(val != 1) { close(); qApp->exit(-1); return; }
} }
} }
else
{
qWarning("Failed to load avisynth.dll libraray!");
}
if(avisynthVersion < 2.5) if(avisynthVersion < 2.5)
{ {
int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("<nobr>It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!<br><br>Please download and install Avisynth:<br><a href=\"http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/\">http://sourceforge.net/projects/avisynth2/files/AviSynth 2.5/</a></nobr>").replace("-", "&minus;"), tr("Quit"), tr("Ignore")); int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("<nobr>It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!<br><br>Please download and install Avisynth:<br><a href=\"http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/\">http://sourceforge.net/projects/avisynth2/files/AviSynth 2.5/</a></nobr>").replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
m_avsLib->unload(); X264_DELETE(m_avsLib); m_avsLib->unload(); X264_DELETE(m_avsLib);
if(val != 1) { close(); qApp->exit(-1); return; } if(val != 1) { close(); qApp->exit(-1); return; }
} }
qDebug("");
} }
//Check for expiration //Check for expiration

View File

@ -86,6 +86,7 @@ private slots:
void launchNextJob(); void launchNextJob();
void pauseButtonPressed(bool checked); void pauseButtonPressed(bool checked);
void restartButtonPressed(void); void restartButtonPressed(void);
void saveLogFile(const QModelIndex &index);
void showAbout(void); void showAbout(void);
void showPreferences(void); void showPreferences(void);
void showWebLink(void); void showWebLink(void);

View File

@ -47,6 +47,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Preferences *preferences,
labelUse10BitEncoding->installEventFilter(this); labelUse10BitEncoding->installEventFilter(this);
labelUse64BitAvs2YUV->installEventFilter(this); labelUse64BitAvs2YUV->installEventFilter(this);
labelShutdownComputer->installEventFilter(this); labelShutdownComputer->installEventFilter(this);
labelSaveLogFiles->installEventFilter(this);
connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed())); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed()));
connect(checkUse10BitEncoding, SIGNAL(toggled(bool)), this, SLOT(use10BitEncodingToggled(bool))); connect(checkUse10BitEncoding, SIGNAL(toggled(bool)), this, SLOT(use10BitEncodingToggled(bool)));
@ -65,6 +66,7 @@ void PreferencesDialog::showEvent(QShowEvent *event)
UPDATE_CHECKBOX(checkRunNextJob, m_preferences->autoRunNextJob); UPDATE_CHECKBOX(checkRunNextJob, m_preferences->autoRunNextJob);
UPDATE_CHECKBOX(checkShutdownComputer, m_preferences->shutdownComputer); UPDATE_CHECKBOX(checkShutdownComputer, m_preferences->shutdownComputer);
UPDATE_CHECKBOX(checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit); UPDATE_CHECKBOX(checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit);
UPDATE_CHECKBOX(checkSaveLogFiles, m_preferences->saveLogFiles);
checkUse10BitEncoding->blockSignals(true); checkUse10BitEncoding->blockSignals(true);
UPDATE_CHECKBOX(checkUse10BitEncoding, m_preferences->use10BitEncoding); UPDATE_CHECKBOX(checkUse10BitEncoding, m_preferences->use10BitEncoding);
@ -82,6 +84,7 @@ bool PreferencesDialog::eventFilter(QObject *o, QEvent *e)
emulateMouseEvent(o, e, labelShutdownComputer, checkShutdownComputer); emulateMouseEvent(o, e, labelShutdownComputer, checkShutdownComputer);
emulateMouseEvent(o, e, labelUse10BitEncoding, checkUse10BitEncoding); emulateMouseEvent(o, e, labelUse10BitEncoding, checkUse10BitEncoding);
emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV); emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV);
emulateMouseEvent(o, e, labelSaveLogFiles, checkSaveLogFiles);
return false; return false;
} }
@ -111,6 +114,7 @@ void PreferencesDialog::done(int n)
m_preferences->shutdownComputer = checkShutdownComputer->isChecked(); m_preferences->shutdownComputer = checkShutdownComputer->isChecked();
m_preferences->use10BitEncoding = checkUse10BitEncoding->isChecked(); m_preferences->use10BitEncoding = checkUse10BitEncoding->isChecked();
m_preferences->useAvisyth64Bit = checkUse64BitAvs2YUV->isChecked(); m_preferences->useAvisyth64Bit = checkUse64BitAvs2YUV->isChecked();
m_preferences->saveLogFiles = checkSaveLogFiles->isChecked();
m_preferences->maxRunningJobCount = spinBoxJobCount->value(); m_preferences->maxRunningJobCount = spinBoxJobCount->value();
savePreferences(m_preferences); savePreferences(m_preferences);
@ -152,6 +156,7 @@ void PreferencesDialog::initPreferences(Preferences *preferences)
preferences->shutdownComputer = false; preferences->shutdownComputer = false;
preferences->use10BitEncoding = false; preferences->use10BitEncoding = false;
preferences->useAvisyth64Bit = false; preferences->useAvisyth64Bit = false;
preferences->saveLogFiles = false;
} }
void PreferencesDialog::loadPreferences(Preferences *preferences) void PreferencesDialog::loadPreferences(Preferences *preferences)
@ -168,6 +173,7 @@ void PreferencesDialog::loadPreferences(Preferences *preferences)
preferences->shutdownComputer = settings.value("shutdown_computer_on_completion", QVariant(defaults.shutdownComputer)).toBool(); preferences->shutdownComputer = settings.value("shutdown_computer_on_completion", QVariant(defaults.shutdownComputer)).toBool();
preferences->use10BitEncoding = settings.value("use_10bit_encoding", QVariant(defaults.use10BitEncoding)).toBool(); preferences->use10BitEncoding = settings.value("use_10bit_encoding", QVariant(defaults.use10BitEncoding)).toBool();
preferences->useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.useAvisyth64Bit)).toBool(); preferences->useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.useAvisyth64Bit)).toBool();
preferences->saveLogFiles = settings.value("save_log_files", QVariant(defaults.saveLogFiles)).toBool();
} }
void PreferencesDialog::savePreferences(Preferences *preferences) void PreferencesDialog::savePreferences(Preferences *preferences)
@ -181,6 +187,7 @@ void PreferencesDialog::savePreferences(Preferences *preferences)
settings.setValue("max_running_job_count", preferences->maxRunningJobCount); settings.setValue("max_running_job_count", preferences->maxRunningJobCount);
settings.setValue("use_10bit_encoding", preferences->use10BitEncoding); settings.setValue("use_10bit_encoding", preferences->use10BitEncoding);
settings.setValue("use_64bit_avisynth", preferences->useAvisyth64Bit); settings.setValue("use_64bit_avisynth", preferences->useAvisyth64Bit);
settings.setValue("save_log_files", preferences->saveLogFiles);
settings.sync(); settings.sync();
} }

View File

@ -35,6 +35,7 @@ public:
bool shutdownComputer; bool shutdownComputer;
bool use10BitEncoding; bool use10BitEncoding;
bool useAvisyth64Bit; bool useAvisyth64Bit;
bool saveLogFiles;
} }
Preferences; Preferences;