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
|
2009-12-29 15:05:37 +00:00
|
|
|
* \author Pavel Sanda
|
2009-12-22 10:04:30 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GuiProgressView.h"
|
2009-12-28 22:02:41 +00:00
|
|
|
#include "GuiApplication.h"
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
2009-12-30 17:15:00 +00:00
|
|
|
#include "FuncRequest.h"
|
2009-12-22 10:04:30 +00:00
|
|
|
|
2009-12-25 16:52:03 +00:00
|
|
|
#include "support/debug.h"
|
2009-12-30 17:15:00 +00:00
|
|
|
#include "support/convert.h"
|
2009-12-25 16:52:03 +00:00
|
|
|
|
2009-12-28 21:55:50 +00:00
|
|
|
#include <QSettings>
|
2009-12-22 10:33:01 +00:00
|
|
|
#include <QTime>
|
2009-12-30 14:48:47 +00:00
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
|
2009-12-30 14:48:47 +00:00
|
|
|
struct LevelButton : QCheckBox
|
2009-12-29 15:05:37 +00:00
|
|
|
{
|
2009-12-30 14:48:47 +00:00
|
|
|
LevelButton(const QString& name) : QCheckBox(name) {}
|
2009-12-29 15:05:37 +00:00
|
|
|
Debug::Type level;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-12-28 22:02:41 +00:00
|
|
|
QFont font(guiApp->typewriterFontName());
|
|
|
|
font.setKerning(false);
|
|
|
|
font.setFixedPitch(true);
|
|
|
|
font.setStyleHint(QFont::TypeWriter);
|
|
|
|
widget_->outTE->setFont(font);
|
|
|
|
|
2009-12-30 14:48:47 +00:00
|
|
|
|
2009-12-30 15:09:49 +00:00
|
|
|
const int levelCount = Debug::levelCount();
|
|
|
|
for (int i = 0; i < levelCount; i++) {
|
|
|
|
const Debug::Type level = Debug::value(i);
|
|
|
|
LevelButton * box = new LevelButton(toqstr(Debug::description(level)));
|
|
|
|
box->level = level;
|
2009-12-29 15:05:37 +00:00
|
|
|
widget_->settingsLayout->addWidget(box);
|
2009-12-30 14:48:47 +00:00
|
|
|
// TODO settings
|
|
|
|
box->setChecked(false);
|
|
|
|
level_buttons << box;
|
2009-12-30 15:09:49 +00:00
|
|
|
connect(box, SIGNAL(stateChanged(int)), this, SLOT(levelChanged()));
|
2009-12-29 15:05:37 +00:00
|
|
|
}
|
2009-12-30 14:48:47 +00:00
|
|
|
|
2009-12-29 15:05:37 +00:00
|
|
|
|
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-29 15:05:37 +00:00
|
|
|
progress->lyxerrConnect();
|
2009-12-22 10:04:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-30 14:48:47 +00:00
|
|
|
void GuiProgressView::levelChanged()
|
2009-12-29 15:05:37 +00:00
|
|
|
{
|
2009-12-30 14:48:47 +00:00
|
|
|
int level = Debug::NONE;
|
|
|
|
Q_FOREACH(const LevelButton* button, level_buttons) {
|
|
|
|
if (button->isChecked())
|
2009-12-30 15:09:49 +00:00
|
|
|
// Debug::NONE overwrites other levels
|
|
|
|
if (button->level == Debug::NONE) {
|
2009-12-30 17:15:00 +00:00
|
|
|
level = Debug::NONE;
|
|
|
|
break;
|
2009-12-30 15:09:49 +00:00
|
|
|
} else {
|
|
|
|
level |= button->level;
|
|
|
|
}
|
2009-12-30 14:48:47 +00:00
|
|
|
}
|
2009-12-30 17:15:00 +00:00
|
|
|
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<std::string>(level)));
|
2009-12-29 15:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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-29 15:05:37 +00:00
|
|
|
if (text.endsWith("\n"))
|
|
|
|
widget_->outTE->insertPlainText(time + ": " + text);
|
|
|
|
else
|
|
|
|
widget_->outTE->insertPlainText(text);
|
|
|
|
|
2009-12-28 21:40:14 +00:00
|
|
|
widget_->outTE->ensureCursorVisible();
|
2009-12-22 10:04:30 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 15:05:37 +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());
|
|
|
|
}
|
|
|
|
|
2009-12-29 15:05:37 +00:00
|
|
|
|
2009-12-28 21:55:50 +00:00
|
|
|
void GuiProgressView::restoreSession()
|
|
|
|
{
|
|
|
|
DockView::restoreSession();
|
|
|
|
QSettings settings;
|
|
|
|
widget_->autoClearCB->setChecked(
|
|
|
|
settings.value(sessionKey() + "/autoclear", true).toBool());
|
|
|
|
}
|
2009-12-22 10:04:30 +00:00
|
|
|
|
|
|
|
|
2009-12-29 15:05:37 +00:00
|
|
|
void GuiProgressView::showEvent(QShowEvent*)
|
|
|
|
{
|
|
|
|
support::ProgressInterface::instance()->lyxerrConnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiProgressView::hideEvent(QHideEvent*)
|
|
|
|
{
|
|
|
|
support::ProgressInterface::instance()->lyxerrDisconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|