![]() Registered Member ![]()
|
I am working on a widget that is a menu (like "apple menu") for my own use.The most part of it is ready except the "Recent Items" menuitem .
Is there a way to make a submenu that displays the recent files when I hover over this.Is there any tutorial on that subject ? Any help will be appreciated. |
![]() Registered Member ![]()
|
Hi!
You can parse the file ~/.local/share/recently-used.xbel to get recent applications and documents in XML if not disabled by the user. I don't know any tutorials, but if you use the C++-Backend, you can use the QXmlStreamReader Class to read it. |
![]() Registered Member ![]()
|
Hi.
Sorry for delayed reply. I am not using c++ backend.I am new on coding on qml. If you want to give me a help, there is the code https://gist.github.com/cgiannakidis70/ ... 39cea5d5c6 . Thanks in advance. |
![]() Registered Member ![]()
|
Afaik you cannot do this in pure QML. You can try to reuse the kickoff/kicker-part. Have a look at /usr/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/ui/ and the implementation of the RecentlyUsedView using org.kde.plasma.private.kicker.
|
![]() Registered Member ![]()
|
Hi.
Thanks for the reply . I will work on it later. By the way as you can see in the code above (post #3), I can not create a submenu .I am using "ListView" for menuitems but I think that it is not the proper way or I am using it the wrong way.Any suggestions for submenu creation will be appreciated. |
![]() Registered Member ![]()
|
You could use the QML Menu with Actions. Using actions has the advantage of not being bound to a visible item. So you can bind an action to a shortcut, menu, button, etc. to handle multiple occurences.
See QML Menu. |
![]() Registered Member ![]()
|
Thanks for the suggestion.After studying the "Kicker" code I 've managed to complete the submenu "recent items" task.
I've ended up using ColumnLayout with ListDelegate items.This is roughly the hierarchy of the code:
The problem now is that the menu opens where the mouse pointer is but I want to open on a certain point on the screen.I used also the
Thanks again for your help. |
![]() Registered Member ![]()
|
The popup-coordinates are relative to its parent not to the underlying screen(s). But I really do not know how to handle this. I normally don't touch positions as the user expects them being at a specific point, e.g. where right-clicked. You also have to handle the case when the mouse is outside of your popup to not automatically close it. You can test this behaviour in Plasma using the «focus follows mouse» policy in the system settings. I do switch focus only by moving the mouse which will surely close the popup in your approach.
|
![]() Registered Member ![]()
|
Hi.
I finally wrote the code again from scratch, and now I am using only MouseArea and Menu .It seems that all are working fine except that I lost the panel icon.What I mean is that when I use
Any idea on what might be the problem? Thanks again. |
![]() Registered Member ![]()
|
Did you provide a layout for both representations? Your code should catch the switch from compact to full representation and handle the plasmoid different. Did you upload the new code for testing?
|
![]() Registered Member ![]()
|
Hi.
Here is the main.qml: https://gist.github.com/cgiannakidis70/ ... b051fd2ee5 I am confused and I dont know how to move on. Any help will be appreciated |
![]() Registered Member ![]()
|
You have to provide a fullRepresantation which is almost your current main.qml and compactRepresentation for the icon. See https://techbase.kde.org/Development/Tutorials/Plasma5/QML2/GettingStarted for a minimal example.
|
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]