From 0dbfbabc6b4d5c8f1141104b17202122abcef406 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sat, 30 Jan 2010 16:41:28 +0000 Subject: [PATCH] Move the message() function from lfunUiToggle to GuiView::dispatch(). Also, let the lfunUiToggle return a bool and let the parameter be a string instead of the FuncRequest. (Pavel, what was "FuncRequest fr(LFUN_INSET_INSERT, "fullscreen")" supposed to mean ?). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33279 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 145a7b9b66..b2d602761a 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2994,8 +2994,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) showDialog("symbols", data); // bug 5274 } else if (name == "prefs" && isFullScreen()) { - FuncRequest fr(LFUN_INSET_INSERT, "fullscreen"); - lfunUiToggle(fr); + lfunUiToggle("fullscreen"); showDialog("prefs", data); } else showDialog(name, data); @@ -3006,11 +3005,16 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) dr.setMessage(cmd.argument()); break; - case LFUN_UI_TOGGLE: - lfunUiToggle(cmd); + case LFUN_UI_TOGGLE: { + string arg = cmd.getArg(0); + if (!lfunUiToggle(arg)) { + docstring const msg = "ui-toggle " + _("%1$s unknown command!"); + dr.setMessage(bformat(msg, from_utf8(arg))); + } // Make sure the keyboard focus stays in the work area. setFocus(); break; + } case LFUN_SPLIT_VIEW: { LASSERT(doc_buffer, break); @@ -3119,10 +3123,9 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) } -void GuiView::lfunUiToggle(FuncRequest const & cmd) +bool GuiView::lfunUiToggle(string const & ui_component) { - string const arg = cmd.getArg(0); - if (arg == "scrollbar") { + if (ui_component == "scrollbar") { // hide() is of no help if (d.current_work_area_->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) @@ -3132,18 +3135,13 @@ void GuiView::lfunUiToggle(FuncRequest const & cmd) else d.current_work_area_->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff); - return; - } - if (arg == "statusbar") { + } else if (ui_component == "statusbar") { statusBar()->setVisible(!statusBar()->isVisible()); - return; - } - if (arg == "menubar") { + } else if (ui_component == "menubar") { menuBar()->setVisible(!menuBar()->isVisible()); - return; - } + } else #if QT_VERSION >= 0x040300 - if (arg == "frame") { + if (ui_component == "frame") { int l, t, r, b; getContentsMargins(&l, &t, &r, &b); //are the frames in default state? @@ -3153,15 +3151,13 @@ void GuiView::lfunUiToggle(FuncRequest const & cmd) } else { setContentsMargins(0, 0, 0, 0); } - return; - } + } else #endif - if (arg == "fullscreen") { + if (ui_component == "fullscreen") { toggleFullScreen(); - return; - } - - message(bformat("LFUN_UI_TOGGLE " + _("%1$s unknown command!"), from_utf8(arg))); + } else + return false; + return true; } -- 2.39.5