diff --git a/res/buttons/text_wrapping.png b/res/buttons/text_wrapping.png
new file mode 100644
index 0000000..106edae
Binary files /dev/null and b/res/buttons/text_wrapping.png differ
diff --git a/res/resources.qrc b/res/resources.qrc
index 87e0c07..7ca3305 100644
--- a/res/resources.qrc
+++ b/res/resources.qrc
@@ -46,6 +46,7 @@
buttons/shield_green.png
buttons/shield_grey.png
buttons/suspended.png
+ buttons/text_wrapping.png
buttons/transmit.png
buttons/trash.png
buttons/update.png
diff --git a/src/model_logFile.cpp b/src/model_logFile.cpp
index c16edb2..b0a50aa 100644
--- a/src/model_logFile.cpp
+++ b/src/model_logFile.cpp
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
LogFileModel::LogFileModel(const QString &sourceName, const QString &outputName, const QString &configName)
{
@@ -92,6 +93,37 @@ void LogFileModel::copyToClipboard(void)
clipboard->setText(m_lines.join("\r\n"));
}
+bool LogFileModel::saveToLocalFile(const QString &fileName)
+{
+ QFile file(fileName);
+ if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
+ {
+ return false;
+ }
+
+ QTextStream out(&file);
+ out.setCodec("UTF-8");
+ for(QStringList::ConstIterator iter = m_lines.constBegin(); iter != m_lines.constEnd(); iter++)
+ {
+ out << (*iter) << QLatin1String("\r\n");
+ if(out.status() != QTextStream::Status::Ok)
+ {
+ file.close();
+ return false;
+ }
+ }
+
+ out.flush();
+ if(out.status() != QTextStream::Status::Ok)
+ {
+ file.close();
+ return false;
+ }
+
+ file.close();
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Slots
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/model_logFile.h b/src/model_logFile.h
index 1bf9d6e..e2bb62f 100644
--- a/src/model_logFile.h
+++ b/src/model_logFile.h
@@ -44,6 +44,7 @@ public:
virtual QVariant data(const QModelIndex &index, int role) const;
void copyToClipboard(void);
+ bool saveToLocalFile(const QString &fileName);
protected:
QStringList m_lines;
diff --git a/src/version.h b/src/version.h
index f197345..45298cd 100644
--- a/src/version.h
+++ b/src/version.h
@@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 5
#define VER_X264_PATCH 0
-#define VER_X264_BUILD 940
+#define VER_X264_BUILD 944
#define VER_X264_PORTABLE_EDITION (0)
diff --git a/src/win_main.cpp b/src/win_main.cpp
index 0681324..3ecb53a 100644
--- a/src/win_main.cpp
+++ b/src/win_main.cpp
@@ -187,9 +187,21 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
//Create context menu
QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), ui->logView);
+ QAction *actionSaveToLog = new QAction(QIcon(":/buttons/disk.png"), tr("Save to File..."), ui->logView);
+ QAction *actionSeparator = new QAction(ui->logView);
+ QAction *actionWordwraps = new QAction(QIcon(":/buttons/text_wrapping.png"), tr("Enable Line-Wrapping"), ui->logView);
+ actionSeparator->setSeparator(true);
+ actionWordwraps->setCheckable(true);
actionClipboard->setEnabled(false);
+ actionSaveToLog->setEnabled(false);
+ actionWordwraps->setEnabled(false);
ui->logView->addAction(actionClipboard);
+ ui->logView->addAction(actionSaveToLog);
+ ui->logView->addAction(actionSeparator);
+ ui->logView->addAction(actionWordwraps);
connect(actionClipboard, SIGNAL(triggered(bool)), this, SLOT(copyLogToClipboard(bool)));
+ connect(actionSaveToLog, SIGNAL(triggered(bool)), this, SLOT(saveLogToLocalFile(bool)));
+ connect(actionWordwraps, SIGNAL(triggered(bool)), this, SLOT(toggleLineWrapping(bool)));
ui->jobsView->addActions(ui->menuJob->actions());
//Enable buttons
@@ -497,7 +509,10 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr
{
ui->logView->setModel(m_jobList->getLogFile(current));
connect(ui->logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
- ui->logView->actions().first()->setEnabled(true);
+ foreach(QAction *action, ui->logView->actions())
+ {
+ action->setEnabled(true);
+ }
QTimer::singleShot(0, ui->logView, SLOT(scrollToBottom()));
ui->progressBar->setValue(m_jobList->getJobProgress(current));
@@ -508,7 +523,10 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr
else
{
ui->logView->setModel(NULL);
- ui->logView->actions().first()->setEnabled(false);
+ foreach(QAction *action, ui->logView->actions())
+ {
+ action->setEnabled(false);
+ }
ui->progressBar->setValue(0);
ui->editDetails->clear();
updateButtons(JobStatus_Undefined);
@@ -1036,6 +1054,36 @@ void MainWindow::copyLogToClipboard(bool checked)
}
}
+/*
+ * Save log to local file
+ */
+void MainWindow::saveLogToLocalFile(bool checked)
+{
+ ENSURE_APP_IS_READY();
+
+ const QModelIndex index = ui->jobsView->currentIndex();
+ const QString initialName = index.isValid() ? QFileInfo(m_jobList->getJobOutputFile(index)).completeBaseName() : tr("Logfile");
+ const QString fileName = QFileDialog::getSaveFileName(this, tr("Save Log File"), initialName, tr("Log File (*.log)"));
+ if(!fileName.isEmpty())
+ {
+ if(LogFileModel *log = dynamic_cast(ui->logView->model()))
+ {
+ if(!log->saveToLocalFile(fileName))
+ {
+ QMessageBox::warning(this, this->windowTitle(), tr("Error: Log file could not be saved!"));
+ }
+ }
+ }
+}
+
+/*
+ * Toggle line-wrapping
+ */
+void MainWindow::toggleLineWrapping(bool checked)
+{
+ ui->logView->setWordWrap(checked);
+}
+
/*
* Process the dropped files
*/
diff --git a/src/win_main.h b/src/win_main.h
index c022758..e145798 100644
--- a/src/win_main.h
+++ b/src/win_main.h
@@ -116,6 +116,8 @@ private slots:
void browseButtonPressed(void);
void deleteButtonPressed(void);
void copyLogToClipboard(bool checked);
+ void saveLogToLocalFile(bool checked);
+ void toggleLineWrapping(bool checked);
void checkUpdates(void);
void handlePendingFiles(void);
void init(void);