diff --git a/usr/share/aiassistant/exchangePage.py b/usr/share/aiassistant/exchangePage.py index 636a5e43a2b1432f3f080dbd0e666251003b9a93..b830701bac91f3155145c96f3387a106f25f1ab4 100644 --- a/usr/share/aiassistant/exchangePage.py +++ b/usr/share/aiassistant/exchangePage.py @@ -22,6 +22,8 @@ from Config import Config class exChange(QWidget): collect_voice_signal = pyqtSignal() collect_voice_flag = False + stop_speech_signal = pyqtSignal() + stop_speech_flag = False def __init__(self): super().__init__() @@ -121,8 +123,11 @@ class exChange(QWidget): self.state = '休眠中' + def capture_voice(self): self.collect_voice_signal.emit() + def stop_speech(self): + self.stop_speech_signal.emit() def updateButton(self): # 更新按钮的图标 if self.current_image_index < len(self.image_files): @@ -149,6 +154,10 @@ class exChange(QWidget): self.capture_voice() #获取声音信息 # self.respondToUser() #self.timer.start(5000) # 3秒 + if self.state == '应答中': + self.updateStatus('休眠中') + self.stop_speech() + def updateStatus(self, new_status): @@ -193,14 +202,14 @@ class exChange(QWidget): raise NotImplementedError("illegal type") # 测试布局和交互效果 -from PyQt5.QtWidgets import * -from PyQt5.QtCore import * -from PyQt5.QtGui import * - -if __name__ == '__main__': - app = QApplication([]) - widget = exChange() - widget.show() - app.exec_() +# from PyQt5.QtWidgets import * +# from PyQt5.QtCore import * +# from PyQt5.QtGui import * +# +# if __name__ == '__main__': +# app = QApplication([]) +# widget = exChange() +# widget.show() +# app.exec_() diff --git a/usr/share/aiassistant/mainwin.py b/usr/share/aiassistant/mainwin.py index 35875e86a928189d0e452e91fee46a57939f38b9..2b35ee4c52594510f1aa66b31a158a7b20b6c185 100644 --- a/usr/share/aiassistant/mainwin.py +++ b/usr/share/aiassistant/mainwin.py @@ -38,7 +38,7 @@ public_types = PublicTypes() class ShadowWindow(QWidget): def __init__(self): super().__init__() - self.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint) #Qt.Dialog主要用于在任务栏隐藏图标 + self.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) #Qt.Dialog主要用于在任务栏隐藏图标 self.setAttribute(Qt.WA_TranslucentBackground) self.setObjectName('shadowindow') self.setStyleSheet( @@ -77,6 +77,7 @@ class ShadowWindow(QWidget): self.title = MianWinTitle(self) self.aboutPage = AboutPage(self) + self.settingPage = SettingsPage(self) # self.title.mousePressEvent = lambda event: # home button @@ -284,6 +285,10 @@ class ShadowWindow(QWidget): self.widget.meeting_bottom_ui.setFixedHeight(120) self.widget.bottomStackWgt.setFixedHeight(120) + self.show() + self.raise_() + self.activateWindow() + else: pass @@ -325,6 +330,10 @@ class ShadowWindow(QWidget): self.setMaximumWidth(public_types.mainwin_width) self.move_to_right_bottom() + + self.show() + self.raise_() + self.activateWindow() else: pass @@ -384,8 +393,8 @@ class ShadowWindow(QWidget): self.apiKeyConfigPage.show() def openSettingPage(self): + self.settingPage.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint) #创建并显示设置页面 - self.settingPage = SettingsPage(self) self.settingPage.show() # 绑定设置页面的关闭信号到槽函数 self.settingPage.closed.connect(self.onSettingPageClosed) @@ -398,6 +407,7 @@ class ShadowWindow(QWidget): self.show() def openAboutPage(self): + self.aboutPage.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint) #创建并显示设置页面 self.aboutPage.show() # 绑定设置页面的关闭信号到槽函数 @@ -411,8 +421,6 @@ class ShadowWindow(QWidget): self.show() def onSettingPageClosed(self): - # 设置窗口置顶标志 - self.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint) # 重新置顶主窗口 self.raise_() self.show() @@ -511,6 +519,7 @@ class Mainwin(QWidget): # self.bottom_ui.send_text_signal.connect(self.send_message_to_ai) self.exchange.collect_voice_signal.connect(self.collect_voice_handle) + self.exchange.stop_speech_signal.connect(self.stop_speech_signal_exchange) self.guidWgt.chat_model_signal.connect(self.set_chat_model) self.guidWgt.paint_model_signal.connect(self.set_paint_model) @@ -639,6 +648,8 @@ class Mainwin(QWidget): else: self.speechTask.set_message(message, bubble_message) self.speechTask.start() + def stop_speech_signal_exchange(self): + self.speechTask.stop_speech() def speechTaskCallback(self, bubble_message): print("speechTaskCallback")