Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 91 lines (77 sloc) 2.632 kb
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
9b687ff @lordmulder Happy New Year 2012!
authored
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
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.
14 //
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.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "Dialog_LogView.h"
23
8977e00 @lordmulder Clean up #include directives: Don't include 'Windows.h' directly, as it'...
authored
24 #include "Global.h"
25
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
26 #include <QClipboard>
27 #include <QFileDialog>
48a23c2 @lordmulder Added a new configuration for initial Qt 5.0 support. Needed a few code-...
authored
28 #include <QMimeData>
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
29
30 LogViewDialog::LogViewDialog(QWidget *parent)
31 :
32 QDialog(parent)
33 {
34 //Init the dialog, from the .ui file
35 setupUi(this);
36 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
5a1ff67 @lordmulder Make more strings translatable.
authored
37
38 //Translate
39 headerText->setText(QString("<b>%1</b><br>%2").arg(tr("Log File"), tr("The log file shows detailed information about the selected job.")));
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
40
41 //Clear
42 textEdit->clear();
43
44 //Enable buttons
45 connect(buttonCopy, SIGNAL(clicked()), this, SLOT(copyButtonClicked()));
46 connect(buttonSave, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
47
48 //Init flags
49 m_clipboardUsed = false;
50 }
51
52 LogViewDialog::~LogViewDialog(void)
53 {
54 if(m_clipboardUsed)
55 {
56 QApplication::clipboard()->clear();
57 }
58 }
59
60 int LogViewDialog::exec(const QStringList &logData)
61 {
62 textEdit->setPlainText(logData.join("\n"));
63 return QDialog::exec();
64 }
65
66 void LogViewDialog::copyButtonClicked(void)
67 {
68 QMimeData *mime = new QMimeData();
69 mime->setData("text/plain", textEdit->toPlainText().toUtf8().constData());
70 QApplication::clipboard()->setMimeData(mime);
71 m_clipboardUsed = true;
571df62 @lordmulder Implement support for Job Objects + improve log view.
authored
72 MessageBeep(MB_ICONINFORMATION);
c0ece99 @lordmulder Implemented logging and added a log file view.
authored
73 }
74
75 void LogViewDialog::saveButtonClicked(void)
76 {
77 QString fileName = QFileDialog::getSaveFileName(this, "Save Log File", QDir::homePath(), "Log Files (*.txt)");
78
79 if(!fileName.isEmpty())
80 {
81 QFile file(fileName);
82 if(file.open(QIODevice::WriteOnly))
83 {
84 QByteArray data = textEdit->toPlainText().toUtf8();
85 data.replace("\n", "\r\n");
86 file.write(data.constData(), data.size());
87 file.close();
88 }
89 }
90 }
Something went wrong with that request. Please try again.