]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiProgress.cpp
add progress widget
[lyx.git] / src / frontends / qt4 / GuiProgress.cpp
1 // -*- C++ -*-
2 /**
3  * \file GuiProgress.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Peter Kümmel
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiProgress.h"
15
16 #include "qt_helpers.h"
17
18 #include "support/Systemcall.h"
19
20 #include <QApplication>
21 #include <QDebug>
22
23
24 namespace lyx {
25 namespace frontend {
26
27
28
29 GuiProgress::GuiProgress(GuiView & parent, Qt::DockWidgetArea area, 
30         Qt::WindowFlags flags) : DockView(parent, "progress", "External tools", area, flags)
31 {
32         setWindowTitle(qt_("Tool monitoring"));
33         setWidget(&text_edit);
34         text_edit.setReadOnly(true);
35
36         connect(this, SIGNAL(processStarted(QString const &)), SLOT(doProcessStarted(QString const &)));
37         connect(this, SIGNAL(processFinished(QString const &)), SLOT(doProcessFinished(QString const &)));
38         connect(this, SIGNAL(appendMessage(QString const &)), SLOT(doAppendMessage(QString const &)));
39         connect(this, SIGNAL(appendError(QString const &)), SLOT(doAppendError(QString const &)));
40         connect(this, SIGNAL(clearMessages()), SLOT(doClearMessages()));
41 }
42
43
44 void GuiProgress::doProcessStarted(QString const & cmd)
45 {
46         appendText("Process started : " + cmd + "\n");
47 }
48
49
50 void GuiProgress::doProcessFinished(QString const & cmd)
51 {
52         appendText("Process finished: " + cmd + "\n");
53 }
54
55
56 void GuiProgress::doAppendMessage(QString const & msg)
57 {
58         // No good messages from the processes
59         //appendText(msg);
60 }
61
62
63 void GuiProgress::doAppendError(QString const & msg)
64 {
65         appendText(msg);
66 }
67
68
69 void GuiProgress::doClearMessages()
70 {
71         text_edit.clear();
72 }
73
74
75 void GuiProgress::appendText(QString const & text)
76 {
77         text_edit.insertPlainText(text);
78         text_edit.ensureCursorVisible();
79 }
80
81
82 void GuiProgress::showEvent(QShowEvent*)
83 {
84         support::ProgressInterface::setInstance(this);
85 }
86
87
88 void GuiProgress::hideEvent(QHideEvent*)
89 {
90         support::ProgressInterface::setInstance(0);
91 }
92
93
94
95 Dialog * createGuiProgress(GuiView & lv)
96 {
97         GuiView & guiview = static_cast<GuiView &>(lv);
98 #ifdef Q_WS_MACX
99         // TODO where to show up on the Mac?
100         //return new GuiProgress(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
101 #else
102         return new GuiProgress(guiview, Qt::BottomDockWidgetArea);
103 #endif
104 }
105
106
107
108 } // namespace frontend
109 } // namespace lyx
110
111 #include "moc_GuiProgress.cpp"