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 GuiProgress::GuiProgress()
37 connect(this, SIGNAL(processStarted(QString const &)), SLOT(doProcessStarted(QString const &)));
38 connect(this, SIGNAL(processFinished(QString const &)), SLOT(doProcessFinished(QString const &)));
39 connect(this, SIGNAL(appendMessage(QString const &)), SLOT(doAppendMessage(QString const &)));
40 connect(this, SIGNAL(appendError(QString const &)), SLOT(doAppendError(QString const &)));
41 connect(this, SIGNAL(clearMessages()), SLOT(doClearMessages()));
44 connect(this, SIGNAL(warning(QString const &, QString const &)),
45 SLOT(doWarning(QString const &, QString const &)));
46 connect(this, SIGNAL(toggleWarning(QString const &, QString const &, QString const &)),
47 SLOT(doToggleWarning(QString const &, QString const &, QString const &)));
48 connect(this, SIGNAL(error(QString const &, QString const &, QString const &)),
49 SLOT(doError(QString const &, QString const &, QString const &)));
50 connect(this, SIGNAL(information(QString const &, QString const &)),
51 SLOT(doInformation(QString const &, QString const &)));
52 connect(this, SIGNAL(triggerFlush()),
53 SLOT(startFlushing()));
55 flushDelay_.setInterval(200);
56 flushDelay_.setSingleShot(true);
57 connect(&flushDelay_, SIGNAL(timeout()), this, SLOT(updateWithLyXErr()));
61 int GuiProgress::prompt(docstring const & title, docstring const & question,
62 int default_button, int cancel_button,
63 docstring const & b1, docstring const & b2)
65 return Alert::prompt(title, question, default_button, cancel_button, b1, b2);
69 QString GuiProgress::currentTime()
71 return QTime::currentTime().toString("hh:mm:ss.zzz");
75 void GuiProgress::doProcessStarted(QString const & cmd)
77 appendText(currentTime() + ": <" + cmd + "> started");
81 void GuiProgress::doProcessFinished(QString const & cmd)
83 appendText(currentTime() + ": <" + cmd + "> done");
87 void GuiProgress::doAppendMessage(QString const & msg)
93 void GuiProgress::doAppendError(QString const & msg)
99 void GuiProgress::doClearMessages()
105 void GuiProgress::startFlushing()
111 void GuiProgress::lyxerrFlush()
117 void GuiProgress::updateWithLyXErr()
119 appendLyXErrMessage(toqstr(lyxerr_stream_.str()));
120 lyxerr_stream_.str("");
124 void GuiProgress::lyxerrConnect()
126 lyxerr.setSecondStream(&lyxerr_stream_);
130 void GuiProgress::lyxerrDisconnect()
132 lyxerr.setSecondStream(0);
136 GuiProgress::~GuiProgress()
142 void GuiProgress::appendText(QString const & text)
145 updateStatusBarMessage(text);
149 void GuiProgress::doWarning(QString const & title, QString const & message)
151 QMessageBox::warning(qApp->focusWidget(), title, message);
155 void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QString const & formatted)
158 if (settings.value("hidden_warnings/" + msg, false).toBool())
161 QCheckBox * dontShowAgainCB = new QCheckBox();
162 dontShowAgainCB->setText(qt_("&Do not show this warning again!"));
163 dontShowAgainCB->setToolTip(qt_("If you check this, LyX will not warn you again in the given case."));
164 QMessageBox box(QMessageBox::Warning, title, formatted,
165 QMessageBox::Ok, qApp->focusWidget());
166 box.setCheckBox(dontShowAgainCB);
167 if (box.exec() == QMessageBox::Ok)
168 if (dontShowAgainCB->isChecked())
169 settings.setValue("hidden_warnings/"
174 void GuiProgress::doError(QString const & title, QString const & message, QString const & details)
176 QMessageBox box(QMessageBox::Critical, title, message, QMessageBox::Ok, qApp->focusWidget());
177 if (!details.isEmpty()) {
178 box.setDetailedText(details);
184 void GuiProgress::doInformation(QString const & title, QString const & message)
186 QMessageBox::information(qApp->focusWidget(), title, message);
190 } // namespace frontend
193 #include "moc_GuiProgress.cpp"