3 * \file GuiProgress.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 "GuiProgress.h"
16 #include "ui_ToggleWarningUi.h"
18 #include "qt_helpers.h"
20 #include "support/debug.h"
21 #include "support/Systemcall.h"
23 #include <QApplication>
25 #include <QMessageBox>
33 class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi
36 GuiToggleWarningDialog(QWidget * parent) : QDialog(parent)
38 Ui::ToggleWarningUi::setupUi(this);
39 QDialog::setModal(true);
44 GuiProgress::GuiProgress(GuiView * view) : view_(view)
46 connect(this, SIGNAL(processStarted(QString const &)), SLOT(doProcessStarted(QString const &)));
47 connect(this, SIGNAL(processFinished(QString const &)), SLOT(doProcessFinished(QString const &)));
48 connect(this, SIGNAL(appendMessage(QString const &)), SLOT(doAppendMessage(QString const &)));
49 connect(this, SIGNAL(appendError(QString const &)), SLOT(doAppendError(QString const &)));
50 connect(this, SIGNAL(clearMessages()), SLOT(doClearMessages()));
51 connect(this, SIGNAL(lyxerrFlush()), SLOT(dolyxerrFlush()));
54 connect(this, SIGNAL(warning(QString const &, QString const &)),
55 SLOT(doWarning(QString const &, QString const &)));
56 connect(this, SIGNAL(toggleWarning(QString const &, QString const &, QString const &)),
57 SLOT(doToggleWarning(QString const &, QString const &, QString const &)));
58 connect(this, SIGNAL(error(QString const &, QString const &)),
59 SLOT(doError(QString const &, QString const &)));
60 connect(this, SIGNAL(information(QString const &, QString const &)),
61 SLOT(doInformation(QString const &, QString const &)));
63 support::ProgressInterface::setInstance(this);
67 void GuiProgress::doProcessStarted(QString const & cmd)
69 QString time = QTime::currentTime().toString();
70 appendText(time + ": <" + cmd + "> started");
74 void GuiProgress::doProcessFinished(QString const & cmd)
76 QString time = QTime::currentTime().toString();
77 appendText(time + ": <" + cmd + "> done");
81 void GuiProgress::doAppendMessage(QString const & msg)
87 void GuiProgress::doAppendError(QString const & msg)
93 void GuiProgress::doClearMessages()
95 view_->message(docstring());
99 void GuiProgress::dolyxerrFlush()
101 appendLyXErrMessage(toqstr(lyxerr_stream_.str()));
102 lyxerr_stream_.str("");
106 void GuiProgress::lyxerrConnect()
108 lyxerr.setSecond(&lyxerr_stream_);
112 void GuiProgress::lyxerrDisconnect()
118 GuiProgress::~GuiProgress()
124 void GuiProgress::appendText(QString const & text)
127 view_->updateMessage(text);
131 void GuiProgress::doWarning(QString const & title, QString const & message)
133 QMessageBox::warning(qApp->focusWidget(), title, message);
137 void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QString const & formatted)
140 if (settings.value("hidden_warnings/" + msg, false).toBool())
143 GuiToggleWarningDialog * dlg =
144 new GuiToggleWarningDialog(qApp->focusWidget());
146 dlg->setWindowTitle(title);
147 dlg->messageLA->setText(formatted);
148 dlg->dontShowAgainCB->setChecked(false);
150 if (dlg->exec() == QDialog::Accepted)
151 if (dlg->dontShowAgainCB->isChecked())
152 settings.setValue("hidden_warnings/"
157 void GuiProgress::doError(QString const & title, QString const & message)
159 QMessageBox::critical(qApp->focusWidget(), title, message);
163 void GuiProgress::doInformation(QString const & title, QString const & message)
165 QMessageBox::information(qApp->focusWidget(), title, message);
169 } // namespace frontend
172 #include "moc_GuiProgress.cpp"