解密后自动加载联系人页面

This commit is contained in:
shuaikangzhou 2023-11-16 00:13:49 +08:00
parent cc97628902
commit e180e58d0f
4 changed files with 34 additions and 16 deletions

View File

@ -4,8 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="修复db文件空格路径的bug"> <list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="修复情感分析数值显示过长的bug">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/ui_pc/contact/contact_window.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/contact/contact_window.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/ui_pc/mainview.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/mainview.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -101,7 +103,7 @@
<recent name="D:\Project\PythonProject\WeChatMsg\app\Ui" /> <recent name="D:\Project\PythonProject\WeChatMsg\app\Ui" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.main"> <component name="RunManager" selected="Python.decrypt_window">
<configuration name="CAvatar" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="CAvatar" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="WeChatMsg" /> <module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@ -230,8 +232,8 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.main" />
<item itemvalue="Python.decrypt_window" /> <item itemvalue="Python.decrypt_window" />
<item itemvalue="Python.main" />
<item itemvalue="Python.misc" /> <item itemvalue="Python.misc" />
<item itemvalue="Python.CAvatar" /> <item itemvalue="Python.CAvatar" />
<item itemvalue="Python.contact_info_ui" /> <item itemvalue="Python.contact_info_ui" />
@ -250,13 +252,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1672848140146</updated> <updated>1672848140146</updated>
</task> </task>
<task id="LOCAL-00015" summary="烂了">
<created>1680624068689</created>
<option name="number" value="00015" />
<option name="presentableId" value="LOCAL-00015" />
<option name="project" value="LOCAL" />
<updated>1680624068689</updated>
</task>
<task id="LOCAL-00016" summary="窗口切换使用stackedWidget"> <task id="LOCAL-00016" summary="窗口切换使用stackedWidget">
<created>1680630659802</created> <created>1680630659802</created>
<option name="number" value="00016" /> <option name="number" value="00016" />
@ -593,7 +588,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1700063620952</updated> <updated>1700063620952</updated>
</task> </task>
<option name="localTasksCounter" value="64" /> <task id="LOCAL-00064" summary="修复情感分析数值显示过长的bug">
<created>1700064404522</created>
<option name="number" value="00064" />
<option name="presentableId" value="LOCAL-00064" />
<option name="project" value="LOCAL" />
<updated>1700064404522</updated>
</task>
<option name="localTasksCounter" value="65" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -629,7 +631,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="重构一些class删除一些不必要的文件" />
<MESSAGE value="用stackedWidget实现导航栏" /> <MESSAGE value="用stackedWidget实现导航栏" />
<MESSAGE value="修复部分bug" /> <MESSAGE value="修复部分bug" />
<MESSAGE value="替换chat里的contact" /> <MESSAGE value="替换chat里的contact" />
@ -654,7 +655,8 @@
<MESSAGE value="头像支持显示二进制" /> <MESSAGE value="头像支持显示二进制" />
<MESSAGE value="显示联系人信息" /> <MESSAGE value="显示联系人信息" />
<MESSAGE value="修复db文件空格路径的bug" /> <MESSAGE value="修复db文件空格路径的bug" />
<option name="LAST_COMMIT_MESSAGE" value="修复db文件空格路径的bug" /> <MESSAGE value="修复情感分析数值显示过长的bug" />
<option name="LAST_COMMIT_MESSAGE" value="修复情感分析数值显示过长的bug" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
</component> </component>

View File

@ -10,6 +10,16 @@ if os.path.exists(micromsg_path):
cursor = DB.cursor() 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(): def is_database_exist():
return os.path.exists(micromsg_path) return os.path.exists(micromsg_path)

View File

@ -49,6 +49,7 @@ class ContactWindow(QWidget, Ui_Form):
super().__init__(parent) super().__init__(parent)
self.show_thread = None self.show_thread = None
self.setupUi(self) self.setupUi(self)
self.ok_flag = False
self.setStyleSheet(Stylesheet) self.setStyleSheet(Stylesheet)
self.init_ui() self.init_ui()
self.show_contacts() self.show_contacts()
@ -60,12 +61,16 @@ class ContactWindow(QWidget, Ui_Form):
self.stackedWidget.setCurrentIndex(0) self.stackedWidget.setCurrentIndex(0)
def show_contacts(self): def show_contacts(self):
if self.ok_flag:
return
micro_msg.init_database()
if not micro_msg.is_database_exist(): if not micro_msg.is_database_exist():
QMessageBox.critical(self, "错误", "数据库不存在\n请先解密数据库") QMessageBox.critical(self, "错误", "数据库不存在\n请先解密数据库")
return return
self.show_thread = ShowContactThread() self.show_thread = ShowContactThread()
self.show_thread.showSingal.connect(self.show_contact) self.show_thread.showSingal.connect(self.show_contact)
self.show_thread.start() self.show_thread.start()
self.ok_flag = True
def show_contact(self, contact): def show_contact(self, contact):
contact_item = ContactQListWidgetItem(contact.nickName, contact.smallHeadImgUrl, contact.smallHeadImgBLOG) contact_item = ContactQListWidgetItem(contact.nickName, contact.smallHeadImgUrl, contact.smallHeadImgBLOG)

View File

@ -85,8 +85,8 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % ( label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % (
randint(0, 255), randint(0, 255), randint(0, 255))) randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label) self.stackedWidget.addWidget(label)
contact_window = ContactWindow() self.contact_window = ContactWindow()
self.stackedWidget.addWidget(contact_window) self.stackedWidget.addWidget(self.contact_window)
label = QLabel('我是页面', self) label = QLabel('我是页面', self)
label.setAlignment(Qt.AlignCenter) label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机) # 设置label的背景颜色(这里随机)
@ -99,7 +99,8 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.stackedWidget.setCurrentIndex(3) self.stackedWidget.setCurrentIndex(3)
def setCurrentIndex(self, row): def setCurrentIndex(self, row):
print(row) if row == 1:
self.contact_window.show_contacts()
self.stackedWidget.setCurrentIndex(row) self.stackedWidget.setCurrentIndex(row)
def about(self): def about(self):