2009-12-20 14:26:55 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GuiProgress.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Peter Kümmel
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiProgress.h"
|
2009-12-21 11:48:19 +00:00
|
|
|
#include "ui_ToggleWarningUi.h"
|
2009-12-20 14:26:55 +00:00
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include "support/Systemcall.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
2009-12-21 11:48:19 +00:00
|
|
|
#include <QTime>
|
|
|
|
#include <QMessageBox>
|
2009-12-21 14:52:56 +00:00
|
|
|
#include <QSettings>
|
2009-12-20 14:26:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
2009-12-21 11:48:19 +00:00
|
|
|
class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi
|
2009-12-20 14:26:55 +00:00
|
|
|
{
|
2009-12-21 11:48:19 +00:00
|
|
|
public:
|
|
|
|
GuiToggleWarningDialog(QWidget * parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
Ui::ToggleWarningUi::setupUi(this);
|
|
|
|
QDialog::setModal(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
GuiProgress::GuiProgress(GuiView * view) : view_(view)
|
|
|
|
{
|
2009-12-20 14:26:55 +00:00
|
|
|
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()));
|
2009-12-21 11:48:19 +00:00
|
|
|
|
|
|
|
// 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(information(QString const &, QString const &)),
|
|
|
|
SLOT(doInformation(QString const &, QString const &)));
|
|
|
|
|
|
|
|
support::ProgressInterface::setInstance(this);
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgress::doProcessStarted(QString const & cmd)
|
|
|
|
{
|
2009-12-22 09:26:45 +00:00
|
|
|
QString time = QTime::currentTime().toString();
|
2009-12-21 11:48:19 +00:00
|
|
|
appendText(time + ": <" + cmd + "> started\n");
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgress::doProcessFinished(QString const & cmd)
|
|
|
|
{
|
2009-12-22 09:26:45 +00:00
|
|
|
QString time = QTime::currentTime().toString();
|
2009-12-21 11:48:19 +00:00
|
|
|
appendText(time + ": <" + cmd + "> done\n");
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgress::doAppendMessage(QString const & msg)
|
|
|
|
{
|
2009-12-22 10:33:01 +00:00
|
|
|
QString time = QTime::currentTime().toString();
|
|
|
|
appendText(time + " : " + msg);
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgress::doAppendError(QString const & msg)
|
|
|
|
{
|
2009-12-22 10:33:01 +00:00
|
|
|
QString time = QTime::currentTime().toString();
|
|
|
|
appendText(time + " : " + msg);
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgress::doClearMessages()
|
|
|
|
{
|
2009-12-21 11:48:19 +00:00
|
|
|
view_->message(docstring());
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgress::appendText(QString const & text)
|
|
|
|
{
|
2009-12-21 13:11:17 +00:00
|
|
|
view_->updateMessage(text);
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-21 11:48:19 +00:00
|
|
|
void GuiProgress::doWarning(QString const & title, QString const & message)
|
2009-12-20 14:26:55 +00:00
|
|
|
{
|
2009-12-21 11:48:19 +00:00
|
|
|
QMessageBox::warning(qApp->focusWidget(), title, message);
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-21 11:48:19 +00:00
|
|
|
void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QString const & formatted)
|
2009-12-20 14:26:55 +00:00
|
|
|
{
|
2009-12-21 11:48:19 +00:00
|
|
|
QSettings settings;
|
|
|
|
if (settings.value("hidden_warnings/" + msg, false).toBool())
|
|
|
|
return;
|
|
|
|
|
|
|
|
GuiToggleWarningDialog * dlg =
|
|
|
|
new GuiToggleWarningDialog(qApp->focusWidget());
|
|
|
|
|
|
|
|
dlg->setWindowTitle(title);
|
|
|
|
dlg->messageLA->setText(formatted);
|
|
|
|
dlg->dontShowAgainCB->setChecked(false);
|
2009-12-20 14:26:55 +00:00
|
|
|
|
2009-12-21 11:48:19 +00:00
|
|
|
if (dlg->exec() == QDialog::Accepted)
|
|
|
|
if (dlg->dontShowAgainCB->isChecked())
|
|
|
|
settings.setValue("hidden_warnings/"
|
|
|
|
+ msg, true);
|
|
|
|
}
|
2009-12-20 14:26:55 +00:00
|
|
|
|
|
|
|
|
2009-12-21 11:48:19 +00:00
|
|
|
void GuiProgress::doError(QString const & title, QString const & message)
|
2009-12-20 14:26:55 +00:00
|
|
|
{
|
2009-12-21 11:48:19 +00:00
|
|
|
QMessageBox::critical(qApp->focusWidget(), title, message);
|
2009-12-20 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-21 11:48:19 +00:00
|
|
|
void GuiProgress::doInformation(QString const & title, QString const & message)
|
|
|
|
{
|
|
|
|
QMessageBox::information(qApp->focusWidget(), title, message);
|
|
|
|
}
|
|
|
|
|
2009-12-20 14:26:55 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2009-12-22 12:00:01 +00:00
|
|
|
#include "moc_GuiProgress.cpp"
|