(source->imageData()), "JPG"); // Sorry, ale cokoli jiného dlouho trvá
91 | return;
92 | }
93 | }
94 | QTextEdit::insertFromMimeData(source);
95 | }
96 |
97 |
98 | QMimeData *MTextEdit::createMimeDataFromSelection() const
99 | {
100 | return QTextEdit::createMimeDataFromSelection();
101 | }
102 |
103 |
104 | void MTextEdit::dropImage(const QImage &image, const QString &format)
105 | {
106 | QByteArray bytes;
107 | QBuffer buffer(&bytes);
108 | buffer.open(QIODevice::WriteOnly);
109 | image.save(&buffer, format.toLocal8Bit().data());
110 | buffer.close();
111 | QByteArray base64 = bytes.toBase64();
112 | QByteArray base64l;
113 | for (int i = 0; i < base64.size(); i++)
114 | {
115 | base64l.append(base64[i]);
116 | if (i % 80 == 0)
117 | {
118 | base64l.append("\n");
119 | }
120 | }
121 |
122 | QTextCursor cursor = textCursor();
123 | QTextImageFormat imageFormat;
124 | imageFormat.setWidth(image.width());
125 | imageFormat.setHeight(image.height());
126 | imageFormat.setName(QString("data:image/%1;base64,%2")
127 | .arg(QString("%1.%2").arg(rand()).arg(format))
128 | .arg(base64l.data())
129 | );
130 | cursor.insertImage(imageFormat);
131 | }
132 |
133 | void MTextEdit::dropImage(const QString &name)
134 | {
135 | QTextCursor cursor = textCursor();
136 | cursor.insertImage(name);
137 | }
138 |
139 | void MTextEdit::keyPressEvent(QKeyEvent *e)
140 | {
141 | // if(e->key()==Qt::Key_Tab)
142 | // emit tab();
143 | // else
144 | QTextEdit::keyPressEvent(e);
145 | }
146 |
147 |
--------------------------------------------------------------------------------
/demo/testDoc2.htm:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | 为了落实 《国家中长期教育改革和发展规划纲要(2010-2020)》 ,为人才强国战略的实施和创新型国家的建设提供强有力的人才支撑,教育部于2009年启动 “基础学科拔尖学生培养试验计划” , 目的是培养一大批拔尖创新人才,使之成为相关基础学科领域的领军人物,并逐步跻身国际一流科学家队伍。
7 |
8 | 作为入选该计划的17所 高水平研究型大学 之一 , 山东大学 决定成立“山东大学泰山学堂”,全面负责山东大学“基础学科拔尖学生培养试验计划”的实施。
9 |
10 | 泰山学堂将依托 数学、物理学、化学、生物学、计算机科学 等5个学科良好的学科基础,并综合利用国内外优质教育资源,借鉴世界一流大学的经验,汲取齐鲁文化精华,重点在培养模式、教学方法、学生遴选、制度创新等方面进行大胆的探索和实践。通过多元、多种、多次和专家选才的方式,选拔具有培养潜质的优秀学生,为其配备一流师资,创造一流学习条件,营造一流学术氛围,形成具有山大特色的人才培养模式和机制, 培养基础扎实、学风朴实,有德性、富有创新精神和创新能力的未来拔尖创新人才 。
11 |
12 | 学校将按照8年“本博贯通”模式对泰山学堂的学生进行长周期培养和精英教育。采用“通专结合、文理交融,学研并重、强化创新,多种经历、三个相跨”的培养模式,为其制定个性化的培养方案,实行弹性化管理,实施住宿学院制、游学制和导师制相结合的学习和管理模式,进一步改革教学方法,创新教学模式,实行小班授课,加强研究性和研讨式教学,不断优化课程体系,选用国际一流教材,使计划学生在本科期间人人拥在世界一流大学进行学习和研究的经历。为有志于从事基础学科研究,有志于成为世界一流科学家的有志学子提供肥沃的土壤,广阔的空间、良好的机遇,为学生的早日成才打下坚实基础,为世界科学的发展和创新型国家的建设做出贡献。
--------------------------------------------------------------------------------
/demo/testDoc3.html:
--------------------------------------------------------------------------------
1 |
2 |
5 | Dear Professor:
6 |
7 | As a teacher in Department of Physics, Shandong University, I am very pleased to take this opportunity to recommend one of my favorite students, Ms Chen, to the Visiting International Student program of Duke university.
8 |
9 | Ms Chen requested a letter of reference from me to support her application for Visiting International Student program of Duke university. As her tutor in the second academic year in Shandong University, I taught her Classical Mechanics and became acquainted with her, so I am willing to comply with her request.
10 |
11 | Ms Chen left a deep impression on me by sitting in the front row in my class at first, but later on, I found that she could not only follow my pace and logic, but often voiced her independent thinkings which were reasonable and innovative at most time. Since then, we have discussed various questions occasionally, including some classical theoretical physics problems in my class, certain classical chaos problems, as well as her scientific training project, Quantum Walk, etc. I was impressed by her unique views about these difficulties which reflected her deep thinkings and integrated logic. What’s more, Ms Chen possesses excellent self-learning capacity, which enables her to get hang of many skills such as numerical simulation and programming. Because of that, she would adjust to a brand new environment quickly.
12 |
13 | At the end of last semester, Ms Chen got the highest score (96/100) in my class, and right now she keeps on learning Quantum Walk in our group.
14 |
15 | I am glad to recommend this excellent girl who already possessed good quality and strong ability. I therefore lend her my enthusiastic support and would appreciate you favora ble consideration of her application.
16 |
17 | Sincerely yours,
18 | Huan Yang
19 |
--------------------------------------------------------------------------------
/src/editor.h:
--------------------------------------------------------------------------------
1 | #ifndef EDITOR_H
2 | #define EDITOR_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "ui_editor.h"
15 | #include "AccountManager.h"
16 |
17 | namespace Ui
18 | {
19 | class Editor;
20 | }
21 |
22 | class Editor : public QMainWindow
23 | {
24 | Q_OBJECT
25 |
26 | public:
27 | explicit Editor(AccountManager manager_, QWidget *parent = nullptr, bool anonymous_ = false);
28 |
29 | virtual ~Editor();
30 |
31 | QString toPlainText() const
32 | { return ui->textEdit->toPlainText(); }
33 |
34 | QString toHtml() const;
35 |
36 | QTextDocument *document()
37 | { return ui->textEdit->document(); }
38 |
39 | QTextCursor textCursor() const
40 | { return ui->textEdit->textCursor(); }
41 |
42 | void setTextCursor(const QTextCursor &cursor)
43 | { ui->textEdit->setTextCursor(cursor); }
44 |
45 | void setUser(QString username)
46 | {
47 | l_username->setText(username);
48 | };
49 |
50 | void setServer(QString address)
51 | {
52 | l_server->setText(address);
53 | };
54 |
55 | void setAnonymous(bool anonymous)
56 | {
57 | Editor::anonymous = anonymous;
58 | }
59 |
60 | QTimer *getFileListTimer() const
61 | {
62 | return fileListTimer;
63 | }
64 |
65 | void updateFileListTimer()
66 | {
67 | shotsCount=0;
68 | if(!anonymous)
69 | fileListTimer->start(1000);
70 | }
71 |
72 | public slots:
73 |
74 | void setText(const QString &text);
75 |
76 | protected slots:
77 |
78 | void setPlainText(const QString &text)
79 | { ui->textEdit->setPlainText(text); }
80 |
81 | void setHtml(const QString &text)
82 | { ui->textEdit->setHtml(text); }
83 |
84 | void textRemoveFormat();
85 |
86 | void textRemoveAllFormat();
87 |
88 | void textBold();
89 |
90 | void textUnderline();
91 |
92 | void textStrikeout();
93 |
94 | void textItalic();
95 |
96 | void textSize(const QString &p);
97 |
98 | void textLink(bool checked);
99 |
100 | void textStyle(int index);
101 |
102 | void textFgColor();
103 |
104 | void textBgColor();
105 |
106 | void listBullet(bool checked);
107 |
108 | void listOrdered(bool checked);
109 |
110 | void slotCurrentCharFormatChanged(const QTextCharFormat &format);
111 |
112 | void slotCursorPositionChanged();
113 |
114 | void slotClipboardDataChanged();
115 |
116 | void increaseIndentation();
117 |
118 | void decreaseIndentation();
119 |
120 | void insertImage();
121 |
122 | void textSource();
123 |
124 | void justifyCenter();
125 |
126 | void justifyLeft();
127 |
128 | void justifyRight();
129 |
130 | void splitPage()
131 | {
132 | // ui->textEdit->textCursor().insertHtml(" ");
133 | ui->textEdit->textCursor().insertHtml(" ");
134 | }
135 |
136 | void splitPragraph(){ui->textEdit->insertHtml(" ");}
137 |
138 | protected:
139 | void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
140 |
141 | void fontChanged(const QFont &f);
142 |
143 | void fgColorChanged(const QColor &c);
144 |
145 | void bgColorChanged(const QColor &c);
146 |
147 | void list(bool checked, QTextListFormat::Style style);
148 |
149 | void indent(int delta);
150 |
151 | void focusInEvent(QFocusEvent *event);
152 |
153 | QStringList m_paragraphItems;
154 | int m_fontsize_h1;
155 | int m_fontsize_h2;
156 | int m_fontsize_h3;
157 | int m_fontsize_h4;
158 |
159 | enum ParagraphItems
160 | {
161 | ParagraphStandard = 0,
162 | ParagraphSansSerif,
163 | ParagraphSystem,
164 | ParagraphHelvetica,
165 | ParagraphCourier,
166 | ParagraphMonospace
167 | };
168 |
169 | QPointer m_lastBlockList;
170 | private slots:
171 |
172 | void on_actionnew_triggered();
173 |
174 | void on_actionopen_triggered();
175 |
176 | void on_actionopen_folder_triggered();
177 |
178 | void on_actionsave_triggered();
179 |
180 | void on_actionlatex_triggered();
181 |
182 | void on_actionpdf_triggered();
183 |
184 | void on_actionlogin_triggered();
185 |
186 | void on_actionregister_triggered();
187 |
188 | void on_actionlogout_triggered();
189 |
190 | void on_n_refresh_clicked();
191 |
192 | void on_n_delete_clicked();
193 |
194 | void on_n_upload_clicked();
195 |
196 | void local_filesystem_view_doubleclicked(const QModelIndex &modelIndex);
197 |
198 | void remote_file_view_doubleclicked(const QModelIndex &modelIndex);
199 |
200 | void showRemoteFiles(QList *stringList);
201 |
202 | void showFile(QString content){ui->textEdit->setHtml(content);std::cout< remoteFileList;
210 | QString recentFileName;
211 | QLabel *l_username;
212 | QLabel *l_server;
213 | QTimer *fileListTimer;
214 | bool anonymous;
215 | int shotsCount;
216 |
217 | void showLocalFileSystem();
218 |
219 |
220 | };
221 |
222 | #endif // EDITOR_H
223 |
--------------------------------------------------------------------------------
/src/systemtrayicon.cpp:
--------------------------------------------------------------------------------
1 | #include "systemtrayicon.h"
2 |
3 | #include
4 | #include
5 |
6 | //SystemTrayIcon::SystemTrayIcon(QWidget *parent) : QWidget(parent)
7 | SystemTrayIcon::SystemTrayIcon(QStringList strList, QIcon icon, QWidget *parent) : QWidget(parent)
8 | {
9 | pWidget = parent;
10 | m_strList = strList;
11 | m_icon = icon;
12 |
13 | create_sysTrayMenuAct();//1.创建点击托盘菜单项的act行为
14 | create_sysTrayMenu();//2.创建托盘菜单
15 | create_sysTrayIcon();//3.创建托盘,init
16 | //注意初始化顺序:1.init托盘菜单包含的项 2.init托盘菜单 3.init托盘Button
17 | }
18 |
19 | //创建点击托盘菜单项的act行为
20 | void SystemTrayIcon::create_sysTrayMenuAct()
21 | {
22 | // actFixed = new QAction("锁定位置(&F)",this);
23 | // actFixed->setCheckable(true);
24 | // actFixed->setChecked(true);
25 |
26 | act_sys_tray_min = new QAction(tr("最小化(&M)"), this);
27 | connect(act_sys_tray_min, SIGNAL(triggered()), pWidget, SLOT(hide()));
28 |
29 | act_sys_tray_normal = new QAction(tr("还 原(&R)"), this);
30 | connect(act_sys_tray_normal, SIGNAL(triggered()), pWidget, SLOT(showNormal()));
31 |
32 | act_sys_tray_exit = new QAction(tr("退出(&Q)"), this);
33 | connect(act_sys_tray_exit, SIGNAL(triggered()), qApp, SLOT(quit()));
34 |
35 | act_sys_tray_lang_ch = new QAction(tr("简体中文(&C)"), this);
36 | // connect(act_sys_tray_lang_ch,SIGNAL(triggered()),this,SLOT(set_lang()));
37 |
38 | act_sys_tray_lang_en = new QAction(tr("英语(&E)"), this);
39 | acrLangGrp = new QActionGroup(this);
40 | acrLangGrp->addAction(act_sys_tray_lang_ch);
41 | acrLangGrp->addAction(act_sys_tray_lang_en);
42 | connect(acrLangGrp, SIGNAL(triggered(QAction * )), this, SLOT(set_lang(QAction * )));
43 |
44 |
45 | }
46 |
47 |
48 | //创建托盘菜单
49 | void SystemTrayIcon::create_sysTrayMenu()
50 | {
51 | mSysTrayMenu = new QMenu(this);
52 | //mSysTrayMenu = new QMenu((QWidget*)QApplication::desktop());
53 |
54 | mSysTrayMenuLangSetting = new QMenu(tr("语言设置"), this);
55 | // QList act_list;
56 | // act_list << act_sys_tray_lang_ch << act_sys_tray_lang_en;
57 | // mSysTrayMenuLangSetting->addActions(act_list);
58 |
59 | mSysTrayMenuLangSetting->addAction(act_sys_tray_lang_ch);
60 | mSysTrayMenuLangSetting->addAction(act_sys_tray_lang_en);
61 |
62 | mSysTrayMenu->addMenu(mSysTrayMenuLangSetting);
63 |
64 | //新增菜单项---显示主界面
65 | mSysTrayMenu->addAction(act_sys_tray_normal);
66 | //新增菜单项---最小化
67 | mSysTrayMenu->addAction(act_sys_tray_min);
68 |
69 | //增加分隔符
70 | mSysTrayMenu->addSeparator();
71 |
72 | //新增菜单项---退出程序
73 | mSysTrayMenu->addAction(act_sys_tray_exit);
74 |
75 |
76 |
77 | // mSysTrayMenuLangSetting
78 |
79 | //把QMenu,系统托盘菜单赋给QSystemTrayIcon对象
80 | // mSysTrayIcon->setContextMenu(mSysTrayMenu); //new之后才能使用mSysTrayIcon
81 | }
82 |
83 |
84 | //创建系统托盘按钮
85 | void SystemTrayIcon::create_sysTrayIcon()
86 | {
87 | if (!QSystemTrayIcon::isSystemTrayAvailable()) //判断系统是否支持系统托盘图标
88 | {
89 | return;
90 | }
91 |
92 | mSysTrayIcon = new QSystemTrayIcon(pWidget);
93 | mSysTrayIcon->setIcon(m_icon); //设置图标图片
94 | mSysTrayIcon->setToolTip(m_strList.at(1)); //托盘时,鼠标放上去的提示信息
95 | mSysTrayIcon->showMessage(m_strList.at(0), m_strList.at(1), QSystemTrayIcon::Information, 10000);
96 |
97 | // mSysTrayIcon = new QSystemTrayIcon(this);//新建QSystemTrayIcon对象
98 | // mSysTrayIcon->setIcon(QIcon(":/images/ico/mini.png")); //设置托盘的icon
99 | // mSysTrayIcon->setStyleSheet("background-color:transparent;");
100 | // mSysTrayIcon->setToolTip(QObject::tr("login_demo"));//当鼠标移动到托盘上的图标时,会显示此处设置的内容
101 |
102 | mSysTrayIcon->setContextMenu(mSysTrayMenu);//设置托盘上下文菜单
103 |
104 | mSysTrayIcon->show();//在系统托盘显示此对象
105 |
106 | //给QSystemTrayIcon对象mSysTrayIcon添加信号为activated(QSystemTrayIcon::ActivationReason)的槽函数
107 | connect(mSysTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
108 | this, SLOT(slot_sys_tray_iconActivated(QSystemTrayIcon::ActivationReason)));
109 |
110 | }
111 |
112 |
113 |
114 |
115 |
116 | //系统托盘触发槽函数
117 | /*********************
118 | enum QSystemTrayIcon::ActivationReason 表述托盘上图标的触发缘由
119 | 常量 值 描述
120 | QSystemTrayIcon::Unknown 0 未知原因
121 | QSystemTrayIcon::Context 1 请求系统托盘的上下文菜单
122 | QSystemTrayIcon::DoubleClick 2 鼠标双击
123 | QSystemTrayIcon::Trigger 3 鼠标单击
124 | QSystemTrayIcon::MiddleClick 4 鼠标中间按键
125 | **********************/
126 | void SystemTrayIcon::slot_sys_tray_iconActivated(QSystemTrayIcon::ActivationReason reason)
127 | {
128 | switch (reason)
129 | {
130 | case QSystemTrayIcon::Unknown: //未知原因
131 | break;
132 | case QSystemTrayIcon::Context: //请求系统托盘的上下文菜单
133 | break;
134 | case QSystemTrayIcon::DoubleClick: //鼠标双击
135 | pWidget->setWindowState(Qt::WindowActive);
136 | pWidget->show();
137 | break;
138 | case QSystemTrayIcon::Trigger: //鼠标单击
139 |
140 | break;
141 | case QSystemTrayIcon::MiddleClick: //鼠标中间按键
142 | break;
143 | default:
144 | break;
145 | }
146 |
147 | }
148 |
149 | void SystemTrayIcon::set_lang(QAction *act)
150 | {
151 | qDebug() << act->text();
152 | if (act == act_sys_tray_lang_ch)
153 | {
154 | qDebug() << "china ";
155 | translator.load(":/cn.qm");
156 | qApp->installTranslator(&translator);
157 |
158 | }
159 | if (act == act_sys_tray_lang_en)
160 | {
161 | qDebug() << "english ";
162 | translator.load(":/en.qm");
163 | qApp->installTranslator(&translator);
164 | }
165 | this->refresh();//刷新托盘相关文字
166 | emit signal_lang_refresh();//发送刷新页面文字的信号
167 | }
168 |
169 |
170 | void SystemTrayIcon::refresh()
171 | {
172 | this->act_sys_tray_exit->setText(tr("退出(&Q)"));
173 | this->act_sys_tray_min->setText(tr("最小化(&M)"));
174 | this->act_sys_tray_lang_ch->setText(tr("简体中文(&C)"));
175 | this->act_sys_tray_lang_en->setText(tr("英语(&E)"));
176 | this->act_sys_tray_normal->setText(tr("还 原(&R)"));
177 | this->mSysTrayMenuLangSetting->setWindowTitle(tr("语言设置"));
178 | qDebug() << "lllllllllllll" << this->mSysTrayMenuLangSetting->windowTitle();
179 |
180 | }
181 |
--------------------------------------------------------------------------------
/src/register.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Register
4 |
5 |
6 |
7 | 0
8 | 0
9 | 244
10 | 314
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 | /* === Shared === */
19 | QLabel, QPushButton, QDialog
20 | {
21 | background-color: #222222;
22 | color: #BBBBBB;
23 | font-family: "Segoe UI";
24 | }
25 |
26 | /* === QWidget === */
27 | QWidget:window {
28 | background: #222222;
29 | color: #BBBBBB;
30 | font-family: "Segoe UI";
31 | }
32 |
33 | /* === QToolTip === */
34 | QToolTip {
35 | background-color: #000000;
36 | border: 2px solid #333333;
37 | color: yellow;
38 | }
39 |
40 | /* === QPushButton === */
41 | QPushButton {
42 | border: 1px solid #333333;
43 | padding: 4px;
44 | min-width: 65px;
45 | min-height: 12px;
46 | }
47 |
48 | QPushButton:hover {
49 | background-color: #333333;
50 | border-color: #444444;
51 | }
52 |
53 | QPushButton:pressed {
54 | background-color: #111111;
55 | border-color: #333333;
56 | color: yellow;
57 | }
58 |
59 | QPushButton:disabled {
60 | color: #333333;
61 | }
62 |
63 | /* =================== */
64 | QLineEdit{
65 | background-color: black;
66 | color: #BBBBBB;
67 | border: 1px solid #333333;
68 | }
69 | /* Nice Windows-XP-style password character. */
70 | QLineEdit[echoMode="2"] {
71 | lineedit-password-character: 9679;
72 | }
73 |
74 | /* We provide a min-width and min-height for push buttons
75 | so that they look elegant regardless of the width of the text. */
76 | QPushButton {
77 | background-color: palegoldenrod;
78 | border-width: 2px;
79 | border-color: darkkhaki;
80 | border-style: solid;
81 | border-radius: 5px;
82 | padding: 3px;
83 | min-width: 9ex;
84 | min-height: 2.5ex;
85 | }
86 |
87 | QPushButton:hover {
88 | background-color: khaki;
89 | }
90 |
91 | /* Increase the padding, so the text is shifted when the button is
92 | pressed. */
93 | QPushButton:pressed {
94 | padding-left: 5px;
95 | padding-top: 5px;
96 | background-color: #d0d67c;
97 | }
98 |
99 | QLabel, QAbstractButton {
100 | font: bold;
101 | }
102 |
103 | QLineEdit, QFrame {
104 | border-width: 1px;
105 | padding: 1px;
106 | border-style: solid;
107 | border-color: darkkhaki;
108 | border-radius: 5px;
109 | }
110 |
111 | /* As mentioned above, eliminate the padding and increase the border. */
112 | QLineEdit:focus, QFrame:focus {
113 | border-width: 3px;
114 | padding: 0px;
115 | }
116 |
117 | /* A QLabel is a QFrame */
118 | QLabel {
119 | border: none;
120 | padding: 0;
121 | background: none;
122 | }
123 |
124 |
125 |
126 |
127 |
128 |
129 | 30
130 | 40
131 | 72
132 | 20
133 |
134 |
135 |
136 | username
137 |
138 |
139 |
140 |
141 |
142 | 30
143 | 80
144 | 72
145 | 20
146 |
147 |
148 |
149 | password
150 |
151 |
152 |
153 |
154 |
155 | 30
156 | 120
157 | 72
158 | 20
159 |
160 |
161 |
162 | confirm
163 |
164 |
165 |
166 |
167 |
168 | 30
169 | 160
170 | 72
171 | 20
172 |
173 |
174 |
175 | email
176 |
177 |
178 |
179 |
180 |
181 | 120
182 | 40
183 | 91
184 | 20
185 |
186 |
187 |
188 |
189 |
190 |
191 | 120
192 | 80
193 | 91
194 | 20
195 |
196 |
197 |
198 |
199 |
200 |
201 | 120
202 | 120
203 | 91
204 | 20
205 |
206 |
207 |
208 |
209 |
210 |
211 | 120
212 | 160
213 | 91
214 | 20
215 |
216 |
217 |
218 |
219 |
220 |
221 | 80
222 | 250
223 | 75
224 | 31
225 |
226 |
227 |
228 | register
229 |
230 |
231 |
232 |
233 |
234 | 30
235 | 200
236 | 72
237 | 20
238 |
239 |
240 |
241 | server
242 |
243 |
244 |
245 |
246 |
247 | 120
248 | 200
249 | 91
250 | 20
251 |
252 |
253 |
254 |
255 |
256 | lineEditName
257 | lineEditPassword
258 | lineEditPasswordCheck
259 | lineEditEmail
260 | lineEditServer
261 | registerCheckButton
262 |
263 |
264 |
265 |
266 |
--------------------------------------------------------------------------------
/src/login.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Login
4 |
5 |
6 |
7 | 0
8 | 0
9 | 427
10 | 330
11 |
12 |
13 |
14 |
15 | 427
16 | 330
17 |
18 |
19 |
20 |
21 | 427
22 | 330
23 |
24 |
25 |
26 | Login
27 |
28 |
29 | true
30 |
31 |
32 |
33 |
34 | 330
35 | 200
36 | 91
37 | 23
38 |
39 |
40 |
41 |
42 | 9
43 |
44 |
45 |
46 | color: rgb(11, 163, 219);
47 |
48 |
49 | Register
50 |
51 |
52 | true
53 |
54 |
55 |
56 |
57 |
58 | 130
59 | 227
60 | 193
61 | 26
62 |
63 |
64 |
65 |
66 | 170
67 | 22
68 |
69 |
70 |
71 |
72 | 12
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | 130
83 | 196
84 | 193
85 | 29
86 |
87 |
88 |
89 |
90 | 12
91 |
92 |
93 |
94 | true
95 |
96 |
97 |
98 |
99 |
100 | 0
101 | 0
102 | 427
103 | 185
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | 30
114 | 195
115 | 80
116 | 80
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | 170
127 | 290
128 | 100
129 | 26
130 |
131 |
132 |
133 | login
134 |
135 |
136 | Return
137 |
138 |
139 |
140 |
141 |
142 | 259
143 | 261
144 | 16
145 | 16
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 | 278
156 | 261
157 | 81
158 | 16
159 |
160 |
161 |
162 | Auto Login
163 |
164 |
165 |
166 |
167 |
168 | 133
169 | 261
170 | 16
171 | 16
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 | 152
182 | 261
183 | 91
184 | 16
185 |
186 |
187 |
188 | Remember Me
189 |
190 |
191 |
192 |
193 |
194 | 20
195 | 290
196 | 121
197 | 29
198 |
199 |
200 |
201 |
202 | 12
203 |
204 |
205 |
206 | true
207 |
208 |
209 |
210 |
211 |
212 | 40
213 | 270
214 | 62
215 | 20
216 |
217 |
218 |
219 | color: rgb(46, 52, 54);
220 |
221 |
222 | Server
223 |
224 |
225 | Qt::AutoText
226 |
227 |
228 | Qt::AlignCenter
229 |
230 |
231 |
232 |
233 |
234 | 310
235 | 290
236 | 100
237 | 26
238 |
239 |
240 |
241 | anonymous
242 |
243 |
244 |
245 |
246 |
247 | cBox_server
248 | cBox_account
249 | lineEdit_passwd
250 | checkBox_rPasswd
251 | btn_login
252 | btn_annonymous
253 | checkBox_autoLogin
254 | btn_regist
255 |
256 |
257 |
258 |
259 |
--------------------------------------------------------------------------------
/resources/qss.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/qss/black.qss
4 | images/qss/Black/arrowBottom.png
5 | images/qss/Black/arrowLeft.png
6 | images/qss/Black/arrowRight.png
7 | images/qss/Black/arrowTop.png
8 | images/qss/Black/bottomArrow.png
9 | images/qss/Black/bottomArrowHover.png
10 | images/qss/Black/checkBox.png
11 | images/qss/Black/checkBoxChecked.png
12 | images/qss/Black/checkBoxCheckedHover.png
13 | images/qss/Black/checkBoxCheckedPressed.png
14 | images/qss/Black/checkBoxHover.png
15 | images/qss/Black/checkBoxIndeterminate.png
16 | images/qss/Black/checkBoxIndeterminateHover.png
17 | images/qss/Black/checkBoxIndeterminatePressed.png
18 | images/qss/Black/checkBoxPressed.png
19 | images/qss/Black/close.png
20 | images/qss/Black/closeHover.png
21 | images/qss/Black/closePressed.png
22 | images/qss/Black/delete.png
23 | images/qss/Black/deleteHover.png
24 | images/qss/Black/deletePressed.png
25 | images/qss/Black/downButton.png
26 | images/qss/Black/error.png
27 | images/qss/Black/feedback.png
28 | images/qss/Black/feedbackHover.png
29 | images/qss/Black/feedbackPressed.png
30 | images/qss/Black/information.png
31 | images/qss/Black/left.png
32 | images/qss/Black/maximize.png
33 | images/qss/Black/maximizeHover.png
34 | images/qss/Black/maximizePressed.png
35 | images/qss/Black/minimize.png
36 | images/qss/Black/minimizeHover.png
37 | images/qss/Black/minimizePressed.png
38 | images/qss/Black/nscc.png
39 | images/qss/Black/open.png
40 | images/qss/Black/openHover.png
41 | images/qss/Black/openPressed.png
42 | images/qss/Black/progressBar.png
43 | images/qss/Black/progressBarChunk.png
44 | images/qss/Black/question.png
45 | images/qss/Black/radioButton.png
46 | images/qss/Black/radioButtonChecked.png
47 | images/qss/Black/radioButtonCheckedHover.png
48 | images/qss/Black/radioButtonCheckedPressed.png
49 | images/qss/Black/radioButtonHover.png
50 | images/qss/Black/radioButtonPressed.png
51 | images/qss/Black/restore.png
52 | images/qss/Black/restoreHover.png
53 | images/qss/Black/restorePressed.png
54 | images/qss/Black/right.png
55 | images/qss/Black/scan.png
56 | images/qss/Black/skin.png
57 | images/qss/Black/skinHover.png
58 | images/qss/Black/skinPressed.png
59 | images/qss/Black/success.png
60 | images/qss/Black/topArrow.png
61 | images/qss/Black/topArrowHover.png
62 | images/qss/Black/transfer.png
63 | images/qss/Black/upButton.png
64 | images/qss/Black/warning.png
65 | images/qss/White/arrowBottom.png
66 | images/qss/White/arrowLeft.png
67 | images/qss/White/arrowRight.png
68 | images/qss/White/arrowTop.png
69 | images/qss/White/bottomArrow.png
70 | images/qss/White/bottomArrowHover.png
71 | images/qss/White/checkBox.png
72 | images/qss/White/checkBoxChecked.png
73 | images/qss/White/checkBoxCheckedHover.png
74 | images/qss/White/checkBoxCheckedPressed.png
75 | images/qss/White/checkBoxHover.png
76 | images/qss/White/checkBoxIndeterminate.png
77 | images/qss/White/checkBoxIndeterminateHover.png
78 | images/qss/White/checkBoxIndeterminatePressed.png
79 | images/qss/White/checkBoxPressed.png
80 | images/qss/White/close.png
81 | images/qss/White/closeHover.png
82 | images/qss/White/closePressed.png
83 | images/qss/White/delete.png
84 | images/qss/White/deleteHover.png
85 | images/qss/White/deletePressed.png
86 | images/qss/White/downButton.png
87 | images/qss/White/error.png
88 | images/qss/White/feedback.png
89 | images/qss/White/feedbackHover.png
90 | images/qss/White/feedbackPressed.png
91 | images/qss/White/information.png
92 | images/qss/White/left.png
93 | images/qss/White/maximize.png
94 | images/qss/White/maximizeHover.png
95 | images/qss/White/maximizePressed.png
96 | images/qss/White/minimize.png
97 | images/qss/White/minimizeHover.png
98 | images/qss/White/minimizePressed.png
99 | images/qss/White/nscc.png
100 | images/qss/White/open.png
101 | images/qss/White/openHover.png
102 | images/qss/White/openPressed.png
103 | images/qss/White/progressBar.png
104 | images/qss/White/progressBarChunk.png
105 | images/qss/White/question.png
106 | images/qss/White/radioButton.png
107 | images/qss/White/radioButtonChecked.png
108 | images/qss/White/radioButtonCheckedHover.png
109 | images/qss/White/radioButtonCheckedPressed.png
110 | images/qss/White/radioButtonHover.png
111 | images/qss/White/radioButtonPressed.png
112 | images/qss/White/restore.png
113 | images/qss/White/restoreHover.png
114 | images/qss/White/restorePressed.png
115 | images/qss/White/right.png
116 | images/qss/White/scan.png
117 | images/qss/White/skin.png
118 | images/qss/White/skinHover.png
119 | images/qss/White/skinPressed.png
120 | images/qss/White/success.png
121 | images/qss/White/topArrow.png
122 | images/qss/White/topArrowHover.png
123 | images/qss/White/transfer.png
124 | images/qss/White/upButton.png
125 | images/qss/White/warning.png
126 | images/qss/white.qss
127 |
128 |
129 |
--------------------------------------------------------------------------------
/resources/cn.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Exam
6 |
7 |
8 | MainWindow
9 | 在线考试
10 |
11 |
12 |
13 | 测试 to do
14 | 测试 to do
15 |
16 |
17 |
18 | 在线考试
19 | 在线考试
20 |
21 |
22 |
23 | Login
24 |
25 |
26 | Login
27 | 登录
28 |
29 |
30 |
31 | 注册帐号
32 | 注册帐号
33 |
34 |
35 |
36 |
37 | 找回密码
38 | 找回密码
39 |
40 |
41 |
42 |
43 |
44 | 登录
45 | 登录
46 |
47 |
48 |
49 |
50 | 记住密码
51 | 记住密码
52 |
53 |
54 |
55 |
56 | 自动登录
57 | 自动登录
58 |
59 |
60 |
61 | 最小化
62 | 最小化
63 |
64 |
65 |
66 | 关闭
67 | 关闭
68 |
69 |
70 |
71 | 设置
72 | 设置
73 |
74 |
75 |
76 | 虚拟键盘
77 | 虚拟键盘
78 |
79 |
80 |
81 | 简体中文
82 | 简体中文
83 |
84 |
85 |
86 | English
87 | 英语
88 |
89 |
90 |
91 | 在线
92 | 在线
93 |
94 |
95 |
96 | 隐身
97 | 隐身
98 |
99 |
100 |
101 | 离线
102 | 离线
103 |
104 |
105 |
106 | 忙碌
107 | 忙碌
108 |
109 |
110 |
111 |
112 |
113 |
114 | 警告
115 | 警告
116 |
117 |
118 |
119 |
120 |
121 | 请输入用户名和密码!
122 | 请输入用户名和密码!
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | 提示
131 | 提示
132 |
133 |
134 |
135 |
136 | 用户不存在!
137 | 用户不存在!
138 |
139 |
140 |
141 |
142 | 用户密码错误!
143 | 用户密码错误!
144 |
145 |
146 |
147 | 注册成功!
148 | 注册成功!
149 |
150 |
151 |
152 | 用户已存在!
153 | 用户已存在!
154 |
155 |
156 |
157 | 注册用户
158 | 注册用户
159 |
160 |
161 |
162 | Register
163 |
164 |
165 | Dialog
166 | 注册信息
167 |
168 |
169 |
170 | 用户名
171 | 用户名
172 |
173 |
174 |
175 | 密码
176 | 密码
177 |
178 |
179 |
180 | 确认密码
181 | 确认密码
182 |
183 |
184 |
185 | 邮箱
186 | 邮箱
187 |
188 |
189 |
190 |
191 | 注册
192 | 注册
193 |
194 |
195 |
196 | SystemTrayIcon
197 |
198 |
199 |
200 | 最小化(&M)
201 | 最小化(&M)
202 |
203 |
204 |
205 |
206 | 还 原(&R)
207 | 还 原(&R)
208 |
209 |
210 |
211 |
212 | 退出(&Q)
213 | 退出(&Q)
214 |
215 |
216 |
217 |
218 | 简体中文(&C)
219 | 简体中文(&C)
220 |
221 |
222 |
223 |
224 | 英语(&E)
225 | 英语(&E)
226 |
227 |
228 |
229 |
230 | 语言设置
231 | 语言
232 | 语言设置
233 |
234 |
235 |
236 | passwdEdit
237 |
238 |
239 | Dialog
240 | 注册信息
241 |
242 |
243 |
244 | 旧 密 码:
245 | 旧密码:
246 |
247 |
248 |
249 | 新 密 码:
250 | 新密码:
251 |
252 |
253 |
254 | 确认密码:
255 | 确认密码:
256 |
257 |
258 |
259 | 确定
260 | 确定
261 |
262 |
263 |
264 | 取消
265 | 取消
266 |
267 |
268 |
269 | 修改密码
270 | 修改密码
271 |
272 |
273 |
274 |
275 |
276 | 警告
277 | 警告
278 |
279 |
280 |
281 | 密码为空!
282 | 密码为空!
283 |
284 |
285 |
286 | 新密码与旧密码一样!
287 | 新密码与旧密码一样!
288 |
289 |
290 |
291 |
292 | 提示
293 | 提示
294 |
295 |
296 |
297 | 密码修改失败!
298 | 密码修改失败!
299 |
300 |
301 |
302 | 密码修改成功!
303 | 密码修改成功!
304 |
305 |
306 |
307 | 旧密码输入错误!
308 | 旧密码输入错误!
309 |
310 |
311 |
312 |
--------------------------------------------------------------------------------
/resources/en.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Exam
6 |
7 |
8 | MainWindow
9 | online
10 |
11 |
12 |
13 | 测试 to do
14 | test to do
15 |
16 |
17 |
18 | 在线考试
19 | online
20 |
21 |
22 |
23 | Login
24 |
25 |
26 | Login
27 | Login
28 |
29 |
30 |
31 | 注册帐号
32 | Register user
33 |
34 |
35 |
36 |
37 | 找回密码
38 | Find Password
39 |
40 |
41 |
42 |
43 |
44 | 登录
45 | Login
46 |
47 |
48 |
49 |
50 | 记住密码
51 | Remember Psw
52 |
53 |
54 |
55 |
56 | 自动登录
57 | Auto Login
58 |
59 |
60 |
61 | 最小化
62 | min
63 |
64 |
65 |
66 | 关闭
67 | close
68 |
69 |
70 |
71 | 设置
72 | setting
73 |
74 |
75 |
76 | 虚拟键盘
77 | Virtual KeyWord
78 |
79 |
80 |
81 | 简体中文
82 | Simp Chinese
83 |
84 |
85 |
86 | English
87 | English
88 |
89 |
90 |
91 | 在线
92 | online
93 |
94 |
95 |
96 | 隐身
97 | hiding
98 |
99 |
100 |
101 | 离线
102 | out online
103 |
104 |
105 |
106 | 忙碌
107 | busy
108 |
109 |
110 |
111 |
112 |
113 |
114 | 警告
115 | Warnning
116 |
117 |
118 |
119 |
120 |
121 | 请输入用户名和密码!
122 | Please input user name and psw!
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | 提示
131 | Info
132 |
133 |
134 |
135 |
136 | 用户不存在!
137 | user is not exist!
138 |
139 |
140 |
141 |
142 | 用户密码错误!
143 | User psw error!
144 |
145 |
146 |
147 | 注册成功!
148 | Register OK!
149 |
150 |
151 |
152 | 用户已存在!
153 | User is exist!
154 |
155 |
156 |
157 | 注册用户
158 | Register USer
159 |
160 |
161 |
162 | Register
163 |
164 |
165 | Dialog
166 | Register Info
167 |
168 |
169 |
170 | 用户名
171 | User Name
172 |
173 |
174 |
175 | 密码
176 | User Password
177 |
178 |
179 |
180 | 确认密码
181 | Re Password
182 |
183 |
184 |
185 | 邮箱
186 | Email
187 |
188 |
189 |
190 |
191 | 注册
192 | Register
193 |
194 |
195 |
196 | SystemTrayIcon
197 |
198 |
199 |
200 | 最小化(&M)
201 | Min(&M)
202 |
203 |
204 |
205 |
206 | 还 原(&R)
207 | Restore(&R)
208 |
209 |
210 |
211 |
212 | 退出(&Q)
213 | Exit(&Q)
214 |
215 |
216 |
217 |
218 | 简体中文(&C)
219 | China(&C)
220 |
221 |
222 |
223 |
224 | 英语(&E)
225 | English(&E)
226 |
227 |
228 |
229 |
230 | 语言设置
231 | 语言
232 | Language
233 |
234 |
235 |
236 | passwdEdit
237 |
238 |
239 | Dialog
240 | Register
241 |
242 |
243 |
244 | 旧 密 码:
245 | Old Psw:
246 |
247 |
248 |
249 | 新 密 码:
250 | New Psw:
251 |
252 |
253 |
254 | 确认密码:
255 | Reput Psw:
256 |
257 |
258 |
259 | 确定
260 | OK
261 |
262 |
263 |
264 | 取消
265 | Cannel
266 |
267 |
268 |
269 | 修改密码
270 | edit psw
271 |
272 |
273 |
274 |
275 |
276 | 警告
277 | Warnning
278 |
279 |
280 |
281 | 密码为空!
282 | Psw is NULL!
283 |
284 |
285 |
286 | 新密码与旧密码一样!
287 | Old psw as same as new psw!
288 |
289 |
290 |
291 |
292 | 提示
293 | Info
294 |
295 |
296 |
297 | 密码修改失败!
298 | Psw edit error!
299 |
300 |
301 |
302 | 密码修改成功!
303 | Psw chang ok!
304 |
305 |
306 |
307 | 旧密码输入错误!
308 | Old psw input error!
309 |
310 |
311 |
312 |
--------------------------------------------------------------------------------
/src/AccountManager.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by peter on 19-5-27.
3 | //
4 |
5 | #include "AccountManager.h"
6 | #include
7 | #include
8 | #include
9 |
10 |
11 | void AccountManager::registerUser(const QString &email)
12 | {
13 | //TODO QNetworkReply不会自动释放空间,一定要主动处理内存释放,可以调用QObject::deleteLater令其自动释放空间
14 | //TODO utf转码
15 | QUrl url("http://"+server+"/register");
16 | QUrlQuery query;
17 | query.addQueryItem("username", username);
18 | //MD5 加密
19 | QCryptographicHash md5(QCryptographicHash::Md5);
20 | md5.addData(QByteArray(password.toStdString().c_str()));
21 | query.addQueryItem("password", md5.result().toHex());
22 | query.addQueryItem("email", email);
23 | url.setQuery(query);
24 | QNetworkReply *reply = manager.get(QNetworkRequest(url));
25 | connect(reply, SIGNAL(finished()), this, SLOT(on_register_finished()));
26 | }
27 |
28 | void AccountManager::login()
29 | {
30 | QUrl url("http://"+server+"/login");
31 | QUrlQuery query;
32 | query.addQueryItem("username", username);
33 | //MD5 加密
34 | QCryptographicHash md5(QCryptographicHash::Md5);
35 | md5.addData(QByteArray(password.toStdString().c_str()));
36 | query.addQueryItem("password", md5.result().toHex());
37 | url.setQuery(query);
38 | QNetworkReply *reply = manager.get(QNetworkRequest(url));
39 | connect(reply, SIGNAL(finished()), this, SLOT(on_login_finished()));
40 | }
41 |
42 | void AccountManager::uploadFile(QString filename, QString content)
43 | {
44 | QUrl url("http://"+server+"/uploadFile");
45 | // QUrlQuery query;
46 | // query.addQueryItem("token", token);
47 | // query.addQueryItem("filename", filename);
48 | // query.addQueryItem("content", content);
49 | // url.setQuery(query);
50 | QByteArray postData(QString("token=%1&filename=%2&content=%3").arg(token).arg(filename).arg(urlEncode(content)).toUtf8());
51 | QNetworkRequest request(url);
52 | request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
53 | QNetworkReply *reply = manager.post(request,postData);
54 | connect(reply, SIGNAL(finished()), this, SLOT(on_uploadFile_finished()));
55 | }
56 |
57 | //void AccountManager::updateFile(QString filename, QString content)
58 | //{
59 | // QUrl url("http://"+server+"/updateFile");
60 | // QByteArray postData(QString("{token:\"%1\", filename:\"%2\", content: \"%3\"}").arg(token).arg(filename).arg(content).toUtf8());
61 | // QNetworkRequest request(url);
62 | // request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
63 | // QNetworkReply *reply = manager.post(request,postData);
64 | // connect(reply, SIGNAL(finished()), this, SLOT(on_updateFile_finished()));
65 | //}
66 |
67 | void AccountManager::getContent(QString filename)
68 | {
69 | QUrl url("http://"+server+"/getContent");
70 | QUrlQuery query;
71 | query.addQueryItem("token", token);
72 | query.addQueryItem("filename", filename);
73 | url.setQuery(query);
74 | QNetworkReply *reply = manager.get(QNetworkRequest(url));
75 | connect(reply, SIGNAL(finished()), this, SLOT(on_getContent_finished()));
76 | }
77 |
78 | void AccountManager::getFiles()
79 | {
80 | QUrl url("http://"+server+"/getFiles");
81 | QUrlQuery query;
82 | query.addQueryItem("token", token);
83 | url.setQuery(query);
84 | QNetworkReply *reply = manager.get(QNetworkRequest(url));
85 | connect(reply, SIGNAL(finished()), this, SLOT(on_getFiles_finished()));
86 | }
87 |
88 | void AccountManager::deleteFile(QString filename)
89 | {
90 | QUrl url("http://"+server+"/deleteFile");
91 | QUrlQuery query;
92 | query.addQueryItem("token", token);
93 | query.addQueryItem("filename", filename);
94 | url.setQuery(query);
95 | QNetworkReply *reply = manager.get(QNetworkRequest(url));
96 | connect(reply, SIGNAL(finished()), this, SLOT(on_deleteFile_finished()));
97 | }
98 |
99 | void AccountManager::on_register_finished()
100 | {
101 | // QString buffer = QString::fromStdString(((QNetworkReply *)sender())->readAll().toStdString()).toUtf8();
102 | // QJsonDocument document = QJsonDocument::fromJson(buffer.toUtf8());
103 | QByteArray buffer = ((QNetworkReply *)sender())->readAll();
104 | QJsonDocument document = QJsonDocument::fromJson(buffer);
105 | if(document.isObject())
106 | {
107 | QJsonObject object = document.object();
108 | if(object.contains("error"))
109 | {
110 | QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
111 | } else if(object.contains("message"))
112 | {
113 | QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString());
114 | } else
115 | {
116 | QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
117 | }
118 | }
119 | ((QNetworkReply *)sender())->deleteLater();
120 | }
121 |
122 | void AccountManager::on_login_finished()
123 | {
124 | QByteArray buffer = ((QNetworkReply *)sender())->readAll();
125 | QJsonDocument document = QJsonDocument::fromJson(buffer);
126 | if(document.isObject())
127 | {
128 | QJsonObject object = document.object();
129 | if(object.contains("error"))
130 | {
131 | QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
132 | } else if(object.contains("message")&&object.contains("token"))
133 | {
134 | token = object.value("token").toString();
135 | emit login_success();//成功
136 | // QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString()+"!");
137 | } else
138 | {
139 | QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
140 | }
141 | }
142 | ((QNetworkReply *)sender())->deleteLater();
143 | }
144 |
145 | void AccountManager::on_uploadFile_finished()
146 | {
147 | QByteArray buffer = ((QNetworkReply *)sender())->readAll();
148 | QJsonDocument document = QJsonDocument::fromJson(buffer);
149 | if(document.isObject())
150 | {
151 | QJsonObject object = document.object();
152 | if(object.contains("error"))
153 | {
154 | QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
155 | } else if(object.contains("message"))
156 | {
157 | QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString());
158 | } else
159 | {
160 | QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
161 | }
162 | }
163 | ((QNetworkReply *)sender())->deleteLater();
164 | }
165 |
166 | //void AccountManager::on_updateFile_finished()
167 | //{
168 | // QByteArray buffer = ((QNetworkReply *)sender())->readAll();
169 | // QJsonDocument document = QJsonDocument::fromJson(buffer);
170 | // if(document.isObject())
171 | // {
172 | // QJsonObject object = document.object();
173 | // if(object.contains("error"))
174 | // {
175 | // QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
176 | // } else if(object.contains("message"))
177 | // {
178 | // QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString());
179 | // } else
180 | // {
181 | // QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
182 | // }
183 | // }
184 | // ((QNetworkReply *)sender())->deleteLater();
185 | //}
186 |
187 | void AccountManager::on_getContent_finished()
188 | {
189 | QByteArray buffer = ((QNetworkReply *)sender())->readAll();
190 | QJsonDocument document = QJsonDocument::fromJson(buffer);
191 | if(document.isObject())
192 | {
193 | QJsonObject object = document.object();
194 | if(object.contains("error"))
195 | {
196 | QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
197 | } else if(object.contains("message")&&object.contains("content"))
198 | {
199 | emit return_content(object.value("content").toString());
200 | // QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString());
201 | } else
202 | {
203 | QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
204 | }
205 | }
206 | ((QNetworkReply *)sender())->deleteLater();
207 | }
208 |
209 | void AccountManager::on_getFiles_finished()
210 | {
211 | QByteArray buffer = ((QNetworkReply *)sender())->readAll();
212 | QJsonDocument document = QJsonDocument::fromJson(buffer);
213 | if(document.isObject())
214 | {
215 | QJsonObject object = document.object();
216 | if(object.contains("error"))
217 | {
218 | QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
219 | } else if(object.contains("message")&&object.contains("files")&&object.value("files").isArray())
220 | {
221 | QJsonArray fileArray = object.value("files").toArray();
222 | QList *fileList = new QList();
223 | //TODO 记得释放fileList
224 | foreach(QJsonValue entry, fileArray)
225 | {
226 | fileList->append(entry.toObject().value("fileName").toString().split("-").value(1));
227 | }
228 | emit return_files_list(fileList);
229 | // QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString());
230 | } else
231 | {
232 | QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
233 | }
234 | }
235 | ((QNetworkReply *)sender())->deleteLater();
236 | }
237 |
238 | void AccountManager::on_deleteFile_finished()
239 | {
240 | QByteArray buffer = ((QNetworkReply *)sender())->readAll();
241 | QJsonDocument document = QJsonDocument::fromJson(buffer);
242 | if(document.isObject())
243 | {
244 | QJsonObject object = document.object();
245 | if(object.contains("error"))
246 | {
247 | QMessageBox::warning((QWidget *)parent(), "error", object.value("error").toString());
248 | } else if(object.contains("message"))
249 | {
250 | QMessageBox::information((QWidget *)parent(), "message", object.value("message").toString());
251 | } else
252 | {
253 | QMessageBox::warning((QWidget *)parent(), "error", "invalid server!");
254 | }
255 | }
256 | ((QNetworkReply *)sender())->deleteLater();
257 | }
258 |
259 | AccountManager::AccountManager(QWidget *parent):manager(parent)
260 | {
261 |
262 | }
263 |
264 | QString AccountManager::urlEncode(QString string)
265 | {
266 | return string
267 | .replace("%", "%25")
268 | .replace(" ","%20")
269 | .replace("\"", "%22")
270 | .replace("#", "%23")
271 | .replace("&", "%26")
272 | .replace("(", "%28")
273 | .replace(")", "%29")
274 | .replace("+", "%2B")
275 | .replace(",", "%2C")
276 | .replace("/", "%2F")
277 | .replace(":", "%3A")
278 | .replace(";", "%3B")
279 | .replace("<", "%3C")
280 | .replace("=", "%3D")
281 | .replace(">", "%3E")
282 | .replace("?", "%3F")
283 | .replace("@", "%40")
284 | .replace("\\", "%5C")
285 | .replace("|", "%7C");
286 | ;
287 | }
288 |
289 | const QString &AccountManager::getUsername() const
290 | {
291 | return username;
292 | }
293 |
294 | const QString &AccountManager::getServer() const
295 | {
296 | return server;
297 | }
298 |
299 | AccountManager::~AccountManager()
300 | = default;
--------------------------------------------------------------------------------
/src/login.cpp:
--------------------------------------------------------------------------------
1 | #include "login.h"
2 | #include "ui_login.h"
3 |
4 | #include "register.h"
5 | #include "systemtrayicon.h"
6 | #include "editor.h"
7 |
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | float opacity1 = 0.0, opacity2 = 1.0;
17 |
18 | Login::Login(QWidget *parent) :
19 | QWidget(parent),
20 | ui(new Ui::Login)
21 | {
22 | ui->setupUi(this);
23 | manager = new AccountManager();
24 |
25 | init();
26 | connect(this, SIGNAL(close()), this, SLOT(close()));
27 | connect(manager, SIGNAL(login_success()), this, SLOT(login_success()));
28 | }
29 |
30 | Login::Login(QWidget *parent, AccountManager *manager_ptr, Editor* editor) :
31 | QWidget(parent),
32 | ui(new Ui::Login)
33 | {
34 | ui->setupUi(this);
35 | parentEditor=editor;
36 | manager = manager_ptr;
37 | init();
38 | }
39 |
40 | Login::~Login()
41 | {
42 | delete ui;
43 | }
44 |
45 | void Login::showAgain()
46 | {
47 | ui->btn_regist->hide();
48 | ui->btn_annonymous->hide();
49 | connect(this, SIGNAL(close()), this, SLOT(close()));
50 | connect(manager, SIGNAL(login_success()), this, SLOT(login_success_without_entering()));
51 | show();
52 | }
53 |
54 | void Login::init()
55 | {
56 | setWindowTitle(tr("login"));
57 |
58 | // ui->btn_edit_pwd->setStyleSheet("background-color:transparent;");
59 | // ui->btn_regist->setStyleSheet("background-color:transparent;");
60 | // ui->btn_login->setStyleSheet("background-color:transparent;");
61 |
62 | m_Drag = false;
63 |
64 | timer1 = new QTimer;
65 | timer1->start(5);
66 | timer2 = new QTimer;
67 | connect(timer1, SIGNAL(timeout()), this, SLOT(slot_timer1()));
68 | connect(timer2, SIGNAL(timeout()), this, SLOT(slot_timer2()));
69 |
70 | configWindow();//UI界面设置 去边框,最小化,最大化button
71 | init_sql();//初始化界面密码,帐号的初值
72 |
73 | //init记住密码
74 | ui->lineEdit_passwd->setEchoMode(QLineEdit::Password);
75 | }
76 |
77 | void Login::get_user_info()
78 | {
79 | user_info_stu.userName.clear();
80 | user_info_stu.userName = ui->cBox_account->currentText();
81 | user_info_stu.passwd.clear();
82 | user_info_stu.passwd = ui->lineEdit_passwd->text();
83 | user_info_stu.server.clear();
84 | user_info_stu.server = ui->cBox_server->currentText();
85 | }
86 |
87 | void Login::configWindow()
88 | {
89 |
90 | // 填充背景图片
91 | QPalette palette;
92 | palette.setBrush(/*QPalette::Background*/this->backgroundRole(),
93 | QBrush(QPixmap(":/images/background.png")));
94 | this->setPalette(palette);
95 |
96 |
97 | //去掉窗口边框
98 | setWindowFlags(Qt::FramelessWindowHint);
99 |
100 | //程序init时,设置top ,user img
101 | set_top_img(true, -1);//设置图片显示为随机显示
102 | set_user_img(true, -1);//设置user图片为随机显示
103 |
104 | //设置UI的按钮button
105 | set_button();
106 |
107 |
108 | //设置任务栏系统托盘 start
109 | QStringList strList;
110 | strList << "Rose" << "Login";//login 为设置trayico的显示提示
111 | QIcon icon(":/images/ico/Qt-TextEditor.png");
112 | SystemTrayIcon *trayIcon = new SystemTrayIcon(strList, icon, this);
113 |
114 | connect(trayIcon, SIGNAL(signal_lang_refresh()), this, SLOT(refresh()));//关联语言设置函数,刷新界面
115 | //设置任务栏系统托盘 end
116 |
117 | }
118 |
119 |
120 | void Login::init_sql()
121 | {
122 | db = QSqlDatabase::addDatabase("QSQLITE");
123 | db.setDatabaseName("database.db");
124 | if (!db.open())
125 | {
126 | qDebug() << "database open fail!";
127 | } else
128 | {
129 | qDebug() << "database open success!";
130 | QSqlQuery query;
131 |
132 | //创建一个名为userInfo的表 顺序为: 用户名 密码 email
133 | QString sql_create_user_table = "CREATE TABLE if not exists userInfo (name VARCHAR PRIMARY KEY,passwd VARCHAR, email VARCHAR, rememberPasswd boolean);";
134 | QString sql_create_server_table("CREATE TABLE if not exists serverList (address VARCHAR PRIMARY KEY);");
135 | // query.prepare(sql_create_user_table);
136 | if (!query.exec(sql_create_user_table))
137 | {
138 | qDebug() << "creater user table error";
139 | }
140 | if (!query.exec(sql_create_server_table))
141 | {
142 | qDebug() << "creater server table error";
143 | }
144 | query.exec("INSERT INTO serverList VALUES ('www.peter-sia.top:2333')");
145 |
146 | query.exec("select * from userInfo");
147 |
148 | while (query.next())
149 | {
150 | QString userName = query.value("name").toString();
151 | ui->cBox_account->addItem(userName);
152 | QString passwd = query.value("passwd").toString();
153 | userPasswd.append(passwd);
154 | is_remembered.append(query.value("rememberPasswd").toBool());
155 | qDebug() << "userName:::" << userName << "passwd:::" << passwd;
156 | }
157 |
158 | if (!is_remembered.empty()&&is_remembered.at(0))
159 | {
160 | ui->checkBox_rPasswd->setChecked(true);
161 | ui->lineEdit_passwd->setText(userPasswd.at(0));
162 | }
163 |
164 | query.exec("select address from serverList");
165 | while (query.next())
166 | {
167 | ui->cBox_server->addItem(query.value("address").toString());
168 | qDebug() << "address:" << query.value("address");
169 | }
170 |
171 | ui->cBox_account->setCurrentIndex(0);
172 | ui->cBox_server->setCurrentIndex(0);
173 | }
174 | db.close();
175 | qDebug() << "database closed!";
176 | }
177 |
178 | void Login::set_top_img(bool isSandom, int index_img)
179 | {
180 | //427 185
181 | int set_index_img = 1;
182 | if (isSandom == true)//随机显示topimg
183 | {
184 |
185 | QTime time_sand;
186 | time_sand = QTime::currentTime();//获取当前时间
187 | qsrand(time_sand.msec() + time_sand.second() * 1000);
188 |
189 | //index_img = qrand()%5 ;//在0-4中选出随机数
190 | set_index_img = qrand() % 5 + 1;//在1-5中选出随机数
191 |
192 | }
193 | if (isSandom == false) //不随机显示,按index_img显示图片s
194 | {
195 | set_index_img = index_img;
196 | }
197 |
198 | QString top_img_path = ":/images/top_img1.png";
199 | qDebug() << " [leo]" << top_img_path;
200 | QImage top_img;
201 | top_img_path = ":/images/top_img" + QString::number(set_index_img, 10) + ".png";
202 | qDebug() << " [leo]" << top_img_path;
203 | top_img.load(top_img_path);
204 | QPixmap top_pic = QPixmap::fromImage(top_img.scaled(ui->label_top_img->width(), ui->label_top_img->height()));
205 | ui->label_top_img->setPixmap(top_pic);
206 | qDebug() << " [leo]top_img width heigh:" << ui->label_top_img->width()
207 | << " " << ui->label_top_img->height();
208 | }
209 |
210 | void Login::set_button()
211 | {
212 | //构建最小化、关闭按钮,设置按钮,键盘ico
213 | minBtn = new QToolButton(this);
214 | closeBbtn = new QToolButton(this);
215 | setBtn = new QToolButton(this);
216 |
217 | // //获取最小化、关闭按钮图标
218 | // QPixmap minPix = style()->standardPixmap(QStyle::SP_TitleBarMinButton);
219 | // QPixmap closePix = style()->standardPixmap(QStyle::SP_TitleBarCloseButton);
220 | // //设置最小化、关闭按钮图标
221 | // minBtn->setIcon(minPix);
222 | // closeBbtn->setIcon(closePix);
223 |
224 | //获取界面的宽度
225 | int width = this->width();
226 | //设置最小化、关闭按钮在界面的位置
227 | minBtn->setGeometry(width - 55, 5, 20, 20);
228 | closeBbtn->setGeometry(width - 25, 5, 20, 20);
229 | setBtn->setGeometry(width - 80, 7, 15, 15);
230 | //设置键盘ico坐标
231 | int x = ui->lineEdit_passwd->x();
232 | int y = ui->lineEdit_passwd->y();
233 | int widthkey = ui->lineEdit_passwd->width();
234 |
235 | qDebug() << "[leo]width:" << width;
236 | qDebug() << "[leo]minBtn" << minBtn->geometry();
237 | qDebug() << "[leo]closeBbtn" << closeBbtn->geometry();
238 |
239 | //设置鼠标移至按钮上的提示信息
240 | minBtn->setToolTip(tr("最小化"));
241 | closeBbtn->setToolTip(tr("关闭"));
242 | setBtn->setToolTip(tr("设置"));
243 |
244 | //设置最小化、关闭按钮的样式图标
245 | minBtn->setIcon(QIcon(":/images/ico/mini.png"));
246 | minBtn->setStyleSheet("background-color:transparent;");
247 | closeBbtn->setIcon(QIcon(":/images/ico/close.png"));
248 | closeBbtn->setStyleSheet("background-color:transparent;");
249 | setBtn->setIcon(QIcon(":/images/ico/setting.png"));
250 | setBtn->setStyleSheet("background-color:transparent;");
251 |
252 | //关联最小化、关闭按钮的槽函数,键盘exe
253 | connect(minBtn, SIGNAL(clicked()), this, SLOT(slot_minWindow()));
254 | connect(closeBbtn, SIGNAL(clicked()), this, SLOT(slot_closeWindow()));
255 | connect(setBtn, SIGNAL(clicked()), this, SLOT(slot_setLanguage()));
256 |
257 | create_menuLanguage(); //创建语言菜单
258 | }
259 |
260 | void Login::set_user_img(bool isSandom, int index_img)
261 | {
262 | //40,182 85 85
263 | int set_index_img = 1;
264 | if (isSandom == true)//随机显示userimg
265 | {
266 |
267 | QTime time_sand;
268 | time_sand = QTime::currentTime();//获取当前时间
269 | qsrand(time_sand.msec() + time_sand.second() * 1000);
270 | set_index_img = qrand() % 5 + 1;//在1-5中选出随机数
271 |
272 | }
273 | if (isSandom == false) //不随机显示,按index_img显示图片s
274 | {
275 | set_index_img = index_img;
276 | }
277 |
278 | QString user_img_path = ":/images/ico/user1.png";
279 | qDebug() << " [leo]user" << user_img_path;
280 | QImage user_img;
281 | user_img_path = ":/images/ico/user" + QString::number(set_index_img, 10) + ".png";
282 | qDebug() << " [leo]user" << user_img_path;
283 | user_img.load(user_img_path);
284 | QPixmap img_pic = QPixmap::fromImage(user_img.scaled(ui->label_user_img->width(),
285 | ui->label_user_img->height()));
286 | ui->label_user_img->setPixmap(img_pic);
287 | qDebug() << " [leo]user_img width height:" << ui->label_user_img->width()
288 | << " " << ui->label_user_img->height();
289 | }
290 |
291 | void Login::create_menuLanguage()
292 | {
293 | //语言
294 | act_chinese = new QAction(tr("简体中文"), this);
295 | act_english = new QAction(tr("English"), this);
296 | menu1 = new QMenu;
297 | menu1->addAction(act_chinese);
298 | menu1->addAction(act_english);
299 |
300 | //在线状态
301 | act0 = new QAction(tr("在线"), this);
302 | act1 = new QAction(tr("隐身"), this);
303 | act2 = new QAction(tr("离线"), this);
304 | act3 = new QAction(tr("忙碌"), this);
305 |
306 | actGrp = new QActionGroup(this);
307 | actGrp->addAction(act0);
308 | actGrp->addAction(act1);
309 | actGrp->addAction(act2);
310 | actGrp->addAction(act3);
311 | connect(actGrp, SIGNAL(triggered(QAction * )), this, SLOT(slot_actGrp(QAction * )));
312 |
313 | menu2 = new QMenu;
314 | menu2->addAction(act0);
315 | menu2->addAction(act1);
316 | menu2->addAction(act2);
317 | menu2->addAction(act3);
318 |
319 | menu1->addAction(act0);
320 | menu1->addAction(act1);
321 | menu1->addAction(act2);
322 | menu1->addAction(act3);
323 | }
324 |
325 | void Login::setStyle(const QString &style)
326 | {
327 | QFile qss(":/images/qss/" + style);//black.qss
328 | qDebug() << "qss :";
329 | qss.open(QIODevice::ReadOnly | QIODevice::Text);
330 | qApp->setStyleSheet(qss.readAll());
331 | qss.close();
332 | }
333 |
334 |
335 | void Login::mousePressEvent(QMouseEvent *e)
336 | {
337 | if (e->button() == Qt::LeftButton)
338 | {
339 | m_Drag = true;
340 | m_point = e->globalPos() - this->pos();
341 | e->accept();
342 | // qDebug()<<"leo";
343 | }
344 | }
345 |
346 | void Login::mouseMoveEvent(QMouseEvent *e)
347 | {
348 | if (m_Drag && (e->buttons() && Qt::LeftButton))
349 | {
350 | move(e->globalPos() - m_point);
351 | e->accept();
352 | // qDebug()<<"leomove";
353 | }
354 | }
355 |
356 | void Login::mouseReleaseEvent(QMouseEvent *e)
357 | {
358 | m_Drag = false;
359 | }
360 |
361 | void Login::on_btn_login_clicked()
362 | {
363 | qDebug() << "login:" << user_info_stu.userName << user_info_stu.passwd;
364 | if (ui->cBox_account->currentText().isEmpty() ||
365 | ui->lineEdit_passwd->text().isEmpty() ||
366 | ui->cBox_server->currentText().isEmpty())
367 | {
368 | QMessageBox::warning(this, tr("error"), tr("Username, Password And Server Are Needed!"));
369 | } else
370 | {
371 | //TODO
372 | get_user_info();
373 | manager->setUsername(user_info_stu.userName);
374 | manager->setPassword(user_info_stu.passwd);
375 | manager->setServer(user_info_stu.server);
376 | manager->login();
377 | // manager.setUsername("lalal");
378 | // manager.setPassword("peter123");
379 | // manager.setServer("www.peter-sia.top:2333");
380 | // manager.login();
381 | }
382 | }
383 |
384 | void Login::on_btn_annonymous_clicked()
385 | {
386 | manager->setUsername(nullptr);
387 | manager->setPassword(nullptr);
388 | manager->setServer(nullptr);
389 | Editor *e = new Editor(*manager, nullptr, true);
390 | e->show();
391 | emit close();
392 | }
393 |
394 | void Login::login_success()
395 | {
396 | if (!db.open())
397 | {
398 | qDebug() << "database open fail login!";
399 | } else
400 | {
401 | QSqlQuery query;
402 | qDebug() << "database open success login!";
403 | QString sql_insert_server_address = "INSERT INTO serverList VALUES (:address);";
404 | query.prepare(sql_insert_server_address);
405 | query.bindValue(":address", ui->cBox_server->currentText());
406 | query.exec();
407 | QString sql_insert_user = "INSERT INTO userInfo (name, passwd, email) VALUES (:username, :password, :email)";
408 | query.prepare(sql_insert_user);
409 | query.bindValue(":username", user_info_stu.userName);
410 | query.bindValue(":password", user_info_stu.passwd);
411 | query.bindValue(":email", user_info_stu.email);
412 | query.exec();
413 | if (ui->checkBox_rPasswd->isChecked())
414 | {
415 | query.prepare("update userInfo set rememberPasswd = 1 where name = :user;");
416 | query.bindValue(":user", user_info_stu.userName);
417 | query.exec();
418 | } else
419 | {
420 | query.prepare("update userInfo set rememberPasswd = 0 where name = :user;");
421 | query.bindValue(":user", user_info_stu.userName);
422 | query.exec();
423 | }
424 | Editor *e = new Editor(*manager, nullptr, false);
425 | e->setUser(user_info_stu.userName);
426 | e->setServer(ui->cBox_server->currentText());
427 | e->show();
428 | emit close();
429 | }
430 |
431 | db.close();
432 | }
433 |
434 | void Login::login_success_without_entering()
435 | {
436 | if (!db.open())
437 | {
438 | qDebug() << "database open fail login!";
439 | } else
440 | {
441 | QSqlQuery query;
442 | qDebug() << "database open success login!";
443 | QString sql_insert_server_address = "INSERT INTO serverList VALUES (:address);";
444 | query.prepare(sql_insert_server_address);
445 | query.bindValue(":address", ui->cBox_server->currentText());
446 | query.exec();
447 | QString sql_insert_user = "INSERT INTO userInfo (name, passwd, email) VALUES (:username, :password, :email)";
448 | query.prepare(sql_insert_user);
449 | query.bindValue(":username", user_info_stu.userName);
450 | query.bindValue(":password", user_info_stu.passwd);
451 | query.bindValue(":email", user_info_stu.email);
452 | query.exec();
453 | if (ui->checkBox_rPasswd->isChecked())
454 | {
455 | query.prepare("update userInfo set rememberPasswd = 1 where name = :user;");
456 | query.bindValue(":user", user_info_stu.userName);
457 | query.exec();
458 | } else
459 | {
460 | query.prepare("update userInfo set rememberPasswd = 0 where name = :user;");
461 | query.bindValue(":user", user_info_stu.userName);
462 | query.exec();
463 | }
464 | QMessageBox::information(this, "success", "login successfully!");
465 | parentEditor->setUser(manager->getUsername());
466 | parentEditor->setServer(manager->getServer());
467 | parentEditor->setAnonymous(false);
468 | parentEditor->updateFileListTimer();
469 | emit close();
470 | }
471 |
472 | db.close();
473 | }
474 |
475 | ////注册button
476 | //void Login::on_btn_regist_clicked()
477 | //{
478 | // Register r(this);
479 | // this->hide();
480 | // r.show();
481 | // //transmitdb(database);
482 | // r.exec();
483 | // this->show();
484 | //}
485 |
486 | //注册button
487 | void Login::on_btn_regist_clicked()
488 | {
489 | //TODO
490 | Register r(manager, this);
491 | //transmitdb(database);
492 | r.exec(); //注册页面r,仅仅获取信息.
493 |
494 | // get_user_info();
495 | // if (user_info_stu.userName.isEmpty() || user_info_stu.passwd.isEmpty() || user_info_stu.server.isEmpty())
496 | // {
497 | // QMessageBox::warning(this, tr("提示"), tr("请同时输入服务器地址和用户名密码!"));
498 | // } else
499 | // {
500 | //// bool existFlag = false; //判断用户是否存在
501 | // manager.setUsername(user_info_stu.userName);
502 | // manager.setPassword(user_info_stu.passwd);
503 | // manager.setServer(user_info_stu.server);
504 | // manager.registerUser(user_info_stu.email);
505 | // if (!db.open())
506 | // {
507 | // qDebug() << "database open fail regist!";
508 | // } else
509 | // {
510 | // QSqlQuery query;
511 | // qDebug() << "database open success regist!";
512 | // query.prepare("select * from userInfo where name = :username;");
513 | // query.bindValue(":username", user_info_stu.userName);
514 | // query.exec();
515 | // qDebug() << query.lastQuery();
516 | // if (query.first())
517 | // {
518 | // QString userName = query.value("name").toString();
519 | // QString passwd = query.value("passwd").toString();
520 | // if (userName == user_info_stu.userName)
521 | // {
522 | // existFlag = true; //用户存在
523 | // }
524 | // }
525 | //// while (query.next())
526 | //// {
527 | //// QString userName = query.value(0).toString();
528 | //// QString passwd = query.value(1).toString();
529 | //// qDebug() << "regist userName:::" << userName << "passwd:::" << passwd;
530 | ////
531 | //// if (userName == user_info_stu.userName)
532 | //// {
533 | //// existFlag = true; //用户存在
534 | //// }
535 | //// }
536 | //
537 | // if (!existFlag)
538 | // {
539 | // if (query.exec(QString("insert into userInfo values ('%1','%2','%3', false)")
540 | // .arg(user_info_stu.userName).arg(user_info_stu.passwd)
541 | // .arg(user_info_stu.email)))
542 | // {
543 | // qDebug() << "ddd:" << user_info_stu.userName << user_info_stu.passwd << user_info_stu.email;
544 | // qDebug() << "regist:::" << query.lastQuery();
545 | // ui->cBox_account->addItem(user_info_stu.userName);
546 | // userPasswd.append(user_info_stu.passwd);
547 | // QMessageBox::information(this, tr("提示"), tr("注册成功!"));
548 | // }
549 | //
550 | // } else
551 | // {
552 | // QMessageBox::warning(this, tr("警告"), tr("用户已存在!"));
553 | // }
554 | // }
555 | // db.close();
556 | // }
557 | }
558 |
559 | ////修改密码button
560 | //void Login::on_btn_edit_pwd_clicked()
561 | //{
562 | // if (ui->cBox_account->currentText().isEmpty() ||
563 | // ui->lineEdit_passwd->text().isEmpty())
564 | // {
565 | // QMessageBox::information(this, tr("提示"), tr("请输入用户名和密码!"));
566 | // } else
567 | // {
568 | // bool is_use_exist_flag = false; //判断用户是否存在
569 | // bool is_use_nampwd_check_flag = false; //判断用户名和密码是否匹配
570 | // get_user_info();
571 | //
572 | // if (!db.open())
573 | // {
574 | // qDebug() << "database open fail login!";
575 | // } else
576 | // {
577 | // QSqlQuery query;
578 | // qDebug() << "database open success login!";
579 | // query.exec("select * from userInfo");
580 | // while (query.next())
581 | // {
582 | // QString userName = query.value(0).toString();
583 | // QString passwd = query.value(1).toString();
584 | // qDebug() << "edit userName:::" << userName << "passwd:::" << passwd;
585 | //
586 | // if (userName == user_info_stu.userName)
587 | // {
588 | // is_use_exist_flag = true; //用户存在
589 | // if (passwd == user_info_stu.passwd)
590 | // {
591 | // is_use_nampwd_check_flag = true; //用户名和密码匹配
592 | // passwdEdit passwd;
593 | // passwd.setLogin(this);
594 | // //this->hide();
595 | // passwd.exec();
596 | // }
597 | // }
598 | // }
599 | //
600 | // if (is_use_exist_flag == false)
601 | // {
602 | // QMessageBox::information(this, tr("提示"), tr("用户不存在!"));
603 | // } else
604 | // {
605 | // if (is_use_nampwd_check_flag == 0)
606 | // {
607 | // QMessageBox::warning(this, tr("警告"), tr("用户密码错误!"));
608 | // }
609 | // }
610 | // }
611 | // db.close();
612 | // }
613 | //}
614 |
615 | //最小化button
616 | void Login::slot_minWindow()
617 | {
618 | this->showMinimized();
619 | }
620 |
621 | void Login::slot_closeWindow()
622 | {
623 | timer2->start(5);
624 | }
625 |
626 | void Login::slot_setLanguage()
627 | {
628 | menu1->exec(QCursor::pos());
629 | }
630 |
631 | void Login::slot_actGrp(QAction *act)
632 | {
633 | if (act == act0)
634 | {
635 | qDebug() << "act0";
636 | } else if (act == act1)
637 | {
638 | qDebug() << "act1";
639 | } else if (act == act2)
640 | {
641 | qDebug() << "act2";
642 | } else if (act == act3)
643 | {
644 | qDebug() << "act3";
645 | }
646 | }
647 |
648 | void Login::slot_timer1()
649 | {
650 | if (opacity1 >= 1.0)
651 | {
652 | timer1->stop();
653 | } else
654 | {
655 | opacity1 += 0.01;
656 | }
657 | setWindowOpacity(opacity1);//设置窗口透明度
658 | }
659 |
660 | void Login::slot_timer2()
661 | {
662 | if (opacity2 <= 0.0)
663 | {
664 | timer2->stop();
665 |
666 | this->close();
667 | } else
668 | {
669 | opacity2 -= 0.01;
670 | }
671 | setWindowOpacity(opacity2);//设置窗口透明度
672 | }
673 |
674 | void Login::on_cBox_account_activated(int index)
675 | {
676 | if (is_remembered.at(index))
677 | {
678 | ui->lineEdit_passwd->setText(userPasswd.at(index));
679 | ui->checkBox_rPasswd->setChecked(true);
680 | } else
681 | {
682 | ui->lineEdit_passwd->setText("");
683 | ui->checkBox_rPasswd->setChecked(false);
684 | }
685 | qDebug() << "change cBox:" << ui->cBox_account->currentText()
686 | << userPasswd.at(index);
687 | }
688 |
689 |
690 | //下拉框选里面的项时,会切换top_img的图片和头像图片
691 | void Login::on_cBox_account_currentIndexChanged(int index)
692 | {
693 | set_top_img(true, index);
694 | set_user_img(true, index);
695 | }
696 |
697 | void Login::refresh()//刷新login页面当前的字符串。其它页面无需刷新,因为打开时候,会自动刷新相关字符串。而主窗口不会。
698 | {
699 | qDebug() << "xxxxxxxxxxxxxxxxxxx";
700 | ui->btn_login->setText(tr("login"));
701 | ui->btn_regist->setText(tr("register"));
702 | //ui->checkBox_autoLogin->setText(tr("自动登录"));
703 | ui->label->setText(tr("remember me"));
704 | ui->label_2->setText(tr("auto login"));
705 |
706 | }
707 |
708 |
709 |
--------------------------------------------------------------------------------
/resources/images/qss/white.qss:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright : http://blog.csdn.net/liang19890820
5 | *
6 | * Author : 一去丶二三里
7 | *
8 | * Date : 2016/07/22
9 | *
10 | * Description : 白色靓丽
11 | *
12 | */
13 |
14 | /**********子界面背景**********/
15 | QWidget#customWidget {
16 | background: rgb(173, 202, 232);
17 | }
18 |
19 | /**********子界面中央背景**********/
20 | QWidget#centerWidget {
21 | background: rgb(232, 241, 252);
22 | }
23 |
24 | /**********主界面样式**********/
25 | QWidget#mainWindow {
26 | border: 1px solid rgb(111, 156, 207);
27 | background: rgb(232, 241, 252);
28 | }
29 |
30 | QWidget#messageWidget {
31 | background: rgba(173, 202, 232, 50%);
32 | }
33 |
34 | QWidget#loadingWidget {
35 | border: none;
36 | border-radius: 5px;
37 | background: rgb(187, 212, 238);
38 | }
39 |
40 | QWidget#remoteWidget {
41 | border-top-right-radius: 10px;
42 | border-bottom-right-radius: 10px;
43 | border: 1px solid rgb(111, 156, 207);
44 | border-left: none;
45 | background: transparent;
46 | }
47 |
48 | StyledWidget {
49 | qproperty-normalColor: rgb(65, 65, 65);
50 | qproperty-disableColor: rgb(180, 180, 180);
51 | qproperty-highlightColor: rgb(0, 160, 230);
52 | qproperty-errorColor: red;
53 | }
54 |
55 | QProgressIndicator {
56 | qproperty-color: rgb(2, 65, 132);
57 | }
58 |
59 | /**********提示**********/
60 | QToolTip{
61 | border: 1px solid rgb(111, 156, 207);
62 | background: white;
63 | color: rgb(51, 51, 51);
64 | }
65 |
66 | /**********菜单栏**********/
67 | QMenuBar {
68 | background: rgb(187, 212, 238);
69 | border: 1px solid rgb(111, 156, 207);
70 | border-left: none;
71 | border-right: none;
72 | }
73 | QMenuBar::item {
74 | border: 1px solid transparent;
75 | padding: 5px 10px 5px 10px;
76 | background: transparent;
77 | }
78 | QMenuBar::item:enabled {
79 | color: rgb(2, 65, 132);
80 | }
81 | QMenuBar::item:!enabled {
82 | color: rgb(155, 155, 155);
83 | }
84 | QMenuBar::item:enabled:selected {
85 | border-top-color: rgb(111, 156, 207);
86 | border-bottom-color: rgb(111, 156, 207);
87 | background: rgb(198, 224, 252);
88 | }
89 |
90 | /**********菜单**********/
91 | QMenu {
92 | border: 1px solid rgb(111, 156, 207);
93 | background: rgb(232, 241, 250);
94 | }
95 | QMenu::item {
96 | height: 22px;
97 | padding: 0px 25px 0px 20px;
98 | }
99 | QMenu::item:enabled {
100 | color: rgb(84, 84, 84);
101 | }
102 | QMenu::item:!enabled {
103 | color: rgb(155, 155, 155);
104 | }
105 | QMenu::item:enabled:selected {
106 | color: rgb(2, 65, 132);
107 | background: rgba(255, 255, 255, 200);
108 | }
109 | QMenu::separator {
110 | height: 1px;
111 | background: rgb(111, 156, 207);
112 | }
113 | QMenu::indicator {
114 | width: 13px;
115 | height: 13px;
116 | }
117 | QMenu::icon {
118 | padding-left: 2px;
119 | padding-right: 2px;
120 | }
121 |
122 | /**********状态栏**********/
123 | QStatusBar {
124 | background: rgb(187, 212, 238);
125 | border: 1px solid rgb(111, 156, 207);
126 | border-left: none;
127 | border-right: none;
128 | border-bottom: none;
129 | }
130 | QStatusBar::item {
131 | border: none;
132 | border-right: 1px solid rgb(111, 156, 207);
133 | }
134 |
135 | /**********分组框**********/
136 | QGroupBox {
137 | font-size: 15px;
138 | border: 1px solid rgb(111, 156, 207);
139 | border-radius: 4px;
140 | margin-top: 10px;
141 | }
142 | QGroupBox::title {
143 | color: rgb(56, 99, 154);
144 | top: -12px;
145 | left: 10px;
146 | }
147 |
148 | /**********页签项**********/
149 | QTabWidget::pane {
150 | border: none;
151 | border-top: 3px solid rgb(0, 78, 161);
152 | background: rgb(187, 212, 238);
153 | }
154 | QTabWidget::tab-bar {
155 | border: none;
156 | }
157 | QTabBar::tab {
158 | border: none;
159 | border-top-left-radius: 4px;
160 | border-top-right-radius: 4px;
161 | color: white;
162 | background: rgb(120, 170, 220);
163 | height: 28px;
164 | min-width: 85px;
165 | margin-right: 5px;
166 | padding-left: 5px;
167 | padding-right: 5px;
168 | }
169 | QTabBar::tab:hover {
170 | background: rgb(0, 78, 161);
171 | }
172 | QTabBar::tab:selected {
173 | color: white;
174 | background: rgb(0, 78, 161);
175 | }
176 |
177 | QTabWidget#tabWidget::pane {
178 | border: 1px solid rgb(111, 156, 207);
179 | background: rgb(232, 241, 252);
180 | margin-top: -1px;
181 | }
182 |
183 | QTabBar#tabBar::tab {
184 | border: 1px solid rgb(111, 156, 207);
185 | border-bottom: none;
186 | color: rgb(70, 71, 73);
187 | background: transparent;
188 | }
189 | QTabBar#tabBar::tab:hover {
190 | color: rgb(2, 65, 132);
191 | }
192 | QTabBar#tabBar::tab:selected {
193 | color: rgb(2, 65, 132);
194 | background: rgb(232, 241, 252);
195 | }
196 |
197 | /**********表头**********/
198 | QHeaderView{
199 | border: none;
200 | border-bottom: 3px solid rgb(0, 78, 161);
201 | background: transparent;
202 | min-height: 30px;
203 | }
204 | QHeaderView::section:horizontal {
205 | border: none;
206 | color: rgb(2, 65, 132);
207 | background: transparent;
208 | padding-left: 5px;
209 | }
210 | QHeaderView::section:horizontal:hover {
211 | color: white;
212 | background: rgb(0, 78, 161);
213 | }
214 | QHeaderView::section:horizontal:pressed {
215 | color: white;
216 | background: rgb(6, 94, 187);
217 | }
218 | QHeaderView::up-arrow {
219 | width: 13px;
220 | height: 11px;
221 | padding-right: 5px;
222 | image: url(:/images/qss/White/topArrow);
223 | subcontrol-position: center right;
224 | }
225 | QHeaderView::up-arrow:hover, QHeaderView::up-arrow:pressed {
226 | image: url(:/images/qss/White/topArrowHover);
227 | }
228 | QHeaderView::down-arrow {
229 | width: 13px;
230 | height: 11px;
231 | padding-right: 5px;
232 | image: url(:/images/qss/White/bottomArrow);
233 | subcontrol-position: center right;
234 | }
235 | QHeaderView::down-arrow:hover, QHeaderView::down-arrow:pressed {
236 | image: url(:/images/qss/White/bottomArrowHover);
237 | }
238 |
239 | /**********表格**********/
240 | QTableView {
241 | border: 1px solid rgb(111, 156, 207);
242 | background: rgb(224, 238, 255);
243 | gridline-color: rgb(111, 156, 207);
244 | }
245 | QTableView::item {
246 | padding-left: 5px;
247 | padding-right: 5px;
248 | border: none;
249 | background: white;
250 | border-right: 1px solid rgb(111, 156, 207);
251 | border-bottom: 1px solid rgb(111, 156, 207);
252 | }
253 | QTableView::item:selected {
254 | background: rgba(255, 255, 255, 100);
255 | }
256 | QTableView::item:selected:!active {
257 | color: rgb(65, 65, 65);
258 | }
259 | QTableView::indicator {
260 | width: 20px;
261 | height: 20px;
262 | }
263 | QTableView::indicator:enabled:unchecked {
264 | image: url(:/images/qss/White/checkBox);
265 | }
266 | QTableView::indicator:enabled:unchecked:hover {
267 | image: url(:/images/qss/White/checkBoxHover);
268 | }
269 | QTableView::indicator:enabled:unchecked:pressed {
270 | image: url(:/images/qss/White/checkBoxPressed);
271 | }
272 | QTableView::indicator:enabled:checked {
273 | image: url(:/images/qss/White/checkBoxChecked);
274 | }
275 | QTableView::indicator:enabled:checked:hover {
276 | image: url(:/images/qss/White/checkBoxCheckedHover);
277 | }
278 | QTableView::indicator:enabled:checked:pressed {
279 | image: url(:/images/qss/White/checkBoxCheckedPressed);
280 | }
281 | QTableView::indicator:enabled:indeterminate {
282 | image: url(:/images/qss/White/checkBoxIndeterminate);
283 | }
284 | QTableView::indicator:enabled:indeterminate:hover {
285 | image: url(:/images/qss/White/checkBoxIndeterminateHover);
286 | }
287 | QTableView::indicator:enabled:indeterminate:pressed {
288 | image: url(:/images/qss/White/checkBoxIndeterminatePressed);
289 | }
290 |
291 | /**********滚动条-水平**********/
292 | QScrollBar:horizontal {
293 | height: 20px;
294 | background: transparent;
295 | margin-top: 3px;
296 | margin-bottom: 3px;
297 | }
298 | QScrollBar::handle:horizontal {
299 | height: 20px;
300 | min-width: 30px;
301 | background: rgb(170, 200, 230);
302 | margin-left: 15px;
303 | margin-right: 15px;
304 | }
305 | QScrollBar::handle:horizontal:hover {
306 | background: rgb(165, 195, 225);
307 | }
308 | QScrollBar::sub-line:horizontal {
309 | width: 15px;
310 | background: transparent;
311 | image: url(:/images/qss/White/arrowLeft);
312 | subcontrol-position: left;
313 | }
314 | QScrollBar::add-line:horizontal {
315 | width: 15px;
316 | background: transparent;
317 | image: url(:/images/qss/White/arrowRight);
318 | subcontrol-position: right;
319 | }
320 | QScrollBar::sub-line:horizontal:hover {
321 | background: rgb(170, 200, 230);
322 | }
323 | QScrollBar::add-line:horizontal:hover {
324 | background: rgb(170, 200, 230);
325 | }
326 | QScrollBar::add-page:horizontal,QScrollBar::sub-page:horizontal {
327 | background: transparent;
328 | }
329 |
330 | /**********滚动条-垂直**********/
331 | QScrollBar:vertical {
332 | width: 20px;
333 | background: transparent;
334 | margin-left: 3px;
335 | margin-right: 3px;
336 | }
337 | QScrollBar::handle:vertical {
338 | width: 20px;
339 | min-height: 30px;
340 | background: rgb(170, 200, 230);
341 | margin-top: 15px;
342 | margin-bottom: 15px;
343 | }
344 | QScrollBar::handle:vertical:hover {
345 | background: rgb(165, 195, 225);
346 | }
347 | QScrollBar::sub-line:vertical {
348 | height: 15px;
349 | background: transparent;
350 | image: url(:/images/qss/White/topArrow);
351 | subcontrol-position: top;
352 | }
353 | QScrollBar::add-line:vertical {
354 | height: 15px;
355 | background: transparent;
356 | image: url(:/images/qss/White/bottomArrow);
357 | subcontrol-position: bottom;
358 | }
359 | QScrollBar::sub-line:vertical:hover {
360 | background: rgb(170, 200, 230);
361 | }
362 | QScrollBar::add-line:vertical:hover {
363 | background: rgb(170, 200, 230);
364 | }
365 | QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
366 | background: transparent;
367 | }
368 |
369 | QScrollBar#verticalScrollBar:vertical {
370 | margin-top: 30px;
371 | }
372 |
373 | /**********下拉列表**********/
374 | QComboBox {
375 | height: 25px;
376 | border-radius: 4px;
377 | border: 1px solid rgb(111, 156, 207);
378 | background: white;
379 | }
380 | QComboBox:enabled {
381 | color: rgb(84, 84, 84);
382 | }
383 | QComboBox:!enabled {
384 | color: rgb(80, 80, 80);
385 | }
386 | QComboBox:enabled:hover, QComboBox:enabled:focus {
387 | color: rgb(51, 51, 51);
388 | }
389 | QComboBox::drop-down {
390 | width: 20px;
391 | border: none;
392 | background: transparent;
393 | }
394 | QComboBox::drop-down:hover {
395 | background: rgba(255, 255, 255, 30);
396 | }
397 | QComboBox::down-arrow {
398 | image: url(:/images/qss/White/arrowBottom);
399 | }
400 | QComboBox::down-arrow:on {
401 | /**top: 1px;**/
402 | }
403 | QComboBox QAbstractItemView {
404 | border: 1px solid rgb(111, 156, 207);
405 | background: white;
406 | outline: none;
407 | }
408 | QComboBox QAbstractItemView::item {
409 | height: 25px;
410 | color: rgb(73, 73, 73);
411 | }
412 | QComboBox QAbstractItemView::item:selected {
413 | background: rgb(232, 241, 250);
414 | color: rgb(2, 65, 132);
415 | }
416 |
417 | /**********进度条**********/
418 | QProgressBar{
419 | border: none;
420 | text-align: center;
421 | color: white;
422 | background: rgb(173, 202, 232);
423 | }
424 | QProgressBar::chunk {
425 | background: rgb(16, 135, 209);
426 | }
427 |
428 | QProgressBar#progressBar {
429 | border: none;
430 | text-align: center;
431 | color: white;
432 | background-color: transparent;
433 | background-image: url(":/images/qss/White/progressBar");
434 | background-repeat: repeat-x;
435 | }
436 | QProgressBar#progressBar::chunk {
437 | border: none;
438 | background-color: transparent;
439 | background-image: url(":/images/qss/White/progressBarChunk");
440 | background-repeat: repeat-x;
441 | }
442 |
443 | /**********复选框**********/
444 | QCheckBox{
445 | spacing: 5px;
446 | }
447 | QCheckBox:enabled:checked{
448 | color: rgb(2, 65, 132);
449 | }
450 | QCheckBox:enabled:!checked{
451 | color: rgb(70, 71, 73);
452 | }
453 | QCheckBox:enabled:hover{
454 | color: rgb(0, 78, 161);
455 | }
456 | QCheckBox:!enabled{
457 | color: rgb(80, 80, 80);
458 | }
459 | QCheckBox::indicator {
460 | width: 20px;
461 | height: 20px;
462 | }
463 | QCheckBox::indicator:unchecked {
464 | image: url(:/images/qss/White/checkBox);
465 | }
466 | QCheckBox::indicator:unchecked:hover {
467 | image: url(:/images/qss/White/checkBoxHover);
468 | }
469 | QCheckBox::indicator:unchecked:pressed {
470 | image: url(:/images/qss/White/checkBoxPressed);
471 | }
472 | QCheckBox::indicator:checked {
473 | image: url(:/images/qss/White/checkBoxChecked);
474 | }
475 | QCheckBox::indicator:checked:hover {
476 | image: url(:/images/qss/White/checkBoxCheckedHover);
477 | }
478 | QCheckBox::indicator:checked:pressed {
479 | image: url(:/images/qss/White/checkBoxCheckedPressed);
480 | }
481 | QCheckBox::indicator:indeterminate {
482 | image: url(:/images/qss/White/checkBoxIndeterminate);
483 | }
484 | QCheckBox::indicator:indeterminate:hover {
485 | image: url(:/images/qss/White/checkBoxIndeterminateHover);
486 | }
487 | QCheckBox::indicator:indeterminate:pressed {
488 | image: url(:/images/qss/White/checkBoxIndeterminatePressed);
489 | }
490 |
491 | /**********单选框**********/
492 | QRadioButton{
493 | spacing: 5px;
494 | }
495 | QRadioButton:enabled:checked{
496 | color: rgb(2, 65, 132);
497 | }
498 | QRadioButton:enabled:!checked{
499 | color: rgb(70, 71, 73);
500 | }
501 | QRadioButton:enabled:hover{
502 | color: rgb(0, 78, 161);
503 | }
504 | QRadioButton:!enabled{
505 | color: rgb(80, 80, 80);
506 | }
507 | QRadioButton::indicator {
508 | width: 20px;
509 | height: 20px;
510 | }
511 | QRadioButton::indicator:unchecked {
512 | image: url(:/images/qss/White/radioButton);
513 | }
514 | QRadioButton::indicator:unchecked:hover {
515 | image: url(:/images/qss/White/radioButtonHover);
516 | }
517 | QRadioButton::indicator:unchecked:pressed {
518 | image: url(:/images/qss/White/radioButtonPressed);
519 | }
520 | QRadioButton::indicator:checked {
521 | image: url(:/images/qss/White/radioButtonChecked);
522 | }
523 | QRadioButton::indicator:checked:hover {
524 | image: url(:/images/qss/White/radioButtonCheckedHover);
525 | }
526 | QRadioButton::indicator:checked:pressed {
527 | image: url(:/images/qss/White/radioButtonCheckedPressed);
528 | }
529 |
530 | /**********输入框**********/
531 | QLineEdit {
532 | border-radius: 4px;
533 | height: 25px;
534 | border: 1px solid rgb(111, 156, 207);
535 | background: white;
536 | }
537 | QLineEdit:enabled {
538 | color: rgb(84, 84, 84);
539 | }
540 | QLineEdit:enabled:hover, QLineEdit:enabled:focus {
541 | color: rgb(51, 51, 51);
542 | }
543 | QLineEdit:!enabled {
544 | color: rgb(80, 80, 80);
545 | }
546 |
547 | /**********文本编辑框**********/
548 | QTextEdit {
549 | border: 1px solid rgb(111, 156, 207);
550 | color: rgb(70, 71, 73);
551 | background: rgb(187, 212, 238);
552 | }
553 |
554 | /**********滚动区域**********/
555 | QScrollArea {
556 | border: 1px solid rgb(111, 156, 207);
557 | background: rgb(187, 212, 238);
558 | }
559 |
560 | /**********滚动区域**********/
561 | QWidget#transparentWidget {
562 | background: transparent;
563 | }
564 |
565 | /**********微调器**********/
566 | QSpinBox {
567 | border-radius: 4px;
568 | height: 24px;
569 | min-width: 40px;
570 | border: 1px solid rgb(111, 156, 207);
571 | background: white;
572 | }
573 | QSpinBox:enabled {
574 | color: rgb(60, 60, 60);
575 | }
576 | QSpinBox:enabled:hover, QSpinBox:enabled:focus {
577 | color: rgb(51, 51, 51);
578 | }
579 | QSpinBox:!enabled {
580 | color: rgb(210, 210, 210);
581 | background: transparent;
582 | }
583 | QSpinBox::up-button {
584 | border-left: 1px solid rgb(111, 156, 207);
585 | width: 18px;
586 | height: 12px;
587 | border-top-right-radius: 4px;
588 | image: url(:/images/qss/White/upButton);
589 | }
590 | QSpinBox::up-button:!enabled {
591 | background: transparent;
592 | }
593 | QSpinBox::up-button:enabled:hover {
594 | background: rgb(255, 255, 255, 30);
595 | }
596 | QSpinBox::down-button {
597 | border-left: 1px solid rgb(111, 156, 207);
598 | width: 18px;
599 | height: 12px;
600 | border-bottom-right-radius: 4px;
601 | image: url(:/images/qss/White/downButton);
602 | }
603 | QSpinBox::down-button:!enabled {
604 | background: transparent;
605 | }
606 | QSpinBox::down-button:hover {
607 | background: rgb(255, 255, 255, 30);
608 | }
609 |
610 | /**********标签**********/
611 | QLabel#grayLabel {
612 | color: rgb(70, 71, 73);
613 | }
614 |
615 | QLabel#highlightLabel {
616 | color: rgb(2, 65, 132);
617 | }
618 |
619 | QLabel#redLabel {
620 | color: red;
621 | }
622 |
623 | QLabel#grayYaHeiLabel {
624 | color: rgb(175, 175, 175);
625 | font-size: 16px;
626 | }
627 |
628 | QLabel#blueLabel {
629 | color: rgb(0, 160, 230);
630 | }
631 |
632 | QLabel#listLabel {
633 | color: rgb(51, 51, 51);
634 | }
635 |
636 | QLabel#lineBlueLabel {
637 | background: rgb(0, 78, 161);
638 | }
639 |
640 | QLabel#graySeperateLabel {
641 | background: rgb(200, 220, 230);
642 | }
643 |
644 | QLabel#seperateLabel {
645 | background: rgb(112, 153, 194);
646 | }
647 |
648 | QLabel#radiusBlueLabel {
649 | border-radius: 15px;
650 | color: white;
651 | font-size: 16px;
652 | background: rgb(0, 78, 161);
653 | }
654 |
655 | QLabel#skinLabel[colorProperty="normal"] {
656 | color: rgb(56, 99, 154);
657 | }
658 | QLabel#skinLabel[colorProperty="highlight"] {
659 | color: rgb(0, 160, 230);
660 | }
661 |
662 | QLabel#informationLabel {
663 | qproperty-pixmap: url(:/images/qss/White/information);
664 | }
665 |
666 | QLabel#errorLabel {
667 | qproperty-pixmap: url(:/images/qss/White/error);
668 | }
669 |
670 | QLabel#successLabel {
671 | qproperty-pixmap: url(:/images/qss/White/success);
672 | }
673 |
674 | QLabel#questionLabel {
675 | qproperty-pixmap: url(:/images/qss/White/question);
676 | }
677 |
678 | QLabel#warningLabel {
679 | qproperty-pixmap: url(:/images/qss/White/warning);
680 | }
681 |
682 | QLabel#groupLabel {
683 | color: rgb(56, 99, 154);
684 | border: 1px solid rgb(111, 156, 207);
685 | font-size: 15px;
686 | border-top-color: transparent;
687 | border-right-color: transparent;
688 | border-left-color: transparent;
689 | }
690 |
691 | /**********按钮**********/
692 | QToolButton#nsccButton {
693 | border: none;
694 | color: rgb(2, 65, 132);
695 | background: transparent;
696 | padding: 10px;
697 | qproperty-icon: url(:/images/qss/White/nscc);
698 | qproperty-iconSize: 32px 32px;
699 | qproperty-toolButtonStyle: ToolButtonTextUnderIcon;
700 | }
701 | QToolButton#nsccButton:hover {
702 | background: rgb(187, 212, 238);
703 | }
704 |
705 | QToolButton#transferButton {
706 | border: none;
707 | color: rgb(2, 65, 132);
708 | background: transparent;
709 | padding: 10px;
710 | qproperty-icon: url(:/images/qss/White/transfer);
711 | qproperty-iconSize: 32px 32px;
712 | qproperty-toolButtonStyle: ToolButtonTextUnderIcon;
713 | }
714 | QToolButton#transferButton:hover {
715 | background: rgb(187, 212, 238);
716 | }
717 |
718 | /**********按钮**********/
719 | QPushButton{
720 | border-radius: 4px;
721 | border: none;
722 | width: 75px;
723 | height: 25px;
724 | }
725 | QPushButton:enabled {
726 | background: rgb(120, 170, 220);
727 | color: white;
728 | }
729 | QPushButton:!enabled {
730 | background: rgb(180, 180, 180);
731 | color: white;
732 | }
733 | QPushButton:enabled:hover{
734 | background: rgb(100, 160, 220);
735 | }
736 | QPushButton:enabled:pressed{
737 | background: rgb(0, 78, 161);
738 | }
739 |
740 | QPushButton#blueButton {
741 | color: white;
742 | }
743 | QPushButton#blueButton:enabled {
744 | background: rgb(0, 78, 161);
745 | color: white;
746 | }
747 | QPushButton:!enabled {
748 | background: rgb(180, 180, 180);
749 | color: white;
750 | }
751 | QPushButton#blueButton:enabled:hover {
752 | background: rgb(2, 65, 132);
753 | }
754 | QPushButton#blueButton:enabled:pressed {
755 | background: rgb(6, 94, 187);
756 | }
757 |
758 | QPushButton#selectButton {
759 | border: none;
760 | border-radius: none;
761 | border-left: 1px solid rgb(111, 156, 207);
762 | background: transparent;
763 | image: url(:/images/qss/White/scan);
764 | color: rgb(51, 51, 51);
765 | }
766 | QPushButton#selectButton:enabled:hover{
767 | background: rgb(187, 212, 238);
768 | }
769 | QPushButton#selectButton:enabled:pressed{
770 | background: rgb(120, 170, 220);
771 | }
772 |
773 | QPushButton#linkButton {
774 | background: transparent;
775 | color: rgb(0, 160, 230);
776 | text-align:left;
777 | }
778 | QPushButton#linkButton:hover {
779 | color: rgb(20, 185, 255);
780 | text-decoration: underline;
781 | }
782 | QPushButton#linkButton:pressed {
783 | color: rgb(0, 160, 230);
784 | }
785 |
786 | QPushButton#transparentButton {
787 | background: transparent;
788 | }
789 |
790 | /*****************标题栏按钮*******************/
791 | QPushButton#minimizeButton {
792 | border-radius: none;
793 | border-bottom-left-radius: 4px;
794 | border-bottom-right-radius: 4px;
795 | background: rgb(120, 170, 220);
796 | image: url(:/images/qss/White/minimizeHover);
797 | }
798 | QPushButton#minimizeButton:hover {
799 | image: url(:/images/qss/White/minimize);
800 | }
801 | QPushButton#minimizeButton:pressed {
802 | image: url(:/images/qss/White/minimizePressed);
803 | }
804 |
805 | QPushButton#maximizeButton[maximizeProperty="maximize"] {
806 | border-radius: none;
807 | border-bottom-left-radius: 4px;
808 | border-bottom-right-radius: 4px;
809 | background: rgb(120, 170, 220);
810 | image: url(:/images/qss/White/maximizeHover);
811 | }
812 | QPushButton#maximizeButton[maximizeProperty="maximize"]:hover {
813 | image: url(:/images/qss/White/maximize);
814 | }
815 | QPushButton#maximizeButton[maximizeProperty="maximize"]:pressed {
816 | image: url(:/images/qss/White/maximizePressed);
817 | }
818 |
819 | QPushButton#maximizeButton[maximizeProperty="restore"] {
820 | border-radius: none;
821 | border-bottom-left-radius: 4px;
822 | border-bottom-right-radius: 4px;
823 | background: rgb(120, 170, 220);
824 | image: url(:/images/qss/White/restoreHover);
825 | }
826 | QPushButton#maximizeButton[maximizeProperty="restore"]:hover {
827 | image: url(:/images/qss/White/restore);
828 | }
829 | QPushButton#maximizeButton[maximizeProperty="restore"]:pressed {
830 | image: url(:/images/qss/White/restorePressed);
831 | }
832 |
833 | QPushButton#closeButton {
834 | border-radius: none;
835 | border-bottom-left-radius: 4px;
836 | border-bottom-right-radius: 4px;
837 | background: rgb(120, 170, 220);
838 | image: url(:/images/qss/White/closeHover);
839 | }
840 | QPushButton#closeButton:hover {
841 | image: url(:/images/qss/White/close);
842 | }
843 | QPushButton#closeButton:pressed {
844 | image: url(:/images/qss/White/closePressed);
845 | }
846 |
847 | QPushButton#skinButton {
848 | border-radius: none;
849 | border-bottom-left-radius: 4px;
850 | border-bottom-right-radius: 4px;
851 | background: rgb(120, 170, 220);
852 | image: url(:/images/qss/White/skinHover);
853 | }
854 | QPushButton#skinButton:hover {
855 | image: url(:/images/qss/White/skin);
856 | }
857 | QPushButton#skinButton:pressed {
858 | image: url(:/images/qss/White/skinPressed);
859 | }
860 |
861 | QPushButton#feedbackButton {
862 | border-radius: none;
863 | border-bottom-left-radius: 4px;
864 | border-bottom-right-radius: 4px;
865 | background: rgb(120, 170, 220);
866 | image: url(:/images/qss/White/feedbackHover);
867 | }
868 | QPushButton#feedbackButton:hover {
869 | image: url(:/images/qss/White/feedback);
870 | }
871 | QPushButton#feedbackButton:pressed {
872 | image: url(:/images/qss/White/feedbackPressed);
873 | }
874 |
875 | QPushButton#closeTipButton {
876 | border-radius: none;
877 | border-image: url(:/images/qss/White/close);
878 | background: transparent;
879 | }
880 | QPushButton#closeTipButton:hover {
881 | border-image: url(:/images/qss/White/closeHover);
882 | }
883 | QPushButton#closeTipButton:pressed {
884 | border-image: url(:/images/qss/White/closePressed);
885 | }
886 |
887 | QPushButton#changeSkinButton{
888 | border-radius: 4px;
889 | border: 2px solid rgb(111, 156, 207);
890 | background: rgb(204, 227, 252);
891 | }
892 | QPushButton#changeSkinButton:hover{
893 | border-color: rgb(60, 150, 200);
894 | }
895 | QPushButton#changeSkinButton:pressed, QPushButton#changeSkinButton:checked{
896 | border-color: rgb(0, 160, 230);
897 | }
898 |
899 | QPushButton#transferButton {
900 | padding-left: 5px;
901 | padding-right: 5px;
902 | color: white;
903 | background: rgb(0, 78, 161);
904 | }
905 | QPushButton#transferButton:hover {
906 | background: rgb(2, 65, 132);
907 | }
908 | QPushButton#transferButton:pressed {
909 | background: rgb(6, 94, 187);
910 | }
911 | QPushButton#transferButton[iconProperty="left"] {
912 | qproperty-icon: url(:/images/qss/White/left);
913 | }
914 | QPushButton#transferButton[iconProperty="right"] {
915 | qproperty-icon: url(:/images/qss/White/right);
916 | }
917 |
918 | QPushButton#openButton {
919 | border-radius: none;
920 | image: url(:/images/qss/White/open);
921 | background: transparent;
922 | }
923 | QPushButton#openButton:hover {
924 | image: url(:/images/qss/White/openHover);
925 | }
926 | QPushButton#openButton:pressed {
927 | image: url(:/images/qss/White/openPressed);
928 | }
929 |
930 | QPushButton#deleteButton {
931 | border-radius: none;
932 | image: url(:/images/qss/White/delete);
933 | background: transparent;
934 | }
935 | QPushButton#deleteButton:hover {
936 | image: url(:/images/qss/White/deleteHover);
937 | }
938 | QPushButton#deleteButton:pressed {
939 | image: url(:/images/qss/White/deletePressed);
940 | }
941 |
942 | QPushButton#menuButton {
943 | text-align: left center;
944 | padding-left: 3px;
945 | color: rgb(84, 84, 84);
946 | border: 1px solid rgb(111, 156, 207);
947 | background: white;
948 | }
949 | QPushButton#menuButton::menu-indicator{
950 | subcontrol-position: right center;
951 | subcontrol-origin: padding;
952 | image: url(:/images/qss/White/arrowBottom);
953 | padding-right: 3px;
954 | }
955 |
--------------------------------------------------------------------------------