2010-11-22 21:45:00 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2012-01-02 00:52:27 +01:00
|
|
|
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-22 21:45:00 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Dialog_LogView.h"
|
|
|
|
|
2013-01-14 00:37:19 +01:00
|
|
|
//UIC includes
|
|
|
|
#include "../tmp/UIC_LogViewDialog.h"
|
|
|
|
|
|
|
|
//Internal
|
2011-04-11 21:55:34 +02:00
|
|
|
#include "Global.h"
|
|
|
|
|
2013-01-14 00:37:19 +01:00
|
|
|
//Qt includes
|
2010-11-22 21:45:00 +01:00
|
|
|
#include <QClipboard>
|
|
|
|
#include <QFileDialog>
|
2012-04-11 00:44:40 +02:00
|
|
|
#include <QMimeData>
|
2013-01-14 00:37:19 +01:00
|
|
|
#include <QTimer>
|
2010-11-22 21:45:00 +01:00
|
|
|
|
|
|
|
LogViewDialog::LogViewDialog(QWidget *parent)
|
|
|
|
:
|
2013-01-14 00:37:19 +01:00
|
|
|
QDialog(parent),
|
|
|
|
m_acceptIcon(new QIcon(":/icons/accept.png")),
|
|
|
|
m_oldIcon(new QIcon()),
|
|
|
|
ui(new Ui::LogViewDialog)
|
2010-11-22 21:45:00 +01:00
|
|
|
{
|
|
|
|
//Init the dialog, from the .ui file
|
2013-01-14 00:37:19 +01:00
|
|
|
ui->setupUi(this);
|
2010-11-22 21:45:00 +01:00
|
|
|
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
|
2011-01-01 19:28:19 +01:00
|
|
|
|
|
|
|
//Translate
|
2013-01-14 00:37:19 +01:00
|
|
|
ui->headerText->setText(QString("<b>%1</b><br>%2").arg(tr("Log File"), tr("The log file shows detailed information about the selected job.")));
|
2010-11-22 21:45:00 +01:00
|
|
|
|
|
|
|
//Clear
|
2013-01-14 00:37:19 +01:00
|
|
|
ui->textEdit->clear();
|
2010-11-22 21:45:00 +01:00
|
|
|
|
|
|
|
//Enable buttons
|
2013-01-14 00:37:19 +01:00
|
|
|
connect(ui->buttonCopy, SIGNAL(clicked()), this, SLOT(copyButtonClicked()));
|
|
|
|
connect(ui->buttonSave, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
|
2010-11-22 21:45:00 +01:00
|
|
|
|
|
|
|
//Init flags
|
|
|
|
m_clipboardUsed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
LogViewDialog::~LogViewDialog(void)
|
|
|
|
{
|
|
|
|
if(m_clipboardUsed)
|
|
|
|
{
|
|
|
|
QApplication::clipboard()->clear();
|
|
|
|
}
|
2013-01-14 00:37:19 +01:00
|
|
|
|
|
|
|
LAMEXP_DELETE(m_oldIcon);
|
|
|
|
LAMEXP_DELETE(m_acceptIcon);
|
|
|
|
LAMEXP_DELETE(ui);
|
2010-11-22 21:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int LogViewDialog::exec(const QStringList &logData)
|
|
|
|
{
|
2013-01-14 00:37:19 +01:00
|
|
|
ui->textEdit->setPlainText(logData.join("\n"));
|
2010-11-22 21:45:00 +01:00
|
|
|
return QDialog::exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogViewDialog::copyButtonClicked(void)
|
|
|
|
{
|
|
|
|
QMimeData *mime = new QMimeData();
|
2013-01-14 00:37:19 +01:00
|
|
|
mime->setData("text/plain", ui->textEdit->toPlainText().toUtf8().constData());
|
2010-11-22 21:45:00 +01:00
|
|
|
QApplication::clipboard()->setMimeData(mime);
|
|
|
|
m_clipboardUsed = true;
|
2013-01-14 00:37:19 +01:00
|
|
|
m_oldIcon->swap(ui->buttonCopy->icon());
|
|
|
|
ui->buttonCopy->setIcon(*m_acceptIcon);
|
|
|
|
ui->buttonCopy->blockSignals(true);
|
|
|
|
QTimer::singleShot(1250, this, SLOT(restoreIcon()));
|
2010-11-24 21:00:59 +01:00
|
|
|
MessageBeep(MB_ICONINFORMATION);
|
2010-11-22 21:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void LogViewDialog::saveButtonClicked(void)
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, "Save Log File", QDir::homePath(), "Log Files (*.txt)");
|
|
|
|
|
|
|
|
if(!fileName.isEmpty())
|
|
|
|
{
|
|
|
|
QFile file(fileName);
|
|
|
|
if(file.open(QIODevice::WriteOnly))
|
|
|
|
{
|
2013-01-14 00:37:19 +01:00
|
|
|
QByteArray data = ui->textEdit->toPlainText().toUtf8();
|
2010-11-22 21:45:00 +01:00
|
|
|
data.replace("\n", "\r\n");
|
|
|
|
file.write(data.constData(), data.size());
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-14 00:37:19 +01:00
|
|
|
|
|
|
|
void LogViewDialog::restoreIcon(void)
|
|
|
|
{
|
|
|
|
if(!m_oldIcon->isNull())
|
|
|
|
{
|
|
|
|
ui->buttonCopy->setIcon(*m_oldIcon);
|
|
|
|
ui->buttonCopy->blockSignals(false);
|
|
|
|
m_oldIcon->swap(QIcon());
|
|
|
|
}
|
|
|
|
}
|