On Fri, Feb 21, 2014 at 10:36 AM, Scott Kostyshak <skost...@lyx.org> wrote:
> On Thu, Feb 20, 2014 at 4:02 AM, Jean-Marc Lasgouttes
> <lasgout...@lyx.org> wrote:
>> 19/02/2014 23:02, Scott Kostyshak:
>>
>>> I'm planning to commit these after 2.1 is released. If anyone has
>>> comments or would like to see them in 2.1 let me know.
>>
>>
>> Concerning menus, the Apple HIG says:
>>
>>   Ensure that a submenu's title is undimmed even when all its commands are
>>   unavailable. As with menu titles, it's important for users to be able to
>>   view a submenu's contents, even if none of them are available in the
>>   current context.
>>
>> https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Menus/Menus.html#//apple_ref/doc/uid/TP30000356-TP6
>
> This has a lot of good info. Thank you for the reference.
> I gave a poor description of the patches. They disable the LFUNs and
> only affect the menus indirectly. I was motivated by the following:
> 1. Open help > Introduction (it should be opened as read only).
> 2. Go to Insert > File > Plain Text and select a file
>
> The file is inserted. This should not happen for read only.
>
>> I did not look at what other HIGs might say, but in this case it is clear.
>> And if one wants to disable submenus which contains only disabled entries,
>> it can be done automatically in the Menus.cpp machinery.
>
> As for the submenus not being accessible if all of the items are
> disabled, attached is a patch.

JMarc (don't worry if you can't look at this before you leave on
vacation), I first interpreted your response in this thread as
disagreeing with the patches I proposed. Upon rereading I think there
was a misunderstanding because of poor description on my part. You
actually made the same change I suggested in the first patch in your
commit at ad56bded.

The other patches still apply cleanly. There are three patches from my
first email and one patch based on your suggestion referencing the
Apple HIG (our recent discussion on UI guides is what brought this
thread back in my mind). I reattach all four to this email (but I did
not change anything).

Scott
From 59acad67ffb8c83de9e88171a7c7d13edf5cf59a Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Fri, 21 Feb 2014 10:26:36 -0500
Subject: [PATCH] Submenus now expand even if all items are disabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As stated in the Apple HIG[1] (via JMarc):

  Ensure that a submenu’s title is undimmed even when all its commands
  are unavailable. As with menu titles, it’s important for users to be
  able to view a submenu’s contents, even if none of them are
  available in the current context.

[1]
https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Menus/Menus.html#//apple_ref/doc/uid/TP30000356-TP6
---
 src/frontends/qt4/Menus.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp
index cc07afc..486efe3 100644
--- a/src/frontends/qt4/Menus.cpp
+++ b/src/frontends/qt4/Menus.cpp
@@ -418,8 +418,7 @@ void MenuDefinition::addWithStatusCheck(MenuItem const & i)
                                // Only these kind of items affect the status 
of the submenu
                                if ((cit->kind() == MenuItem::Command
                                        || cit->kind() == MenuItem::Submenu
-                                       || cit->kind() == MenuItem::Help)
-                                   && cit->status().enabled()) {
+                                       || cit->kind() == MenuItem::Help)) {
                                        enabled = true;
                                        break;
                                }
-- 
1.8.3.2

From 2d594c6be3e495b3652474d9a1f8a2aee8586577 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Wed, 19 Feb 2014 16:58:29 -0500
Subject: [PATCH 2/4] Disable custom insets insert menu if read only

Before, if a document was read only and had no custom insets
defined, the submenu would be enabled.
---
 src/frontends/qt4/Menus.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp
index cc07afc..bf7d1a7 100644
--- a/src/frontends/qt4/Menus.cpp
+++ b/src/frontends/qt4/Menus.cpp
@@ -1215,7 +1215,7 @@ void MenuDefinition::expandFlexInsert(
                }
        }
        // FIXME This is a little clunky.
-       if (items_.empty() && type == InsetLayout::CUSTOM)
+       if (items_.empty() && type == InsetLayout::CUSTOM && !buf->isReadonly())
                add(MenuItem(MenuItem::Help, qt_("No Custom Insets Defined!")));
 }
 
-- 
1.8.3.2

From ca9c99499e80012c1d0e3c4abcf2043221e28578 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Wed, 19 Feb 2014 16:58:31 -0500
Subject: [PATCH 3/4] Disable branches insert menu if read only

---
 src/frontends/qt4/Menus.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp
index bf7d1a7..dfba0e6 100644
--- a/src/frontends/qt4/Menus.cpp
+++ b/src/frontends/qt4/Menus.cpp
@@ -1393,7 +1393,7 @@ void MenuDefinition::expandToolbars()
 
 void MenuDefinition::expandBranches(Buffer const * buf)
 {
-       if (!buf)
+       if (!buf || buf->isReadonly())
                return;
 
        BufferParams const & master_params = buf->masterBuffer()->params();
-- 
1.8.3.2

From 65a66284b70dfc7d169d9c98f8aa2f8544e68fd0 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Wed, 19 Feb 2014 16:58:33 -0500
Subject: [PATCH 4/4] Disable insertion of plain text file if read only

---
 src/frontends/qt4/GuiView.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index 90a45cf..159a32f 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -1871,7 +1871,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, 
FuncStatus & flag)
 
        case LFUN_FILE_INSERT_PLAINTEXT:
        case LFUN_FILE_INSERT_PLAINTEXT_PARA:
-               enable = documentBufferView() && 
documentBufferView()->cursor().inTexted();
+               enable = documentBufferView()
+                       && documentBufferView()->cursor().inTexted()
+                       && !doc_buffer->isReadonly();
                break;
 
        case LFUN_SPELLING_CONTINUOUSLY:
-- 
1.8.3.2

Reply via email to