Fixed Lua closeUserWindow() and QDockWidget Close button.#951
Fixed Lua closeUserWindow() and QDockWidget Close button.#951vadi2 merged 8 commits intoMudlet:developmentfrom itsTheFae:fix-closeUserWindow
closeUserWindow() and QDockWidget Close button.#951Conversation
Updated Lua `closeUserWindow()` to call closeWindow() not hideWindow() Updated Mudlet `closeWindow()` to also close widget object and remove objects from QMap lists so they can be re-added. Added extension class for QDockWidget to monitor widget Close-Button events. Added call to `closeWindow()` inside close-button events.
|
Tagging @Mudlet/core-cpp for review |
ahmedcharles
left a comment
There was a problem hiding this comment.
TDockWidget should probably go in it's own file as well.
If you need help with any of these suggestions, let me know.
src/mudlet.cpp
Outdated
|
|
||
| // addition to help with dock widget closing. | ||
| void TDockWidget::closeEvent( QCloseEvent * event ) { | ||
| mudlet::self()->closeWindow( mudlet::self()->getActiveHost(), windowTitle() ); |
There was a problem hiding this comment.
The active Host may not be the same as the one that was originally used to create it. You can test for this (probably) by opening a 2 connections, open a window in one and then close it while the other is selected.
You can store the Host in a QPointer<Host> in TDockWidget and pass that to closeWindow.
There was a problem hiding this comment.
Ok, that should be simple enough.
I need to learn a bit more about the Hosts and what the best ways are to fetch and interact with them.
Moved TDockWidget code to their own files. Updated usage and storage of Host pointer. Added new sources to `src.pro` and `CMakeLists.txt` files.
|
@ahmedcharles I'm not sure if you get notified when I push commits, tagging you just in case. |
|
|
||
| #include "pre_guard.h" | ||
| #include <QPointer> | ||
| #include <QDockWidget> |
src/TDockWidget.h
Outdated
| void closeEvent( QCloseEvent * ); | ||
|
|
||
| private: | ||
| QPointer<Host> widgetHost; |
There was a problem hiding this comment.
No extra spaces.
And while I'm not much of a fan of this style, we mostly call this variable mpHost. It's probably best to be consistent.
src/TDockWidget.h
Outdated
|
|
||
| private: | ||
| QPointer<Host> widgetHost; | ||
|
|
src/TDockWidget.h
Outdated
|
|
||
| }; | ||
|
|
||
|
|
| }; | ||
|
|
||
|
|
||
| #endif // MUDLET_TDOCKWIDGET_H |
There was a problem hiding this comment.
I'm not sure if github can tell, but make sure there's one newline at the end of the line.
There was a problem hiding this comment.
Yes, there is a new line there.
src/mudlet.cpp
Outdated
| if( ! dockWindowMap.contains( name ) ) | ||
| { | ||
| auto pD = new TDockWidget(); | ||
| auto pD = new TDockWidget( pHost ); |
There was a problem hiding this comment.
No spaces just on the insides of the ().
| @@ -0,0 +1,36 @@ | |||
| /*************************************************************************** | |||
| * * | |||
There was a problem hiding this comment.
Should probably add your name/email here. Though, I suppose you don't have to.
src/TDockWidget.cpp
Outdated
|
|
||
| #include "pre_guard.h" | ||
| #include <QtEvents> | ||
| #include <QDockWidget> |
There was a problem hiding this comment.
No need to include it again.
src/TDockWidget.h
Outdated
| #include "pre_guard.h" | ||
| #include <QPointer> | ||
| #include <QDockWidget> | ||
| #include <QWidget> |
There was a problem hiding this comment.
Probably don't need to include this one.
src/TDockWidget.h
Outdated
| TDockWidget( Host * ) ; | ||
|
|
||
| protected: | ||
| void closeEvent( QCloseEvent * ); |
There was a problem hiding this comment.
Should have override at the end, before the ;.
|
The more I look into the code here, the more I realize it's more complex than it seems.
I stopped looking after finding 5 things. The current approach in the PR seems to work, but I don't think it will fix all of the issues here. Let's take a step back and try and fix them one at a time, if that's ok? Let me know if you'd like any help. 1 and 3 are pretty straight forward. 2 requires |
|
Oh, apparently <sarcasm>I'm truly excited now.</sarcasm> |
|
Okay a bit of history before we proceed - user windows were created first. Then we abandoned them, because building a out of them completely would have sucked due to all the window borders, so we left them be as-is and made miniconsoles instead - a much more nicely embeddable thing. User windows of course still have their purpose for example you can drag them to their own monitor. The API has moved in a direction of re-using functions for similar stuff after that - so for example showWindow/hideWindow both operate on a label and a miniconsole. Given how closeUserWindow didn't work before - since we're reanimating userwindows, I'd prefer to bring them into alignment with miniconsoles and labels instead of having them by the side - so 1) could we have The other thing as you might notice is that there is no closeWindow for labels or miniconsoles. That's by design - efficiency reasons. Wouldn't be against adding it in for people who'd really want it, but making that entire mechanism work would be a pretty huge scope of work. To solve the original problem of you not being able to re-open a userwindow after it has been closed, how about we 2) make the X on the widget redirect to hiding the window, so that creating/showing it will make it show up again? |
|
I suppose that makes sense, sort of... I'll have a think on it for a bit. |
|
... bit late to the party but are we talking about the dock-able windows that can be conveniently moved to a different monitor when you are on a multi-headed PC?✽ That being the case you can see the dockable widgets in the default context (right-click) menu on the Title-bar of any dock-widget or on any toolbar - note that we still haven't gotten around to putting up "names" (or ideally "type - profile - name" to handle multi-playing set-ups) for all items yet, including the main toolbars...! See how the "comms" window is handled below: FTR The grey item is the (docked but float-able) toolbar with manual map movement direction controls - floating toolbars are not hidable/showable via the built-in UI so the checkbox is greyed out and we do not (currently) show a title on them which really breaks in a multi-playing setup as you do not know which user toolbar works which profile... 😒 ✽ = {That reminds me I really must have another go at asking Matrox to update their Linux drivers, the latest kernel their binary blob driver with open source API supports is 3.10 😭 so is now unusable and I cannot yet get back to using a display card and a hydra system with a set of 4 monitors!} |
|
Yep it's those ones!
…On Tue, 25 Apr 2017 8:43 pm Stephen Lyons, ***@***.***> wrote:
... bit late to the party but are we talking about the dock-able windows
that can be conveniently moved to a different monitor when you are on a
multi-headed PC?✽ That being the case you can see the dockable widgets in
the default context (right-click) menu on the Title-bar of any dock-widget
or on any toolbar - note that we still haven't gotten around to putting up
"names" (or ideally "type - profile - name" to handle multi-playing
set-ups) for all items yet, including the main toolbars...! See how the
"comms" window is handled:
[image: peek 2017-04-25 19-31]
<https://cloud.githubusercontent.com/assets/6163092/25401713/61b2abda-29ee-11e7-920f-993bf9e1a424.gif>
FTR The grey item is the (docked but float-able) toolbar with manual map
movement direction controls - floating toolbars are not hidable/showable
via the built-in UI so the checkbox is greyed out and we do not (currently)
show a title on them which really breaks in a multi-playing setup as you do
not know which user toolbar works which profile... 😒
✽ = {That reminds me I really must have another go at asking Matrox to
update their Linux drivers, latest their binary blob with open source API
is kernel 3.10 😭 so is now unusable and I cannot yet get back to using a
display card and a hydra system with a set of 4 monitors!}
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#951 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGxjPebO18fDrJubSIuEun3TTC-wpUaks5rzj7hgaJpZM4NGtCo>
.
|
I'm going to sit this one out and let the others decide what the api should look like.
|
I'm getting a crash in when I re-open a profile and try to call open To reproduce:
function userwindowTest()
openUserWindow("dockedwindow")
print("created docked window")
tempTimer(1, function() closeUserWindow("dockedwindow") print("hid docked window") end)
tempTimer(3, function() showWindow("dockedwindow") print("showed docked window") end)
end
userwindowTest()
|
|
Let us know if you'd like help in figuring out the problem! |
|
This probably needs closer testing and review. I've poured over the miniconsole and I'm still not sure how it works, or if it works. I tried using it in 2.1 and got the same results so I'm almost sure I'm doing it wrong. I'm hopeful this code wont break anything in those regards. I tested the lua functions and have not generated a crash. Edit: DockWidgets aren't properly host-mapped. heh. I'll be patching that shortly. |
|
Hey we broke your stuff with some formatting changes in |
|
Sorry I should have done a merge locally but spaced. Thanks for fixing it. |
vadi2
left a comment
There was a problem hiding this comment.
X and closeWindow() work and openWindow() on the window again opens it - great!
Thank you!
| #ifndef MUDLET_TDOCKWIDGET_H | ||
| #define MUDLET_TDOCKWIDGET_H | ||
| /*************************************************************************** | ||
| * * |
There was a problem hiding this comment.
You really do want to add your name + contact EMail to the header for each file in the year that you work on them.
How are you going to get universal praise and admiration for your deft coding and cunning algorithms if no-one knows it was you? 😀
{And hiding your details really won't stop the tar-and-feathers brigade if you do a really monumental cock-up - and as someone who occasionally does make mistakes, I feel strongly that feathers keep you warm and I am sure there is some use for tar!} 🤣
There was a problem hiding this comment.
Heh, well in my head it was only a tiny bit of code I cobbled together from examples and code bits in the sources already.
I will probably make more changes to TDockWidget when I add window layout code, so I suppose I'll add my info then. :)
Gmail has good anti-spam for this reason.
|
Not sure I am clear on whether the Host mapping will do what I think it might. If I have two profiles loaded and running and I create a mini-console called "info" in one profile, can I create the same named one in the other profile? Maybe that is a side-issue and not entirely within scope of this PR, but I am aware that I cannot do that in the existing code (or as it was the last time I looked at it) i.e. #842 . |
|
Yes, you should be able to create a window of the same name in two profiles. There is an issue still with creating both a Miniconsole and a DockWidget console of the same name, since they both occupy the same console map. I had a fix in mind for that (some 'simple' name prefixing within the console map could do it.) but the issue is almost a non-issue and could be patched later if needed. Vadi has found a crash with this code, related to closing a profile with docked consoles open. The dockwidgets don't get closed with the profile. I'll have a fix for that shortly but may not add it to this PR unless you all think I should. |
|
Done! Thanks so much for this fix 💯 |

Updated Lua
closeUserWindow()to callmudlet::self()->closeWindow()notmudlet::self()->hideWindow()Updated Mudlet
closeWindow()to also close QDockWidget object and remove objects from QMap lists so they can be re-added later.Added extension class for
QDockWidgetcalledTDockWidgetto monitor DockWidget Close-Buttonevents and handle them properly.
Added call to
mudlet::self()->closeWindow()insideTDockWidget:closeEvent().This should address Issue #721