3 * \file GuiProgressView.cpp
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
15 #include "GuiProgressView.h"
16 #include "GuiApplication.h"
18 #include "qt_helpers.h"
20 #include "support/debug.h"
25 #include <QRadioButton>
26 #include <QButtonGroup>
32 struct LevelButton : QRadioButton
34 LevelButton(const QString& name) : QRadioButton(name) {}
39 ProgressViewWidget::ProgressViewWidget()
46 GuiProgressView::~GuiProgressView()
52 GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
53 Qt::WindowFlags flags) : DockView(parent, "progress", "Debug/Progress window", area, flags)
55 widget_ = new ProgressViewWidget();
58 QFont font(guiApp->typewriterFontName());
59 font.setKerning(false);
60 font.setFixedPitch(true);
61 font.setStyleHint(QFont::TypeWriter);
62 widget_->outTE->setFont(font);
64 QButtonGroup* button_group = new QButtonGroup(this);
65 const std::vector<Debug::Type> levels = Debug::levels();
66 for (unsigned int i = 0; i < levels.size(); i++) {
67 LevelButton * box = new LevelButton(toqstr(Debug::description(levels[i])));
68 box->level = levels[i];
69 widget_->settingsLayout->addWidget(box);
70 button_group->addButton(box);
72 connect(button_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(levelChanged(QAbstractButton*)));
74 button_group->buttons().front()->setChecked(true);
76 GuiProgress* progress = dynamic_cast<GuiProgress*>(support::ProgressInterface::instance());
79 connect(progress, SIGNAL(processStarted(QString const &)), this, SLOT(appendText(QString const &)));
80 //connect(progress, SIGNAL(processFinished(QString const &)), this, SLOT(appendText(QString const &)));
81 connect(progress, SIGNAL(appendMessage(QString const &)), this, SLOT(appendText(QString const &)));
82 connect(progress, SIGNAL(appendError(QString const &)), this, SLOT(appendText(QString const &)));
83 connect(progress, SIGNAL(clearMessages()), this, SLOT(clearText()));
84 progress->lyxerrConnect();
89 void GuiProgressView::levelChanged(QAbstractButton* b)
91 LevelButton* lb = dynamic_cast<LevelButton*>(b);
93 lyxerr.level(lb->level);
97 void GuiProgressView::clearText()
99 if (widget_->autoClearCB->isChecked())
100 widget_->outTE->clear();
104 void GuiProgressView::appendText(QString const & text)
108 QString time = QTime::currentTime().toString();
109 if (text.endsWith("\n"))
110 widget_->outTE->insertPlainText(time + ": " + text);
112 widget_->outTE->insertPlainText(text);
114 widget_->outTE->ensureCursorVisible();
118 void GuiProgressView::saveSession() const
120 Dialog::saveSession();
123 sessionKey() + "/autoclear", widget_->autoClearCB->isChecked());
127 void GuiProgressView::restoreSession()
129 DockView::restoreSession();
131 widget_->autoClearCB->setChecked(
132 settings.value(sessionKey() + "/autoclear", true).toBool());
136 void GuiProgressView::showEvent(QShowEvent*)
138 support::ProgressInterface::instance()->lyxerrConnect();
142 void GuiProgressView::hideEvent(QHideEvent*)
144 support::ProgressInterface::instance()->lyxerrDisconnect();
150 Dialog * createGuiProgressView(GuiView & guiview)
153 return new GuiProgressView(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
155 return new GuiProgressView(guiview, Qt::BottomDockWidgetArea);
161 } // namespace frontend
164 #include "moc_GuiProgressView.cpp"