This patch enables to show even disabled OptItems.

I found that this is wanted sometimes. Example: An inlined equation does not have a label and thus no copy as reference, so these can be hidden. When the equation is displayed, you can insert a label. But, as long as there is no label inserted, copy as reference will be disabled, but I'd like to show it disabled.

This will make the ui somewhat more 'relaxed' by not changing the menus unnecessarily.

Ok ?

Vincent
Index: src/frontends/qt4/Menus.cpp
===================================================================
--- src/frontends/qt4/Menus.cpp (revision 29757)
+++ src/frontends/qt4/Menus.cpp (working copy)
@@ -356,7 +356,8 @@
 
        case MenuItem::Command: {
                FuncStatus status = lyx::getStatus(i.func());
-               if (status.unknown() || (!status.enabled() && i.optional()))
+               if (status.unknown()
+                       || (!status.enabled() && i.optional() && 
!status.showAlways()))
                        break;
                items_.push_back(i);
                items_.back().status(status);
Index: src/FuncStatus.cpp
===================================================================
--- src/FuncStatus.cpp  (revision 29757)
+++ src/FuncStatus.cpp  (working copy)
@@ -82,6 +82,21 @@
 }
 
 
+void FuncStatus::setShowAlways(bool b)
+{
+       if (b)
+               v_ |= SHOWALWAYS;
+       else
+               v_ &= ~SHOWALWAYS;
+}
+
+
+bool FuncStatus::showAlways() const
+{
+       return (v_ & SHOWALWAYS);
+}
+
+
 void FuncStatus::message(docstring const & m)
 {
        message_ = m;
Index: src/FuncStatus.h
===================================================================
--- src/FuncStatus.h    (revision 29757)
+++ src/FuncStatus.h    (working copy)
@@ -39,7 +39,9 @@
                /// Command is off (i. e. the menu item has no checkmark
                /// and the toolbar icon is not pushed).
                /// Not all commands use this
-               OFF = 8
+               OFF = 8,
+               /// Show an OptItem even when it is disabled.
+               SHOWALWAYS = 16
        };
 
        unsigned int v_;
@@ -70,6 +72,11 @@
        bool onoff(bool b) const;
 
        ///
+       void setShowAlways(bool b);
+       ///
+       bool showAlways() const;
+
+       ///
        void message(docstring const & m);
        ///
        docstring const & message() const;

Reply via email to