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 "frontends/alert.h"
22 #include "support/debug.h"
23 #include "support/Systemcall.h"
25 #include <QApplication>
27 #include <QMessageBox>
35 class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi
38 GuiToggleWarningDialog(QWidget * parent) : QDialog(parent)
40 Ui::ToggleWarningUi::setupUi(this);
41 QDialog::setModal(true);
46 GuiProgress::GuiProgress()
48 connect(this, SIGNAL(processStarted(QString const &)), SLOT(doProcessStarted(QString const &)));
49 connect(this, SIGNAL(processFinished(QString const &)), SLOT(doProcessFinished(QString const &)));
50 connect(this, SIGNAL(appendMessage(QString const &)), SLOT(doAppendMessage(QString const &)));
51 connect(this, SIGNAL(appendError(QString const &)), SLOT(doAppendError(QString const &)));
52 connect(this, SIGNAL(clearMessages()), SLOT(doClearMessages()));
55 connect(this, SIGNAL(warning(QString const &, QString const &)),
56 SLOT(doWarning(QString const &, QString const &)));
57 connect(this, SIGNAL(toggleWarning(QString const &, QString const &, QString const &)),
58 SLOT(doToggleWarning(QString const &, QString const &, QString const &)));
59 connect(this, SIGNAL(error(QString const &, QString const &, QString const &)),
60 SLOT(doError(QString const &, QString const &, QString const &)));
61 connect(this, SIGNAL(information(QString const &, QString const &)),
62 SLOT(doInformation(QString const &, QString const &)));
63 connect(this, SIGNAL(triggerFlush()),
64 SLOT(startFlushing()));
66 flushDelay_.setInterval(200);
67 flushDelay_.setSingleShot(true);
68 connect(&flushDelay_, SIGNAL(timeout()), this, SLOT(updateWithLyXErr()));
72 int GuiProgress::prompt(docstring const & title, docstring const & question,
73 int default_button, int cancel_button,
74 docstring const & b1, docstring const & b2)
76 return Alert::prompt(title, question, default_button, cancel_button, b1, b2);
80 QString GuiProgress::currentTime()
82 return QTime::currentTime().toString("hh:mm:ss.zzz");
86 void GuiProgress::doProcessStarted(QString const & cmd)
88 appendText(currentTime() + ": <" + cmd + "> started");
92 void GuiProgress::doProcessFinished(QString const & cmd)
94 appendText(currentTime() + ": <" + cmd + "> done");
98 void GuiProgress::doAppendMessage(QString const & msg)
104 void GuiProgress::doAppendError(QString const & msg)
110 void GuiProgress::doClearMessages()
116 void GuiProgress::startFlushing()
122 void GuiProgress::lyxerrFlush()
128 void GuiProgress::updateWithLyXErr()
130 appendLyXErrMessage(toqstr(lyxerr_stream_.str()));
131 lyxerr_stream_.str("");
135 void GuiProgress::lyxerrConnect()
137 lyxerr.setSecondStream(&lyxerr_stream_);
141 void GuiProgress::lyxerrDisconnect()
143 lyxerr.setSecondStream(0);
147 GuiProgress::~GuiProgress()
153 void GuiProgress::appendText(QString const & text)
156 updateStatusBarMessage(text);
160 void GuiProgress::doWarning(QString const & title, QString const & message)
162 QMessageBox::warning(qApp->focusWidget(), title, message);
166 void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QString const & formatted)
169 if (settings.value("hidden_warnings/" + msg, false).toBool())
172 GuiToggleWarningDialog * dlg =
173 new GuiToggleWarningDialog(qApp->focusWidget());
175 dlg->setWindowTitle(title);
176 dlg->messageLA->setText(formatted);
177 dlg->dontShowAgainCB->setChecked(false);
179 if (dlg->exec() == QDialog::Accepted)
180 if (dlg->dontShowAgainCB->isChecked())
181 settings.setValue("hidden_warnings/"
186 void GuiProgress::doError(QString const & title, QString const & message, QString const & details)
188 QMessageBox box(QMessageBox::Critical, title, message, QMessageBox::Ok, qApp->focusWidget());
189 if (!details.isEmpty()) {
190 box.setDetailedText(details);
196 void GuiProgress::doInformation(QString const & title, QString const & message)
198 QMessageBox::information(qApp->focusWidget(), title, message);
202 } // namespace frontend
205 #include "moc_GuiProgress.cpp"