]> git.lyx.org Git - features.git/commitdiff
- Show progress information in status bar.
authorPeter Kümmel <syntheticpp@gmx.net>
Mon, 21 Dec 2009 11:48:19 +0000 (11:48 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Mon, 21 Dec 2009 11:48:19 +0000 (11:48 +0000)
- Remove progress view because ATM we don't have to show anything usefull.
- move Alert:: void functions into GUI thread

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32604 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ui/stdmenus.inc
src/frontends/qt4/GuiAlert.cpp
src/frontends/qt4/GuiProgress.cpp
src/frontends/qt4/GuiProgress.h
src/frontends/qt4/GuiView.cpp
src/support/ProgressInterface.h
src/support/Systemcall.cpp

index c391338aa5b4988ca5977c0cf9303ffcdec0632d..436a0ca316c2b3594a280a6abba3fd9be21a74dc 100644 (file)
@@ -315,7 +315,6 @@ Menuset
                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"
index 983d58d1c1056f6d05268c481ea7f88fc849a9b7..fdb2065c084f1fa40ad9ad1902cf472b2b77b44a 100644 (file)
 
 #include "alert.h"
 
+
 #include "frontends/Application.h"
 
 #include "qt_helpers.h"
 #include "LyX.h" // for lyx::use_gui
 #include "ui_AskForTextUi.h"
-#include "ui_ToggleWarningUi.h"
 #include "support/gettext.h"
 
 #include "support/debug.h"
 #include "support/docstring.h"
 #include "support/lstrings.h"
+#include "support/ProgressInterface.h"
 
 #include <QApplication>
 #include <QCheckBox>
@@ -43,15 +44,6 @@ namespace lyx {
 namespace frontend {
 
 
-class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi
-{
-public:
-       GuiToggleWarningDialog(QWidget * parent) : QDialog(parent)
-       {
-               Ui::ToggleWarningUi::setupUi(this);
-               QDialog::setModal(true);
-       }
-};
 
 
 static docstring const formatted(docstring const & text)
@@ -114,26 +106,18 @@ static docstring const formatted(docstring const & text)
 }
 
 
-void toggleWarning(docstring const & title, docstring const & msg)
+void noAppDialog(QString const & title, QString const & msg, QMessageBox::Icon mode)
 {
-       if (!use_gui)
-               return;
-
-       QSettings settings;
-       if (settings.value("hidden_warnings/" + toqstr(msg), false).toBool())
-               return;
-
-       GuiToggleWarningDialog * dlg =
-               new GuiToggleWarningDialog(qApp->focusWidget());
-
-       dlg->setWindowTitle(toqstr(title));
-       dlg->messageLA->setText(toqstr(formatted(msg)));
-       dlg->dontShowAgainCB->setChecked(false);
-
-       if (dlg->exec() == QDialog::Accepted)
-               if (dlg->dontShowAgainCB->isChecked())
-                       settings.setValue("hidden_warnings/"
-                               + toqstr(msg), true);
+       int argc = 1;
+       char * argv[1];
+       QApplication app(argc, argv);
+       switch (mode)
+       {
+               case QMessageBox::Information: QMessageBox::information(0, title, msg); break;
+               case QMessageBox::Warning: QMessageBox::warning(0, title, msg); break;
+               case QMessageBox::Critical: QMessageBox::critical(0, title, msg); break;
+               default: break;
+       }
 }
 
 
@@ -196,26 +180,23 @@ void warning(docstring const & title0, docstring const & message,
        docstring const title = bformat(_("LyX: %1$s"), title0);
 
        if (theApp() == 0) {
-               int argc = 1;
-               char * argv[1];
-               QApplication app(argc, argv);
-               QMessageBox::warning(0,
-                       toqstr(title),
-                       toqstr(formatted(message)));
+               noAppDialog(toqstr(title), toqstr(formatted(message)), QMessageBox::Warning);
                return;
        }
-       if (!askshowagain)
-               QMessageBox::warning(qApp->focusWidget(),
+
+       if (!askshowagain) {
+               ProgressInterface::instance()->warning(
                                toqstr(title),
                                toqstr(formatted(message)));
-       else
-               toggleWarning(title, message);
+       } else {
+               ProgressInterface::instance()->toggleWarning(
+                               toqstr(title),
+                               toqstr(message),
+                               toqstr(formatted(message)));
+       }
 }
 
 
-int argc = 1;
-char * argv[1];
-
 void error(docstring const & title0, docstring const & message)
 {
        lyxerr << "Error: " << title0 << '\n'
@@ -226,16 +207,15 @@ void error(docstring const & title0, docstring const & message)
                return;
 
        docstring const title = bformat(_("LyX: %1$s"), title0);
+
        if (theApp() == 0) {
-               QApplication app(argc, argv);
-               QMessageBox::critical(0,
-                       toqstr(title),
-                       toqstr(formatted(message)));
+               noAppDialog(toqstr(title), toqstr(formatted(message)), QMessageBox::Critical);
                return;
        }
-       QMessageBox::critical(qApp->focusWidget(),
-                             toqstr(title),
-                             toqstr(formatted(message)));
+
+       ProgressInterface::instance()->error(
+               toqstr(title),
+               toqstr(formatted(message)));
 }
 
 
@@ -250,9 +230,15 @@ void information(docstring const & title0, docstring const & message)
                return;
 
        docstring const title = bformat(_("LyX: %1$s"), title0);
-       QMessageBox::information(qApp->focusWidget(),
-                                toqstr(title),
-                                toqstr(formatted(message)));
+
+       if (theApp() == 0) {
+               noAppDialog(toqstr(title), toqstr(formatted(message)), QMessageBox::Information);
+               return;
+       }
+
+       ProgressInterface::instance()->information(
+               toqstr(title),
+               toqstr(formatted(message)));
 }
 
 
index b421616ab4d329543cd86f0304ead46382b81368..c6c5506bd07d222a6621ff5f6dea1caf38210741 100644 (file)
 #include <config.h>
 
 #include "GuiProgress.h"
+#include "ui_ToggleWarningUi.h"
 
 #include "qt_helpers.h"
 
 #include "support/Systemcall.h"
 
 #include <QApplication>
-#include <QDebug>
+#include <QTime>
+#include <QMessageBox>
+
 
 
 namespace lyx {
 namespace frontend {
 
 
-
-GuiProgress::GuiProgress(GuiView & parent, Qt::DockWidgetArea area, 
-       Qt::WindowFlags flags) : DockView(parent, "progress", "External tools", area, flags)
+class GuiToggleWarningDialog : public QDialog, public Ui::ToggleWarningUi
 {
-       setWindowTitle(qt_("Tool monitoring"));
-       setWidget(&text_edit);
-       text_edit.setReadOnly(true);
+public:
+       GuiToggleWarningDialog(QWidget * parent) : QDialog(parent)
+       {
+               Ui::ToggleWarningUi::setupUi(this);
+               QDialog::setModal(true);
+       }
+};
+
+
+
 
+GuiProgress::GuiProgress(GuiView * view) : view_(view)
+{
        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()));
+       
+       // 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);
 }
 
 
 void GuiProgress::doProcessStarted(QString const & cmd)
 {
-       appendText("Process started : " + cmd + "\n");
+       QString time = QTime::currentTime().toString(Qt::SystemLocaleShortDate);
+       appendText(time + ": <" + cmd + "> started\n");
 }
 
 
 void GuiProgress::doProcessFinished(QString const & cmd)
 {
-       appendText("Process finished: " + cmd + "\n");
+       QString time = QTime::currentTime().toString(Qt::SystemLocaleShortDate);
+       appendText(time + ": <" + cmd + "> done\n");
 }
 
 
 void GuiProgress::doAppendMessage(QString const & msg)
 {
-       // No good messages from the processes
-       //appendText(msg);
+       appendText(msg);
 }
 
 
@@ -68,42 +91,53 @@ void GuiProgress::doAppendError(QString const & msg)
 
 void GuiProgress::doClearMessages()
 {
-       text_edit.clear();
+       view_->message(docstring());
 }
 
 
 void GuiProgress::appendText(QString const & text)
 {
-       text_edit.insertPlainText(text);
-       text_edit.ensureCursorVisible();
+       view_->message(qstring_to_ucs4(text));
 }
 
 
-void GuiProgress::showEvent(QShowEvent*)
+void GuiProgress::doWarning(QString const & title, QString const & message)
 {
-       support::ProgressInterface::setInstance(this);
+       QMessageBox::warning(qApp->focusWidget(), title, message);
 }
 
 
-void GuiProgress::hideEvent(QHideEvent*)
+void GuiProgress::doToggleWarning(QString const & title, QString const & msg, QString const & formatted)
 {
-       support::ProgressInterface::setInstance(0);
-}
+       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);
 
+       if (dlg->exec() == QDialog::Accepted)
+               if (dlg->dontShowAgainCB->isChecked())
+                       settings.setValue("hidden_warnings/"
+                               + msg, true);
+}
 
 
-Dialog * createGuiProgress(GuiView & lv)
+void GuiProgress::doError(QString const & title, QString const & message)
 {
-       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
+       QMessageBox::critical(qApp->focusWidget(), title, message);
 }
 
 
+void GuiProgress::doInformation(QString const & title, QString const & message)
+{
+       QMessageBox::information(qApp->focusWidget(), title, message);
+}
+
 
 } // namespace frontend
 } // namespace lyx
index 79891548c1277e9c8aadcf5bf11bb237b1b2f605..a47eb749867eb561c96b66b83e2d99002b96292a 100644 (file)
@@ -27,17 +27,15 @@ namespace lyx {
 namespace frontend {
 
 
-class GuiProgress : 
-       public DockView, 
-       public lyx::support::ProgressInterface
+class GuiProgress :
+               public QObject,
+               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);
+       GuiProgress(GuiView * view);
+
 
 Q_SIGNALS:
        void processStarted(QString const &);
@@ -46,6 +44,12 @@ Q_SIGNALS:
        void appendError(QString const &);
        void clearMessages();
 
+       // Alert interface
+       void warning(QString const & title, QString const & message);
+       void toggleWarning(QString const & title, QString const & msg, QString const & formatted);
+       void error(QString const & title, QString const & message);
+       void information(QString const & title, QString const & message);
+
 private Q_SLOTS:
        void doProcessStarted(QString const &);
        void doProcessFinished(QString const &);
@@ -53,25 +57,15 @@ private Q_SLOTS:
        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 doWarning(QString const &, QString const &);
+       void doToggleWarning(QString const & title, QString const & msg, QString const & formatted);
+       void doError(QString const &, QString const &);
+       void doInformation(QString const &, QString const &);
 
+
+private:
+       GuiView* view_;
        void appendText(QString const &);
 
 };
index de7d60e125ffda8b8f19cb37ee820b54469a822d..373e015c6b7ca9e52209178efb29e20bb90f0215 100644 (file)
@@ -77,6 +77,7 @@
 #include "support/Systemcall.h"
 #include "support/Timeout.h"
 #include "support/ProgressInterface.h"
+#include "GuiProgress.h"
 
 #include <QAction>
 #include <QApplication>
@@ -192,6 +193,7 @@ struct GuiView::GuiViewPrivate
                stack_widget_->addWidget(bg_widget_);
                stack_widget_->addWidget(splitter_);
                setBackground();
+               progress = new GuiProgress(gv);
        }
 
        ~GuiViewPrivate()
@@ -199,6 +201,7 @@ struct GuiView::GuiViewPrivate
                delete splitter_;
                delete bg_widget_;
                delete stack_widget_;
+               delete progress;
        }
 
        QMenu * toolBarPopup(GuiView * parent)
@@ -284,6 +287,7 @@ public:
        BackgroundWidget * bg_widget_;
        /// view's toolbars
        ToolbarMap toolbars_;
+       GuiProgress* progress;
        /// The main layout box.
        /** 
         * \warning Don't Delete! The layout box is actually owned by
@@ -1420,7 +1424,6 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                                || name == "file" //FIXME: should be removed.
                                || name == "prefs"
                                || name == "texinfo"
-                               || name == "progress"
                                || name == "compare";
                else if (name == "print")
                        enable = doc_buffer->isExportable("dvi")
@@ -2691,6 +2694,9 @@ bool GuiView::dispatch(FuncRequest const & cmd)
                        if (argument.empty())
                                format = doc_buffer->getDefaultOutputFormat();
 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+                       ProgressInterface::instance()->clearMessages();
+                       QString time = QTime::currentTime().toString(Qt::SystemLocaleShortDate);
+                       ProgressInterface::instance()->appendMessage(time + ": Exporting ...\n");
                        QFuture<docstring> f = QtConcurrent::run(exportAndDestroy,
                                doc_buffer->clone(), format);
                        d.setPreviewFuture(f);
@@ -2706,6 +2712,9 @@ bool GuiView::dispatch(FuncRequest const & cmd)
                        if (argument.empty())
                                format = doc_buffer->getDefaultOutputFormat();
 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+                       ProgressInterface::instance()->clearMessages();
+                       QString time = QTime::currentTime().toString(Qt::SystemLocaleShortDate);
+                       ProgressInterface::instance()->appendMessage(time + ": Previewing ...\n");
                        QFuture<docstring> f = QtConcurrent::run(previewAndDestroy,
                                doc_buffer->clone(), format);
                        d.setPreviewFuture(f);
@@ -3175,7 +3184,7 @@ char const * const dialognames[] = {
 "mathmatrix", "mathspace", "nomenclature", "nomencl_print", "note",
 "paragraph", "phantom", "prefs", "print", "ref", "sendto", "space",
 "spellchecker", "symbols", "tabular", "tabularcreate", "thesaurus", "texinfo",
-"toc", "view-source", "vspace", "wrap", "progress" };
+"toc", "view-source", "vspace", "wrap"};
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -3373,7 +3382,8 @@ Dialog * createGuiHyperlink(GuiView & lv);
 Dialog * createGuiVSpace(GuiView & lv);
 Dialog * createGuiViewSource(GuiView & lv);
 Dialog * createGuiWrap(GuiView & lv);
-Dialog * createGuiProgress(GuiView & lv);
+
+
 
 Dialog * GuiView::build(string const & name)
 {
@@ -3477,8 +3487,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiVSpace(*this);
        if (name == "wrap")
                return createGuiWrap(*this);
-       if (name == "progress") 
-               return createGuiProgress(*this); 
 
        return 0;
 }
index 4199fd82ae9d07d0b447c96bb7e9c463288c69ba..1fdd3b417be77b65bc6dcfb9031287de63a65ee3 100644 (file)
@@ -31,6 +31,13 @@ public:
        virtual void appendError(QString const &) = 0;
        virtual void clearMessages() = 0;
 
+       // Alert interface
+       virtual void warning(QString const & title, QString const & message) = 0;
+       virtual void toggleWarning(QString const & title, QString const & msg, QString const & formatted) = 0;
+       virtual void error(QString const & title, QString const & message) = 0;
+       virtual void information(QString const & title, QString const & message) = 0;
+
+
        static void setInstance(ProgressInterface*);
        static ProgressInterface* instance();
 
index 2a1154cf2dbb97da069ec3e62628a199ca6ef25b..5ba04cce4af157f16eea40acecaff5992b13e606 100644 (file)
@@ -61,6 +61,11 @@ public:
        void appendMessage(QString const &) {}
        void appendError(QString const &) {}
        void clearMessages() {}
+
+       void warning(QString const &, QString const &) {}
+       void toggleWarning(QString const &, QString const &, QString const &) {}
+       void error(QString const &, QString const &) {}
+       void information(QString const &, QString const &) {}
 };
 
 
@@ -369,8 +374,10 @@ void SystemcallPrivate::stdOut()
                }
        }
        const QString data = QString::fromLocal8Bit(outdata_);
-       if (!data.isEmpty())
-               ProgressInterface::instance()->appendMessage(data);
+       if (!data.isEmpty()) {
+               // TODO No good messages from the processes. Disable batch mode?
+               //ProgressInterface::instance()->appendMessage(data);
+       }
        processEvents();
 }