├── QQClient ├── .qmake.stash ├── Icons │ ├── FileType │ │ ├── file.png │ │ ├── pdf.png │ │ ├── picture.png │ │ ├── video.png │ │ └── word.png │ └── MainWindow │ │ ├── add.png │ │ ├── add2.png │ │ ├── add3.png │ │ ├── admin.png │ │ ├── arrowDown.png │ │ ├── arrowDown2.png │ │ ├── arrowRight.png │ │ ├── arrowRight2.png │ │ ├── arrow_close.png │ │ ├── arrow_close2.png │ │ ├── arrow_open.png │ │ ├── arrow_open2.png │ │ ├── back.png │ │ ├── blank.png │ │ ├── chat.png │ │ ├── chat2.png │ │ ├── chat3.png │ │ ├── chat3_ (2).png │ │ ├── chat3_.png │ │ ├── chat4.png │ │ ├── close.png │ │ ├── close2.png │ │ ├── contact.png │ │ ├── contact2.png │ │ ├── contact3.png │ │ ├── contact3_.png │ │ ├── contact4.png │ │ ├── createGroup.png │ │ ├── default_head_icon.png │ │ ├── default_head_icon2.png │ │ ├── deleted.png │ │ ├── editHead.png │ │ ├── editHead2.png │ │ ├── emoji.png │ │ ├── emoji2.png │ │ ├── error.png │ │ ├── error_.png │ │ ├── female.png │ │ ├── file.png │ │ ├── file2.png │ │ ├── friend.png │ │ ├── friend2.png │ │ ├── friend3.png │ │ ├── group.png │ │ ├── group2.png │ │ ├── group3.png │ │ ├── group_chat.png │ │ ├── head.png │ │ ├── head2.png │ │ ├── head_bkg.png │ │ ├── left_arrow.png │ │ ├── loading.gif │ │ ├── loading2.gif │ │ ├── male.png │ │ ├── max.png │ │ ├── min.png │ │ ├── newmsg.png │ │ ├── notice.png │ │ ├── picture.png │ │ ├── picture2.png │ │ ├── radius_back.png │ │ ├── radius_front.png │ │ ├── screenshot.png │ │ ├── screenshot2.png │ │ ├── search.png │ │ ├── search_close.png │ │ ├── sendBtn_arrow_down.png │ │ ├── sendBtn_arrow_down_.png │ │ ├── sendMsg.png │ │ ├── sendMsg2.png │ │ ├── settings.png │ │ ├── settings2.png │ │ ├── settings3.png │ │ ├── settings3_.png │ │ ├── settings4.png │ │ ├── shadow.png │ │ ├── title.png │ │ ├── top.png │ │ ├── top2.png │ │ ├── top2_.png │ │ ├── top3.png │ │ ├── top4.png │ │ ├── top_.png │ │ └── top_chat.png ├── Makefile ├── Makefile.Release ├── QQ.pro ├── QQ.pro.user ├── QQ_resource.rc ├── basewidget │ ├── basewidget.pri │ ├── mybutton.cpp │ ├── mybutton.h │ ├── resizablewindow.cpp │ ├── resizablewindow.h │ ├── roundlabel.cpp │ ├── roundlabel.h │ ├── searchbar.cpp │ ├── searchbar.h │ ├── userinfownd.cpp │ └── userinfownd.h ├── cell │ ├── cell.cpp │ ├── cell.h │ ├── cell.pri │ ├── cellviewdad.cpp │ ├── cellviewdad.h │ ├── cellviewson.cpp │ ├── cellviewson.h │ ├── listwidget.cpp │ └── listwidget.h ├── clientsocket.cpp ├── clientsocket.h ├── comapi │ ├── aero.h │ ├── comapi.pri │ ├── global.h │ ├── myapp.cpp │ ├── myapp.h │ ├── unit.h │ ├── windwmapi.cpp │ └── windwmapi.h ├── database.cpp ├── database.h ├── debug │ └── QQ │ │ └── Data │ │ ├── Conf │ │ ├── config.ini │ │ └── debug.log │ │ ├── Database │ │ └── user.db │ │ ├── Face │ │ └── default.png │ │ └── Head │ │ ├── 100001.png │ │ ├── 100002.png │ │ ├── 100003.png │ │ ├── 100004.png │ │ ├── 100005.png │ │ ├── 100006.png │ │ ├── 100007.png │ │ ├── 100008.png │ │ ├── 100009.png │ │ ├── 900001.png │ │ ├── 900002.png │ │ ├── 900003.png │ │ ├── 900004.png │ │ ├── 900005.png │ │ ├── 900006.png │ │ ├── 900007.png │ │ ├── 900008.png │ │ ├── 900009.png │ │ └── 毕业照.jpg ├── exe.ico ├── icons.qrc ├── leftbar.cpp ├── leftbar.h ├── login │ ├── LoginWnd │ │ ├── loginlineedit.cpp │ │ ├── loginlineedit.h │ │ ├── loginwnd.cpp │ │ ├── loginwnd.h │ │ ├── loginwndloginingpage.cpp │ │ ├── loginwndloginingpage.h │ │ ├── loginwndmainpage.cpp │ │ └── loginwndmainpage.h │ ├── Util │ │ ├── checkbox.cpp │ │ ├── checkbox.h │ │ ├── clickablelabel.cpp │ │ ├── clickablelabel.h │ │ ├── headlabel.cpp │ │ ├── headlabel.h │ │ ├── lineeditex.cpp │ │ ├── lineeditex.h │ │ ├── windowbase.cpp │ │ └── windowbase.h │ ├── changepasswordwnd.cpp │ ├── changepasswordwnd.h │ ├── iplineedit.cpp │ ├── iplineedit.h │ ├── login.pri │ ├── networksetwnd.cpp │ ├── networksetwnd.h │ ├── qiplineedit.cpp │ ├── qiplineedit.h │ ├── registerwnd.cpp │ ├── registerwnd.h │ ├── rotatingstackedwidget.cpp │ └── rotatingstackedwidget.h ├── main.cpp ├── mainui.cpp ├── mainui.h ├── midbar │ ├── addfriendwnd.cpp │ ├── addfriendwnd.h │ ├── addsubgroup.cpp │ ├── addsubgroup.h │ ├── blankpage.cpp │ ├── blankpage.h │ ├── contactwidget.cpp │ ├── contactwidget.h │ ├── creategroupwnd.cpp │ ├── creategroupwnd.h │ ├── findfriendwnd.cpp │ ├── findfriendwnd.h │ ├── midbar.cpp │ ├── midbar.h │ └── midbar.pri ├── qss.qrc ├── qss │ ├── default.css │ └── scrollbar.qss ├── release │ └── QQ │ │ ├── Data │ │ ├── Conf │ │ │ ├── config.ini │ │ │ └── debug.log │ │ └── Database │ │ │ └── user.db │ │ └── QQ.exe ├── resource │ ├── exe.ico │ └── login_ui │ │ ├── button_login_down.png │ │ ├── button_login_hover.png │ │ ├── button_login_normal.png │ │ ├── checkbox │ │ ├── checkbox_hover.png │ │ ├── checkbox_normal.png │ │ ├── checkbox_press.png │ │ ├── checkbox_tick_highlight.png │ │ ├── checkbox_tick_normal.png │ │ └── checkbox_tick_pushed.png │ │ ├── edit_line │ │ ├── edit_frame_hover.png │ │ ├── edit_frame_normal.png │ │ ├── psw_hover.png │ │ ├── psw_normal.png │ │ ├── qqnum_hover.png │ │ └── qqnum_normal.png │ │ ├── head │ │ ├── defalut_head.png │ │ ├── head_bkg_highlight.png │ │ ├── head_bkg_highlight2.png │ │ └── head_bkg_shadow.png │ │ ├── login_bkg │ │ ├── bk_shadow.png │ │ ├── bk_shadow2.png │ │ ├── img_0.png │ │ ├── img_1.png │ │ ├── img_2.png │ │ ├── img_3.png │ │ └── img_4.png │ │ ├── login_ui.qrc │ │ ├── logo-QQ.png │ │ ├── logo-QQ2.png │ │ ├── menu_btn │ │ ├── close_hover.png │ │ ├── close_normal.png │ │ ├── close_press.png │ │ ├── min_hover.png │ │ ├── min_normal.png │ │ ├── min_press.png │ │ ├── set_hover.png │ │ ├── set_normal.png │ │ └── set_press.png │ │ └── win_border.png ├── rightbar │ ├── bubble │ │ ├── bubbleinfo.cpp │ │ ├── bubbleinfo.h │ │ ├── bubblelist.cpp │ │ ├── bubblelist.h │ │ ├── bubbleview.cpp │ │ ├── bubbleview.h │ │ ├── radiusprogressbar.cpp │ │ └── radiusprogressbar.h │ ├── chatwindow.cpp │ ├── chatwindow.h │ ├── defaultpage.cpp │ ├── defaultpage.h │ ├── inputwidget.cpp │ ├── inputwidget.h │ ├── mytextedit.cpp │ ├── mytextedit.h │ ├── rightbar.cpp │ ├── rightbar.h │ └── rightbar.pri ├── settingswnd.cpp ├── settingswnd.h └── titlebar │ ├── titlebar.cpp │ ├── titlebar.h │ ├── titlebar.pri │ ├── titlebutton.cpp │ └── titlebutton.h ├── QQServer ├── QQServer.pro ├── QQServer.pro.user ├── clientsocket.cpp ├── clientsocket.h ├── database.cpp ├── database.h ├── global.h ├── main.cpp ├── mainui.cpp ├── mainui.h ├── myapp.cpp ├── myapp.h ├── server.ico ├── tcpserver.cpp ├── tcpserver.h └── unit.h ├── README.md └── Screenshots ├── 20201223_163945.gif ├── MainUI.jpg ├── Snipaste_2019-05-24_21-39-31.jpg ├── Snipaste_2019-05-27_10-33-01.jpg ├── Snipaste_2019-06-09_10-57-21.jpg ├── Snipaste_2020-12-23_16-29-54.png ├── Snipaste_2020-12-23_16-33-15.png ├── Snipaste_2020-12-23_17-06-39.png ├── Snipaste_2020-12-23_17-14-09.png ├── add.png ├── database1.png ├── database10.png ├── database2.png ├── database3.png ├── database4.png ├── database5.png ├── database6.png ├── database7.png ├── database8.png ├── database9.png ├── fold.png ├── friends_list.png ├── group.png └── unfold.png /QQClient/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.INCDIRS = \ 2 | D:/Qt/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include \ 3 | D:/Qt/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0/include-fixed \ 4 | D:/Qt/Tools/mingw530_32/i686-w64-mingw32/include \ 5 | D:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++ \ 6 | D:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/i686-w64-mingw32 \ 7 | D:/Qt/Tools/mingw530_32/i686-w64-mingw32/include/c++/backward 8 | QMAKE_CXX.LIBDIRS = \ 9 | D:/Qt/Tools/mingw530_32/lib/gcc/i686-w64-mingw32/5.3.0 \ 10 | D:/Qt/Tools/mingw530_32/lib/gcc \ 11 | D:/Qt/Tools/mingw530_32/i686-w64-mingw32/lib \ 12 | D:/Qt/Tools/mingw530_32/lib 13 | QMAKE_CXX.QT_COMPILER_STDCXX = 199711L 14 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 5 15 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 16 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 17 | QMAKE_CXX.COMPILER_MACROS = \ 18 | QT_COMPILER_STDCXX \ 19 | QMAKE_GCC_MAJOR_VERSION \ 20 | QMAKE_GCC_MINOR_VERSION \ 21 | QMAKE_GCC_PATCH_VERSION 22 | -------------------------------------------------------------------------------- /QQClient/Icons/FileType/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/FileType/file.png -------------------------------------------------------------------------------- /QQClient/Icons/FileType/pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/FileType/pdf.png -------------------------------------------------------------------------------- /QQClient/Icons/FileType/picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/FileType/picture.png -------------------------------------------------------------------------------- /QQClient/Icons/FileType/video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/FileType/video.png -------------------------------------------------------------------------------- /QQClient/Icons/FileType/word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/FileType/word.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/add.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/add2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/add2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/add3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/add3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/admin.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrowDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrowDown.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrowDown2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrowDown2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrowRight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrowRight.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrowRight2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrowRight2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrow_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrow_close.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrow_close2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrow_close2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrow_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrow_open.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/arrow_open2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/arrow_open2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/back.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/blank.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/chat.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/chat2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/chat2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/chat3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/chat3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/chat3_ (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/chat3_ (2).png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/chat3_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/chat3_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/chat4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/chat4.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/close.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/close2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/close2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/contact.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/contact2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/contact2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/contact3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/contact3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/contact3_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/contact3_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/contact4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/contact4.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/createGroup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/createGroup.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/default_head_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/default_head_icon.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/default_head_icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/default_head_icon2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/deleted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/deleted.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/editHead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/editHead.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/editHead2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/editHead2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/emoji.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/emoji.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/emoji2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/emoji2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/error.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/error_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/error_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/female.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/file.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/file2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/file2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/friend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/friend.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/friend2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/friend2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/friend3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/friend3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/group.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/group2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/group2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/group3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/group3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/group_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/group_chat.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/head.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/head2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/head2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/head_bkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/head_bkg.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/left_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/left_arrow.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/loading.gif -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/loading2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/loading2.gif -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/male.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/max.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/min.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/newmsg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/newmsg.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/notice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/notice.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/picture.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/picture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/picture2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/radius_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/radius_back.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/radius_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/radius_front.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/screenshot.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/screenshot2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/search.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/search_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/search_close.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/sendBtn_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/sendBtn_arrow_down.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/sendBtn_arrow_down_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/sendBtn_arrow_down_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/sendMsg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/sendMsg.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/sendMsg2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/sendMsg2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/settings.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/settings2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/settings2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/settings3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/settings3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/settings3_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/settings3_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/settings4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/settings4.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/shadow.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/title.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top2.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top2_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top2_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top3.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top4.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top_.png -------------------------------------------------------------------------------- /QQClient/Icons/MainWindow/top_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/Icons/MainWindow/top_chat.png -------------------------------------------------------------------------------- /QQClient/QQ.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-04-22T16:13:03 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui sql network multimedia 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QQ 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | HEADERS += \ 28 | mainui.h \ 29 | leftbar.h \ 30 | database.h \ 31 | clientsocket.h \ 32 | settingswnd.h 33 | 34 | SOURCES += \ 35 | main.cpp \ 36 | mainui.cpp \ 37 | leftbar.cpp \ 38 | database.cpp \ 39 | clientsocket.cpp \ 40 | settingswnd.cpp 41 | 42 | # Default rules for deployment. 43 | qnx: target.path = /tmp/$${TARGET}/bin 44 | else: unix:!android: target.path = /opt/$${TARGET}/bin 45 | !isEmpty(target.path): INSTALLS += target 46 | 47 | RESOURCES += \ 48 | resource/login_ui/login_ui.qrc \ 49 | qss.qrc \ 50 | icons.qrc 51 | 52 | RC_ICONS = exe.ico #exe图标文件 53 | 54 | include($$PWD/basewidget/basewidget.pri) 55 | include($$PWD/cell/cell.pri) 56 | include($$PWD/comapi/comapi.pri) 57 | include($$PWD/login/login.pri) 58 | include($$PWD/midbar/midbar.pri) 59 | include($$PWD/rightbar/rightbar.pri) 60 | include($$PWD/titlebar/titlebar.pri) 61 | 62 | DESTDIR = $$PWD/release/QQ 63 | #OBJECTS_DIR = $$PWD/release/obj 64 | #MOC_DIR = $$PWD/release/moc 65 | #UI_DIR = $$PWD/release/ui 66 | #RCC_DIR = $$PWD/release/rcc 67 | -------------------------------------------------------------------------------- /QQClient/QQ_resource.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | IDI_ICON1 ICON DISCARDABLE "E:\\Graduation Project\\Final\\QQ\\exe.ico" 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 0,0,0,0 7 | PRODUCTVERSION 0,0,0,0 8 | FILEFLAGSMASK 0x3fL 9 | #ifdef _DEBUG 10 | FILEFLAGS VS_FF_DEBUG 11 | #else 12 | FILEFLAGS 0x0L 13 | #endif 14 | FILEOS VOS__WINDOWS32 15 | FILETYPE VFT_DLL 16 | FILESUBTYPE 0x0L 17 | BEGIN 18 | BLOCK "StringFileInfo" 19 | BEGIN 20 | BLOCK "040904b0" 21 | BEGIN 22 | VALUE "CompanyName", "\0" 23 | VALUE "FileDescription", "\0" 24 | VALUE "FileVersion", "0.0.0.0\0" 25 | VALUE "LegalCopyright", "\0" 26 | VALUE "OriginalFilename", "QQ.exe\0" 27 | VALUE "ProductName", "QQ\0" 28 | VALUE "ProductVersion", "0.0.0.0\0" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x0409, 1200 34 | END 35 | END 36 | /* End of Version info */ 37 | 38 | -------------------------------------------------------------------------------- /QQClient/basewidget/basewidget.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | HEADERS += \ 4 | $$PWD/mybutton.h \ 5 | $$PWD/searchbar.h \ 6 | $$PWD/roundlabel.h \ 7 | $$PWD/userinfownd.h 8 | 9 | SOURCES += \ 10 | $$PWD/mybutton.cpp \ 11 | $$PWD/searchbar.cpp \ 12 | $$PWD/roundlabel.cpp \ 13 | $$PWD/userinfownd.cpp -------------------------------------------------------------------------------- /QQClient/basewidget/mybutton.cpp: -------------------------------------------------------------------------------- 1 | #include "mybutton.h" 2 | #include "global.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | MyButton::MyButton(QWidget *parent,QStringList iconsList,QSize Iconsize,BtnType type): 11 | QPushButton(parent) 12 | { 13 | if(iconsList.size() < 3){ 14 | qDebug() << "mybutton.cpp : fatal error!icon number is too few"; 15 | } 16 | NormalIcon = iconsList.at(0); 17 | MoveInIcon = iconsList.at(1); 18 | ClickIcon = iconsList.at(2); 19 | btnSize = Iconsize; 20 | btnType = type; 21 | 22 | setFixedSize(btnSize); 23 | setImage(NormalIcon); 24 | } 25 | 26 | void MyButton::enterEvent(QEvent *e) 27 | { 28 | if(btnType == NormalBtn){ 29 | if(!tag){ 30 | setImage(MoveInIcon); 31 | setCursor(Qt::PointingHandCursor); 32 | } 33 | }else{ 34 | setCursor(Qt::PointingHandCursor); 35 | //setStyleSheet("border:2px solid white;border-radius:25px;"); 36 | } 37 | 38 | return QPushButton::enterEvent(e); 39 | } 40 | 41 | void MyButton::leaveEvent(QEvent *e) 42 | { 43 | if(btnType == NormalBtn){ 44 | if(!tag){ 45 | setImage(NormalIcon); 46 | setCursor(Qt::ArrowCursor); 47 | } 48 | }else{ 49 | setCursor(Qt::ArrowCursor); 50 | //resize(btnSize); 51 | } 52 | 53 | return QPushButton::leaveEvent(e); 54 | } 55 | 56 | void MyButton::paintEvent(QPaintEvent *event) 57 | { 58 | return QPushButton::paintEvent(event); 59 | } 60 | 61 | 62 | #if 0 63 | void LeftBarButton::mousePressEvent(QMouseEvent *) 64 | { 65 | setIcon(ClickIcon); 66 | qDebug() << "mouse press:" << this->size(); 67 | } 68 | 69 | void LeftBarButton::mouseReleaseEvent(QMouseEvent *) 70 | { 71 | setIcon(NormalIcon); 72 | qDebug() << "mouse release:" << this->size(); 73 | } 74 | 75 | #endif 76 | 77 | void MyButton::setImage(QString iconName) 78 | { 79 | if(btnType == HeadBtn){ 80 | QPixmap pixmap = myHelper::PixmapToRound(QPixmap(iconName),btnSize.width()/2); 81 | // QPixmap pixmap = myHelper::PixmapToRound( 82 | // QPixmap("E:\\100001.png"),btnSize.width()/2); 83 | setIcon(QIcon(pixmap)); 84 | setIconSize(size()); 85 | setStyleSheet("border:none;"); 86 | }else{ 87 | setIcon(QIcon(iconName)); 88 | setIconSize(size()); 89 | setStyleSheet("border:none;"); 90 | } 91 | } 92 | 93 | void MyButton::onBtnClicked() 94 | { 95 | if(btnType == NormalBtn){ 96 | setImage(ClickIcon); 97 | tag = true; 98 | } 99 | } 100 | 101 | void MyButton::restoreBtn() 102 | { 103 | if(btnType == NormalBtn){ 104 | setImage(NormalIcon); 105 | tag = false; 106 | } 107 | } 108 | 109 | void MyButton::changeIconSet(QStringList iconsList) 110 | { 111 | NormalIcon = iconsList.at(0); 112 | MoveInIcon = iconsList.at(1); 113 | ClickIcon = iconsList.at(2); 114 | } 115 | -------------------------------------------------------------------------------- /QQClient/basewidget/mybutton.h: -------------------------------------------------------------------------------- 1 | #ifndef LEFTBARBUTTON_H 2 | #define LEFTBARBUTTON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | enum BtnType{ 12 | NormalBtn, //普通按钮 13 | HeadBtn //头像按钮 14 | }; 15 | 16 | class MyButton : public QPushButton 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | MyButton(QWidget *parent,QStringList iconsList,QSize size,BtnType type = NormalBtn); 22 | void setImage(QString); 23 | void onBtnClicked(); 24 | void restoreBtn(); 25 | 26 | void changeIconSet(QStringList); 27 | 28 | QString NormalIcon;//正常显示时的图片 29 | QString MoveInIcon;//光标移入时的图片 30 | QString ClickIcon;//点击时的光标 31 | QSize btnSize; 32 | BtnType btnType; 33 | bool tag = false; 34 | 35 | //弹出个人信息界面中使用 36 | int id; 37 | QString name; 38 | int sex = 0; 39 | QString head; 40 | 41 | protected: 42 | void enterEvent(QEvent *); 43 | void leaveEvent(QEvent *); 44 | void paintEvent(QPaintEvent *event); 45 | 46 | }; 47 | 48 | #endif // LEFTBARBUTTON_H 49 | 50 | -------------------------------------------------------------------------------- /QQClient/basewidget/resizablewindow.h: -------------------------------------------------------------------------------- 1 | #ifndef RESIZABLEWINDOW_H 2 | #define RESIZABLEWINDOW_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define PADDING 2 13 | 14 | enum Direction{ 15 | UP = 0, 16 | DOWN=1, 17 | LEFT, 18 | RIGHT, 19 | LEFTTOP, 20 | LEFTBOTTOM, 21 | RIGHTBOTTOM, 22 | RIGHTTOP, 23 | NONE 24 | }; 25 | 26 | class ResizableWindow : public QWidget 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit ResizableWindow(QWidget *parent = nullptr); 32 | ~ResizableWindow(); 33 | 34 | void region(const QPoint &cursorPoint); 35 | 36 | signals: 37 | void changeWindowSize(QSize); 38 | 39 | protected: 40 | void mouseReleaseEvent(QMouseEvent *event); 41 | void mouseMoveEvent(QMouseEvent *event); 42 | void mousePressEvent(QMouseEvent *event); 43 | bool nativeEvent(const QByteArray &eventType, void *message, long *result); 44 | 45 | private: 46 | bool isLeftPressDown; 47 | QPoint dragPosition; 48 | Direction dir; 49 | 50 | }; 51 | 52 | #endif // RESIZABLEWINDOW_H 53 | -------------------------------------------------------------------------------- /QQClient/basewidget/roundlabel.cpp: -------------------------------------------------------------------------------- 1 | #include "roundlabel.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | RoundLabel::RoundLabel(QWidget *parent,QString iconPath) 8 | : QLabel(parent) 9 | { 10 | pixmap = QPixmap(iconPath); 11 | pixmap.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation); 12 | } 13 | 14 | void RoundLabel::setPixmap(QString iconpath) 15 | { 16 | pixmap = QPixmap(iconpath); 17 | pixmap.scaled(this->width(),this->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation); 18 | update(); 19 | } 20 | 21 | void RoundLabel::paintEvent(QPaintEvent *e) 22 | { 23 | QPainter painter(this); 24 | painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform,true);// 抗锯齿 25 | 26 | QPainterPath path; 27 | int radius = this->width()/2; 28 | path.addEllipse(0,0,radius * 2,radius*2); 29 | painter.setClipPath(path); 30 | 31 | painter.drawPixmap(QRect(0,0,radius*2,radius*2),pixmap); 32 | 33 | return QLabel::paintEvent(e); 34 | } 35 | -------------------------------------------------------------------------------- /QQClient/basewidget/roundlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef ROUNDLABEL_H 2 | #define ROUNDLABEL_H 3 | 4 | #include 5 | #include 6 | 7 | class RoundLabel : public QLabel 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | RoundLabel(QWidget *parent = nullptr,QString iconPath = ""); 13 | void setPixmap(QString iconpath); 14 | 15 | private: 16 | QPixmap pixmap; 17 | 18 | protected: 19 | void paintEvent(QPaintEvent*); 20 | }; 21 | 22 | 23 | #endif // ROUNDLABEL_H 24 | -------------------------------------------------------------------------------- /QQClient/basewidget/searchbar.cpp: -------------------------------------------------------------------------------- 1 | #include "searchbar.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | SearchBar::SearchBar(QWidget *parent, QSize p_size,int tag): 8 | QLineEdit(parent),tag(tag) 9 | { 10 | setFixedSize(p_size); 11 | IconHeight = p_size.height()/2; 12 | icon = new QLabel; 13 | icon->setPixmap(QPixmap(":/Icons/MainWindow/search.png"). 14 | scaled(IconHeight,IconHeight,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 15 | icon->setFixedSize(QSize(IconHeight,IconHeight)); 16 | icon->setStyleSheet("border:none;"); 17 | 18 | QStringList list; 19 | list << ":/Icons/MainWindow/search_close.png" 20 | << ":/Icons/MainWindow/search_close.png" 21 | << ":/Icons/MainWindow/search_close.png"; 22 | closeBtn = new MyButton(nullptr,list,QSize(IconHeight,IconHeight)); 23 | closeBtn->setToolTip(tr("关闭")); 24 | closeBtn->setFocusPolicy(Qt::NoFocus); 25 | 26 | setPlaceholderText(tr("搜索...")); 27 | QHBoxLayout *mainLayout = new QHBoxLayout; 28 | mainLayout->addWidget(icon); 29 | mainLayout->addStretch(); 30 | mainLayout->addWidget(closeBtn); 31 | mainLayout->setContentsMargins(5,0,5,0); 32 | 33 | setTextMargins(IconHeight+5,0,IconHeight+5,0); 34 | setLayout(mainLayout); 35 | if(tag == 0) 36 | setStyleSheet("background-color:rgb(219, 217, 216);border:1px solid #eaeaea;border-radius:15px;"); 37 | else if(tag == 1) 38 | setStyleSheet("background-color:rgb(219, 217, 216);border:2px solid #aeaeae;border-radius:20px;"); 39 | 40 | setFont(QFont("Microsoft YaHei", 10, 50, false)); 41 | connect(closeBtn,&MyButton::clicked,[&](){ 42 | this->setText(""); 43 | this->clearFocus(); 44 | }); 45 | 46 | closeBtn->setVisible(false); 47 | 48 | connect(this,&SearchBar::editingFinished,[&](){ 49 | qDebug() << this->text(); 50 | }); 51 | } 52 | 53 | void SearchBar::focusInEvent(QFocusEvent *e) 54 | { 55 | setStyleSheet("background-color:white;border:1px solid #eaeaea;border-radius:15px;"); 56 | closeBtn->setVisible(true); 57 | this->setCursorPosition(0); 58 | return QLineEdit::focusInEvent(e); 59 | } 60 | 61 | void SearchBar::focusOutEvent(QFocusEvent *e) 62 | { 63 | setStyleSheet("background-color:rgb(219, 217, 216);border:1px solid #eaeaea;border-radius:15px;"); 64 | 65 | closeBtn->setVisible(false); 66 | 67 | if(tag == 0) 68 | setText(""); 69 | 70 | return QLineEdit::focusOutEvent(e); 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /QQClient/basewidget/searchbar.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHBAR_H 2 | #define SEARCHBAR_H 3 | 4 | #include "mybutton.h" 5 | 6 | #include 7 | #include 8 | 9 | class SearchBar : public QLineEdit 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | SearchBar(QWidget *parent = nullptr, QSize p_Size = QSize(0,0),int tag = 0); 15 | 16 | private: 17 | QLabel *icon; 18 | MyButton *closeBtn; 19 | int IconHeight; 20 | int tag; 21 | 22 | protected: 23 | void focusInEvent(QFocusEvent *e); 24 | void focusOutEvent(QFocusEvent *e); 25 | }; 26 | 27 | #endif // SEARCHBAR_H 28 | -------------------------------------------------------------------------------- /QQClient/basewidget/userinfownd.h: -------------------------------------------------------------------------------- 1 | #ifndef USERINFOWND_H 2 | #define USERINFOWND_H 3 | 4 | #include "mybutton.h" 5 | 6 | #include 7 | #include 8 | 9 | class UserInfoWnd : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit UserInfoWnd(QWidget *parent = nullptr,int id = 0,QString name = "",QString head = "",int sex = 0); 14 | 15 | signals: 16 | 17 | public slots: 18 | 19 | private: 20 | QLabel *idLabel; 21 | QLabel *nameLabel; 22 | QLabel *headLabel; 23 | QLabel *sexLabel; 24 | QLabel *subGroupLabel; 25 | MyButton *sendMsgBtn; 26 | QLabel *schoolLabel; 27 | QLabel *regionLabel; 28 | QLabel *emailLabel; 29 | 30 | int id; 31 | QString name; 32 | QString head; 33 | int sex; 34 | 35 | protected: 36 | void paintEvent(QPaintEvent*); 37 | void focusInEvent(QFocusEvent*); 38 | void focusOutEvent(QFocusEvent*); 39 | void showEvent(QShowEvent*); 40 | bool nativeEvent(const QByteArray &eventType, void *message, long *result); 41 | }; 42 | 43 | #endif // USERINFOWND_H 44 | -------------------------------------------------------------------------------- /QQClient/cell/cell.cpp: -------------------------------------------------------------------------------- 1 | #include "cell.h" 2 | 3 | #include 4 | 5 | Cell::Cell() 6 | { 7 | isOpen = false; 8 | isClicked = false; 9 | } 10 | 11 | void Cell::SetSubtitle(const QString &text) 12 | { 13 | if (text.isEmpty()) return; 14 | subTitle = text; 15 | } 16 | 17 | void Cell::SetIconPath(const QString &path) 18 | { 19 | if (path.isEmpty()) return; 20 | iconPath = path; 21 | } 22 | 23 | void Cell::SetStatus(const quint8 &val) 24 | { 25 | status = val; 26 | } 27 | 28 | void Cell::sortById() 29 | { 30 | std::sort(childs.begin(),childs.end(),[](Cell* cellA, Cell* cellB){ 31 | return cellA->id < cellB->id; 32 | }); 33 | 34 | qDebug() << "done"; 35 | } 36 | 37 | void Cell::sortByName() 38 | { 39 | std::sort(childs.begin(),childs.end(),[](Cell* cellA, Cell* cellB){ 40 | return cellA->name < cellB->name; 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /QQClient/cell/cell.h: -------------------------------------------------------------------------------- 1 | #ifndef CELL_H 2 | #define CELL_H 3 | 4 | #include 5 | #include 6 | 7 | typedef enum CellType 8 | { 9 | Cell_FriendChat = 0, //聊天列表中好友小格子 10 | Cell_GroupChat = 1, //聊天列表中群小格子 11 | Cell_FriendContact = 2, //好友的一个小格子 12 | Cell_GroupContact = 3, //群的一个小格子 13 | Cell_FriendDrawer = 4, //好友列表的一级标题 14 | Cell_GroupDrawer = 5, //群列表的一级标题 15 | Cell_AddFriend = 6, //请求添加好友 16 | Cell_AddGroup = 7 //请求加群 17 | } CellType; 18 | 19 | 20 | class Cell 21 | { 22 | public: 23 | Cell(); 24 | void SetSubtitle(const QString &text); 25 | void SetIconPath(const QString &path); 26 | void SetStatus(const quint8 &val); 27 | void sortById(); 28 | void sortByName(); 29 | 30 | public: 31 | QString iconPath; 32 | QString name; 33 | QString subTitle; 34 | QString msg = ""; 35 | 36 | QString ipaddr; 37 | QString groupName; //组名 38 | int id; //QQ号,作为标识 39 | int status; 40 | CellType type; 41 | 42 | //Cell_AddGroup专用 43 | int groupid; 44 | QString groupname_; 45 | QString groupHead; 46 | 47 | int newUserID; 48 | QString newUserName; 49 | QString newUserHead; 50 | 51 | bool done = false; 52 | bool deleted = false; 53 | bool stayOnTop = false; 54 | 55 | //下面几项都是只用于Cell_FriendDrawer = 2 和 Cell_GroupDrawer = 3 56 | bool isOpen; //标记下拉抽屉的打开状态 57 | bool isClicked; 58 | bool showNewMsg = false; 59 | QList childs; //子项 60 | }; 61 | 62 | #endif // CELL_H 63 | -------------------------------------------------------------------------------- /QQClient/cell/cell.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | HEADERS += \ 4 | $$PWD/cell.h \ 5 | $$PWD/cellviewdad.h \ 6 | $$PWD/cellviewson.h \ 7 | $$PWD/listwidget.h 8 | 9 | 10 | SOURCES += \ 11 | $$PWD/cell.cpp \ 12 | $$PWD/cellviewdad.cpp \ 13 | $$PWD/cellviewson.cpp \ 14 | $$PWD/listwidget.cpp -------------------------------------------------------------------------------- /QQClient/cell/cellviewdad.cpp: -------------------------------------------------------------------------------- 1 | #include "cellviewdad.h" 2 | #include 3 | #include 4 | #include 5 | 6 | CellViewDad::CellViewDad(QWidget *parent) : QWidget(parent) 7 | { 8 | setWindowFlag(Qt::FramelessWindowHint); 9 | setFixedSize(QSize(325,30)); 10 | 11 | QHBoxLayout *layout = new QHBoxLayout(this); 12 | iconLabel = new QLabel; 13 | iconLabel->setFixedSize(QSize(15,15)); 14 | titleLabel = new QLabel; 15 | subTitleLabel = new QLabel; 16 | subTitleLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 17 | layout->addWidget(iconLabel); 18 | layout->addWidget(titleLabel); 19 | layout->addWidget(subTitleLabel); 20 | layout->setContentsMargins(0,0,0,0); 21 | 22 | setFont(QFont("微软雅黑",10,5,false)); 23 | } 24 | 25 | void CellViewDad::setCell(Cell *c) 26 | { 27 | cell = c; 28 | if(cell->isOpen){ 29 | iconLabel->setPixmap(QPixmap(":/Icons/MainWindow/arrowDown.png"). 30 | scaled(iconLabel->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 31 | }else{ 32 | iconLabel->setPixmap(QPixmap(":/Icons/MainWindow/arrowRight.png"). 33 | scaled(iconLabel->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 34 | } 35 | } 36 | 37 | void CellViewDad::setPopMenu(QMenu *menu) 38 | { 39 | popMenu = menu; 40 | } 41 | 42 | void CellViewDad::mousePressEvent(QMouseEvent *e) 43 | { 44 | if(cell == nullptr) return; 45 | if(e->button() == Qt::LeftButton){//处理鼠标左键单击事件 46 | cell->isOpen = !cell->isOpen;//鼠标左键单击,改变cell的打开状态 47 | if(cell->isOpen) iconLabel->setPixmap(QPixmap(":/Icons/MainWindow/arrowDown.png").scaled(iconLabel->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 48 | else iconLabel->setPixmap(QPixmap(":/Icons/MainWindow/arrowRight.png").scaled(iconLabel->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 49 | qDebug() << "LeftBtn clicked on viewdad:" << cell->id << cell->name; 50 | 51 | emit onOpenStatusChanged(this); 52 | }else if(e->button() == Qt::RightButton){ 53 | if(popMenu == nullptr) return; 54 | qDebug() << "RightBtn clicked on viewdad:" << cell->id << cell->name; 55 | emit onPopMenuToShow(cell,popMenu); 56 | popMenu->exec(QCursor::pos());//在光标位置弹出右键菜单 57 | } 58 | 59 | return QWidget::mousePressEvent(e); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /QQClient/cell/cellviewdad.h: -------------------------------------------------------------------------------- 1 | #ifndef CELLVIEWDAD_H 2 | #define CELLVIEWDAD_H 3 | 4 | #include "cell.h" 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | class CellViewDad : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CellViewDad(QWidget *parent = nullptr); 16 | void setCell(Cell *c); 17 | void setPopMenu(QMenu *menu); 18 | 19 | signals: 20 | void onOpenStatusChanged(CellViewDad *);//打开状态发生了改变 21 | void onPopMenuToShow(Cell*,QMenu*); 22 | 23 | protected: 24 | void mousePressEvent(QMouseEvent *e); 25 | 26 | public: 27 | Cell *cell; //里面封装了显示CellView所需要的数据 28 | QLabel *iconLabel; //显示图片 29 | QLabel *titleLabel; //显示标题 30 | QLabel *subTitleLabel; //显示副标题 31 | QMenu *popMenu; 32 | }; 33 | 34 | #endif // CELLVIEWDAD_H 35 | -------------------------------------------------------------------------------- /QQClient/cell/cellviewson.h: -------------------------------------------------------------------------------- 1 | #ifndef CELLVIEWSON_H 2 | #define CELLVIEWSON_H 3 | 4 | #include "cell.h" 5 | #include "mybutton.h" 6 | #include "roundlabel.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class CellViewSon : public QWidget 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit CellViewSon(QWidget *parent = nullptr,Cell *c = nullptr,int tag = 0); 17 | void setPopMenu(QMenu *menu); 18 | 19 | signals: 20 | void onSelected(Cell *cell); 21 | void onDoubleClicked(Cell *cell); 22 | void onRightClicked(Cell *cell); 23 | void onPopMenuToShow(Cell*,QMenu*); 24 | 25 | void signalOpenDialog(Cell* cell); 26 | 27 | protected: 28 | void mousePressEvent(QMouseEvent *e); 29 | void mouseDoubleClickEvent(QMouseEvent *e); 30 | void enterEvent(QEvent *event); 31 | void leaveEvent(QEvent *event); 32 | void paintEvent(QPaintEvent *); 33 | void focusOutEvent(QFocusEvent*); 34 | 35 | public : 36 | Cell *cell; 37 | QMenu *popMenu; 38 | 39 | private: 40 | bool entered; //记录光标是否移入 41 | int tag = 0; 42 | bool isAdmin = false; 43 | 44 | //QLabel *headIcon; 45 | QLabel *newMsg; 46 | RoundLabel *headLabel; 47 | //QLabel *headLabel; 48 | QLabel *notice; 49 | QLabel *adminLabel; 50 | QLabel *topLabel; 51 | }; 52 | 53 | #endif // CELLVIEWSON_H 54 | -------------------------------------------------------------------------------- /QQClient/cell/listwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTWIDGET_H 2 | #define LISTWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "cell.h" 11 | #include "cellviewdad.h" 12 | #include "cellviewson.h" 13 | 14 | 15 | class FloatingScrollBar; 16 | class ListWidget : public QListWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit ListWidget(QWidget* parent = nullptr,int tag = 0); 22 | 23 | Cell *getRightClickedCell();//获取右击选中的格子 24 | void insertCell(Cell *cell); 25 | void removeCell(Cell *cell); 26 | void removeAllCells(); 27 | void refreshList(); 28 | Cell* getDadCellFromName(QString *name); 29 | void setDadPopMenu(QMenu *menu); 30 | void setSonPopMenu(QMenu *menu); 31 | void setCellToTop(Cell*); 32 | void cancelCellOnTop(Cell*); 33 | 34 | QList getAllCells() const; 35 | void resetCellState(); 36 | void refreshCellTime(int id,qint64 time,QString msg); 37 | 38 | signals: 39 | void popMenuToShow(Cell*,QMenu *); 40 | void sonDoubleClicked(Cell *son); 41 | void signalSonRightClicked(); 42 | 43 | void signalOpenDialog(Cell* cell); 44 | 45 | private: 46 | QList cells;//包含列表中所有的格子 47 | QList sonItems; 48 | QMenu *cellDadMenu; 49 | QMenu *cellSonMenu; 50 | Cell *rightClickedCell; 51 | int tag = 0; 52 | FloatingScrollBar * scrollBar; 53 | 54 | void addSonItem(Cell *cell); 55 | void changeSonSelectionState(Cell*); 56 | 57 | public slots: 58 | void onDadOpenChanged(CellViewDad *dad); 59 | void onSonSelected(Cell *son); 60 | void onCellRightClicked(Cell *cell); 61 | //void onPopMenuShow(QMenu *menu); 62 | void slt_valueChanged(int); 63 | 64 | protected: 65 | void enterEvent(QEvent *); 66 | void leaveEvent(QEvent *); 67 | void resizeEvent(QResizeEvent*); 68 | }; 69 | 70 | class FloatingScrollBar : public QScrollBar 71 | { 72 | Q_OBJECT 73 | 74 | public: 75 | explicit FloatingScrollBar(QWidget *parent,Qt::Orientation t); 76 | ~FloatingScrollBar(){} 77 | 78 | public slots: 79 | void slt_valueChanged(int); 80 | void slt_rangeChanged(int,int); 81 | }; 82 | 83 | #endif // LISTWIDGET_H 84 | -------------------------------------------------------------------------------- /QQClient/clientsocket.h: -------------------------------------------------------------------------------- 1 | #ifndef TCPCLIENT_H 2 | #define TCPCLIENT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | class ClientSocket : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit ClientSocket(QObject *parent = nullptr); 15 | ~ClientSocket(); 16 | 17 | // 获取当前用户的ID 18 | int getUserID() const; 19 | void setUserID(const int &id); 20 | 21 | void checkConnected(); 22 | void closeConnection(); 23 | 24 | // 连接服务器 25 | void connectToHost(const QString &host, const int &port); 26 | void connectToHost(const QHostAddress &host, const int &port); 27 | 28 | signals: 29 | void signalMessage(const quint8 &type, const QJsonValue &dataVal); 30 | void signalStatus(const quint8 &state); 31 | void signalRegisterOk(const QJsonValue &dataVal); 32 | void signalChangePwdReply(const QJsonValue &dataVal); 33 | void signalFindFriendReply(const QJsonValue &dataVal); 34 | void signalGetOfflineMsg(const QJsonValue &dataVal); 35 | 36 | public slots: 37 | // socket消息发送封装 38 | void sltSendMessage(const quint8 &type, const QJsonValue &dataVal); 39 | // 发送上线通知 40 | void sltSendOnline(); 41 | // 发送下线通知 42 | void sltSendOffline(); 43 | 44 | private: 45 | // tcpsocket 46 | QTcpSocket *tcpSocket; 47 | int ID; 48 | 49 | private slots: 50 | // 与服务器断开链接 51 | void sltDisconnected(); 52 | // 链接上服务器 53 | void sltConnected(); 54 | // tcp消息处理 55 | void sltReadyRead(); 56 | 57 | private: 58 | // 解析登陆返回信息 59 | void parseLogin(const QJsonValue &dataVal); 60 | // 解析注册返回信息 61 | void parseReister(const QJsonValue &dataVal); 62 | }; 63 | 64 | 65 | 66 | class ClientFileSocket : public QObject 67 | { 68 | Q_OBJECT 69 | 70 | public: 71 | explicit ClientFileSocket(QObject *parent = nullptr); 72 | ~ClientFileSocket(); 73 | 74 | bool isConneciton(); 75 | void setTag(int tag){this->tag = tag;} 76 | bool isBusy(){return this->busy;} 77 | 78 | // 发送文件大小等信息 79 | void startTransferFile(QString fileReadName,qint64 time,quint8 type); 80 | 81 | // 连接到服务器 82 | void connectToServer(const QString &ip, const int &port, const int &usrId); 83 | // 断开服务器 84 | void closeConnection(); 85 | 86 | // 文件传输完成 87 | void fileTransFinished(); 88 | 89 | // 设置当前socket的id 90 | void setUserId(const int &id); 91 | 92 | signals: 93 | void signalSendFinished(quint8,QString); 94 | void signalFileRecvOk(const quint8 &type, const QString &filePath,int senderID); 95 | void signalUpdateProgress(qint64 currSize, qint64 total); 96 | void signalConnectd(); 97 | 98 | void signalFileArrived(const QJsonValue&); 99 | 100 | private: 101 | quint64 loadSize; //每次发送数据的大小 102 | 103 | /************* Receive file *******************/ 104 | qint64 bytesReceived; //已收到数据的大小 105 | quint64 fileNameSize; //文件名的大小信息 106 | QString fileReadName; //存放文件名 107 | QByteArray inBlock; //数据缓冲区 108 | qint64 ullRecvTotalBytes; //数据总大小 109 | QFile *fileToRecv; //要发送的文件 110 | qint64 senderID; //发送文件者id 111 | qint64 RecvFileSendTime; //文件发送时间 112 | 113 | /************* Send file **********************/ 114 | quint16 blockSize; //存放接收到的信息大小 115 | QFile *fileToSend; //要发送的文件 116 | qint64 ullSendTotalBytes; //数据总大小 117 | qint64 bytesWritten; //已经发送数据大小 118 | quint64 bytesToWrite; //剩余数据大小 119 | QByteArray outBlock; //数据缓冲区,即存放每次要发送的数据 120 | QString fileSendName; //存放发送文件的名字(包括路径) 121 | 122 | // 用户目录 123 | QString strFilePath; 124 | 125 | // 通信类 126 | QTcpSocket *tcpSocket; 127 | 128 | bool busy; 129 | int winID; 130 | quint8 type; 131 | 132 | int tag = 0;//tag = 0表示这是私聊窗口的一个filesocket,tag = 1表示这是群聊窗口的一个filesocket 133 | 134 | qint64 flag; 135 | 136 | private: 137 | // socket 初始化 138 | void initSocket(); 139 | 140 | public slots: 141 | 142 | private slots: 143 | // 显示错误 144 | void displayError(QAbstractSocket::SocketError); 145 | // 发送文件数据,更新进度条 146 | void sltUpdateClientProgress(qint64); 147 | 148 | // 文件接收 149 | void sltReadyRead(); 150 | void sltConnected(); 151 | void sltDisConnected(); 152 | }; 153 | 154 | 155 | #endif // TCPCLIENT_H 156 | -------------------------------------------------------------------------------- /QQClient/comapi/aero.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef AERO_H_ 3 | #define AERO_H_ 4 | 5 | #include 6 | #include 7 | #pragma comment (lib,"user32.lib") 8 | 9 | typedef enum _WINDOWCOMPOSITIONATTRIB 10 | { 11 | WCA_UNDEFINED = 0, 12 | WCA_NCRENDERING_ENABLED = 1, 13 | WCA_NCRENDERING_POLICY = 2, 14 | WCA_TRANSITIONS_FORCEDISABLED = 3, 15 | WCA_ALLOW_NCPAINT = 4, 16 | WCA_CAPTION_BUTTON_BOUNDS = 5, 17 | WCA_NONCLIENT_RTL_LAYOUT = 6, 18 | WCA_FORCE_ICONIC_REPRESENTATION = 7, 19 | WCA_EXTENDED_FRAME_BOUNDS = 8, 20 | WCA_HAS_ICONIC_BITMAP = 9, 21 | WCA_THEME_ATTRIBUTES = 10, 22 | WCA_NCRENDERING_EXILED = 11, 23 | WCA_NCADORNMENTINFO = 12, 24 | WCA_EXCLUDED_FROM_LIVEPREVIEW = 13, 25 | WCA_VIDEO_OVERLAY_ACTIVE = 14, 26 | WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15, 27 | WCA_DISALLOW_PEEK = 16, 28 | WCA_CLOAK = 17, 29 | WCA_CLOAKED = 18, 30 | WCA_ACCENT_POLICY = 19, 31 | WCA_FREEZE_REPRESENTATION = 20, 32 | WCA_EVER_UNCLOAKED = 21, 33 | WCA_VISUAL_OWNER = 22, 34 | WCA_LAST = 23 35 | } WINDOWCOMPOSITIONATTRIB; 36 | 37 | typedef struct _WINDOWCOMPOSITIONATTRIBDATA 38 | { 39 | WINDOWCOMPOSITIONATTRIB Attrib; 40 | PVOID pvData; 41 | SIZE_T cbData; 42 | } WINDOWCOMPOSITIONATTRIBDATA; 43 | 44 | typedef enum _ACCENT_STATE 45 | { 46 | ACCENT_DISABLED = 0, 47 | ACCENT_ENABLE_GRADIENT = 1, 48 | ACCENT_ENABLE_TRANSPARENTGRADIENT = 2, 49 | ACCENT_ENABLE_BLURBEHIND = 3, 50 | ACCENT_INVALID_STATE = 4 51 | } ACCENT_STATE; 52 | 53 | typedef struct _ACCENT_POLICY 54 | { 55 | ACCENT_STATE AccentState; 56 | DWORD AccentFlags; 57 | DWORD GradientColor; 58 | DWORD AnimationId; 59 | } ACCENT_POLICY; 60 | 61 | WINUSERAPI 62 | BOOL 63 | WINAPI 64 | GetWindowCompositionAttribute( 65 | _In_ HWND hWnd, 66 | _Inout_ WINDOWCOMPOSITIONATTRIBDATA* pAttrData); 67 | 68 | typedef BOOL(WINAPI*pfnGetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*); 69 | 70 | WINUSERAPI 71 | BOOL 72 | WINAPI 73 | SetWindowCompositionAttribute( 74 | _In_ HWND hWnd, 75 | _Inout_ WINDOWCOMPOSITIONATTRIBDATA* pAttrData); 76 | 77 | typedef BOOL(WINAPI*pfnSetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*); 78 | 79 | #endif -------------------------------------------------------------------------------- /QQClient/comapi/comapi.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | HEADERS += \ 4 | $$PWD/global.h \ 5 | $$PWD/unit.h \ 6 | $$PWD/myapp.h \ 7 | $$PWD/windwmapi.h \ 8 | $$PWD/aero.h 9 | 10 | SOURCES += \ 11 | $$PWD/myapp.cpp \ 12 | $$PWD/windwmapi.cpp 13 | -------------------------------------------------------------------------------- /QQClient/comapi/myapp.h: -------------------------------------------------------------------------------- 1 | #ifndef MYAPP_H 2 | #define MYAPP_H 3 | 4 | #include 5 | 6 | class QApplication; 7 | 8 | class MyApp 9 | { 10 | public: 11 | //=======================系统配置部分=========================// 12 | static QString m_strAppPath; // 应用程序路径 13 | static QString m_strDataPath; // 数据保存路径 14 | static QString m_strRecvPath; // 音频目录 15 | static QString m_strDatabasePath; // 数据库目录 16 | static QString m_strConfPath; // 配置目录 17 | static QString m_strSoundPath; // 配置目录 18 | static QString m_strRecordPath; // 录音目录 19 | 20 | static QString m_strFacePath; // 配置目录 21 | static QString m_strHeadPath; // 配置目录 22 | 23 | static QString m_strIniFile; // 配置文件 24 | static QString m_debugFile; // 调试信息 25 | 26 | static QString m_strHostAddr; // 服务器地址配置 27 | static int m_nMsgPort; // 聊天消息服务器端口配置 28 | static int m_nFilePort; // 文件转发服务器端口配置 29 | static int m_nGroupPort; // 群组聊天窗口 30 | 31 | static QString m_strUserName; // 用户名 32 | static QString m_strPassword; // 用户密码 33 | static QString m_strHeadFile; // 头像文件 34 | 35 | static int m_nId; 36 | static bool checked; 37 | static bool autoLogin; 38 | static bool sendWay; // 发送消息的方式,true表示enter发送,false表示ctrl+enter发送 39 | 40 | static int m_nWinX; 41 | static int m_nWinY; 42 | 43 | //=======================函数功能部分=========================// 44 | // 初始化 45 | static void initApp(const QString &appPath); 46 | // 创建配置文件 47 | static void createSettingFile(); 48 | // 读配置文件,加载系统配置 49 | static void readSettingFile(); 50 | 51 | // 读取/修改配置文件 52 | static void setSettingFile(const QString &group, const QString &key, const QVariant &value); 53 | static QVariant getSettingKeyValue(const QString &group, const QString &key, const QVariant &value); 54 | // 检查目录 55 | static void checkDirs(); 56 | static void checkSound(); 57 | static void checkDebugFile(); 58 | 59 | static void saveConfig(); 60 | }; 61 | 62 | #endif // MYAPP_H 63 | -------------------------------------------------------------------------------- /QQClient/comapi/windwmapi.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 去掉标题之后添加边框阴影 3 | * 4 | * windwmapi.cpp 5 | * 封装windows api的cpp文件。 6 | * 7 | * FlyWM_ 8 | * GitHub: https://github.com/FlyWM 9 | * CSDN: https://blog.csdn.net/a844651990 10 | * 11 | */ 12 | 13 | #include "windwmapi.h" 14 | 15 | WinDwmapi::WinDwmapi() 16 | : dwmapi_dll_(LoadLibraryW(L"dwmapi.dll")) 17 | , dwm_is_composition_enabled_(NULL) 18 | { 19 | if (dwmapi_dll_) { 20 | dwm_is_composition_enabled_ = \ 21 | reinterpret_cast(GetProcAddress(dwmapi_dll_, "DwmIsCompositionEnabled")); 22 | dwm_extendframe_into_client_area_ = \ 23 | reinterpret_cast(GetProcAddress(dwmapi_dll_, "DwmExtendFrameIntoClientArea")); 24 | } 25 | } 26 | 27 | WinDwmapi::~WinDwmapi() 28 | { 29 | if (dwmapi_dll_) { 30 | FreeLibrary(dwmapi_dll_); 31 | } 32 | } 33 | 34 | HRESULT WinDwmapi::DwmIsCompositionEnabled(BOOL *pfEnabled) const 35 | { 36 | if (dwm_is_composition_enabled_) { 37 | return dwm_is_composition_enabled_(pfEnabled); 38 | } 39 | 40 | return E_NOTIMPL; 41 | } 42 | 43 | HRESULT WinDwmapi::DwmExtendFrameIntoClientArea(HWND hWnd, const MARGINS *pMarInset) const 44 | { 45 | if (dwm_extendframe_into_client_area_) { 46 | return dwm_extendframe_into_client_area_(hWnd, pMarInset); 47 | } 48 | 49 | return E_NOTIMPL; 50 | } 51 | 52 | const WinDwmapi *WinDwmapi::instance() 53 | { 54 | static const WinDwmapi s_dwmapi; 55 | return &s_dwmapi; 56 | } 57 | -------------------------------------------------------------------------------- /QQClient/comapi/windwmapi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 去掉标题之后添加边框阴影 3 | * 4 | * windwmapi.h 5 | * 封装windows api的头文件。 6 | * 7 | * FlyWM_ 8 | * GitHub: https://github.com/FlyWM 9 | * CSDN: https://blog.csdn.net/a844651990 10 | * 11 | */ 12 | 13 | #ifndef WINDWMAPI_H 14 | #define WINDWMAPI_H 15 | 16 | #include 17 | 18 | typedef struct _MARGINS 19 | { 20 | int cxLeftWidth; // width of left border that retains its size 21 | int cxRightWidth; // width of right border that retains its size 22 | int cyTopHeight; // height of top border that retains its size 23 | int cyBottomHeight; // height of bottom border that retains its size 24 | } MARGINS, *PMARGINS; 25 | 26 | class WinDwmapi 27 | { 28 | public: 29 | WinDwmapi(); 30 | ~WinDwmapi(); 31 | 32 | typedef HRESULT (WINAPI* DwmIsCompositionEnabledPtr)(BOOL* pfEnabled); 33 | typedef HRESULT (WINAPI* DwmExtendFrameIntoClientAreaPtr)(HWND hWnd, const MARGINS *pMarInset); 34 | 35 | HRESULT DwmIsCompositionEnabled(BOOL* pfEnabled) const; 36 | HRESULT DwmExtendFrameIntoClientArea(HWND hWnd, const MARGINS *pMarInset) const; 37 | 38 | static const WinDwmapi* instance(); 39 | 40 | private: 41 | DwmIsCompositionEnabledPtr dwm_is_composition_enabled_; 42 | DwmExtendFrameIntoClientAreaPtr dwm_extendframe_into_client_area_; 43 | HMODULE dwmapi_dll_; 44 | }; 45 | 46 | #endif // WINDWMAPI_H 47 | -------------------------------------------------------------------------------- /QQClient/database.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASE_H 2 | #define DATABASE_H 3 | 4 | #include "bubbleinfo.h" 5 | #include "cell.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | class DataBase : public QObject 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit DataBase(QObject *parent = nullptr); 18 | ~DataBase(); 19 | 20 | bool openDb(const QString &dataName); 21 | 22 | // 单实例运行 23 | static DataBase *Instance() 24 | { 25 | static QMutex mutex; 26 | if (self == nullptr) { 27 | QMutexLocker locker(&mutex); 28 | 29 | if (!self) { 30 | self = new DataBase(); 31 | } 32 | } 33 | return self; 34 | } 35 | 36 | // 添加历史聊天记录 37 | void addHistoryMsg(BubbleInfo *info); 38 | // 添加好友 39 | void addFriend(const int &myID, const int &friendID); 40 | // 添加群组 41 | void addGroup(const int &myID, const int &groupID); 42 | 43 | // 删除好友 44 | bool deleteMyFriend(const int &myID, const int &friendID); 45 | 46 | // 获取我的好友 47 | QJsonArray getMyFriends() const; 48 | // 获取我的群组 49 | QJsonArray getMyGroups() const; 50 | // 获取我的分组 51 | QJsonArray getMySubgroup() const; 52 | // 获取我的历史聊天列表 53 | QJsonArray getMyChatList() const; 54 | // 获取好友信息 55 | QJsonObject getFriendInfo(int id) const; 56 | // 获取群信息 57 | QJsonObject getGroupInfo(int id) const; 58 | 59 | // 判断改好友是否已经是我的好友了 60 | bool isMyFriend(const int &friendID); 61 | // 判断是否已经加入该群组了 62 | bool isInGroup(const int &groupID); 63 | // 判断是否是一个群的群主 64 | bool isAdmin(int id,int groupID); 65 | 66 | void updateFileMsg(BubbleInfo *info); 67 | 68 | // 获取历史聊天记录,id表示聊天窗口好友或者群的id,tag标记这是私聊还是群聊窗口,count表示最近的记录数 69 | QVector queryHistory(int id,int tag, int count); 70 | 71 | // 测试使用,打印数据库中的所有信息 72 | void queryAll(); 73 | signals: 74 | 75 | public slots: 76 | 77 | private: 78 | static DataBase *self; 79 | 80 | // 数据库管理 81 | QSqlDatabase userdb; 82 | }; 83 | 84 | 85 | #endif // DATABASE_H 86 | -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Conf/config.ini: -------------------------------------------------------------------------------- 1 | [User] 2 | ID=100001 3 | Name=xjx 4 | Passwd=123456 5 | 6 | [Server] 7 | HostAddr=114.212.86.139 8 | MsgPort=60100 9 | FilePort=60101 10 | GroupPort=0 11 | 12 | [Application] 13 | checked=true 14 | autoLogin=false 15 | sendWay=true 16 | -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Conf/debug.log: -------------------------------------------------------------------------------- 1 | 2020/10/13 15:04:39 login... 2 | 3 | to server 4 | /Graduation Project/Final/QQ/debug/QQ/Data/Head/100004.pngsent by:-2 5 | 23555 6 | 560158416 7 | up 900001 8 | 01 9 | 00002 10 | 手册(学生版).pdf 11 | 1560140470 12 | "name": "xjx", 13 | "status": 5 14 | }, 15 | { 16 | "groupid": 900003, 17 | "head": "100005.png", 18 | "id": 100005, 19 | "name": "user5", 20 | "status": 6 21 | } 22 | ], 23 | "from": 100001, 24 | "type": 50 25 | } 26 | 27 | 28 | "head": "100009.png", 29 | "id": 100009, 30 | "name": "user9", 31 | "status": 6 32 | } 33 | ], 34 | "from": 100001, 35 | "type": 50 36 | } 37 | 38 | 39 | "head": "100009.png", 40 | "id": 100009, 41 | "name": "user9", 42 | "status": 6 43 | } 44 | ], 45 | "from": 100001, 46 | "type": 50 47 | } 48 | 49 | 50 | "head": "100005.png", 51 | "id": 100005, 52 | "name": "user5", 53 | "status": 5 54 | }, 55 | { 56 | "groupid": 900003, 57 | "head": "100006.png", 58 | "id": 100006, 59 | "name": "user6", 60 | "status": 6 61 | }, 62 | { 63 | "groupid": 900003, 64 | "head": "100007.png", 65 | "id": 100007, 66 | "name": "user7", 67 | "status": 6 68 | }, 69 | { 70 | "groupid": 900003, 71 | "head": "100008.png", 72 | "id": 100008, 73 | "name": "user8", 74 | "status": 6 75 | }, 76 | { 77 | "groupid": 900003, 78 | "head": "100009.png", 79 | "id": 100009, 80 | "name": "user9", 81 | "status": 6 82 | } 83 | ], 84 | "from": 100001, 85 | "type": 50 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Database/user.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Database/user.db -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Face/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Face/default.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100001.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100002.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100003.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100004.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100005.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100006.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100007.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100008.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/100009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/100009.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900001.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900002.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900003.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900004.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900005.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900006.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900007.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900008.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/900009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/900009.png -------------------------------------------------------------------------------- /QQClient/debug/QQ/Data/Head/毕业照.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/debug/QQ/Data/Head/毕业照.jpg -------------------------------------------------------------------------------- /QQClient/exe.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/exe.ico -------------------------------------------------------------------------------- /QQClient/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Icons/MainWindow/back.png 4 | Icons/MainWindow/close.png 5 | Icons/MainWindow/max.png 6 | Icons/MainWindow/min.png 7 | Icons/MainWindow/title.png 8 | Icons/MainWindow/contact.png 9 | Icons/MainWindow/head.png 10 | Icons/MainWindow/chat.png 11 | Icons/MainWindow/settings.png 12 | Icons/MainWindow/chat2.png 13 | Icons/MainWindow/contact2.png 14 | Icons/MainWindow/settings2.png 15 | Icons/MainWindow/chat3.png 16 | Icons/MainWindow/contact3.png 17 | Icons/MainWindow/settings3.png 18 | Icons/MainWindow/search_close.png 19 | Icons/MainWindow/search.png 20 | Icons/MainWindow/add.png 21 | Icons/MainWindow/arrowDown.png 22 | Icons/MainWindow/arrowDown2.png 23 | Icons/MainWindow/arrowRight.png 24 | Icons/MainWindow/arrowRight2.png 25 | Icons/MainWindow/default_head_icon.png 26 | Icons/MainWindow/friend.png 27 | Icons/MainWindow/friend2.png 28 | Icons/MainWindow/friend3.png 29 | Icons/MainWindow/group.png 30 | Icons/MainWindow/group2.png 31 | Icons/MainWindow/group3.png 32 | Icons/MainWindow/head2.png 33 | Icons/MainWindow/arrow_close.png 34 | Icons/MainWindow/arrow_open.png 35 | Icons/MainWindow/emoji.png 36 | Icons/MainWindow/emoji2.png 37 | Icons/MainWindow/file.png 38 | Icons/MainWindow/file2.png 39 | Icons/MainWindow/screenshot.png 40 | Icons/MainWindow/screenshot2.png 41 | Icons/MainWindow/arrow_close2.png 42 | Icons/MainWindow/arrow_open2.png 43 | Icons/MainWindow/group_chat.png 44 | Icons/MainWindow/loading.gif 45 | Icons/FileType/pdf.png 46 | Icons/MainWindow/picture.png 47 | Icons/MainWindow/picture2.png 48 | Icons/FileType/file.png 49 | Icons/FileType/picture.png 50 | Icons/FileType/video.png 51 | Icons/FileType/word.png 52 | Icons/MainWindow/top.png 53 | Icons/MainWindow/top2.png 54 | Icons/MainWindow/close2.png 55 | Icons/MainWindow/head_bkg.png 56 | Icons/MainWindow/newmsg.png 57 | Icons/MainWindow/blank.png 58 | Icons/MainWindow/left_arrow.png 59 | Icons/MainWindow/radius_back.png 60 | Icons/MainWindow/radius_front.png 61 | Icons/MainWindow/createGroup.png 62 | Icons/MainWindow/notice.png 63 | Icons/MainWindow/error.png 64 | Icons/MainWindow/shadow.png 65 | Icons/MainWindow/female.png 66 | Icons/MainWindow/male.png 67 | Icons/MainWindow/sendMsg.png 68 | Icons/MainWindow/sendMsg2.png 69 | Icons/MainWindow/editHead.png 70 | Icons/MainWindow/editHead2.png 71 | Icons/MainWindow/sendBtn_arrow_down.png 72 | Icons/MainWindow/admin.png 73 | Icons/MainWindow/top_chat.png 74 | Icons/MainWindow/loading2.gif 75 | Icons/MainWindow/deleted.png 76 | 77 | 78 | -------------------------------------------------------------------------------- /QQClient/leftbar.cpp: -------------------------------------------------------------------------------- 1 | #include "leftbar.h" 2 | #include "titlebar.h" 3 | #include "myapp.h" 4 | #include "userinfownd.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef Q_OS_WIN 13 | #pragma comment(lib, "user32.lib") 14 | #include 15 | #endif 16 | 17 | LeftBar::LeftBar(QWidget *parent) : QWidget(parent) 18 | { 19 | setWindowFlag(Qt::FramelessWindowHint); 20 | setFixedWidth(80); 21 | 22 | QString headPath = MyApp::m_strHeadPath + MyApp::m_strHeadFile; 23 | QFileInfo fileInfo(headPath); 24 | if(!fileInfo.exists() || MyApp::m_strHeadFile.isEmpty()){ 25 | MyApp::m_strHeadFile = "default.png"; 26 | headPath = MyApp::m_strHeadPath + MyApp::m_strHeadFile; 27 | } 28 | 29 | QStringList tmp; 30 | // tmp << headPath << headPath << headPath; 31 | // //qDebug() << "headPath:" << headPath; 32 | // headIcon = new MyButton(nullptr,tmp,QSize(60,60),HeadBtn); 33 | // tmp.clear(); 34 | 35 | headLabel = new HeadLabel(this, headPath, ":/loginwnd/head_bkg_shadow", ":/loginwnd/head_bkg_highlight2",1); 36 | headLabel->setFixedSize(98, 98); 37 | headLabel->move(-9,6); 38 | 39 | tmp << ":/Icons/MainWindow/chat.png" 40 | << ":/Icons/MainWindow/chat2.png" 41 | << ":/Icons/MainWindow/chat3.png"; 42 | chatList = new MyButton(nullptr,tmp,QSize(30,30)); 43 | chatList->setToolTip("聊天"); 44 | tmp.clear(); 45 | 46 | tmp << ":/Icons/MainWindow/contact.png" 47 | << ":/Icons/MainWindow/contact2.png" 48 | << ":/Icons/MainWindow/contact3.png"; 49 | contacts = new MyButton(nullptr,tmp,QSize(30,30)); 50 | contacts->setToolTip("联系人"); 51 | tmp.clear(); 52 | 53 | tmp << ":/Icons/MainWindow/settings.png" 54 | << ":/Icons/MainWindow/settings2.png" 55 | << ":/Icons/MainWindow/settings.png"; 56 | settings = new MyButton(nullptr,tmp,QSize(30,30)); 57 | settings->setToolTip("设置"); 58 | tmp.clear(); 59 | 60 | TitleBar *titleBar = new TitleBar(nullptr,0); 61 | 62 | QVBoxLayout *layout = new QVBoxLayout(this); 63 | layout->addWidget(titleBar); 64 | //layout->addWidget(headLabel,0,Qt::AlignCenter); 65 | layout->addStretch(2); 66 | layout->addWidget(chatList,0,Qt::AlignCenter); 67 | layout->addStretch(1); 68 | layout->addWidget(contacts,0,Qt::AlignCenter); 69 | layout->addStretch(1); 70 | layout->addWidget(settings,0,Qt::AlignCenter); 71 | layout->addStretch(15); 72 | 73 | 74 | m_btnGroup = new QButtonGroup(this); 75 | m_btnGroup->addButton(chatList, 0); 76 | m_btnGroup->addButton(contacts, 1); 77 | m_btnGroup->addButton(settings, 2); 78 | 79 | chatList->onBtnClicked();//默认选中会话列表按钮 80 | 81 | connect(headLabel,&HeadLabel::clicked,[&](){ 82 | qDebug() << "显示个人信息"; 83 | int id = MyApp::m_nId; 84 | QString name = MyApp::m_strUserName; 85 | QString head = MyApp::m_strHeadPath + MyApp::m_strHeadFile; 86 | 87 | UserInfoWnd *myInfo = new UserInfoWnd(nullptr,id,name,head,0); 88 | 89 | myInfo->show(); 90 | myInfo->move(QCursor::pos()); 91 | }); 92 | 93 | QPalette palette; 94 | palette.setColor(QPalette::Background, QColor(39, 41, 45));//110, 123, 139 95 | setAutoFillBackground(true); //一定要这句,否则不行 96 | setPalette(palette); 97 | 98 | setFocusPolicy(Qt::StrongFocus); 99 | } 100 | 101 | void LeftBar::mousePressEvent(QMouseEvent *event) 102 | { 103 | #ifdef Q_OS_WIN 104 | if (ReleaseCapture()){ 105 | QWidget *pWindow = this->window(); 106 | if (pWindow->isTopLevel()){ 107 | SendMessage(HWND(pWindow->winId()), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); 108 | } 109 | } 110 | event->ignore(); 111 | #endif 112 | } 113 | -------------------------------------------------------------------------------- /QQClient/leftbar.h: -------------------------------------------------------------------------------- 1 | #ifndef LEFTBAR_H 2 | #define LEFTBAR_H 3 | 4 | #include "mybutton.h" 5 | #include "headlabel.h" 6 | 7 | #include 8 | #include 9 | 10 | class LeftBar : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit LeftBar(QWidget *parent = nullptr); 15 | 16 | //MyButton *headIcon; 17 | HeadLabel *headLabel; 18 | 19 | MyButton *chatList; 20 | MyButton *contacts; 21 | MyButton *settings; 22 | QButtonGroup *m_btnGroup; 23 | 24 | protected: 25 | // 重写鼠标操作以实现移动窗口 26 | virtual void mousePressEvent(QMouseEvent *event) override; 27 | 28 | signals: 29 | 30 | public slots: 31 | }; 32 | 33 | #endif // LEFTBAR_H 34 | -------------------------------------------------------------------------------- /QQClient/login/LoginWnd/loginlineedit.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 登录界面的用户名密码输入框 3 | ****************************************************************************/ 4 | 5 | #include "loginlineedit.h" 6 | 7 | LoginLineEdit::LoginLineEdit(QWidget *parent) : QWidget(parent), m_lineEdit(nullptr), 8 | m_leftIcon(nullptr), m_rightIcon(nullptr), m_bottomLine(nullptr) 9 | { 10 | this->setFixedSize(230, 30); 11 | 12 | m_lineEdit = new LineEditEx(this); 13 | m_lineEdit->setFixedSize(200, 30); 14 | m_lineEdit->move(20, 0); 15 | m_lineEdit->setStyleSheet("border-width:0;border-style:outset"); 16 | connect(m_lineEdit, &LineEditEx::focusInSignal, this, &LoginLineEdit::focusIn); 17 | connect(m_lineEdit, &LineEditEx::focusOutSignal, this, &LoginLineEdit::focusOut); 18 | connect(m_lineEdit, &LineEditEx::returnPressed,this,&LoginLineEdit::returnPressed); 19 | 20 | m_leftIcon = new QLabel(this); 21 | m_leftIcon->setFixedSize(12, 16); 22 | m_leftIcon->move(1, 7); 23 | 24 | m_rightIcon = new QLabel(this); 25 | m_rightIcon->setFixedSize(12, 16); 26 | m_rightIcon->move(247, 7); 27 | 28 | m_bottomLine = new QLabel(this); 29 | m_bottomLine->setFixedSize(230, 2); 30 | m_bottomLine->move(0, 28); 31 | 32 | connect(m_lineEdit,SIGNAL(textChanged(const QString &)),this,SIGNAL(textChanged())); 33 | } 34 | 35 | 36 | void LoginLineEdit::setLeftIcon(QString leftIconPathNormal, QString leftIconPathHover) 37 | { 38 | m_leftIconPathNormal = leftIconPathNormal; 39 | m_leftIconPathHover = leftIconPathHover; 40 | 41 | if(m_leftIcon != nullptr){ 42 | m_leftIcon->setPixmap(QPixmap(m_leftIconPathNormal)); 43 | } 44 | } 45 | 46 | 47 | void LoginLineEdit::setBottomIcon(QString bottomLinePathNormal, QString bottomLinePathHover) 48 | { 49 | m_bottomLinePathNormal = bottomLinePathNormal; 50 | m_bottomLinePathHover = bottomLinePathHover; 51 | 52 | if(m_bottomLine != nullptr){ 53 | m_bottomLine->setPixmap(QPixmap(m_bottomLinePathNormal)); 54 | } 55 | } 56 | 57 | 58 | void LoginLineEdit::setLineEditStyleSheet(QString styleSheet) 59 | { 60 | if(m_lineEdit != nullptr){ 61 | m_lineEdit->setStyleSheet(styleSheet); 62 | } 63 | } 64 | 65 | 66 | void LoginLineEdit::setPlaceholderText(QString placeholderText) 67 | { 68 | if(m_lineEdit != nullptr){ 69 | m_lineEdit->setPlaceholderText(placeholderText); 70 | } 71 | } 72 | 73 | 74 | void LoginLineEdit::setEchoMode(QLineEdit::EchoMode echoMode) 75 | { 76 | if(m_lineEdit != nullptr){ 77 | m_lineEdit->setEchoMode(echoMode); 78 | } 79 | } 80 | 81 | 82 | QString LoginLineEdit::text() const 83 | { 84 | return m_lineEdit->text(); 85 | } 86 | 87 | void LoginLineEdit::setFocus() 88 | { 89 | m_lineEdit->setFocus(); 90 | } 91 | 92 | 93 | void LoginLineEdit::focusIn() 94 | { 95 | if(m_leftIcon != nullptr){ 96 | m_leftIcon->setPixmap(QPixmap(m_leftIconPathHover)); 97 | } 98 | 99 | if(m_bottomLine != nullptr){ 100 | m_bottomLine->setPixmap(QPixmap(m_bottomLinePathHover)); 101 | } 102 | } 103 | 104 | 105 | void LoginLineEdit::focusOut() 106 | { 107 | if(m_leftIcon != nullptr){ 108 | m_leftIcon->setPixmap(QPixmap(m_leftIconPathNormal)); 109 | } 110 | 111 | if(m_bottomLine != nullptr){ 112 | m_bottomLine->setPixmap(QPixmap(m_bottomLinePathNormal)); 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /QQClient/login/LoginWnd/loginlineedit.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 登录界面的用户名密码输入框 3 | ****************************************************************************/ 4 | 5 | #ifndef LOGINEDITLINE_H 6 | #define LOGINEDITLINE_H 7 | 8 | #include "lineeditex.h" 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | class LoginLineEdit : public QWidget 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit LoginLineEdit(QWidget *parent = nullptr); 19 | 20 | public: 21 | void setLeftIcon(QString leftIconPathNormal, QString leftIconPathHover); 22 | void setBottomIcon(QString bottomLinePathNormal, QString bottomLinePathHover); 23 | void setLineEditStyleSheet(QString styleSheet); 24 | void setPlaceholderText(QString placeholderText); 25 | void setEchoMode(QLineEdit::EchoMode echoMode); 26 | 27 | QString text() const; 28 | void setText(QString text){m_lineEdit->setText(text);} 29 | void setFocus(); 30 | 31 | signals: 32 | void returnPressed(); 33 | void textChanged(); 34 | 35 | public slots: 36 | void focusIn(); 37 | void focusOut(); 38 | 39 | private: 40 | LineEditEx* m_lineEdit; // 编辑框 41 | QLabel* m_leftIcon; // 编辑框左边的图标 42 | QLabel* m_rightIcon; // 编辑框右边的图标 43 | QLabel* m_bottomLine; // 编辑框下方的线条 44 | 45 | QString m_leftIconPathNormal; 46 | QString m_leftIconPathHover; 47 | QString m_bottomLinePathNormal; 48 | QString m_bottomLinePathHover; 49 | }; 50 | 51 | #endif // LOGINEDITLINE_H 52 | -------------------------------------------------------------------------------- /QQClient/login/LoginWnd/loginwnd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 登录界面窗体 3 | ****************************************************************************/ 4 | 5 | #ifndef LOGINWND_H 6 | #define LOGINWND_H 7 | 8 | #include "loginwndmainpage.h" 9 | #include "loginwndloginingpage.h" 10 | #include "clientsocket.h" 11 | 12 | #include 13 | 14 | 15 | class LoginWnd : public QStackedWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit LoginWnd(QWidget *parent = nullptr); 21 | void showMainUI(); 22 | 23 | signals: 24 | void rotateWindow(); 25 | void closeWindow(); 26 | void hideWindow(); 27 | void loginSuccess(); 28 | void openRegisterWnd(); 29 | void openChangePasswordWnd(); 30 | 31 | void signalRegisterOK(const QJsonValue&); 32 | void signalChangePwdReply(const QJsonValue &dataVal); 33 | 34 | public slots: 35 | void changePage(); 36 | void showNotifyMsg(QString); 37 | void hideNotifyMsg(); 38 | void sltTcpStatus(const quint8 &state); 39 | void slotTimeout(); 40 | 41 | void sltFileRecvFinished(quint8,QString,int); 42 | void checkAutoLogin(); 43 | 44 | void sltRegister(const QJsonValue &); 45 | void sltChangePwd(const QJsonValue &); 46 | 47 | void writeOffLineMsgToDatabase(const QJsonValue &); 48 | void sltGetOffLineMsg(); 49 | 50 | private: 51 | LoginWndMainPage *loginMainPage; 52 | LoginWndLoginingPage *loginingPage; 53 | ClientSocket *tcpSocket; 54 | bool connected; 55 | QTimer *timer; 56 | 57 | ClientFileSocket *globalFileSocket; 58 | 59 | QLabel *m_notifyMsg;// 提醒信息 60 | 61 | protected: 62 | void paintEvent(QPaintEvent*); 63 | }; 64 | 65 | #endif // LOGINWND_H 66 | -------------------------------------------------------------------------------- /QQClient/login/LoginWnd/loginwndloginingpage.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 登录窗口登录中界面 3 | ****************************************************************************/ 4 | #include "loginwndloginingpage.h" 5 | #include "myapp.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | LoginWndLoginingPage::LoginWndLoginingPage(QWidget *parent) : WindowBase(parent) 12 | { 13 | this->setFixedSize(430,330);//(430,330) 14 | this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); 15 | 16 | QString headPath = MyApp::m_strHeadPath + MyApp::m_strHeadFile; 17 | //qDebug() << "headPath:" << headPath; 18 | QFileInfo fileInfo(headPath); 19 | if(!fileInfo.exists() || MyApp::m_strHeadFile.isEmpty()) 20 | headPath = ":/loginwnd/defalut_head"; 21 | 22 | 23 | m_headLabel = new HeadLabel(this, headPath, ":/loginwnd/head_bkg_shadow", ":/loginwnd/head_bkg_highlight"); 24 | m_headLabel->setFixedSize(98, 98); 25 | m_headLabel->move(166, 90); 26 | 27 | m_loginingLabel = new QLabel(this); 28 | m_loginingLabel->setText(tr("登录中")+m_points); 29 | m_loginingLabel->move(168, 175); 30 | m_loginingLabel->setFixedSize(100, 35); 31 | m_loginingLabel->setAlignment(Qt::AlignCenter); 32 | m_loginingLabel->setStyleSheet("font-size: 18px;font-family:Microsoft YaHei; color: #ffffff"); 33 | 34 | m_cancelBtn = new QPushButton(this); 35 | m_cancelBtn->move(168, 270); 36 | m_cancelBtn->setFixedSize(100, 35); 37 | m_cancelBtn->setText(tr("取消")); 38 | m_cancelBtn->setStyleSheet("QPushButton{ background-color:rgba(49,195,255,45);border-color:#96d5fd; " 39 | "border-width:1px; border-radius:2px; border-style: solid;" 40 | "font-size: 16px;font-family:Microsoft YaHei; color: #ffffff}" 41 | "QPushButton:hover:!pressed{ background-color:rgba(111,221,255,45);" 42 | "border-color:#96d5fd; border-width:1px; border-radius:2px; border-style: solid;}" 43 | "QPushButton:hover:pressed{ background-color:rgba(147,238,255,45);border-color:#96d5fd;" 44 | "border-width:1px; border-radius:2px; border-style: solid;}"); 45 | QObject::connect(m_cancelBtn, &QPushButton::clicked, this, &LoginWndLoginingPage::cancelButtonClicked); 46 | 47 | m_loginingTimer = new QTimer(this); 48 | QObject::connect(m_loginingTimer, &QTimer::timeout, this, &LoginWndLoginingPage::changePoints); 49 | m_loginingTimer->start(1000); 50 | } 51 | 52 | void LoginWndLoginingPage::hideEvent(QHideEvent *) 53 | { 54 | m_loginingTimer->stop(); 55 | emit hideWindow(); 56 | } 57 | 58 | void LoginWndLoginingPage::changePoints() 59 | { 60 | m_points.append('.'); 61 | if(m_points.size() > 3){ 62 | m_points.clear(); 63 | } 64 | m_loginingLabel->setText(tr("登录中")+m_points); 65 | } 66 | 67 | void LoginWndLoginingPage::cancelButtonClicked(bool) 68 | { 69 | emit cancelSignal(); 70 | } 71 | 72 | void LoginWndLoginingPage::loginSuccess() 73 | { 74 | m_loginingTimer->stop(); 75 | m_loginingLabel->setText(tr("登录成功!")); 76 | //m_headLabel->updateHead(); 77 | QTimer::singleShot(1000,this,SLOT(showMainUI())); 78 | } 79 | 80 | void LoginWndLoginingPage::updateHead() 81 | { 82 | QString headPath = MyApp::m_strHeadPath + MyApp::m_strHeadFile; 83 | //qDebug() << "headPath:" << headPath; 84 | QFileInfo fileInfo(headPath); 85 | if(!fileInfo.exists() || MyApp::m_strHeadFile.isEmpty()) 86 | headPath = ":/loginwnd/defalut_head"; 87 | 88 | m_headLabel->changeHead(headPath); 89 | } 90 | 91 | void LoginWndLoginingPage::showMainUI() 92 | { 93 | emit animationFinished(); 94 | } 95 | -------------------------------------------------------------------------------- /QQClient/login/LoginWnd/loginwndloginingpage.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 登录窗口登录中界面 3 | ****************************************************************************/ 4 | #ifndef LOGINWNDLOGININGPAGE_H 5 | #define LOGINWNDLOGININGPAGE_H 6 | 7 | #include "windowbase.h" 8 | #include "headlabel.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | class LoginWndLoginingPage : public WindowBase 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit LoginWndLoginingPage(QWidget *parent = nullptr); 19 | 20 | protected: 21 | virtual void hideEvent(QHideEvent *) override; 22 | 23 | signals: 24 | void cancelSignal(); 25 | void closeWindow(); 26 | void hideWindow(); 27 | void animationFinished(); 28 | 29 | 30 | public slots: 31 | void changePoints(); 32 | void cancelButtonClicked(bool); 33 | void showMainUI(); 34 | void loginSuccess(); 35 | 36 | void updateHead(); 37 | 38 | private: 39 | QLabel* m_loginingLabel; // 正在登录中标签 40 | QPushButton* m_cancelBtn; // 取消登录按钮 41 | QTimer* m_loginingTimer; // 登录中动画计时器 42 | QString m_points; // 登录中后面的小点 43 | 44 | HeadLabel* m_headLabel; // 头像 45 | }; 46 | 47 | 48 | #endif // LOGINWNDLOGININGPAGE_H 49 | -------------------------------------------------------------------------------- /QQClient/login/LoginWnd/loginwndmainpage.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 登录界面窗体: 登录界面显示的控件 3 | ****************************************************************************/ 4 | #ifndef LOGINWNDMAINPAGE_H 5 | #define LOGINWNDMAINPAGE_H 6 | 7 | #include "headlabel.h" 8 | #include "checkbox.h" 9 | #include "clickablelabel.h" 10 | #include "loginlineedit.h" 11 | #include "windowbase.h" 12 | 13 | #include 14 | #include 15 | 16 | 17 | class LoginWndMainPage : public WindowBase 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit LoginWndMainPage(QWidget *parent = nullptr); 22 | QString getID(){return m_userIDEdit->text();} 23 | QString getPassword(){return m_passwordEdit->text();} 24 | void readConfig(); 25 | 26 | protected: 27 | virtual void paintEvent(QPaintEvent *) override; 28 | virtual void showEvent(QShowEvent*) override; 29 | 30 | signals: 31 | void loginSignal(); 32 | void closeWindow(); 33 | void hideWindow(); 34 | void rotateWindow(); 35 | 36 | void hideNotifyMsg(); 37 | void showNotifyMsg(QString); 38 | 39 | void openRegisterWnd(); 40 | void openChangePasswordWnd(); 41 | void changeLoginingHead(); 42 | 43 | public slots: 44 | void openRegisterAccountUrl(ClickableLabel*); 45 | void openFindPasswordUrl(ClickableLabel*); 46 | void autoLoginChecked(bool isChecked); 47 | void loginBtnClicked(); 48 | void remeberPassword(bool isChecked); 49 | void checkAutoLogin(); 50 | void changeHead(); 51 | 52 | private: 53 | QPushButton* m_memuSetBtn; //网络设置按钮 54 | QPushButton* m_menuCloseBtn; // 菜单栏关闭按钮 55 | QPushButton* m_menuMinBtn; // 菜单栏最小化按钮 56 | HeadLabel* m_headLabel; // 头像 57 | 58 | LoginLineEdit* m_userIDEdit; // 用户名 59 | LoginLineEdit* m_passwordEdit; // 密码 60 | CheckBox* m_autoLogin; // 自动登录 61 | CheckBox* m_remeberPassword; // 自动登录 62 | QPushButton* m_loginBtn; // 登录按钮 63 | 64 | ClickableLabel* m_findPassword; // 找回密码 65 | ClickableLabel* m_registerAccount; // 注册账号 66 | }; 67 | 68 | 69 | #endif // LOGINWNDMAINPAGE_H 70 | -------------------------------------------------------------------------------- /QQClient/login/Util/checkbox.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 自定义的 CheckBox 3 | ****************************************************************************/ 4 | #include "checkbox.h" 5 | 6 | #include 7 | 8 | const QString CheckBox::CHECKBOX_NORMAL_ICON_PATHS[2] = {":/loginwnd/checkbox_normal", ":/loginwnd/checkbox_tick_normal"}; 9 | const QString CheckBox::CHECKBOX_HOVER_ICON_PATHS[2] = {":/loginwnd/checkbox_hover", ":/loginwnd/checkbox_tick_highlight"}; 10 | const QString CheckBox::CHECKBOX_PRESS_ICON_PATHS[2] = {":/loginwnd/checkbox_press", ":/loginwnd/checkbox_tick_pushed"}; 11 | 12 | CheckBox::CheckBox(bool checked, QWidget *parent) : QWidget(parent), m_isChecked(checked), 13 | m_leftIcon(nullptr), m_textLabel(nullptr) 14 | { 15 | m_leftIcon = new QLabel(this); 16 | m_leftIcon->setPixmap(QPixmap(CHECKBOX_NORMAL_ICON_PATHS[m_isChecked])); 17 | m_leftIcon->setFixedSize(14, 14); 18 | m_leftIcon->move(3, 3); 19 | 20 | m_textLabel = new QLabel(this); 21 | m_textLabel->setStyleSheet("font-size: 12px;font-family:Microsoft YaHei; color: #a6a6a6"); 22 | m_textLabel->setFixedSize(55, 20); 23 | m_textLabel->move(20, 0); 24 | } 25 | 26 | void CheckBox::setText(QString text) 27 | { 28 | m_textLabel->setText(text); 29 | } 30 | 31 | void CheckBox::mousePressEvent(QMouseEvent *event) 32 | { 33 | m_isChecked = !m_isChecked; 34 | emit statusChanged(m_isChecked); 35 | 36 | event->accept(); 37 | m_leftIcon->setPixmap(QPixmap(CHECKBOX_PRESS_ICON_PATHS[m_isChecked])); 38 | } 39 | 40 | void CheckBox::mouseReleaseEvent(QMouseEvent *event) 41 | { 42 | event->accept(); 43 | m_leftIcon->setPixmap(QPixmap(CHECKBOX_NORMAL_ICON_PATHS[m_isChecked])); 44 | } 45 | 46 | void CheckBox::enterEvent(QEvent *) 47 | { 48 | m_leftIcon->setPixmap(QPixmap(CHECKBOX_HOVER_ICON_PATHS[m_isChecked])); 49 | } 50 | 51 | void CheckBox::leaveEvent(QEvent *) 52 | { 53 | m_leftIcon->setPixmap(QPixmap(CHECKBOX_NORMAL_ICON_PATHS[m_isChecked])); 54 | } 55 | 56 | void CheckBox::changeStatus(bool isChecked) 57 | { 58 | m_isChecked = isChecked; 59 | m_leftIcon->setPixmap(QPixmap(CHECKBOX_NORMAL_ICON_PATHS[m_isChecked])); 60 | } 61 | -------------------------------------------------------------------------------- /QQClient/login/Util/checkbox.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 自定义的 CheckBox 3 | ****************************************************************************/ 4 | #ifndef CHECKBOX_H 5 | #define CHECKBOX_H 6 | 7 | #include 8 | #include 9 | 10 | 11 | class CheckBox : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit CheckBox(bool checked = false, QWidget *parent = nullptr); 16 | void setText(QString text); 17 | 18 | protected: 19 | virtual void mousePressEvent(QMouseEvent *event) override; 20 | virtual void mouseReleaseEvent(QMouseEvent *event) override; 21 | virtual void enterEvent(QEvent *) override; 22 | virtual void leaveEvent(QEvent *) override; 23 | 24 | signals: 25 | void statusChanged(bool isChecked); 26 | 27 | public slots: 28 | void changeStatus(bool isChecked); 29 | 30 | private: 31 | bool m_isChecked; 32 | QLabel* m_leftIcon; // CheckBox 左边的图标 33 | QLabel* m_textLabel; // CheckBox 右边的文字 34 | 35 | const static QString CHECKBOX_NORMAL_ICON_PATHS[2]; 36 | const static QString CHECKBOX_HOVER_ICON_PATHS[2]; 37 | const static QString CHECKBOX_PRESS_ICON_PATHS[2]; 38 | }; 39 | 40 | 41 | #endif // CHECKBOX_H 42 | -------------------------------------------------------------------------------- /QQClient/login/Util/clickablelabel.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 响应点击操作的 QLabel 3 | ****************************************************************************/ 4 | #include "clickablelabel.h" 5 | 6 | 7 | 8 | ClickableLabel::ClickableLabel(QWidget *parent) : QLabel(parent) 9 | { 10 | 11 | } 12 | 13 | void ClickableLabel::mousePressEvent(QMouseEvent *) 14 | { 15 | emit clickSignal(this); 16 | } 17 | 18 | void ClickableLabel::enterEvent(QEvent *) 19 | { 20 | this->setStyleSheet("font-size: 12px;font-family:Microsoft YaHei; color: #12b7f5"); 21 | setCursor(Qt::PointingHandCursor); 22 | } 23 | 24 | void ClickableLabel::leaveEvent(QEvent *) 25 | { 26 | this->setStyleSheet("font-size: 12px;font-family:Microsoft YaHei; color: #a6a6a6"); 27 | setCursor(Qt::ArrowCursor); 28 | } 29 | -------------------------------------------------------------------------------- /QQClient/login/Util/clickablelabel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 响应点击操作的 QLabel 3 | ****************************************************************************/ 4 | 5 | #ifndef CLICKABLELABEL_H 6 | #define CLICKABLELABEL_H 7 | 8 | #include 9 | #include 10 | 11 | 12 | class ClickableLabel : public QLabel 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit ClickableLabel(QWidget *parent = nullptr); 17 | 18 | protected: 19 | virtual void mousePressEvent(QMouseEvent *) override; 20 | virtual void enterEvent(QEvent *) override; 21 | virtual void leaveEvent(QEvent *) override; 22 | 23 | signals: 24 | void clickSignal(ClickableLabel* label); 25 | 26 | public slots: 27 | 28 | }; 29 | 30 | 31 | #endif // CLICKABLELABEL_H 32 | -------------------------------------------------------------------------------- /QQClient/login/Util/headlabel.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 头像显示 Label 3 | ****************************************************************************/ 4 | #include "headlabel.h" 5 | #include "myapp.h" 6 | 7 | #include 8 | #include 9 | 10 | 11 | HeadLabel::HeadLabel(QWidget *parent, QString headPhotoPath, QString headPhotoShadowPath, QString headPhotoHighlightPath,int tag) 12 | : QLabel(parent), m_headPhoto(nullptr), m_headPhotoRound(nullptr),m_headPhotoShadow(nullptr), m_headPhotoHighlight(nullptr),tag(tag) 13 | { 14 | if(!headPhotoPath.isEmpty()) 15 | m_headPhoto = new QPixmap(headPhotoPath); 16 | if(!headPhotoShadowPath.isEmpty()) 17 | m_headPhotoShadow = new QPixmap(headPhotoShadowPath); 18 | if(!headPhotoHighlightPath.isEmpty()) 19 | m_headPhotoHighlight = new QPixmap(headPhotoHighlightPath); 20 | 21 | this->headPhotoHighlightPath = headPhotoHighlightPath; 22 | } 23 | 24 | 25 | HeadLabel::~HeadLabel() 26 | { 27 | if(m_headPhoto != nullptr) 28 | delete m_headPhoto; 29 | if(m_headPhotoRound != nullptr) 30 | delete m_headPhotoRound; 31 | if(m_headPhotoShadow != nullptr) 32 | delete m_headPhotoShadow; 33 | if(m_headPhotoHighlight != nullptr) 34 | delete m_headPhotoHighlight; 35 | } 36 | 37 | void HeadLabel::updateHead() 38 | { 39 | m_headPhoto = new QPixmap(MyApp::m_strHeadPath + MyApp::m_strHeadFile); 40 | } 41 | 42 | void HeadLabel::changeHead(QString head) 43 | { 44 | m_headPhoto = new QPixmap(head); 45 | 46 | if(m_headPhoto != nullptr){ 47 | if(m_headPhotoRound != nullptr) 48 | delete m_headPhotoRound; 49 | 50 | m_headPhotoSize = {this->size().width()*31/49, this->size().height()*31/49}; 51 | QBitmap mask(m_headPhotoSize); 52 | QPainter maskPainter(&mask); 53 | maskPainter.setRenderHint(QPainter::Antialiasing); 54 | maskPainter.setRenderHint(QPainter::SmoothPixmapTransform); 55 | maskPainter.fillRect(0, 0, m_headPhotoSize.width(), m_headPhotoSize.height(), Qt::white); 56 | maskPainter.setBrush(QColor(0, 0, 0)); 57 | maskPainter.drawRoundedRect(0, 0, m_headPhotoSize.width(), m_headPhotoSize.height(), 100, 100); 58 | m_headPhotoRound = new QPixmap(m_headPhoto->scaled(m_headPhotoSize)); 59 | m_headPhotoRound->setMask(mask); 60 | } 61 | 62 | 63 | update(); 64 | } 65 | 66 | 67 | void HeadLabel::paintEvent(QPaintEvent *event) 68 | { 69 | QPainter painter(this); 70 | painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform); 71 | 72 | if(m_headPhotoRound != nullptr) { 73 | int tx = (this->width()-m_headPhotoSize.width())/2; 74 | int ty = (this->height()-m_headPhotoSize.height())/2; 75 | painter.drawPixmap(tx, ty, *m_headPhotoRound); 76 | } 77 | 78 | if(m_headPhotoHighlight != nullptr){ 79 | int tx = (this->width()-m_headPhotoHighlightSize.width())/2; 80 | int ty = (this->height()-m_headPhotoHighlightSize.height())/2; 81 | painter.drawPixmap(tx, ty, m_headPhotoHighlightSize.width(), 82 | m_headPhotoHighlightSize.height(), *m_headPhotoHighlight); 83 | } 84 | 85 | if(tag == 0){ 86 | if(m_headPhotoShadow != nullptr) 87 | painter.drawPixmap(0, 0, *m_headPhotoShadow); 88 | }else if(tag == 1){ 89 | if(mouseIn){ 90 | if(m_headPhotoShadow != nullptr) 91 | painter.drawPixmap(0, 0, *m_headPhotoShadow); 92 | } 93 | } 94 | 95 | return QLabel::paintEvent(event); 96 | } 97 | 98 | 99 | void HeadLabel::resizeEvent(QResizeEvent *event) 100 | { 101 | // 创建圆形头像 102 | if(m_headPhoto != nullptr){ 103 | if(m_headPhotoRound != nullptr) 104 | delete m_headPhotoRound; 105 | 106 | m_headPhotoSize = {this->size().width()*31/49, this->size().height()*31/49}; 107 | QBitmap mask(m_headPhotoSize); 108 | QPainter maskPainter(&mask); 109 | maskPainter.setRenderHint(QPainter::Antialiasing); 110 | maskPainter.setRenderHint(QPainter::SmoothPixmapTransform); 111 | maskPainter.fillRect(0, 0, m_headPhotoSize.width(), m_headPhotoSize.height(), Qt::white); 112 | maskPainter.setBrush(QColor(0, 0, 0)); 113 | maskPainter.drawRoundedRect(0, 0, m_headPhotoSize.width(), m_headPhotoSize.height(), 100, 100); 114 | m_headPhotoRound = new QPixmap(m_headPhoto->scaled(m_headPhotoSize)); 115 | m_headPhotoRound->setMask(mask); 116 | } 117 | 118 | if(m_headPhotoHighlight != nullptr) 119 | m_headPhotoHighlightSize = {this->size().width()*65/98, this->size().height()*65/98}; 120 | 121 | return QLabel::resizeEvent(event); 122 | } 123 | 124 | void HeadLabel::enterEvent(QEvent *e) 125 | { 126 | if(tag == 1){ 127 | mouseIn = true; 128 | setCursor(Qt::PointingHandCursor); 129 | 130 | m_headPhotoHighlight = new QPixmap(":/loginwnd/head_bkg_highlight"); 131 | this->update(); 132 | } 133 | return QLabel::enterEvent(e); 134 | } 135 | 136 | void HeadLabel::leaveEvent(QEvent *e) 137 | { 138 | if(tag == 1){ 139 | mouseIn = false; 140 | setCursor(Qt::ArrowCursor); 141 | m_headPhotoHighlight = new QPixmap(headPhotoHighlightPath); 142 | this->update(); 143 | } 144 | return QLabel::enterEvent(e); 145 | } 146 | 147 | void HeadLabel::mousePressEvent(QMouseEvent *e) 148 | { 149 | if(e->button() == Qt::LeftButton){ 150 | emit clicked(); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /QQClient/login/Util/headlabel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 头像显示 Label 3 | ****************************************************************************/ 4 | 5 | #ifndef HEADLABEL_H 6 | #define HEADLABEL_H 7 | 8 | #include 9 | #include 10 | 11 | class HeadLabel : public QLabel 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit HeadLabel(QWidget *parent = nullptr, QString headPhotoPath = "", 16 | QString headPhotoShadowPath = "", QString headPhotoHighlightPath = "",int tag = 0); 17 | ~HeadLabel() override; 18 | void updateHead(); 19 | 20 | void changeHead(QString head); 21 | 22 | protected: 23 | virtual void paintEvent(QPaintEvent *event) override; 24 | virtual void resizeEvent(QResizeEvent *event) override; 25 | virtual void enterEvent(QEvent*) override; 26 | virtual void leaveEvent(QEvent*) override; 27 | virtual void mousePressEvent(QMouseEvent *event) override; 28 | 29 | signals: 30 | void clicked(); 31 | 32 | public slots: 33 | 34 | private: 35 | QPixmap* m_headPhoto; // 头像原图 36 | QPixmap* m_headPhotoRound; // 显示的头像图 37 | QPixmap* m_headPhotoShadow; // 边框阴影 38 | QPixmap* m_headPhotoHighlight; // 高亮边框 39 | 40 | QSize m_headPhotoSize; // 显示头像的大小 41 | QSize m_headPhotoHighlightSize; // 显示头像高亮边框的大小 42 | 43 | QString headPhotoHighlightPath; 44 | 45 | int tag; 46 | bool mouseIn = false; 47 | }; 48 | 49 | #endif // HEADLABEL_H 50 | -------------------------------------------------------------------------------- /QQClient/login/Util/lineeditex.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 对 Qt 的 QLineEdit 进行扩展 3 | ****************************************************************************/ 4 | 5 | #include "lineeditex.h" 6 | 7 | #include 8 | #include 9 | 10 | LineEditEx::LineEditEx(QWidget *parent) : QLineEdit(parent) 11 | { 12 | 13 | } 14 | 15 | void LineEditEx::focusInEvent(QFocusEvent *event) 16 | { 17 | emit focusInSignal(); 18 | return QLineEdit::focusInEvent(event); 19 | } 20 | 21 | void LineEditEx::focusOutEvent(QFocusEvent *event) 22 | { 23 | emit focusOutSignal(); 24 | return QLineEdit::focusOutEvent(event); 25 | } 26 | -------------------------------------------------------------------------------- /QQClient/login/Util/lineeditex.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 对 Qt 的 QLineEdit 进行扩展 3 | ****************************************************************************/ 4 | 5 | #ifndef LINEEDITEX_H 6 | #define LINEEDITEX_H 7 | 8 | #include 9 | #include 10 | 11 | 12 | class LineEditEx : public QLineEdit 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit LineEditEx(QWidget *parent = nullptr); 17 | 18 | protected: 19 | virtual void focusInEvent(QFocusEvent *event) override; 20 | virtual void focusOutEvent(QFocusEvent *event) override; 21 | 22 | signals: 23 | void focusInSignal(); 24 | void focusOutSignal(); 25 | 26 | public slots: 27 | }; 28 | 29 | 30 | 31 | #endif // LINEEDITEX_H 32 | -------------------------------------------------------------------------------- /QQClient/login/Util/windowbase.cpp: -------------------------------------------------------------------------------- 1 | #include "windowbase.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | const QString WindowBase::LW_BACKGOUND_PREFIX = ":/loginwnd/login_bkg_"; 13 | const quint8 WindowBase::LW_BACKGOUND_NUM = 5; 14 | 15 | 16 | WindowBase::WindowBase(QWidget *parent) : QWidget(parent) 17 | { 18 | this->setWindowFlag(Qt::FramelessWindowHint); 19 | 20 | m_bkgOpacityInterval = 0.005; 21 | m_currentBkgIdx = 0; 22 | m_increasing = true; 23 | 24 | m_bkgTimer = new QTimer(this); 25 | connect(m_bkgTimer,SIGNAL(timeout()),this,SLOT(changeBackground())); 26 | m_bkgTimer->start(10); 27 | } 28 | 29 | 30 | void WindowBase::paintEventForRoundAndBorder(int roundRadius, int borderWidth) 31 | { 32 | // 绘制圆角窗口 33 | #if 1 34 | QBitmap maskBmp(this->size()); 35 | maskBmp.fill(); 36 | QPainter maskBmpPainter(&maskBmp); 37 | maskBmpPainter.setPen(Qt::NoPen); 38 | maskBmpPainter.setBrush(Qt::black); 39 | maskBmpPainter.setRenderHint(QPainter::Antialiasing, true); //抗锯齿 40 | maskBmpPainter.drawRoundedRect(this->rect(), roundRadius, roundRadius); 41 | setMask(maskBmp); 42 | #endif 43 | 44 | // 绘制边框阴影 45 | QPainter painter(this); 46 | QPixmap border(":/loginwnd/win_border"); 47 | QRect topRect(0, 0, this->rect().width(), borderWidth); 48 | QRect topRectSource(5, 0, border.width()-10, 5); 49 | QRect leftRect(0, 0, borderWidth, this->rect().height()); 50 | QRect leftRectSource(0, 5, 5, border.height()-10); 51 | QRect rightRect(this->rect().width()-borderWidth, 0, borderWidth, this->rect().height()); 52 | QRect rightRectSource(border.width()-5, 5, 5, border.height()-10); 53 | QRect bottomRect(0, this->rect().height()-borderWidth, this->rect().width(), borderWidth); 54 | QRect bottomRectSource(5, border.height()-5, border.width()-10, 5); 55 | 56 | painter.drawPixmap(topRect, border, topRectSource); 57 | painter.drawPixmap(leftRect, border, leftRectSource); 58 | painter.drawPixmap(rightRect, border, rightRectSource); 59 | painter.drawPixmap(bottomRect, border, bottomRectSource); 60 | } 61 | 62 | 63 | void WindowBase::paintEvent(QPaintEvent *e) 64 | { 65 | qint8 nextBkgIdx = getNextBkgIdx(); 66 | paintBackground(m_currentBkgIdx, 1); 67 | paintBackground(nextBkgIdx, m_bkgOpacity); 68 | 69 | paintEventForRoundAndBorder(10,1); 70 | 71 | return QWidget::paintEvent(e); 72 | } 73 | 74 | 75 | void WindowBase::changeBackground() 76 | { 77 | m_bkgOpacity = m_bkgOpacity + m_bkgOpacityInterval; 78 | if(m_bkgOpacity > 1.0){ 79 | m_currentBkgIdx = getNextBkgIdx(); 80 | m_bkgOpacity = 0; 81 | } 82 | 83 | this->update(); 84 | } 85 | 86 | 87 | qint8 WindowBase::getNextBkgIdx() 88 | { 89 | qint8 nextBkgIdx = m_currentBkgIdx; 90 | if(m_increasing == true){ 91 | if(++nextBkgIdx >= LW_BACKGOUND_NUM && m_currentBkgIdx-1 >= 0){ 92 | m_increasing = false; 93 | nextBkgIdx = m_currentBkgIdx-1; 94 | } 95 | }else if(m_increasing == false){ 96 | if(--nextBkgIdx < 0 && m_currentBkgIdx+1 < LW_BACKGOUND_NUM){ 97 | m_increasing = true; 98 | nextBkgIdx = m_currentBkgIdx+1; 99 | } 100 | } 101 | return nextBkgIdx; 102 | } 103 | 104 | 105 | void WindowBase::paintBackground(qint8 bkgIdx, qreal bkgOpacity) 106 | { 107 | QPainter painter(this); 108 | QPixmap background; 109 | background.load(QString("%1%2").arg(LW_BACKGOUND_PREFIX).arg(bkgIdx)); 110 | painter.setOpacity(bkgOpacity); 111 | painter.drawPixmap(0, 0, background); 112 | } 113 | 114 | 115 | #if 0 116 | 117 | void WindowBase::mousePressEvent(QMouseEvent *event) 118 | { 119 | if(event->button() == Qt::LeftButton){ 120 | m_pressedPoint = event->globalPos() - this->pos(); 121 | m_isPressed = true; 122 | event->accept(); 123 | } 124 | } 125 | 126 | 127 | void WindowBase::mouseReleaseEvent(QMouseEvent *event) 128 | { 129 | m_isPressed = false; 130 | event->accept(); 131 | } 132 | 133 | 134 | void WindowBase::mouseMoveEvent(QMouseEvent *event) 135 | { 136 | if((event->buttons()&(Qt::LeftButton)) && m_isPressed == true){ 137 | move(event->globalPos() - m_pressedPoint); 138 | event->accept(); 139 | } 140 | } 141 | 142 | 143 | void WindowBase::keyPressEvent(QKeyEvent *event) 144 | { 145 | if(event->key() == Qt::Key_Escape){ 146 | this->close(); 147 | event->accept(); 148 | } 149 | } 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /QQClient/login/Util/windowbase.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** QQ-Like 实现窗口常用的功能 3 | ****************************************************************************/ 4 | 5 | #ifndef WINDOWBASE_H 6 | #define WINDOWBASE_H 7 | 8 | #include 9 | #include 10 | 11 | class WindowBase : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit WindowBase(QWidget *parent = nullptr); 16 | 17 | protected: 18 | // 绘制窗口的圆角和边框阴影 19 | void paintEventForRoundAndBorder(int roundRadius = 0, int borderWidth = 1); 20 | virtual void paintEvent(QPaintEvent *) override; 21 | 22 | #if 0 23 | // 重写鼠标操作以实现移动窗口 24 | virtual void mousePressEvent(QMouseEvent *event) override; 25 | virtual void mouseReleaseEvent(QMouseEvent *event) override; 26 | virtual void mouseMoveEvent(QMouseEvent *event) override; 27 | 28 | // ESC 按下后关闭窗口 29 | virtual void keyPressEvent(QKeyEvent *event) override; 30 | 31 | #endif 32 | 33 | signals: 34 | 35 | public slots: 36 | void changeBackground(); 37 | 38 | private: 39 | QPoint m_pressedPoint; // for moving window 40 | bool m_isPressed = false; 41 | 42 | qreal m_bkgOpacity; // 下一张背景图的不透明度 43 | qreal m_bkgOpacityInterval; // 每次改变背景图的不透明度 44 | qint8 m_currentBkgIdx; // 当前背景图的索引 45 | bool m_increasing; // 当前背景图的值正在递增 46 | QTimer* m_bkgTimer; // 背景图动画的计时器 47 | 48 | qint8 getNextBkgIdx(); 49 | void paintBackground(qint8 bkgIdx, qreal bkgOpacity); 50 | 51 | const static QString LW_BACKGOUND_PREFIX; // 背景图的前缀 52 | const static quint8 LW_BACKGOUND_NUM; // 背景图数量 53 | }; 54 | 55 | 56 | #endif // WINDOWBASE_H 57 | -------------------------------------------------------------------------------- /QQClient/login/changepasswordwnd.h: -------------------------------------------------------------------------------- 1 | #ifndef FINDPASSWORDWND_H 2 | #define FINDPASSWORDWND_H 3 | 4 | #include "windowbase.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class ChangePasswordWndPrivate : public WindowBase 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | ChangePasswordWndPrivate(QWidget *parent = nullptr); 18 | 19 | signals: 20 | void closeWindow(); 21 | void signalChangePwd(const QJsonValue &jsonVal); 22 | 23 | private: 24 | QLabel* m_notifyMsg; 25 | QPushButton* m_menuCloseBtn; // 菜单栏关闭按钮 26 | QPushButton* m_menuMinBtn; // 菜单栏最小化按钮 27 | QLabel *title; 28 | QLabel *logo; 29 | QLabel *idLabel; 30 | QLabel *oldPasswordLabel; 31 | QLabel *newPasswordLabel; 32 | QLineEdit *idEdit; 33 | QLineEdit *oldPasswordEdit; 34 | QLineEdit *newPasswordEdit; 35 | QPushButton *okBtn; 36 | QPushButton *cancelBtn; 37 | 38 | public slots: 39 | void closeWnd(); 40 | void sltOKBtnClicked(); 41 | void sltChangePwdReply(const QJsonValue &); 42 | }; 43 | 44 | 45 | class ChangePasswordWnd : public QWidget 46 | { 47 | Q_OBJECT 48 | 49 | public: 50 | ChangePasswordWnd(QWidget *parent = nullptr); 51 | 52 | signals: 53 | void closeWindow(QPoint); 54 | void signalChangePwd(const QJsonValue &jsonVal); 55 | 56 | public slots: 57 | void sltChangePwdReply(const QJsonValue &); 58 | void sltCloseWnd(); 59 | 60 | private: 61 | ChangePasswordWndPrivate *mainWnd; 62 | 63 | QPoint m_pressedPoint; // for moving window 64 | bool m_isPressed = false; 65 | 66 | protected: 67 | // 重写鼠标操作以实现移动窗口 68 | virtual void mousePressEvent(QMouseEvent *event) override; 69 | virtual void mouseReleaseEvent(QMouseEvent *event) override; 70 | virtual void mouseMoveEvent(QMouseEvent *event) override; 71 | 72 | }; 73 | 74 | #endif // FINDPASSWORDWND_H 75 | -------------------------------------------------------------------------------- /QQClient/login/iplineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef IPLINEEDIT_H 2 | #define IPLINEEDIT_H 3 | 4 | #include 5 | #include 6 | 7 | class IPLineEdit : public QLineEdit 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | IPLineEdit(QWidget *parent = nullptr); 13 | ~IPLineEdit(); 14 | 15 | void setText(const QString&); 16 | QString getText() const; 17 | 18 | protected: 19 | bool eventFilter(QObject *, QEvent *); 20 | int getIndex(QLineEdit*); 21 | bool isTextValid(const QString&); 22 | 23 | private: 24 | QLineEdit *lineEdit[4]; 25 | }; 26 | 27 | #endif // IPLINEEDIT_H 28 | -------------------------------------------------------------------------------- /QQClient/login/login.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | INCLUDEPATH += $$PWD/LoginWnd $$PWD/Util 4 | 5 | HEADERS += \ 6 | $$PWD/rotatingstackedwidget.h \ 7 | $$PWD/LoginWnd/loginwndloginingpage.h\ 8 | $$PWD/LoginWnd/loginwnd.h \ 9 | $$PWD/LoginWnd/loginwndmainpage.h \ 10 | $$PWD/LoginWnd/loginlineedit.h \ 11 | $$PWD/Util/windowbase.h \ 12 | $$PWD/Util/headlabel.h \ 13 | $$PWD/Util/lineeditex.h \ 14 | $$PWD/Util/checkbox.h \ 15 | $$PWD/Util/clickablelabel.h \ 16 | $$PWD/networksetwnd.h \ 17 | $$PWD/iplineedit.h \ 18 | $$PWD/qiplineedit.h \ 19 | $$PWD/registerwnd.h \ 20 | $$PWD/changepasswordwnd.h 21 | 22 | SOURCES += \ 23 | $$PWD/rotatingstackedwidget.cpp \ 24 | $$PWD/LoginWnd/loginwnd.cpp \ 25 | $$PWD/LoginWnd/loginwndmainpage.cpp \ 26 | $$PWD/LoginWnd/loginlineedit.cpp \ 27 | $$PWD/LoginWnd/loginwndloginingpage.cpp \ 28 | $$PWD/Util/windowbase.cpp \ 29 | $$PWD/Util/headlabel.cpp \ 30 | $$PWD/Util/lineeditex.cpp \ 31 | $$PWD/Util/checkbox.cpp \ 32 | $$PWD/Util/clickablelabel.cpp \ 33 | $$PWD/networksetwnd.cpp \ 34 | $$PWD/iplineedit.cpp \ 35 | $$PWD/qiplineedit.cpp \ 36 | $$PWD/registerwnd.cpp \ 37 | $$PWD/changepasswordwnd.cpp 38 | -------------------------------------------------------------------------------- /QQClient/login/networksetwnd.h: -------------------------------------------------------------------------------- 1 | #ifndef NETWORKSETWND_H 2 | #define NETWORKSETWND_H 3 | 4 | #include "windowbase.h" 5 | #include "iplineedit.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include "qiplineedit.h" 11 | 12 | 13 | class NetWorkSetWnd : public WindowBase 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit NetWorkSetWnd(QWidget *parent = nullptr); 19 | void readConfig(); 20 | void showErrorMsg(QString); 21 | 22 | signals: 23 | void rotateWindow(); 24 | void closeWindow(); 25 | void hideWindow(); 26 | 27 | public slots: 28 | void btnClicked(); 29 | void hideErrorMsg(); 30 | 31 | private: 32 | QPushButton* m_menuCloseBtn; // 菜单栏关闭按钮 33 | QPushButton* m_menuMinBtn; // 菜单栏最小化按钮 34 | QLabel *titleLabel; 35 | QLabel *ipAddrLabel; 36 | QLabel *msgPortLabel; 37 | QLabel *filePortLabel; 38 | //IPLineEdit *ipEdit; 39 | QIPLineEdit *ipEdit; 40 | QLineEdit *msgPortEdit; 41 | QLineEdit *filePortEdit; 42 | QPushButton *cancelBtn; 43 | QPushButton *okBtn; 44 | 45 | QLabel *m_notifyMsg; 46 | }; 47 | 48 | #endif // NETWORKSETWND_H 49 | -------------------------------------------------------------------------------- /QQClient/login/qiplineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef QIPLINEEDIT_H 2 | #define QIPLINEEDIT_H 3 | 4 | #include 5 | #include 6 | 7 | class QLabel; 8 | 9 | class QIPLineEdit : public QLineEdit 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | QIPLineEdit(QWidget *parent = nullptr); 15 | ~QIPLineEdit(); 16 | 17 | void setText(const QString &strIP); 18 | QString getText() const; 19 | 20 | signals: 21 | void textChanged(); 22 | 23 | protected: 24 | bool eventFilter(QObject *obj, QEvent *ev); 25 | 26 | int getIndex(QLineEdit *pEdit); 27 | bool isTextValid(const QString &strIP); 28 | 29 | private: 30 | QLineEdit *m_lineEidt[4]; 31 | }; 32 | 33 | ///////////////////////////////////////////// 34 | class QMacLineEdit : public QLineEdit 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | QMacLineEdit(QWidget *parent = nullptr); 40 | ~QMacLineEdit(); 41 | 42 | void setText(const QString &strMac); 43 | QString text() const; 44 | protected: 45 | // void paintEvent(QPaintEvent *event); 46 | bool eventFilter(QObject *obj, QEvent *ev); 47 | 48 | int getIndex(QLineEdit *pEdit); 49 | bool isTextValid(const QString &strIP); 50 | private: 51 | QLineEdit *m_lineEidt[6]; 52 | }; 53 | 54 | /////////////////////////////////////////////////////////// 55 | /// \brief QIconLineEdit::QIconLineEdit 56 | /// \param parent 57 | /// 带图片的linedit 58 | class QIconLineEdit : public QLineEdit { 59 | Q_OBJECT 60 | public: 61 | QIconLineEdit(QWidget *parent = nullptr); 62 | ~QIconLineEdit(); 63 | 64 | void SetIcon(const QPixmap &pixmap); 65 | private: 66 | QLabel *labelPixmap; 67 | }; 68 | 69 | #endif // QIPLINEEDIT_H 70 | 71 | -------------------------------------------------------------------------------- /QQClient/login/registerwnd.h: -------------------------------------------------------------------------------- 1 | #ifndef REGISTERWND_H 2 | #define REGISTERWND_H 3 | 4 | #include "windowbase.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class RegisterWndPrivate : public WindowBase 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | RegisterWndPrivate(QWidget *parent = nullptr); 18 | 19 | signals: 20 | void closeWindow(); 21 | void signalRegister(const QJsonValue &jsonVal); 22 | 23 | private: 24 | QLabel* m_notifyMsg; 25 | QPushButton* m_menuCloseBtn; // 菜单栏关闭按钮 26 | QPushButton* m_menuMinBtn; // 菜单栏最小化按钮 27 | QLabel *welcome; 28 | QLabel *logo; 29 | QLabel *nameLabel; 30 | QLabel *passwordLabel; 31 | QLineEdit *nameEdit; 32 | QLineEdit *passwordEdit; 33 | QPushButton *okBtn; 34 | QPushButton *cancelBtn; 35 | QLabel *idLabel; 36 | 37 | public slots: 38 | void sltBtnClicked(); 39 | void closeWnd(); 40 | void sltRegisterOK(const QJsonValue&); 41 | }; 42 | 43 | 44 | class RegisterWnd : public QWidget 45 | { 46 | Q_OBJECT 47 | 48 | public: 49 | RegisterWnd(QWidget *parent = nullptr); 50 | 51 | signals: 52 | void closeWindow(QPoint); 53 | void signalRegister(const QJsonValue &jsonVal); 54 | 55 | public slots: 56 | void sltCloseWnd(); 57 | void sltRegisterOK(const QJsonValue&); 58 | 59 | private: 60 | RegisterWndPrivate *mainWnd; 61 | QPoint m_pressedPoint; // for moving window 62 | bool m_isPressed = false; 63 | 64 | protected: 65 | // 重写鼠标操作以实现移动窗口 66 | virtual void mousePressEvent(QMouseEvent *event) override; 67 | virtual void mouseReleaseEvent(QMouseEvent *event) override; 68 | virtual void mouseMoveEvent(QMouseEvent *event) override; 69 | }; 70 | 71 | #endif // REGISTERWND_H 72 | -------------------------------------------------------------------------------- /QQClient/login/rotatingstackedwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ROTATINGSTACKEDWIDGET_H 2 | #define ROTATINGSTACKEDWIDGET_H 3 | 4 | #include "loginwnd.h" 5 | #include "networksetwnd.h" 6 | #include "registerwnd.h" 7 | #include "changepasswordwnd.h" 8 | 9 | #include 10 | #include 11 | 12 | class RotatingStackedWidget : public QStackedWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit RotatingStackedWidget(QWidget *parent = nullptr); 18 | ~RotatingStackedWidget() override; 19 | // 初始化旋转的窗口; 20 | void initRotateWindow(); 21 | 22 | protected: 23 | // 重写鼠标操作以实现移动窗口 24 | virtual void mousePressEvent(QMouseEvent *event) override; 25 | virtual void mouseReleaseEvent(QMouseEvent *event) override; 26 | virtual void mouseMoveEvent(QMouseEvent *event) override; 27 | virtual void paintEvent(QPaintEvent* event) override; 28 | 29 | public slots: 30 | // 开始旋转窗口; 31 | void onRotateWindow(); 32 | // 窗口旋转结束; 33 | void onRotateFinished(); 34 | // 最小化窗口; 35 | void onHideWindow(); 36 | 37 | void sltAutoLogin(); 38 | 39 | void sltOpenRegisterWnd(); 40 | void sltOpenChangePasswordWnd(); 41 | void sltCloseRegisterWnd(QPoint); 42 | void sltCloseFindwordWnd(QPoint); 43 | 44 | private: 45 | // 当前窗口是否正在旋转; 46 | bool m_isRoratingWindow; 47 | LoginWnd *loginWnd; 48 | NetWorkSetWnd *netWorkSetWnd; 49 | int m_nextPageIndex; 50 | 51 | RegisterWnd *registerWnd; 52 | ChangePasswordWnd *changePasswordWnd; 53 | 54 | QPoint m_pressedPoint; // for moving window 55 | bool m_isPressed = false; 56 | }; 57 | 58 | #endif // ROTATINGSTACKEDWIDGET_H 59 | -------------------------------------------------------------------------------- /QQClient/main.cpp: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "myapp.h" 3 | #include "database.h" 4 | #include "rotatingstackedwidget.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | QApplication a(argc, argv); 13 | //a.setQuitOnLastWindowClosed(false); 14 | 15 | QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8")); 16 | 17 | MyApp::initApp(a.applicationDirPath()); 18 | myHelper::setStyle("default"); 19 | 20 | // 加载数据库 21 | DataBase::Instance()->openDb(MyApp::m_strDatabasePath + "user.db"); 22 | 23 | //显示登陆界面 24 | RotatingStackedWidget launcher; 25 | launcher.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /QQClient/mainui.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINUI_H 2 | #define MAINUI_H 3 | 4 | #include "leftbar.h" 5 | #include "midbar.h" 6 | #include "rightbar.h" 7 | #include "clientsocket.h" 8 | #include "settingswnd.h" 9 | 10 | #include 11 | 12 | class MainUI : public QWidget 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit MainUI(QWidget *parent = nullptr); 17 | ~MainUI(); 18 | void setSocket(ClientSocket *,ClientFileSocket*); 19 | void initUI(); 20 | 21 | private: 22 | LeftBar *leftBar; 23 | MidBar *midBar; 24 | RightBar *rightBar; 25 | ClientSocket *tcpSocket; 26 | 27 | ClientFileSocket *globalFileSocket; 28 | 29 | SettingsWnd *settings; 30 | protected: 31 | void paintEvent(QPaintEvent*); 32 | bool nativeEvent(const QByteArray &eventType, void *message, long *result); 33 | 34 | signals: 35 | 36 | public slots: 37 | void onBtnClicked(int); 38 | void stayOnTop(bool); 39 | void sltTcpReply(quint8,QJsonValue); 40 | void sltTcpStatus(quint8); 41 | void sltAddChat(Cell*); 42 | 43 | void parseFriendMessageReply(const QJsonValue &dataVal); 44 | void parseGetGroupMembersReply(const QJsonValue &dataVal); 45 | void parseGroupMessageReply(const QJsonValue &dataVal); 46 | void parseSendFileReply(const QJsonValue &dataVal); 47 | void parseAddFriendReply(const QJsonValue &dataVal); 48 | void parseDeleteFriendReply(const QJsonValue &dataVal); 49 | void parseAddGroupReply(const QJsonValue &dataVal); 50 | void parseDeleteGroupReply(const QJsonValue &dataVal); 51 | void parseAddFriendRequestConfirmed(const QJsonValue &dataVal); 52 | void parseAddGroupRequestConfirmed(const QJsonValue &dataVal); 53 | 54 | void sltFileRecvFinished(quint8,QString,int); 55 | }; 56 | 57 | #endif // MAINUI_H 58 | -------------------------------------------------------------------------------- /QQClient/midbar/addfriendwnd.cpp: -------------------------------------------------------------------------------- 1 | #include "addfriendwnd.h" 2 | #include "myapp.h" 3 | #include "unit.h" 4 | #include "database.h" 5 | #include "global.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | AddFriendWnd::AddFriendWnd(Cell *cell) 12 | { 13 | setFixedSize(400,200); 14 | setWindowFlags(Qt::WindowCloseButtonHint); 15 | 16 | this->cell = cell; 17 | 18 | if(cell->type == Cell_AddFriend) 19 | setWindowTitle("申请添加好友"); 20 | else if(cell->type == Cell_AddGroup) 21 | setWindowTitle("申请加入群:" + QString::number(cell->groupid)); 22 | font = QFont("Microsoft YaHei", 12, 50, false); 23 | headLabel = new RoundLabel(this,cell->iconPath); 24 | headLabel->setFixedSize(80,80); 25 | 26 | idLabel = new QLabel(QString::number(cell->id),this); 27 | idLabel->setFont(font); 28 | nameLabel = new QLabel(cell->name,this); 29 | nameLabel->setFont(font); 30 | 31 | bool tag = cell->done; 32 | 33 | if(tag){ 34 | noticeLabel = new QLabel("已处理该请求",this); 35 | noticeLabel->setFont(font); 36 | noticeLabel->setStyleSheet("color:#0081ef"); 37 | noticeLabel->setGeometry(135,150,200,30); 38 | } 39 | 40 | agreeBtn = new QPushButton("同意",this); 41 | rejectBtn = new QPushButton("拒绝",this); 42 | 43 | headLabel->setGeometry(120,40,80,80); 44 | idLabel->setGeometry(210,45,150,30); 45 | nameLabel->setGeometry(210,85,150,30); 46 | 47 | agreeBtn->setGeometry(290,150,80,30); 48 | agreeBtn->setStyleSheet("QPushButton{border:1px solid #86949e;background-color:#0188fb;border-radius:5px}" 49 | "QPushButton:hover{background-color:#289cff;}" 50 | "QPushButton:pressed{background-color:#0081ef}"); 51 | rejectBtn->setGeometry(190,150,80,30); 52 | rejectBtn->setStyleSheet("QPushButton{border:1px solid #86949e;background-color:#0188fb;border-radius:5px}" 53 | "QPushButton:hover{background-color:#289cff;}" 54 | "QPushButton:pressed{background-color:#0081ef}"); 55 | connect(agreeBtn,SIGNAL(clicked(bool)),this,SLOT(sltBtnClicked())); 56 | connect(rejectBtn,SIGNAL(clicked(bool)),this,SLOT(sltBtnClicked())); 57 | if(tag){ 58 | agreeBtn->setVisible(false); 59 | rejectBtn->setVisible(false); 60 | } 61 | 62 | QPalette palette; 63 | palette.setColor(QPalette::Background, Qt::white); 64 | this->setAutoFillBackground(true); //一定要这句,否则不行 65 | this->setPalette(palette); 66 | } 67 | 68 | void AddFriendWnd::sltBtnClicked() 69 | { 70 | if(sender() == agreeBtn){ 71 | if(cell->type == Cell_AddFriend){ 72 | cell->done = true; 73 | 74 | //更新本地服务器 75 | QSqlQuery query; 76 | query.prepare("INSERT INTO MyFriend (id, name, head, subgroup, tag, lastMsg, lastTime) " 77 | "VALUES (?, ?, ?, ?, ?, ?, ?);"); 78 | query.bindValue(0, cell->id); 79 | query.bindValue(1, cell->name); 80 | query.bindValue(2, cell->iconPath); 81 | query.bindValue(3, "默认分组"); 82 | query.bindValue(4, 0); 83 | query.bindValue(5, ""); 84 | query.bindValue(6, ""); 85 | query.exec(); 86 | 87 | //通知服务器,已同意 88 | QJsonObject json; 89 | json.insert("userID1",cell->id); 90 | json.insert("userID2",MyApp::m_nId); 91 | json.insert("time",QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); 92 | emit signalAddFriend(AddFriendRequist,json); 93 | 94 | //通知中栏添加与该用户的聊天格子 95 | Cell *c = new Cell; 96 | c->type = Cell_FriendChat; 97 | c->id = cell->id; 98 | c->name = cell->name; 99 | c->iconPath = cell->iconPath; 100 | c->isClicked = false; 101 | c->subTitle = QDateTime::currentDateTime().toString("hh:mm:ss"); 102 | c->msg = "你和" + QString::number(c->id) + "已经成为好友了!"; 103 | c->status = OnLine; 104 | emit signalAddChat(c); 105 | 106 | }else if(cell->type == Cell_AddGroup){ 107 | cell->done = true; 108 | 109 | //通知服务器,已同意 110 | QJsonObject json; 111 | json.insert("groupID",cell->groupid); 112 | json.insert("userID",cell->id); 113 | json.insert("time",QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); 114 | emit signalAddFriend(AddGroupRequist,json); 115 | 116 | myHelper::Sleep(100); 117 | 118 | //通知中栏添加与该群的聊天格子(如果已存在则只更新格子) 119 | Cell *c = new Cell; 120 | c->type = Cell_GroupChat; 121 | c->id = cell->groupid;//格子的id为群id 122 | c->name = cell->groupname_; 123 | c->iconPath = cell->groupHead; 124 | c->isClicked = false; 125 | c->subTitle = QDateTime::currentDateTime().toString("hh:mm:ss"); 126 | c->msg = "用户" + QString::number(cell->id) + "已经加入该群"; 127 | c->status = OnLine; 128 | 129 | //用于刷新该群的群员列表 130 | c->newUserID = cell->id; 131 | c->newUserName = cell->name; 132 | c->newUserHead = cell->iconPath; 133 | 134 | emit signalAddChat(c); 135 | } 136 | 137 | agreeBtn->setVisible(false); 138 | rejectBtn->setVisible(false); 139 | 140 | noticeLabel = new QLabel("已同意请求",this); 141 | noticeLabel->setStyleSheet("color:#0081ef"); 142 | noticeLabel->setFont(font); 143 | noticeLabel->setVisible(true); 144 | noticeLabel->setGeometry(150,150,200,30); 145 | }else{ 146 | this->close(); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /QQClient/midbar/addfriendwnd.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDFRIENDWND_H 2 | #define ADDFRIENDWND_H 3 | 4 | #include "cell.h" 5 | #include "roundlabel.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class AddFriendWnd : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | AddFriendWnd(Cell *cell); 17 | 18 | signals: 19 | void signalAddFriend(const quint8 &,const QJsonValue&); 20 | void signalAddChat(Cell*); 21 | 22 | public slots: 23 | void sltBtnClicked(); 24 | 25 | private: 26 | RoundLabel *headLabel; 27 | QLabel *idLabel; 28 | QLabel *nameLabel; 29 | QPushButton *agreeBtn; 30 | QPushButton *rejectBtn; 31 | QLabel *noticeLabel; 32 | QFont font; 33 | 34 | Cell *cell; 35 | }; 36 | 37 | #endif // ADDFRIENDWND_H 38 | -------------------------------------------------------------------------------- /QQClient/midbar/addsubgroup.cpp: -------------------------------------------------------------------------------- 1 | #include "addsubgroup.h" 2 | #include "database.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | AddSubGroup::AddSubGroup() 9 | { 10 | setWindowTitle("新建分组"); 11 | setFixedSize(350,150); 12 | setWindowFlags(Qt::WindowCloseButtonHint); 13 | 14 | QFont font = QFont("Microsoft YaHei", 12, 50, false); 15 | QFont font2 = QFont("Microsoft YaHei", 10, 50, false); 16 | nameLabel = new QLabel("请输入分组名:",this); 17 | nameLabel->setFont(font); 18 | nameEdit = new QLineEdit(this); 19 | nameEdit->setFont(font2); 20 | 21 | okBtn = new QPushButton("确定",this); 22 | okBtn->setStyleSheet("QPushButton{border:1px solid #86949e;background-color:#0188fb;border-radius:5px}" 23 | "QPushButton:hover{background-color:#289cff;}" 24 | "QPushButton:pressed{background-color:#0081ef}"); 25 | connect(okBtn,SIGNAL(clicked(bool)),this,SLOT(sltBtnClicked())); 26 | 27 | cancelBtn = new QPushButton("取消",this); 28 | cancelBtn->setStyleSheet("QPushButton{border:1px solid #86949e;background-color:#0188fb;border-radius:5px}" 29 | "QPushButton:hover{background-color:#289cff;}" 30 | "QPushButton:pressed{background-color:#0081ef}"); 31 | 32 | connect(cancelBtn,SIGNAL(clicked(bool)),this,SLOT(close())); 33 | 34 | nameLabel->setGeometry(20,30,150,30); 35 | nameEdit->setGeometry(150,30,180,30); 36 | okBtn->setGeometry(250,100,80,30); 37 | cancelBtn->setGeometry(150,100,80,30); 38 | 39 | QPalette palette; 40 | palette.setColor(QPalette::Background, Qt::white); 41 | this->setAutoFillBackground(true); 42 | this->setPalette(palette); 43 | } 44 | 45 | void AddSubGroup::sltBtnClicked() 46 | { 47 | QString text = nameEdit->text(); 48 | if(text.size() > 20){ 49 | QMessageBox::information(this,"error","分组名不能多于20个字符!"); 50 | return; 51 | }else { 52 | QJsonArray jsonArray = DataBase::Instance()->getMySubgroup(); 53 | int cnt = jsonArray.size(); 54 | for(int i = 0;i < cnt;i++){ 55 | QJsonObject json = jsonArray.at(i).toObject(); 56 | QString name = json.value("name").toString(); 57 | if(text == name){ 58 | QMessageBox::information(this,"error","分组中已存在该分组名!"); 59 | return; 60 | } 61 | } 62 | 63 | QSqlQuery query; 64 | QString sql = "insert into mySubgroup values('" + text + "','" + 65 | QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") + "')"; 66 | query.exec(sql); 67 | 68 | emit updateList(text); 69 | 70 | this->close(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /QQClient/midbar/addsubgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDSUBGROUP_H 2 | #define ADDSUBGROUP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class AddSubGroup : public QDialog 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | AddSubGroup(); 15 | 16 | signals: 17 | void updateList(QString); 18 | 19 | public slots: 20 | void sltBtnClicked(); 21 | 22 | private: 23 | QLabel *nameLabel; 24 | QLineEdit *nameEdit; 25 | 26 | QPushButton *okBtn; 27 | QPushButton *cancelBtn; 28 | }; 29 | 30 | #endif // ADDSUBGROUP_H 31 | -------------------------------------------------------------------------------- /QQClient/midbar/blankpage.cpp: -------------------------------------------------------------------------------- 1 | #include "blankpage.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef Q_OS_WIN 8 | #pragma comment(lib, "user32.lib") 9 | #include 10 | #endif 11 | 12 | BlankPage::BlankPage(QWidget *parent) : QWidget(parent) 13 | { 14 | setWindowFlag(Qt::FramelessWindowHint); 15 | //#ebeae8 16 | setStyleSheet("border:none;background-color:#ebeae8;"); 17 | QVBoxLayout *layout = new QVBoxLayout(this); 18 | QFont font("Microsoft YaHei", 10, 40, false); 19 | QLabel *label = new QLabel(); 20 | label->setPixmap(QPixmap(":/Icons/MainWindow/blank.png"). 21 | scaled(200,200,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 22 | label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 23 | 24 | QLabel *label2 = new QLabel(tr("打开联系人列表选择好友或者群聊天"),this); 25 | label2->setFont(font); 26 | label2->setFixedSize(300,30); 27 | label2->setStyleSheet("color:#1296db"); 28 | label2->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 29 | 30 | QLabel *label3 = new QLabel(this); 31 | label3->setPixmap(QPixmap(":/Icons/MainWindow/left_arrow.png"). 32 | scaled(30,30,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 33 | label3->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 34 | label3->move(0,115); 35 | 36 | label2->move(25,150); 37 | 38 | layout->setSpacing(5); 39 | layout->setContentsMargins(0,0,0,0); 40 | layout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 41 | 42 | layout->addWidget(label); 43 | } 44 | 45 | void BlankPage::mousePressEvent(QMouseEvent *event) 46 | { 47 | #ifdef Q_OS_WIN 48 | if (ReleaseCapture()){ 49 | QWidget *pWindow = this->window(); 50 | if (pWindow->isTopLevel()){ 51 | SendMessage(HWND(pWindow->winId()), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); 52 | } 53 | } 54 | event->ignore(); 55 | #endif 56 | } 57 | -------------------------------------------------------------------------------- /QQClient/midbar/blankpage.h: -------------------------------------------------------------------------------- 1 | #ifndef BLANKPAGE_H 2 | #define BLANKPAGE_H 3 | 4 | #include 5 | 6 | class BlankPage : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | BlankPage(QWidget *parent = nullptr); 11 | 12 | protected: 13 | // 重写鼠标操作以实现移动窗口 14 | virtual void mousePressEvent(QMouseEvent *event) override; 15 | 16 | signals: 17 | 18 | public slots: 19 | 20 | }; 21 | 22 | #endif // BLANKPAGE_H 23 | -------------------------------------------------------------------------------- /QQClient/midbar/contactwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTACTWIDGET_H 2 | #define CONTACTWIDGET_H 3 | 4 | #include "listwidget.h" 5 | #include "mybutton.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class ContactWidget : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit ContactWidget(QWidget *parent = nullptr); 16 | void InitList(); 17 | void addCell(Cell*); 18 | void deleteFriend(int id); 19 | 20 | private: 21 | ListWidget *friendList; 22 | ListWidget *groupList; 23 | MyButton *friendBtn; 24 | MyButton *groupBtn; 25 | QButtonGroup *btnGroup; 26 | QStackedWidget *stackWidget; 27 | 28 | QHash hash;//通过分组名找到对应的cell抽屉 29 | Cell *popMenuCell = nullptr; 30 | 31 | signals: 32 | void signalSendMessage(const quint8 &, const QJsonValue &); 33 | void openDialog(Cell*); 34 | void deleteChat(int id); 35 | 36 | public slots: 37 | void onFriendDadMenuSelected(QAction*); 38 | void onGroupDadMenuSelected(QAction*); 39 | void onSonMenuSelected(QAction*); 40 | void onSonDoubleClicked(Cell*);//双击好友格子 41 | void onSwitchPage(int); 42 | void setPopMenuCell(Cell*,QMenu*); 43 | void sltUpdateFriendList(QString); 44 | }; 45 | 46 | #endif // CONTACTWIDGET_H 47 | -------------------------------------------------------------------------------- /QQClient/midbar/creategroupwnd.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATEGROUPWND_H 2 | #define CREATEGROUPWND_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class CreateGroupWnd : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | CreateGroupWnd(); 17 | 18 | signals: 19 | void signalCreateGroup(const QJsonValue &jsonVal); 20 | 21 | protected: 22 | // 重写鼠标操作以实现移动窗口 23 | virtual void mousePressEvent(QMouseEvent *event) override; 24 | virtual void mouseReleaseEvent(QMouseEvent *event) override; 25 | virtual void mouseMoveEvent(QMouseEvent *event) override; 26 | 27 | private: 28 | QLabel* m_notifyMsg; 29 | QPushButton* m_menuCloseBtn; // 菜单栏关闭按钮 30 | QPushButton* m_menuMinBtn; // 菜单栏最小化按钮 31 | QLabel *welcome; 32 | QLabel *logo; 33 | QLabel *nameLabel; 34 | QLineEdit *nameEdit; 35 | QPushButton *okBtn; 36 | QPushButton *cancelBtn; 37 | QLabel *idLabel; 38 | 39 | QPoint m_pressedPoint; // for moving window 40 | bool m_isPressed = false; 41 | 42 | public slots: 43 | void sltCreate(); 44 | }; 45 | 46 | 47 | #endif // CREATEGROUPWND_H 48 | -------------------------------------------------------------------------------- /QQClient/midbar/findfriendwnd.h: -------------------------------------------------------------------------------- 1 | #ifndef FINDFRIENDWND_H 2 | #define FINDFRIENDWND_H 3 | 4 | #include "searchbar.h" 5 | #include "roundlabel.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class FindFriendWnd : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | FindFriendWnd(int tag = 0); 17 | 18 | signals: 19 | void signalFind(const QJsonValue&); 20 | void signalSendMessage(const quint8 &, const QJsonValue &); 21 | 22 | public slots: 23 | void sltBtnClicked(); 24 | void sltFindFriendReply(const QJsonValue &); 25 | void sltAddFriend(); 26 | 27 | private: 28 | SearchBar *searchBar; 29 | QLabel *resultLabel; 30 | RoundLabel *headLabel; 31 | QLabel *idLabel; 32 | QLabel *nameLabel; 33 | QLabel *msgLabel; 34 | 35 | QPushButton *addBtn; 36 | 37 | int tag; 38 | int friendID; 39 | }; 40 | 41 | #endif // FINDFRIENDWND_H 42 | -------------------------------------------------------------------------------- /QQClient/midbar/midbar.h: -------------------------------------------------------------------------------- 1 | #ifndef MIDBAR_H 2 | #define MIDBAR_H 3 | 4 | #include "contactwidget.h" 5 | #include "listwidget.h" 6 | #include "blankpage.h" 7 | #include "creategroupwnd.h" 8 | #include "addfriendwnd.h" 9 | 10 | #include 11 | #include 12 | 13 | class MidBar : public QWidget 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit MidBar(QWidget *parent = nullptr); 18 | ~MidBar(); 19 | void SltMainPageChanged(int); 20 | void InitChatList(); 21 | void InitContactList(); 22 | Cell* isIDExist(int id); 23 | void insertCell(Cell *c); 24 | void switchToChatList(); 25 | void addCellToContact(Cell*); 26 | void deleteFriend(int id); 27 | Cell *getSelectedCell(){return selectedCell;} 28 | 29 | protected: 30 | void paintEvent(QPaintEvent *); 31 | 32 | private: 33 | QStackedWidget *mainWidget; 34 | ContactWidget *contactWidget; 35 | ListWidget *chatList; 36 | BlankPage *blankPage; 37 | 38 | CreateGroupWnd *newGroup; 39 | 40 | Cell *popMenuCell = nullptr; 41 | Cell *selectedCell = nullptr;//选中的格子,即如果右边有对话框时,对应中间的格子就是这个,初始化时没有被选中的 42 | 43 | QMenu *addMenu; 44 | 45 | signals: 46 | void openDialog(Cell*); 47 | void signalSendMessage(const quint8 &, const QJsonValue &); 48 | void signalFindFriendReply(const QJsonValue &); 49 | void signalAddChat(Cell*); 50 | void resetRightPage(); 51 | void contactBtnClicked(); 52 | 53 | public slots: 54 | void onSonMenuSelected(QAction*); 55 | void sltOpenDialog(Cell*); 56 | void setPopMenuCell(Cell*,QMenu*); 57 | 58 | void updateTime(int,qint64,QString); 59 | 60 | void sltMenuSelected(QAction*); 61 | 62 | void sltFind(const QJsonValue&); 63 | void sltCreateGroup(const QJsonValue &jsonVal); 64 | 65 | void sltAddFriend(Cell *cell); 66 | 67 | void deleteChatCell(int); 68 | }; 69 | 70 | #endif // MIDBAR_H 71 | -------------------------------------------------------------------------------- /QQClient/midbar/midbar.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | HEADERS += \ 4 | $$PWD/midbar.h \ 5 | $$PWD/contactwidget.h \ 6 | $$PWD/blankpage.h \ 7 | $$PWD/findfriendwnd.h \ 8 | $$PWD/creategroupwnd.h \ 9 | $$PWD/addfriendwnd.h \ 10 | $$PWD/addsubgroup.h 11 | 12 | SOURCES += \ 13 | $$PWD/midbar.cpp \ 14 | $$PWD/contactwidget.cpp \ 15 | $$PWD/blankpage.cpp \ 16 | $$PWD/findfriendwnd.cpp \ 17 | $$PWD/creategroupwnd.cpp \ 18 | $$PWD/addfriendwnd.cpp \ 19 | $$PWD/addsubgroup.cpp -------------------------------------------------------------------------------- /QQClient/qss.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qss/default.css 4 | qss/scrollbar.qss 5 | 6 | 7 | -------------------------------------------------------------------------------- /QQClient/qss/default.css: -------------------------------------------------------------------------------- 1 | *{ font-family: "微软雅黑"; } 2 | 3 | 4 | /*滚动条样式*/ 5 | QScrollBar:horizontal{ 6 | background:#C7E5D6; 7 | padding:0px; 8 | border-radius:6px; 9 | max-height:12px; 10 | } 11 | 12 | QScrollBar::handle:horizontal{ 13 | background:#9FB7AB; 14 | min-width:50px; 15 | border-radius:6px; 16 | } 17 | 18 | QScrollBar::handle:horizontal:hover{ 19 | background:#5F6E66; 20 | } 21 | 22 | QScrollBar::handle:horizontal:pressed{ 23 | background:#5F6E66; 24 | } 25 | 26 | QScrollBar::add-page:horizontal{ 27 | background:none; 28 | } 29 | 30 | QScrollBar::sub-page:horizontal{ 31 | background:none; 32 | } 33 | 34 | QScrollBar::add-line:horizontal{ 35 | background:none; 36 | } 37 | 38 | QScrollBar::sub-line:horizontal{ 39 | background:none; 40 | } 41 | 42 | QScrollBar:vertical{ 43 | background:#ebeae8; 44 | border-radius:6px; 45 | max-width:12px; 46 | margin:0px,0px,0px,0px; 47 | padding:0px; 48 | } 49 | 50 | QScrollBar::handle:vertical{ 51 | background:#cac7c6; 52 | min-height:50px; 53 | max-height:350px; 54 | border-radius:6px; 55 | } 56 | 57 | QScrollBar::handle:vertical:hover{ 58 | background:#b2b1b0; 59 | } 60 | 61 | QScrollBar::handle:vertical:pressed{ 62 | background:#b2b1b0; 63 | } 64 | 65 | QScrollBar::add-page:vertical{ 66 | background:none; 67 | } 68 | 69 | QScrollBar::sub-page:vertical{ 70 | background:none; 71 | } 72 | 73 | QScrollBar::add-line:vertical{ 74 | background:none; 75 | } 76 | 77 | QScrollBar::sub-line:vertical{ 78 | background:none; 79 | } 80 | 81 | QScrollArea{ 82 | border:0px; 83 | } 84 | /*end 滚动条样式 end*/ 85 | 86 | /* 87 | QListView::item:hover{ 88 | background-color:#D9D8D7; 89 | } 90 | 91 | QListWidget::item:selected{ 92 | background:#eceae8; 93 | } 94 | */ 95 | 96 | QListWidget{ 97 | outline:none; 98 | } 99 | 100 | QListWidget:item:hover 101 | { 102 | border: 0px; 103 | } 104 | QListWidget::item:selected { 105 | border: 0px; 106 | } 107 | 108 | QMenu { 109 | background-color: white; /* sets background of the menu 设置整个菜单区域的背景色,我用的是白色:white*/ 110 | border: 1px solid white;/*整个菜单区域的边框粗细、样式、颜色*/ 111 | } 112 | 113 | QMenu::item { 114 | /* sets background of menu item. set this to something non-transparent 115 | if you want menu color and menu item color to be different */ 116 | background-color: transparent; 117 | padding:8px 32px;/*设置菜单项文字上下和左右的内边距,效果就是菜单中的条目左右上下有了间隔*/ 118 | margin:0px 0px;/*设置菜单项的外边距*/ 119 | } 120 | 121 | QMenu::item:selected { /* when user selects item using mouse or keyboard */ 122 | background-color: #e2e2e2;/*这一句是设置菜单项鼠标经过选中的样式*/ 123 | } 124 | 125 | QWidget{ 126 | outline:none; 127 | } 128 | 129 | 130 | -------------------------------------------------------------------------------- /QQClient/qss/scrollbar.qss: -------------------------------------------------------------------------------- 1 | QScrollBar{ 2 | border:none; 3 | background:transparent; /* rgba(0,0,0,0%)*/ 4 | } 5 | QScrollBar:vertical 6 | { 7 | width:8px; 8 | background:transparent; /* rgba(0,0,0,0%)*/ 9 | margin:0px,0px,0px,0px; 10 | padding-top:0px; 11 | padding-bottom:0px; 12 | } 13 | QScrollBar::handle:vertical 14 | { 15 | width:8px; 16 | background:rgba(0,0,0,10%); 17 | border-radius:4px; 18 | min-height:60; 19 | } 20 | QScrollBar::handle:vertical:hover 21 | { 22 | width:8px; 23 | background:rgba(0,0,0,20%); 24 | border-radius:4px; 25 | min-height:60; 26 | } 27 | QScrollBar::add-line:vertical 28 | { 29 | height:0px;width:0px; 30 | subcontrol-position:bottom; 31 | } 32 | QScrollBar::sub-line:vertical 33 | { 34 | height:0px;width:0px; 35 | subcontrol-position:top; 36 | } 37 | QScrollBar::add-line:vertical:hover 38 | { 39 | height:0px;width:0px; 40 | subcontrol-position:bottom; 41 | } 42 | QScrollBar::sub-line:vertical:hover 43 | { 44 | height:0px;width:0px; 45 | subcontrol-position:top; 46 | } 47 | QScrollBar::sub-page:vertical{ 48 | background: none; 49 | } 50 | QScrollBar::add-page:vertical 51 | { 52 | background: none; 53 | } 54 | -------------------------------------------------------------------------------- /QQClient/release/QQ/Data/Conf/config.ini: -------------------------------------------------------------------------------- 1 | [User] 2 | ID=-1 3 | Name= 4 | Passwd= 5 | 6 | [Server] 7 | HostAddr= 8 | MsgPort=0 9 | FilePort=0 10 | GroupPort=0 11 | 12 | [Application] 13 | checked=false 14 | autoLogin=false 15 | sendWay=false 16 | -------------------------------------------------------------------------------- /QQClient/release/QQ/Data/Conf/debug.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/release/QQ/Data/Conf/debug.log -------------------------------------------------------------------------------- /QQClient/release/QQ/Data/Database/user.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/release/QQ/Data/Database/user.db -------------------------------------------------------------------------------- /QQClient/release/QQ/QQ.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/release/QQ/QQ.exe -------------------------------------------------------------------------------- /QQClient/resource/exe.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/exe.ico -------------------------------------------------------------------------------- /QQClient/resource/login_ui/button_login_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/button_login_down.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/button_login_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/button_login_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/button_login_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/button_login_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/checkbox/checkbox_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/checkbox/checkbox_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/checkbox/checkbox_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/checkbox/checkbox_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/checkbox/checkbox_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/checkbox/checkbox_press.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/checkbox/checkbox_tick_highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/checkbox/checkbox_tick_highlight.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/checkbox/checkbox_tick_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/checkbox/checkbox_tick_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/checkbox/checkbox_tick_pushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/checkbox/checkbox_tick_pushed.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/edit_line/edit_frame_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/edit_line/edit_frame_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/edit_line/edit_frame_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/edit_line/edit_frame_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/edit_line/psw_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/edit_line/psw_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/edit_line/psw_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/edit_line/psw_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/edit_line/qqnum_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/edit_line/qqnum_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/edit_line/qqnum_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/edit_line/qqnum_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/head/defalut_head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/head/defalut_head.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/head/head_bkg_highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/head/head_bkg_highlight.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/head/head_bkg_highlight2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/head/head_bkg_highlight2.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/head/head_bkg_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/head/head_bkg_shadow.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/bk_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/bk_shadow.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/bk_shadow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/bk_shadow2.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/img_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/img_0.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/img_1.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/img_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/img_2.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/img_3.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_bkg/img_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/login_bkg/img_4.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/login_ui.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | login_bkg/img_0.png 4 | login_bkg/img_1.png 5 | login_bkg/img_2.png 6 | login_bkg/img_3.png 7 | login_bkg/img_4.png 8 | logo-QQ.png 9 | login_bkg/bk_shadow.png 10 | win_border.png 11 | menu_btn/close_hover.png 12 | menu_btn/close_normal.png 13 | menu_btn/close_press.png 14 | menu_btn/min_hover.png 15 | menu_btn/min_normal.png 16 | menu_btn/min_press.png 17 | menu_btn/set_hover.png 18 | menu_btn/set_normal.png 19 | menu_btn/set_press.png 20 | head/defalut_head.png 21 | head/head_bkg_shadow.png 22 | head/head_bkg_highlight.png 23 | head/head_bkg_highlight2.png 24 | edit_line/edit_frame_hover.png 25 | edit_line/edit_frame_normal.png 26 | edit_line/psw_hover.png 27 | edit_line/psw_normal.png 28 | edit_line/qqnum_hover.png 29 | edit_line/qqnum_normal.png 30 | checkbox/checkbox_hover.png 31 | checkbox/checkbox_normal.png 32 | checkbox/checkbox_press.png 33 | checkbox/checkbox_tick_highlight.png 34 | checkbox/checkbox_tick_normal.png 35 | checkbox/checkbox_tick_pushed.png 36 | button_login_down.png 37 | button_login_hover.png 38 | button_login_normal.png 39 | 40 | 41 | -------------------------------------------------------------------------------- /QQClient/resource/login_ui/logo-QQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/logo-QQ.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/logo-QQ2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/logo-QQ2.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/close_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/close_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/close_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/close_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/close_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/close_press.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/min_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/min_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/min_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/min_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/min_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/min_press.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/set_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/set_hover.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/set_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/set_normal.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/menu_btn/set_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/menu_btn/set_press.png -------------------------------------------------------------------------------- /QQClient/resource/login_ui/win_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQClient/resource/login_ui/win_border.png -------------------------------------------------------------------------------- /QQClient/rightbar/bubble/bubbleinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "bubbleinfo.h" 2 | 3 | BubbleInfo::BubbleInfo() 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /QQClient/rightbar/bubble/bubbleinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef BUBBLEINFO_H 2 | #define BUBBLEINFO_H 3 | 4 | #include "unit.h" 5 | 6 | #include 7 | #include 8 | 9 | typedef enum Sender{ 10 | Me = 0, 11 | You = 1, 12 | System = 2 13 | }Sender; 14 | 15 | class BubbleInfo : public QObject 16 | { 17 | Q_OBJECT 18 | public: 19 | BubbleInfo(); 20 | 21 | Sender sender;//消息发送者 22 | int myID = 0; 23 | int yourID = 0; 24 | int groupID = 0; 25 | int tag = 0;//0表示私聊消息,1表示群聊消息 26 | 27 | QString msg = "";//消息内容 28 | QString name;//发送者的名字 29 | QString headIcon;//头像 30 | 31 | //消息发送的时间戳 qint64 curTime = QDateTime::currentSecsSinceEpoch(); 32 | qint64 time = 0; 33 | 34 | MessageType msgType;//消息的类型,普通文本消息,图片,文件 35 | qint64 fileSize = 0;//文件大小,只有当消息类型为文件时有效 36 | 37 | bool showProgressBar = true;//是否显示进度条 38 | bool showAnimation = true; 39 | bool showDownload = false; 40 | bool showError = false;//删除好友或者群时再发送消息时,消息无法发送,此时显示一个感叹号 41 | 42 | bool downloaded = false;//是否已经下载了 43 | 44 | signals: 45 | void updateProgressBar(qint64,qint64); 46 | void updatePopMenu(); 47 | void hideAnimation(); 48 | }; 49 | 50 | #endif // BUBBLEINFO_H 51 | -------------------------------------------------------------------------------- /QQClient/rightbar/bubble/bubblelist.h: -------------------------------------------------------------------------------- 1 | #ifndef CHATBUBBLE_H 2 | #define CHATBUBBLE_H 3 | 4 | #include "bubbleview.h" 5 | #include "listwidget.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class BubbleList : public QListWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit BubbleList(QWidget *parent = nullptr); 16 | 17 | void insertBubble(BubbleInfo*); 18 | void addBubbleItem(BubbleInfo*); 19 | void refreshList(); 20 | void wapeOut(); 21 | 22 | void msgConfirmed(qint64 time); 23 | 24 | BubbleInfo* findBubble(int senderID,qint64 time); 25 | 26 | private: 27 | QList bubbles; 28 | int oldWidth; 29 | 30 | FloatingScrollBar *scrollBar; 31 | 32 | BubbleInfo *curBubble; 33 | 34 | protected: 35 | void resizeEvent(QResizeEvent *event); 36 | void paintEvent(QPaintEvent *); 37 | void enterEvent(QEvent *); 38 | void leaveEvent(QEvent*); 39 | 40 | signals: 41 | void popMenuToShow(BubbleInfo*,QMenu*); 42 | void signalSendMessage(const quint8 &, const QJsonValue &); 43 | 44 | public slots: 45 | void slt_valueChanged(int); 46 | void onSonMenuSelected(QAction*); 47 | void sltshowPopMenu(BubbleInfo*,QMenu*); 48 | }; 49 | 50 | #endif // CHATBUBBLE_H 51 | -------------------------------------------------------------------------------- /QQClient/rightbar/bubble/bubbleview.h: -------------------------------------------------------------------------------- 1 | #ifndef BUBBLEVIEW_H 2 | #define BUBBLEVIEW_H 3 | 4 | #include "bubbleinfo.h" 5 | #include "mybutton.h" 6 | #include "radiusprogressbar.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | class BubbleView : public QWidget 17 | { 18 | Q_OBJECT 19 | public: 20 | explicit BubbleView(QWidget *parent = nullptr,BubbleInfo* info = nullptr); 21 | 22 | QSize setRect(); 23 | QSize getRealString(QString src); 24 | 25 | void setPopMenu(QMenu *menu){popMenu = menu;} 26 | QString getFileSize(qint64); 27 | 28 | BubbleInfo *info; 29 | 30 | public slots: 31 | void slotupdateProgressBar(qint64,qint64); 32 | void sltUpdatePopMenu(); 33 | void sltHideAnimation(); 34 | 35 | private: 36 | 37 | int height;//整个widget的高度 38 | int textWidth; 39 | int lineHeight; 40 | 41 | QFont textFont; 42 | QFont sysMsgFont;//系统消息字体 43 | 44 | QRect iconRect; 45 | QRect triangleRect;//气泡中的小三角 46 | QRect frameRect; 47 | QRect textRect; 48 | 49 | MyButton *headIcon; 50 | QLabel *loadingLabel; 51 | QMovie *loadingMovie; 52 | 53 | //QProgressBar *progressBar; 54 | RadiusProgressBar *progressBar; 55 | 56 | QLabel *fileNameLabel; 57 | QLabel *fileIconLabel; 58 | QLabel *fileSizeLabel; 59 | QLabel *picture; 60 | QLabel *downloadLabel; 61 | 62 | QLabel *errorLabel; 63 | 64 | QMenu *popMenu; 65 | 66 | protected: 67 | void paintEvent(QPaintEvent*); 68 | void mousePressEvent(QMouseEvent *); 69 | void enterEvent(QEvent *); 70 | void leaveEvent(QEvent *); 71 | 72 | signals: 73 | void mouseRightClicked(BubbleInfo*,QMenu*); 74 | }; 75 | 76 | #endif // BUBBLEVIEW_H 77 | -------------------------------------------------------------------------------- /QQClient/rightbar/bubble/radiusprogressbar.cpp: -------------------------------------------------------------------------------- 1 | #include "radiusprogressbar.h" 2 | #include 3 | #include 4 | 5 | RadiusProgressBar::RadiusProgressBar(QWidget *parent) : QProgressBar(parent) 6 | { 7 | setMinimum(0); 8 | setMaximum(100); 9 | setValue(0); 10 | } 11 | 12 | void RadiusProgressBar::paintEvent(QPaintEvent *) 13 | { 14 | QPainter p(this); 15 | QRect rect = QRect(0, 0, width(), height()/2); 16 | QRect textRect = QRect(0, height()/2, width(), height()/2); 17 | 18 | const double k = (double)(value() - minimum()) / (maximum()-minimum()); 19 | //qDebug() << "sent: " << k << " value:" << value() << " min:" << minimum() << " max:" << maximum(); 20 | 21 | int x = (int)(rect.width() * k); 22 | QRect fillRect = rect.adjusted(0, 0, x-rect.width(), 0); 23 | 24 | QString valueStr; 25 | if(tag == 0) 26 | valueStr = QString("已发送 %1%").arg(QString::number(value())); 27 | else if(tag == 1) 28 | valueStr = QString("已接收 %1%").arg(QString::number(value())); 29 | 30 | QPixmap buttomMap = QPixmap(":/Icons/MainWindow/radius_back.png"); 31 | QPixmap fillMap = QPixmap(":/Icons/MainWindow/radius_front.png"); 32 | 33 | //画进度条 34 | p.drawPixmap(rect, buttomMap); 35 | p.drawPixmap(fillRect, fillMap, fillRect); 36 | 37 | //画文字 38 | QFont f = QFont("Microsoft YaHei", 10, QFont::Bold); 39 | p.setFont(f); 40 | p.setPen(QColor("#555555")); 41 | p.drawText(textRect, Qt::AlignCenter, valueStr); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /QQClient/rightbar/bubble/radiusprogressbar.h: -------------------------------------------------------------------------------- 1 | #ifndef RADIUSPROGRESSBAR_H 2 | #define RADIUSPROGRESSBAR_H 3 | 4 | #include 5 | 6 | class RadiusProgressBar : public QProgressBar 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit RadiusProgressBar(QWidget *parent = nullptr); 11 | void setTag(int tag){this->tag = tag;} 12 | 13 | signals: 14 | 15 | public slots: 16 | 17 | protected: 18 | void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; 19 | 20 | private: 21 | int tag; 22 | }; 23 | 24 | #endif // RADIUSPROGRESSBAR_H 25 | -------------------------------------------------------------------------------- /QQClient/rightbar/chatwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef CHATWINDOW_H 2 | #define CHATWINDOW_H 3 | 4 | #include "mybutton.h" 5 | #include "bubblelist.h" 6 | #include "listwidget.h" 7 | #include "inputwidget.h" 8 | #include "clientsocket.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | class TopBar : public QWidget{ 16 | Q_OBJECT 17 | public: 18 | explicit TopBar(QWidget *parent = nullptr); 19 | 20 | QLabel *nameLabel; 21 | MyButton *listBtn; 22 | 23 | protected: 24 | virtual void paintEvent(QPaintEvent *) override; 25 | 26 | // 重写鼠标操作以实现移动窗口 27 | virtual void mousePressEvent(QMouseEvent *event) override; 28 | }; 29 | 30 | 31 | class GroupList : public QWidget 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit GroupList(QWidget *parent = nullptr); 36 | QLabel *groupListLabel; 37 | ListWidget *memberList; 38 | 39 | void paintEvent(QPaintEvent *); 40 | }; 41 | 42 | 43 | class ChatWindow : public QWidget 44 | { 45 | Q_OBJECT 46 | public: 47 | explicit ChatWindow(QWidget *parent = nullptr,Cell *cell = nullptr); 48 | 49 | void setCell(Cell *c){cell = c;} 50 | int getID(){return cell->id;} 51 | void InitGroupList(); 52 | void sendTimeMsg(qint64 time, QString msg);//更新中栏格子时间并且更新消息内容 53 | void setTag(int tag){ this->tag = tag;tcpFileSocket->setTag(tag); } 54 | void refreshGroupList(QJsonValue &dataVal); 55 | void addCellToGroupList(Cell *); 56 | void removeCellFromGroupList(int id); 57 | void forbidSendMsg(); 58 | void allowSendMsg(); 59 | void addSystemMsg(QString msg); 60 | void msgReceived(QJsonValue &value);//接收服务器转发过来的消息,并在界面上显示出来 61 | void writeMsgToDatabase(BubbleInfo*);//把消息写入本地数据库 62 | void loadMsgFromDatabase();//从数据库中加载聊天记录 63 | void startLoadingAnimation(); 64 | 65 | TopBar *topBar; 66 | BubbleList *msgWindow; 67 | InputWidget *inputWindow; 68 | GroupList *groupList; 69 | 70 | QLabel *loadingLabel; 71 | QMovie *loadingMovie; 72 | 73 | private: 74 | bool open = true; 75 | Cell *cell;//记录该聊天窗口对方的信息 76 | int tag = 0;//记录该聊天窗口是私聊窗口还是群聊窗口,tag = 0为私聊窗口,tag = 1为群聊窗口 77 | 78 | qint64 lastMsgTime = 0; 79 | 80 | //文件传输 81 | ClientFileSocket *tcpFileSocket; 82 | QString fileName; 83 | QTime updateTime; 84 | quint8 fileType; 85 | bool busy = false; 86 | BubbleInfo *curFileBubble; 87 | 88 | signals: 89 | void signalSendMessage(const quint8 &type, const QJsonValue &json);//发消息给服务器 90 | void updateMidBarTime(int id,qint64 time,QString msg);//更新中栏对应格子的时间 91 | 92 | public slots: 93 | void sendMsg();//发送消息 94 | void onSonMenuSelected(QAction*); 95 | void stopLoadingAnimation(); 96 | 97 | //文件传输 98 | void sltSendFileFinished(quint8,QString); 99 | void sltRecvFileFinished(quint8,QString,int); 100 | void sltUpdateProgress(qint64 bytes,qint64 total); 101 | void sltFileArrived(const QJsonValue&); 102 | }; 103 | 104 | #endif // CHATWINDOW_H 105 | -------------------------------------------------------------------------------- /QQClient/rightbar/defaultpage.cpp: -------------------------------------------------------------------------------- 1 | #include "defaultpage.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef Q_OS_WIN 8 | #pragma comment(lib, "user32.lib") 9 | #include 10 | #endif 11 | 12 | DefaultPage::DefaultPage(QWidget *parent) : QWidget(parent) 13 | { 14 | setWindowFlag(Qt::FramelessWindowHint); 15 | setStyleSheet("border:none;background-color:#F0F0F0;"); 16 | QVBoxLayout *layout = new QVBoxLayout(this); 17 | QFont font("Microsoft YaHei", 15, 40, false); 18 | QFont font2("Microsoft YaHei", 10, 10, false); 19 | 20 | QLabel *label = new QLabel(); 21 | label->setPixmap(QPixmap(":/Icons/MainWindow/title.png")); 22 | label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 23 | 24 | QLabel *label2 = new QLabel(tr("打开世界的另一扇窗")); 25 | label2->setFont(font); 26 | label2->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 27 | 28 | QLabel *label3 = new QLabel(tr("主动一点,世界会更大")); 29 | label3->setFont(font2); 30 | label3->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 31 | 32 | layout->setSpacing(5); 33 | layout->setContentsMargins(0,0,0,0); 34 | layout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 35 | layout->addStretch(2); 36 | layout->addWidget(label); 37 | layout->addSpacing(30); 38 | layout->addWidget(label2); 39 | layout->addWidget(label3); 40 | layout->addStretch(3); 41 | } 42 | 43 | void DefaultPage::mousePressEvent(QMouseEvent *event) 44 | { 45 | #ifdef Q_OS_WIN 46 | if (ReleaseCapture()){ 47 | QWidget *pWindow = this->window(); 48 | if (pWindow->isTopLevel()){ 49 | SendMessage(HWND(pWindow->winId()), WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); 50 | } 51 | } 52 | event->ignore(); 53 | #endif 54 | } 55 | -------------------------------------------------------------------------------- /QQClient/rightbar/defaultpage.h: -------------------------------------------------------------------------------- 1 | #ifndef DEFAULTPAGE_H 2 | #define DEFAULTPAGE_H 3 | 4 | #include 5 | 6 | class DefaultPage : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit DefaultPage(QWidget *parent = nullptr); 11 | 12 | protected: 13 | void mousePressEvent(QMouseEvent *event); 14 | 15 | signals: 16 | 17 | public slots: 18 | }; 19 | 20 | #endif // DEFAULTPAGE_H 21 | -------------------------------------------------------------------------------- /QQClient/rightbar/inputwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef INPUTWIDGET_H 2 | #define INPUTWIDGET_H 3 | 4 | #include "mybutton.h" 5 | #include "mytextedit.h" 6 | 7 | #include 8 | #include 9 | 10 | class InputWidget : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit InputWidget(QWidget *parent = nullptr); 15 | 16 | MyButton *picture; 17 | MyButton *file; 18 | MyButton *screenshot; 19 | MyButton *emoji; 20 | QPushButton *sendBtn; 21 | QPushButton *actionBtn; 22 | MyTextEdit *textEdit; 23 | 24 | void paintEvent(QPaintEvent *); 25 | 26 | signals: 27 | 28 | public slots: 29 | void changeColor(); 30 | void restoreColor(); 31 | void saveSendWay(QAction *); 32 | }; 33 | 34 | #endif // INPUTWIDGET_H 35 | -------------------------------------------------------------------------------- /QQClient/rightbar/mytextedit.cpp: -------------------------------------------------------------------------------- 1 | #include "mytextedit.h" 2 | #include "myapp.h" 3 | 4 | #include 5 | 6 | MyTextEdit::MyTextEdit(QWidget *parent): 7 | QTextEdit(parent) 8 | { 9 | 10 | } 11 | 12 | 13 | void MyTextEdit::mousePressEvent(QMouseEvent *e) 14 | { 15 | emit mousePressed(); 16 | return QTextEdit::mousePressEvent(e); 17 | } 18 | 19 | void MyTextEdit::focusOutEvent(QFocusEvent *e) 20 | { 21 | emit focusOut(); 22 | return QTextEdit::focusOutEvent(e); 23 | } 24 | 25 | void MyTextEdit::keyPressEvent(QKeyEvent *e) 26 | { 27 | if(MyApp::sendWay){//按enter发送 28 | if(e->key() == Qt::Key_Return){ 29 | emit sendMsg(); 30 | }else{ 31 | return QTextEdit::keyPressEvent(e); 32 | } 33 | }else{ 34 | if(e->key() == Qt::Key_Return && e->modifiers() == Qt::ControlModifier) 35 | emit sendMsg(); 36 | return QTextEdit::keyPressEvent(e); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /QQClient/rightbar/mytextedit.h: -------------------------------------------------------------------------------- 1 | #ifndef MYTEXTEDIT_H 2 | #define MYTEXTEDIT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class MyTextEdit : public QTextEdit 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | MyTextEdit(QWidget *parent = nullptr); 14 | 15 | signals: 16 | void mousePressed(); 17 | void focusOut(); 18 | void sendMsg(); 19 | 20 | protected: 21 | 22 | void mousePressEvent(QMouseEvent*); 23 | void focusOutEvent(QFocusEvent *); 24 | void keyPressEvent(QKeyEvent*); 25 | }; 26 | 27 | #endif // MYTEXTEDIT_H 28 | -------------------------------------------------------------------------------- /QQClient/rightbar/rightbar.h: -------------------------------------------------------------------------------- 1 | #ifndef BASEWIDGET_H 2 | #define BASEWIDGET_H 3 | 4 | #include "titlebar.h" 5 | #include "chatwindow.h" 6 | #include "clientsocket.h" 7 | #include "defaultpage.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | class RightBar : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | RightBar(QWidget *parent = nullptr); 21 | ~RightBar(); 22 | 23 | QStackedWidget *stackWidget; 24 | ChatWindow *defaultWindow; 25 | void switchPage(Cell *); 26 | void msgconfirmed(QJsonValue dataVal);//这是服务器回的确认收到本机发出去的消息, 27 | void msgReceived(Cell *c,QJsonValue dataVal);//这是服务器转发给我的消息,是我的好友或者群发给我的消息 28 | void refreshGroupList(QJsonValue dataVal); 29 | void addNewUserToGroupList(int groupID,Cell *newUser);//新用户入群 30 | void removeUserFromGroupList(int groupID,int userID);//用户退群 31 | 32 | void resetPage(); 33 | void restorePage(); 34 | void setTitleText(QString text){this->titleBar->setTitleText(text);} 35 | void setCurrentPage(int page){currentPage = page;} 36 | void forbidSendMsg(int id); 37 | void allowSendMsg(int id); 38 | void startLoadingAnimation(); 39 | void stopLoadingAnimation(); 40 | 41 | signals: 42 | void stayOnTop(bool); 43 | void signalSendMessage(const quint8 &, const QJsonValue &); 44 | void updateMidBarTime(int id,qint64 time,QString msg); 45 | 46 | private: 47 | TitleBar *titleBar; 48 | 49 | DefaultPage *defaultPage; 50 | QList chatWindowList; 51 | QHash hash;//用户对应id到聊天窗口的映射 52 | int cnt = 1; 53 | int currentPage = 0; 54 | ClientSocket *tcpSocket; 55 | 56 | QLabel *loadingLabel; 57 | QMovie *loadingMovie; 58 | 59 | public slots: 60 | 61 | }; 62 | 63 | #endif // BASEWIDGET_H 64 | -------------------------------------------------------------------------------- /QQClient/rightbar/rightbar.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | INCLUDEPATH += $$PWD/bubble 4 | 5 | HEADERS += \ 6 | $$PWD/chatwindow.h \ 7 | $$PWD/inputwidget.h \ 8 | $$PWD/mytextedit.h \ 9 | $$PWD/rightbar.h \ 10 | $$PWD/bubble/bubbleinfo.h \ 11 | $$PWD/bubble/bubbleview.h \ 12 | $$PWD/bubble/bubblelist.h \ 13 | $$PWD/defaultpage.h \ 14 | $$PWD/bubble/radiusprogressbar.h 15 | 16 | SOURCES += \ 17 | $$PWD/chatwindow.cpp \ 18 | $$PWD/inputwidget.cpp \ 19 | $$PWD/mytextedit.cpp \ 20 | $$PWD/rightbar.cpp \ 21 | $$PWD/bubble/bubbleinfo.cpp \ 22 | $$PWD/bubble/bubbleview.cpp \ 23 | $$PWD/bubble/bubblelist.cpp \ 24 | $$PWD/defaultpage.cpp \ 25 | $$PWD/bubble/radiusprogressbar.cpp -------------------------------------------------------------------------------- /QQClient/settingswnd.cpp: -------------------------------------------------------------------------------- 1 | #include "settingswnd.h" 2 | #include "titlebar.h" 3 | #include "myapp.h" 4 | 5 | #include 6 | 7 | SettingsWnd::SettingsWnd(QWidget *parent) : QWidget(parent) 8 | { 9 | setFixedSize(700,500); 10 | setWindowFlags(Qt::WindowCloseButtonHint); 11 | //this->setAttribute(Qt::WA_DeleteOnClose); 12 | setWindowTitle("设置"); 13 | setStyleSheet("background-color:white"); 14 | 15 | QFont font = QFont("Microsoft YaHei", 15, 50, false); 16 | autoLoginLabel = new QLabel("自动登陆",this); 17 | autoLoginLabel->setFont(font); 18 | autoLoginLabel->setGeometry(40,40,100,30); 19 | autoLoginCheckBox = new QCheckBox(this); 20 | autoLoginCheckBox->setGeometry(150,43,30,30); 21 | 22 | bool checked = MyApp::autoLogin; 23 | autoLoginCheckBox->setChecked(checked); 24 | 25 | connect(autoLoginCheckBox,SIGNAL(stateChanged(int)), 26 | this,SLOT(setAutoLogin(int))); 27 | } 28 | 29 | void SettingsWnd::setAutoLogin(int state) 30 | { 31 | qDebug() << "check state:" << state; 32 | MyApp::autoLogin = state; 33 | MyApp::saveConfig(); 34 | } 35 | -------------------------------------------------------------------------------- /QQClient/settingswnd.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGSWND_H 2 | #define SETTINGSWND_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class SettingsWnd : public QWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit SettingsWnd(QWidget *parent = nullptr); 13 | 14 | signals: 15 | 16 | public slots: 17 | void setAutoLogin(int); 18 | 19 | private: 20 | QLabel *autoLoginLabel; 21 | QCheckBox *autoLoginCheckBox; 22 | }; 23 | 24 | #endif // SETTINGSWND_H 25 | -------------------------------------------------------------------------------- /QQClient/titlebar/titlebar.h: -------------------------------------------------------------------------------- 1 | #ifndef TITLEBAR_H 2 | #define TITLEBAR_H 3 | 4 | 5 | #include 6 | #include "titlebutton.h" 7 | 8 | class QLabel; 9 | class QPushButton; 10 | 11 | class TitleBar : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit TitleBar(QWidget *parent = nullptr,int tag = 2);//tag == 0左边,tag == 1中间,tag == 2右边 17 | ~TitleBar(); 18 | void setTitleText(QString text); 19 | 20 | signals: 21 | void stayOnTop(bool); 22 | 23 | protected: 24 | 25 | // 双击标题栏进行界面的最大化/还原 26 | virtual void mouseDoubleClickEvent(QMouseEvent *event); 27 | 28 | // 进行鼠界面的拖动 29 | virtual void mousePressEvent(QMouseEvent *event); 30 | 31 | // 设置界面标题与图标 32 | virtual bool eventFilter(QObject *obj, QEvent *event); 33 | 34 | private slots: 35 | 36 | // 进行最小化、最大化/还原、关闭操作 37 | void onClicked(); 38 | 39 | private: 40 | 41 | // 最大化/还原 42 | void updateMaximize(); 43 | 44 | private: 45 | QLabel *iconLabel; 46 | QLabel *titleLabel; 47 | TitleButton *topBtn; 48 | TitleButton *minBtn; 49 | TitleButton *maxBtn; 50 | TitleButton *closeBtn; 51 | 52 | int barHeight; 53 | int tag; 54 | bool isOnTop = false; 55 | }; 56 | 57 | 58 | #endif // TITLEBAR_H 59 | -------------------------------------------------------------------------------- /QQClient/titlebar/titlebar.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | 3 | HEADERS += \ 4 | $$PWD/titlebar.h \ 5 | $$PWD/titlebutton.h \ 6 | 7 | 8 | SOURCES += \ 9 | $$PWD/titlebar.cpp \ 10 | $$PWD/titlebutton.cpp \ -------------------------------------------------------------------------------- /QQClient/titlebar/titlebutton.cpp: -------------------------------------------------------------------------------- 1 | #include "titlebutton.h" 2 | #include 3 | 4 | TitleButton::TitleButton(QWidget *parent,int tag,QString iconName) 5 | :QPushButton (parent),tag(tag) 6 | { 7 | setFixedSize(40, 30); 8 | setIcon(QPixmap(iconName).scaled(15,15,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 9 | setFlat(true); 10 | setStyleSheet("border:none"); 11 | } 12 | 13 | TitleButton::~TitleButton() 14 | { 15 | 16 | } 17 | 18 | void TitleButton::enterEvent(QEvent *) 19 | { 20 | if(tag == 0){ 21 | setFlat(false); 22 | setStyleSheet("QPushButton{background-color:rgb(232,17,35);border:none}"); 23 | setIcon(QPixmap(":/Icons/MainWindow/close2.png"). 24 | scaled(15,15,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 25 | }else if(tag == 1){ 26 | setFlat(false); 27 | setStyleSheet("QPushButton{background-color:rgb(200,200,200);border:none}"); 28 | } 29 | setCursor(Qt::PointingHandCursor); 30 | } 31 | 32 | void TitleButton::leaveEvent(QEvent *e) 33 | { 34 | 35 | setFlat(true); 36 | setStyleSheet("QPushButton{background-color:rgb(242,242,242);border:none}"); 37 | setCursor(Qt::ArrowCursor); 38 | 39 | if(tag == 0) 40 | setIcon(QPixmap(":/Icons/MainWindow/close.png"). 41 | scaled(15,15,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); 42 | 43 | return QPushButton::leaveEvent(e); 44 | } 45 | -------------------------------------------------------------------------------- /QQClient/titlebar/titlebutton.h: -------------------------------------------------------------------------------- 1 | #ifndef TITLEBUTTON_H 2 | #define TITLEBUTTON_H 3 | 4 | #include 5 | #include 6 | 7 | class TitleButton : public QPushButton 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | TitleButton(QWidget *parent = nullptr,int tag = 0,QString iconName = ""); 13 | ~TitleButton(); 14 | void enterEvent(QEvent*); 15 | void leaveEvent(QEvent*); 16 | 17 | private: 18 | int tag; 19 | }; 20 | 21 | 22 | 23 | #endif // TITLEBUTTON_H 24 | -------------------------------------------------------------------------------- /QQServer/QQServer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-05-07T17:54:01 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui sql network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QQServer 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | mainui.cpp \ 30 | database.cpp \ 31 | tcpserver.cpp \ 32 | clientsocket.cpp \ 33 | myapp.cpp 34 | 35 | HEADERS += \ 36 | mainui.h \ 37 | database.h \ 38 | tcpserver.h \ 39 | clientsocket.h \ 40 | global.h \ 41 | unit.h \ 42 | myapp.h 43 | 44 | # Default rules for deployment. 45 | qnx: target.path = /tmp/$${TARGET}/bin 46 | else: unix:!android: target.path = /opt/$${TARGET}/bin 47 | !isEmpty(target.path): INSTALLS += target 48 | 49 | 50 | RC_ICONS = server.ico #exe图标文件 51 | 52 | DESTDIR = $$PWD/release/QQServer 53 | -------------------------------------------------------------------------------- /QQServer/clientsocket.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENTSOCKET_H 2 | #define CLIENTSOCKET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | class ClientSocket : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit ClientSocket(QObject *parent = nullptr, QTcpSocket *tcpSocket = nullptr); 17 | ~ClientSocket(); 18 | 19 | int getUserID() const; 20 | void close(); 21 | QString getClientInfo(){ 22 | return QString("") + "ip:" + QHostAddress( tcpSocket->peerAddress().toIPv4Address() ).toString() 23 | + " port:" + QString::number(tcpSocket->peerPort()) ; 24 | } 25 | 26 | signals: 27 | void signalConnected(); 28 | void signalDisConnected(); 29 | void signalDownloadFile(const QJsonValue &json); 30 | void signalMsgToClient(const quint8 &type, const int &reveicerID, const QJsonValue &dataVal); 31 | 32 | private: 33 | QTcpSocket *tcpSocket; 34 | int ID; 35 | 36 | public slots: 37 | //消息回发 38 | void sltSendMessage(const quint8 &type, const QJsonValue &json); 39 | 40 | private slots: 41 | void sltConnected(); 42 | void sltDisconnected(); 43 | void sltReadyRead(); 44 | 45 | private: 46 | // 消息解析和转发处理 47 | void parseLogin(const QJsonValue &dataVal); 48 | void parseLogout(const QJsonValue &dataVal); 49 | void parseUserOnline(const QJsonValue &dataVal); 50 | void parseUpdateUserHead(const QJsonValue &dataVal); 51 | 52 | void parseReister(const QJsonValue &dataVal); 53 | 54 | void parseAddFriend(const QJsonValue &dataVal); 55 | void parseDeleteFriend(const QJsonValue &dataVal); 56 | void parseAddFriendReply(const QJsonValue &dataVal); 57 | 58 | void parseAddGroup(const QJsonValue &dataVal); 59 | void parseDeleteGroup(const QJsonValue &dataVal); 60 | void parseAddGroupReply(const QJsonValue &dataVal); 61 | void parseCreateGroup(const QJsonValue &dataVal); 62 | 63 | void parseGetMyFriend(const QJsonValue &dataVal); 64 | void parseGetMyGroups(const QJsonValue &dataVal); 65 | void parseGetGroupMembers(const QJsonValue &dataVal); 66 | 67 | void parseRefreshFriend(const QJsonValue &dataVal); 68 | void parseRefreshGroups(const QJsonValue &dataVal); 69 | 70 | void parseFriendMessages(const QByteArray &reply); 71 | void parseGroupMessages(const QByteArray &reply); 72 | 73 | void parseSendPicture(const QJsonValue &dataVal); 74 | void parseChangePwd(const QJsonValue &dataVal); 75 | void parseFindFriend(const QJsonValue &dataVal); 76 | 77 | void parseGetOfflineMsg(const QJsonValue &dataVal); 78 | }; 79 | 80 | 81 | //-------------------------------------------- 82 | 83 | 84 | class ClientFileSocket : public QObject 85 | { 86 | Q_OBJECT 87 | 88 | public: 89 | explicit ClientFileSocket(QObject *parent = nullptr, QTcpSocket *tcpSocket = nullptr); 90 | ~ClientFileSocket(); 91 | 92 | void close(); 93 | bool checkUserID(const qint32 nId, const qint32 &winId); 94 | QString getClientInfo(){ 95 | return QString("") + "ip:" + QHostAddress( tcpSocket->peerAddress().toIPv4Address() ).toString() 96 | + " port:" + QString::number(tcpSocket->peerPort()) ; 97 | } 98 | 99 | // 文件传输完成 100 | void fileTransFinished(); 101 | void startTransferFile(QString fileName,int senderID, qint64 time,int flag = 0); 102 | void insertDataBase(QString filepath,QString filename); 103 | 104 | signals: 105 | void signalConnected(); 106 | void signalDisConnected(); 107 | void signalRecvFinished(int id, const QJsonValue &json); 108 | void signalMsgToClient(const quint8 &type, const int &reveicerID, const QJsonValue &dataVal); 109 | 110 | void signalDownloadFile(const QJsonValue &json); 111 | 112 | private: 113 | /************* Receive file *******************/ 114 | quint64 loadSize; 115 | quint64 bytesReceived; //已收到数据的大小 116 | quint64 fileNameSize; //文件名的大小信息 117 | QString fileReadName; //存放文件名 118 | QString filesavepath; //存放文件的保存路径 119 | QByteArray inBlock; //数据缓冲区 120 | quint64 ullRecvTotalBytes; //数据总大小 121 | QFile *fileToRecv; //要发送的文件 122 | 123 | QTcpSocket *tcpSocket; 124 | 125 | /************* send file *******************/ 126 | quint16 blockSize; //存放接收到的信息大小 127 | QFile *fileToSend; //要发送的文件 128 | quint64 ullSendTotalBytes; //数据总大小 129 | quint64 bytesWritten; //已经发送数据大小 130 | quint64 bytesToWrite; //剩余数据大小 131 | QByteArray outBlock; //数据缓冲区,即存放每次要发送的数据 132 | 133 | 134 | bool busy; 135 | 136 | // 需要转发的用户id,即发送文件的用户ID 137 | qint32 userID; 138 | // 当前用户的窗口好友的id,即需要接收文件的用户ID 139 | qint32 windowID; 140 | 141 | qint32 tag;//标记聊天双方是私聊还是群聊,tag=0表示私聊,tag=1表示群聊 142 | qint64 msgSendTime; 143 | 144 | private: 145 | void initSocket(); 146 | 147 | public slots: 148 | 149 | private slots: 150 | void displayError(QAbstractSocket::SocketError); // 显示错误 151 | // 文件接收 152 | void sltReadyRead(); 153 | // 发送 154 | void sltUpdateClientProgress(qint64 numBytes); 155 | }; 156 | 157 | 158 | #endif // CLIENTSOCKET_H 159 | -------------------------------------------------------------------------------- /QQServer/database.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASE_H 2 | #define DATABASE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class DataBase : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit DataBase(QObject *parent = nullptr); 15 | ~DataBase(); 16 | 17 | bool openDb(const QString &dataName); 18 | void closeDb(); 19 | 20 | // 单实例 21 | static DataBase *Instance() 22 | { 23 | static QMutex mutex; 24 | if (self == nullptr) { 25 | QMutexLocker locker(&mutex); 26 | 27 | if (!self) { 28 | self = new DataBase(); 29 | } 30 | } 31 | return self; 32 | } 33 | 34 | // 更新用户状态/上下线 35 | void updateUserStatus(const int &id, const quint8 &status); 36 | void updateUserHead(const int &id, const QString &strHead); 37 | void testHeadPic(const int &id, const QString &name, const QString &strHead); 38 | 39 | // 获取用户状态 40 | QJsonArray getAllUsers(); 41 | QJsonObject getUserStatus(const int &id) const; 42 | int getUserLineStatus(const int &id) const; 43 | 44 | // 用户校验 45 | QJsonObject checkUserLogin(const int &id, const QString &passwd); 46 | // 注册用户 47 | int registerUser(QString name, QString pwd); 48 | 49 | // 添加好友 50 | QJsonObject addFriend(const QString &name); 51 | 52 | // 添加群组 53 | QJsonObject addGroup(const int &userId, const QString &name); 54 | // 创建群组 55 | QJsonObject createGroup(const int &adminID, const QString &name, qint64 time); 56 | // 查询当前群组下面的好友 57 | QJsonArray getGroupUsers(const int &groupId); 58 | 59 | // 查询文件发送历史,获取要发送的文件在服务器上的完整地址 60 | QString getSentFile(int senderID,int receiverID,qint64 time); 61 | 62 | // 服务器启动的时候更新下所以人员的状态,可以不要 63 | void changeAllUserStatus(); 64 | 65 | // 查询当前id的名字 66 | QString getUserName(const int &id) const; 67 | QString getUserHead(const int &id) const; 68 | QJsonObject getUserInfo(const int &id) const; 69 | QJsonObject getGroupInfo(const int &id) const; 70 | 71 | int getGroupAdmin(int groupid); 72 | 73 | QJsonObject changePwd(int id,QString oldpwd,QString newpwd); 74 | 75 | //获取离线消息 76 | QJsonArray getOfflineMsg(int id); 77 | 78 | signals: 79 | 80 | private: 81 | static DataBase *self; 82 | QSqlDatabase userdb; 83 | void queryAll(); 84 | 85 | public slots: 86 | }; 87 | 88 | #endif // DATABASE_H 89 | -------------------------------------------------------------------------------- /QQServer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainui.h" 2 | #include "myapp.h" 3 | #include "database.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | QApplication a(argc, argv); 17 | 18 | qDebug() << "服务器启动..." << endl; 19 | 20 | //初始化程序 21 | MyApp::InitApp(a.applicationDirPath()); 22 | qDebug() << "初始化路径完毕,当前路径为:" << a.applicationDirPath(); 23 | 24 | // 加载数据库 25 | DataBase::Instance()->openDb(MyApp::m_strDatabasePath + "server.db"); 26 | 27 | //显示主界面 28 | MainUI w; 29 | //w.show(); 30 | 31 | return a.exec(); 32 | } 33 | -------------------------------------------------------------------------------- /QQServer/mainui.cpp: -------------------------------------------------------------------------------- 1 | #include "mainui.h" 2 | 3 | #include 4 | 5 | MainUI::MainUI(QWidget *parent) 6 | : QWidget(parent) 7 | { 8 | InitNetwork(); 9 | } 10 | 11 | MainUI::~MainUI() 12 | { 13 | 14 | } 15 | 16 | void MainUI::InitNetwork() 17 | { 18 | tcpMsgServer = new TcpMsgServer(this); 19 | bool ok = tcpMsgServer->startListen(60100); 20 | if(ok){ 21 | qDebug() << "消息服务器监听成功,端口: 60100"; 22 | }else{ 23 | qDebug() << "消息服务器监听失败"; 24 | } 25 | 26 | tcpFileServer = new TcpFileServer(this); 27 | ok = tcpFileServer->startListen(60101); 28 | if(ok){ 29 | qDebug() << "文件服务器监听成功,端口: 60101"; 30 | }else{ 31 | qDebug() << "文件服务器监听失败"; 32 | } 33 | 34 | qDebug() << "--------------------------------------------------------------------" << endl; 35 | 36 | connect(tcpMsgServer, SIGNAL(signalDownloadFile(QJsonValue)), tcpFileServer, SLOT(sltClientDownloadFile(QJsonValue))); 37 | connect(tcpMsgServer, SIGNAL(signalUserStatus(QString)), this, SLOT(showUserStatus(QString))); 38 | 39 | connect(tcpFileServer, SIGNAL(signalUserStatus(QString)), this, SLOT(showUserStatus(QString))); 40 | connect(tcpFileServer,SIGNAL(signalMsgToClient(const quint8 &, const int &, const QJsonValue &)), 41 | tcpMsgServer,SLOT(sltMsgToClient(quint8,int,QJsonValue))); 42 | } 43 | 44 | void MainUI::showUserStatus(QString str) 45 | { 46 | qDebug() << str << endl 47 | << "......................................................" << endl; 48 | } 49 | -------------------------------------------------------------------------------- /QQServer/mainui.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINUI_H 2 | #define MAINUI_H 3 | 4 | #include "tcpserver.h" 5 | #include "database.h" 6 | #include "myapp.h" 7 | #include "global.h" 8 | #include "unit.h" 9 | 10 | #include 11 | 12 | class MainUI : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | MainUI(QWidget *parent = nullptr); 18 | ~MainUI(); 19 | 20 | private: 21 | TcpMsgServer *tcpMsgServer; 22 | TcpFileServer *tcpFileServer; 23 | 24 | void InitNetwork(); 25 | 26 | public slots: 27 | void showUserStatus(QString); 28 | }; 29 | 30 | #endif // MAINUI_H 31 | -------------------------------------------------------------------------------- /QQServer/myapp.cpp: -------------------------------------------------------------------------------- 1 | #include "myapp.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | QString MyApp::m_strAppPath = "./"; // 应用程序路径,即exe文件所在目录 12 | QString MyApp::m_strDataPath = ""; // 数据保存路径 13 | QString MyApp::m_strDatabasePath = ""; // 数据库目录 14 | QString MyApp::m_strConfPath = ""; // 配置目录 15 | QString MyApp::m_strBackupPath = ""; 16 | QString MyApp::m_strRecvPath = ""; 17 | QString MyApp::m_strHeadPath = ""; 18 | 19 | QString MyApp::m_strIniFile = "config.ini"; // 配置文件 20 | QString MyApp::m_strUserName = "admin"; 21 | QString MyApp::m_strPassword = "123456"; 22 | 23 | int MyApp::m_nId = -1; 24 | int MyApp::m_nIdentyfi = -1; 25 | 26 | // 初始化 27 | void MyApp::InitApp(const QString &appPath) 28 | { 29 | m_strAppPath = appPath + "/"; 30 | m_strDataPath = m_strAppPath + "Data/"; 31 | m_strDatabasePath = m_strDataPath + "Database/"; 32 | m_strConfPath = m_strDataPath + "Conf/"; 33 | m_strBackupPath = m_strDataPath + "Backup/"; 34 | m_strRecvPath = m_strDataPath + "Files/"; 35 | m_strHeadPath = m_strDataPath + "Head/"; 36 | m_strIniFile = m_strConfPath + "config.ini"; 37 | 38 | // 检查目录 39 | CheckDirs(); 40 | 41 | // 创建配置文件 42 | CreateSettingFile(); 43 | 44 | // 加载系统配置 45 | ReadSettingFile(); 46 | } 47 | 48 | void MyApp::CreateSettingFile() { 49 | // 写入配置文件 50 | QSettings settings(m_strIniFile, QSettings::IniFormat); 51 | QString strGroups = settings.childGroups().join(""); 52 | if (!QFile::exists(m_strIniFile) || (strGroups.isEmpty())) 53 | { 54 | 55 | /*系统设置*/ 56 | settings.beginGroup("UserCfg"); 57 | settings.setValue("User", m_strUserName); 58 | settings.setValue("Passwd", m_strPassword); 59 | settings.endGroup(); 60 | settings.sync(); 61 | 62 | } 63 | #ifdef Q_WS_QWS 64 | QProcess::execute("sync"); 65 | #endif 66 | } 67 | 68 | void MyApp::ReadSettingFile() 69 | { 70 | QSettings settings(m_strIniFile, QSettings::IniFormat); 71 | settings.beginGroup("UserCfg"); 72 | m_strUserName = settings.value("User", "admin").toString(); 73 | m_strPassword = settings.value("Passwd", "123456") .toString(); 74 | settings.endGroup(); 75 | } 76 | 77 | void MyApp::SetSettingFile(const QString &group, const QString &key, const QVariant &value) 78 | { 79 | QSettings settings(m_strIniFile, QSettings::IniFormat); 80 | settings.beginGroup(group); 81 | settings.setValue(key, value); 82 | settings.sync(); 83 | } 84 | 85 | QVariant MyApp::GetSettingKeyValue(const QString &group, const QString &key, const QVariant &value) 86 | { 87 | QSettings settings(m_strIniFile, QSettings::IniFormat); 88 | settings.beginGroup(group); 89 | return settings.value(key, value); 90 | } 91 | 92 | void MyApp::CheckDirs() 93 | { 94 | // 数据文件夹 95 | QDir dir(m_strDataPath); 96 | if (!dir.exists()) { 97 | dir.mkdir(m_strDataPath); 98 | #ifdef Q_WS_QWS 99 | QProcess::execute("sync"); 100 | #endif 101 | } 102 | 103 | // 数据库目录 104 | dir.setPath(m_strDatabasePath); 105 | if (!dir.exists()) { 106 | dir.mkdir(m_strDatabasePath); 107 | #ifdef Q_WS_QWS 108 | QProcess::execute("sync"); 109 | #endif 110 | } 111 | 112 | // 备份文件目录 113 | dir.setPath(m_strBackupPath); 114 | if (!dir.exists()) { 115 | dir.mkdir(m_strBackupPath); 116 | #ifdef Q_WS_QWS 117 | QProcess::execute("sync"); 118 | #endif 119 | } 120 | 121 | // 服务器文件目录 122 | dir.setPath(m_strRecvPath); 123 | if (!dir.exists()) { 124 | dir.mkdir(m_strRecvPath); 125 | #ifdef Q_WS_QWS 126 | QProcess::execute("sync"); 127 | #endif 128 | } 129 | 130 | // 头像目录 131 | dir.setPath(m_strHeadPath); 132 | if (!dir.exists()) { 133 | dir.mkdir(m_strHeadPath); 134 | #ifdef Q_WS_QWS 135 | QProcess::execute("sync"); 136 | #endif 137 | } 138 | } 139 | 140 | void MyApp::SaveConfig() 141 | { 142 | QSettings settings(m_strIniFile, QSettings::IniFormat); 143 | 144 | /*系统设置*/ 145 | settings.beginGroup("UserCfg"); 146 | settings.setValue("User", m_strUserName); 147 | settings.setValue("Passwd", m_strPassword); 148 | settings.endGroup(); 149 | 150 | settings.sync(); 151 | } 152 | 153 | void MyApp::createDir(QString path) 154 | { 155 | QDir dir(path); 156 | if (!dir.exists()) { 157 | dir.mkdir(path); 158 | #ifdef Q_WS_QWS 159 | QProcess::execute("sync"); 160 | #endif 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /QQServer/myapp.h: -------------------------------------------------------------------------------- 1 | #ifndef MYAPP_H 2 | #define MYAPP_H 3 | 4 | #include 5 | 6 | #if 0 7 | typedef enum { 8 | Administrator = 0x01, 9 | Mangager, 10 | Worker 11 | } E_IDENTITY; 12 | #endif 13 | 14 | class QApplication; 15 | 16 | class MyApp 17 | { 18 | public: 19 | //=======================系统配置部分=========================// 20 | static QString m_strAppPath; // 应用程序路径 21 | static QString m_strDataPath; // 数据保存路径 22 | static QString m_strDatabasePath; // 数据库目录 23 | static QString m_strConfPath; // 配置目录 24 | static QString m_strBackupPath; // 配置目录 25 | static QString m_strRecvPath; // 文件接收保存目录 26 | static QString m_strHeadPath; // 用户头像目录 27 | 28 | static QString m_strIniFile; // 配置文件 29 | 30 | static QString m_strUserName; // 用户名 31 | static QString m_strPassword; // 用户密码 32 | 33 | static int m_nId; 34 | static int m_nIdentyfi; 35 | 36 | //=======================函数功能部分=========================// 37 | // 初始化 38 | static void InitApp(const QString &appPath); 39 | // 创建配置文件 40 | static void CreateSettingFile(); 41 | // 读配置文件,加载系统配置 42 | static void ReadSettingFile(); 43 | 44 | // 读取/修改配置文件 45 | static void SetSettingFile(const QString &group, const QString &key, const QVariant &value); 46 | static QVariant GetSettingKeyValue(const QString &group, const QString &key, const QVariant &value); 47 | // 检查目录 48 | static void CheckDirs(); 49 | 50 | static void SaveConfig(); 51 | 52 | static void createDir(QString path); 53 | }; 54 | 55 | #endif // MYAPP_H 56 | -------------------------------------------------------------------------------- /QQServer/server.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/QQServer/server.ico -------------------------------------------------------------------------------- /QQServer/tcpserver.h: -------------------------------------------------------------------------------- 1 | #ifndef TCPSERVER_H 2 | #define TCPSERVER_H 3 | 4 | #include "clientsocket.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | class TcpServer : public QObject 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit TcpServer(QObject *parent = nullptr); 19 | ~TcpServer(); 20 | 21 | bool startListen(int port = 6666); 22 | void closeListen(); 23 | 24 | signals: 25 | void signalUserStatus(const QString &); 26 | 27 | protected: 28 | QTcpServer *tcpServer; 29 | 30 | public slots: 31 | virtual void sltNewConnection() = 0; 32 | virtual void sltConnected() = 0; 33 | virtual void sltDisConnected() = 0; 34 | }; 35 | 36 | 37 | class TcpMsgServer : public TcpServer 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit TcpMsgServer(QObject *parent = nullptr); 42 | ~TcpMsgServer(); 43 | 44 | signals: 45 | void signalDownloadFile(const QJsonValue &json); 46 | 47 | private: 48 | // 客户端管理 49 | QVector clients; 50 | 51 | public slots: 52 | void sltTransFileToClient(const int &userId, const QJsonValue &json); 53 | 54 | private slots: 55 | void sltNewConnection(); 56 | void sltConnected(); 57 | void sltDisConnected(); 58 | void sltMsgToClient(const quint8 &type, const int &id, const QJsonValue &json); 59 | }; 60 | 61 | 62 | class TcpFileServer : public TcpServer { 63 | Q_OBJECT 64 | 65 | public : 66 | explicit TcpFileServer(QObject *parent = nullptr); 67 | ~TcpFileServer(); 68 | 69 | signals: 70 | void signalRecvFinished(int id, const QJsonValue &json); 71 | void signalMsgToClient(const quint8 &, const int &, const QJsonValue &); 72 | 73 | private: 74 | // 客户端管理 75 | QVector clients; 76 | 77 | private slots: 78 | void sltNewConnection(); 79 | void sltConnected(); 80 | void sltDisConnected(); 81 | void sltClientDownloadFile(const QJsonValue &json); 82 | }; 83 | 84 | 85 | #endif // TCPSERVER_H 86 | -------------------------------------------------------------------------------- /Screenshots/20201223_163945.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/20201223_163945.gif -------------------------------------------------------------------------------- /Screenshots/MainUI.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/MainUI.jpg -------------------------------------------------------------------------------- /Screenshots/Snipaste_2019-05-24_21-39-31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2019-05-24_21-39-31.jpg -------------------------------------------------------------------------------- /Screenshots/Snipaste_2019-05-27_10-33-01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2019-05-27_10-33-01.jpg -------------------------------------------------------------------------------- /Screenshots/Snipaste_2019-06-09_10-57-21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2019-06-09_10-57-21.jpg -------------------------------------------------------------------------------- /Screenshots/Snipaste_2020-12-23_16-29-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2020-12-23_16-29-54.png -------------------------------------------------------------------------------- /Screenshots/Snipaste_2020-12-23_16-33-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2020-12-23_16-33-15.png -------------------------------------------------------------------------------- /Screenshots/Snipaste_2020-12-23_17-06-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2020-12-23_17-06-39.png -------------------------------------------------------------------------------- /Screenshots/Snipaste_2020-12-23_17-14-09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/Snipaste_2020-12-23_17-14-09.png -------------------------------------------------------------------------------- /Screenshots/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/add.png -------------------------------------------------------------------------------- /Screenshots/database1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database1.png -------------------------------------------------------------------------------- /Screenshots/database10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database10.png -------------------------------------------------------------------------------- /Screenshots/database2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database2.png -------------------------------------------------------------------------------- /Screenshots/database3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database3.png -------------------------------------------------------------------------------- /Screenshots/database4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database4.png -------------------------------------------------------------------------------- /Screenshots/database5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database5.png -------------------------------------------------------------------------------- /Screenshots/database6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database6.png -------------------------------------------------------------------------------- /Screenshots/database7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database7.png -------------------------------------------------------------------------------- /Screenshots/database8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database8.png -------------------------------------------------------------------------------- /Screenshots/database9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/database9.png -------------------------------------------------------------------------------- /Screenshots/fold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/fold.png -------------------------------------------------------------------------------- /Screenshots/friends_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/friends_list.png -------------------------------------------------------------------------------- /Screenshots/group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/group.png -------------------------------------------------------------------------------- /Screenshots/unfold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nullxjx/QQ/554d11d19131025b02817dc775aa86e252b1bae2/Screenshots/unfold.png --------------------------------------------------------------------------------