OptItem "View Master Document|M" "master-buffer-view"
OptItem "Update Master Document|a" "master-buffer-update"
Separator
+ Item "Show process messages" "dialog-toggle progress"
Item "Split View Into Left and Right Half|i" "split-view horizontal"
Item "Split View Into Upper and Lower Half|e" "split-view vertical"
Item "Close Current View|w" "close-tab-group"
- Item "Fullscreen|l" "ui-toggle fullscreen"
+ Item "Fullscreen|l" "ui-toggle fullscreen"
Submenu "Toolbars|b" "toolbars"
Separator
Documents
--- /dev/null
+// -*- 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"
+
+#include "qt_helpers.h"
+
+#include "support/Systemcall.h"
+
+#include <QApplication>
+#include <QDebug>
+
+
+namespace lyx {
+namespace frontend {
+
+
+
+GuiProgress::GuiProgress(GuiView & parent, Qt::DockWidgetArea area,
+ Qt::WindowFlags flags) : DockView(parent, "progress", "External tools", area, flags)
+{
+ setWindowTitle(qt_("Tool monitoring"));
+ setWidget(&text_edit);
+ text_edit.setReadOnly(true);
+
+ 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()));
+}
+
+
+void GuiProgress::doProcessStarted(QString const & cmd)
+{
+ appendText("Process started : " + cmd + "\n");
+}
+
+
+void GuiProgress::doProcessFinished(QString const & cmd)
+{
+ appendText("Process finished: " + cmd + "\n");
+}
+
+
+void GuiProgress::doAppendMessage(QString const & msg)
+{
+ // No good messages from the processes
+ //appendText(msg);
+}
+
+
+void GuiProgress::doAppendError(QString const & msg)
+{
+ appendText(msg);
+}
+
+
+void GuiProgress::doClearMessages()
+{
+ text_edit.clear();
+}
+
+
+void GuiProgress::appendText(QString const & text)
+{
+ text_edit.insertPlainText(text);
+ text_edit.ensureCursorVisible();
+}
+
+
+void GuiProgress::showEvent(QShowEvent*)
+{
+ support::ProgressInterface::setInstance(this);
+}
+
+
+void GuiProgress::hideEvent(QHideEvent*)
+{
+ support::ProgressInterface::setInstance(0);
+}
+
+
+
+Dialog * createGuiProgress(GuiView & lv)
+{
+ GuiView & guiview = static_cast<GuiView &>(lv);
+#ifdef Q_WS_MACX
+ // TODO where to show up on the Mac?
+ //return new GuiProgress(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
+#else
+ return new GuiProgress(guiview, Qt::BottomDockWidgetArea);
+#endif
+}
+
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "moc_GuiProgress.cpp"
\ No newline at end of file
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file GuiProgress.h
+ * 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.
+ */
+
+#ifndef GUIPROGRESS_H
+#define GUIPROGRESS_H
+
+#include "support/ProgressInterface.h"
+
+#include "DockView.h"
+
+#include <QTextEdit>
+#include <QSplashScreen>
+#include <QTimer>
+
+#include <string>
+
+
+namespace lyx {
+namespace frontend {
+
+
+class GuiProgress :
+ public DockView,
+ public lyx::support::ProgressInterface
+{
+
+ Q_OBJECT
+public:
+ GuiProgress(
+ GuiView & parent, ///< the main window where to dock.
+ Qt::DockWidgetArea area, ///< Position of the dock (and also drawer)
+ Qt::WindowFlags flags = 0);
+
+Q_SIGNALS:
+ void processStarted(QString const &);
+ void processFinished(QString const &);
+ void appendMessage(QString const &);
+ void appendError(QString const &);
+ void clearMessages();
+
+private Q_SLOTS:
+ void doProcessStarted(QString const &);
+ void doProcessFinished(QString const &);
+ void doAppendMessage(QString const &);
+ void doAppendError(QString const &);
+ void doClearMessages();
+
+public:
+ /// Controller inherited method.
+ ///@{
+ bool initialiseParams(std::string const &) { return true; }
+ void clearParams() {}
+ void dispatchParams() {}
+ bool isBufferDependent() const { return false; }
+ bool canApply() const { return true; }
+ bool canApplyToReadOnly() const { return true; }
+ void updateView() {}
+ ///@}
+
+
+ void showEvent(QShowEvent*);
+ void hideEvent(QHideEvent*);
+
+private:
+ QTextEdit text_edit;
+
+ void appendText(QString const &);
+
+};
+
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif
+
#include "support/Path.h"
#include "support/Systemcall.h"
#include "support/Timeout.h"
+#include "support/ProgressInterface.h"
#include <QAction>
#include <QApplication>
|| name == "file" //FIXME: should be removed.
|| name == "prefs"
|| name == "texinfo"
+ || name == "progress"
|| name == "compare";
else if (name == "print")
enable = doc_buffer->isExportable("dvi")
"mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
"paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
"spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
-"toc", "view-source", "vspace", "wrap" };
+"toc", "view-source", "vspace", "wrap", "progress" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
Dialog * createGuiVSpace(GuiView & lv);
Dialog * createGuiViewSource(GuiView & lv);
Dialog * createGuiWrap(GuiView & lv);
-
+Dialog * createGuiProgress(GuiView & lv);
Dialog * GuiView::build(string const & name)
{
return createGuiVSpace(*this);
if (name == "wrap")
return createGuiWrap(*this);
+ if (name == "progress")
+ return createGuiProgress(*this);
return 0;
}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file ProgressInterface.h
+ * 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.
+ */
+
+#ifndef LYX_SUPPORT_PROGRESSINTERFACE_H
+#define LYX_SUPPORT_PROGRESSINTERFACE_H
+
+#include <string>
+
+class QString;
+
+namespace lyx {
+namespace support {
+
+
+class ProgressInterface
+{
+public:
+ virtual ~ProgressInterface() {}
+
+ virtual void processStarted(QString const &) = 0;
+ virtual void processFinished(QString const &) = 0;
+ virtual void appendMessage(QString const &) = 0;
+ virtual void appendError(QString const &) = 0;
+ virtual void clearMessages() = 0;
+
+ static void setInstance(ProgressInterface*);
+ static ProgressInterface* instance();
+
+protected:
+ ProgressInterface() {}
+};
+
+
+
+} // namespace support
+} // namespace lyx
+
+#endif // LYX_SUPPORT_PROGRESSINTERFACE_H
+
#include "support/Systemcall.h"
#include "support/SystemcallPrivate.h"
#include "support/os.h"
+#include "support/ProgressInterface.h"
#include <cstdlib>
+
using namespace std;
namespace lyx {
namespace support {
+class ProgressDummy : public ProgressInterface
+{
+public:
+ ProgressDummy() {}
+
+ void processStarted(QString const &) {}
+ void processFinished(QString const &) {}
+ void appendMessage(QString const &) {}
+ void appendError(QString const &) {}
+ void clearMessages() {}
+};
+
+
+static ProgressInterface* progress_instance = 0;
+
+void ProgressInterface::setInstance(ProgressInterface* p)
+{
+ progress_instance = p;
+}
+
+
+ProgressInterface* ProgressInterface::instance()
+{
+ if (!progress_instance) {
+ static ProgressDummy dummy;
+ return &dummy;
+ }
+ return progress_instance;
+}
+
+
+
// Reuse of instance
#ifndef USE_QPROCESS
if (outfile != os::nulldev())
proc_->setStandardOutputFile(toqstr(outfile));
} else if (os::is_terminal(os::STDOUT))
- showout();
+ setShowOut(true);
if (os::is_terminal(os::STDERR))
- showerr();
+ setShowErr(true);
connect(proc_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
connect(proc_, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
void SystemcallPrivate::startProcess(const QString& cmd)
{
+ cmd_ = cmd;
if (proc_) {
state = SystemcallPrivate::Starting;
- proc_->start(cmd);
+ proc_->start(cmd_);
}
}
void SystemcallPrivate::processEvents()
{
- if(process_events) {
- QCoreApplication::processEvents(QEventLoop::AllEvents);
- }
+ //if(process_events) {
+ QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
+ //}
}
if (outindex_) {
outdata_[outindex_] = '\0';
outindex_ = 0;
- cout << outdata_;
+ if (showout_)
+ cout << outdata_;
}
cout.flush();
if (errindex_) {
errdata_[errindex_] = '\0';
errindex_ = 0;
- cerr << errdata_;
+ if (showerr_)
+ cerr << errdata_;
}
cerr.flush();
void SystemcallPrivate::stdOut()
{
- if (proc_ && showout_) {
+ if (proc_) {
char c;
proc_->setReadChannel(QProcess::StandardOutput);
while (proc_->getChar(&c)) {
if (c == '\n' || outindex_ + 1 == bufsize_) {
outdata_[outindex_] = '\0';
outindex_ = 0;
- cout << outdata_;
+ if (showout_)
+ cout << outdata_;
}
}
}
+ const QString data = QString::fromLocal8Bit(outdata_);
+ if (!data.isEmpty())
+ ProgressInterface::instance()->appendMessage(data);
processEvents();
}
void SystemcallPrivate::stdErr()
{
- if (proc_ && showerr_) {
+ if (proc_) {
char c;
proc_->setReadChannel(QProcess::StandardError);
while (proc_->getChar(&c)) {
if (c == '\n' || errindex_ + 1 == bufsize_) {
errdata_[errindex_] = '\0';
errindex_ = 0;
- cerr << errdata_;
+ if (showerr_)
+ cerr << errdata_;
}
}
}
+ const QString data = QString::fromLocal8Bit(errdata_);
+ if (!data.isEmpty())
+ ProgressInterface::instance()->appendError(data);
processEvents();
}
void SystemcallPrivate::processStarted()
{
state = Running;
- // why do we get two started signals?
- //disconnect(proc_, SIGNAL(started()), this, SLOT(processStarted()));
+ ProgressInterface::instance()->processStarted(cmd_);
}
void SystemcallPrivate::processFinished(int, QProcess::ExitStatus)
{
state = Finished;
+ ProgressInterface::instance()->processFinished(cmd_);
}
void SystemcallPrivate::processError(QProcess::ProcessError)
{
state = Error;
+ ProgressInterface::instance()->appendError(errorMessage());
}
~SystemcallPrivate();
/// Should the standard output be displayed?
- void showout() { showout_ = true; }
+ void setShowOut(bool val) { showout_ = val; }
/// Should the standard error be displayed?
- void showerr() { showerr_ = true; }
+ void setShowErr(bool val) { showerr_ = val; }
enum State {
Starting,
///
bool showerr_;
bool process_events;
+ QString cmd_;
void waitAndProcessEvents();
void processEvents();
void processStarted();
void processFinished(int, QProcess::ExitStatus status);
+Q_SIGNALS:
+
};
} // namespace support