LomoX界面库-高仿QQ2011、QQ音乐盒等

来源:互联网 发布:苹果手机网络制式查询 编辑:程序博客网 时间:2024/05/03 20:25
本帖最后由 shawken 于 2012-11-13 09:23 编辑

UI界面开发的新思想,不像传统的DirectUI的方式,而是以Html做为软件的界面布局,这种效果可以达到很多DirectUI达不到的效果,关键没难度。

Windows 8 的Metro风格开发,也是采用了与此一致的思想,对于Windows 8,布局使用的是xaml,而对于本项目,界面是html.


LomoX是一款基于QT开发,跨平台,已支持Linux,以html,css,javascript来布局软件界面,逻辑由C++实现。
支持html5。目前正在开发MAC支持、windows phone支持。
已发布C++插件版本。
网站:www.lomox.hk
论坛:bbs.lomox.hk
QQ群:41830909
更多项目描述,请访问本人博客或项目网站:
http://www.windowscoder.org

目前已开源:UI层库,插件源码。

插件机制:
插件主要是使用C++来开发业务逻辑层,通过与JavaScript进行交互,达到逻辑的实现,例如:C++写的一个简单的dll
  1. calcPlugin.cpp
  2. class CalcPlugin implements Plugin
  3. {
  4. private:
  5.       string action_add = "call_add";
  6.       string action_sub = "call_sub";
  7. public:
  8.       PluginResult execute(string action,JSONArray jsonParams,string callBackID)
  9.       {
  10.            string resultStatus = PluginResult.Status.OK;  //PluginResult.OK|ERR

  11.           if(action.equal(action_add))
  12.            {
  13.                 int num1 = jsonParams.getNumber(0);     //Get First number
  14.                 int num2 = jsonParams.getNumber(1);     //Get Second number
  15.                 int sum = num1 + num2;
  16.                 JSONObject jsonObj = new JSONObject();
  17.                 jsonResult.put("sum",sum);
  18.                 return new PluginResult(resultStatus,jsonResult);
  19.            }
  20.            else if(action.equal(action_sub))
  21.            {
  22.                 int num1 = jsonParams.getNumber(0);     //Get First number
  23.                 int num2 = jsonParams.getNumber(1);     //Get Second number
  24.                 int sub = num1 - num2;
  25.                 JSONObject jsonObj = new JSONObject();
  26.                 jsonResult.put("sub",sub);
  27.                 return new PluginResult(resultStatus,jsonResult);
  28.            }
  29.       }
  30. }
复制代码
那么对于Javascript来说:Javascript主要是为了调用C++中的函数:CalcPlugin
  1. plugins.js
  2. //define the Calc class:
  3. var Calc = function(){
  4. };
  5. /*if the status is "PluginResult.Status.OK" that call successCallBack, and if the status is "PluginResult.Status.ERR", then call errorCallBack.*/

  6. Calc.prototype.add=function(successCallBack,errorCallBack,num1,num2){
  7.      Lomox.calcPlugin.execute(successCallBack,errorCallBack,"call_add",[num1,num2]);
  8. }

  9. Calc.prototype.sub=function(successCallBack,errorCallBack,num1,num2){
  10.      Lomox.calcPlugin.execute(successCallBack,errorCallBack,"call_sub",[num1,num2]);
  11. }
复制代码
最后一步,则在html页面中引入js.
  1. <script src="lomox.js"></script>
  2. <script src="plugins.js"></script>
复制代码
  1. var calc = new Calc();

  2. function sumSuccess(result){
  3.   alert("result:"+result.sum)
  4. }

  5. function sumError(result){
  6.   alert("result:"+result.msg)
  7. }

  8. calc.add(sumSuccess,sumError,12,14);

  9. function subSuccess(result){
  10.   alert("result:"+result.sub)
  11. }
  12. function subError(result){
  13.   alert("result:"+result.msg)
  14. }
  15. calc.add(subSuccess,subError,12,14);
复制代码
同样的,对于Javascript,也就是说,UI界面调用C++插件层。举个例子:
  1. class CalcPlugin implements Plugin
  2. {
  3. private:
  4.       string action_add = "call_showmsg";
  5. public:
  6.       PluginResult execute(string action,JSONArray jsonParams,string callBackID)
  7.       {
  8.            string resultStatus = PluginResult.Status.OK;  //PluginResult.OK|ERR
  9.           if(action.equal(action_add))
  10.            {
  11.                 string msg jsonParams.getString(0);     //Get the Text you want to show
  12.                 //Here call our JavaScript function "ShowMsg"
  13.                 Lomox.execJS( "ShowMsg("+msg+");" );              
  14.                 JSONObject jsonObj = new JSONObject();
  15.                 return new PluginResult(resultStatus,jsonResult);
  16.            }      
  17.       }
  18. }
复制代码
举一些开源的例子与商业例子:

QQ2011:


QQ音乐盒:


谷歌浏览器:


Metro风格电话软件:


界面仿QQ股票软件、数据使用广发证券API:




GIS系统(B/S版)转换成LomoX桌面版。LomoX特性之一。离线客户端开发。