├── VictorClient ├── id集合.txt ├── victoricon2.ico └── WePlatform │ ├── image │ ├── QQ.png │ ├── boy.png │ ├── id.png │ ├── wxx.png │ ├── yun.png │ ├── chat.png │ ├── close.png │ ├── close2.png │ ├── cuowu.png │ ├── dizhi.png │ ├── fanhui.png │ ├── girl.png │ ├── haoyou.png │ ├── lishi.png │ ├── mima.png │ ├── more.png │ ├── more2.png │ ├── qqqq.png │ ├── riqi.png │ ├── shezhi.png │ ├── yonghu.png │ ├── Simpson.jpg │ ├── biaoqing.png │ ├── dongtai.png │ ├── minimum.png │ ├── minimum2.png │ ├── shezhi2.png │ ├── tianjia.png │ ├── tianjia2.png │ ├── wenjian.png │ ├── yonghu2.png │ ├── WeCloudIcon.png │ ├── addfriend.png │ ├── background.jpg │ ├── background2.png │ ├── background3.jpg │ ├── background4.jpg │ ├── victoricon.png │ ├── victoricon2.png │ └── WeCloudIcon2.png │ ├── touxiang │ ├── dog.jpg │ ├── pig.jpg │ ├── tom.jpg │ ├── beizi.jpg │ ├── girl.jpg │ ├── girl2.jpg │ ├── girl3.jpg │ ├── girl4.jpg │ ├── panda.jpg │ ├── yazi.jpg │ ├── Simpson.jpg │ ├── icebear.jpg │ ├── shuaya.jpg │ ├── xiaoxin.jpg │ ├── blownbear.jpg │ ├── duolaameng.jpg │ ├── fenhongbao.jpg │ ├── haimianbob.jpg │ ├── paidaxing.jpg │ └── xiaowanzi.jpg │ ├── loginlose.cpp │ ├── loginlose.h │ ├── tabwidget.h │ ├── main.cpp │ ├── database.h │ ├── pwback.h │ ├── listwidget.h │ ├── listwidget2.h │ ├── changepw.h │ ├── regist.h │ ├── login.h │ ├── tabwidget.cpp │ ├── pwback.cpp │ ├── setting.h │ ├── qnchatmessage.h │ ├── addfrd.h │ ├── WePlatform.pro │ ├── listwidget.cpp │ ├── listwidget2.cpp │ ├── inform.h │ ├── image.qrc │ ├── loginlose.ui │ ├── changepw.cpp │ ├── pwback.ui │ ├── database.cpp │ ├── mainwindow.h │ ├── regist.cpp │ ├── login.cpp │ ├── changepw.ui │ ├── setting.cpp │ ├── login.ui │ ├── qnchatmessage.cpp │ └── regist.ui ├── VictorServer ├── qtsingleapplication │ ├── QtLockedFile │ ├── QtSingleApplication │ ├── qtsinglecoreapplication.pri │ ├── qtsingleapplication.pri │ ├── README.TXT │ ├── qtsinglecoreapplication.h │ ├── qtlocalpeer.h │ ├── qtlockedfile.h │ ├── qtlockedfile_unix.cpp │ ├── qtsingleapplication.h │ ├── qtsinglecoreapplication.cpp │ ├── qtlockedfile.cpp │ ├── qtlockedfile_win.cpp │ ├── qtlocalpeer.cpp │ └── INSTALL.TXT ├── main.cpp ├── tcpserver.h ├── mysocket.h ├── mysocket.cpp ├── .gitignore ├── LICENSE ├── serverthread.h ├── tcpserver.cpp ├── VictorServer.pro ├── serverthread.cpp ├── qtserver.h ├── qtserver.ui └── qtserver.cpp ├── screenshoot ├── chat.png ├── login.png ├── server.png ├── addFriend.png ├── register.png └── mainwindow.png └── README.md /VictorClient/id集合.txt: -------------------------------------------------------------------------------- 1 | 41 2 | 8963 3 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/QtLockedFile: -------------------------------------------------------------------------------- 1 | #include "qtlockedfile.h" 2 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/QtSingleApplication: -------------------------------------------------------------------------------- 1 | #include "qtsingleapplication.h" 2 | -------------------------------------------------------------------------------- /screenshoot/chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/screenshoot/chat.png -------------------------------------------------------------------------------- /screenshoot/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/screenshoot/login.png -------------------------------------------------------------------------------- /screenshoot/server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/screenshoot/server.png -------------------------------------------------------------------------------- /screenshoot/addFriend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/screenshoot/addFriend.png -------------------------------------------------------------------------------- /screenshoot/register.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/screenshoot/register.png -------------------------------------------------------------------------------- /screenshoot/mainwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/screenshoot/mainwindow.png -------------------------------------------------------------------------------- /VictorClient/victoricon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/victoricon2.ico -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/QQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/QQ.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/boy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/boy.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/id.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/id.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/wxx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/wxx.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/yun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/yun.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/chat.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/close.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/close2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/close2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/cuowu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/cuowu.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/dizhi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/dizhi.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/fanhui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/fanhui.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/girl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/girl.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/haoyou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/haoyou.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/lishi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/lishi.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/mima.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/mima.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/more.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/more2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/more2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/qqqq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/qqqq.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/riqi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/riqi.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/shezhi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/shezhi.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/yonghu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/yonghu.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/dog.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/pig.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/pig.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/tom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/tom.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/Simpson.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/Simpson.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/biaoqing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/biaoqing.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/dongtai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/dongtai.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/minimum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/minimum.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/minimum2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/minimum2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/shezhi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/shezhi2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/tianjia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/tianjia.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/tianjia2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/tianjia2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/wenjian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/wenjian.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/yonghu2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/yonghu2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/beizi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/beizi.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/girl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/girl.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/girl2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/girl2.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/girl3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/girl3.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/girl4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/girl4.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/panda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/panda.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/yazi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/yazi.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/WeCloudIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/WeCloudIcon.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/addfriend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/addfriend.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/background.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/background2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/background2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/background3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/background3.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/background4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/background4.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/victoricon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/victoricon.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/victoricon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/victoricon2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/Simpson.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/Simpson.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/icebear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/icebear.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/shuaya.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/shuaya.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/xiaoxin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/xiaoxin.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/image/WeCloudIcon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/image/WeCloudIcon2.png -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/blownbear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/blownbear.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/duolaameng.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/duolaameng.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/fenhongbao.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/fenhongbao.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/haimianbob.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/haimianbob.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/paidaxing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/paidaxing.jpg -------------------------------------------------------------------------------- /VictorClient/WePlatform/touxiang/xiaowanzi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WQ-Vincent/InstantMessenger/HEAD/VictorClient/WePlatform/touxiang/xiaowanzi.jpg -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtsinglecoreapplication.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h 4 | SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp 5 | 6 | QT *= network 7 | 8 | win32:contains(TEMPLATE, lib):contains(CONFIG, shared) { 9 | DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport) 10 | } 11 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/loginlose.cpp: -------------------------------------------------------------------------------- 1 | #include "loginlose.h" 2 | #include "ui_loginlose.h" 3 | #include "pwback.h" 4 | 5 | loginlose::loginlose(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::loginlose) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | loginlose::~loginlose() 13 | { 14 | delete ui; 15 | } 16 | 17 | void loginlose::on_pushButton_clicked() 18 | { 19 | pwback a; 20 | a.exec(); 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 聊天软件 Victor 2 | 3 | 作者:[WQ-Vincent](https://www.cnblogs.com/wqvincent/), 4 | 这是一款基于 QtCreater 开发的即时通讯软件,借用了QQ,微信的一些元素。目前支持局域网聊天。**screenshoot中有软件运行的部分截图**。持续填坑中。 5 | 6 | **供大家学习参考,觉得不错的点个星星吧!** 7 | 8 | --- 9 | 10 | ## 如何使用 11 | 12 | **Qt运行环境**:本项目是 Qt 工程项目,需要Qt C++的运行环境,没有的同学去官网下载。本人是 4.10 Community版本。 13 | 14 | **开始**:分别打开Server和Client中的.pro文件,QT构建运行,构建后的文件夹和项目文件放在一起。**一定要先运行Server,再运行Client。不然客户端之间是不能通讯的!** 15 | 16 | --- 17 | 18 | 更新于 2021.08.02 19 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/loginlose.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGINLOSE_H 2 | #define LOGINLOSE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class loginlose; 8 | } 9 | 10 | class loginlose : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit loginlose(QWidget *parent = nullptr); 16 | ~loginlose(); 17 | 18 | private slots: 19 | void on_pushButton_clicked(); 20 | 21 | private: 22 | Ui::loginlose *ui; 23 | }; 24 | 25 | #endif // LOGINLOSE_H 26 | -------------------------------------------------------------------------------- /VictorServer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "qtserver.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QtSingleApplication a("myapp_id",argc, argv); 9 | if(a.isRunning()) //判断实例是否已经运行 10 | { 11 | qDebug()<<"this is already running"; 12 | a.sendMessage("raise_window_noop", 2000); //4s后激活前个实例 13 | return EXIT_SUCCESS; 14 | } 15 | QtServer w; 16 | a.setActivationWindow(&w,1); 17 | w.show(); 18 | return a.exec(); 19 | } 20 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/tabwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TABWIDGET_H 2 | #define TABWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | class TabBar: public QTabBar 12 | { 13 | public: 14 | QSize tabSizeHint(int index) const; 15 | protected: 16 | void paintEvent(QPaintEvent *); 17 | }; 18 | 19 | class tabwidget : public QTabWidget 20 | { 21 | public: 22 | 23 | tabwidget(QWidget *parent=nullptr); 24 | }; 25 | 26 | #endif // TABWIDGET_H 27 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "login.h" 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | DataBase d; 9 | d.createConnection(); 10 | d.createTable1(); 11 | d.createTable2(); 12 | d.createTable3(); 13 | d.createTable4(); 14 | d.createTable6(); 15 | MainWindow w; 16 | w.show(); 17 | if(w.ifopen==false)w.close(); 18 | MainWindow g; 19 | g.show(); 20 | if(g.ifopen==false)g.close(); 21 | return a.exec(); //程序一直执行,直到主窗口关闭 22 | } 23 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/database.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASE_H 2 | #define DATABASE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class DataBase 14 | { 15 | public: 16 | bool createConnection(); //创建一个连接 17 | bool createTable1(); //创建数据库表 18 | bool createTable2(); 19 | bool createTable3(); 20 | bool createTable4(); 21 | //bool createTable5(); 22 | bool createTable6(); 23 | }; 24 | 25 | #endif // DATABASE_H 26 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/pwback.h: -------------------------------------------------------------------------------- 1 | #ifndef PWBACK_H 2 | #define PWBACK_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class pwback; 8 | } 9 | 10 | class pwback : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit pwback(QWidget *parent = nullptr); 16 | ~pwback(); 17 | private slots: 18 | void mousePressEvent(QMouseEvent *event); 19 | 20 | void mouseMoveEvent(QMouseEvent *event); 21 | 22 | void mouseReleaseEvent(QMouseEvent *event); 23 | 24 | private: 25 | bool m_pressed; 26 | QPoint m_movePos; 27 | Ui::pwback *ui; 28 | }; 29 | 30 | #endif // PWBACK_H 31 | -------------------------------------------------------------------------------- /VictorServer/tcpserver.h: -------------------------------------------------------------------------------- 1 | #ifndef TCPSERVER_H 2 | #define TCPSERVER_H 3 | #include 4 | #include 5 | #include 6 | #include "serverthread.h" 7 | #include "qtserver.h" 8 | class QtServer; 9 | class TcpServer:public QTcpServer 10 | { 11 | Q_OBJECT 12 | public: 13 | 14 | explicit TcpServer(QObject *parent = Q_NULLPTR); 15 | 16 | ~TcpServer(); 17 | 18 | private: 19 | 20 | void incomingConnection(int sockDesc); 21 | 22 | private slots: 23 | 24 | void clientDisconnected(int sockDesc); 25 | 26 | private: 27 | 28 | QtServer *m_dialog; 29 | 30 | QList m_socketList; 31 | }; 32 | 33 | #endif // TCPSERVER_H 34 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/listwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTWIDGET_H 2 | #define LISTWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class alistwidget : public QListWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit alistwidget(QWidget *parent=nullptr); 13 | QString frdid; 14 | QPushButton *action1=new QPushButton; 15 | QPushButton *action2=new QPushButton; 16 | QPushButton *action3=new QPushButton; 17 | public slots: 18 | void actionone(); 19 | void actiontwo(); 20 | private slots: 21 | void contextMenuEvent ( QContextMenuEvent * event ); 22 | void mousePressEvent (QMouseEvent * event ); 23 | }; 24 | 25 | #endif // LISTWIDGET_H 26 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/listwidget2.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTWIDGET2_H 2 | #define LISTWIDGET2_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class listwidget2 : public QListWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit listwidget2(QWidget *parent=nullptr); 13 | QString frdid; 14 | QPushButton *action1=new QPushButton; 15 | QPushButton *action2=new QPushButton; 16 | QPushButton *action3=new QPushButton; 17 | public slots: 18 | void actionone(); 19 | void actiontwo(); 20 | private slots: 21 | void contextMenuEvent ( QContextMenuEvent * event ); 22 | void mousePressEvent (QMouseEvent * event ); 23 | }; 24 | 25 | #endif // LISTWIDGET2_H 26 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtsingleapplication.pri: -------------------------------------------------------------------------------- 1 | #include(../common.pri) 2 | INCLUDEPATH += $$PWD 3 | DEPENDPATH += $$PWD 4 | QT *= network 5 | greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets 6 | 7 | qtsingleapplication-uselib:!qtsingleapplication-buildlib { 8 | LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME 9 | } else { 10 | SOURCES += $$PWD/qtsingleapplication.cpp 11 | HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h 12 | } 13 | 14 | win32 { 15 | contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT 16 | else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT 17 | } 18 | 19 | SOURCES += \ 20 | $$PWD/qtlocalpeer.cpp 21 | -------------------------------------------------------------------------------- /VictorServer/mysocket.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSOCKET_H 2 | 3 | #define MYSOCKET_H 4 | 5 | 6 | 7 | #include 8 | 9 | #include 10 | 11 | 12 | 13 | #include 14 | 15 | 16 | 17 | class MySocket : public QTcpSocket 18 | 19 | { 20 | 21 | Q_OBJECT 22 | 23 | public: 24 | 25 | explicit MySocket(int sockDesc, QObject *parent = Q_NULLPTR); 26 | 27 | ~MySocket(); 28 | 29 | 30 | 31 | signals: 32 | 33 | void dataReady(const QString &ip, const QByteArray &data); 34 | 35 | 36 | 37 | public slots: 38 | 39 | void recvData(void); 40 | 41 | void sendData(int id, const QByteArray &data); 42 | 43 | 44 | 45 | private: 46 | 47 | int m_sockDesc; 48 | 49 | }; 50 | 51 | 52 | 53 | #endif // MYSOCKET_H 54 | -------------------------------------------------------------------------------- /VictorServer/mysocket.cpp: -------------------------------------------------------------------------------- 1 | #include "mysocket.h" 2 | 3 | 4 | 5 | MySocket::MySocket(int sockDesc, QObject *parent) : 6 | 7 | QTcpSocket(parent) 8 | 9 | { 10 | m_sockDesc=sockDesc; 11 | connect(this, SIGNAL(readyRead()), this, SLOT(recvData())); 12 | 13 | } 14 | 15 | 16 | 17 | MySocket::~MySocket() 18 | 19 | { 20 | 21 | 22 | 23 | } 24 | 25 | 26 | 27 | void MySocket::sendData(int id, const QByteArray &data) 28 | 29 | { 30 | if (id == m_sockDesc && !data.isEmpty()) 31 | { 32 | 33 | this->write(data); 34 | 35 | } 36 | 37 | } 38 | 39 | 40 | 41 | void MySocket::recvData(void) 42 | 43 | { 44 | 45 | QString ip = peerAddress().toString().remove(0, 7); 46 | 47 | QByteArray data = readAll(); 48 | 49 | 50 | 51 | emit dataReady(ip, data); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /VictorServer/.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.so.* 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | object_script.*.Release 15 | object_script.*.Debug 16 | *_plugin_import.cpp 17 | /.qmake.cache 18 | /.qmake.stash 19 | *.pro.user 20 | *.pro.user.* 21 | *.qbs.user 22 | *.qbs.user.* 23 | *.moc 24 | moc_*.cpp 25 | moc_*.h 26 | qrc_*.cpp 27 | ui_*.h 28 | *.qmlc 29 | *.jsc 30 | Makefile* 31 | *build-* 32 | *.qm 33 | *.prl 34 | 35 | # Qt unit tests 36 | target_wrapper.* 37 | 38 | # QtCreator 39 | *.autosave 40 | 41 | # QtCreator Qml 42 | *.qmlproject.user 43 | *.qmlproject.user.* 44 | 45 | # QtCreator CMake 46 | CMakeLists.txt.user* 47 | 48 | # QtCreator 4.8< compilation database 49 | compile_commands.json 50 | 51 | # QtCreator local machine specific files for imported projects 52 | *creator.user* 53 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/changepw.h: -------------------------------------------------------------------------------- 1 | #ifndef CHANGEPW_H 2 | #define CHANGEPW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class changepw; 8 | } 9 | 10 | class changepw : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit changepw(QWidget *parent = nullptr); 16 | ~changepw(); 17 | 18 | int ifchange; 19 | 20 | private slots: 21 | void mousePressEvent(QMouseEvent *event); 22 | 23 | void mouseMoveEvent(QMouseEvent *event); 24 | 25 | void mouseReleaseEvent(QMouseEvent *event); 26 | 27 | void on_pushButton_clicked(); 28 | 29 | void on_lineEdit_editingFinished(); 30 | 31 | void on_lineEdit_2_editingFinished(); 32 | 33 | void on_lineEdit_3_editingFinished(); 34 | 35 | private: 36 | Ui::changepw *ui; 37 | 38 | bool m_pressed; 39 | QPoint m_movePos; 40 | 41 | QString truepwd; 42 | int ifright[3]; 43 | }; 44 | 45 | 46 | #endif // CHANGEPW_H 47 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/regist.h: -------------------------------------------------------------------------------- 1 | #ifndef REGIST_H 2 | #define REGIST_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class regist; 8 | } 9 | 10 | class regist : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit regist(QWidget *parent = nullptr); 16 | ~regist(); 17 | 18 | private slots: 19 | void mousePressEvent(QMouseEvent *event); 20 | 21 | void mouseMoveEvent(QMouseEvent *event); 22 | 23 | void mouseReleaseEvent(QMouseEvent *event); 24 | 25 | void on_pushButton_clicked(); 26 | 27 | void on_lineEdit_editingFinished(); 28 | 29 | void on_lineEdit_4_editingFinished(); 30 | 31 | void on_lineEdit_2_editingFinished(); 32 | 33 | void on_lineEdit_3_editingFinished(); 34 | 35 | void on_pushButton_2_clicked(); 36 | 37 | private: 38 | Ui::regist *ui; 39 | 40 | bool m_pressed; 41 | QPoint m_movePos; 42 | int ifregist[5]; 43 | }; 44 | 45 | #endif // REGIST_H 46 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/login.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGIN_H 2 | #define LOGIN_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class login; 8 | } 9 | 10 | class login : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit login(QWidget *parent = nullptr); 16 | ~login(); 17 | QString getid(); 18 | private slots: 19 | QPixmap PixmapToRound(const QPixmap &src, int radius); 20 | 21 | void mousePressEvent(QMouseEvent *event); 22 | 23 | void mouseMoveEvent(QMouseEvent *event); 24 | 25 | void mouseReleaseEvent(QMouseEvent *event); 26 | 27 | void on_pushButton_3_clicked(); 28 | 29 | void on_pushButton_clicked(); 30 | 31 | void on_pushButton_2_clicked(); 32 | 33 | void on_pushButton_4_clicked(); 34 | 35 | void on_pushButton_5_clicked(); 36 | 37 | 38 | void on_lineEdit_editingFinished(); 39 | 40 | private: 41 | Ui::login *ui; 42 | 43 | bool m_pressed; 44 | QPoint m_movePos; 45 | QString trueid; 46 | }; 47 | 48 | #endif // LOGIN_H 49 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/README.TXT: -------------------------------------------------------------------------------- 1 | Qt Solutions Component: Single Application 2 | 3 | The QtSingleApplication component provides support for 4 | applications that can be only started once per user. 5 | 6 | 7 | 8 | Version history: 9 | 10 | 2.0: - Version 1.3 ported to Qt 4. 11 | 12 | 2.1: - Fix compilation problem on Mac. 13 | 14 | 2.2: - Really fix the Mac compilation problem. 15 | - Mac: fix crash due to wrong object releasing. 16 | - Mac: Fix memory leak. 17 | 18 | 2.3: - Windows: Force creation of internal widget to make it work 19 | with Qt 4.2. 20 | 21 | 2.4: - Fix the system for automatic window raising on message 22 | reception. NOTE: minor API change. 23 | 24 | 2.5: - Mac: Fix isRunning() to work and report correctly. 25 | 26 | 2.6: - - initialize() is now obsolete, no longer necessary to call 27 | it 28 | - - Fixed race condition where multiple instances migth be started 29 | - - QtSingleCoreApplication variant provided for non-GUI (console) 30 | usage 31 | - Complete reimplementation. Visible changes: 32 | - LGPL release. 33 | 34 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/tabwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "tabwidget.h" 2 | 3 | tabwidget::tabwidget(QWidget *parent):QTabWidget(parent) 4 | { 5 | setTabBar(new TabBar); 6 | setTabPosition(QTabWidget::West); 7 | } 8 | 9 | QSize TabBar::tabSizeHint(int index) const 10 | { 11 | QSize s = QTabBar::tabSizeHint(index); 12 | s.transpose(); 13 | return s; 14 | } 15 | 16 | void TabBar::paintEvent(QPaintEvent *) 17 | { 18 | QStylePainter painter(this); 19 | QStyleOptionTab opt; 20 | for(int i = 0;i < count();i++) 21 | { 22 | initStyleOption(&opt,i); 23 | painter.drawControl(QStyle::CE_TabBarTabShape, opt); 24 | painter.save(); 25 | QSize s = opt.rect.size(); 26 | s.transpose(); 27 | QRect r(QPoint(), s); 28 | r.moveCenter(opt.rect.center()); 29 | opt.rect = r; 30 | QPoint c = tabRect(i).center(); 31 | painter.translate(c); 32 | painter.rotate(90); 33 | painter.translate(-c); 34 | painter.drawControl(QStyle::CE_TabBarTabLabel,opt); 35 | painter.restore(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /VictorServer/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 WQ-Vincent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/pwback.cpp: -------------------------------------------------------------------------------- 1 | #include "pwback.h" 2 | #include "ui_pwback.h" 3 | #include "mainwindow.h" 4 | 5 | pwback::pwback(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::pwback) 8 | { 9 | ui->setupUi(this); 10 | ui->lineEdit->setPlaceholderText(" 用户名"); 11 | ui->lineEdit_2->setPlaceholderText(" 手机号码"); 12 | } 13 | 14 | pwback::~pwback() 15 | { 16 | delete ui; 17 | } 18 | 19 | void pwback::mousePressEvent(QMouseEvent *event) 20 | { 21 | m_pressed = true; 22 | m_movePos = event->globalPos() - pos(); 23 | 24 | return QDialog::mousePressEvent(event); 25 | } 26 | void pwback::mouseMoveEvent(QMouseEvent *event) 27 | { 28 | if (m_pressed && (event->buttons()== Qt::LeftButton) 29 | && (event->globalPos() - m_movePos).manhattanLength() > QApplication::startDragDistance()) 30 | { 31 | QPoint movePos = event->globalPos() - m_movePos; 32 | this->move(movePos); 33 | m_movePos = event->globalPos() - pos(); 34 | } 35 | 36 | return QDialog::mouseMoveEvent(event); 37 | } 38 | void pwback::mouseReleaseEvent(QMouseEvent *event) 39 | { 40 | m_pressed = false; 41 | 42 | return QDialog::mouseReleaseEvent(event); 43 | } 44 | -------------------------------------------------------------------------------- /VictorServer/serverthread.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVERTHREAD_H 2 | 3 | #define SERVERTHREAD_H 4 | 5 | 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | 16 | 17 | #include "mysocket.h" 18 | 19 | 20 | 21 | class Socket; 22 | 23 | 24 | 25 | class serverThread : public QThread 26 | 27 | { 28 | 29 | Q_OBJECT 30 | 31 | public: 32 | 33 | serverThread(int sockDesc, QObject *parent = Q_NULLPTR); 34 | 35 | ~serverThread(); 36 | 37 | 38 | 39 | private: 40 | 41 | void run(void); 42 | 43 | 44 | 45 | public slots: 46 | 47 | void sendDataSlot(int sockDesc, const QByteArray &data); 48 | 49 | 50 | 51 | signals: 52 | 53 | void dataReady(const QString &ip, const QByteArray &data); 54 | 55 | void sendData(int sockDesc, const QByteArray &data); 56 | 57 | void disconnectTCP(int sockDesc); 58 | 59 | 60 | 61 | private slots: 62 | 63 | void recvDataSlot(const QString &ip, const QByteArray &data); 64 | 65 | void disconnectToHost(void); 66 | 67 | 68 | 69 | private: 70 | 71 | MySocket *m_socket; 72 | 73 | 74 | 75 | int m_sockDesc; 76 | 77 | }; 78 | 79 | 80 | 81 | #endif // SERVERTHREAD_H 82 | -------------------------------------------------------------------------------- /VictorServer/tcpserver.cpp: -------------------------------------------------------------------------------- 1 | #include "tcpserver.h" 2 | #include "serverthread.h" 3 | 4 | TcpServer::TcpServer(QObject *parent) : 5 | QTcpServer(parent) 6 | { 7 | m_dialog = dynamic_cast(parent); 8 | } 9 | 10 | TcpServer::~TcpServer() 11 | { 12 | 13 | } 14 | 15 | void TcpServer::incomingConnection(int sockDesc) 16 | { 17 | m_socketList.append(sockDesc); 18 | 19 | 20 | 21 | serverThread *thread = new serverThread(sockDesc); 22 | 23 | 24 | 25 | m_dialog->showConnection(sockDesc); 26 | 27 | 28 | 29 | connect(thread, SIGNAL(disconnectTCP(int)), this, SLOT(clientDisconnected(int))); 30 | 31 | connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); 32 | 33 | 34 | 35 | connect(thread, SIGNAL(dataReady(const QString&, const QByteArray&)), 36 | 37 | m_dialog, SLOT(recvData(const QString&, const QByteArray&))); 38 | 39 | 40 | 41 | connect(m_dialog, SIGNAL(sendData(int, const QByteArray&)), 42 | 43 | thread, SLOT(sendDataSlot(int, const QByteArray&))); 44 | 45 | 46 | 47 | thread->start(); 48 | } 49 | void TcpServer::clientDisconnected(int sockDesc) 50 | 51 | { 52 | 53 | m_dialog->showDisconnection(sockDesc); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/setting.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTING_H 2 | #define SETTING_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class setting; 8 | } 9 | 10 | class setting : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit setting(QWidget *parent = nullptr); 16 | ~setting(); 17 | 18 | private slots: 19 | void mousePressEvent(QMouseEvent *event); 20 | 21 | void mouseMoveEvent(QMouseEvent *event); 22 | 23 | void mouseReleaseEvent(QMouseEvent *event); 24 | 25 | void on_pushButton_clicked(); 26 | 27 | void on_pushButton_2_clicked(); 28 | 29 | void on_checkBox_stateChanged(int arg1); 30 | 31 | void on_pushButton_3_clicked(); 32 | 33 | void on_checkBox_3_stateChanged(int arg1); 34 | 35 | void on_checkBox_2_stateChanged(int arg1); 36 | 37 | void on_checkBox_4_stateChanged(int arg1); 38 | 39 | void on_checkBox_5_stateChanged(int arg1); 40 | 41 | void on_checkBox_6_stateChanged(int arg1); 42 | 43 | void on_lineEdit_2_editingFinished(); 44 | 45 | void on_lineEdit_3_editingFinished(); 46 | 47 | void on_comboBox_activated(const QString &arg1); 48 | 49 | private: 50 | Ui::setting *ui; 51 | 52 | bool m_pressed; 53 | QPoint m_movePos; 54 | QString id; 55 | }; 56 | 57 | #endif // SETTING_H 58 | -------------------------------------------------------------------------------- /VictorServer/VictorServer.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | QT += network 3 | include(./qtsingleapplication/qtsingleapplication.pri) 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 5 | 6 | CONFIG += c++11 7 | 8 | # The following define makes your compiler emit warnings if you use 9 | # any Qt feature that has been marked deprecated (the exact warnings 10 | # depend on your compiler). Please consult the documentation of the 11 | # deprecated API in order to know how to port your code away from it. 12 | DEFINES += QT_DEPRECATED_WARNINGS 13 | 14 | # You can also make your code fail to compile if it uses deprecated APIs. 15 | # In order to do so, uncomment the following line. 16 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 17 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 18 | 19 | SOURCES += \ 20 | main.cpp \ 21 | mysocket.cpp \ 22 | qtserver.cpp \ 23 | serverthread.cpp \ 24 | tcpserver.cpp 25 | 26 | HEADERS += \ 27 | mysocket.h \ 28 | qtserver.h \ 29 | serverthread.h \ 30 | tcpserver.h 31 | 32 | FORMS += \ 33 | qtserver.ui 34 | 35 | # Default rules for deployment. 36 | qnx: target.path = /tmp/$${TARGET}/bin 37 | else: unix:!android: target.path = /opt/$${TARGET}/bin 38 | !isEmpty(target.path): INSTALLS += target 39 | -------------------------------------------------------------------------------- /VictorServer/serverthread.cpp: -------------------------------------------------------------------------------- 1 | #include "serverthread.h" 2 | 3 | serverThread::serverThread(int sockDesc, QObject *parent) : 4 | 5 | QThread(parent), 6 | 7 | m_sockDesc(sockDesc) 8 | 9 | { 10 | 11 | 12 | 13 | } 14 | serverThread::~serverThread() 15 | 16 | { 17 | 18 | m_socket->close(); 19 | 20 | } 21 | 22 | 23 | 24 | void serverThread::run(void) 25 | 26 | { 27 | 28 | m_socket = new MySocket(m_sockDesc); 29 | 30 | 31 | 32 | if (!m_socket->setSocketDescriptor(m_sockDesc)) { 33 | 34 | return ; 35 | 36 | } 37 | 38 | 39 | 40 | connect(m_socket, &MySocket::disconnected, this, &serverThread::disconnectToHost); 41 | 42 | connect(m_socket, SIGNAL(dataReady(const QString&, const QByteArray&)), 43 | 44 | this, SLOT(recvDataSlot(const QString&, const QByteArray&))); 45 | 46 | connect(this, SIGNAL(sendData(int, const QByteArray&)), 47 | 48 | m_socket, SLOT(sendData(int, const QByteArray&))); 49 | 50 | 51 | 52 | this->exec(); 53 | 54 | } 55 | 56 | 57 | 58 | void serverThread::sendDataSlot(int sockDesc, const QByteArray &data) 59 | 60 | { 61 | 62 | if (data.isEmpty()) { 63 | 64 | return ; 65 | 66 | } 67 | 68 | 69 | 70 | emit sendData(sockDesc, data); 71 | 72 | } 73 | 74 | 75 | 76 | void serverThread::recvDataSlot(const QString &ip, const QByteArray &data) 77 | 78 | { 79 | 80 | emit dataReady(ip, data); 81 | 82 | } 83 | 84 | 85 | 86 | void serverThread::disconnectToHost(void) 87 | 88 | { 89 | 90 | emit disconnectTCP(m_sockDesc); 91 | 92 | m_socket->disconnectFromHost(); 93 | 94 | this->quit(); 95 | 96 | } 97 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/qnchatmessage.h: -------------------------------------------------------------------------------- 1 | #ifndef QNCHATMESSAGE_H 2 | #define QNCHATMESSAGE_H 3 | 4 | #include 5 | 6 | class QPaintEvent; 7 | class QPainter; 8 | class QLabel; 9 | class QMovie; 10 | 11 | class QNChatMessage : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit QNChatMessage(QWidget *parent,QString send_id,QString receive_id); 16 | 17 | enum User_Type{ 18 | User_System,//系统 19 | User_Me, //自己 20 | User_She, //用户 21 | User_Time, //时间 22 | }; 23 | void setTextSuccess(); 24 | void setText(QString text, QString time, QSize allSize, User_Type userType); 25 | 26 | QSize getRealString(QString src); 27 | QSize fontRect(QString str); 28 | 29 | inline QString text() {return m_msg;} 30 | inline QString time() {return m_time;} 31 | inline User_Type userType() {return m_userType;} 32 | protected: 33 | void paintEvent(QPaintEvent *event); 34 | private: 35 | QString id; 36 | QString fid; 37 | 38 | QString m_msg; 39 | QString m_time; 40 | QString m_curTime; 41 | 42 | QSize m_allSize; 43 | User_Type m_userType = User_System; 44 | 45 | int m_kuangWidth; 46 | int m_textWidth; 47 | int m_spaceWid; 48 | double m_lineHeight; 49 | 50 | QRect m_iconLeftRect; 51 | QRect m_iconRightRect; 52 | QRect m_sanjiaoLeftRect; 53 | QRect m_sanjiaoRightRect; 54 | QRect m_kuangLeftRect; 55 | QRect m_kuangRightRect; 56 | QRect m_textLeftRect; 57 | QRect m_textRightRect; 58 | QPixmap m_leftPixmap; 59 | QPixmap m_rightPixmap; 60 | QLabel* m_loading = Q_NULLPTR; 61 | QMovie* m_loadingMovie = Q_NULLPTR; 62 | bool m_isSending = false; 63 | }; 64 | 65 | #endif // QNCHATMESSAGE_H 66 | 67 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/addfrd.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDFRD_H 2 | #define ADDFRD_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class addfrd; 8 | } 9 | 10 | class addfrd : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit addfrd(QWidget *parent = nullptr); 16 | ~addfrd(); 17 | 18 | private slots: 19 | void mousePressEvent(QMouseEvent *event); 20 | 21 | void mouseMoveEvent(QMouseEvent *event); 22 | 23 | void mouseReleaseEvent(QMouseEvent *event); 24 | 25 | void on_pushButton_clicked(); 26 | 27 | void on_pushButton_2_clicked(); 28 | 29 | void on_pushButton_3_clicked(); 30 | 31 | void on_pushButton_12_clicked(); 32 | 33 | void on_pushButton_21_clicked(); 34 | 35 | void on_pushButton_6_clicked(); 36 | 37 | void on_pushButton_22_clicked(); 38 | 39 | void on_pushButton_7_clicked(); 40 | 41 | void on_pushButton_8_clicked(); 42 | 43 | void on_pushButton_9_clicked(); 44 | 45 | void on_pushButton_11_clicked(); 46 | 47 | void on_pushButton_20_clicked(); 48 | 49 | void on_pushButton_13_clicked(); 50 | 51 | void on_pushButton_14_clicked(); 52 | 53 | void on_pushButton_15_clicked(); 54 | 55 | void on_pushButton_16_clicked(); 56 | 57 | void on_pushButton_18_clicked(); 58 | 59 | void on_pushButton_19_clicked(); 60 | 61 | void addwin(QString frdid); 62 | 63 | void on_pushButton_5_clicked(); 64 | 65 | void on_pushButton_17_clicked(); 66 | 67 | void on_pushButton_10_clicked(); 68 | 69 | void on_pushButton_24_clicked(); 70 | 71 | void on_pushButton_23_clicked(); 72 | 73 | private: 74 | Ui::addfrd *ui; 75 | 76 | bool m_pressed; 77 | QPoint m_movePos; 78 | int pagenum; 79 | }; 80 | 81 | #endif // ADDFRD_H 82 | -------------------------------------------------------------------------------- /VictorServer/qtserver.h: -------------------------------------------------------------------------------- 1 | #ifndef QTSERVER_H 2 | #define QTSERVER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | QT_BEGIN_NAMESPACE 17 | 18 | class TcpServer; 19 | 20 | namespace Ui { class QtServer; } 21 | QT_END_NAMESPACE 22 | 23 | class QtServer : public QMainWindow 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit QtServer(QWidget *parent = nullptr); 29 | ~QtServer(); 30 | 31 | //TcpServer *fileserver; 32 | 33 | signals: 34 | void sendData(int id, const QByteArray &data); 35 | 36 | 37 | public slots: 38 | 39 | void recvData(const QString &ip, const QByteArray &data); 40 | 41 | private slots: 42 | void showConnection(int sockDesc); 43 | 44 | void showDisconnection(int sockDesc); 45 | 46 | void sendDataSlot(void); 47 | 48 | void clearData(void); 49 | 50 | //void acceptFileConnection(); 51 | //void updateFileProgress(); 52 | ///选择发送的文件 53 | //void selectFile(); 54 | //void sendFile(); 55 | ////更新文件传送进度 56 | //void updateFileProgress(qint64); 57 | 58 | private: 59 | Ui::QtServer *ui; 60 | 61 | friend class TcpServer; 62 | int count; 63 | TcpServer *server; 64 | 65 | ////传送文件相关变量 66 | qint64 totalBytes; 67 | qint64 bytesReceived; 68 | qint64 bytestoWrite; 69 | qint64 bytesWritten; 70 | qint64 filenameSize; 71 | QString filename; 72 | ///每次发送数据大小 73 | qint64 perDataSize; 74 | QFile *localFile; 75 | ////本地缓冲区 76 | QByteArray inBlock; 77 | QByteArray outBlock; 78 | 79 | ////系统时间 80 | QDateTime current_date_time; 81 | QString str_date_time; 82 | }; 83 | #endif // QTSERVER_H 84 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/WePlatform.pro: -------------------------------------------------------------------------------- 1 | QT += core gui sql 2 | QT +=xml 3 | QT += network 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 5 | 6 | CONFIG += c++11 7 | 8 | # The following define makes your compiler emit warnings if you use 9 | # any Qt feature that has been marked deprecated (the exact warnings 10 | # depend on your compiler). Please consult the documentation of the 11 | # deprecated API in order to know how to port your code away from it. 12 | DEFINES += QT_DEPRECATED_WARNINGS 13 | 14 | # You can also make your code fail to compile if it uses deprecated APIs. 15 | # In order to do so, uncomment the following line. 16 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 17 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 18 | 19 | SOURCES += \ 20 | addfrd.cpp \ 21 | changepw.cpp \ 22 | database.cpp \ 23 | inform.cpp \ 24 | listwidget.cpp \ 25 | listwidget2.cpp \ 26 | login.cpp \ 27 | loginlose.cpp \ 28 | main.cpp \ 29 | mainwindow.cpp \ 30 | pwback.cpp \ 31 | qnchatmessage.cpp \ 32 | regist.cpp \ 33 | setting.cpp \ 34 | tabwidget.cpp 35 | 36 | HEADERS += \ 37 | addfrd.h \ 38 | changepw.h \ 39 | database.h \ 40 | inform.h \ 41 | listwidget.h \ 42 | listwidget2.h \ 43 | login.h \ 44 | loginlose.h \ 45 | mainwindow.h \ 46 | pwback.h \ 47 | qnchatmessage.h \ 48 | regist.h \ 49 | setting.h \ 50 | tabwidget.h 51 | 52 | FORMS += \ 53 | addfrd.ui \ 54 | changepw.ui \ 55 | inform.ui \ 56 | login.ui \ 57 | loginlose.ui \ 58 | mainwindow.ui \ 59 | pwback.ui \ 60 | regist.ui \ 61 | setting.ui 62 | 63 | # Default rules for deployment. 64 | qnx: target.path = /tmp/$${TARGET}/bin 65 | else: unix:!android: target.path = /opt/$${TARGET}/bin 66 | !isEmpty(target.path): INSTALLS += target 67 | 68 | DISTFILES += \ 69 | wbb.jpg 70 | 71 | RESOURCES += \ 72 | image.qrc 73 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/listwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "listwidget.h" 2 | #include "mainwindow.h" 3 | 4 | alistwidget::alistwidget(QWidget *parent):QListWidget(parent) 5 | { 6 | } 7 | void alistwidget::contextMenuEvent ( QContextMenuEvent * event ) 8 | { 9 | QListWidgetItem *item=this->itemAt(event->pos()); 10 | QWidget* pwig = this->itemWidget(item); 11 | QList linedList = pwig->findChildren(); 12 | foreach(QLineEdit *lined, linedList) 13 | { 14 | if(!lined->text().isEmpty()) 15 | { 16 | frdid=lined->text(); 17 | } 18 | } 19 | QMenu* popMenu = new QMenu(this); 20 | popMenu->setStyleSheet("QMenu{color: rbg(80,80,80)}" 21 | "QMenu::item:selected {background-color:rgb(128, 185, 240);color: rgb(245,245,245);}" 22 | "QMenu::item{font-size: 9pt;" 23 | "border: 0px solid rgb(140, 195, 245); background-color:rgb(232, 240, 255);" 24 | "padding:5px 40px;" /*设置菜单项文字上下和左右的内边距,效果就是菜单中的条目左右上下有了间隔*/ 25 | "}");/*设置菜单项的外边距*/ 26 | 27 | QFont font("微软雅黑",10,50); 28 | popMenu->setFont(font); 29 | if(this->itemAt(event->pos())) 30 | { 31 | QAction *action1=new QAction("发送消息", this); 32 | QAction *action2=new QAction("删除好友", this); 33 | popMenu->addAction(action1); 34 | popMenu->addAction(action2); 35 | 36 | connect(action1, SIGNAL(triggered()), this, SLOT(actionone())); 37 | connect(action2, SIGNAL(triggered()), this, SLOT(actiontwo())); 38 | } 39 | popMenu->exec(QCursor::pos()); // 菜单出现的位置为当前鼠标的位置 40 | } 41 | 42 | void alistwidget::mousePressEvent(QMouseEvent * event) 43 | { 44 | if(this->itemAt(event->pos())) 45 | { 46 | QListWidgetItem *item=this->itemAt(event->pos()); 47 | item->setSelected(true); 48 | QWidget* pwig = this->itemWidget(item); 49 | QList linedList = pwig->findChildren(); 50 | foreach(QLineEdit *lined, linedList) 51 | { 52 | if(!lined->text().isEmpty()) 53 | { 54 | frdid=lined->text(); 55 | } 56 | } 57 | action3->clicked(); 58 | } 59 | } 60 | 61 | void alistwidget::actionone() 62 | { 63 | action1->clicked(); 64 | } 65 | 66 | void alistwidget::actiontwo() 67 | { 68 | action2->clicked(); 69 | } 70 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/listwidget2.cpp: -------------------------------------------------------------------------------- 1 | #include "listwidget2.h" 2 | #include "mainwindow.h" 3 | 4 | listwidget2::listwidget2(QWidget *parent):QListWidget(parent) 5 | { 6 | } 7 | void listwidget2::contextMenuEvent ( QContextMenuEvent * event ) 8 | { 9 | QListWidgetItem *item=this->itemAt(event->pos()); 10 | QWidget* pwig = this->itemWidget(item); 11 | QList linedList = pwig->findChildren(); 12 | foreach(QLineEdit *lined, linedList) 13 | { 14 | if(!lined->text().isEmpty()) 15 | { 16 | frdid=lined->text(); 17 | } 18 | } 19 | QMenu* popMenu = new QMenu(this); 20 | popMenu->setStyleSheet("QMenu{color: rbg(80,80,80)}" 21 | "QMenu::item:selected {background-color:rgb(128, 185, 240);color: rgb(245,245,245);}" 22 | "QMenu::item{font-size: 9pt;" 23 | "border: 0px solid rgb(140, 195, 245); background-color:rgb(232, 240, 255);" 24 | "padding:5px 40px;" /*设置菜单项文字上下和左右的内边距,效果就是菜单中的条目左右上下有了间隔*/ 25 | "}");/*设置菜单项的外边距*/ 26 | 27 | QFont font("微软雅黑",10,50); 28 | popMenu->setFont(font); 29 | if(this->itemAt(event->pos())) 30 | { 31 | QAction *action1=new QAction("置顶", this); 32 | QAction *action2=new QAction("删除聊天", this); 33 | popMenu->addAction(action1); 34 | popMenu->addAction(action2); 35 | 36 | connect(action1, SIGNAL(triggered()), this, SLOT(actionone())); 37 | connect(action2, SIGNAL(triggered()), this, SLOT(actiontwo())); 38 | } 39 | popMenu->exec(QCursor::pos()); // 菜单出现的位置为当前鼠标的位置 40 | } 41 | 42 | void listwidget2::mousePressEvent(QMouseEvent * event) 43 | { 44 | if(this->itemAt(event->pos())) 45 | { 46 | QListWidgetItem *item=this->itemAt(event->pos()); 47 | item->setSelected(true); 48 | QWidget* pwig = this->itemWidget(item); 49 | QList linedList = pwig->findChildren(); 50 | foreach(QLineEdit *lined, linedList) 51 | { 52 | if(!lined->text().isEmpty()) 53 | { 54 | frdid=lined->text(); 55 | } 56 | } 57 | action3->clicked(); 58 | } 59 | } 60 | 61 | void listwidget2::actionone() 62 | { 63 | action1->clicked(); 64 | } 65 | 66 | void listwidget2::actiontwo() 67 | { 68 | action2->clicked(); 69 | } 70 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/inform.h: -------------------------------------------------------------------------------- 1 | #ifndef INFORM_H 2 | #define INFORM_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class inform; 8 | } 9 | 10 | class inform : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit inform(QString id,QWidget *parent = nullptr); 16 | ~inform(); 17 | 18 | private slots: 19 | QPixmap PixmapToRound(const QPixmap &src, int radius); 20 | 21 | void mousePressEvent(QMouseEvent *event); 22 | 23 | void mouseMoveEvent(QMouseEvent *event); 24 | 25 | void mouseReleaseEvent(QMouseEvent *event); 26 | 27 | void on_pushButton_clicked(); 28 | 29 | void on_pushButton_2_clicked(); 30 | 31 | void on_pushButton_3_clicked(); 32 | 33 | void on_pushButton_4_clicked(); 34 | 35 | void on_pushButton_5_clicked(); 36 | 37 | void on_pushButton_6_clicked(); 38 | 39 | void on_comboBox_2_activated(const QString &arg1); 40 | 41 | void on_lineEdit_editingFinished(); 42 | 43 | void on_comboBox_5_activated(const QString &arg1); 44 | 45 | void on_comboBox_4_activated(const QString &arg1); 46 | 47 | 48 | void on_pushButton_30_clicked(); 49 | 50 | void on_pushButton_7_clicked(); 51 | 52 | void on_pushButton_8_clicked(); 53 | 54 | void on_pushButton_9_clicked(); 55 | 56 | void on_pushButton_10_clicked(); 57 | 58 | void on_pushButton_11_clicked(); 59 | 60 | void on_pushButton_12_clicked(); 61 | 62 | void on_pushButton_13_clicked(); 63 | 64 | void on_pushButton_14_clicked(); 65 | 66 | void on_pushButton_15_clicked(); 67 | 68 | void on_pushButton_16_clicked(); 69 | 70 | void on_pushButton_17_clicked(); 71 | 72 | void on_pushButton_18_clicked(); 73 | 74 | void on_pushButton_19_clicked(); 75 | 76 | void on_pushButton_20_clicked(); 77 | 78 | void on_pushButton_21_clicked(); 79 | 80 | void on_pushButton_22_clicked(); 81 | 82 | void on_pushButton_23_clicked(); 83 | 84 | void on_pushButton_24_clicked(); 85 | 86 | void on_pushButton_25_clicked(); 87 | 88 | void on_pushButton_26_clicked(); 89 | 90 | void on_pushButton_27_clicked(); 91 | 92 | void on_pushButton_28_clicked(); 93 | 94 | void on_pushButton_29_clicked(); 95 | 96 | private: 97 | Ui::inform *ui; 98 | 99 | bool m_pressed; 100 | QPoint m_movePos; 101 | QString nowid; 102 | }; 103 | 104 | #endif // INFORM_H 105 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/image.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/background.jpg 4 | image/minimum.png 5 | image/close.png 6 | image/yonghu.png 7 | image/shezhi.png 8 | image/background2.png 9 | image/WeCloudIcon.png 10 | image/mima.png 11 | image/yun.png 12 | image/cuowu.png 13 | image/Simpson.jpg 14 | image/chat.png 15 | image/haoyou.png 16 | image/dongtai.png 17 | image/close2.png 18 | image/minimum2.png 19 | image/shezhi2.png 20 | image/tianjia.png 21 | image/biaoqing.png 22 | image/wenjian.png 23 | image/lishi.png 24 | image/more.png 25 | image/more2.png 26 | image/yonghu2.png 27 | image/riqi.png 28 | image/id.png 29 | image/dizhi.png 30 | other/LocList.xml 31 | image/background3.jpg 32 | image/background4.jpg 33 | image/tianjia2.png 34 | image/fanhui.png 35 | image/boy.png 36 | image/girl.png 37 | image/addfriend.png 38 | touxiang/beizi.jpg 39 | touxiang/blownbear.jpg 40 | touxiang/dog.jpg 41 | touxiang/duolaameng.jpg 42 | touxiang/fenhongbao.jpg 43 | touxiang/girl.jpg 44 | touxiang/girl2.jpg 45 | touxiang/girl3.jpg 46 | touxiang/girl4.jpg 47 | touxiang/haimianbob.jpg 48 | touxiang/icebear.jpg 49 | touxiang/paidaxing.jpg 50 | touxiang/panda.jpg 51 | touxiang/pig.jpg 52 | touxiang/shuaya.jpg 53 | touxiang/tom.jpg 54 | touxiang/xiaowanzi.jpg 55 | touxiang/xiaoxin.jpg 56 | touxiang/yazi.jpg 57 | touxiang/Simpson.jpg 58 | image/victoricon2.png 59 | image/victoricon.png 60 | 61 | 62 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtsinglecoreapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #ifndef QTSINGLECOREAPPLICATION_H 42 | #define QTSINGLECOREAPPLICATION_H 43 | 44 | #include 45 | 46 | class QtLocalPeer; 47 | 48 | class QtSingleCoreApplication : public QCoreApplication 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | QtSingleCoreApplication(int &argc, char **argv); 54 | QtSingleCoreApplication(const QString &id, int &argc, char **argv); 55 | 56 | bool isRunning(); 57 | QString id() const; 58 | 59 | public Q_SLOTS: 60 | bool sendMessage(const QString &message, int timeout = 5000); 61 | 62 | 63 | Q_SIGNALS: 64 | void messageReceived(const QString &message); 65 | 66 | 67 | private: 68 | QtLocalPeer* peer; 69 | }; 70 | 71 | #endif // QTSINGLECOREAPPLICATION_H 72 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/loginlose.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | loginlose 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 231 11 | 12 | 13 | 14 | 登录失败 15 | 16 | 17 | 18 | :/image/cuowu.png:/image/cuowu.png 19 | 20 | 21 | 22 | 23 | 60 24 | 60 25 | 281 26 | 81 27 | 28 | 29 | 30 | <html><head/><body><p><span style=" font-size:12pt;">账号或密码有误,请重新输入!</span></p></body></html> 31 | 32 | 33 | 34 | 35 | 36 | 0 37 | 0 38 | 401 39 | 231 40 | 41 | 42 | 43 | background-color: rgb(255, 255, 255); 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 90 53 | 200 54 | 181 55 | 20 56 | 57 | 58 | 59 | 60 | 微软雅黑 61 | 62 | 63 | 64 | 如果你的密码丢失或遗忘, 65 | 66 | 67 | 68 | 69 | 70 | 263 71 | 196 72 | 131 73 | 28 74 | 75 | 76 | 77 | 78 | 微软雅黑 79 | 80 | 81 | 82 | 83 | QPushButton{background:transparent;color: rgb(0, 140, 255);} 84 | QPushButton:hover{color: rgb(50, 180, 255);} 85 | 86 | 87 | 点击这里找回密码 88 | 89 | 90 | label_2 91 | label 92 | label_3 93 | pushButton 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtlocalpeer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #ifndef QTLOCALPEER_H 42 | #define QTLOCALPEER_H 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include "qtlockedfile.h" 50 | 51 | class QtLocalPeer : public QObject 52 | { 53 | Q_OBJECT 54 | 55 | public: 56 | QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); 57 | bool isClient(); 58 | bool sendMessage(const QString &message, int timeout); 59 | QString applicationId() const 60 | { return id; } 61 | 62 | Q_SIGNALS: 63 | void messageReceived(const QString &message); 64 | 65 | protected Q_SLOTS: 66 | void receiveConnection(); 67 | 68 | protected: 69 | QString id; 70 | QString socketName; 71 | QLocalServer* server; 72 | QtLP_Private::QtLockedFile lockFile; 73 | 74 | private: 75 | static const char* ack; 76 | }; 77 | 78 | #endif // QTLOCALPEER_H 79 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtlockedfile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #ifndef QTLOCKEDFILE_H 42 | #define QTLOCKEDFILE_H 43 | 44 | #include 45 | #ifdef Q_OS_WIN 46 | #include 47 | #endif 48 | 49 | #if defined(Q_OS_WIN) 50 | # if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) 51 | # define QT_QTLOCKEDFILE_EXPORT 52 | # elif defined(QT_QTLOCKEDFILE_IMPORT) 53 | # if defined(QT_QTLOCKEDFILE_EXPORT) 54 | # undef QT_QTLOCKEDFILE_EXPORT 55 | # endif 56 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) 57 | # elif defined(QT_QTLOCKEDFILE_EXPORT) 58 | # undef QT_QTLOCKEDFILE_EXPORT 59 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) 60 | # endif 61 | #else 62 | # define QT_QTLOCKEDFILE_EXPORT 63 | #endif 64 | 65 | namespace QtLP_Private { 66 | 67 | class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile 68 | { 69 | public: 70 | enum LockMode { NoLock = 0, ReadLock, WriteLock }; 71 | 72 | QtLockedFile(); 73 | QtLockedFile(const QString &name); 74 | ~QtLockedFile(); 75 | 76 | bool open(OpenMode mode); 77 | 78 | bool lock(LockMode mode, bool block = true); 79 | bool unlock(); 80 | bool isLocked() const; 81 | LockMode lockMode() const; 82 | 83 | private: 84 | #ifdef Q_OS_WIN 85 | Qt::HANDLE wmutex; 86 | Qt::HANDLE rmutex; 87 | QVector rmutexes; 88 | QString mutexname; 89 | 90 | Qt::HANDLE getMutexHandle(int idx, bool doCreate); 91 | bool waitMutex(Qt::HANDLE mutex, bool doBlock); 92 | 93 | #endif 94 | LockMode m_lock_mode; 95 | }; 96 | } 97 | #endif 98 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtlockedfile_unix.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "qtlockedfile.h" 47 | 48 | bool QtLockedFile::lock(LockMode mode, bool block) 49 | { 50 | if (!isOpen()) { 51 | qWarning("QtLockedFile::lock(): file is not opened"); 52 | return false; 53 | } 54 | 55 | if (mode == NoLock) 56 | return unlock(); 57 | 58 | if (mode == m_lock_mode) 59 | return true; 60 | 61 | if (m_lock_mode != NoLock) 62 | unlock(); 63 | 64 | struct flock fl; 65 | fl.l_whence = SEEK_SET; 66 | fl.l_start = 0; 67 | fl.l_len = 0; 68 | fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; 69 | int cmd = block ? F_SETLKW : F_SETLK; 70 | int ret = fcntl(handle(), cmd, &fl); 71 | 72 | if (ret == -1) { 73 | if (errno != EINTR && errno != EAGAIN) 74 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 75 | return false; 76 | } 77 | 78 | 79 | m_lock_mode = mode; 80 | return true; 81 | } 82 | 83 | 84 | bool QtLockedFile::unlock() 85 | { 86 | if (!isOpen()) { 87 | qWarning("QtLockedFile::unlock(): file is not opened"); 88 | return false; 89 | } 90 | 91 | if (!isLocked()) 92 | return true; 93 | 94 | struct flock fl; 95 | fl.l_whence = SEEK_SET; 96 | fl.l_start = 0; 97 | fl.l_len = 0; 98 | fl.l_type = F_UNLCK; 99 | int ret = fcntl(handle(), F_SETLKW, &fl); 100 | 101 | if (ret == -1) { 102 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 103 | return false; 104 | } 105 | 106 | m_lock_mode = NoLock; 107 | return true; 108 | } 109 | 110 | QtLockedFile::~QtLockedFile() 111 | { 112 | if (isOpen()) 113 | unlock(); 114 | } 115 | 116 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/changepw.cpp: -------------------------------------------------------------------------------- 1 | #include "changepw.h" 2 | #include "ui_changepw.h" 3 | #include "mainwindow.h" 4 | 5 | changepw::changepw(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::changepw) 8 | { 9 | ui->setupUi(this); 10 | 11 | ifchange=0; 12 | ui->lineEdit->setPlaceholderText("旧密码"); 13 | ui->lineEdit_2->setPlaceholderText("新密码"); 14 | ui->lineEdit_3->setPlaceholderText("再次填写新密码"); 15 | ui->lineEdit->setEchoMode(QLineEdit::Password); 16 | ui->lineEdit_2->setEchoMode(QLineEdit::Password); 17 | ui->lineEdit_3->setEchoMode(QLineEdit::Password); 18 | ui->label_6->hide(); 19 | ui->label_7->hide(); 20 | ui->label_8->hide(); 21 | 22 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 23 | QSqlQuery query(db); 24 | QString str=QString("select user_id,user_password from loginuser"); 25 | query.exec(str); 26 | QString id; 27 | if(query.next()) 28 | { 29 | id=query.value(0).toString(); 30 | truepwd=query.value(1).toString(); 31 | } 32 | ui->label_5->setText(id); 33 | } 34 | 35 | changepw::~changepw() 36 | { 37 | delete ui; 38 | } 39 | 40 | void changepw::mousePressEvent(QMouseEvent *event) 41 | { 42 | m_pressed = true; 43 | m_movePos = event->globalPos() - pos(); 44 | 45 | return QDialog::mousePressEvent(event); 46 | } 47 | void changepw::mouseMoveEvent(QMouseEvent *event) 48 | { 49 | if (m_pressed && (event->buttons()== Qt::LeftButton) 50 | && (event->globalPos() - m_movePos).manhattanLength() > QApplication::startDragDistance()) 51 | { 52 | QPoint movePos = event->globalPos() - m_movePos; 53 | this->move(movePos); 54 | m_movePos = event->globalPos() - pos(); 55 | } 56 | 57 | return QDialog::mouseMoveEvent(event); 58 | } 59 | void changepw::mouseReleaseEvent(QMouseEvent *event) 60 | { 61 | m_pressed = false; 62 | 63 | return QDialog::mouseReleaseEvent(event); 64 | } 65 | 66 | 67 | void changepw::on_pushButton_clicked() 68 | { 69 | QString id=ui->label_5->text(); 70 | QString pwd=ui->lineEdit_2->text(); 71 | int suc=1; 72 | for(int i=0;i<3;i++) 73 | { 74 | if(ifright[i]==0)suc=0; 75 | } 76 | if(suc==0)return; 77 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 78 | QSqlQuery query(db); 79 | QString str=QString("update user_inform set user_password='%1' where user_id='%2'").arg(pwd).arg(id); 80 | bool a=query.exec(str); 81 | QString str1=QString("update loginuser set user_password='%1' where user_id='%2'").arg(pwd).arg(id); 82 | bool b=query.exec(str1); 83 | if(a&&b) 84 | { 85 | ifchange=1; 86 | QMessageBox::information(this,"修改成功","修改成功,请重新登录"); 87 | close(); 88 | } 89 | else 90 | { 91 | ifchange=0; 92 | QMessageBox::critical(this,"操作失败","修改失败,请检查输入格式"); 93 | } 94 | } 95 | 96 | void changepw::on_lineEdit_editingFinished() 97 | { 98 | QString pwd = ui->lineEdit->text(); 99 | if(pwd!=truepwd) 100 | { 101 | ifright[0]=0; 102 | ui->label_6->show(); 103 | ui->lineEdit->clear(); 104 | return; 105 | } 106 | else 107 | { 108 | ifright[0]=1; 109 | ui->label_6->hide(); 110 | } 111 | } 112 | 113 | void changepw::on_lineEdit_2_editingFinished() 114 | { 115 | QString newpwd = ui->lineEdit_2->text(); 116 | if(newpwd.isEmpty()) 117 | { 118 | ifright[1]=0; 119 | ui->label_7->show(); 120 | return; 121 | } 122 | else 123 | { 124 | ifright[1]=1; 125 | ui->label_7->hide(); 126 | } 127 | } 128 | 129 | void changepw::on_lineEdit_3_editingFinished() 130 | { 131 | QString newpwd = ui->lineEdit_2->text(); 132 | QString newpwd2 = ui->lineEdit_3->text(); 133 | if(newpwd!=newpwd2) 134 | { 135 | ifright[2]=0; 136 | ui->label_8->show(); 137 | ui->lineEdit_2->clear(); 138 | ui->lineEdit_3->clear(); 139 | return; 140 | } 141 | else 142 | { 143 | ifright[2]=1; 144 | ui->label_8->hide(); 145 | } 146 | } 147 | 148 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/pwback.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | pwback 4 | 5 | 6 | 7 | 0 8 | 0 9 | 519 10 | 533 11 | 12 | 13 | 14 | 密码找回 15 | 16 | 17 | 18 | :/image/victoricon2.png:/image/victoricon2.png 19 | 20 | 21 | 22 | 23 | 70 24 | 30 25 | 251 26 | 51 27 | 28 | 29 | 30 | 31 | 微软雅黑 32 | 20 33 | 50 34 | false 35 | 36 | 37 | 38 | <html><head/><body><p>密码找回</p></body></html> 39 | 40 | 41 | 42 | 43 | 44 | 0 45 | 0 46 | 521 47 | 541 48 | 49 | 50 | 51 | background-color: rgb(255, 255, 255); 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 70 61 | 250 62 | 371 63 | 51 64 | 65 | 66 | 67 | 68 | 微软雅黑 69 | 12 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 70 80 | 320 81 | 371 82 | 51 83 | 84 | 85 | 86 | 87 | 微软雅黑 88 | 12 89 | 90 | 91 | 92 | 93 | 94 | 95 | 70 96 | 410 97 | 371 98 | 61 99 | 100 | 101 | 102 | 103 | 微软雅黑 104 | 12 105 | 50 106 | false 107 | 108 | 109 | 110 | QPushButton{border-style:none;background-color: rgb(89, 169, 255);color: rgb(255, 255, 255);} 111 | QPushButton:hover{background: rgb(100, 185, 255);color: rgb(255, 255, 255);} 112 | 113 | 114 | 发送验证码 115 | 116 | 117 | 118 | 119 | 120 | 70 121 | 110 122 | 331 123 | 101 124 | 125 | 126 | 127 | 128 | 微软雅黑 129 | 10 130 | 131 | 132 | 133 | <html><head/><body><p>填写你的用户名和手机号码,</p><p>系统将会发送一条验证码短信到你的手机。</p></body></html> 134 | 135 | 136 | label_2 137 | lineEdit 138 | lineEdit_2 139 | pushButton 140 | label 141 | label_3 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtsingleapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #ifndef QTSINGLEAPPLICATION_H 42 | #define QTSINGLEAPPLICATION_H 43 | 44 | #include 45 | 46 | class QtLocalPeer; 47 | 48 | #if defined(Q_OS_WIN) 49 | # if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) 50 | # define QT_QTSINGLEAPPLICATION_EXPORT 51 | # elif defined(QT_QTSINGLEAPPLICATION_IMPORT) 52 | # if defined(QT_QTSINGLEAPPLICATION_EXPORT) 53 | # undef QT_QTSINGLEAPPLICATION_EXPORT 54 | # endif 55 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) 56 | # elif defined(QT_QTSINGLEAPPLICATION_EXPORT) 57 | # undef QT_QTSINGLEAPPLICATION_EXPORT 58 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) 59 | # endif 60 | #else 61 | # define QT_QTSINGLEAPPLICATION_EXPORT 62 | #endif 63 | 64 | class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication 65 | { 66 | Q_OBJECT 67 | 68 | public: 69 | QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); 70 | QtSingleApplication(const QString &id, int &argc, char **argv); 71 | #if QT_VERSION < 0x050000 72 | QtSingleApplication(int &argc, char **argv, Type type); 73 | # if defined(Q_WS_X11) 74 | QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 75 | QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 76 | QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 77 | # endif // Q_WS_X11 78 | #endif // QT_VERSION < 0x050000 79 | 80 | bool isRunning(); 81 | QString id() const; 82 | 83 | void setActivationWindow(QWidget* aw, bool activateOnMessage = true); 84 | QWidget* activationWindow() const; 85 | 86 | // Obsolete: 87 | void initialize(bool dummy = true) 88 | { isRunning(); Q_UNUSED(dummy) } 89 | 90 | public Q_SLOTS: 91 | bool sendMessage(const QString &message, int timeout = 5000); 92 | void activateWindow(); 93 | 94 | 95 | Q_SIGNALS: 96 | void messageReceived(const QString &message); 97 | 98 | 99 | private: 100 | void sysInit(const QString &appId = QString()); 101 | QtLocalPeer *peer; 102 | QWidget *actWin; 103 | }; 104 | 105 | #endif // QTSINGLEAPPLICATION_H 106 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/database.cpp: -------------------------------------------------------------------------------- 1 | #include "database.h" 2 | 3 | 4 | //建立一个数据库连接 5 | bool DataBase::createConnection() 6 | { 7 | //以后就可以用"sqlite1"与数据库进行连接了 8 | QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "sqlite1"); 9 | db.setDatabaseName(".//qtDb.db"); 10 | if( !db.open()) 11 | { 12 | qDebug() << "无法建立数据库连接"; 13 | return false; 14 | } 15 | return true; 16 | } 17 | 18 | //创建数据库表 19 | bool DataBase::createTable1() 20 | { 21 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 22 | QSqlQuery query(db); 23 | bool success = query.exec("create table user_inform(" 24 | "user_id char(11)," 25 | "user_password char(11)," 26 | "phonenumber int(11))"); 27 | if(success) 28 | { 29 | qDebug() << QObject::tr("数据库表1创建成功!"); 30 | return true; 31 | } 32 | else 33 | { 34 | return false; 35 | } 36 | } 37 | 38 | bool DataBase::createTable2() 39 | { 40 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 41 | QSqlQuery query(db); 42 | bool success = query.exec("create table userdata(" 43 | "user_id char(11)," 44 | "user_name char(11)," 45 | "user_sex int," 46 | "year char(10),month char(8),date char(8)," 47 | "phonenumber char(11)," 48 | "user_state char(20)," 49 | "user_city char(20)," 50 | "signature char(40)," 51 | "cansearch int," 52 | "canlookover int," 53 | "addway int," 54 | "addquestion char(30)," 55 | "addanswer char(30)," 56 | "touxiang char(20))"); 57 | if(success) 58 | { 59 | qDebug() << QObject::tr("数据库表2创建成功!"); 60 | return true; 61 | } 62 | else 63 | { 64 | 65 | return false; 66 | } 67 | } 68 | 69 | bool DataBase::createTable3() 70 | { 71 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 72 | QSqlQuery query(db); 73 | bool success = query.exec("create table loginuser(" 74 | "user_id char(11)," 75 | "user_password char(11)," 76 | "ifrem int)"); 77 | if(success) 78 | { 79 | qDebug() << QObject::tr("数据库表3创建成功!"); 80 | return true; 81 | } 82 | else 83 | { 84 | 85 | return false; 86 | } 87 | } 88 | 89 | bool DataBase::createTable4() 90 | { 91 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 92 | QSqlQuery query(db); 93 | bool success = query.exec("create table userfriend(" 94 | "user_id char(11)," 95 | "user_friend char(500))"); 96 | if(success) 97 | { 98 | qDebug() << QObject::tr("数据库表4创建成功!"); 99 | return true; 100 | } 101 | else 102 | { 103 | 104 | return false; 105 | } 106 | } 107 | 108 | /*bool DataBase::createTable5() 109 | { 110 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 111 | QSqlQuery query(db); 112 | bool success = query.exec("create table message(" 113 | "user_id char(11)," 114 | "frdmessa char(50)," 115 | "talkmessa char(100))"); 116 | if(success) 117 | { 118 | qDebug() << QObject::tr("数据库表5创建成功!"); 119 | return true; 120 | } 121 | else 122 | { 123 | qDebug()< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | QT_BEGIN_NAMESPACE 46 | namespace Ui { class MainWindow; } 47 | QT_END_NAMESPACE 48 | 49 | class MainWindow : public QMainWindow 50 | { 51 | Q_OBJECT 52 | 53 | public: 54 | MainWindow(QWidget *parent = nullptr); 55 | ~MainWindow(); 56 | 57 | void dealMessage(QNChatMessage *messageW, QListWidgetItem *item, QString text, QString time, QNChatMessage::User_Type type); 58 | 59 | void dealMessageTime(QString curMsgTime); 60 | 61 | void initTCP(); 62 | void newConnect(); 63 | 64 | bool ifopen; 65 | QString nowid; 66 | 67 | protected: 68 | bool eventFilter(QObject *target, QEvent *event); 69 | 70 | private slots: // 客户端方法 71 | ////连接服务器 72 | QString getHostIpAddress(); 73 | 74 | void connectServer(); 75 | ////与服务器断开连接 76 | void disconnectServer(); 77 | ////接收服务器发送的数据 78 | void receiveData(); 79 | ////向服务器发送数据 80 | void send_message(); 81 | ////浏览文件 82 | void selectFile(); 83 | ////发送文件 84 | void sendFile(); 85 | ////更新文件发送进度 86 | void updateFileProgress(qint64); 87 | ////更新文件接收进度 88 | void updateFileProgress(); 89 | 90 | private slots: 91 | 92 | void initial_friendlist(); 93 | 94 | void initial_talklist(); 95 | 96 | void frdinform_display(); 97 | 98 | void delete_frd(); 99 | 100 | void set_top(); 101 | 102 | void delete_talk(); 103 | 104 | void talkto(); 105 | 106 | void mousePressEvent(QMouseEvent *event); 107 | 108 | void mouseMoveEvent(QMouseEvent *event); 109 | 110 | void mouseReleaseEvent(QMouseEvent *event); 111 | 112 | void on_pushButton_2_clicked(); 113 | 114 | void on_pushButton_clicked(); 115 | 116 | void on_pushButton_3_clicked(); 117 | 118 | void on_pushButton_4_clicked(); 119 | 120 | void on_pushButton_5_clicked(); 121 | 122 | void on_pushButton_7_clicked(); 123 | 124 | void on_pushButton_15_clicked(bool checked); 125 | 126 | void on_pushButton_6_clicked(); 127 | 128 | void on_pushButton_17_clicked(); 129 | 130 | void on_pushButton_19_clicked(); 131 | 132 | void on_pushButton_16_clicked(); 133 | 134 | void on_pushButton_8_clicked(bool checked); 135 | 136 | void on_pushButton_20_clicked(); 137 | 138 | void on_pushButton_23_clicked(); 139 | 140 | void on_lineEdit_2_textChanged(const QString &arg1); 141 | 142 | void on_pushButton_24_clicked(); 143 | 144 | void on_pushButton_11_clicked(); 145 | 146 | void on_commandLinkButton_clicked(); 147 | 148 | void on_pushButton_18_clicked(); 149 | 150 | void on_pushButton_22_clicked(); 151 | 152 | private: 153 | Ui::MainWindow *ui; 154 | 155 | // 客户端成员 156 | QString ip_address; 157 | QTcpSocket *tcpSocket; 158 | QTcpSocket *fileSocket; 159 | 160 | ///文件传送 161 | QFile *localFile; 162 | ///文件大小 163 | qint64 totalBytes; //文件总字节数 164 | qint64 bytesWritten; //已发送的字节数 165 | qint64 bytestoWrite; //尚未发送的字节数 166 | qint64 filenameSize; //文件名字的字节数 167 | qint64 bytesReceived; //接收的字节数 168 | ///每次发送数据大小 169 | qint64 perDataSize; 170 | QString filename; 171 | ///数据缓冲区 172 | QByteArray inBlock; 173 | QByteArray outBlock; 174 | 175 | ////系统时间 176 | QDateTime current_date_time; 177 | QString str_date_time; 178 | 179 | bool m_pressed; 180 | QPoint m_movePos; 181 | }; 182 | 183 | #endif // MAINWINDOW_H 184 | -------------------------------------------------------------------------------- /VictorServer/qtserver.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | QtServer 4 | 5 | 6 | 7 | 0 8 | 0 9 | 790 10 | 588 11 | 12 | 13 | 14 | Victor服务器 15 | 16 | 17 | 18 | 19 | 20 | 580 21 | 500 22 | 101 23 | 41 24 | 25 | 26 | 27 | 28 | 微软雅黑 29 | 10 30 | 31 | 32 | 33 | 发送文件 34 | 35 | 36 | 37 | 38 | 39 | 20 40 | 440 41 | 441 42 | 41 43 | 44 | 45 | 46 | 47 | 48 | 49 | 470 50 | 440 51 | 101 52 | 41 53 | 54 | 55 | 56 | 57 | 微软雅黑 58 | 10 59 | 60 | 61 | 62 | 发送 63 | 64 | 65 | 66 | 67 | 68 | 20 69 | 20 70 | 441 71 | 401 72 | 73 | 74 | 75 | 76 | 微软雅黑 77 | 78 | 79 | 80 | 81 | 82 | 83 | 20 84 | 500 85 | 441 86 | 41 87 | 88 | 89 | 90 | 91 | 92 | 93 | 470 94 | 500 95 | 101 96 | 41 97 | 98 | 99 | 100 | 101 | 微软雅黑 102 | 10 103 | 104 | 105 | 106 | 选择文件 107 | 108 | 109 | 110 | 111 | 112 | 500 113 | 160 114 | 251 115 | 51 116 | 117 | 118 | 119 | 120 | 微软雅黑 121 | 10 122 | 123 | 124 | 125 | 126 | 127 | 128 | 540 129 | 110 130 | 61 131 | 31 132 | 133 | 134 | 135 | 136 | 微软雅黑 137 | 10 138 | 139 | 140 | 141 | 连接数: 142 | 143 | 144 | 145 | 146 | 147 | 620 148 | 110 149 | 81 150 | 31 151 | 152 | 153 | 154 | 155 | 微软雅黑 156 | 10 157 | 158 | 159 | 160 | TextLabel 161 | 162 | 163 | 164 | 165 | 166 | 470 167 | 380 168 | 101 169 | 41 170 | 171 | 172 | 173 | 174 | 微软雅黑 175 | 10 176 | 177 | 178 | 179 | 清空 180 | 181 | 182 | 183 | 184 | 185 | 186 | 0 187 | 0 188 | 790 189 | 26 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtsinglecoreapplication.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | 42 | #include "qtsinglecoreapplication.h" 43 | #include "qtlocalpeer.h" 44 | 45 | /*! 46 | \class QtSingleCoreApplication qtsinglecoreapplication.h 47 | \brief A variant of the QtSingleApplication class for non-GUI applications. 48 | 49 | This class is a variant of QtSingleApplication suited for use in 50 | console (non-GUI) applications. It is an extension of 51 | QCoreApplication (instead of QApplication). It does not require 52 | the QtGui library. 53 | 54 | The API and usage is identical to QtSingleApplication, except that 55 | functions relating to the "activation window" are not present, for 56 | obvious reasons. Please refer to the QtSingleApplication 57 | documentation for explanation of the usage. 58 | 59 | A QtSingleCoreApplication instance can communicate to a 60 | QtSingleApplication instance if they share the same application 61 | id. Hence, this class can be used to create a light-weight 62 | command-line tool that sends commands to a GUI application. 63 | 64 | \sa QtSingleApplication 65 | */ 66 | 67 | /*! 68 | Creates a QtSingleCoreApplication object. The application identifier 69 | will be QCoreApplication::applicationFilePath(). \a argc and \a 70 | argv are passed on to the QCoreAppliation constructor. 71 | */ 72 | 73 | QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) 74 | : QCoreApplication(argc, argv) 75 | { 76 | peer = new QtLocalPeer(this); 77 | connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); 78 | } 79 | 80 | 81 | /*! 82 | Creates a QtSingleCoreApplication object with the application 83 | identifier \a appId. \a argc and \a argv are passed on to the 84 | QCoreAppliation constructor. 85 | */ 86 | QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) 87 | : QCoreApplication(argc, argv) 88 | { 89 | peer = new QtLocalPeer(this, appId); 90 | connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); 91 | } 92 | 93 | 94 | /*! 95 | Returns true if another instance of this application is running; 96 | otherwise false. 97 | 98 | This function does not find instances of this application that are 99 | being run by a different user (on Windows: that are running in 100 | another session). 101 | 102 | \sa sendMessage() 103 | */ 104 | 105 | bool QtSingleCoreApplication::isRunning() 106 | { 107 | return peer->isClient(); 108 | } 109 | 110 | 111 | /*! 112 | Tries to send the text \a message to the currently running 113 | instance. The QtSingleCoreApplication object in the running instance 114 | will emit the messageReceived() signal when it receives the 115 | message. 116 | 117 | This function returns true if the message has been sent to, and 118 | processed by, the current instance. If there is no instance 119 | currently running, or if the running instance fails to process the 120 | message within \a timeout milliseconds, this function return false. 121 | 122 | \sa isRunning(), messageReceived() 123 | */ 124 | 125 | bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) 126 | { 127 | return peer->sendMessage(message, timeout); 128 | } 129 | 130 | 131 | /*! 132 | Returns the application identifier. Two processes with the same 133 | identifier will be regarded as instances of the same application. 134 | */ 135 | 136 | QString QtSingleCoreApplication::id() const 137 | { 138 | return peer->applicationId(); 139 | } 140 | 141 | 142 | /*! 143 | \fn void QtSingleCoreApplication::messageReceived(const QString& message) 144 | 145 | This signal is emitted when the current instance receives a \a 146 | message from another instance of this application. 147 | 148 | \sa sendMessage() 149 | */ 150 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/regist.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "regist.h" 3 | #include "ui_regist.h" 4 | 5 | regist::regist(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::regist) 8 | { 9 | ui->setupUi(this); 10 | ui->lineEdit->setPlaceholderText(" 用户名"); 11 | ui->lineEdit_2->setPlaceholderText(" 密码"); 12 | ui->lineEdit_3->setPlaceholderText(" 手机号码"); 13 | ui->lineEdit_4->setPlaceholderText(" 再次输入密码"); 14 | ui->lineEdit_2->setEchoMode(QLineEdit::Password); 15 | ui->lineEdit_4->setEchoMode(QLineEdit::Password); 16 | ui->label_3->hide(); 17 | ui->label_4->hide(); 18 | ui->label_5->hide(); 19 | ui->label_6->hide(); 20 | ui->label_7->hide(); 21 | ui->widget->hide(); 22 | } 23 | 24 | regist::~regist() 25 | { 26 | delete ui; 27 | } 28 | 29 | void regist::mousePressEvent(QMouseEvent *event) 30 | { 31 | m_pressed = true; 32 | m_movePos = event->globalPos() - pos(); 33 | 34 | return QDialog::mousePressEvent(event); 35 | } 36 | void regist::mouseMoveEvent(QMouseEvent *event) 37 | { 38 | if (m_pressed && (event->buttons()== Qt::LeftButton) 39 | && (event->globalPos() - m_movePos).manhattanLength() > QApplication::startDragDistance()) 40 | { 41 | QPoint movePos = event->globalPos() - m_movePos; 42 | this->move(movePos); 43 | m_movePos = event->globalPos() - pos(); 44 | } 45 | 46 | return QDialog::mouseMoveEvent(event); 47 | } 48 | void regist::mouseReleaseEvent(QMouseEvent *event) 49 | { 50 | m_pressed = false; 51 | 52 | return QDialog::mouseReleaseEvent(event); 53 | } 54 | 55 | 56 | void regist::on_pushButton_clicked() 57 | { 58 | qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); 59 | int flr=1; 60 | for(int i=0;i<5;i++) 61 | { 62 | if(ifregist[i]==0) 63 | { 64 | flr=0; 65 | break; 66 | } 67 | } 68 | if(flr==0)return; 69 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 70 | QSqlQuery query(db); 71 | QString name = ui->lineEdit->text(); 72 | QString password = ui->lineEdit_2->text(); 73 | QString password2 = ui->lineEdit_4->text(); 74 | QString phone = ui->lineEdit_3->text(); 75 | int sex=1; 76 | int search=1; 77 | int add=2; 78 | int lookover=1; 79 | QString toux=":/touxiang/Simpson.jpg"; 80 | 81 | QString id; 82 | bool flagg=false; 83 | while(flagg==false) 84 | { 85 | flagg=true; 86 | int idnumber=qrand()%10000; 87 | id=QString::number(idnumber,10); 88 | query.exec("select user_id from user_infrom"); 89 | while(query.next()) 90 | { 91 | QString oldid=query.value(0).toString(); 92 | if(id==oldid) 93 | { 94 | flagg=false; 95 | break; 96 | } 97 | } 98 | } 99 | 100 | QString str = QString("insert into user_inform(user_id, user_password, phonenumber) values('%1', '%2', '%3')").arg(id).arg(password).arg(phone); 101 | QString str2 = QString("insert into userdata(user_id,user_name,user_sex,phonenumber,cansearch,canlookover,addway,touxiang) values('%1','%2','%3','%4','%5','%6','%7','%8')").arg(id).arg(name).arg(sex).arg(phone).arg(search).arg(lookover).arg(add).arg(toux); 102 | QString str3 = QString("insert into userfriend(user_id) values('%1')").arg(id); 103 | QString str4 = QString("insert into talklist(user_id) values('%1')").arg(id); 104 | bool flag=query.exec(str); 105 | bool flag2=query.exec(str2); 106 | bool flag3=query.exec(str3); 107 | bool flag4=query.exec(str4); 108 | if(flag&&flag2&&flag3&&flag4) 109 | { 110 | ui->widget->show(); 111 | ui->label_10->setText(id); 112 | ui->label_10->adjustSize(); 113 | int a=ui->label_10->width(); 114 | int b=ui->label_10->y(); 115 | ui->label_10->move(260-a/2,b); 116 | } 117 | else QMessageBox::warning(this,"注册失败","请检查你的输入格式"); 118 | } 119 | 120 | void regist::on_lineEdit_4_editingFinished() 121 | { 122 | QString password = ui->lineEdit_2->text(); 123 | QString password2 = ui->lineEdit_4->text(); 124 | if(password!=password2) 125 | { 126 | ifregist[0]=0; 127 | ui->label_5->show(); 128 | ui->lineEdit_2->clear(); 129 | ui->lineEdit_4->clear(); 130 | return; 131 | } 132 | else 133 | { 134 | ifregist[0]=1; 135 | ui->label_5->hide(); 136 | } 137 | } 138 | 139 | void regist::on_lineEdit_2_editingFinished() 140 | { 141 | QString password = ui->lineEdit_2->text(); 142 | if(password.isEmpty()) 143 | { 144 | ifregist[1]=0; 145 | ui->label_4->show(); 146 | return; 147 | } 148 | else 149 | { 150 | ifregist[1]=1; 151 | ui->label_4->hide(); 152 | } 153 | } 154 | 155 | void regist::on_lineEdit_editingFinished() 156 | { 157 | QString name = ui->lineEdit->text(); 158 | if(name.isEmpty()) 159 | { 160 | ifregist[2]=0; 161 | ui->label_3->show(); 162 | return; 163 | } 164 | else 165 | { 166 | ifregist[2]=1; 167 | ui->label_3->hide(); 168 | } 169 | } 170 | 171 | void regist::on_lineEdit_3_editingFinished() 172 | { 173 | QString phone = ui->lineEdit_3->text(); 174 | if(phone.isEmpty()) 175 | { 176 | ifregist[3]=0; 177 | ui->label_6->show(); 178 | return; 179 | } 180 | else 181 | { 182 | ifregist[3]=1; 183 | ui->label_6->hide(); 184 | } 185 | if(phone.length()!=11) 186 | { 187 | ifregist[4]=0; 188 | ui->label_7->show(); 189 | return; 190 | } 191 | else 192 | { 193 | ifregist[4]=1; 194 | ui->label_7->hide(); 195 | } 196 | } 197 | 198 | void regist::on_pushButton_2_clicked() 199 | { 200 | close(); 201 | } 202 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/login.cpp: -------------------------------------------------------------------------------- 1 | #include "login.h" 2 | #include "ui_login.h" 3 | #include "mainwindow.h" 4 | #include "loginlose.h" 5 | #include "regist.h" 6 | #include "pwback.h" 7 | 8 | login::login(QWidget *parent) : 9 | QDialog(parent), 10 | ui(new Ui::login) 11 | { 12 | ui->setupUi(this); 13 | 14 | setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint); 15 | setFixedSize(this->width(),this->height()); 16 | 17 | setAttribute(Qt::WA_TranslucentBackground); 18 | QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); 19 | effect->setOffset(0, 0); //设置向哪个方向产生阴影效果(dx,dy),特别地,(0,0)代表向四周发散 20 | effect->setColor(Qt::gray); //设置阴影颜色,也可以setColor(QColor(220,220,220)) 21 | effect->setBlurRadius(20); //设定阴影的模糊半径,数值越大越模糊 22 | ui->frame->setGraphicsEffect(effect); 23 | 24 | ui->lineEdit->setPlaceholderText(" 用户名"); 25 | ui->lineEdit_2->setPlaceholderText(" 密码"); 26 | ui->lineEdit_2->setEchoMode(QLineEdit::Password); 27 | 28 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 29 | QSqlQuery query(db); 30 | QString idd,pwd; 31 | int jizhu=0; 32 | query.exec("select * from loginuser"); 33 | if(query.next()) 34 | { 35 | idd=query.value(0).toString(); 36 | pwd=query.value(1).toString(); 37 | jizhu=query.value(2).toInt(); 38 | } 39 | ui->lineEdit->setText(idd); 40 | if(jizhu==1) 41 | { 42 | ui->lineEdit_2->setText(pwd); 43 | ui->checkBox_2->setCheckState(Qt::Checked); 44 | } 45 | query.exec(QString("select touxiang from userdata where user_id='%1'").arg(idd)); 46 | QString toux; 47 | if(query.next()) 48 | { 49 | toux=query.value(0).toString(); 50 | } 51 | QPixmap img1; 52 | img1.load(toux); 53 | if(idd.isEmpty()) 54 | img1.load(":/image/victoricon2.png"); 55 | QPixmap pixMap= img1.scaled(90,90, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 56 | pixMap = PixmapToRound(pixMap, 45); 57 | ui->label_7->setPixmap(pixMap); 58 | } 59 | 60 | login::~login() 61 | { 62 | delete ui; 63 | } 64 | 65 | void login::mousePressEvent(QMouseEvent *event) 66 | { 67 | m_pressed = true; 68 | m_movePos = event->globalPos() - pos(); 69 | 70 | return QDialog::mousePressEvent(event); 71 | } 72 | void login::mouseMoveEvent(QMouseEvent *event) 73 | { 74 | if (m_pressed && (event->buttons()== Qt::LeftButton) 75 | && (event->globalPos() - m_movePos).manhattanLength() > QApplication::startDragDistance()) 76 | { 77 | QPoint movePos = event->globalPos() - m_movePos; 78 | this->move(movePos); 79 | m_movePos = event->globalPos() - pos(); 80 | } 81 | 82 | return QDialog::mouseMoveEvent(event); 83 | } 84 | void login::mouseReleaseEvent(QMouseEvent *event) 85 | { 86 | m_pressed = false; 87 | 88 | return QDialog::mouseReleaseEvent(event); 89 | } 90 | 91 | QString login::getid() 92 | { 93 | return trueid; 94 | } 95 | 96 | QPixmap login::PixmapToRound(const QPixmap &src, int radius) 97 | { 98 | if (src.isNull()) { 99 | return QPixmap(); 100 | } 101 | QSize size(2*radius, 2*radius); 102 | QBitmap mask(size); 103 | QPainter painter(&mask); 104 | painter.setRenderHint(QPainter::Antialiasing); 105 | painter.setRenderHint(QPainter::SmoothPixmapTransform); 106 | painter.fillRect(0, 0, size.width(), size.height(), Qt::white); 107 | painter.setBrush(QColor(0, 0, 0)); 108 | painter.drawRoundedRect(0, 0, size.width(), size.height(), 99, 99); 109 | QPixmap image = src.scaled(size); 110 | image.setMask(mask); 111 | return image; 112 | } 113 | 114 | void login::on_pushButton_3_clicked() 115 | { 116 | QString id=ui->lineEdit->text(); 117 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 118 | QSqlQuery query(db); 119 | QString str=QString("select user_password from user_inform where user_id='%1'").arg(id); 120 | query.exec(str); 121 | QString truepw; 122 | if(query.next()) 123 | { 124 | truepw = query.value(0).toString(); 125 | } 126 | if(ui->lineEdit_2->text()!=""&&ui->lineEdit_2->text()==truepw) 127 | { //加trimmed()可以去除用户名字符串开头和结尾的空白字符 128 | trueid=id; 129 | int rem=0; 130 | if(ui->checkBox_2->isChecked()) 131 | rem=1; 132 | query.exec("delete from loginuser"); 133 | QString str1=QString("insert into loginuser(user_id,user_password,ifrem) values('%1','%2','%3')").arg(id).arg(truepw).arg(rem); 134 | query.exec(str1); 135 | accept(); 136 | } 137 | else 138 | { 139 | loginlose a; 140 | a.exec(); 141 | ui->lineEdit_2->clear(); 142 | ui->lineEdit_2->setFocus();//将光标移到用户名框内 143 | } 144 | } 145 | 146 | void login::on_pushButton_clicked() 147 | { 148 | close(); 149 | } 150 | 151 | void login::on_pushButton_2_clicked() 152 | { 153 | showMinimized(); 154 | } 155 | 156 | void login::on_pushButton_4_clicked() 157 | { 158 | regist a; 159 | a.exec(); 160 | } 161 | 162 | void login::on_pushButton_5_clicked() 163 | { 164 | pwback a; 165 | a.exec(); 166 | } 167 | 168 | void login::on_lineEdit_editingFinished() 169 | { 170 | QString idd=ui->lineEdit->text(); 171 | QSqlDatabase db=QSqlDatabase::database("sqlite1"); 172 | QSqlQuery query(db); 173 | query.exec(QString("select touxiang from userdata where user_id='%1'").arg(idd)); 174 | QString toux; 175 | if(query.next()) 176 | { 177 | toux=query.value(0).toString(); 178 | } 179 | QPixmap img1; 180 | img1.load(toux); 181 | 182 | //100,100为QLabel的宽高 183 | QPixmap pixMap= img1.scaled(90,90, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 184 | //50为圆形的半径 185 | pixMap = PixmapToRound(pixMap, 45); 186 | 187 | ui->label_7->setPixmap(pixMap); 188 | } 189 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtlockedfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #include "qtlockedfile.h" 42 | 43 | /*! 44 | \class QtLockedFile 45 | 46 | \brief The QtLockedFile class extends QFile with advisory locking 47 | functions. 48 | 49 | A file may be locked in read or write mode. Multiple instances of 50 | \e QtLockedFile, created in multiple processes running on the same 51 | machine, may have a file locked in read mode. Exactly one instance 52 | may have it locked in write mode. A read and a write lock cannot 53 | exist simultaneously on the same file. 54 | 55 | The file locks are advisory. This means that nothing prevents 56 | another process from manipulating a locked file using QFile or 57 | file system functions offered by the OS. Serialization is only 58 | guaranteed if all processes that access the file use 59 | QLockedFile. Also, while holding a lock on a file, a process 60 | must not open the same file again (through any API), or locks 61 | can be unexpectedly lost. 62 | 63 | The lock provided by an instance of \e QtLockedFile is released 64 | whenever the program terminates. This is true even when the 65 | program crashes and no destructors are called. 66 | */ 67 | 68 | /*! \enum QtLockedFile::LockMode 69 | 70 | This enum describes the available lock modes. 71 | 72 | \value ReadLock A read lock. 73 | \value WriteLock A write lock. 74 | \value NoLock Neither a read lock nor a write lock. 75 | */ 76 | 77 | /*! 78 | Constructs an unlocked \e QtLockedFile object. This constructor 79 | behaves in the same way as \e QFile::QFile(). 80 | 81 | \sa QFile::QFile() 82 | */ 83 | QtLockedFile::QtLockedFile() 84 | : QFile() 85 | { 86 | #ifdef Q_OS_WIN 87 | wmutex = 0; 88 | rmutex = 0; 89 | #endif 90 | m_lock_mode = NoLock; 91 | } 92 | 93 | /*! 94 | Constructs an unlocked QtLockedFile object with file \a name. This 95 | constructor behaves in the same way as \e QFile::QFile(const 96 | QString&). 97 | 98 | \sa QFile::QFile() 99 | */ 100 | QtLockedFile::QtLockedFile(const QString &name) 101 | : QFile(name) 102 | { 103 | #ifdef Q_OS_WIN 104 | wmutex = 0; 105 | rmutex = 0; 106 | #endif 107 | m_lock_mode = NoLock; 108 | } 109 | 110 | /*! 111 | Opens the file in OpenMode \a mode. 112 | 113 | This is identical to QFile::open(), with the one exception that the 114 | Truncate mode flag is disallowed. Truncation would conflict with the 115 | advisory file locking, since the file would be modified before the 116 | write lock is obtained. If truncation is required, use resize(0) 117 | after obtaining the write lock. 118 | 119 | Returns true if successful; otherwise false. 120 | 121 | \sa QFile::open(), QFile::resize() 122 | */ 123 | bool QtLockedFile::open(OpenMode mode) 124 | { 125 | if (mode & QIODevice::Truncate) { 126 | qWarning("QtLockedFile::open(): Truncate mode not allowed."); 127 | return false; 128 | } 129 | return QFile::open(mode); 130 | } 131 | 132 | /*! 133 | Returns \e true if this object has a in read or write lock; 134 | otherwise returns \e false. 135 | 136 | \sa lockMode() 137 | */ 138 | bool QtLockedFile::isLocked() const 139 | { 140 | return m_lock_mode != NoLock; 141 | } 142 | 143 | /*! 144 | Returns the type of lock currently held by this object, or \e 145 | QtLockedFile::NoLock. 146 | 147 | \sa isLocked() 148 | */ 149 | QtLockedFile::LockMode QtLockedFile::lockMode() const 150 | { 151 | return m_lock_mode; 152 | } 153 | 154 | /*! 155 | \fn bool QtLockedFile::lock(LockMode mode, bool block = true) 156 | 157 | Obtains a lock of type \a mode. The file must be opened before it 158 | can be locked. 159 | 160 | If \a block is true, this function will block until the lock is 161 | aquired. If \a block is false, this function returns \e false 162 | immediately if the lock cannot be aquired. 163 | 164 | If this object already has a lock of type \a mode, this function 165 | returns \e true immediately. If this object has a lock of a 166 | different type than \a mode, the lock is first released and then a 167 | new lock is obtained. 168 | 169 | This function returns \e true if, after it executes, the file is 170 | locked by this object, and \e false otherwise. 171 | 172 | \sa unlock(), isLocked(), lockMode() 173 | */ 174 | 175 | /*! 176 | \fn bool QtLockedFile::unlock() 177 | 178 | Releases a lock. 179 | 180 | If the object has no lock, this function returns immediately. 181 | 182 | This function returns \e true if, after it executes, the file is 183 | not locked by this object, and \e false otherwise. 184 | 185 | \sa lock(), isLocked(), lockMode() 186 | */ 187 | 188 | /*! 189 | \fn QtLockedFile::~QtLockedFile() 190 | 191 | Destroys the \e QtLockedFile object. If any locks were held, they 192 | are released. 193 | */ 194 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtlockedfile_win.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #include "qtlockedfile.h" 42 | #include 43 | #include 44 | 45 | #define MUTEX_PREFIX "QtLockedFile mutex " 46 | // Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS 47 | #define MAX_READERS MAXIMUM_WAIT_OBJECTS 48 | 49 | #if QT_VERSION >= 0x050000 50 | #define QT_WA(unicode, ansi) unicode 51 | #endif 52 | 53 | Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) 54 | { 55 | if (mutexname.isEmpty()) { 56 | QFileInfo fi(*this); 57 | mutexname = QString::fromLatin1(MUTEX_PREFIX) 58 | + fi.absoluteFilePath().toLower(); 59 | } 60 | QString mname(mutexname); 61 | if (idx >= 0) 62 | mname += QString::number(idx); 63 | 64 | Qt::HANDLE mutex; 65 | if (doCreate) { 66 | QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, 67 | { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); 68 | if (!mutex) { 69 | qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); 70 | return 0; 71 | } 72 | } 73 | else { 74 | QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, 75 | { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); 76 | if (!mutex) { 77 | if (GetLastError() != ERROR_FILE_NOT_FOUND) 78 | qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); 79 | return 0; 80 | } 81 | } 82 | return mutex; 83 | } 84 | 85 | bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) 86 | { 87 | Q_ASSERT(mutex); 88 | DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); 89 | switch (res) { 90 | case WAIT_OBJECT_0: 91 | case WAIT_ABANDONED: 92 | return true; 93 | break; 94 | case WAIT_TIMEOUT: 95 | break; 96 | default: 97 | qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); 98 | } 99 | return false; 100 | } 101 | 102 | 103 | 104 | bool QtLockedFile::lock(LockMode mode, bool block) 105 | { 106 | if (!isOpen()) { 107 | qWarning("QtLockedFile::lock(): file is not opened"); 108 | return false; 109 | } 110 | 111 | if (mode == NoLock) 112 | return unlock(); 113 | 114 | if (mode == m_lock_mode) 115 | return true; 116 | 117 | if (m_lock_mode != NoLock) 118 | unlock(); 119 | 120 | if (!wmutex && !(wmutex = getMutexHandle(-1, true))) 121 | return false; 122 | 123 | if (!waitMutex(wmutex, block)) 124 | return false; 125 | 126 | if (mode == ReadLock) { 127 | int idx = 0; 128 | for (; idx < MAX_READERS; idx++) { 129 | rmutex = getMutexHandle(idx, false); 130 | if (!rmutex || waitMutex(rmutex, false)) 131 | break; 132 | CloseHandle(rmutex); 133 | } 134 | bool ok = true; 135 | if (idx >= MAX_READERS) { 136 | qWarning("QtLockedFile::lock(): too many readers"); 137 | rmutex = 0; 138 | ok = false; 139 | } 140 | else if (!rmutex) { 141 | rmutex = getMutexHandle(idx, true); 142 | if (!rmutex || !waitMutex(rmutex, false)) 143 | ok = false; 144 | } 145 | if (!ok && rmutex) { 146 | CloseHandle(rmutex); 147 | rmutex = 0; 148 | } 149 | ReleaseMutex(wmutex); 150 | if (!ok) 151 | return false; 152 | } 153 | else { 154 | Q_ASSERT(rmutexes.isEmpty()); 155 | for (int i = 0; i < MAX_READERS; i++) { 156 | Qt::HANDLE mutex = getMutexHandle(i, false); 157 | if (mutex) 158 | rmutexes.append(mutex); 159 | } 160 | if (rmutexes.size()) { 161 | DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), 162 | TRUE, block ? INFINITE : 0); 163 | if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { 164 | if (res != WAIT_TIMEOUT) 165 | qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); 166 | m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky 167 | unlock(); 168 | return false; 169 | } 170 | } 171 | } 172 | 173 | m_lock_mode = mode; 174 | return true; 175 | } 176 | 177 | bool QtLockedFile::unlock() 178 | { 179 | if (!isOpen()) { 180 | qWarning("QtLockedFile::unlock(): file is not opened"); 181 | return false; 182 | } 183 | 184 | if (!isLocked()) 185 | return true; 186 | 187 | if (m_lock_mode == ReadLock) { 188 | ReleaseMutex(rmutex); 189 | CloseHandle(rmutex); 190 | rmutex = 0; 191 | } 192 | else { 193 | foreach(Qt::HANDLE mutex, rmutexes) { 194 | ReleaseMutex(mutex); 195 | CloseHandle(mutex); 196 | } 197 | rmutexes.clear(); 198 | ReleaseMutex(wmutex); 199 | } 200 | 201 | m_lock_mode = QtLockedFile::NoLock; 202 | return true; 203 | } 204 | 205 | QtLockedFile::~QtLockedFile() 206 | { 207 | if (isOpen()) 208 | unlock(); 209 | if (wmutex) 210 | CloseHandle(wmutex); 211 | } 212 | -------------------------------------------------------------------------------- /VictorServer/qtserver.cpp: -------------------------------------------------------------------------------- 1 | #include "qtserver.h" 2 | #include "ui_qtserver.h" 3 | 4 | QtServer::QtServer(QWidget *parent) 5 | : QMainWindow(parent) 6 | , ui(new Ui::QtServer) 7 | { 8 | ui->setupUi(this); 9 | 10 | count=0; 11 | setWindowFlags(this->windowFlags() | Qt::WindowMinMaxButtonsHint); 12 | ui->labelNum->setText(QString("%1").arg(count)); 13 | this->server = new TcpServer(this); 14 | ///开启监听 15 | this->server->listen(QHostAddress::Any,6666); 16 | connect(this->server,SIGNAL(newConnection()),this,SLOT(acceptConnection())); 17 | 18 | ///文件传送套接字 19 | //this->filesocket = new QTcpSocket(this); 20 | //this->fileserver = new TcpServer(this); 21 | //this->fileserver->listen(QHostAddress::Any,8888); 22 | //connect(this->fileserver,SIGNAL(newConnection()),this,SLOT(acceptFileConnection())); 23 | 24 | //// 文件传送相关变量初始化 25 | bytesReceived = 0; 26 | totalBytes = 0; 27 | filenameSize = 0; 28 | connect(ui->btnSend,SIGNAL(clicked()),this, SLOT(sendDataSlot())); 29 | connect(ui->btnClear,SIGNAL(clicked()),this, SLOT(clearData())); 30 | } 31 | 32 | QtServer::~QtServer() 33 | { 34 | delete ui; 35 | } 36 | 37 | void QtServer::showConnection(int sockDesc) 38 | 39 | { 40 | count++; 41 | /* add socket object that join in */ 42 | ui->comboBoxObj->addItem(QString("%1").arg(sockDesc), sockDesc); 43 | 44 | /* change connect number while connection is connecting */ 45 | ui->labelNum->setText(QString("%1").arg(count)); 46 | } 47 | 48 | 49 | 50 | void QtServer::showDisconnection(int sockDesc) 51 | { 52 | count--; 53 | 54 | /* refresh combobox */ 55 | 56 | ui->comboBoxObj->clear(); 57 | int index = ui->comboBoxObj->findData(sockDesc); 58 | 59 | ui->comboBoxObj->removeItem(index); 60 | /* change connect number while connection is disconnecting */ 61 | 62 | ui->labelNum->setText(QString("%1").arg(count)); 63 | 64 | } 65 | 66 | void QtServer::sendDataSlot(void) 67 | 68 | { 69 | 70 | /* if send message is null return */ 71 | 72 | if (ui->lineEditMsg->text().isEmpty()) { 73 | 74 | QMessageBox::information(Q_NULLPTR, QString("注意"), QString("发送内容不能为空!"), QMessageBox::Yes); 75 | 76 | return ; 77 | 78 | } 79 | 80 | /* send original data */ 81 | 82 | for(int i=0;icomboBoxObj->count();i++) 83 | { 84 | qDebug()<comboBoxObj->itemText(i).toInt(), ui->lineEditMsg->text().toUtf8()); 86 | } 87 | 88 | ui->lineEditMsg->setText(""); 89 | 90 | } 91 | void QtServer::recvData(const QString &ip, const QByteArray &data) 92 | 93 | { 94 | 95 | QString msg; 96 | 97 | /* add ip address string to displaying string */ 98 | 99 | 100 | /* choose data format to display */ 101 | 102 | msg.prepend(data) + "\n"; 103 | /* send back data */ 104 | for(int i=0;icomboBoxObj->count();i++) 105 | { 106 | emit sendData(ui->comboBoxObj->itemText(i).toInt(), msg.toUtf8()); 107 | } 108 | ui->textBrowser->append(msg); 109 | } 110 | 111 | void QtServer::clearData(void) 112 | 113 | { 114 | ui->textBrowser->clear(); 115 | } 116 | 117 | /*void QtServer::acceptFileConnection() 118 | { 119 | bytesWritten = 0; 120 | ///每次发送数据大小为64kb 121 | perDataSize = 64*1024; 122 | this->filesocket = this->fileserver->nextPendingConnection(); 123 | ///接受文件 124 | connect(filesocket,SIGNAL(readyRead()),this,SLOT(updateFileProgress())); 125 | connect(filesocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(updateFileProgress(qint64))); 126 | connect(filesocket,SIGNAL(bytesWritten(qint64)),this,SLOT(displayError(QAbstractSocket::SocketError socketError))); 127 | } 128 | 129 | void QtServer::updateFileProgress() 130 | { 131 | QDataStream inFile(this->filesocket); 132 | inFile.setVersion(QDataStream::Qt_4_8); 133 | 134 | ///如果接收到的数据小于16个字节,保存到来的文件头结构 135 | if(bytesReceived <= sizeof(qint64)*2) 136 | { 137 | if((filesocket->bytesAvailable()>=(sizeof(qint64))*2) && (filenameSize==0)) 138 | { 139 | inFile>>totalBytes>>filenameSize; 140 | bytesReceived += sizeof(qint64)*2; 141 | } 142 | if((filesocket->bytesAvailable()>=filenameSize) && (filenameSize != 0)) 143 | { 144 | inFile>>filename; 145 | bytesReceived += filenameSize; 146 | ////接收的文件放在指定目录下 147 | filename = "ClientData/"+filename; 148 | localFile = new QFile(filename); 149 | if(!localFile->open(QFile::WriteOnly)) 150 | { 151 | qDebug()<<"Server::open file error!"; 152 | return; 153 | } 154 | } 155 | else 156 | return; 157 | } 158 | /////如果接收的数据小于总数据,则写入文件 159 | if(bytesReceived < totalBytes) 160 | { 161 | bytesReceived += filesocket->bytesAvailable(); 162 | inBlock = filesocket->readAll(); 163 | localFile->write(inBlock); 164 | inBlock.resize(0); 165 | } 166 | ////更新进度条显示 167 | //this->ui->progressBar_fileProgress->setMaximum(totalBytes); 168 | //this->ui->progressBar_fileProgress->setValue(bytesReceived); 169 | ////数据接收完成时 170 | if(bytesReceived == totalBytes) 171 | { 172 | this->ui->browser->append("Receive file successfully!"); 173 | bytesReceived = 0; 174 | totalBytes = 0; 175 | filenameSize = 0; 176 | localFile->close(); 177 | //filesocket->close(); 178 | } 179 | } 180 | 181 | void QtServer::selectFile() 182 | { 183 | filesocket->open(QIODevice::WriteOnly); 184 | ////文件传送进度更新 185 | connect(filesocket,SIGNAL(bytesWritten(qint64)),this,SLOT(updateFileProgress(qint64))); 186 | 187 | this->filename = QFileDialog::getOpenFileName(this,"Open a file","/","files (*)"); 188 | ui->lineEdit_fileName->setText(filename); 189 | } 190 | 191 | void QtServer::sendFile() 192 | { 193 | this->localFile = new QFile(filename); 194 | if(!localFile->open(QFile::ReadOnly)) 195 | { 196 | qDebug()<<"发送文件失败"; 197 | return; 198 | } 199 | ///获取文件大小 200 | this->totalBytes = localFile->size(); 201 | QDataStream sendout(&outBlock,QIODevice::WriteOnly); 202 | sendout.setVersion(QDataStream::Qt_4_8); 203 | QString currentFileName = filename.right(filename.size()-filename.lastIndexOf('/')-1); 204 | 205 | ////保留总代大小信息空间、文件名大小信息空间、文件名 206 | sendout<seek(0); 209 | sendout<write(outBlock); 212 | outBlock.resize(0); 213 | } 214 | 215 | void QtServer::updateFileProgress(qint64 numBytes) 216 | { 217 | ////已经发送的数据大小 218 | bytesWritten += (int)numBytes; 219 | 220 | ////如果已经发送了数据 221 | if(bytestoWrite > 0) 222 | { 223 | outBlock = localFile->read(qMin(bytestoWrite,perDataSize)); 224 | ///发送完一次数据后还剩余数据的大小 225 | bytestoWrite -= ((int)filesocket->write(outBlock)); 226 | ///清空发送缓冲区 227 | outBlock.resize(0); 228 | } 229 | else 230 | localFile->close(); 231 | 232 | ////如果发送完毕 233 | if(bytesWritten == totalBytes) 234 | { 235 | localFile->close(); 236 | //filesocket->close(); 237 | } 238 | }*/ 239 | 240 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/qtlocalpeer.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | 42 | #include "qtlocalpeer.h" 43 | #include 44 | #include 45 | 46 | #if defined(Q_OS_WIN) 47 | #include 48 | #include 49 | typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); 50 | static PProcessIdToSessionId pProcessIdToSessionId = 0; 51 | #endif 52 | #if defined(Q_OS_UNIX) 53 | #include 54 | #include 55 | #include 56 | #endif 57 | 58 | namespace QtLP_Private { 59 | #include "qtlockedfile.cpp" 60 | #if defined(Q_OS_WIN) 61 | #include "qtlockedfile_win.cpp" 62 | #else 63 | #include "qtlockedfile_unix.cpp" 64 | #endif 65 | } 66 | 67 | const char* QtLocalPeer::ack = "ack"; 68 | 69 | QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) 70 | : QObject(parent), id(appId) 71 | { 72 | QString prefix = id; 73 | if (id.isEmpty()) { 74 | id = QCoreApplication::applicationFilePath(); 75 | #if defined(Q_OS_WIN) 76 | id = id.toLower(); 77 | #endif 78 | prefix = id.section(QLatin1Char('/'), -1); 79 | } 80 | prefix.remove(QRegExp("[^a-zA-Z]")); 81 | prefix.truncate(6); 82 | 83 | QByteArray idc = id.toUtf8(); 84 | quint16 idNum = qChecksum(idc.constData(), idc.size()); 85 | socketName = QLatin1String("qtsingleapp-") + prefix 86 | + QLatin1Char('-') + QString::number(idNum, 16); 87 | 88 | #if defined(Q_OS_WIN) 89 | if (!pProcessIdToSessionId) { 90 | QLibrary lib("kernel32"); 91 | pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); 92 | } 93 | if (pProcessIdToSessionId) { 94 | DWORD sessionId = 0; 95 | pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); 96 | socketName += QLatin1Char('-') + QString::number(sessionId, 16); 97 | } 98 | #else 99 | socketName += QLatin1Char('-') + QString::number(::getuid(), 16); 100 | #endif 101 | 102 | server = new QLocalServer(this); 103 | QString lockName = QDir(QDir::tempPath()).absolutePath() 104 | + QLatin1Char('/') + socketName 105 | + QLatin1String("-lockfile"); 106 | lockFile.setFileName(lockName); 107 | lockFile.open(QIODevice::ReadWrite); 108 | } 109 | 110 | 111 | 112 | bool QtLocalPeer::isClient() 113 | { 114 | if (lockFile.isLocked()) 115 | return false; 116 | 117 | if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) 118 | return true; 119 | 120 | bool res = server->listen(socketName); 121 | #if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) 122 | // ### Workaround 123 | if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { 124 | QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); 125 | res = server->listen(socketName); 126 | } 127 | #endif 128 | if (!res) 129 | qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); 130 | QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); 131 | return false; 132 | } 133 | 134 | 135 | bool QtLocalPeer::sendMessage(const QString &message, int timeout) 136 | { 137 | if (!isClient()) 138 | return false; 139 | 140 | QLocalSocket socket; 141 | bool connOk = false; 142 | for(int i = 0; i < 2; i++) { 143 | // Try twice, in case the other instance is just starting up 144 | socket.connectToServer(socketName); 145 | connOk = socket.waitForConnected(timeout/2); 146 | if (connOk || i) 147 | break; 148 | int ms = 250; 149 | #if defined(Q_OS_WIN) 150 | Sleep(DWORD(ms)); 151 | #else 152 | struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; 153 | nanosleep(&ts, NULL); 154 | #endif 155 | } 156 | if (!connOk) 157 | return false; 158 | 159 | QByteArray uMsg(message.toUtf8()); 160 | QDataStream ds(&socket); 161 | ds.writeBytes(uMsg.constData(), uMsg.size()); 162 | bool res = socket.waitForBytesWritten(timeout); 163 | if (res) { 164 | res &= socket.waitForReadyRead(timeout); // wait for ack 165 | if (res) 166 | res &= (socket.read(qstrlen(ack)) == ack); 167 | } 168 | return res; 169 | } 170 | 171 | 172 | void QtLocalPeer::receiveConnection() 173 | { 174 | QLocalSocket* socket = server->nextPendingConnection(); 175 | if (!socket) 176 | return; 177 | 178 | while (socket->bytesAvailable() < (int)sizeof(quint32)) 179 | socket->waitForReadyRead(); 180 | QDataStream ds(socket); 181 | QByteArray uMsg; 182 | quint32 remaining; 183 | ds >> remaining; 184 | uMsg.resize(remaining); 185 | int got = 0; 186 | char* uMsgBuf = uMsg.data(); 187 | do { 188 | got = ds.readRawData(uMsgBuf, remaining); 189 | remaining -= got; 190 | uMsgBuf += got; 191 | } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); 192 | if (got < 0) { 193 | qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); 194 | delete socket; 195 | return; 196 | } 197 | QString message(QString::fromUtf8(uMsg)); 198 | socket->write(ack, qstrlen(ack)); 199 | socket->waitForBytesWritten(1000); 200 | socket->waitForDisconnected(1000); // make sure client reads ack 201 | delete socket; 202 | emit messageReceived(message); //### (might take a long time to return) 203 | } 204 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/changepw.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | changepw 4 | 5 | 6 | 7 | 0 8 | 0 9 | 522 10 | 620 11 | 12 | 13 | 14 | 修改密码 15 | 16 | 17 | 18 | :/image/victoricon2.png:/image/victoricon2.png 19 | 20 | 21 | 22 | 23 | 0 24 | 0 25 | 521 26 | 621 27 | 28 | 29 | 30 | QFrame::StyledPanel 31 | 32 | 33 | QFrame::Raised 34 | 35 | 36 | 37 | 38 | 0 39 | 0 40 | 521 41 | 620 42 | 43 | 44 | 45 | background-color: rgb(255, 255, 255); 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 73 55 | 100 56 | 331 57 | 31 58 | 59 | 60 | 61 | 62 | 微软雅黑 63 | 10 64 | 65 | 66 | 67 | <html><head/><body><p>请谨慎填写你的新密码。</p></body></html> 68 | 69 | 70 | 71 | 72 | 73 | 73 74 | 220 75 | 371 76 | 51 77 | 78 | 79 | 80 | 81 | 微软雅黑 82 | 12 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 73 93 | 40 94 | 251 95 | 51 96 | 97 | 98 | 99 | 100 | 微软雅黑 101 | 20 102 | 50 103 | false 104 | 105 | 106 | 107 | <html><head/><body><p>修改密码</p></body></html> 108 | 109 | 110 | 111 | 112 | 113 | 73 114 | 505 115 | 371 116 | 61 117 | 118 | 119 | 120 | 121 | 微软雅黑 122 | 12 123 | 50 124 | false 125 | 126 | 127 | 128 | QPushButton{border-style:none;background-color: rgb(89, 169, 255);color: rgb(255, 255, 255);} 129 | QPushButton:hover{background: rgb(100, 185, 255);color: rgb(255, 255, 255);} 130 | 131 | 132 | 133 | 修改 134 | 135 | 136 | 137 | 138 | 139 | 73 140 | 310 141 | 371 142 | 51 143 | 144 | 145 | 146 | 147 | 微软雅黑 148 | 12 149 | 150 | 151 | 152 | 153 | 154 | 155 | 73 156 | 170 157 | 31 158 | 31 159 | 160 | 161 | 162 | 163 | 微软雅黑 164 | 12 165 | 166 | 167 | 168 | border-image: url(:/image/yonghu2.png); 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 123 178 | 170 179 | 321 180 | 31 181 | 182 | 183 | 184 | 185 | 微软雅黑 186 | 12 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 73 197 | 400 198 | 371 199 | 51 200 | 201 | 202 | 203 | 204 | 微软雅黑 205 | 12 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 73 216 | 280 217 | 201 218 | 21 219 | 220 | 221 | 222 | 223 | 微软雅黑 224 | 225 | 226 | 227 | color: rgb(255, 0, 0); 228 | 229 | 230 | 旧密码错误 231 | 232 | 233 | 234 | 235 | 236 | 73 237 | 370 238 | 201 239 | 21 240 | 241 | 242 | 243 | 244 | 微软雅黑 245 | 246 | 247 | 248 | color: rgb(255, 0, 0); 249 | 250 | 251 | 新密码不能为空 252 | 253 | 254 | 255 | 256 | 257 | 73 258 | 460 259 | 201 260 | 21 261 | 262 | 263 | 264 | 265 | 微软雅黑 266 | 267 | 268 | 269 | color: rgb(255, 0, 0); 270 | 271 | 272 | 两次输入密码不一致 273 | 274 | 275 | label_2 276 | label_3 277 | lineEdit 278 | pushButton 279 | lineEdit_2 280 | label 281 | label_4 282 | label_5 283 | lineEdit_3 284 | label_6 285 | label_7 286 | label_8 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/setting.cpp: -------------------------------------------------------------------------------- 1 | #include "setting.h" 2 | #include "mainwindow.h" 3 | #include "ui_setting.h" 4 | #include "changepw.h" 5 | 6 | setting::setting(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::setting) 9 | { 10 | ui->setupUi(this); 11 | 12 | setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint); 13 | setFixedSize(this->width(),this->height()); 14 | 15 | setAttribute(Qt::WA_TranslucentBackground); 16 | QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); 17 | effect->setOffset(0, 0); //设置向哪个方向产生阴影效果(dx,dy),特别地,(0,0)代表向四周发散 18 | effect->setColor(Qt::gray); //设置阴影颜色,也可以setColor(QColor(220,220,220)) 19 | effect->setBlurRadius(20); //设定阴影的模糊半径,数值越大越模糊 20 | ui->frame->setGraphicsEffect(effect); 21 | 22 | QButtonGroup* pButtonGroup = new QButtonGroup(this); 23 | pButtonGroup->addButton(ui->checkBox_4, 1); 24 | pButtonGroup->addButton(ui->checkBox_5, 2); 25 | pButtonGroup->addButton(ui->checkBox_6, 3); 26 | 27 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 28 | QSqlQuery query(db); 29 | int jizhu=0; 30 | query.exec("select user_id,ifrem from loginuser"); 31 | if(query.next()) 32 | { 33 | id=query.value(0).toString(); 34 | jizhu=query.value(1).toInt(); 35 | } 36 | if(jizhu==1) 37 | { 38 | ui->checkBox->setCheckState(Qt::Checked); 39 | ui->label_9->hide(); 40 | ui->label_8->show(); 41 | } 42 | else 43 | { 44 | ui->label_8->hide(); 45 | ui->label_9->show(); 46 | } 47 | QString str=QString("select cansearch,canlookover from userdata where user_id='%1'").arg(id); 48 | query.exec(str); 49 | int search=1; 50 | int lookover=1; 51 | if(query.next()) 52 | { 53 | search=query.value(0).toInt(); 54 | lookover=query.value(1).toInt(); 55 | } 56 | if(search==1) 57 | { 58 | ui->checkBox_2->setCheckState(Qt::Checked); 59 | } 60 | else 61 | { 62 | ui->checkBox_3->setCheckState(Qt::Checked); 63 | } 64 | if(lookover==1) 65 | { 66 | ui->comboBox->setCurrentText("所有人可见"); 67 | } 68 | else if(lookover==2) 69 | { 70 | ui->comboBox->setCurrentText("仅好友可见"); 71 | } 72 | else if(lookover==3) 73 | { 74 | ui->comboBox->setCurrentText("仅自己可见"); 75 | } 76 | ui->widget->hide(); 77 | QString str2=QString("select addway,addquestion,addanswer from userdata where user_id='%1'").arg(id); 78 | query.exec(str2); 79 | int way=1; 80 | QString ques,answ; 81 | if(query.next()) 82 | { 83 | way=query.value(0).toInt(); 84 | ques=query.value(1).toString(); 85 | answ=query.value(2).toString(); 86 | } 87 | if(way==1) 88 | { 89 | ui->checkBox_4->setCheckState(Qt::Checked); 90 | } 91 | else if(way==2) 92 | { 93 | ui->checkBox_5->setCheckState(Qt::Checked); 94 | } 95 | else if(way==3) 96 | { 97 | ui->checkBox_6->setCheckState(Qt::Checked); 98 | ui->lineEdit_2->setText(ques); 99 | ui->lineEdit_3->setText(answ); 100 | ui->widget->show(); 101 | } 102 | } 103 | 104 | setting::~setting() 105 | { 106 | delete ui; 107 | } 108 | 109 | void setting::mousePressEvent(QMouseEvent *event) 110 | { 111 | if(ui->label_3->geometry().contains(event->pos())||ui->label_2->geometry().contains(event->pos())) 112 | { 113 | m_pressed = true; 114 | m_movePos = event->globalPos() - pos(); 115 | } 116 | 117 | return QDialog::mousePressEvent(event); 118 | } 119 | void setting::mouseMoveEvent(QMouseEvent *event) 120 | { 121 | if(ui->label_3->geometry().contains(event->pos())||ui->label_2->geometry().contains(event->pos())) 122 | { 123 | if (m_pressed && (event->buttons()== Qt::LeftButton) 124 | && (event->globalPos() - m_movePos).manhattanLength() > QApplication::startDragDistance()) 125 | { 126 | QPoint movePos = event->globalPos() - m_movePos; 127 | this->move(movePos); 128 | m_movePos = event->globalPos() - pos(); 129 | } 130 | } 131 | 132 | return QDialog::mouseMoveEvent(event); 133 | } 134 | void setting::mouseReleaseEvent(QMouseEvent *event) 135 | { 136 | m_pressed = false; 137 | 138 | return QDialog::mouseReleaseEvent(event); 139 | } 140 | 141 | 142 | void setting::on_pushButton_clicked() 143 | { 144 | close(); 145 | } 146 | 147 | void setting::on_pushButton_2_clicked() 148 | { 149 | showMinimized(); 150 | } 151 | 152 | void setting::on_checkBox_stateChanged(int arg1) 153 | { 154 | int rem; 155 | if(arg1==2) 156 | { 157 | rem=1; 158 | ui->label_9->hide(); 159 | ui->label_8->show(); 160 | } 161 | else 162 | { 163 | rem=0; 164 | ui->label_8->hide(); 165 | ui->label_9->show(); 166 | } 167 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 168 | QSqlQuery query(db); 169 | QString str = QString("update loginuser set ifrem='%1' where user_id='%2'").arg(rem).arg(id); 170 | query.exec(str); 171 | } 172 | 173 | void setting::on_pushButton_3_clicked() 174 | { 175 | changepw a; 176 | a.exec(); 177 | if(a.ifchange) 178 | { 179 | accept(); 180 | } 181 | else return; 182 | } 183 | 184 | void setting::on_checkBox_3_stateChanged(int arg1) 185 | { 186 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 187 | QSqlQuery query(db); 188 | if(arg1==2) 189 | { 190 | ui->checkBox_2->setCheckState(Qt::Unchecked); 191 | int search=0; 192 | QString str=QString("update userdata set cansearch='%1' where user_id='%2'").arg(search).arg(id); 193 | query.exec(str); 194 | } 195 | else if(arg1==0) 196 | { 197 | ui->checkBox_2->setCheckState(Qt::Checked); 198 | int search=1; 199 | QString str=QString("update userdata set cansearch='%1' where user_id='%2'").arg(search).arg(id); 200 | query.exec(str); 201 | } 202 | } 203 | 204 | void setting::on_checkBox_2_stateChanged(int arg1) 205 | { 206 | if(arg1==2) 207 | { 208 | ui->checkBox_3->setCheckState(Qt::Unchecked); 209 | } 210 | else if(arg1==0) 211 | { 212 | ui->checkBox_3->setCheckState(Qt::Checked); 213 | } 214 | } 215 | 216 | void setting::on_checkBox_4_stateChanged(int arg1) 217 | { 218 | if(arg1==2) 219 | { 220 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 221 | QSqlQuery query(db); 222 | int way=1; 223 | QString str=QString("update userdata set addway='%1' where user_id='%2'").arg(way).arg(id); 224 | query.exec(str); 225 | } 226 | else return; 227 | } 228 | 229 | void setting::on_checkBox_5_stateChanged(int arg1) 230 | { 231 | if(arg1==2) 232 | { 233 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 234 | QSqlQuery query(db); 235 | int way=2; 236 | QString str=QString("update userdata set addway='%1' where user_id='%2'").arg(way).arg(id); 237 | query.exec(str); 238 | } 239 | else return; 240 | } 241 | 242 | void setting::on_checkBox_6_stateChanged(int arg1) 243 | { 244 | if(arg1==2) 245 | { 246 | ui->widget->show(); 247 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 248 | QSqlQuery query(db); 249 | int way=3; 250 | QString str=QString("update userdata set addway='%1' where user_id='%2'").arg(way).arg(id); 251 | query.exec(str); 252 | } 253 | else 254 | { 255 | ui->widget->hide(); 256 | return; 257 | } 258 | } 259 | 260 | void setting::on_lineEdit_2_editingFinished() 261 | { 262 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 263 | QSqlQuery query(db); 264 | QString ques=ui->lineEdit_2->text(); 265 | QString answ=ui->lineEdit_3->text(); 266 | QString str=QString("update userdata set addquestion='%1',addanswer='%2' where user_id='%3'").arg(ques).arg(answ).arg(id); 267 | query.exec(str); 268 | } 269 | 270 | void setting::on_lineEdit_3_editingFinished() 271 | { 272 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 273 | QSqlQuery query(db); 274 | QString ques=ui->lineEdit_2->text(); 275 | QString answ=ui->lineEdit_3->text(); 276 | QString str=QString("update userdata set addquestion='%1',addanswer='%2' where user_id='%3'").arg(ques).arg(answ).arg(id); 277 | query.exec(str); 278 | } 279 | 280 | void setting::on_comboBox_activated(const QString &arg1) 281 | { 282 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 283 | QSqlQuery query(db); 284 | int lookover=1; 285 | if(arg1=="所有人可见") 286 | lookover=1; 287 | else if(arg1=="仅好友可见") 288 | lookover=2; 289 | else if(arg1=="仅自己可见") 290 | lookover=3; 291 | query.exec(QString("update userdata set canlookover='%1' where user_id='%2'").arg(lookover).arg(id)); 292 | } 293 | -------------------------------------------------------------------------------- /VictorServer/qtsingleapplication/INSTALL.TXT: -------------------------------------------------------------------------------- 1 | INSTALLATION INSTRUCTIONS 2 | 3 | These instructions refer to the package you are installing as 4 | some-package.tar.gz or some-package.zip. The .zip file is intended for use 5 | on Windows. 6 | 7 | The directory you choose for the installation will be referred to as 8 | your-install-dir. 9 | 10 | Note to Qt Visual Studio Integration users: In the instructions below, 11 | instead of building from command line with nmake, you can use the menu 12 | command 'Qt->Open Solution from .pro file' on the .pro files in the 13 | example and plugin directories, and then build from within Visual 14 | Studio. 15 | 16 | Unpacking and installation 17 | -------------------------- 18 | 19 | 1. Unpacking the archive (if you have not done so already). 20 | 21 | On Unix and Mac OS X (in a terminal window): 22 | 23 | cd your-install-dir 24 | gunzip some-package.tar.gz 25 | tar xvf some-package.tar 26 | 27 | This creates the subdirectory some-package containing the files. 28 | 29 | On Windows: 30 | 31 | Unpack the .zip archive by right-clicking it in explorer and 32 | choosing "Extract All...". If your version of Windows does not 33 | have zip support, you can use the infozip tools available 34 | from www.info-zip.org. 35 | 36 | If you are using the infozip tools (in a command prompt window): 37 | cd your-install-dir 38 | unzip some-package.zip 39 | 40 | 2. Configuring the package. 41 | 42 | The configure script is called "configure" on unix/mac and 43 | "configure.bat" on Windows. It should be run from a command line 44 | after cd'ing to the package directory. 45 | 46 | You can choose whether you want to use the component by including 47 | its source code directly into your project, or build the component 48 | as a dynamic shared library (DLL) that is loaded into the 49 | application at run-time. The latter may be preferable for 50 | technical or licensing (LGPL) reasons. If you want to build a DLL, 51 | run the configure script with the argument "-library". Also see 52 | the note about usage below. 53 | 54 | (Components that are Qt plugins, e.g. styles and image formats, 55 | are by default built as a plugin DLL.) 56 | 57 | The configure script will prompt you in some cases for further 58 | information. Answer these questions and carefully read the license text 59 | before accepting the license conditions. The package cannot be used if 60 | you do not accept the license conditions. 61 | 62 | 3. Building the component and examples (when required). 63 | 64 | If a DLL is to be built, or if you would like to build the 65 | examples, next give the commands 66 | 67 | qmake 68 | make [or nmake if your are using Microsoft Visual C++] 69 | 70 | The example program(s) can be found in the directory called 71 | "examples" or "example". 72 | 73 | Components that are Qt plugins, e.g. styles and image formats, are 74 | ready to be used as soon as they are built, so the rest of this 75 | installation instruction can be skipped. 76 | 77 | 4. Building the Qt Designer plugin (optional). 78 | 79 | Some of the widget components are provided with plugins for Qt 80 | Designer. To build and install the plugin, cd into the 81 | some-package/plugin directory and give the commands 82 | 83 | qmake 84 | make [or nmake if your are using Microsoft Visual C++] 85 | 86 | Restart Qt Designer to make it load the new widget plugin. 87 | 88 | Note: If you are using the built-in Qt Designer from the Qt Visual 89 | Studio Integration, you will need to manually copy the plugin DLL 90 | file, i.e. copy 91 | %QTDIR%\plugins\designer\some-component.dll 92 | to the Qt Visual Studio Integration plugin path, typically: 93 | C:\Program Files\Trolltech\Qt VS Integration\plugins 94 | 95 | Note: If you for some reason are using a Qt Designer that is built 96 | in debug mode, you will need to build the plugin in debug mode 97 | also. Edit the file plugin.pro in the plugin directory, changing 98 | 'release' to 'debug' in the CONFIG line, before running qmake. 99 | 100 | 101 | 102 | Solutions components are intended to be used directly from the package 103 | directory during development, so there is no 'make install' procedure. 104 | 105 | 106 | Using a component in your project 107 | --------------------------------- 108 | 109 | To use this component in your project, add the following line to the 110 | project's .pro file (or do the equivalent in your IDE): 111 | 112 | include(your-install-dir/some-package/src/some-package.pri) 113 | 114 | This adds the package's sources and headers to the SOURCES and HEADERS 115 | project variables respectively (or, if the component has been 116 | configured as a DLL, it adds that library to the LIBS variable), and 117 | updates INCLUDEPATH to contain the package's src 118 | directory. Additionally, the .pri file may include some dependencies 119 | needed by the package. 120 | 121 | To include a header file from the package in your sources, you can now 122 | simply use: 123 | 124 | #include 125 | 126 | or alternatively, in pre-Qt 4 style: 127 | 128 | #include 129 | 130 | Refer to the documentation to see the classes and headers this 131 | components provides. 132 | 133 | 134 | 135 | Install documentation (optional) 136 | -------------------------------- 137 | 138 | The HTML documentation for the package's classes is located in the 139 | your-install-dir/some-package/doc/html/index.html. You can open this 140 | file and read the documentation with any web browser. 141 | 142 | To install the documentation into Qt Assistant (for Qt version 4.4 and 143 | later): 144 | 145 | 1. In Assistant, open the Edit->Preferences dialog and choose the 146 | Documentation tab. Click the Add... button and select the file 147 | your-install-dir/some-package/doc/html/some-package.qch 148 | 149 | For Qt versions prior to 4.4, do instead the following: 150 | 151 | 1. The directory your-install-dir/some-package/doc/html contains a 152 | file called some-package.dcf. Execute the following commands in a 153 | shell, command prompt or terminal window: 154 | 155 | cd your-install-dir/some-package/doc/html/ 156 | assistant -addContentFile some-package.dcf 157 | 158 | The next time you start Qt Assistant, you can access the package's 159 | documentation. 160 | 161 | 162 | Removing the documentation from assistant 163 | ----------------------------------------- 164 | 165 | If you have installed the documentation into Qt Assistant, and want to uninstall it, do as follows, for Qt version 4.4 and later: 166 | 167 | 1. In Assistant, open the Edit->Preferences dialog and choose the 168 | Documentation tab. In the list of Registered Documentation, select 169 | the item com.nokia.qtsolutions.some-package_version, and click 170 | the Remove button. 171 | 172 | For Qt versions prior to 4.4, do instead the following: 173 | 174 | 1. The directory your-install-dir/some-package/doc/html contains a 175 | file called some-package.dcf. Execute the following commands in a 176 | shell, command prompt or terminal window: 177 | 178 | cd your-install-dir/some-package/doc/html/ 179 | assistant -removeContentFile some-package.dcf 180 | 181 | 182 | 183 | Using the component as a DLL 184 | ---------------------------- 185 | 186 | 1. Normal components 187 | 188 | The shared library (DLL) is built and placed in the 189 | some-package/lib directory. It is intended to be used directly 190 | from there during development. When appropriate, both debug and 191 | release versions are built, since the run-time linker will in some 192 | cases refuse to load a debug-built DLL into a release-built 193 | application or vice versa. 194 | 195 | The following steps are taken by default to help the dynamic 196 | linker to locate the DLL at run-time (during development): 197 | 198 | Unix: The some-package.pri file will add linker instructions to 199 | add the some-package/lib directory to the rpath of the 200 | executable. (When distributing, or if your system does not support 201 | rpath, you can copy the shared library to another place that is 202 | searched by the dynamic linker, e.g. the "lib" directory of your 203 | Qt installation.) 204 | 205 | Mac: The full path to the library is hardcoded into the library 206 | itself, from where it is copied into the executable at link time, 207 | and ready by the dynamic linker at run-time. (When distributing, 208 | you will want to edit these hardcoded paths in the same way as for 209 | the Qt DLLs. Refer to the document "Deploying an Application on 210 | Mac OS X" in the Qt Reference Documentation.) 211 | 212 | Windows: the .dll file(s) are copied into the "bin" directory of 213 | your Qt installation. The Qt installation will already have set up 214 | that directory to be searched by the dynamic linker. 215 | 216 | 217 | 2. Plugins 218 | 219 | For Qt Solutions plugins (e.g. image formats), both debug and 220 | release versions of the plugin are built by default when 221 | appropriate, since in some cases the release Qt library will not 222 | load a debug plugin, and vice versa. The plugins are automatically 223 | copied into the plugins directory of your Qt installation when 224 | built, so no further setup is required. 225 | 226 | Plugins may also be built statically, i.e. as a library that will be 227 | linked into your application executable, and so will not need to 228 | be redistributed as a separate plugin DLL to end users. Static 229 | building is required if Qt itself is built statically. To do it, 230 | just add "static" to the CONFIG variable in the plugin/plugin.pro 231 | file before building. Refer to the "Static Plugins" section in the 232 | chapter "How to Create Qt Plugins" for explanation of how to use a 233 | static plugin in your application. The source code of the example 234 | program(s) will also typically contain the relevant instructions 235 | as comments. 236 | 237 | 238 | 239 | Uninstalling 240 | ------------ 241 | 242 | The following command will remove any fils that have been 243 | automatically placed outside the package directory itself during 244 | installation and building 245 | 246 | make distclean [or nmake if your are using Microsoft Visual C++] 247 | 248 | If Qt Assistant documentation or Qt Designer plugins have been 249 | installed, they can be uninstalled manually, ref. above. 250 | 251 | 252 | Enjoy! :) 253 | 254 | - The Qt Solutions Team. 255 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/login.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | login 4 | 5 | 6 | 7 | 0 8 | 0 9 | 552 10 | 423 11 | 12 | 13 | 14 | 登录 15 | 16 | 17 | 18 | :/image/victoricon2.png:/image/victoricon2.png 19 | 20 | 21 | 22 | 23 | 0 24 | 0 25 | 552 26 | 423 27 | 28 | 29 | 30 | QFrame::StyledPanel 31 | 32 | 33 | QFrame::Raised 34 | 35 | 36 | 37 | 38 | 6 39 | 6 40 | 541 41 | 161 42 | 43 | 44 | 45 | border-image: url(:/image/background2.png); 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 6 55 | 156 56 | 541 57 | 261 58 | 59 | 60 | 61 | background-color: rgb(255, 255, 255); 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 16 71 | 13 72 | 41 73 | 41 74 | 75 | 76 | 77 | 78 | border-image: url(:/image/victoricon2.png); 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 60 88 | 17 89 | 72 90 | 31 91 | 92 | 93 | 94 | 95 | 微软雅黑 96 | 14 97 | 75 98 | true 99 | 100 | 101 | 102 | color: rgb(255, 255, 255); 103 | 104 | 105 | <html><head/><body><p>Victor</p></body></html> 106 | 107 | 108 | 109 | 110 | 111 | 513 112 | 8 113 | 32 114 | 32 115 | 116 | 117 | 118 | QPushButton{border-image: url(:/image/close.png);} 119 | QPushButton:hover{background: rgb(211, 64, 67);} 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 479 129 | 8 130 | 32 131 | 32 132 | 133 | 134 | 135 | QPushButton{border-image: url(:/image/minimum.png);} 136 | QPushButton:hover{background:rgb(87, 148, 239);} 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 156 147 | 221 148 | 271 149 | 31 150 | 151 | 152 | 153 | 154 | 微软雅黑 155 | 11 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 156 166 | 266 167 | 271 168 | 31 169 | 170 | 171 | 172 | 173 | 微软雅黑 174 | 11 175 | 176 | 177 | 178 | 179 | 180 | 181 | 126 182 | 272 183 | 20 184 | 20 185 | 186 | 187 | 188 | border-image: url(:/image/mima.png); 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 125 198 | 224 199 | 22 200 | 22 201 | 202 | 203 | 204 | border-image: url(:/image/yonghu2.png); 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 128 214 | 312 215 | 91 216 | 20 217 | 218 | 219 | 220 | 221 | 微软雅黑 222 | 223 | 224 | 225 | 记住密码 226 | 227 | 228 | 229 | 230 | 231 | 350 232 | 309 233 | 91 234 | 28 235 | 236 | 237 | 238 | 239 | 微软雅黑 240 | 241 | 242 | 243 | QPushButton{background:transparent;color: rgb(135, 135, 135);} 244 | QPushButton:hover{color:rgb(65, 155, 255);} 245 | 246 | 247 | 找回密码 248 | 249 | 250 | 251 | 252 | 253 | 126 254 | 345 255 | 299 256 | 49 257 | 258 | 259 | 260 | 261 | 微软雅黑 262 | 11 263 | 9 264 | false 265 | false 266 | 267 | 268 | 269 | QPushButton{border-style:none;font: 75 11pt "微软雅黑";background-color: rgb(70, 190, 255);color: rgb(255, 255, 255);} 270 | QPushButton:hover{background: rgb(85, 205, 255);color: rgb(255, 255, 255);} 271 | 272 | 273 | 登录 274 | 275 | 276 | true 277 | 278 | 279 | false 280 | 281 | 282 | false 283 | 284 | 285 | 286 | 287 | 288 | 470 289 | 390 290 | 81 291 | 28 292 | 293 | 294 | 295 | 296 | 微软雅黑 297 | 298 | 299 | 300 | QPushButton{background:transparent;color: rgb(135, 135, 135);} 301 | QPushButton:hover{color:rgb(65, 155, 255);} 302 | 303 | 304 | 注册账号 305 | 306 | 307 | 308 | 309 | 310 | 230 311 | 111 312 | 90 313 | 90 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 215 327 | 94 328 | 121 329 | 121 330 | 331 | 332 | 333 | QLabel{background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(0, 0, 0, 0), stop:0.70 rgba(0, 0, 0, 0), stop:0.80 rgba(136, 194, 255, 100), stop:1 rgba(0, 0, 0, 0));} 334 | QLabel:hover{background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(0, 0, 0, 0), stop:0.70 rgba(0, 0, 0, 0), stop:0.80 rgba(186, 224, 255, 100), stop:1 rgba(0, 0, 0, 0));} 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/qnchatmessage.cpp: -------------------------------------------------------------------------------- 1 | #include "qnchatmessage.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | QNChatMessage::QNChatMessage(QWidget *parent,QString send_id,QString receive_id) : QWidget(parent) 12 | { 13 | QFont te_font = this->font(); 14 | te_font.setFamily("微软雅黑"); 15 | te_font.setPointSize(11); 16 | // te_font.setWordSpacing(0); 17 | // te_font.setLetterSpacing(QFont::PercentageSpacing,0); 18 | // te_font.setLetterSpacing(QFont::PercentageSpacing, 100); //300%,100为默认 //设置字间距% 19 | // te_font.setLetterSpacing(QFont::AbsoluteSpacing, 0); //设置字间距为3像素 //设置字间距像素值 20 | this->setFont(te_font); 21 | id=send_id; fid=receive_id; 22 | QSqlDatabase db = QSqlDatabase::database("sqlite1"); //建立数据库连接 23 | QSqlQuery query(db); 24 | query.exec(QString("select touxiang from userdata where user_id='%1'").arg(id)); 25 | QString toux; 26 | if(query.next()) 27 | { 28 | toux=query.value(0).toString(); 29 | } 30 | query.exec(QString("select touxiang from userdata where user_id='%1'").arg(fid)); 31 | QString ftoux; 32 | if(query.next()) 33 | { 34 | ftoux=query.value(0).toString(); 35 | } 36 | m_leftPixmap = QPixmap(ftoux); 37 | m_rightPixmap = QPixmap(toux); 38 | 39 | m_loadingMovie = new QMovie(this); 40 | m_loadingMovie->setFileName(":/touxiang/girl3.jpg"); 41 | m_loading = new QLabel(this); 42 | m_loading->setMovie(m_loadingMovie); 43 | m_loading->resize(0,0); 44 | m_loading->setAttribute(Qt::WA_TranslucentBackground , true); 45 | m_loading->setAutoFillBackground(false); 46 | } 47 | 48 | void QNChatMessage::setTextSuccess() 49 | { 50 | m_loading->hide(); 51 | m_loadingMovie->stop(); 52 | m_isSending = true; 53 | } 54 | 55 | void QNChatMessage::setText(QString text, QString time, QSize allSize, QNChatMessage::User_Type userType) 56 | { 57 | m_msg = text; 58 | m_userType = userType; 59 | m_time = time; 60 | m_curTime = QDateTime::fromTime_t(time.toInt()).toString("hh:mm"); 61 | m_allSize = allSize; 62 | if(userType == User_Me) { 63 | if(!m_isSending) { 64 | m_loading->move(m_kuangRightRect.x() - m_loading->width() - 10, m_kuangRightRect.y()+m_kuangRightRect.height()/2- m_loading->height()/2); 65 | m_loading->show(); 66 | m_loadingMovie->start(); 67 | } 68 | } else { 69 | m_loading->hide(); 70 | } 71 | 72 | this->update(); 73 | } 74 | 75 | QSize QNChatMessage::fontRect(QString str) 76 | { 77 | m_msg = str; 78 | int minHei = 30; 79 | int iconWH = 50; 80 | int iconSpaceW = 20; 81 | int iconRectW = 10; 82 | int iconTMPH = 15; 83 | int sanJiaoW = 10; 84 | int kuangTMP = 15; 85 | int textSpaceRect = 14; 86 | m_kuangWidth = this->width() - kuangTMP - 2*(iconWH+iconSpaceW+iconRectW); 87 | m_textWidth = m_kuangWidth - 2*textSpaceRect; 88 | m_spaceWid = this->width() - m_textWidth; 89 | m_iconLeftRect = QRect(iconSpaceW, iconTMPH, iconWH, iconWH); 90 | m_iconRightRect = QRect(this->width() - iconSpaceW - iconWH, iconTMPH, iconWH, iconWH); 91 | 92 | QSize size = getRealString(m_msg); // 整个的size 93 | 94 | qDebug() << "fontRect Size:" << size; 95 | int hei = size.height() < minHei ? minHei : size.height(); 96 | 97 | m_sanjiaoLeftRect = QRect(iconWH+iconSpaceW+iconRectW, m_lineHeight/2, sanJiaoW, hei - m_lineHeight); 98 | m_sanjiaoRightRect = QRect(this->width() - iconRectW - iconWH - iconSpaceW - sanJiaoW, m_lineHeight/2, sanJiaoW, hei - m_lineHeight); 99 | 100 | if(size.width() < (m_textWidth+m_spaceWid)) { 101 | m_kuangLeftRect.setRect(m_sanjiaoLeftRect.x()+m_sanjiaoLeftRect.width(), m_lineHeight/4*3, size.width()-m_spaceWid+2*textSpaceRect, hei-m_lineHeight); 102 | m_kuangRightRect.setRect(this->width() - size.width() + m_spaceWid - 2*textSpaceRect - iconWH - iconSpaceW - iconRectW - sanJiaoW, 103 | m_lineHeight/4*3, size.width()-m_spaceWid+2*textSpaceRect, hei-m_lineHeight); 104 | } else { 105 | m_kuangLeftRect.setRect(m_sanjiaoLeftRect.x()+m_sanjiaoLeftRect.width(), m_lineHeight/4*3, m_kuangWidth, hei-m_lineHeight); 106 | m_kuangRightRect.setRect(iconWH + kuangTMP + iconSpaceW + iconRectW - sanJiaoW, m_lineHeight/4*3, m_kuangWidth, hei-m_lineHeight); 107 | } 108 | m_textLeftRect.setRect(m_kuangLeftRect.x()+textSpaceRect,m_kuangLeftRect.y()+iconTMPH, 109 | m_kuangLeftRect.width()-2*textSpaceRect,m_kuangLeftRect.height()-2*iconTMPH); 110 | m_textRightRect.setRect(m_kuangRightRect.x()+textSpaceRect,m_kuangRightRect.y()+iconTMPH, 111 | m_kuangRightRect.width()-2*textSpaceRect,m_kuangRightRect.height()-2*iconTMPH); 112 | 113 | return QSize(size.width(), hei); 114 | } 115 | 116 | QSize QNChatMessage::getRealString(QString src) 117 | { 118 | QFontMetricsF fm(this->font()); 119 | m_lineHeight = fm.lineSpacing(); 120 | double nCount = src.count("\n"); 121 | double nMaxWidth = 0; 122 | if(nCount == 0.0) { 123 | nMaxWidth = fm.width(src); 124 | QString value = src; 125 | if(nMaxWidth > m_textWidth) { 126 | nMaxWidth = m_textWidth; 127 | int size = (int)(m_textWidth / fm.width(" ")); 128 | int num = (int)(fm.width(value) / m_textWidth); 129 | double ttmp = num*fm.width(" "); 130 | num = (int)(( fm.width(value) ) / m_textWidth); 131 | nCount += num; 132 | QString temp = ""; 133 | for(int i = 0; i < num; i++) { 134 | temp += value.mid(i*size, (i+1)*size) + "\n"; 135 | } 136 | src.replace(value, temp); 137 | } 138 | } else { 139 | for(int i = 0; i < (nCount + 1); i++) { 140 | QString value = src.split("\n").at(i); 141 | nMaxWidth = fm.width(value) > nMaxWidth ? fm.width(value) : nMaxWidth; 142 | if(fm.width(value) > m_textWidth) { 143 | nMaxWidth = m_textWidth; 144 | int size = (int)(m_textWidth / fm.width(" ")); 145 | int num = (int)(fm.width(value) / m_textWidth); 146 | num = (int)(((i+num)*fm.width(" ") + fm.width(value)) / m_textWidth); 147 | nCount += num; 148 | QString temp = ""; 149 | for(int i = 0; i < num; i++) { 150 | temp += value.mid(i*size, (i+1)*size) + "\n"; 151 | } 152 | src.replace(value, temp); 153 | } 154 | } 155 | } 156 | return QSize(nMaxWidth+m_spaceWid, (nCount + 1) * m_lineHeight+2*m_lineHeight); 157 | } 158 | 159 | void QNChatMessage::paintEvent(QPaintEvent *event) 160 | { 161 | Q_UNUSED(event) 162 | 163 | QPainter painter(this); 164 | painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);//消锯齿 165 | painter.setPen(Qt::NoPen); 166 | painter.setBrush(QBrush(Qt::gray)); 167 | 168 | if(m_userType == User_Type::User_She) { // 用户 169 | //头像 170 | // painter.drawRoundedRect(m_iconLeftRect,m_iconLeftRect.width(),m_iconLeftRect.height()); 171 | painter.drawPixmap(m_iconLeftRect, m_leftPixmap); 172 | 173 | //框加边 174 | QColor col_KuangB(234, 234, 234); 175 | painter.setBrush(QBrush(col_KuangB)); 176 | painter.drawRoundedRect(m_kuangLeftRect.x()-1,m_kuangLeftRect.y()-1,m_kuangLeftRect.width()+2,m_kuangLeftRect.height()+2,4,4); 177 | //框 178 | QColor col_Kuang(255,255,255); 179 | painter.setBrush(QBrush(col_Kuang)); 180 | painter.drawRoundedRect(m_kuangLeftRect,4,4); 181 | 182 | //三角 183 | QPointF points[3] = { 184 | QPointF(m_sanjiaoLeftRect.x(), 30), 185 | QPointF(m_sanjiaoLeftRect.x()+m_sanjiaoLeftRect.width(), 25), 186 | QPointF(m_sanjiaoLeftRect.x()+m_sanjiaoLeftRect.width(), 35), 187 | }; 188 | QPen pen; 189 | pen.setColor(col_Kuang); 190 | painter.setPen(pen); 191 | painter.drawPolygon(points, 3); 192 | 193 | //三角加边 194 | QPen penSanJiaoBian; 195 | penSanJiaoBian.setColor(col_KuangB); 196 | painter.setPen(penSanJiaoBian); 197 | painter.drawLine(QPointF(m_sanjiaoLeftRect.x() - 1, 30), QPointF(m_sanjiaoLeftRect.x()+m_sanjiaoLeftRect.width(), 24)); 198 | painter.drawLine(QPointF(m_sanjiaoLeftRect.x() - 1, 30), QPointF(m_sanjiaoLeftRect.x()+m_sanjiaoLeftRect.width(), 36)); 199 | 200 | //内容 201 | QPen penText; 202 | penText.setColor(QColor(51,51,51)); 203 | painter.setPen(penText); 204 | QTextOption option(Qt::AlignLeft | Qt::AlignVCenter); 205 | option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); 206 | painter.setFont(this->font()); 207 | painter.drawText(m_textLeftRect, m_msg,option); 208 | } else if(m_userType == User_Type::User_Me) { // 自己 209 | //头像 210 | // painter.drawRoundedRect(m_iconRightRect,m_iconRightRect.width(),m_iconRightRect.height()); 211 | painter.drawPixmap(m_iconRightRect, m_rightPixmap); 212 | //框 213 | QColor col_Kuang(99, 178, 230); 214 | painter.setBrush(QBrush(col_Kuang)); 215 | painter.drawRoundedRect(m_kuangRightRect,4,4); 216 | //三角 217 | QPointF points[3] = { 218 | QPointF(m_sanjiaoRightRect.x()+m_sanjiaoRightRect.width(), 30), 219 | QPointF(m_sanjiaoRightRect.x(), 25), 220 | QPointF(m_sanjiaoRightRect.x(), 35), 221 | }; 222 | QPen pen; 223 | pen.setColor(col_Kuang); 224 | painter.setPen(pen); 225 | painter.drawPolygon(points, 3); 226 | //内容 227 | QPen penText; 228 | penText.setColor(Qt::white); 229 | painter.setPen(penText); 230 | QTextOption option(Qt::AlignLeft | Qt::AlignVCenter); 231 | option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); 232 | painter.setFont(this->font()); 233 | painter.drawText(m_textRightRect,m_msg,option); 234 | } else if(m_userType == User_Type::User_Time) { // 时间 235 | QPen penText; 236 | penText.setColor(QColor(153,153,153)); 237 | painter.setPen(penText); 238 | QTextOption option(Qt::AlignCenter); 239 | option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); 240 | QFont te_font = this->font(); 241 | te_font.setFamily("微软雅黑"); 242 | te_font.setPointSize(10); 243 | painter.setFont(te_font); 244 | painter.drawText(this->rect(),m_curTime,option); 245 | } 246 | } 247 | 248 | 249 | -------------------------------------------------------------------------------- /VictorClient/WePlatform/regist.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | regist 4 | 5 | 6 | 7 | 0 8 | 0 9 | 519 10 | 620 11 | 12 | 13 | 14 | 注册 15 | 16 | 17 | 18 | :/image/victoricon2.png:/image/victoricon2.png 19 | 20 | 21 | 22 | 23 | 72 24 | 30 25 | 271 26 | 91 27 | 28 | 29 | 30 | 31 | 微软雅黑 32 | 20 33 | 50 34 | false 35 | 36 | 37 | 38 | <html><head/><body><p><span style=" font-size:22pt;">欢迎注册Victor</span></p></body></html> 39 | 40 | 41 | 42 | 43 | 44 | 0 45 | 0 46 | 521 47 | 621 48 | 49 | 50 | 51 | background-color: rgb(255, 255, 255); 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 70 61 | 150 62 | 371 63 | 51 64 | 65 | 66 | 67 | 68 | 微软雅黑 69 | 12 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 70 80 | 240 81 | 371 82 | 51 83 | 84 | 85 | 86 | 87 | 微软雅黑 88 | 12 89 | 90 | 91 | 92 | 93 | 94 | 95 | 70 96 | 510 97 | 371 98 | 61 99 | 100 | 101 | 102 | 103 | 微软雅黑 104 | 12 105 | 50 106 | false 107 | 108 | 109 | 110 | QPushButton{border-style:none;background-color: rgb(89, 169, 255);color: rgb(255, 255, 255);} 111 | QPushButton:hover{background: rgb(100, 185, 255);color: rgb(255, 255, 255);} 112 | 113 | 114 | 立即注册 115 | 116 | 117 | 118 | 119 | 120 | 70 121 | 420 122 | 371 123 | 51 124 | 125 | 126 | 127 | 128 | 微软雅黑 129 | 12 130 | 131 | 132 | 133 | 134 | 135 | 136 | 70 137 | 330 138 | 371 139 | 51 140 | 141 | 142 | 143 | 144 | 微软雅黑 145 | 12 146 | 147 | 148 | 149 | 150 | 151 | 152 | 70 153 | 210 154 | 101 155 | 21 156 | 157 | 158 | 159 | 160 | 微软雅黑 161 | 162 | 163 | 164 | color: rgb(255, 0, 0); 165 | 166 | 167 | 昵称不能为空 168 | 169 | 170 | 171 | 172 | 173 | 70 174 | 300 175 | 111 176 | 21 177 | 178 | 179 | 180 | 181 | 微软雅黑 182 | 183 | 184 | 185 | color: rgb(255, 0, 0); 186 | 187 | 188 | 密码不能为空 189 | 190 | 191 | 192 | 193 | 194 | 70 195 | 390 196 | 151 197 | 21 198 | 199 | 200 | 201 | 202 | 微软雅黑 203 | 204 | 205 | 206 | color: rgb(255, 0, 0); 207 | 208 | 209 | 两次输入密码不一致 210 | 211 | 212 | 213 | 214 | 215 | 70 216 | 480 217 | 131 218 | 21 219 | 220 | 221 | 222 | 223 | 微软雅黑 224 | 225 | 226 | 227 | color: rgb(255, 0, 0); 228 | 229 | 230 | 手机号码不能为空 231 | 232 | 233 | 234 | 235 | 236 | 70 237 | 480 238 | 171 239 | 21 240 | 241 | 242 | 243 | 244 | 微软雅黑 245 | 246 | 247 | 248 | color: rgb(255, 0, 0); 249 | 250 | 251 | 请输入有效的手机号码 252 | 253 | 254 | 255 | 256 | 257 | 0 258 | 0 259 | 521 260 | 621 261 | 262 | 263 | 264 | background-color: rgb(255, 255, 255); 265 | 266 | 267 | 268 | 269 | 72 270 | 50 271 | 311 272 | 61 273 | 274 | 275 | 276 | 277 | 微软雅黑 278 | 20 279 | 50 280 | false 281 | 282 | 283 | 284 | <html><head/><body><p>你已成功注册Victor</p></body></html> 285 | 286 | 287 | 288 | 289 | 290 | 72 291 | 190 292 | 301 293 | 51 294 | 295 | 296 | 297 | 298 | 微软雅黑 299 | 16 300 | 50 301 | false 302 | 303 | 304 | 305 | <html><head/><body><p>你的账号是:</p></body></html> 306 | 307 | 308 | 309 | 310 | 311 | 72 312 | 265 313 | 381 314 | 71 315 | 316 | 317 | 318 | 319 | 微软雅黑 320 | 18 321 | 75 322 | true 323 | 324 | 325 | 326 | TextLabel 327 | 328 | 329 | 330 | 331 | 332 | 72 333 | 480 334 | 371 335 | 61 336 | 337 | 338 | 339 | 340 | 微软雅黑 341 | 12 342 | 343 | 344 | 345 | QPushButton{border-style:none;background-color: rgb(89, 169, 255);color: rgb(255, 255, 255);} 346 | QPushButton:hover{background: rgb(100, 185, 255);color: rgb(255, 255, 255);} 347 | 348 | 349 | 确定 350 | 351 | 352 | 353 | 354 | 355 | 72 356 | 450 357 | 391 358 | 31 359 | 360 | 361 | 362 | 363 | 微软雅黑 364 | 9 365 | 50 366 | false 367 | 368 | 369 | 370 | <html><head/><body><p>每个人的账号都是独一无二的,请务必牢记</p></body></html> 371 | 372 | 373 | 374 | label_2 375 | label 376 | lineEdit 377 | lineEdit_2 378 | pushButton 379 | lineEdit_3 380 | lineEdit_4 381 | label_3 382 | label_4 383 | label_5 384 | label_6 385 | label_7 386 | widget 387 | 388 | 389 | 390 | 391 | 392 | 393 | --------------------------------------------------------------------------------