2010-11-22 21:45:00 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2016-01-03 15:53:42 +01:00
|
|
|
// Copyright (C) 2004-2016 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
|
2013-10-23 20:56:57 +02:00
|
|
|
// (at your option) any later version, but always including the *additional*
|
|
|
|
// restrictions defined in the "License.txt" file.
|
2010-11-22 21:45:00 +01:00
|
|
|
//
|
|
|
|
// 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
|
2014-11-24 18:28:53 +01:00
|
|
|
#include "UIC_LogViewDialog.h"
|
2013-01-14 00:37:19 +01:00
|
|
|
|
|
|
|
//Internal
|
2011-04-11 21:55:34 +02:00
|
|
|
#include "Global.h"
|
|
|
|
|
2014-11-25 02:14:42 +01:00
|
|
|
//MUtils
|
|
|
|
#include <MUtils/Global.h>
|
2014-12-05 21:08:26 +01:00
|
|
|
#include <MUtils/Sound.h>
|
2014-11-25 02:14:42 +01:00
|
|
|
|
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
|
|
|
|
2014-11-25 02:14:42 +01:00
|
|
|
MUTILS_DELETE(m_oldIcon);
|
|
|
|
MUTILS_DELETE(m_acceptIcon);
|
|
|
|
MUTILS_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();
|
2014-11-25 02:14:42 +01:00
|
|
|
mime->setData("text/plain", MUTILS_UTF8(ui->textEdit->toPlainText()));
|
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()));
|
2014-12-05 21:08:26 +01:00
|
|
|
MUtils::Sound::beep(MUtils::Sound::BEEP_NFO);
|
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());
|
|
|
|
}
|
|
|
|
}
|