Here the progress widget integrated as toolbar. Peter
Index: development/cmake/src/support/CMakeLists.txt =================================================================== --- development/cmake/src/support/CMakeLists.txt (revision 21309) +++ development/cmake/src/support/CMakeLists.txt (working copy) @@ -24,6 +24,8 @@ ${TOP_SRC_DIR}/src/support/minizip/iowin32.c) lyx_add_msvc_pch(support) + +lyx_automoc(${support_sources}) include_directories(${TOP_SRC_DIR}/src/support ${TOP_SRC_DIR}/src/support/minizip @@ -37,12 +39,17 @@ add_library(support ${library_type} ${support_sources} ${support_headers}) else() lyx_const_touched_files(_allinone support_sources) + set(depends_moc ${support_headers}) + set_source_files_properties(_allinone_const.C + PROPERTIES OBJECT_DEPENDS "${depends_moc}") + set_source_files_properties(_allinone_touched.C + PROPERTIES OBJECT_DEPENDS "${depends_moc}") add_library(support ${library_type} ${_allinone_files} - ${support_minizip_sources} ${support_minizip_cpp_sources}) + ${support_minizip_sources} ${support_minizip_cpp_sources} ${support_headers}) endif() -target_link_libraries(support boost_signals) +target_link_libraries(support boost_signals ${QT_QTCORE_LIBRARY} ) if(WIN32) target_link_libraries(support shlwapi) Index: development/Win32/packaging/AltInstaller/specials/session =================================================================== --- development/Win32/packaging/AltInstaller/specials/session (revision 21309) +++ development/Win32/packaging/AltInstaller/specials/session (working copy) @@ -7,6 +7,7 @@ math_panels = 2 1 math = 2 1 minibuffer = 1 1 +latexprogress = 1 1 review = 2 1 table = 2 1 view/update = 0 3 Index: development/Win32/packaging/AltInstaller/specials/stdtoolbars.inc =================================================================== --- development/Win32/packaging/AltInstaller/specials/stdtoolbars.inc (revision 21309) +++ development/Win32/packaging/AltInstaller/specials/stdtoolbars.inc (working copy) @@ -167,6 +167,10 @@ Minibuffer End + Toolbar "latexprogress" "LaTex Progress" + LatexProgress + End + Toolbar "review" "Review" Item "Track changes" "changes-track" Item "Show changes in output" "changes-output" Index: src/LaTeX.cpp =================================================================== --- src/LaTeX.cpp (revision 21309) +++ src/LaTeX.cpp (working copy) @@ -427,11 +427,10 @@ int LaTeX::startscript() { // onlyFilename() is needed for cygwin - string tmp = cmd + ' ' - + quoteName(onlyFilename(file.toFilesystemEncoding())) - + " > " + os::nulldev(); - Systemcall one; - return one.startscript(Systemcall::Wait, tmp); + string tmp = cmd + ' ' + + "-max-print-line=200 " + + quoteName((file.toFilesystemEncoding())); + return Systemcall().startscript(Systemcall::Wait, tmp); } Index: src/frontends/LyXView.h =================================================================== --- src/frontends/LyXView.h (revision 21309) +++ src/frontends/LyXView.h (working copy) @@ -124,6 +124,7 @@ virtual bool isToolbarVisible(std::string const & id) = 0; /// virtual void showMiniBuffer(bool visible) = 0; + virtual void showLatexProgress(bool visible) = 0; virtual void openMenu(docstring const & name) = 0; /// get access to the dialogs Index: src/frontends/qt4/GuiProgress.cpp =================================================================== --- src/frontends/qt4/GuiProgress.cpp (revision 0) +++ src/frontends/qt4/GuiProgress.cpp (revision 0) @@ -0,0 +1,51 @@ +// -*- 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 "GuiProgress.h" + +#include "GuiView.h" + +#include <QApplication> +#include <QVBoxLayout> + +namespace lyx { +namespace frontend { + + +GuiProgress::GuiProgress(GuiViewBase*) : QWidget() +{ + QVBoxLayout* vl = new QVBoxLayout; + // TODO translate + vl->addWidget(new QLabel("Progress")); + vl->addWidget(&text_edit); + setLayout(vl); + vl->setMargin(0); +} + + +void GuiProgress::appendMessage(QString const & msg) +{ + text_edit.append(msg); + QApplication::processEvents(); +} + + +void GuiProgress::clearMessages() +{ + text_edit.clear(); +} + + +} // namespace frontend +} // namespace lyx + +
Property changes on: src/frontends/qt4/GuiProgress.cpp ___________________________________________________________________ Name: svn:eol-style + native Index: src/frontends/qt4/GuiToolbar.h =================================================================== --- src/frontends/qt4/GuiToolbar.h (revision 21309) +++ src/frontends/qt4/GuiToolbar.h (working copy) @@ -29,6 +29,7 @@ namespace frontend { class GuiCommandBuffer; +class GuiProgress; class GuiViewBase; class Action; @@ -69,6 +70,9 @@ GuiLayoutBox * layout() const { return layout_; } /// GuiCommandBuffer * commandBuffer() { return command_buffer_; } + //// + GuiProgress * latexProgress() { return latex_progress_; } + Q_SIGNALS: void updated(); @@ -81,6 +85,7 @@ GuiLayoutBox * layout_; GuiCommandBuffer * command_buffer_; + GuiProgress * latex_progress_; }; } // namespace frontend Index: src/frontends/qt4/GuiView.h =================================================================== --- src/frontends/qt4/GuiView.h (revision 21309) +++ src/frontends/qt4/GuiView.h (working copy) @@ -74,6 +74,7 @@ virtual void clearMessage(); virtual bool hasFocus() const; void showMiniBuffer(bool); + void showLatexProgress(bool); void openMenu(docstring const &); void openLayoutList(); void updateLayoutChoice(); Index: src/frontends/qt4/GuiToolbars.cpp =================================================================== --- src/frontends/qt4/GuiToolbars.cpp (revision 21309) +++ src/frontends/qt4/GuiToolbars.cpp (working copy) @@ -15,6 +15,7 @@ #include "GuiToolbars.h" #include "GuiCommandBuffer.h" +#include "GuiProgress.h" #include "GuiToolbar.h" #include "GuiView.h" @@ -384,5 +385,27 @@ } } +// TODO is identical to showCommandBuffer, +// find a <GuiProgress, ..> solution + +void GuiToolbars::showLatexProgress(bool show_it) +{ + ToolbarsMap::const_iterator it = toolbars_.begin(); + ToolbarsMap::const_iterator const end = toolbars_.end(); + for (; it != end; ++it) { + GuiProgress * cb = it->second->latexProgress(); + if (!cb) + continue; + if (!show_it) { + it->second->hide(); + return; + } + if (!it->second->isVisible()) + it->second->show(); + cb->setFocus(); + return; + } +} + } // namespace frontend } // namespace lyx Index: src/frontends/qt4/GuiToolbar.cpp =================================================================== --- src/frontends/qt4/GuiToolbar.cpp (revision 21309) +++ src/frontends/qt4/GuiToolbar.cpp (working copy) @@ -27,6 +27,7 @@ #include "GuiView.h" #include "GuiCommandBuffer.h" +#include "GuiProgress.h" #include "GuiToolbar.h" #include "LyXAction.h" #include "Action.h" @@ -36,6 +37,7 @@ #include "support/filetools.h" #include "support/lstrings.h" #include "support/lyxalgo.h" // sorted +#include "support/SystemProcess.h" #include <QComboBox> #include <QToolBar> @@ -365,6 +367,12 @@ /// \todo find a Qt4 equivalent to setHorizontalStretchable(true); //setHorizontalStretchable(true); break; + case ToolbarItem::LATEXPROGRESS: + latex_progress_ = new GuiProgress(&owner_); + addWidget(latex_progress_); + lyx::support::SystemProcess::registerProgressInterface(latex_progress_); + setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); + break; case ToolbarItem::TABLEINSERT: { QToolButton * tb = new QToolButton; tb->setCheckable(true); Index: src/frontends/qt4/GuiView.cpp =================================================================== --- src/frontends/qt4/GuiView.cpp (revision 21309) +++ src/frontends/qt4/GuiView.cpp (working copy) @@ -22,6 +22,7 @@ #include "GuiToolbar.h" #include "GuiToolbars.h" #include "qt_helpers.h" +#include "GuiProgress.h" #include "frontends/Application.h" #include "frontends/Dialogs.h" @@ -32,6 +33,7 @@ #include "support/convert.h" #include "support/lstrings.h" #include "support/os.h" +#include "support/SystemProcess.h" #include "Buffer.h" #include "BufferParams.h" @@ -66,6 +68,7 @@ #include <QToolBar> #include <QUrl> + #include <boost/current_function.hpp> using std::endl; @@ -134,6 +137,7 @@ TabWorkArea * tab_widget_; QStackedWidget * stack_widget_; BackgroundWidget * bg_widget_; + /// view's menubar GuiMenubar * menubar_; /// view's toolbars @@ -875,6 +879,11 @@ } +void GuiViewBase::showLatexProgress(bool visible) +{ + d.toolbars_->showLatexProgress(visible); +} + void GuiViewBase::openMenu(docstring const & name) { d.menubar_->openByName(toqstr(name)); Index: src/frontends/qt4/GuiToolbars.h =================================================================== --- src/frontends/qt4/GuiToolbars.h (revision 21309) +++ src/frontends/qt4/GuiToolbars.h (working copy) @@ -73,6 +73,8 @@ /// Show or hide the command buffer. void showCommandBuffer(bool show_it); + /// Show or hide the LaTex progress widget + void showLatexProgress(bool show_it); private: /// Add a new toolbar. if newline==true, start from a new line Index: src/frontends/qt4/GuiProgress.h =================================================================== --- src/frontends/qt4/GuiProgress.h (revision 0) +++ src/frontends/qt4/GuiProgress.h (revision 0) @@ -0,0 +1,45 @@ +// -*- 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 <QTextEdit> +#include <QWidget> + +#include <string> + + +namespace lyx { +namespace frontend { + +class GuiViewBase; + +class GuiProgress : public QWidget, public lyx::support::ProgressInterface +{ +public: + GuiProgress(GuiViewBase * view); + + void appendMessage(QString const &); + void clearMessages(); + +private: + QTextEdit text_edit; +}; + + +} // namespace frontend +} // namespace lyx + +#endif + Property changes on: src/frontends/qt4/GuiProgress.h ___________________________________________________________________ Name: svn:eol-style + native Index: src/support/Systemcall.cpp =================================================================== --- src/support/Systemcall.cpp (revision 21309) +++ src/support/Systemcall.cpp (working copy) @@ -14,6 +14,7 @@ #include <config.h> #include "support/Systemcall.h" +#include "support/SystemProcess.h" #include "support/os.h" #include <cstdlib> @@ -32,19 +33,14 @@ { string command = what; - if (how == DontWait) { - switch (os::shell()) { - case os::UNIX: - command += " &"; - break; - case os::CMD_EXE: - command = "start /min " + command; - break; - } - } + SystemProcess* process = new SystemProcess; + + if (how == Wait) + return process->start(command, true); - return ::system(command.c_str()); + return process->start(command, false); } + } // namespace support } // namespace lyx Index: src/support/SystemProcess.h =================================================================== --- src/support/SystemProcess.h (revision 0) +++ src/support/SystemProcess.h (revision 0) @@ -0,0 +1,52 @@ +// -*- C++ -*- +/** + * \file SystemProcess.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_SYSTEMPROCESS_H +#define LYX_SUPPORT_SYSTEMPROCESS_H + +#include <string> +#include <QObject> +#include <QProcess> + +namespace lyx { +namespace support { + +class ProgressInterface; + +class SystemProcess : public QObject +{ + Q_OBJECT + +public: + SystemProcess(); + + // waitForFinished == true: returns the exit code of the process + // waitForFinished == false: returns 0 if the process could bestarted + int start(const std::string& cmd, bool waitForFinished); + + static void registerProgressInterface(ProgressInterface*); + +public Q_SLOTS: + void newProcessOutput(); + void processStarted(); + void processError(QProcess::ProcessError); + void processFinished(int, QProcess::ExitStatus); + +private: + QProcess process; + static ProgressInterface* progress; +}; + + +} // namespace support +} // namespace lyx + +#endif // LYX_SUPPORT_PROCESS_H Property changes on: src/support/SystemProcess.h ___________________________________________________________________ Name: svn:eol-style + native Index: src/support/SystemProcess.cpp =================================================================== --- src/support/SystemProcess.cpp (revision 0) +++ src/support/SystemProcess.cpp (revision 0) @@ -0,0 +1,108 @@ +// -*- C++ -*- +/** + * \file SystemProcess.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 "SystemProcess.h" +#include "ProgressInterface.h" + + +namespace lyx { +namespace support { + + +ProgressInterface* SystemProcess::progress = 0; + + +SystemProcess::SystemProcess() +{ + if (progress) { + connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(newProcessOutput())); + connect(&process, SIGNAL(started()), this, SLOT(processStarted())); + connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); + connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(processFinished(int, QProcess::ExitStatus))); + } +} + + +void SystemProcess::registerProgressInterface(ProgressInterface* p) +{ + progress = p; +} + + +int SystemProcess::start(const std::string& cmd, bool waitForFinished) +{ + if (progress) { + progress->clearMessages(); + progress->appendMessage("starting LaTex with command"); + progress->appendMessage(cmd.c_str()); + } + + process.setReadChannel(QProcess::StandardOutput); + process.start(cmd.c_str(), QStringList(), QIODevice::ReadOnly); + // wait some seconds until the process has started + process.waitForStarted(10 * 1000); + if (waitForFinished) { + // with waitForFinished(-1); we only get one signal per run + while (process.state() == QProcess::Running) + process.waitForFinished(500); + return process.exitCode(); + } + if (process.state() != QProcess::Running) { + process.kill(); + // TODO this needs more testing + deleteLater(); + return -1; + } + return 0; +} + + +void SystemProcess::newProcessOutput() +{ + if (!progress) + return; + // parse output for page number, etc., could be used for a progress bar + const QString output = QString::fromLocal8Bit(process.readAllStandardOutput()); + progress->appendMessage(output); +} + + +void SystemProcess::processStarted() +{ + if (!progress) + return; + progress->appendMessage("LaTex started\n"); +} + + +void SystemProcess::processError(QProcess::ProcessError) +{ + if (!progress) + return; + progress->appendMessage("LaTex error\n"); +} + + +void SystemProcess::processFinished(int, QProcess::ExitStatus) +{ + deleteLater(); +} + + +} // namespace support +} // namespace lyx + +#include "SystemProcess_moc.cpp" + + Property changes on: src/support/SystemProcess.cpp ___________________________________________________________________ Name: svn:eol-style + native Index: src/support/ProgressInterface.h =================================================================== --- src/support/ProgressInterface.h (revision 0) +++ src/support/ProgressInterface.h (revision 0) @@ -0,0 +1,38 @@ +// -*- 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 + +class QString; + +namespace lyx { +namespace support { + + +class ProgressInterface +{ +public: + virtual ~ProgressInterface() {} + + virtual void appendMessage(QString const &) = 0; + virtual void clearMessages() = 0; + +protected: + ProgressInterface() {} +}; + + +} // namespace support +} // namespace lyx + +#endif // LYX_SUPPORT_PROGRESSINTERFACE_H + Property changes on: src/support/ProgressInterface.h ___________________________________________________________________ Name: svn:eol-style + native Index: src/ToolbarBackend.cpp =================================================================== --- src/ToolbarBackend.cpp (revision 21309) +++ src/ToolbarBackend.cpp (working copy) @@ -85,6 +85,7 @@ TO_SEPARATOR, TO_LAYOUTS, TO_MINIBUFFER, + TO_LATEXPROGRESS, TO_TABLEINSERT, TO_POPUPMENU, TO_ICONPALETTE, @@ -97,6 +98,7 @@ { "item", TO_COMMAND }, { "layouts", TO_LAYOUTS }, { "minibuffer", TO_MINIBUFFER }, + { "latexprogress", TO_LATEXPROGRESS }, { "popupmenu", TO_POPUPMENU }, { "separator", TO_SEPARATOR }, { "tableinsert", TO_TABLEINSERT } @@ -150,6 +152,11 @@ FuncRequest(kb_action(ToolbarItem::MINIBUFFER)))); break; + case TO_LATEXPROGRESS: + add(ToolbarItem(ToolbarItem::LATEXPROGRESS, + FuncRequest(kb_action(ToolbarItem::LATEXPROGRESS)))); + break; + case TO_SEPARATOR: add(ToolbarItem(ToolbarItem::SEPARATOR, FuncRequest(kb_action(ToolbarItem::SEPARATOR)))); Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (revision 21309) +++ src/Buffer.cpp (working copy) @@ -1078,8 +1078,7 @@ if (output_preamble) { if (!runparams.nice) { // code for usual, NOT nice-latex-file - os << "\\batchmode\n"; // changed - // from \nonstopmode + os << "\\nonstopmode\n"; texrow().newline(); } if (!original_path.empty()) { Index: src/ToolbarBackend.h =================================================================== --- src/ToolbarBackend.h (revision 21309) +++ src/ToolbarBackend.h (working copy) @@ -30,6 +30,8 @@ COMMAND, /// the command buffer MINIBUFFER, + /// LaTex progress widget + LATEXPROGRESS, /// adds space between buttons in the toolbar SEPARATOR, /// a special combox insead of a button Index: lib/ui/default.ui =================================================================== --- lib/ui/default.ui (revision 21309) +++ lib/ui/default.ui (working copy) @@ -40,4 +40,5 @@ "math_panels" "math,bottom" "math" "math,bottom" "minibuffer" "off,bottom" + "latexprogress" "off,bottom" End Index: lib/ui/stdtoolbars.inc =================================================================== --- lib/ui/stdtoolbars.inc (revision 21309) +++ lib/ui/stdtoolbars.inc (working copy) @@ -167,6 +167,10 @@ Minibuffer End + Toolbar "latexprogress" "LaTex Progress" + LatexProgress + End + Toolbar "review" "Review" Item "Track changes" "changes-track" Item "Show changes in output" "changes-output" Index: lib/ui/classic.ui =================================================================== --- lib/ui/classic.ui (revision 21309) +++ lib/ui/classic.ui (working copy) @@ -449,4 +449,5 @@ "table" "off,bottom" "math" "off,bottom" "minibuffer" "off,bottom" + "latexprogress" "off,bottom" End