2
This file is part of Rocs.
3
Copyright 2012 Andreas Cord-Landwehr <cola@uni-paderborn.de>
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
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
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include "ScriptOutputWidget.h"
20
#include "DocumentManager.h"
21
#include "EngineModules/Console/ConsoleModule.h"
23
#include <QtScriptBackend.h>
26
ScriptOutputWidget::ScriptOutputWidget(QWidget* parent)
30
ui = new Ui::ScriptOutputWidget;
34
ui->buttonEnableDebugOutput->setIcon(KIcon("tools-report-bug"));
35
ui->buttonDisableClear->setIcon(KIcon("document-decrypt"));
36
ui->buttonClear->setIcon(KIcon("edit-clear-list"));
38
connect(ui->buttonEnableDebugOutput, SIGNAL(clicked(bool)), this, SLOT(showDebugOutput(bool)));
39
connect(ui->buttonDisableClear, SIGNAL(clicked(bool)), this, SLOT(updateFixOutputButton()));
40
connect(ui->buttonClear, SIGNAL(clicked(bool)), this, SLOT(clear()));
43
void ScriptOutputWidget::unsetConsoleInterface()
46
_console->disconnect(this);
51
void ScriptOutputWidget::setConsoleInterface(ConsoleModule* console)
53
unsetConsoleInterface();
56
connect(console, SIGNAL(backlogChanged(ConsoleModule::MessageType,QString)),
57
this, SLOT(appendOutput(ConsoleModule::MessageType,QString)));
60
ConsoleModule * ScriptOutputWidget::consoleInterface() const
65
void ScriptOutputWidget::updateFixOutputButton()
67
if (ui->buttonDisableClear->isChecked() == true) {
68
ui->buttonDisableClear->setIcon(KIcon("document-encrypt"));
71
ui->buttonDisableClear->setIcon(KIcon("document-decrypt"));
75
void ScriptOutputWidget::clear()
77
ui->dbgOutput->clear();
78
ui->txtOutput->clear();
81
bool ScriptOutputWidget::isOutputClearEnabled() const
83
return !ui->buttonDisableClear->isChecked();
86
void ScriptOutputWidget::appendOutput(ConsoleModule::MessageType type, const QString& message)
90
case ConsoleModule::Log:
91
ui->txtOutput->append(message);
92
ui->dbgOutput->append("<i>" + message + "</i>");
94
case ConsoleModule::Debug:
95
ui->dbgOutput->append("<span style=\"color: green\">" + message + "</span>");
97
case ConsoleModule::Error:
98
ui->txtOutput->append("<b style=\"color: red\">" + message + "</b>");
99
ui->dbgOutput->append("<b style=\"color: red\">" + message + "</b>");
102
kWarning() << "Unknown message type, aborting printing.";
106
void ScriptOutputWidget::showDebugOutput(bool show)
108
if (show && !ui->buttonEnableDebugOutput->isChecked()) {
109
ui->buttonEnableDebugOutput->toggle();
111
if (!show && ui->buttonEnableDebugOutput->isChecked()) {
112
ui->buttonEnableDebugOutput->toggle();
115
ui->output->setCurrentIndex(1);
117
ui->output->setCurrentIndex(0);