Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
arjide committed Oct 25, 2014
1 parent 8c18701 commit 2235d49
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 88 deletions.
2 changes: 1 addition & 1 deletion QQStars.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = QQStars
QT += widgets network webkit svg qml quick concurrent sql#gui-private
QT += widgets network webkit svg qml quick concurrent sql #widgets-private core-private gui-private

INCLUDEPATH += \
src \
Expand Down
10 changes: 6 additions & 4 deletions qml/Api/QQApi.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick 2.2
import utility 1.0
import QtQuick.Window 2.1
import QQItemInfo 1.0

QQ{
id: root
Expand All @@ -12,7 +13,7 @@ QQ{
property var friendListData//储存好友列表
property string list_hash//获取好友列表时需要的hash
property string ptwebqq//登录后返回的cookie

windowScale: {
var dosktopWidth = Screen.desktopAvailableWidth
if(dosktopWidth<=1366)
Expand Down Expand Up @@ -121,14 +122,14 @@ QQ{
var list = JSON.parse(data)
if( list.retcode==0 ) {
loginReData = list.result//将数据记录下来
getUserData(myqq.userQQ, getDataFinished)//获取自己的资料
myqq.openSqlDatabase();//登录完成后,打开数据库(用来储存聊天记录)
utility.loadQml("qml/MainPanel/main.qml")//登录成功后加载主面板
myqq.loginStatus = QQ.LoginFinished//设置为登录成功
var poll2data = 'r={"clientid":"'+clientid+'","psessionid":"'+loginReData.psessionid+'","key":0,"ids":[]}&clientid='+clientid+'&psessionid='+loginReData.psessionid
myqq.startPoll2(encodeURI(poll2data))//启动心跳包的post
var url = "http://q.qlogo.cn/headimg_dl?spec=240&dst_uin="+myqq.userQQ
downloadImage(url, "friend_"+myqq.userQQ, "240", getAvatarFinished)//获取头像
getUserData(myqq.userQQ, getDataFinished)//获取自己的资料
downloadImage(QQItemInfo.Friend, url, myqq.userQQ, "240", getAvatarFinished)//获取头像
}else{
myqq.showWarningInfo("登陆出错,错误代码:"+list.retcode)
}
Expand All @@ -148,7 +149,8 @@ QQ{
var list = JSON.parse(data)
if( list.retcode==0 ) {
userData = list.result
root.nick = userData.nick//储存昵称
//console.debug("获取资料成功,我的昵称是:"+userData.nick)
root.nick = String(userData.nick)//储存昵称
myqq.addLoginedQQInfo(userQQ, nick)//保存此账号的登录信息
//getPanelSize()//获取主面板的大小
}else{
Expand Down
21 changes: 10 additions & 11 deletions qml/Chat/ChatWindowCommand.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ import "../Utility"

MyWindow{
id: root
visible: true
minimumHeight: 500
minimumWidth: item_chatPage.minWidth+left_bar.width//设置最小宽度
width: left_bar.width+item_chatPage.width
noBorder: true//无边框的
removable: true//可移动的
fixedSize: false//固定大小的
dockableWindow: false//可停靠的
topHint: false//窗口保持在最前端
noNotifyIcon:false//隐藏任务栏图标
color: "transparent"
windowGlowItem.color: "black"//"#f07000"
setLeftBorder: function(arg){
if(left_bar.isOpen&&left_bar.setBarDefaultWidth(left_bar.defaultWidth+arg)){//如果窗口大小设置成功
root.mySetLeftBorder(arg)//设置窗口位置
Expand All @@ -23,8 +32,6 @@ MyWindow{
root.mySetRightBorder(arg)
}
}

visible: true
onVisibleChanged: {
if(visible)
root.showFront()//显示到最屏幕最前端
Expand All @@ -35,15 +42,6 @@ MyWindow{
else
return "qrc:/images/avatar.png"
}

noBorder: true//无边框的
removable: true//可移动的
fixedSize: false//固定大小的
dockableWindow: false//可停靠的
topHint: false//窗口保持在最前端
noNotifyIcon:false//隐藏任务栏图标
color: "transparent"
windowGlowItem.color: "black"//"#f07000"
property ChatPage currentShowPage//记录当前显示中的聊天页面
property int chatPageWidth: myqq.value("chatPageWidth", 600)//获取聊天页面的width, 初始化为600,聊天也的width

Expand All @@ -54,6 +52,7 @@ MyWindow{
if(currentShowPage)
currentShowPage.visible = false//先将旧的page设置为隐藏
currentShowPage = page//
currentShowPage.myinfo.unreadMessagesCount = 0//将未读消息的条数设为0
//console.log(page+","+currentShowPage)
}
}
Expand Down
3 changes: 0 additions & 3 deletions qml/Login/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ MyWindow{
noNotifyIcon: true//隐藏任务栏图标
windowGlow: false//是否开启阴影
color: "transparent"
Component.onCompleted: {
//systemTray.openMessageWindow()
}

Connections{
target: myqq
Expand Down
1 change: 0 additions & 1 deletion qml/MainPanel/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ MyWindow{
target: systemTray
onActivated:{
if( arg == MySystemTrayIcon.Trigger ) {
utility.consoleLog("点击了托盘")
windowToActive()//将窗口转为活动状态
}
}
Expand Down
132 changes: 84 additions & 48 deletions qml/Utility/SystemTray.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,110 @@ MySystemTrayIcon{
id: root
visible: true
windowIcon: "qrc:/images/avatar.png"
property var currentInfo

onWindowIconChanged: {
if(windowIcon!="qrc:/images/avatar.png"){
timer_shake.start()
}else{
timer_shake.stop()
}
}
ListModel{
id: mymodel
}
menu: myqq.loginStatus == QQ.LoginFinished?menu2:menu1

function openMessageWindow(){
mymodel.append({"sender_info": myqq.createFriendInfo("826169080")})
var component = Qt.createComponent("TrayMessageWindow.qml")
var data = {
"trayX": root.x,
"trayY": root.y,
"trayWidth": root.width,
"mymodel": mymodel
}
component.createObject(null, data)
toolTip: {
if( myqq.loginStatus == QQ.LoginFinished ){
return "QQ:"+myqq.nick+"("+myqq.userQQ+")"
}else
return "星辰QQ"
}

Timer{
id: timer_shake
interval: 300
repeat: true//开启重复闪动
property string old_icon: "qrc:/images/avatar.png"
onTriggered: {
if(root.windowIcon!=""){
old_icon=root.windowIcon
root.windowIcon=""
}else{
root.windowIcon=old_icon
}
property var currentInfo//当前最新消息的发送人的信息
signal triggered(var arg)
property bool hovered: false//鼠标是否悬浮在托盘上空
property TrayMessageWindow trayMessageWindow

Component.onCompleted: {
var component = Qt.createComponent("TrayMessageWindow.qml");
if (component.status == Component.Ready){
trayMessageWindow = component.createObject(null, {});
}
}

function iconShakeStart(){//开启图标闪动
timer_shake.start()
}
function iconShakeStop(){//停止鼠标闪动
timer_shake.stop()
windowIcon = "qrc:/images/avatar.png"
}

onMessageClicked:{
windowIcon="qrc:/images/avatar.png"
iconShakeStop()//停止闪动头像
myqq.addChatPage(currentInfo.uin, currentInfo.mytype)//增加聊天页面
}
onActivated:{
if( timer_shake.running&&arg == MySystemTrayIcon.Trigger ) {
windowIcon="qrc:/images/avatar.png"
if( timer_shake.running&&arg == MySystemTrayIcon.Trigger ) {//如果头像正在闪动
iconShakeStop()//停止闪动头像
myqq.addChatPage(currentInfo.uin, currentInfo.mytype)//增加聊天页面
}
}
toolTip: {
if( myqq.userData ){
return "QQ:"+myqq.nick+"("+myqq.userQQ+")"
}else
return "星辰QQ"
Connections{
target: trayMessageWindow
onStopShakeIcon: {//如果清除全部消息提示
iconShakeStop()//停止闪动头像
}
onSetCurrentInfo:{
currentInfo = info
root.windowIcon = currentInfo.avatar40//设置图标
}
}
signal triggered(var arg)
menu: myqq.loginStatus == QQ.LoginFinished?menu2:menu1


Connections{
target: timer_shake.running?utility:null
onMouseDesktopPosChanged:{
if(arg.x>=root.x&&arg.y>=root.y&&arg.x<=root.x+root.width&&arg.y<=root.y+root.height){
if(!hovered){
hovered = true
//console.debug("进入了托盘区域")
root.toolTip = ""
trayMessageWindow.showWindow(root.x, root.y, root.width, root.height)//显示消息通知框
}
}else if(hovered){
hovered = false
//console.debug("离开了托盘区域")
if(arg.x<root.x||arg.x>root.x+root.width){
trayMessageWindow.closeWindow()//隐藏消息通知栏
//console.debug("即将隐藏消息通知栏")
}
root.toolTip = "QQ:"+myqq.nick+"("+myqq.userQQ+")"
}
}
}

Connections{
target: myqq
onNewMessage:{
if(!myqq.isChatPageExist(fromUin, type)){//判断聊天页面是否存在
if(!myqq.isChatPageExist(fromUin, type)){//判断聊天页面是否存在,如果存在的话 不用提示新消息
if(type==QQItemInfo.Friend){//如果是qq消息
currentInfo = myqq.createFriendInfo(fromUin)
root.showMessage("来自:"+currentInfo.aliasOrNick+"的消息", info.contentData)
root.windowIcon = currentInfo.avatar40
//root.showMessage("来自:"+currentInfo.aliasOrNick+"的消息", info.contentData)
}else if(type==QQItemInfo.Group){//如果是群消息
currentInfo = myqq.createGroupInfo(fromUin)
//root.showMessage("来自:"+currentInfo.aliasOrNick+"的消息", info.contentData)
}else if(type==QQItemInfo.Discu){//如果是讨论组消息
currentInfo = myqq.createDiscuInfo(fromUin)
//root.showMessage("来自:"+currentInfo.aliasOrNick+"的消息", info.contentData)
}
root.windowIcon = currentInfo.avatar40
trayMessageWindow.appendModel(currentInfo)
iconShakeStart()//开始闪动
}
}
}

Timer{
id: timer_shake
interval: 300
repeat: true//开启重复闪动
property string old_icon
onTriggered: {
if(root.windowIcon!=""){
old_icon=root.windowIcon
root.windowIcon=""
}else{
root.windowIcon=old_icon
}
}
}
Expand Down
Loading

0 comments on commit 2235d49

Please sign in to comment.