source: smplayer/vendor/0.8.1/src/logwindow.cpp

Last change on this file was 121, checked in by Silvan Scherrer, 14 years ago

SMPlayer 0.7.1: vendor update

File size: 3.6 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "logwindow.h"
20#include <QTextEdit>
21#include "filedialog.h"
22#include <QFile>
23#include <QTextStream>
24#include <QMessageBox>
25#include <QFileInfo>
26#include <QPushButton>
27
28#include "images.h"
29
30LogWindow::LogWindow( QWidget* parent )
31 : QWidget(parent, Qt::Window )
32{
33 setupUi(this);
34
35 browser->setFont( QFont("fixed") );
36
37 retranslateStrings();
38}
39
40LogWindow::~LogWindow() {
41}
42
43/*
44QTextEdit * LogWindow::editor() {
45 return browser;
46}
47*/
48
49void LogWindow::retranslateStrings() {
50 retranslateUi(this);
51
52 saveButton->setText("");
53 copyButton->setText("");
54
55 saveButton->setIcon( Images::icon("save") );
56 copyButton->setIcon( Images::icon("copy") );
57
58 setWindowIcon( Images::icon("logo") );
59}
60
61
62void LogWindow::setText(QString log) {
63 browser->setPlainText(log);
64}
65
66QString LogWindow::text() {
67 return browser->toPlainText();
68}
69
70void LogWindow::setHtml(QString text) {
71 browser->setHtml(text);
72}
73
74QString LogWindow::html() {
75 return browser->toHtml();
76}
77
78void LogWindow::clear() {
79 browser->clear();
80}
81
82void LogWindow::appendText(QString text) {
83 browser->moveCursor(QTextCursor::End);
84 browser->insertPlainText(text);
85}
86
87void LogWindow::appendHtml(QString text) {
88 browser->moveCursor(QTextCursor::End);
89 browser->insertHtml(text);
90}
91
92void LogWindow::on_copyButton_clicked() {
93 browser->selectAll();
94 browser->copy();
95}
96
97void LogWindow::on_saveButton_clicked() {
98 QString s = MyFileDialog::getSaveFileName(
99 this, tr("Choose a filename to save under"),
100 "", tr("Logs") +" (*.log *.txt)" );
101
102 if (!s.isEmpty()) {
103 if (QFileInfo(s).exists()) {
104 int res =QMessageBox::question( this,
105 tr("Confirm overwrite?"),
106 tr("The file already exists.\n"
107 "Do you want to overwrite?"),
108 QMessageBox::Yes,