X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiProgress.cpp;h=a21baf338c3042426f2429c4dc2c5bdbd989cab4;hb=82cade48776705e0b1dd39369447ddbd82f23d53;hp=0735265384532e891035c4346f3fecb3a128d498;hpb=d481f75848e77595f3d26ff10d6479eadbc44899;p=lyx.git diff --git a/src/frontends/qt4/GuiProgress.cpp b/src/frontends/qt4/GuiProgress.cpp index 0735265384..a21baf338c 100644 --- a/src/frontends/qt4/GuiProgress.cpp +++ b/src/frontends/qt4/GuiProgress.cpp @@ -17,6 +17,8 @@ #include "qt_helpers.h" +#include "frontends/alert.h" + #include "support/debug.h" #include "support/Systemcall.h" @@ -30,6 +32,10 @@ namespace lyx { namespace frontend { +// This dialog is only a fallback for Qt < 5.2, which does not feature +// QMessageBox::setCheckBox() yet. Note that it has issues with line +// breaking and size, in particular with html. +#if QT_VERSION < 0x050200 class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi { public: @@ -39,41 +45,58 @@ public: QDialog::setModal(true); } }; +#endif -GuiProgress::GuiProgress(GuiView * view) : view_(view) +GuiProgress::GuiProgress() { connect(this, SIGNAL(processStarted(QString const &)), SLOT(doProcessStarted(QString const &))); connect(this, SIGNAL(processFinished(QString const &)), SLOT(doProcessFinished(QString const &))); connect(this, SIGNAL(appendMessage(QString const &)), SLOT(doAppendMessage(QString const &))); connect(this, SIGNAL(appendError(QString const &)), SLOT(doAppendError(QString const &))); connect(this, SIGNAL(clearMessages()), SLOT(doClearMessages())); - + // Alert interface connect(this, SIGNAL(warning(QString const &, QString const &)), SLOT(doWarning(QString const &, QString const &))); connect(this, SIGNAL(toggleWarning(QString const &, QString const &, QString const &)), SLOT(doToggleWarning(QString const &, QString const &, QString const &))); - connect(this, SIGNAL(error(QString const &, QString const &)), - SLOT(doError(QString const &, QString const &))); + connect(this, SIGNAL(error(QString const &, QString const &, QString const &)), + SLOT(doError(QString const &, QString const &, QString const &))); connect(this, SIGNAL(information(QString const &, QString const &)), SLOT(doInformation(QString const &, QString const &))); + connect(this, SIGNAL(triggerFlush()), + SLOT(startFlushing())); + + flushDelay_.setInterval(200); + flushDelay_.setSingleShot(true); + connect(&flushDelay_, SIGNAL(timeout()), this, SLOT(updateWithLyXErr())); +} + - support::ProgressInterface::setInstance(this); +int GuiProgress::prompt(docstring const & title, docstring const & question, + int default_button, int cancel_button, + docstring const & b1, docstring const & b2) +{ + return Alert::prompt(title, question, default_button, cancel_button, b1, b2); +} + + +QString GuiProgress::currentTime() +{ + return QTime::currentTime().toString("hh:mm:ss.zzz"); } void GuiProgress::doProcessStarted(QString const & cmd) { - QString time = QTime::currentTime().toString(); - appendText(time + ": <" + cmd + "> started"); + appendText(currentTime() + ": <" + cmd + "> started"); } void GuiProgress::doProcessFinished(QString const & cmd) { - QString time = QTime::currentTime().toString(); - appendText(time + ": <" + cmd + "> done"); + appendText(currentTime() + ": <" + cmd + "> done"); } @@ -91,11 +114,23 @@ void GuiProgress::doAppendError(QString const & msg) void GuiProgress::doClearMessages() { - view_->message(docstring()); + clearMessageText(); +} + + +void GuiProgress::startFlushing() +{ + flushDelay_.start(); } void GuiProgress::lyxerrFlush() +{ + triggerFlush(); +} + + +void GuiProgress::updateWithLyXErr() { appendLyXErrMessage(toqstr(lyxerr_stream_.str())); lyxerr_stream_.str(""); @@ -104,13 +139,13 @@ void GuiProgress::lyxerrFlush() void GuiProgress::lyxerrConnect() { - lyxerr.setSecond(&lyxerr_stream_); + lyxerr.setSecondStream(&lyxerr_stream_); } void GuiProgress::lyxerrDisconnect() { - lyxerr.setSecond(0); + lyxerr.setSecondStream(0); } @@ -123,7 +158,7 @@ GuiProgress::~GuiProgress() void GuiProgress::appendText(QString const & text) { if (!text.isEmpty()) - view_->updateMessage(text); + updateStatusBarMessage(text); } @@ -139,6 +174,9 @@ void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QS if (settings.value("hidden_warnings/" + msg, false).toBool()) return; +// Qt < 5.2 does not feature QMessageBox::setCheckBox() yet, +// so we roll our own dialog. +#if QT_VERSION < 0x050200 GuiToggleWarningDialog * dlg = new GuiToggleWarningDialog(qApp->focusWidget()); @@ -150,12 +188,28 @@ void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QS if (dlg->dontShowAgainCB->isChecked()) settings.setValue("hidden_warnings/" + msg, true); +#else + QCheckBox * dontShowAgainCB = new QCheckBox(); + dontShowAgainCB->setText(qt_("&Do not show this warning again!")); + dontShowAgainCB->setToolTip(qt_("If you check this, LyX will not warn you again in the given case.")); + QMessageBox box(QMessageBox::Warning, title, formatted, + QMessageBox::Ok, qApp->focusWidget()); + box.setCheckBox(dontShowAgainCB); + if (box.exec() == QMessageBox::Ok) + if (dontShowAgainCB->isChecked()) + settings.setValue("hidden_warnings/" + + msg, true); +#endif } -void GuiProgress::doError(QString const & title, QString const & message) +void GuiProgress::doError(QString const & title, QString const & message, QString const & details) { - QMessageBox::critical(qApp->focusWidget(), title, message); + QMessageBox box(QMessageBox::Critical, title, message, QMessageBox::Ok, qApp->focusWidget()); + if (!details.isEmpty()) { + box.setDetailedText(details); + } + box.exec(); }