qmh_confluence源码研究

 

licl 01:Confluence.qml  中包含主界面中加载各项目(music等)的操作
var rootMenuItems = [
            { name: qsTr("Music"), mediaPlugin: "music", sourceUrl: "MusicWindow.qml", background: "music.jpg",  constructorArgs: { deleteOnClose: true } },
            { name: qsTr("Picture"), mediaPlugin: "picture", sourceUrl: "PictureWindow.qml", background: "pictures.jpg", constructorArgs: { deleteOnClose: true } },
            { name: qsTr("Video"), mediaPlugin: "video", sourceUrl: "VideoWindow.qml", background: "videos.jpg", constructorArgs: { deleteOnClose: true } },
            { name: qsTr("Radio"), mediaPlugin: "radio", sourceUrl: "RadioWindow.qml", background: "music.jpg", constructorArgs: { deleteOnClose: true } },
            { name: qsTr("Snes"), mediaPlugin: "snes", sourceUrl: "SnesWindow.qml", background: "snes.jpg", constructorArgs: { deleteOnClose: true } },
            { name: qsTr("Weather"), sourceUrl: "WeatherWindow.qml", window: _weatherWindow, background: "weather.jpg" },
            { name: qsTr("Web"), sourceUrl: "WebWindow.qml", window: _browserWindow, background: "web.jpg",
                onActivate: function() { this.initialUrl = "http://qt.nokia.com"; this.enableBrowserShortcuts = true } },
        ]

 


licl 02:Confluence.qml  中包含加载html、qml的app操作
var apps = runtime.apps.findApplications()
        for (var idx in apps) {
            var path = apps[idx]
            var manifest = createQmlObjectFromFile(path + "qmhmanifest.qml")
            var uiType = manifest.ui.substring(manifest.ui.lastIndexOf('.')+1)
            if (uiType == "qml") {
                rootMenuItems.push({ name: manifest.name, appUrl: path + manifest.ui, background: path + manifest.background,
                                   constructorArgs: { deleteOnClose: true }})
                runtime.view.addImportPath(path + "imports")
            } else if (uiType == "html")
           
qmhmanifest.qml并不在源码树中,但是个关键的脚本


licl 03:appsmanager.cpp 中有发现app应用的源码实现


QStringList AppsManager::findApplications() const
{
    QStringList apps;
    foreach(const QString &appSearchPath, LibraryInfo::applicationPaths(m_settings)) {
        QStringList subdirs = QDir(appSearchPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
        foreach(const QString &subdir, subdirs)  {
            QString appPath(appSearchPath + '/' + subdir + '/');
            QString fileName(appPath + "qmhmanifest.qml"); // look for apps/x/qmhmanifest.qml
            QFile prospectiveFile(fileName);
            if (prospectiveFile.exists())
                apps << (QDir(appPath).absolutePath() + '/');
        }
    }
    return apps;
}
在指定的appSearchPath下,遍历subdirs,找到相应的qmhmanifest.qml,以带文件名的完整路径作为appPath。其中subdirs是由该代码自行检测的
若存在qmhmanifest.qml,则将所有带有此配置文件的所有路径,取其绝对路径(以“/”结尾),保存于apps数组中

 

licl 03:
createQmlObjectFromFile函数根据配置文件qmhmanifest.qml建立应用对象manifest,从中找出配置文件的规范。——>直接下载应用示例,
另,要找到appSearchPath确定的方法,具体位置。在函数applicationPaths中找——>封装的libraryinfo.cpp中static QStringList standardResourcePaths函数——>三个Qtmediahub路径下的app目录之一均可放置应用程序
在google搜qmhmanifest.qml,找相应的链接。——>直接下载应用示例
           
           
licl 03:建立manifest对象之后,利用其成员url作为函数 onActivate: function()的参数启动界面        

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值