Re: KStandardAction::showMenubar and native menubars

2016-11-06 Thread Albert Astals Cid
El diumenge, 6 de novembre de 2016, a les 10:43:42 CET, David Faure va 
escriure:
> On mercredi 12 octobre 2016 00:05:30 CET Albert Astals Cid wrote:
> > My current (yet to implement/test) idea is have
> > KStandardAction::showMenubar check all the menubars of the top level
> > windows of the app and if they are all marked as native, then return a
> > dummy QAction that is not inserted in the menubar/actionCollection and
> > that already returns "true" for checked.
> Why not just call QAction::setVisible(false) ?

Yep, that's what 
  https://git.reviewboard.kde.org/r/129261/
does.

Cheers,
  Albert



Re: KStandardAction::showMenubar and native menubars

2016-11-06 Thread David Faure
On mercredi 12 octobre 2016 00:05:30 CET Albert Astals Cid wrote:
> My current (yet to implement/test) idea is have KStandardAction::showMenubar
> check all the menubars of the top level windows of the app and if they are
> all marked as native, then return a dummy QAction that is not inserted in
> the menubar/actionCollection and that already returns "true" for checked.

Why not just call QAction::setVisible(false) ?

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5



Re: KStandardAction::showMenubar and native menubars

2016-10-12 Thread Aleix Pol
On Wed, Oct 12, 2016 at 12:05 AM, Albert Astals Cid  wrote:
> On platforms with native menubars (Mac, Unity) the showMenuBar action makes
> no sense since the menubar is integrated in the desktop shell instead of the
> application so the application gains no space by hiding/showing the menubar
> (sometimes it isn't possible to hide it at all)
>
>
>
> So on thos platforms havign a menu item that does virtually nothing is bad
> and can be a little disconcerting.
>
>
>
> I was thinking if we could somehow fix it centrally in frameworks instead of
> patching every app that has a KStandardAction::showMenubar
>
>
>
> My current (yet to implement/test) idea is have KStandardAction::showMenubar
> check all the menubars of the top level windows of the app and if they are
> all marked as native, then return a dummy QAction that is not inserted in
> the menubar/actionCollection and that already returns "true" for checked.
>
>
>
> This way the app thinks it got a real action to control the menubar status,
> but it is never shown to the user.
>
>
>
> What do you think, do you think it could work or it is trying to be too
> smart and it'll break somehow?

I think it would be great if it did integrate without having to touch
the code and the approach you suggest sounds like it would make sense.
TBH, I didn't expect so many applications hardcoding the action in
their code, I expected it to be a kxmlgui magic thing.

Anyway, your approach would work, I'd give it a try, I don't see a
more elegant approach, even though it sounds a bit hackish. ;)

Aleix


Re: Fwd: KStandardAction::showMenubar and native menubars

2016-10-11 Thread René J . V . Bertin
On Wednesday October 12 2016 01:12:14 Marko Käning wrote:

> > From: Albert Astals Cid 

> > My current (yet to implement/test) idea is have 
> > KStandardAction::showMenubar check all the menubars of the top level 
> > windows of the app and if they are all marked as native, then return a 
> > dummy QAction that is not inserted in the menubar/actionCollection and that 
> > already returns "true" for checked.
> >  
> > This way the app thinks it got a real action to control the menubar status, 
> > but it is never shown to the user.
> >  
> > What do you think, do you think it could work or it is trying to be too 
> > smart and it'll break somehow?

A "long" time ago I patched a menu(bar) related issue in KDE4 apps (but 
possibly in Qt4), with some help from Thomas Luebking. I'd have to hunt down 
the patch to see exactly how this was done, but IIRC it boiled down to checking 
the parent recursively. A native Mac menubar on OS X never has a parent.

I don't disagree with the idea of hiding the menu item when it cannot work, but 
I think we'll have to ensure that the algorithm doesn't simply assume that 
certain platforms have a native menubar. IOW, the algorithm should detect at 
runtime what kind of menubar is being used.

In fact, if you look at Qt5's own code the Qt::AA_DontUseNativeMenuBar 
attribute is ON by default, and is supposed to be turned off by platform 
plugins. An application can turn the attribute back on, and on OS X there can 
be a good reason for that which is related to menu item reuse. I've evoked that 
issue often enough so I won't go into details here, but suffice it to say that 
with the current Qt5 QMenu/Bar implementation you can end up with missing or 
inactive menu items if they're  reused in the native menubar and elsewhere.
That's a very lowlevel Qt5 issue, and the only reliable way around it I've 
found to date is to disable the native menubar in applications where the 
symptoms are particularly annoying (as in my last Kate builds).

A thought that just occurs to me: one way to deal with the "hide/show menubar" 
action would be to repurpose it to allow users to use a non-native menubar 
where that's possible. It'd be a bit of a geeky feature but so is hiding the 
menubar IMHO.

BTW, it seems hat the currently the menubar is detected as being hidden on OS 
X. At least, when I fire up an application with a non-native menubar (or using 
the XCB QPA plugin), the menubar is hidden at first. A bit surprising.

R




KStandardAction::showMenubar and native menubars

2016-10-11 Thread Albert Astals Cid
On platforms with native menubars (Mac, Unity) the showMenuBar action makes no 
sense since 
the menubar is integrated in the desktop shell instead of the application so 
the application gains 
no space by hiding/showing the menubar (sometimes it isn't possible to hide it 
at all)

So on thos platforms havign a menu item that does virtually nothing is bad and 
can be a little 
disconcerting.

I was thinking if we could somehow fix it centrally in frameworks instead of 
patching every app 
that has a KStandardAction::showMenubar

My current (yet to implement/test) idea is have KStandardAction::showMenubar 
check all the 
menubars of the top level windows of the app and if they are all marked as 
native, then return a 
dummy QAction that is not inserted in the menubar/actionCollection and that 
already returns 
"true" for checked.

This way the app thinks it got a real action to control the menubar status, but 
it is never shown 
to the user.

What do you think, do you think it could work or it is trying to be too smart 
and it'll break 
somehow?

Cheers,
  Albert