2009-12-22 10:04:30 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GuiProgressView.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 "GuiProgressView.h"
|
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2009-12-25 16:52:03 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
|
2009-12-28 21:55:50 +00:00
|
|
|
#include <QSettings>
|
2009-12-22 10:33:01 +00:00
|
|
|
#include <QTime>
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
2009-12-28 21:40:14 +00:00
|
|
|
ProgressViewWidget::ProgressViewWidget()
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GuiProgressView::~GuiProgressView()
|
|
|
|
{
|
|
|
|
delete widget_;
|
|
|
|
}
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
|
2009-12-28 21:40:14 +00:00
|
|
|
Qt::WindowFlags flags) : DockView(parent, "progress", "Debug/Progress window", area, flags)
|
2009-12-22 10:04:30 +00:00
|
|
|
{
|
2009-12-28 21:40:14 +00:00
|
|
|
widget_ = new ProgressViewWidget();
|
|
|
|
setWidget(widget_);
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
GuiProgress* progress = dynamic_cast<GuiProgress*>(support::ProgressInterface::instance());
|
|
|
|
|
|
|
|
if (progress) {
|
|
|
|
connect(progress, SIGNAL(processStarted(QString const &)), this, SLOT(appendText(QString const &)));
|
2009-12-22 10:33:01 +00:00
|
|
|
//connect(progress, SIGNAL(processFinished(QString const &)), this, SLOT(appendText(QString const &)));
|
2009-12-22 10:04:30 +00:00
|
|
|
connect(progress, SIGNAL(appendMessage(QString const &)), this, SLOT(appendText(QString const &)));
|
|
|
|
connect(progress, SIGNAL(appendError(QString const &)), this, SLOT(appendText(QString const &)));
|
2009-12-22 10:33:01 +00:00
|
|
|
connect(progress, SIGNAL(clearMessages()), this, SLOT(clearText()));
|
2009-12-22 10:04:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgressView::clearText()
|
|
|
|
{
|
2009-12-28 21:40:20 +00:00
|
|
|
if (widget_->autoClearCB->isChecked())
|
|
|
|
widget_->outTE->clear();
|
2009-12-22 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgressView::appendText(QString const & text)
|
|
|
|
{
|
2009-12-22 10:33:01 +00:00
|
|
|
if (text.isEmpty())
|
|
|
|
return;
|
|
|
|
QString time = QTime::currentTime().toString();
|
2009-12-28 21:40:14 +00:00
|
|
|
widget_->outTE->insertPlainText(time + ": " + text.trimmed() + "\n");
|
|
|
|
widget_->outTE->ensureCursorVisible();
|
2009-12-22 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
2009-12-28 21:55:50 +00:00
|
|
|
void GuiProgressView::saveSession() const
|
|
|
|
{
|
|
|
|
Dialog::saveSession();
|
|
|
|
QSettings settings;
|
|
|
|
settings.setValue(
|
|
|
|
sessionKey() + "/autoclear", widget_->autoClearCB->isChecked());
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiProgressView::restoreSession()
|
|
|
|
{
|
|
|
|
DockView::restoreSession();
|
|
|
|
QSettings settings;
|
|
|
|
widget_->autoClearCB->setChecked(
|
|
|
|
settings.value(sessionKey() + "/autoclear", true).toBool());
|
|
|
|
}
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
Dialog * createGuiProgressView(GuiView & guiview)
|
|
|
|
{
|
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
return new GuiProgressView(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
|
|
|
|
#else
|
|
|
|
return new GuiProgressView(guiview, Qt::BottomDockWidgetArea);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2009-12-25 16:52:03 +00:00
|
|
|
#include "moc_GuiProgressView.cpp"
|