]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiProgressView.cpp
377a3c5640b3ed0db50dc2d75e2432d7eed362ae
[lyx.git] / src / frontends / qt4 / GuiProgressView.cpp
1 // -*- C++ -*-
2 /**
3  * \file GuiProgressView.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 "GuiProgressView.h"
15
16 #include "qt_helpers.h"
17
18
19
20 namespace lyx {
21 namespace frontend {
22
23
24
25
26 GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area, 
27         Qt::WindowFlags flags) : DockView(parent, "progress", "Progress monitoring", area, flags)
28 {
29         setWindowTitle(qt_("Progress monitoring"));
30         setWidget(&text_edit);
31         text_edit.setReadOnly(true);
32
33         GuiProgress* progress = dynamic_cast<GuiProgress*>(support::ProgressInterface::instance());
34
35         if (progress) {
36                 connect(progress, SIGNAL(processStarted(QString const &)), this, SLOT(appendText(QString const &)));
37                 connect(progress, SIGNAL(processFinished(QString const &)), this, SLOT(appendText(QString const &)));
38                 connect(progress, SIGNAL(appendMessage(QString const &)), this, SLOT(appendText(QString const &)));
39                 connect(progress, SIGNAL(appendError(QString const &)), this, SLOT(appendText(QString const &)));
40                 connect(progress, SIGNAL(clearMessages()), this, SLOT(clearText(QString const &)));
41         }
42 }
43
44
45 void GuiProgressView::clearText()
46 {
47         text_edit.clear();
48 }
49
50
51 void GuiProgressView::appendText(QString const & text)
52 {
53         text_edit.insertPlainText(text);
54         text_edit.ensureCursorVisible();
55 }
56
57
58
59
60
61 Dialog * createGuiProgressView(GuiView & guiview)
62 {
63 #ifdef Q_WS_MACX
64         return new GuiProgressView(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
65 #else
66         return new GuiProgressView(guiview, Qt::BottomDockWidgetArea);
67 #endif
68 }
69
70
71
72 } // namespace frontend
73 } // namespace lyx
74
75 #include "moc_GuiProgressView.cpp"