]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
On Mac, moving down a paragraph should place the cursor at the end of the current...
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 66d3997862c1b076f0626ff5a7b0511e5ff97d7c..993e830036c5fb3a3e2a7c1d346fd9736e07262a 100644 (file)
@@ -34,6 +34,7 @@
 #include "qt_helpers.h"
 
 #include "frontends/alert.h"
+#include "frontends/KeySymbol.h"
 
 #include "buffer_funcs.h"
 #include "Buffer.h"
@@ -58,6 +59,7 @@
 #include "LyXVC.h"
 #include "Paragraph.h"
 #include "SpellChecker.h"
+#include "Session.h"
 #include "TexRow.h"
 #include "TextClass.h"
 #include "Text.h"
@@ -501,7 +503,7 @@ GuiView::GuiView(int id)
 
        if (lyxrc.allow_geometry_session) {
                // Now take care of session management.
-               if (restoreLayout(true))
+               if (restoreLayout())
                        return;
        }
 
@@ -623,7 +625,7 @@ void GuiView::saveUISettings() const
 }
 
 
-bool GuiView::restoreLayout(bool force_inittoolbars)
+bool GuiView::restoreLayout()
 {
        QSettings settings;
        settings.beginGroup("views");
@@ -672,9 +674,18 @@ bool GuiView::restoreLayout(bool force_inittoolbars)
        if ((dialog = findOrBuild("findreplaceadv", true)))
                dialog->prepareView();
 
-       if (!restoreState(settings.value("layout").toByteArray(), 0)
-           || force_inittoolbars)
+       if (!restoreState(settings.value("layout").toByteArray(), 0))
                initToolbars();
+       
+       // init the toolbars that have not been restored
+       Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
+       Toolbars::Infos::iterator end = guiApp->toolbars().end();
+       for (; cit != end; ++cit) {
+               GuiToolbar * tb = toolbar(cit->name);
+               if (tb && !tb->isRestored())
+                       initToolbar(cit->name);
+       }
+
        updateDialogs();
        return true;
 }
@@ -717,42 +728,47 @@ void GuiView::initToolbars()
        // extracts the toolbars from the backend
        Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
        Toolbars::Infos::iterator end = guiApp->toolbars().end();
-       for (; cit != end; ++cit) {
-               GuiToolbar * tb = toolbar(cit->name);
-               if (!tb)
-                       continue;
-               int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
-               bool newline = !(visibility & Toolbars::SAMEROW);
-               tb->setVisible(false);
-               tb->setVisibility(visibility);
-
-               if (visibility & Toolbars::TOP) {
-                       if (newline)
-                               addToolBarBreak(Qt::TopToolBarArea);
-                       addToolBar(Qt::TopToolBarArea, tb);
-               }
+       for (; cit != end; ++cit)
+               initToolbar(cit->name);
+}
 
-               if (visibility & Toolbars::BOTTOM) {
-                       if (newline)
-                               addToolBarBreak(Qt::BottomToolBarArea);
-                       addToolBar(Qt::BottomToolBarArea, tb);
-               }
 
-               if (visibility & Toolbars::LEFT) {
-                       if (newline)
-                               addToolBarBreak(Qt::LeftToolBarArea);
-                       addToolBar(Qt::LeftToolBarArea, tb);
-               }
+void GuiView::initToolbar(string const & name)
+{
+       GuiToolbar * tb = toolbar(name);
+       if (!tb)
+               return;
+       int const visibility = guiApp->toolbars().defaultVisibility(name);
+       bool newline = !(visibility & Toolbars::SAMEROW);
+       tb->setVisible(false);
+       tb->setVisibility(visibility);
+
+       if (visibility & Toolbars::TOP) {
+               if (newline)
+                       addToolBarBreak(Qt::TopToolBarArea);
+               addToolBar(Qt::TopToolBarArea, tb);
+       }
 
-               if (visibility & Toolbars::RIGHT) {
-                       if (newline)
-                               addToolBarBreak(Qt::RightToolBarArea);
-                       addToolBar(Qt::RightToolBarArea, tb);
-               }
+       if (visibility & Toolbars::BOTTOM) {
+               if (newline)
+                       addToolBarBreak(Qt::BottomToolBarArea);
+               addToolBar(Qt::BottomToolBarArea, tb);
+       }
+
+       if (visibility & Toolbars::LEFT) {
+               if (newline)
+                       addToolBarBreak(Qt::LeftToolBarArea);
+               addToolBar(Qt::LeftToolBarArea, tb);
+       }
 
-               if (visibility & Toolbars::ON)
-                       tb->setVisible(true);
+       if (visibility & Toolbars::RIGHT) {
+               if (newline)
+                       addToolBarBreak(Qt::RightToolBarArea);
+               addToolBar(Qt::RightToolBarArea, tb);
        }
+
+       if (visibility & Toolbars::ON)
+               tb->setVisible(true);
 }
 
 
@@ -1334,7 +1350,7 @@ void GuiView::removeWorkArea(GuiWorkArea * wa)
 
        // It is not a tabbed work area (i.e., the search work area), so it
        // should be deleted by other means.
-       LASSERT(found_twa, /* */);
+       LASSERT(found_twa, return);
 
        if (d.current_work_area_ == 0) {
                if (d.splitter_->count() != 0) {
@@ -1855,6 +1871,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                enable = documentBufferView() && documentBufferView()->cursor().inTexted();
                break;
 
+       case LFUN_SPELLING_CONTINUOUSLY:
+               flag.setOnOff(lyxrc.spellcheck_continuously);
+               break;
+
        default:
                return false;
        }
@@ -2385,7 +2405,7 @@ bool GuiView::exportBufferAs(Buffer & b)
 
        string s = fromqstr(filter);
        size_t pos = s.find(" (*.");
-       LASSERT(pos != string::npos, /**/);
+       LATTEST(pos != string::npos);
        string fmt_prettyname = s.substr(0, pos);
        string fmt_name;
        fname.set(fromqstr(result.second));
@@ -2436,12 +2456,7 @@ bool GuiView::saveBuffer(Buffer & b, FileName const & fn)
        if (fn.empty() && b.isUnnamed())
                return renameBuffer(b, docstring());
 
-       bool success;
-       if (fn.empty())
-               success = b.save();
-       else
-               success = b.saveAs(fn);
-       
+       bool const success = (fn.empty() ? b.save() : b.saveAs(fn));
        if (success) {
                theSession().lastFiles().add(b.fileName());
                return true;
@@ -3217,7 +3232,7 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing(
 void GuiView::dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr)
 {
        BufferView * bv = currentBufferView();
-       LASSERT(bv, /**/);
+       LASSERT(bv, return);
 
        // Let the current BufferView dispatch its own actions.
        bv->dispatch(cmd, dr);
@@ -3763,6 +3778,12 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        one.startscript(Systemcall::DontWait, command);
                        break;
                }
+
+               case LFUN_SPELLING_CONTINUOUSLY:
+                       lyxrc.spellcheck_continuously = !lyxrc.spellcheck_continuously;
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
+                       break;
+
                default:
                        // The LFUN must be for one of BufferView, Buffer or Cursor;
                        // let's try that: