Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MenuBar #99

Merged
merged 6 commits into from Aug 17, 2020
Merged

Conversation

joseivanlopez
Copy link
Contributor

Problem

A new MenuBar widget was added in a previous PR, see #97. But the management of hot-keys for the top level menu options was completely missing.

Solution

Hot-keys for top level menu options are now properly handled.

Bonus: A new class CyclicContainer was created to extract some repeated logic.

Note: This PR does not fix the shorcuts conflicts in the top level menu options. This will come with a separate fix, see https://bugzilla.suse.com/show_bug.cgi?id=1175142.

#include <vector>

template <class T>
class CyclicContainer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a container with wrap-around behaviour for next() and previous(), right Please add some lines of documentation to describe this.

Does it also have something like selectFirst() and selectLast() ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run make docs and make sure that the HTML docs make sense for the new code. A one line description for a new class is a bare minimum!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selecting first and last is not explicitly needed. Do you think we need to add it?

Copy link
Contributor

@shundhammer shundhammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once it has some documentation for that CyclicContainer class, LGTM.

}


void add( T * element )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO! NO! NO!

This is a "naked pointer". Nobody knows who owns (deletes) the data pointed to.

Use smart pointers instead. If you must use a dumb pointer you must document the ownership.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd vote to document who owns the object. That is indeed missing here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this class is ultimately using YMenuItems, ownership will remain with the YSelectionWidget, as usual; but that knowledge is implicit here. Somebody reading this code will probably not know that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I will add documentation.

@shundhammer
Copy link
Contributor

LGTM

@joseivanlopez joseivanlopez merged commit 716185e into libyui:master Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants