Added option to enable line-wrapping + added option for saving the log to file.
This commit is contained in:
parent
f43589facb
commit
8e4e381408
BIN
res/buttons/text_wrapping.png
Normal file
BIN
res/buttons/text_wrapping.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 271 B |
@ -46,6 +46,7 @@
|
||||
<file>buttons/shield_green.png</file>
|
||||
<file>buttons/shield_grey.png</file>
|
||||
<file>buttons/suspended.png</file>
|
||||
<file>buttons/text_wrapping.png</file>
|
||||
<file>buttons/transmit.png</file>
|
||||
<file>buttons/trash.png</file>
|
||||
<file>buttons/update.png</file>
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
|
||||
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
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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<LogFileModel*>(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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user