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()
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()));
53 connect(this, SIGNAL(warning(QString const &, QString const &)),
54 SLOT(doWarning(QString const &, QString const &)));
55 connect(this, SIGNAL(toggleWarning(QString const &, QString const &, QString const &)),
56 SLOT(doToggleWarning(QString const &, QString const &, QString const &)));
57 connect(this, SIGNAL(error(QString const &, QString const &)),
58 SLOT(doError(QString const &, QString const &)));
59 connect(this, SIGNAL(information(QString const &, QString const &)),
60 SLOT(doInformation(QString const &, QString const &)));
62 flushDelay_.setInterval(200);
63 flushDelay_.setSingleShot(true);
64 connect(&flushDelay_, SIGNAL(timeout()), this, SLOT(updateWithLyXErr()));
68 QString GuiProgress::currentTime()
70 return QTime::currentTime().toString("hh:mm:ss:zzz") + "ms";
74 void GuiProgress::doProcessStarted(QString const & cmd)
76 appendText(currentTime() + ": <" + cmd + "> started");
80 void GuiProgress::doProcessFinished(QString const & cmd)
82 appendText(currentTime() + ": <" + cmd + "> done");
86 void GuiProgress::doAppendMessage(QString const & msg)
92 void GuiProgress::doAppendError(QString const & msg)
98 void GuiProgress::doClearMessages()
104 void GuiProgress::lyxerrFlush()
110 void GuiProgress::updateWithLyXErr()
112 appendLyXErrMessage(toqstr(lyxerr_stream_.str()));
113 lyxerr_stream_.str("");
117 void GuiProgress::lyxerrConnect()
119 lyxerr.setSecond(&lyxerr_stream_);
123 void GuiProgress::lyxerrDisconnect()
129 GuiProgress::~GuiProgress()
135 void GuiProgress::appendText(QString const & text)
138 updateStatusBarMessage(text);
142 void GuiProgress::doWarning(QString const & title, QString const & message)
144 QMessageBox::warning(qApp->focusWidget(), title, message);
148 void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QString const & formatted)
151 if (settings.value("hidden_warnings/" + msg, false).toBool())
154 GuiToggleWarningDialog * dlg =
155 new GuiToggleWarningDialog(qApp->focusWidget());
157 dlg->setWindowTitle(title);
158 dlg->messageLA->setText(formatted);
159 dlg->dontShowAgainCB->setChecked(false);
161 if (dlg->exec() == QDialog::Accepted)
162 if (dlg->dontShowAgainCB->isChecked())
163 settings.setValue("hidden_warnings/"
168 void GuiProgress::doError(QString const & title, QString const & message)
170 QMessageBox::critical(qApp->focusWidget(), title, message);
174 void GuiProgress::doInformation(QString const & title, QString const & message)
176 QMessageBox::information(qApp->focusWidget(), title, message);
180 } // namespace frontend
183 #include "moc_GuiProgress.cpp"