I am trying to develop some program in QT with QT SDK. Yesterday I was reading about Unity Launcher API on official ubuntu website. But there is example only for Vala and python. Is possible to use Unity Launcher API(quicklists, counters, and progress bars) with C++ language and if it's possible, please post an example.
|
|
I'm also learning Qt and tried to find a way to use Unity API in Qt , I could only use Dbus API , but no luck with Quicklist since it needs a DbusMenu and I do not know how to implement that (still learning :) ). This is the example I created for my self and I hope it's useful for others . Maybe Unity devs can help to correct / fix / add new code (quicklist) to it :)
download the example here http://ubuntuone.com/1SLDPcN9OhrU6LD1wgDs3r |
|||||||||||||||||||||
|
|
There is not currently a specific library for accessing launcher functionality from Qt C++. There is a libunity library but this is heavily glib oriented so is relatively unsuited to Qt. As mentioned in the other answer, the most convenient way to integrate with the launcher is to use the low level dbus API. The basic concept of how to integrate with the launcher is you send a signal to the launcher with an application ID and a set of properties. The application ID is the file name of the .desktop file, normally stored in
CounterTo set the counter, you will need to set the properties such that the count is visible and give it the desired integer value:
Progress BarTo set the progress bar, you will need to set the properties such that the progress is visible and give it the desired double value:
QuicklistThe quicklist can be set by using the dbusmenu Qt library. You will need to include the header file:
The quicklist is created as a In your main window class declaration, add the following instance variables:
Then, in the constructor function:
To add items to the menu, use the [addAction](http: //qt-project.org/doc/qt-5.0/qtwidgets/qmenu.html#addAction) method of the menu to add [QAction](http: //qt-project.org/doc/qt-5.0/qtwidgets/qaction.html) objects. To set the quicklist of the launcher icon, set the 'quicklist' property of the signal:
Configuring the Project FileYou will need to configure the .pro file to add dbus support:
Example ApplicationTo see an full example using all of the launcher functionality from Qt, look at this Github project. |
|||
|
|