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()的参数启动界面