应用程序开发 – 用于C的Unity Launcher API
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了应用程序开发 – 用于C的Unity Launcher API,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2227字,纯文字阅读大概需要4分钟。
内容图文
我正在尝试使用QT SDK在QT中开发一些程序.昨天我在官方的ubuntu网站上阅读了大约Unity Launcher API.但是只有Vala和python的例子.可以使用C语言的Unity Launcher API(快速列表,计数器和进度条),如果可能的话,请发布一个示例.
解决方法:
我也在学习Qt,并试图找到一种在Qt中使用Unity API的方法,我只能使用Dbus API,但由于它需要DbusMenu并且我不知道如何实现(仍在学习:),因此没有运气Quicklist ).
这是我为自己创造的例子,我希望它对其他人有用.
也许Unity开发人员可以帮助纠正/修复/添加新代码(快速列表):)
/*
Unity Launcher Dbus API exmable for Qt
foxoman [gplus.to/foxoman][foxoman.u@gmail.com]
https://wiki.ubuntu.com/Unity/LauncherAPI#Low_level_DBus_API:_com.canonical.Unity.LauncherEntry
First step : add this line to your Qt project file .pro
QT += dbus
*/
/* I will run this example as Qt console apps */
#include <QtCore/QCoreApplication>
/* Include Qt Dbus required */
#include <QtDBus>
// Qt Main Method
int main(int argc, char *argv[])
{
/* Qt console Main Loop [ in GUI application the Main loop is QApplication ]
Unity API need Main Loop to run */
QCoreApplication a(argc, argv);
/* Create Qt Dbus Signal to send Dbus Message to unity Dbus API
signal com.canonical.Unity.LauncherEntry.Update (in s app_uri, in a{sv} properties)
*/
QDBusMessage signal = QDBusMessage::createSignal(
"/", /* Path */
"com.canonical.Unity.LauncherEntry", /* Unity DBus Interface */
"Update"); /* Update Signal */
/* app_uri
Desktop ID ex: firefox -> need to be pined in the launcher to see the effect
*/
signal << "application://firefox.desktop";
/* properties : A map of strings to variants with the properties to set on the launcher icon */
QVariantMap setProperty;
/* A number to display on the launcher icon */
setProperty.insert("count", qint64(80));
/* show count */
setProperty.insert("count-visible", true);
/* progress bar count must be float between 0 and 1 (mean from 0.00 to 0.100)*/
setProperty.insert("progress", double(0.80));
/* show progress bar */
setProperty.insert("progress-visible", true);
/* Tells the launcher to get the users attention */
setProperty.insert("urgent",true);
/* Pack the properties Map to the signal */
signal << setProperty;
/* Send the signal */
QDBusConnection::sessionBus().send(signal);
return a.exec();
}
在这里下载示例
http://ubuntuone.com/1SLDPcN9OhrU6LD1wgDs3r
内容总结
以上是互联网集市为您收集整理的应用程序开发 – 用于C的Unity Launcher API全部内容,希望文章能够帮你解决应用程序开发 – 用于C的Unity Launcher API所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。