20240810105500
This commit is contained in:
parent
c51920d73f
commit
8a9f786107
19
main.py
19
main.py
|
@ -4,8 +4,9 @@ import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
import hashlib
|
||||||
|
import tempfile
|
||||||
import warnings
|
import warnings
|
||||||
import threading
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import win32com.client
|
import win32com.client
|
||||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QDialog, QLabel, QComboBox, QCheckBox, QLineEdit, QAction, QMenu, QMessageBox, QPushButton, QTableWidget, QVBoxLayout, QHBoxLayout, QTableWidgetItem
|
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QDialog, QLabel, QComboBox, QCheckBox, QLineEdit, QAction, QMenu, QMessageBox, QPushButton, QTableWidget, QVBoxLayout, QHBoxLayout, QTableWidgetItem
|
||||||
|
@ -611,7 +612,7 @@ class MainWindow(QMainWindow):
|
||||||
def __init__(self, logger: Logger):
|
def __init__(self, logger: Logger):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.app_name = '蓝牙音频连接'
|
self.app_name = '蓝牙音频连接'
|
||||||
self.app_version = ('1.0.1', '20240808', 'zhaoyafan', 'zhaoyafan@foxmail.com', 'https://www.fanscloud.net/')
|
self.app_version = ('1.0.2', '20240810', 'zhaoyafan', 'zhaoyafan@foxmail.com', 'https://www.fanscloud.net/')
|
||||||
self.app_text = {'search': '正在搜索', 'connecting': '连接中...'}
|
self.app_text = {'search': '正在搜索', 'connecting': '连接中...'}
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.bluesoleil = None
|
self.bluesoleil = None
|
||||||
|
@ -694,7 +695,14 @@ class MainWindow(QMainWindow):
|
||||||
self.init_bluesoleil()
|
self.init_bluesoleil()
|
||||||
|
|
||||||
def init_bluesoleil(self):
|
def init_bluesoleil(self):
|
||||||
|
try:
|
||||||
self.bluesoleil = BtSdk()
|
self.bluesoleil = BtSdk()
|
||||||
|
except FileNotFoundError:
|
||||||
|
QMessageBox.critical(self, '错误', '关键程序“千月(bluesoleil)”未安装,请安装后再试')
|
||||||
|
self.close()
|
||||||
|
except Exception:
|
||||||
|
QMessageBox.critical(self, '警告', '蓝牙尚未启动')
|
||||||
|
self.close()
|
||||||
|
|
||||||
def restartServActionFunction(self):
|
def restartServActionFunction(self):
|
||||||
if (os.path.exists('C:\\Program Files (x86)\\IVT Corporation\\BlueSoleil\\BtTray.exe')) == 1:
|
if (os.path.exists('C:\\Program Files (x86)\\IVT Corporation\\BlueSoleil\\BtTray.exe')) == 1:
|
||||||
|
@ -743,8 +751,11 @@ class MainWindow(QMainWindow):
|
||||||
f.write(b'\x22\x00')
|
f.write(b'\x22\x00')
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
|
try:
|
||||||
self.bluesoleil.done()
|
self.bluesoleil.done()
|
||||||
self.bluesoleil = None
|
self.bluesoleil = None
|
||||||
|
except:
|
||||||
|
pass
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def open_manu_search_dialog(self):
|
def open_manu_search_dialog(self):
|
||||||
|
@ -946,7 +957,7 @@ class ManuWindow(QDialog):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if (os.path.basename(__file__).lower().endswith('.int')) == 1:
|
if (os.path.basename(__file__).lower().endswith('.int')) == 1:
|
||||||
QCoreApplication.addLibraryPath(os.path.abspath(os.path.join(os.path.dirname(__file__), 'site-packages/PyQt5/Qt5/plugins')))
|
QCoreApplication.addLibraryPath(os.path.abspath(os.path.join(os.path.dirname(__file__), 'site-packages/PyQt5/Qt5/plugins')))
|
||||||
f_lock = open(file='%s.lock' % (os.path.splitext(__file__)[0],), mode='w', encoding='utf-8')
|
f_lock = open(file=os.path.abspath(os.path.join(tempfile.gettempdir(), '%s.lock' % hashlib.md5(bytes(__file__, encoding='utf-8')).hexdigest()[:16])), mode='w', encoding='utf-8')
|
||||||
if (not flock(f_lock, LOCK_EX | LOCK_NB)) == 1:
|
if (not flock(f_lock, LOCK_EX | LOCK_NB)) == 1:
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
msg = QMessageBox()
|
msg = QMessageBox()
|
||||||
|
@ -958,5 +969,5 @@ if __name__ == '__main__':
|
||||||
app.exit(1)
|
app.exit(1)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
window_main = MainWindow(logger=Logger(name='main', fh=LoggerFileHandler(log_file='%s.log' % (os.path.splitext(__file__)[0],), mode='w'), ch=LoggerConsHandler()))
|
window_main = MainWindow(logger=Logger(name='main', fh=None, ch=LoggerConsHandler()))
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
Loading…
Reference in New Issue