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 30, 2014
1 parent 079de3d commit 4767c88
Show file tree
Hide file tree
Showing 24 changed files with 514 additions and 301 deletions.
8 changes: 4 additions & 4 deletions QQStars.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ SOURCES += src/main.cpp \
src/mywidgets/mywindow.cpp \
src/qqstars/qqstars.cpp \
src/mywidgets/systemtrayicon.cpp \
src/utility/threaddownloadimage.cpp \
src/mywidgets/mysvgview.cpp \
src/mywidgets/myimage.cpp \
src/mywidgets/mymessagebox.cpp \
src/utility/myhttprequest.cpp \
src/qqstars/qqiteminfo.cpp
src/qqstars/qqiteminfo.cpp \
src/utility/downloadimage.cpp

RESOURCES += \ # qml.qrc
images.qrc \
Expand Down Expand Up @@ -48,12 +48,12 @@ HEADERS += \
src/mywidgets/mywindow.h \
src/qqstars/qqstars.h \
src/mywidgets/systemtrayicon.h \
src/utility/threaddownloadimage.h \
src/mywidgets/mysvgview.h \
src/mywidgets/myimage.h \
src/mywidgets/mymessagebox.h \
src/utility/myhttprequest.h \
src/qqstars/qqiteminfo.h
src/qqstars/qqiteminfo.h \
src/utility/downloadimage.h

OTHER_FILES += \
qml/Utility/CodeInput.qml \
Expand Down
3 changes: 2 additions & 1 deletion qml/Api/QQApi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ QQ{
property var friendListData//储存好友列表
property string list_hash//获取好友列表时需要的hash
property string ptwebqq//登录后返回的cookie
property string psessionid: loginReData?loginReData.psessionid:""//登录后返回的数据

signal closeMainPanel//如果需要从头重新登录就关闭主面板

Expand Down Expand Up @@ -134,8 +135,8 @@ QQ{
myqq.startPoll2(encodeURI(poll2data))//启动心跳包的post
}else{
console.debug("重新登录失败")
root.loginStatus = QQ.Offline//将登录状态设置为离线
showWarningInfo("QQ已掉线,请重新登录")
root.closeChatWindow();//关闭聊天窗口
root.closeMainPanel();//关闭主面板
utility.loadQml("qml/Login/main.qml")//打开登录面板
}
Expand Down
15 changes: 10 additions & 5 deletions qml/Chat/ChatPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ Item{
property alias rightBar: right_bar
property alias inputBox: input
property alias listModel: mymodel
property QQItemInfo myinfo//用来储存自己的各种信息(用uin标识)
property QQItemInfo myinfo//用来储存自己的各种信息(用uin标识)

onMyinfoChanged: {
if(myinfo){//从缓冲区中读取数据
var message_list = myinfo.getChatRecords()//获取内存中的所有聊天记录
for(var i=0;i<message_list.length;++i){
var message = message_list[i]//读取第i条消息
var messageInfo = myinfo.createChatMessageInfo(message.messageID)
var data = {
"uin":message.senderUin,//发送者是谁
"uin":messageInfo.senderUin,//发送者是谁
"send_uin":"",//如果mode为right才需要此值(为发送给谁)
"mode": message.senderUin==myqq.userQQ?"right":"left",//要判断发送者是不是自己(这条消息是发送的还是接收的)
"message": message.contentData,//消息内容
"message_info": messageInfo,//消息内容
"parent_info": myinfo
}
listModel.append(data)
Expand All @@ -41,7 +43,7 @@ Item{
"uin":info.senderUin,//发送者是谁
"send_uin":"",//如果mode为right才需要此值(为发送给谁)
"mode": "left",//要判断发送者是不是自己(这条消息是发送的还是接收的)
"message": info.contentData,//消息内容
"message_info": info,//消息内容
"parent_info": myinfo
}
var temp = scroll_list.isContentEnd()//记录是否应该讲聊天页面拉到最后
Expand Down Expand Up @@ -121,11 +123,14 @@ Item{

onClicked: {
inputBox.selectAll()//先选中全部
var messageInfo = myinfo.createChatMessageInfo(myqq.getMessageIndex())
messageInfo.contentData = inputBox.selectedText//选中的文本
//创建一个新的聊天储存聊天内容各种信息的对象(例如发送时间等等)
var data = {
"uin":myqq.userQQ,//发送者是当前登录的用户qq
"send_uin":myuin,//发送给自己(这里的自己代表对当前登录的用户qq来说是他的好友或者群,讨论组)
"mode": "right",
"message": inputBox.selectedText,//选中的文本
"message_info": messageInfo,
"parent_info": myinfo
}
listModel.append(data)
Expand Down
18 changes: 12 additions & 6 deletions qml/Chat/MessageListComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ Component{
id: root
width: parent.width
height: nick.implicitHeight+backgound.height+backgound.anchors.topMargin
property var myinfo: myqq.createFriendInfo(uin)
property FriendInfo myinfo: myqq.createFriendInfo(uin)
//这条消息的发送者的信息,好友里面就是你的好友本身,群里边就是此条群消息的发送者
property string sendUin: send_uin//将此消息发送给谁
property QQItemInfo parentInfo: parent_info//消息属主的info
property QQItemInfo parentInfo: parent_info
//消息属主的info,好友里面就是你的好友本身,群里边就是群本身
property ChatMessageInfo messageInfo: message_info
//这条消息自身的信息,千万不要和parentInfo和myinfo搞混了

property var sendMessage: {
if(!parentInfo)
Expand All @@ -30,16 +34,18 @@ Component{
Component.onCompleted: {
//console.log(message)//输出消息内容
if(sendUin!=""&&sendMessage&&mode=="right"){//如果为模式right代表是要发送消息
sendMessage(sendMessageFinished, sendUin, message)//发送消息
sendMessage(sendMessageFinished, sendUin, messageInfo.contentData)//发送消息
}
}
function sendMessageFinished(error, data){//如果这个Item发送信息,此函数用来接收发送结果
//console.log(data)
if(!error){//如果没有出错
data = JSON.parse(data)
if(data.retcode==0&&data.result=="ok"){
var message_info = myqq.createChatMessageInfo(myqq.userQQ, mytext.text)
parentInfo.addChatRecord(message_info)//将聊天记录保存到内存当中
var date_time = new Date
messageInfo.date = date_time.getDate()
messageInfo.time = date_time.getTime()
parentInfo.addChatRecord(messageInfo)//将聊天记录保存到内存当中
console.debug("消息发送成功")
}else{
console.log("发送失败")
Expand Down Expand Up @@ -93,7 +99,7 @@ Component{
}

wrapMode: TextEdit.Wrap
text: message
text: root.messageInfo.contentData
onTextChanged: {
if(text[text.length-1]=="\n"){
text = text.substr(0, text.length-1)
Expand Down
8 changes: 7 additions & 1 deletion qml/Login/LoginPanel/LoginPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ Item{
source: myqq.avatar240
x:-30/80*width
anchors.verticalCenter: inputarea.verticalCenter

Connections{
target: myqq
onUserQQChanged:{
avatar_image.source = myqq.avatar240
}
}

onLoadError:{
console.log("头像加载出错:"+myqq.avatar240)
source = "qrc:/images/avatar.png"
Expand Down
19 changes: 9 additions & 10 deletions qml/Login/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import "../Utility"
import "../MainPanel"
import "LoginPanel"
import "../Chat"
//import QtWebKit 3.0

MyWindow{
id:main
Expand All @@ -32,7 +31,15 @@ MyWindow{
noNotifyIcon: true//隐藏任务栏图标
windowGlow: false//是否开启阴影
color: "transparent"


function openSettingPage() {//进行设置
settings_page.enabled = true
flipable.flipped = false
}
function openLoginPage() {//打开登录面板
login_page.enabled = true
flipable.flipped = true
}
Connections{
target: myqq
onError:{
Expand Down Expand Up @@ -64,14 +71,6 @@ MyWindow{
}
}
}
function openSettingPage() {//进行设置
settings_page.enabled = true
flipable.flipped = false
}
function openLoginPage() {//打开登录面板
login_page.enabled = true
flipable.flipped = true
}

Flipable {
id: flipable
Expand Down
2 changes: 1 addition & 1 deletion qml/MainPanel/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import QtQuick.Window 2.1
import utility 1.0
import "../Utility"
import "../Chat"
import Qt.labs.settings 1.0
//import Qt.labs.settings 1.0

MyWindow{
id:main
Expand Down
7 changes: 6 additions & 1 deletion qml/QQItemInfo/FriendInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import QtQuick 2.2

FriendInfo{
id: root

property bool getImageing: false//记录是否正在获取图片

userQQ: myqq.userQQ
onUinChanged: {//如果uin变了
myqq.getFriendQQ( uin, getQQFinished )//获取好友的真实qq号
Expand Down Expand Up @@ -35,6 +38,7 @@ FriendInfo{
}
}
function getAvatarFinished( path ,name){
getImageing = false//获取图像结束
var imageName = path+"/"+name+".png"
avatar40 = imageName//保存自己头像的地址
//console.log(nick+"获取头像完成:"+imageName)
Expand All @@ -54,7 +58,8 @@ FriendInfo{
myqq.getQQSignature( uin, getQQSignatureFinished )//获取个性签名
}
function getAvatar(size){
if(account!=""){
if(account!=""&&!getImageing){
getImageing = true//正在获取头像
myqq.downloadImage(QQItemInfo.Friend
, "http://q.qlogo.cn/headimg_dl?spec="+String(size)+"&dst_uin="+account
, account, String(size), getAvatarFinished)//下载头像
Expand Down
7 changes: 6 additions & 1 deletion qml/QQItemInfo/GroupInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import QtQuick 2.2
import QQItemInfo 1.0

GroupInfo{
id: root
property bool getImageing: false//记录是否正在获取图片

userQQ: myqq.userQQ
onCodeChanged: {
//console.log(nick+"将要获取真实qq")
Expand Down Expand Up @@ -30,11 +33,13 @@ GroupInfo{
}
}
function getAvatarFinished( path ,name){
getImageing=false//将正在获取头像置为false
var imageName = path+"/"+name+".png"
avatar40 = imageName
}
function getAvatar(size){
if(account!=""){
if(account!=""&&!getImageing){
getImageing = true//置为true,不然可能会多次请求头像
myqq.downloadImage(QQItemInfo.Group
, "http://p.qlogo.cn/gh/"+account+"/"+account+"/"+String(size)
, account, String(size), getAvatarFinished)//下载头像
Expand Down
1 change: 0 additions & 1 deletion qml/Utility/TrayMessageWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ Window{
y=trayY-height
else
y=tempy
console.debug(x+","+y)
timer_close.stop()//先停止动画
root.opacity = 1
root.show()
Expand Down
5 changes: 2 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
#include "mywindow.h"
#include "qqstars.h"
#include "myimage.h"
#include "threaddownloadimage.h"
#include "mysvgview.h"
#include "myshortcut.h"
#include "httprequestid.h"
#include "myhttprequest.h"
#include <QDirModel>
#include <QTreeView>

Expand Down Expand Up @@ -68,7 +67,7 @@ int main(int argc, char *argv[])
systemTray->setParent (Utility::createUtilityClass ());//不设置父对象会导致程序退出后托盘还存在的问题
#endif
engine->rootContext ()->setContextProperty ("systemTray", systemTray);//将程序托盘注册过去
engine->load(QUrl(QStringLiteral("qml/Login/main.qml")));
qqapi->loadLoginWindow ();//加载登录窗口

return app.exec();
}
1 change: 1 addition & 0 deletions src/mywidgets/mywindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QApplication>
#include <QPainter>
#include <QPainterPath>
#include <QScreen>
#ifdef Q_OS_WIN
#include <winuser.h>
#elif defined(Q_OS_LINUX)
Expand Down
Loading

0 comments on commit 4767c88

Please sign in to comment.