1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "Dialog_LogView.h"
26 #include "../tmp/UIC_LogViewDialog.h"
33 #include <QFileDialog>
37 LogViewDialog::LogViewDialog(QWidget
*parent
)
40 m_acceptIcon(new QIcon(":/icons/accept.png")),
41 m_oldIcon(new QIcon()),
42 ui(new Ui::LogViewDialog
)
44 //Init the dialog, from the .ui file
46 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint
);
49 ui
->headerText
->setText(QString("<b>%1</b><br>%2").arg(tr("Log File"), tr("The log file shows detailed information about the selected job.")));
52 ui
->textEdit
->clear();
55 connect(ui
->buttonCopy
, SIGNAL(clicked()), this, SLOT(copyButtonClicked()));
56 connect(ui
->buttonSave
, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
59 m_clipboardUsed
= false;
62 LogViewDialog::~LogViewDialog(void)
66 QApplication::clipboard()->clear();
69 LAMEXP_DELETE(m_oldIcon
);
70 LAMEXP_DELETE(m_acceptIcon
);
74 int LogViewDialog::exec(const QStringList
&logData
)
76 ui
->textEdit
->setPlainText(logData
.join("\n"));
77 return QDialog::exec();
80 void LogViewDialog::copyButtonClicked(void)
82 QMimeData
*mime
= new QMimeData();
83 mime
->setData("text/plain", QUTF8(ui
->textEdit
->toPlainText()));
84 QApplication::clipboard()->setMimeData(mime
);
85 m_clipboardUsed
= true;
86 m_oldIcon
->swap(ui
->buttonCopy
->icon());
87 ui
->buttonCopy
->setIcon(*m_acceptIcon
);
88 ui
->buttonCopy
->blockSignals(true);
89 QTimer::singleShot(1250, this, SLOT(restoreIcon()));
90 lamexp_beep(lamexp_beep_info
);
93 void LogViewDialog::saveButtonClicked(void)
95 QString fileName
= QFileDialog::getSaveFileName(this, "Save Log File", QDir::homePath(), "Log Files (*.txt)");
97 if(!fileName
.isEmpty())
100 if(file
.open(QIODevice::WriteOnly
))
102 QByteArray data
= ui
->textEdit
->toPlainText().toUtf8();
103 data
.replace("\n", "\r\n");
104 file
.write(data
.constData(), data
.size());
110 void LogViewDialog::restoreIcon(void)
112 if(!m_oldIcon
->isNull())
114 ui
->buttonCopy
->setIcon(*m_oldIcon
);
115 ui
->buttonCopy
->blockSignals(false);
116 m_oldIcon
->swap(QIcon());