From: lordmulder Date: Mon, 30 Apr 2012 17:26:41 +0000 (+0200) Subject: Added an option to save the log automatically. X-Git-Tag: v2.27~61 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7effdd62d8e240b6c44ee143f2ee21e780dc7c3a;p=x264-launcher%2Fx264-launcher.git Added an option to save the log automatically. --- diff --git a/gui/win_preferences.ui b/gui/win_preferences.ui index 679e130..f1762b1 100644 --- a/gui/win_preferences.ui +++ b/gui/win_preferences.ui @@ -10,7 +10,7 @@ 0 0 379 - 260 + 292 @@ -47,7 +47,7 @@ - + Qt::Horizontal @@ -63,7 +63,7 @@ - + Qt::Horizontal @@ -155,14 +155,14 @@ Please be aware that this option does NOT have any effect on 32-Bit systems. - + - + Shutdown computer as soon as the last job has completed @@ -185,7 +185,7 @@ Please be aware that this option does NOT have any effect on 32-Bit systems. - + Qt::Vertical @@ -258,6 +258,36 @@ Please be aware that this option does NOT have any effect on 32-Bit systems. + + + + + + + + + + + Automatically save output to log file when a job has finished + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + diff --git a/src/thread_encode.cpp b/src/thread_encode.cpp index 65215dc..34251e0 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -180,6 +180,7 @@ void EncodeThread::encode(void) QDateTime startTime = QDateTime::currentDateTime(); //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("Source file: %1").arg(m_sourceFileName)); log(tr("Output file: %1").arg(m_outputFileName)); diff --git a/src/version.h b/src/version.h index 8f3549a..c0a6b77 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 0 #define VER_X264_PATCH 4 -#define VER_X264_BUILD 312 +#define VER_X264_BUILD 325 #define VER_X264_MINIMUM_REV 2189 #define VER_X264_CURRENT_API 124 diff --git a/src/win_main.cpp b/src/win_main.cpp index 698c27b..a1b940a 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -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.shutdownComputer) QTimer::singleShot(0, this, SLOT(shutdownComputer())); + if(m_preferences.saveLogFiles) saveLogFile(m_jobList->index(i, 1, QModelIndex())); } } } @@ -537,7 +539,6 @@ void MainWindow::showPreferences(void) void MainWindow::launchNextJob(void) { qDebug("launchNextJob(void)"); - const int rows = m_jobList->rowCount(QModelIndex()); @@ -567,6 +568,39 @@ void MainWindow::launchNextJob(void) } /* + * 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) */ void MainWindow::shutdownComputer(void) @@ -748,12 +782,17 @@ void MainWindow::init(void) if(val != 1) { close(); qApp->exit(-1); return; } } } + else + { + qWarning("Failed to load avisynth.dll libraray!"); + } if(avisynthVersion < 2.5) { int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("It appears that Avisynth is not currently installed on your computer.
Therefore Avisynth (.avs) input will not be working at all!

Please download and install Avisynth:
http://sourceforge.net/projects/avisynth2/files/AviSynth 2.5/
").replace("-", "−"), tr("Quit"), tr("Ignore")); m_avsLib->unload(); X264_DELETE(m_avsLib); if(val != 1) { close(); qApp->exit(-1); return; } } + qDebug(""); } //Check for expiration diff --git a/src/win_main.h b/src/win_main.h index f8435ae..115ecc4 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -86,6 +86,7 @@ private slots: void launchNextJob(); void pauseButtonPressed(bool checked); void restartButtonPressed(void); + void saveLogFile(const QModelIndex &index); void showAbout(void); void showPreferences(void); void showWebLink(void); diff --git a/src/win_preferences.cpp b/src/win_preferences.cpp index 8b0d8aa..37499ea 100644 --- a/src/win_preferences.cpp +++ b/src/win_preferences.cpp @@ -47,6 +47,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Preferences *preferences, labelUse10BitEncoding->installEventFilter(this); labelUse64BitAvs2YUV->installEventFilter(this); labelShutdownComputer->installEventFilter(this); + labelSaveLogFiles->installEventFilter(this); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed())); 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(checkShutdownComputer, m_preferences->shutdownComputer); UPDATE_CHECKBOX(checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit); + UPDATE_CHECKBOX(checkSaveLogFiles, m_preferences->saveLogFiles); checkUse10BitEncoding->blockSignals(true); 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, labelUse10BitEncoding, checkUse10BitEncoding); emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV); + emulateMouseEvent(o, e, labelSaveLogFiles, checkSaveLogFiles); return false; } @@ -111,6 +114,7 @@ void PreferencesDialog::done(int n) m_preferences->shutdownComputer = checkShutdownComputer->isChecked(); m_preferences->use10BitEncoding = checkUse10BitEncoding->isChecked(); m_preferences->useAvisyth64Bit = checkUse64BitAvs2YUV->isChecked(); + m_preferences->saveLogFiles = checkSaveLogFiles->isChecked(); m_preferences->maxRunningJobCount = spinBoxJobCount->value(); savePreferences(m_preferences); @@ -152,6 +156,7 @@ void PreferencesDialog::initPreferences(Preferences *preferences) preferences->shutdownComputer = false; preferences->use10BitEncoding = false; preferences->useAvisyth64Bit = false; + preferences->saveLogFiles = false; } 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->use10BitEncoding = settings.value("use_10bit_encoding", QVariant(defaults.use10BitEncoding)).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) @@ -181,6 +187,7 @@ void PreferencesDialog::savePreferences(Preferences *preferences) settings.setValue("max_running_job_count", preferences->maxRunningJobCount); settings.setValue("use_10bit_encoding", preferences->use10BitEncoding); settings.setValue("use_64bit_avisynth", preferences->useAvisyth64Bit); + settings.setValue("save_log_files", preferences->saveLogFiles); settings.sync(); } diff --git a/src/win_preferences.h b/src/win_preferences.h index 9f04252..1d35ec6 100644 --- a/src/win_preferences.h +++ b/src/win_preferences.h @@ -35,6 +35,7 @@ public: bool shutdownComputer; bool use10BitEncoding; bool useAvisyth64Bit; + bool saveLogFiles; } Preferences;