Skip to content

Commit

Permalink
解密后自动加载联系人页面
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Nov 15, 2023
1 parent cc97628 commit e180e58
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
28 changes: 15 additions & 13 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions app/DataBase/micro_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
cursor = DB.cursor()


def init_database():
global DB
global cursor
if not DB:
if os.path.exists(micromsg_path):
DB = sqlite3.connect(micromsg_path, check_same_thread=False)
# '''创建游标'''
cursor = DB.cursor()


def is_database_exist():
return os.path.exists(micromsg_path)

Expand Down
5 changes: 5 additions & 0 deletions app/ui_pc/contact/contact_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, parent=None):
super().__init__(parent)
self.show_thread = None
self.setupUi(self)
self.ok_flag = False
self.setStyleSheet(Stylesheet)
self.init_ui()
self.show_contacts()
Expand All @@ -60,12 +61,16 @@ def init_ui(self):
self.stackedWidget.setCurrentIndex(0)

def show_contacts(self):
if self.ok_flag:
return
micro_msg.init_database()
if not micro_msg.is_database_exist():
QMessageBox.critical(self, "错误", "数据库不存在\n请先解密数据库")
return
self.show_thread = ShowContactThread()
self.show_thread.showSingal.connect(self.show_contact)
self.show_thread.start()
self.ok_flag = True

def show_contact(self, contact):
contact_item = ContactQListWidgetItem(contact.nickName, contact.smallHeadImgUrl, contact.smallHeadImgBLOG)
Expand Down
7 changes: 4 additions & 3 deletions app/ui_pc/mainview.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def init_ui(self):
label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % (
randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label)
contact_window = ContactWindow()
self.stackedWidget.addWidget(contact_window)
self.contact_window = ContactWindow()
self.stackedWidget.addWidget(self.contact_window)
label = QLabel('我是页面', self)
label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机)
Expand All @@ -99,7 +99,8 @@ def init_ui(self):
self.stackedWidget.setCurrentIndex(3)

def setCurrentIndex(self, row):
print(row)
if row == 1:
self.contact_window.show_contacts()
self.stackedWidget.setCurrentIndex(row)

def about(self):
Expand Down

0 comments on commit e180e58

Please sign in to comment.