Skip to content

Commit 077caa6

Browse files
committed
App Program Updated
1 parent a177cf2 commit 077caa6

26 files changed

+1627
-116
lines changed

TestDemo-2/DashboardTestDemo.ui

+189-55
Large diffs are not rendered by default.

TestDemo-2/DashboardTestDemo_ui.py

+127-55
Large diffs are not rendered by default.

TestDemo-2/Icons/main-logo.png

61.2 KB
Loading

TestDemo-2/Icons/rescources1.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<RCC>
22
<qresource prefix="icons">
3+
<file>main-logo.png</file>
34
<file>lock.svg</file>
45
<file>user.svg</file>
56
<file>log-in.svg</file>

TestDemo-2/Icons/rescources2.qrc

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<RCC>
22
<qresource prefix="icons">
3+
<file>main-logo.png</file>
4+
<file>send-message (2).png</file>
5+
<file>send (1).svg</file>
6+
<file>send-message.png</file>
37
<file>profile.png</file>
48
<file>send.svg</file>
59
<file>lock.svg</file>

TestDemo-2/Icons/resources5.qrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<RCC>
2+
<qresource prefix="icons">
3+
<file>main-logo.png</file>
4+
<file>lock.svg</file>
5+
<file>log-in (1).svg</file>
6+
<file>log-in.svg</file>
7+
<file>logo.png</file>
8+
<file>log-out (1).svg</file>
9+
<file>moon.svg</file>
10+
<file>plus.svg</file>
11+
<file>profile.png</file>
12+
<file>send (1).svg</file>
13+
<file>send.svg</file>
14+
<file>send-message (2).png</file>
15+
<file>send-message.png</file>
16+
<file>settings.svg</file>
17+
<file>sun.svg</file>
18+
<file>trash-2.svg</file>
19+
<file>user.svg</file>
20+
</qresource>
21+
</RCC>

TestDemo-2/Icons/send (1).svg

+1
Loading

TestDemo-2/Icons/send-message (2).png

5.96 KB
Loading

TestDemo-2/Icons/send-message.png

2.56 KB
Loading

TestDemo-2/TestDemoLogin.ui

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</property>
2222
<property name="styleSheet">
2323
<string notr="true">#Form{
24-
background-color:#0a676c
24+
background-color:#063d40
2525
}
2626

2727
#loginwidget{
@@ -54,7 +54,7 @@ color: #fff;
5454
}
5555

5656
#login_btn_frame {
57-
background-color: #0a676c;
57+
background-color: #0a676c;
5858
border-radius: 5px;
5959
}
6060
#login_btn_frame:hover {
@@ -134,7 +134,7 @@ padding-left: 5px
134134
</property>
135135
<property name="icon">
136136
<iconset resource="Icons/rescources1.qrc">
137-
<normaloff>:/icons/logo.png</normaloff>:/icons/logo.png</iconset>
137+
<normaloff>:/icons/main-logo.png</normaloff>:/icons/main-logo.png</iconset>
138138
</property>
139139
<property name="iconSize">
140140
<size>

TestDemo-2/TestDemoLogin_ui.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def setupUi(self, Form):
1515
Form.resize(510, 450)
1616
Form.setMinimumSize(QtCore.QSize(510, 450))
1717
Form.setStyleSheet("#Form{\n"
18-
"background-color:#0a676c\n"
18+
"background-color:#063d40\n"
1919
"}\n"
2020
"\n"
2121
"#loginwidget{\n"
@@ -48,7 +48,7 @@ def setupUi(self, Form):
4848
"}\n"
4949
"\n"
5050
"#login_btn_frame {\n"
51-
"background-color: #0a676c;\n"
51+
"background-color: #0a676c;\n"
5252
"border-radius: 5px;\n"
5353
"}\n"
5454
"#login_btn_frame:hover {\n"
@@ -93,7 +93,7 @@ def setupUi(self, Form):
9393
self.logo.setFont(font)
9494
self.logo.setText("")
9595
icon = QtGui.QIcon()
96-
icon.addPixmap(QtGui.QPixmap(":/icons/logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
96+
icon.addPixmap(QtGui.QPixmap(":/icons/main-logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
9797
self.logo.setIcon(icon)
9898
self.logo.setIconSize(QtCore.QSize(70, 30))
9999
self.logo.setObjectName("logo")
Binary file not shown.
Binary file not shown.
653 Bytes
Binary file not shown.

TestDemo-2/app.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
import os
3+
import json
4+
from PyQt6.QtWidgets import QApplication
5+
from main_app import MainWindow
6+
7+
if __name__ == '__main__':
8+
9+
flag = os.path.exists("datas/data.json")
10+
11+
if not flag:
12+
os.mkdir("datas")
13+
with open("datas/data.json", "w") as f:
14+
f.write(json.dumps([]))
15+
16+
app = QApplication(sys.argv)
17+
18+
window = MainWindow()
19+
window.show()
20+
21+
sys.exit(app.exec())

TestDemo-2/chat_window.py

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from PyQt6.QtWidgets import QWidget, QVBoxLayout,QSpacerItem, QSizePolicy
2+
3+
from input_widget import Ui_Form as Input_Form
4+
from output_widget import Ui_Form as Output_Form
5+
6+
class InputWidget(QWidget):
7+
def __init__(self, parent=None, chat_obj=None):
8+
sueper().__init__(parent)
9+
10+
self.input_ui = Input_Form()
11+
self.input_ui.setupUi(self)
12+
13+
self.chat_obj = chat_obj
14+
self.input_label = self.input_ui.label_2
15+
16+
def set_input_text(self, input_str):
17+
self.input_label.setText(input_str)
18+
19+
20+
21+
class OutputWidget(QWidget):
22+
def __init__(self, parent=None):
23+
sueper().__init__(parent)
24+
25+
self.output_ui = Output_Form()
26+
self.output_ui.setupUi(self)
27+
28+
self.output_label = self.output_ui.label_2
29+
30+
def set_output_text(self, output_str):
31+
self.output_label.setText(output_str)
32+
33+
class ChatWindow(QWidget):
34+
def __init__(self, parent=None, chat_obj=None, chat_data=None):
35+
super().__init__(parent)
36+
37+
self.chat_object = chat_obj
38+
self.chat_data = chat_data
39+
40+
41+
self.main_verticalLayout = QVBoxLayout(self)
42+
self.main_verticalLayout.setContentsMargins(0,0,0,0)
43+
self.main_verticalLayout.setSpacing(0)
44+
self.main_verticalLayout.setObjectName("main_verticalLayout")
45+
46+
self.style_str = """
47+
QPushButton,
48+
QLabel {
49+
border: none;
50+
padding: 5px;
51+
}
52+
53+
QWidget {
54+
background: red;
55+
}
56+
57+
"""
58+
59+
60+
self.setStyleSheet(self.style_str)
61+
self.chat_data = {
62+
"title": "",
63+
"chat_list": []
64+
}
65+
66+
if self.chat_data:
67+
self.chat_data["title"] = self.chat_data["title"]
68+
self.chats_data["title"] = self.chat_data["title"]
69+
self.chats_data["chat_list"] += self.chat_data["chat_list"]
70+
71+
self.show_chats()
72+
73+
def show_chats(self):
74+
chat_list = self.chats_data.get("chat_list")
75+
for chat in chat_list:
76+
input_str = chat.get("input_str")
77+
input_widget = InputWidget(chat_obj=self.chat_object)
78+
input_widget.set_input_text(input_str)
79+
self.main_verticalLayout.addWidget(input_widget)
80+
81+
output_str = chat.get("output_str")
82+
output_widget = OutputWidget()
83+
output_widget.set_output_text(output_str)
84+
85+
self.main_verticalLayout.addwidget(output_widget)
86+
87+
spacerItem = QSpacerItem(20, 300, QSizePolicy.Minimum, QSizePolicy.Expanding)
88+
self.main_verticalLayout.addItem(spacerItem)
89+
self.setLayout(self.main_verticalLayout)

TestDemo-2/connect_db.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import sqlite3
2+
import json
3+
4+
class ConnectDB:
5+
def __init__(self):
6+
self.chat_db_path = "datas/data.json"
7+
8+
9+
def get_chat_data(self):
10+
with open(self.chat_db_path, "r") as f:
11+
chat_db = json.load(f)
12+
13+
return chat_db
14+
15+
def get_chat_title_list(self):
16+
chat_list = []
17+
chat_db = self.get_chat_data()
18+
for chat in chat_db:
19+
title = chat.get("title")
20+
chat_list.append(title)
21+
return chat_list
22+
23+
def save_chat_data(self, new_chat_data):
24+
with open(self.chat_db_path, "w") as f:
25+
f.write(json.dups(new_chat_data))
26+
27+
def delete_all_data(self):
28+
chat_db = self.get_chat_data()
29+
chat_db.Clear()
30+
self.save_chat_data(chat_db)
31+
32+
def delete_chat_data(self, index):
33+
chat_db = self.get_chat_data()
34+
chat_db.pop(index)
35+
self.save_chat_data(chat_db)
36+

TestDemo-2/datas/data.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)