MineQWidget.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from PySide6.QtWidgets import *
  2. from PySide6.QtCore import *
  3. from PySide6.QtGui import *
  4. from PySide6.QtWidgets import *
  5. from PySide6.QtCore import *
  6. from PySide6.QtMultimedia import *
  7. import settings
  8. import os
  9. import threading
  10. import concurrent.futures
  11. from functools import partial
  12. # 统一封装
  13. class MineQWidget(QWidget):
  14. def __init__(self):
  15. super().__init__()
  16. self.setWindowFlags(Qt.WindowStaysOnTopHint)
  17. def checkLogin(self):
  18. """检查是否登录"""
  19. if not settings.IsLogin:
  20. # self.PlayErrorAudio()
  21. QMessageBox.critical(self, "警告", "请先登录账号", QMessageBox.Ok)
  22. return False
  23. return True
  24. def WaringMessage(self, message):
  25. """警告弹窗"""
  26. # self.PlayErrorAudio()
  27. return QMessageBox.critical(self, "警告", message, QMessageBox.Ok)
  28. def PlayErrorAudio(self):
  29. current_path = os.getcwd()
  30. effect = QSoundEffect(self)
  31. # print("current_path", current_path)
  32. effect.setSource(
  33. QUrl.fromLocalFile(r"{}\resources\ttl\error_audio.wav".format(current_path))
  34. )
  35. effect.setVolume(1)
  36. effect.setLoopCount(1)
  37. effect.play()
  38. return
  39. def comfirmMessage(self, message):
  40. questResult = QMessageBox.question(
  41. self, "确认", message, QMessageBox.Yes | QMessageBox.No
  42. )
  43. return questResult