Fix typos.
[LameXP.git] / src / Dialog_LogView.cpp
blob62b320d694254ccc96fab56a659151aca5ff85ae
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
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.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Dialog_LogView.h"
24 #include <QClipboard>
25 #include <QFileDialog>
26 #include <Windows.h>
28 LogViewDialog::LogViewDialog(QWidget *parent)
30 QDialog(parent)
32 //Init the dialog, from the .ui file
33 setupUi(this);
34 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
36 //Translate
37 headerText->setText(QString("<b>%1</b><br>%2").arg(tr("Log File"), tr("The log file shows detailed information about the selected job.")));
39 //Clear
40 textEdit->clear();
42 //Enable buttons
43 connect(buttonCopy, SIGNAL(clicked()), this, SLOT(copyButtonClicked()));
44 connect(buttonSave, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
46 //Init flags
47 m_clipboardUsed = false;
50 LogViewDialog::~LogViewDialog(void)
52 if(m_clipboardUsed)
54 QApplication::clipboard()->clear();
58 int LogViewDialog::exec(const QStringList &logData)
60 textEdit->setPlainText(logData.join("\n"));
61 return QDialog::exec();
64 void LogViewDialog::copyButtonClicked(void)
66 QMimeData *mime = new QMimeData();
67 mime->setData("text/plain", textEdit->toPlainText().toUtf8().constData());
68 QApplication::clipboard()->setMimeData(mime);
69 m_clipboardUsed = true;
70 MessageBeep(MB_ICONINFORMATION);
73 void LogViewDialog::saveButtonClicked(void)
75 QString fileName = QFileDialog::getSaveFileName(this, "Save Log File", QDir::homePath(), "Log Files (*.txt)");
77 if(!fileName.isEmpty())
79 QFile file(fileName);
80 if(file.open(QIODevice::WriteOnly))
82 QByteArray data = textEdit->toPlainText().toUtf8();
83 data.replace("\n", "\r\n");
84 file.write(data.constData(), data.size());
85 file.close();