]> git.lyx.org Git - features.git/commitdiff
Revert "Auto feature for minibuffer toolbar"
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 30 Jun 2015 09:09:48 +0000 (11:09 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 30 Jun 2015 09:09:48 +0000 (11:09 +0200)
This reverts commit fdcff02a3124845d1033d3d804cede127850ff0f.

This was pushed too early, we are not ready yet.

15 files changed:
lib/ui/default.ui
src/LyX.cpp
src/LyX.h
src/frontends/Application.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiCommandBuffer.cpp
src/frontends/qt4/GuiCommandBuffer.h
src/frontends/qt4/GuiCommandEdit.cpp
src/frontends/qt4/GuiCommandEdit.h
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/Toolbars.cpp
src/frontends/qt4/Toolbars.h

index 34f56510aaedd37579ab8c25374307e5b3290049..fa20f1d39e35fb7d99cb8aea2a214098c5d6beb0 100644 (file)
@@ -56,5 +56,5 @@ Toolbars
        "math" "auto,math,bottom"
        "mathmacrotemplate" "auto,mathmacrotemplate,bottom"
        "ipa" "auto,ipa,bottom"
-       "minibuffer" "auto,minibuffer,bottom"
+       "minibuffer" "off,bottom"
 End
index b4c02168c8ed36f1d539d1030863eb6398245058..c3d84b22f614d2c636cd18a1990313d679e15386 100644 (file)
@@ -1386,7 +1386,7 @@ FuncStatus getStatus(FuncRequest const & action)
 }
 
 
-DispatchResult const & dispatch(FuncRequest const & action)
+void dispatch(FuncRequest const & action)
 {
        LAPPERR(theApp());
        return theApp()->dispatch(action);
@@ -1396,7 +1396,7 @@ DispatchResult const & dispatch(FuncRequest const & action)
 void dispatch(FuncRequest const & action, DispatchResult & dr)
 {
        LAPPERR(theApp());
-       theApp()->dispatch(action, dr);
+       return theApp()->dispatch(action, dr);
 }
 
 
index 9980ab5eef47d55a909b84b2a79b6535565cfd5c..ccce7a31549bf1f1099a9db0944f8bc1d4ea87f9 100644 (file)
--- a/src/LyX.h
+++ b/src/LyX.h
@@ -135,7 +135,7 @@ private:
        bool first_start;
 
        friend FuncStatus getStatus(FuncRequest const & action);
-       friend DispatchResult const & dispatch(FuncRequest const & action);
+       friend void dispatch(FuncRequest const & action);
        friend void dispatch(FuncRequest const & action, DispatchResult & dr);
        friend std::vector<std::string> & theFilesToLoad();
        friend BufferList & theBufferList();
@@ -175,7 +175,7 @@ void execBatchCommands();
 FuncStatus getStatus(FuncRequest const & action);
 
 ///
-DispatchResult const & dispatch(FuncRequest const & action);
+void dispatch(FuncRequest const & action);
 
 ///
 void dispatch(FuncRequest const & action, DispatchResult & dr);
index df0be95493e4cbe5ff2bcbdf71434ec5c7413e66..ca5ea4493ad774dce66e94d4bb6a2b20c46649c9 100644 (file)
@@ -177,7 +177,7 @@ public:
        /// Every user command is processed here, either invocated from
        /// keyboard or from the GUI. All GUI objects, including buttons and
        /// menus should use this class and never call kernel functions directly.
-       virtual DispatchResult const & dispatch(FuncRequest const &) = 0;
+       virtual void dispatch(FuncRequest const &) = 0;
 
        /// LyX dispatcher: executes lyx actions and returns result.
        virtual void dispatch(FuncRequest const &, DispatchResult & dr) = 0;
index fa668716bb88405bfb6297dd87a63913c2883d01..8bd22c8c0385134b495e7ca234e05871047199e2 100644 (file)
@@ -965,9 +965,6 @@ struct GuiApplication::Private
        ///
        KeyModifier meta_fake_bit;
 
-       /// The result of last dispatch action
-       DispatchResult dispatch_result_;
-
        /// Multiple views container.
        /**
        * Warning: This must not be a smart pointer as the destruction of the
@@ -1375,7 +1372,7 @@ static docstring makeDispatchMessage(docstring const & msg,
 }
 
 
-DispatchResult const & GuiApplication::dispatch(FuncRequest const & cmd)
+void GuiApplication::dispatch(FuncRequest const & cmd)
 {
        Buffer * buffer = 0;
        if (current_view_ && current_view_->currentBufferView()) {
@@ -1395,9 +1392,6 @@ DispatchResult const & GuiApplication::dispatch(FuncRequest const & cmd)
        // the buffer may have been closed by one action
        if (theBufferList().isLoaded(buffer))
                buffer->undo().endUndoGroup();
-
-       d->dispatch_result_ = dr;
-       return d->dispatch_result_;
 }
 
 
index 344a8620dab421e8435cf03c65b768dd777af6ce..bfc242ccde8713ebd0d314f9c64fdd4699084d23 100644 (file)
@@ -62,7 +62,7 @@ public:
 
        /// \name Methods inherited from Application class
        //@{
-       DispatchResult const & dispatch(FuncRequest const &);
+       void dispatch(FuncRequest const &);
        void dispatch(FuncRequest const &, DispatchResult & dr);
        FuncStatus getStatus(FuncRequest const & cmd) const;
        void restoreGuiSession();
index 9880e2b996a37a6f60929ef61281b139ff85a936..c9ddf4a49ea539d5aab70582facda99737a5c1fe 100644 (file)
@@ -108,11 +108,12 @@ GuiCommandBuffer::GuiCommandBuffer(GuiView * view)
        edit_->setMinimumSize(edit_->sizeHint());
        edit_->setFocusPolicy(Qt::ClickFocus);
 
+       connect(edit_, SIGNAL(escapePressed()), this, SLOT(cancel()));
        connect(edit_, SIGNAL(returnPressed()), this, SLOT(dispatch()));
        connect(edit_, SIGNAL(tabPressed()), this, SLOT(complete()));
        connect(edit_, SIGNAL(upPressed()), this, SLOT(up()));
        connect(edit_, SIGNAL(downPressed()), this, SLOT(down()));
-       connect(edit_, SIGNAL(escapePressed()), this, SLOT(hideParent()));
+       connect(edit_, SIGNAL(hidePressed()), this, SLOT(hideParent()));
 
        layout->addWidget(upPB, 0);
        layout->addWidget(downPB, 0);
@@ -137,19 +138,22 @@ GuiCommandBuffer::GuiCommandBuffer(GuiView * view)
 }
 
 
+void GuiCommandBuffer::cancel()
+{
+       view_->setFocus();
+       edit_->setText(QString());
+}
+
+
 void GuiCommandBuffer::dispatch()
 {
-       std::string const cmd = fromqstr(edit_->text());
-       if (!cmd.empty())
-               theSession().lastCommands().add(cmd);
-       DispatchResult const & dr = dispatch(cmd);
-       if (!dr.error()) {
-               view_->setFocus();
-               edit_->setText(QString());
-               edit_->clearFocus();
-               // If the toolbar was "auto", it is not needed anymore
-               view_->resetCommandExecute();
-       }
+       QString const cmd = edit_->text();
+       view_->setFocus();
+       edit_->setText(QString());
+       edit_->clearFocus();
+       std::string const cmd_ = fromqstr(cmd);
+       theSession().lastCommands().add(cmd_);
+       dispatch(cmd_);
 }
 
 
@@ -253,9 +257,9 @@ void GuiCommandBuffer::down()
 void GuiCommandBuffer::hideParent()
 {
        view_->setFocus();
-       view_->resetCommandExecute();
        edit_->setText(QString());
        edit_->clearFocus();
+       hide();
 }
 
 
@@ -297,6 +301,13 @@ docstring const GuiCommandBuffer::getCurrentState() const
 }
 
 
+void GuiCommandBuffer::hide() const
+{
+       FuncRequest cmd(LFUN_COMMAND_EXECUTE, "off");
+       lyx::dispatch(cmd);
+}
+
+
 vector<string> const
 GuiCommandBuffer::completions(string const & prefix, string & new_prefix)
 {
@@ -336,12 +347,10 @@ GuiCommandBuffer::completions(string const & prefix, string & new_prefix)
 }
 
 
-DispatchResult const & GuiCommandBuffer::dispatch(string const & str)
+void GuiCommandBuffer::dispatch(string const & str)
 {
-       if (str.empty()) {
-               static DispatchResult empty_dr;
-               return empty_dr;
-       }
+       if (str.empty())
+               return;
 
        history_.push_back(trim(str));
        history_pos_ = history_.end();
@@ -349,7 +358,7 @@ DispatchResult const & GuiCommandBuffer::dispatch(string const & str)
        downPB->setEnabled(history_pos_ != history_.end());
        FuncRequest func = lyxaction.lookupFunc(str);
        func.setOrigin(FuncRequest::COMMANDBUFFER);
-       return lyx::dispatch(func);
+       lyx::dispatch(func);
 }
 
 } // namespace frontend
index 8225ec71a720c8b1c42cfbda55da12d3030c4c59..07370875f31cea00c653f266247bae721cb49a2e 100644 (file)
@@ -24,9 +24,6 @@
 class QListWidgetItem;
 
 namespace lyx {
-
-class DispatchResult;
-
 namespace frontend {
 
 class GuiView;
@@ -40,6 +37,8 @@ public:
        GuiCommandBuffer(GuiView * view);
 
 public Q_SLOTS:
+       /// cancel command compose
+       void cancel();
        /// dispatch a command
        void dispatch();
        /// tab-complete
@@ -68,6 +67,9 @@ private:
        /// return the font and depth in the active BufferView as a message.
        docstring const getCurrentState() const;
 
+       /// hide the command buffer.
+       void hide() const;
+
        /// open a listbox and show the contents of the list. When reversed
        /// is true, the contents of the list is filled bottom-up.
        void showList(std::vector<std::string> const & list, 
@@ -78,7 +80,7 @@ private:
                                              std::string & new_prefix);
 
        /// dispatch a command
-       DispatchResult const & dispatch(std::string const & str);
+       void dispatch(std::string const & str);
 
        /// available command names
        std::vector<std::string> commands_;
index 22dd9c8f033a4476cfa762e75a729b5367058435..6dbec414a0a005447dd93091ebdbb36836f542ac 100644 (file)
@@ -45,6 +45,14 @@ void GuiCommandEdit::keyPressEvent(QKeyEvent * e)
                downPressed();
                break;
 
+       case Qt::Key_X:
+               if (e->modifiers() == Qt::AltModifier
+                  || e->modifiers() == Qt::MetaModifier) {
+                       // emit signal
+                       hidePressed();
+                       break;
+               }
+
        default:
                QLineEdit::keyPressEvent(e);
                break;
index 76833115cd255fe97ef20de814989f17280887e3..5968b6fbd06e06c1059a7795bebfed616b63afe6 100644 (file)
@@ -35,6 +35,8 @@ Q_SIGNALS:
        void downPressed();
        /// complete
        void tabPressed();
+       /// leave and hide command buffer
+       void hidePressed();
 
 protected:
        ///
index 77471c98af384e380cf2d720943aab5d65e901cc..11413a680633247e898ff9424429cc3b31869d84 100644 (file)
@@ -323,12 +323,8 @@ void GuiToolbar::add(ToolbarItem const & item)
 
 void GuiToolbar::update(int context)
 {
-       if (visibility_ & Toolbars::AUTO) {
-               bool const was_visible = isVisible();
+       if (visibility_ & Toolbars::AUTO)
                setVisible(visibility_ & context & Toolbars::ALLOWAUTO);
-               if (isVisible() && !was_visible && commandBuffer())
-                       commandBuffer()->setFocus();
-       }
 
        // update visible toolbars only
        if (!isVisible())
index ed7835fcca2d419ebcf98da81f18b24c723d16e7..9a8664d39367dedb37321ef47b93dbb2e6269f5b 100644 (file)
@@ -508,8 +508,7 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
 
 
 GuiView::GuiView(int id)
-       : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0),
-         command_execute_(false)
+       : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0)
 {
        // GuiToolbars *must* be initialised before the menu bar.
        normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
@@ -1344,13 +1343,6 @@ void GuiView::setBusy(bool busy)
 }
 
 
-void GuiView::resetCommandExecute()
-{
-       command_execute_ = false;
-       updateToolbars();
-}
-
-
 double GuiView::pixelRatio() const
 {
 #if QT_VERSION >= 0x050000
@@ -1555,8 +1547,6 @@ void GuiView::updateToolbars()
                        context |= Toolbars::MATHMACROTEMPLATE;
                if (lyx::getStatus(FuncRequest(LFUN_IN_IPA)).enabled())
                        context |= Toolbars::IPA;
-               if (command_execute_)
-                       context |= Toolbars::MINIBUFFER;
 
                for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
                        it->second->update(context);
@@ -3634,7 +3624,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
 
                case LFUN_COMMAND_EXECUTE: {
-                       command_execute_ = true;
+                       bool const show_it = cmd.argument() != "off";
+                       // FIXME: this is a hack, "minibuffer" should not be
+                       // hardcoded.
+                       if (GuiToolbar * t = toolbar("minibuffer")) {
+                               t->setVisible(show_it);
+                               if (show_it && t->commandBuffer())
+                                       t->commandBuffer()->setFocus();
+                       }
                        break;
                }
                case LFUN_DROP_LAYOUTS_CHOICE:
index 74aad81f83d0fd24f11567381b25e9cd699a6add..43b9b988a5db8b6f288c62660a196d1c4704467a 100644 (file)
@@ -84,8 +84,6 @@ public:
        /// are we busy ?
        bool busy() const;
 
-       /// Signal that the any "auto" minibuffer can be closed now.
-       void resetCommandExecute();
 
        /// \name Generic accessor functions
        //@{
@@ -452,9 +450,6 @@ private:
        /// functions that call setBusy;
        int busy_;
 
-       /// Request to open the command toolbar if it is "auto"
-       bool command_execute_;
-
 };
 
 } // namespace frontend
index 20eee931bc9eeeea80b9df8b2b4a7156273b4441..c9610252f3ca3c1b2ad6b43abc60c64fbdd7e0b4 100644 (file)
@@ -348,8 +348,6 @@ void Toolbars::readToolbarSettings(Lexer & lex)
                                flag = MATHMACROTEMPLATE;
                        else if (!compare_ascii_no_case(*cit, "review"))
                                flag = REVIEW;
-                       else if (!compare_ascii_no_case(*cit, "minibuffer"))
-                               flag = MINIBUFFER;
                        else if (!compare_ascii_no_case(*cit, "top"))
                                flag = TOP;
                        else if (!compare_ascii_no_case(*cit, "bottom"))
index 02d0ebe5a4da275f7079da88d74936ed1bd4025d..3e6ac570318af3a9cc9ba3ce90659c2b0605663f 100644 (file)
@@ -110,8 +110,7 @@ public:
                MATHMACROTEMPLATE = 1024, //< show in math macro template
                SAMEROW = 2048, //place to the current row, no new line
                IPA = 4096, //< show when in IPA inset
-               MINIBUFFER = 8192, //< show when command-execute has been invoked
-               ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA | MINIBUFFER
+               ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA
        };
 
        typedef std::vector<ToolbarInfo> Infos;