Skip to content

Instantly share code, notes, and snippets.

@Cryolitia
Created October 27, 2025 07:53
Show Gist options
  • Select an option

  • Save Cryolitia/e46b3f619749ca22212ee7f57ba254fd to your computer and use it in GitHub Desktop.

Select an option

Save Cryolitia/e46b3f619749ca22212ee7f57ba254fd to your computer and use it in GitHub Desktop.
lecoo-mini-pro-control-center
# uncompyle6 version 3.9.3
# Python bytecode version base 3.6 (3379)
# Decompiled from: Python 3.10.18 (main, Jun 4 2025, 08:17:53) [GCC 14.3.0 20250523 (AOSC OS, Core)]
# Embedded file name: ControlCenter.py
import multiprocessing, os, platform, random, signal, sys, time
from ctypes import *
from ftplib import FTP
from multiprocessing import Queue, Process
import clr, psutil, urllib3, wmi
from PyQt5 import QtCore
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtCore import *
from PyQt5.QtCore import QPoint
from PyQt5.QtCore import QSize
from PyQt5.QtCore import QTimer
from PyQt5.QtGui import *
from PyQt5.QtGui import QEnterEvent, QPainter, QColor, QPen
from PyQt5.QtGui import QFont
from PyQt5.QtGui import QIcon
from PyQt5.QtNetwork import QNetworkConfigurationManager
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QSpacerItem, QSizePolicy
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QStackedWidget
from win32 import win32api, win32gui, win32print
from win32.lib import win32con
from win32com.client import GetObject
from CPUGPUMemorynew import CircleCPUTemperature, MemoryInfo, DiskInfo
from btn1 import SwitchBtn
sys.path.append(os.getcwd())
protecthdll = CDLL("DllCallMethod.dll")
def getAllPid():
pid_dict = {}
pids = psutil.pids()
for pid in pids:
p = psutil.Process(pid)
pid_dict[pid] = p.name()
return pid_dict
def kill(pid):
try:
kill_pid = os.kill(pid, signal.SIGABRT)
except Exception as e:
pass
def close_relation_pro():
dic = getAllPid()
for t in dic.keys():
if dic[t] == "ControlCenter.exe":
kill(t)
os._exit(0)
class FTPBiosInfo(FTP):
encoding = "gbk"
def getSubdir(self, *args):
"""拷贝了 nlst() 和 dir() 代码修改,返回详细信息而不打印"""
cmd = "LIST"
func = None
if args[-1:]:
if type(args[-1]) != type(""):
args, func = args[:-1], args[-1]
for arg in args:
cmd = cmd + (" " + arg)
files = []
self.retrlines(cmd, files.append)
return files
def getdirs(self, dirname=None):
"""返回目录列表,包括文件简要信息"""
if dirname != None:
self.cwd(dirname)
files = self.getSubdir()
r_files = [file.split(" ")[-1] for file in files]
return [file for file in r_files if file != "." if file != ".."]
def getfiles(self, dirname=None):
"""返回文件列表,简要信息"""
if dirname != None:
self.cwd(dirname)
return self.nlst()
def ftp_read_bios_version():
try:
ftp = FTPBiosInfo()
ftp.connect("116.236.154.218", 2300, 5)
ftp.login("gmcnt", "7PP3jRARfsH7A8y8")
lst = ftp.getdirs("/APP/BoxAPP/client1/bios_version")
print(lst)
ftp.quit()
return lst
except ConnectionRefusedError:
print("无法连接")
return "无法连接"
class RunInfothread(QtCore.QThread):
_signal = pyqtSignal(str, str, str, str, str, str, str, str, str, str)
def __init__(self):
super(RunInfothread, self).__init__()
def __del__(self):
self.wait()
def run(self):
while True:
try:
c = wmi.WMI()
sys1 = c.Win32_OperatingSystem()[0]
processor = c.Win32_Processor()[0]
ssd1 = c.Win32_DiskDrive()[0]
memory = c.Win32_PhysicalMemory()[0]
for bios_id in c.Win32_BIOS():
biosidstr = bios_id.Version
break
mem = str(round(float(psutil.virtual_memory().total) / 1024.0 / 1024.0 / 1024.0, 1)) + "GB"
hDC = win32gui.GetDC(0)
w = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
h = win32print.GetDeviceCaps(hDC, win32con.DESKTOPVERTRES)
screen_scale_rate = str(int(round(w / sX, 2) * 100)) + "%"
sysinfo, versionnum, sysbit, cpuinfo, boardinfo, biosversion, meminfo, diplay, ssdinfo, memoeysp = (
sys1.Caption, platform.version(), sys1.OSArchitecture, processor.Name.strip(),
c.Win32_BaseBoard()[0].Product, biosidstr, mem,
"分辨率 " + str(w) + "x" + str(h) + " 缩放比例 " + screen_scale_rate, ssd1.Caption, memory.Speed)
except:
print("获取设备基本信息异常")
self._signal.emit(sysinfo, versionnum, sysbit, cpuinfo, boardinfo, biosversion, meminfo, diplay, ssdinfo, memoeysp)
def GetFeatureValue():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("GetFeatureValue").inParameters.SpawnInstance_()
objInParam.Reserved1 = 1
objInParam.Reserved2 = 0
objInParam.Reserved3 = 0
objInParam.Reserved4 = 0
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetFeatureValue", objInParam)
resbin = bin(objOutParams.ResultStatus).split("0b")[1]
while len(resbin) < 8:
resbin = "".join(["0", resbin])
return (
int(resbin[0]), int(resbin[1]), int(resbin[2]), int(resbin[3]), int(resbin[4]), int(resbin[5]),
int(resbin[6]), int(resbin[7]))
except:
print("获取特征值失败,可能是设备不支持")
return (-1, -1, -1, -1, -1, -1, -1, -1)
def SetFeatureValue(par1, par2):
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("SetFeatureValue").inParameters.SpawnInstance_()
objInParam.Reserved1 = par1
objInParam.Reserved2 = par2
objInParam.Reserved3 = 0
objInParam.Reserved4 = 0
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "SetFeatureValue", objInParam)
return objOutParams.ResultStatus
except:
print("获取支持的模式数量失败,可能是设备不支持")
return -1
def GetModeNum():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("GetFeatureValue").inParameters.SpawnInstance_()
objInParam.Reserved1 = 2
objInParam.Reserved2 = 0
objInParam.Reserved3 = 0
objInParam.Reserved4 = 0
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetFeatureValue", objInParam)
return objOutParams.ResultStatus
except:
print("获取支持的模式数量失败,可能是设备不支持")
return -1
def GetFeatureValue_3():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("GetFeatureValue").inParameters.SpawnInstance_()
objInParam.Reserved1 = 3
objInParam.Reserved2 = 0
objInParam.Reserved3 = 0
objInParam.Reserved4 = 0
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetFeatureValue", objInParam)
return objOutParams.ResultStatus
except:
print("获取支持的风扇数量,可能是设备不支持")
return -1
def GetFeatureValue_4():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("GetFeatureValue").inParameters.SpawnInstance_()
objInParam.Reserved1 = 4
objInParam.Reserved2 = 0
objInParam.Reserved3 = 0
objInParam.Reserved4 = 0
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetFeatureValue", objInParam)
return objOutParams.ResultStatus
except:
print("获取是否支持GPU,可能是设备不支持")
return -1
def whether_support_cpu_turbo():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("GetFeatureValue").inParameters.SpawnInstance_()
objInParam.Reserved1 = 5
objInParam.Reserved2 = 0
objInParam.Reserved3 = 0
objInParam.Reserved4 = 0
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetFeatureValue", objInParam)
return objOutParams.ResultStatus
except:
print("获取是否支持cputurbo,可能是设备不支持")
return -1
def get_OSD_version():
if os.path.exists("C:/Program Files/ImagesShow"):
osddirlist = os.listdir("C:/Program Files/ImagesShow")
last_version = ""
for singel in osddirlist:
if "OsdShowV" in singel:
char1 = "OsdShowV"
char2 = ".exe"
nPos1 = singel.find(char1) + 8
nPos2 = singel.find(char2)
last_version = singel[nPos1:nPos2]
return last_version
if not last_version:
return "No Find"
else:
return "No Find"
def onReScan():
devs = hid.enumerate(1046, 32769)
dev = 0
devs.sort(key=(lambda x: (x["vendor_id"], x["product_id"], x.get("usage", 0))), reverse=True)
for d in devs:
if d["usage_page"] == 1:
if d["usage"] == 2:
dev = d
break
return dev["path"]
try:
devpath = onReScan()
device = hid.device()
device.open_path(devpath)
except:
pass
def GetFanRPM():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("GetFanControl").inParameters.SpawnInstance_()
objInParam.FanNumber = 1
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetFanControl", objInParam)
objFanDuty = objOutParams.FanDuty
reshex = hex(objFanDuty).split("0x")[1]
while len(reshex) < 8:
reshex = "".join(["0", reshex])
fan1RPM = eval("0x" + reshex[4:8])
fan2RPM = eval("0x" + reshex[0:4])
return (
fan1RPM, fan2RPM)
except:
print("获取失败,可能是设备不支持")
return (-1, -1)
def SetFan1Control(par):
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("SetFanControl").inParameters.SpawnInstance_()
objInParam.FanNumber = 1
objInParam.FanDuty = par
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "SetFanControl", objInParam)
return objOutParams.ResultStatus
except:
print("设置不成功,可能是设备不支持")
return -1
def SetFan2Control(par):
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("SetFanControl").inParameters.SpawnInstance_()
objInParam.FanNumber = 2
objInParam.FanDuty = par
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "SetFanControl", objInParam)
return objOutParams.ResultStatus
except:
print("设置不成功,可能是设备不支持")
return -1
class Fan1Circle(QMainWindow):
def __init__(self, q):
super().__init__()
self.qq = q
self.setWindowTitle("Fan1Circle")
self.resize(400, 400)
self.fanTimer = QTimer()
self.fanTimer.setInterval(10)
self.fanTimer.timeout.connect(self.fanTimerOut)
self.fanAngle = 0
self.RPM = 0
self.RPMStr = "RPM"
self.getRPMTimer = QTimer()
self.getRPMTimer.setInterval(1000)
self.getRPMTimer.timeout.connect(self.getRPMTimerOut)
self.getRPMTimer.stop()
def getRPMTimerOut(self):
if self.qq.qsize() != 0:
temp = self.qq.get()
if temp == 0 or temp == -1 or temp == 8000:
if self.fanTimer.isActive():
self.fanTimer.stop()
self.RPM = 0
else:
self.RPM = temp
if self.RPM > 0:
if self.RPM < 2000:
self.fanTimerLevel1()
if self.RPM >= 2000:
if self.RPM < 3000:
self.fanTimerLevel2()
if self.RPM >= 3000 and self.RPM < 4000:
self.fanTimerLevel3()
elif self.RPM >= 4000 and self.RPM < 5000:
self.fanTimerLevel4()
else:
if self.RPM >= 5000:
if self.RPM < 6000:
self.fanTimerLevel5()
else:
self.fanTimerLevel6()
self.update()
def OpenGetRPMTimer(self):
if self.getRPMTimer.isActive():
self.getRPMTimer.stop()
self.getRPMTimer.start()
def fanTimerOut(self):
if self.fanAngle == 360:
self.fanAngle = 0
self.fanAngle += 1
self.update()
def fanTimerStop(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
def fanTimerLevel1(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(9)
self.fanTimer.start()
def fanTimerLevel2(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(8)
self.fanTimer.start()
def fanTimerLevel3(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(7)
self.fanTimer.start()
def fanTimerLevel4(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(6)
self.fanTimer.start()
def fanTimerLevel5(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(5)
self.fanTimer.start()
def fanTimerLevel6(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(4)
self.fanTimer.start()
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
side = min(self.width(), self.height())
painter.translate(self.width() / 2, self.height() / 2)
painter.scale(side / 400, side / 400)
self.drawCircle(painter)
self.drawpolygon1(painter)
self.drawTitle(painter)
def drawCircle(self, painter):
painter.save()
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#696969"))
radius1 = 140
painter.drawEllipse(-radius1, -radius1, radius1 * 2, radius1 * 2)
radius2 = 132
painter.setBrush(QColor("#000000"))
painter.drawEllipse(-radius2, -radius2, radius2 * 2, radius2 * 2)
radius3 = 78
painter.setBrush(QColor("#232323"))
painter.drawEllipse(-radius3, -radius3, radius3 * 2, radius3 * 2)
painter.restore()
def drawpolygon(self, painter):
painter.rotate(self.fanAngle)
painter.save()
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#1fe1fd"))
points = QPolygon([
QPoint(5, -190),
QPoint(30, -190),
QPoint(20, -139),
QPoint(0, -140)])
painter.drawPolygon(points)
for i in range(17):
painter.rotate(20)
painter.drawPolygon(points)
painter.restore()
def drawpolygon1(self, painter):
painter.rotate(self.fanAngle)
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#41aa94"))
painter.save()
path = QPainterPath()
path.moveTo(0, -140)
path.lineTo(20, -139)
path.cubicTo(19, -160, 26, -175, 35, -185)
path.lineTo(10, -185)
path.cubicTo(3, -170, 1, -150, 0, -140)
painter.drawPath(path)
for i in range(17):
painter.rotate(20)
painter.drawPath(path)
painter.restore()
def drawTitle(self, p):
p.save()
p.rotate(-self.fanAngle)
p.setPen(Qt.white)
font = QFont("Microsoft YaHei")
pointsize = font.pointSize()
font.setPixelSize(int(pointsize * 90 / 30))
app.setFont(font)
font = QFont(font)
p.setFont(font)
fm = QFontMetrics(p.font())
w = fm.size(Qt.TextSingleLine, str(self.RPM)).width()
p.drawText(int(-w / 2), -2, str(self.RPM))
p.setPen(QColor(97, 105, 111))
fm = QFontMetrics(p.font())
w = fm.size(Qt.TextSingleLine, self.RPMStr).width()
p.drawText(int(-w / 2), 50, self.RPMStr)
p.restore()
def fan1process(self, q):
process1 = multiprocessing.Process(target=updaterfan1, args=(q,))
process1.daemon = True
process1.start()
def updaterfan1(fan1q):
while True:
a, b = GetFanRPM()
fan1q.put(a)
print("风扇1的转速为:", a)
time.sleep(1.5)
class Fan2Circle(QMainWindow):
def __init__(self, q):
super().__init__()
self.qq = q
self.setWindowTitle("Fan2Circle")
self.resize(400, 400)
self.fanTimer = QTimer()
self.fanTimer.setInterval(10)
self.fanTimer.timeout.connect(self.fanTimerOut)
self.fanAngle = 0
self.RPM = 0
self.RPMStr = "RPM"
self.getRPMTimer = QTimer()
self.getRPMTimer.setInterval(1000)
self.getRPMTimer.timeout.connect(self.getRPMTimerOut)
def getRPMTimerOut(self):
if self.qq.qsize() != 0:
temp = self.qq.get()
if temp == 0 or temp == -1 or temp == 8000:
if self.fanTimer.isActive():
self.fanTimer.stop()
self.RPM = 0
else:
self.RPM = temp
if self.RPM > 0:
if self.RPM < 2000:
self.fanTimerLevel1()
if self.RPM >= 2000:
if self.RPM < 3000:
self.fanTimerLevel2()
if self.RPM >= 3000 and self.RPM < 4000:
self.fanTimerLevel3()
elif self.RPM >= 4000 and self.RPM < 5000:
self.fanTimerLevel4()
else:
if self.RPM >= 5000:
if self.RPM < 6000:
self.fanTimerLevel5()
else:
self.fanTimerLevel6()
self.update()
def OpenGetRPMTimer(self):
if self.getRPMTimer.isActive():
self.getRPMTimer.stop()
self.getRPMTimer.start()
def fanTimerOut(self):
if self.fanAngle == 360:
self.fanAngle = 0
self.fanAngle += 1
self.update()
def fanTimerStop(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
def fanTimerLevel1(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(9)
self.fanTimer.start()
def fanTimerLevel2(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(8)
self.fanTimer.start()
def fanTimerLevel3(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(7)
self.fanTimer.start()
def fanTimerLevel4(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(6)
self.fanTimer.start()
def fanTimerLevel5(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(5)
self.fanTimer.start()
def fanTimerLevel6(self):
if self.fanTimer.isActive():
self.fanTimer.stop()
self.fanTimer.setInterval(4)
self.fanTimer.start()
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
side = min(self.width(), self.height())
painter.translate(self.width() / 2, self.height() / 2)
painter.scale(side / 400, side / 400)
self.drawCircle(painter)
self.drawpolygon1(painter)
self.drawTitle(painter)
def drawCircle(self, painter):
painter.save()
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#696969"))
radius1 = 140
painter.drawEllipse(-radius1, -radius1, radius1 * 2, radius1 * 2)
radius2 = 132
painter.setBrush(QColor("#000000"))
painter.drawEllipse(-radius2, -radius2, radius2 * 2, radius2 * 2)
radius3 = 78
painter.setBrush(QColor("#232323"))
painter.drawEllipse(-radius3, -radius3, radius3 * 2, radius3 * 2)
painter.restore()
def drawpolygon(self, painter):
painter.rotate(self.fanAngle)
painter.save()
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#00acc7"))
points = QPolygon([
QPoint(5, -190),
QPoint(30, -190),
QPoint(20, -139),
QPoint(0, -140)])
painter.drawPolygon(points)
for i in range(17):
painter.rotate(20)
painter.drawPolygon(points)
painter.restore()
def drawpolygon1(self, painter):
painter.rotate(self.fanAngle)
painter.setPen(Qt.NoPen)
painter.setBrush(QColor("#41aa94"))
painter.save()
path = QPainterPath()
path.moveTo(0, -140)
path.lineTo(20, -139)
path.cubicTo(19, -160, 26, -175, 35, -185)
path.lineTo(10, -185)
path.cubicTo(3, -170, 1, -150, 0, -140)
painter.drawPath(path)
for i in range(17):
painter.rotate(20)
painter.drawPath(path)
painter.restore()
def drawTitle(self, p):
p.save()
p.rotate(-self.fanAngle)
p.setPen(Qt.white)
font = QFont("Microsoft YaHei", 20)
p.setFont(font)
fm = QFontMetrics(p.font())
w = fm.size(Qt.TextSingleLine, str(self.RPM)).width()
p.drawText(int(-w / 2), -2, str(self.RPM))
p.setPen(QColor(97, 105, 111))
fm = QFontMetrics(p.font())
w = fm.size(Qt.TextSingleLine, self.RPMStr).width()
p.drawText(int(-w / 2), 50, self.RPMStr)
p.restore()
def fan2process(self, q):
process2 = multiprocessing.Process(target=updaterfan2, args=(q,))
process2.daemon = True
process2.start()
def updaterfan2(fan2q):
while True:
a, b = GetFanRPM()
fan2q.put(b)
print("风扇2的转速为:", b)
time.sleep(1.5)
StyleSheet = "\n/*标题栏*/\nTitleBar {\n background-color: #12171e;\n}\n#titleLabel{color:#e7e4e4;}\n/*最小化最大化关闭按钮通用默认背景*/\n#buttonMinimum,#buttonClose {\n border: none;\n background-color: #12171e;\n color:#60636e;\n}\n/*悬停*/\n#buttonMinimum:hover {\n color: black;\n background-color:#4b4b54\n}\n#buttonClose:hover {\n background-color:#6a3432\n}\n/*鼠标按下不放*/\n#buttonMinimum:pressed {\n color:white;\n background-color: #55555c;\n}\n#buttonClose:pressed {\n color: white;\n background-color: Firebrick;\n}\n"
class MeunBar(QMenuBar):
def __init__(self, parent):
super(MeunBar, self).__init__(parent)
self.win = parent
self.InitializeWindow()
def InitializeWindow(self):
self.isPressed = False
return
import ftpDownloadProcessbar
class BiosInfoThread(QThread):
trigger = pyqtSignal(list)
def __int__(self):
super(BiosInfoThread, self).__init__()
def run(self):
try:
biosinfo = ftp_read_bios_version()
self.trigger.emit(biosinfo)
except:
return
def test_internet():
try:
http = urllib3.PoolManager()
http.request("GET", "https://baidu.com")
return True
except:
return False
def ftpconnect(host, username, password):
ftp = FTP()
timeout = 2
port = 2300
ftp.connect(host, port, timeout)
ftp.login(username, password)
return ftp
def downloadfile(ftp, remotepath, localpath):
ftp.cwd(remotepath)
list = ftp.nlst()
bufsize = 1024
try:
list.remove(".")
list.remove("..")
except:
print("移除值不在列表内")
for name in list:
file_size = ftp.size(name)
print("1111111", name)
path = localpath + name
print(path)
filename = "RETR " + name
try:
with open(path, "wb") as f:
ftp.retrbinary(filename, f.write, bufsize)
f.close()
except Exception as err:
print("Download file error :{}".format(err))
ftp.set_debuglevel(0)
def get_last_version_info(remotepath='/APP/BoxAPP/client1/lastest_release'):
try:
ftp = FTP()
timeout = 2
port = 2300
ftp.connect("116.236.154.218", port, timeout)
ftp.login("gmcnt", "7PP3jRARfsH7A8y8")
ftp.cwd(remotepath)
list = ftp.nlst()
list.remove(".")
list.remove("..")
if list:
package_name = list[0]
char1 = "Setup"
char2 = ".exe"
nPos1 = package_name.find(char1) + 5
nPos2 = package_name.find(char2)
last_version = package_name[nPos1:nPos2]
return last_version
ftp.close()
return ""
except:
return ""
def get_all_bios_info(remotepath='/APP/BoxAPP/client1/bios_lastest_release'):
try:
ftp = FTP()
timeout = 2
port = 2300
ftp.connect("116.236.154.218", port, timeout)
ftp.login("gmcnt", "7PP3jRARfsH7A8y8")
ftp.cwd(remotepath)
listdir = ftp.nlst()
listdir.remove(".")
listdir.remove("..")
if listdir:
return listdir
ftp.close()
return ""
except:
return ""
def get_all_OSD_info(remotepath='/OSD/OSDSetup/OSD_Release'):
try:
ftp = FTP()
timeout = 2
port = 2300
ftp.connect("116.236.154.218", port, timeout)
ftp.login("gmcnt", "7PP3jRARfsH7A8y8")
ftp.cwd(remotepath)
listdir = ftp.nlst()
listdir.remove(".")
listdir.remove("..")
print(listdir)
if listdir:
return listdir
ftp.close()
return ""
except:
return ""
class FTPProcess(Process):
def __init__(self):
super(FTPProcess, self).__init__()
def run(self):
print("测试11111111多进程")
ftp_connect_download()
def start_installAPP():
os.startfile(ftpDownloadProcessbar.Last_APP_Location)
time.sleep(0.01)
os.startfile("killControCenter.exe")
def ftp_connect_download(remote_path):
ftpDownloadProcessbar.download_ftp("C:/Program Files/", remote_path)
start_installAPP()
def ftp_connect_download_bios(remote_path, file_name):
ftpDownloadProcessbar.download_ftp_bios("C:/Program Files/", remote_path, file_name)
time.sleep(0.01)
os.startfile(ftpDownloadProcessbar.Last_APP_Location)
def ftp_connect_download_osd(remote_path, file_name):
ftpDownloadProcessbar.download_ftp_osd("C:/Program Files/", remote_path, file_name)
time.sleep(0.01)
os.startfile(ftpDownloadProcessbar.Last_APP_Location)
def ftp_connect_download_Bios(remote_path):
ftpDownloadProcessbar.download_ftp_bios("C:/Program Files/", remote_path)
time.sleep(0.01)
os.startfile(ftpDownloadProcessbar.Last_APP_Location)
class TitleBar(QWidget):
windowMinimumed = pyqtSignal()
windowClosed = pyqtSignal()
windowMoved = pyqtSignal(QPoint)
def __init__(self, *args, **kwargs):
(super(TitleBar, self).__init__)(*args, **kwargs)
self.setAttribute(Qt.WA_StyledBackground, True)
self.mPos = None
self.setAutoFillBackground(True)
palette = self.palette()
palette.setColor(palette.Window, QColor(240, 240, 240))
self.setPalette(palette)
layout = QHBoxLayout(self, spacing=0)
layout.setContentsMargins(0, 0, 0, 0)
self.iconLabel = QLabel(self)
self.iconLabel.setPixmap(QPixmap("./imgs/TitleBack.png"))
self.iconLabel.setScaledContents(True)
toolbtnsize = QtCore.QSize(int(ui_sY / 2), int(ui_sY / 17))
self.iconLabel.setFixedSize(toolbtnsize)
self.iconLabel.setScaledContents(True)
layout.addSpacing(80)
layout.addWidget((self.iconLabel), 1, alignment=(Qt.AlignHCenter))
font21 = self.font()
pointsize1 = int(ui_sY / 43)
font21.setPixelSize(pointsize1)
font21.setFamily("Webdings")
font9 = self.font()
pointsize1 = int(ui_sY / 35)
font9.setPixelSize(pointsize1)
font90 = self.font()
pointsize1 = int(ui_sY / 38)
font90.setPixelSize(pointsize1)
self.menubar = QMenuBar(self)
radius = 9
self.menubar.setStyleSheet(" QMenuBar {{ background-color:#12171e;color:#60636e; /*整个背景*/ }} QMenuBar::item:selected {{ background-color:#4b4b54;/*选中的样式*/ }} QMenu {{ background-color:#12171e; /*整个背景*/ }} QMenu::item {{ font-size: {0}pt;font-family:Microsoft YaHei;color: rgb(225,225,225); /*字体颜色*/ border: 2px solid rgb(60,60,60);height:2em; width:5.5em; /*item选框*/ background-color:#12171e; padding:2px 2px ; /*设置菜单项文字上下和左右的内边距,效果就是菜单中的条目左右上下有了间隔*/ /*设置菜单项的外边距*/ }} QMenu::item:selected {{ background-color:#1a806a;/*选中的样式*/ }} QMenu::item:pressed {{/*菜单项按下效果*/ border: 2px solid rgb(60,60,61); background-color: #24917a; }}\\ ".format(radius))
self.menubar.setFont(QFont(font9))
self.mainbar = self.menubar.addMenu("≡")
self.language = QAction("English", self)
self.mainbar.addAction(self.language)
self.helpinfo = QAction("关于", self)
self.mainbar.addAction(self.helpinfo)
layout.addWidget((self.menubar), alignment=(Qt.AlignCenter))
self.buttonMinimum = QPushButton("0", self, clicked=(self.windowMinimumed.emit), font=font21, objectName="buttonMinimum")
layout.addWidget(self.buttonMinimum)
self.buttonClose = QPushButton("r", self, clicked=(self.windowClosed.emit), font=font21, objectName="buttonClose")
layout.addWidget(self.buttonClose)
self.trans = QTranslator()
addo = int(ui_sY / 17)
self.setHeight(addo)
def setHeight(self, height):
"""设置标题栏高度"""
self.setMinimumHeight(height)
self.setMaximumHeight(height)
self.buttonMinimum.setMinimumSize(height, height)
self.buttonMinimum.setMaximumSize(height, height)
self.buttonClose.setMinimumSize(height, height)
self.buttonClose.setMaximumSize(height, height)
def enterEvent(self, event):
self.setCursor(Qt.ArrowCursor)
super(TitleBar, self).enterEvent(event)
def mousePressEvent(self, event):
"""鼠标点击事件"""
if event.button() == Qt.LeftButton:
self.mPos = event.pos()
event.accept()
def mouseReleaseEvent(self, event):
"""鼠标弹起事件"""
self.mPos = None
event.accept()
def mouseMoveEvent(self, event):
if event.buttons() == Qt.LeftButton:
if self.mPos:
self.windowMoved.emit(self.mapToGlobal(event.pos() - self.mPos))
event.accept()
Left, Top, Right, Bottom, LeftTop, RightTop, LeftBottom, RightBottom = range(8)
class FramelessWindow(QWidget):
Margins = 5
def __init__(self, *args, **kwargs):
(super(FramelessWindow, self).__init__)(*args, **kwargs)
self._pressed = False
self.Direction = None
self.setAttribute(Qt.WA_TranslucentBackground, True)
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowMinimizeButtonHint)
self.setMouseTracking(True)
layout = QVBoxLayout(self, spacing=0)
layout.setContentsMargins(self.Margins, self.Margins, self.Margins, self.Margins)
self.titleBar = TitleBar(self)
layout.addWidget(self.titleBar)
self.SwithFalg_CN = True
self.currentVersion = "1.1"
self.Version = "1.1"
self.network_manager = QNetworkConfigurationManager()
self.titleBar.language.triggered.connect(self.en_cn_translate_btnClicked)
self.titleBar.helpinfo.triggered.connect(self.helpinfotrigger)
self.titleBar.windowMinimumed.connect(self.showMinimized)
self.titleBar.windowClosed.connect(self.close)
self.titleBar.windowMoved.connect(self.move)
self.setFocusPolicy(Qt.ClickFocus)
def closeEvent(self, QCloseEvent):
try:
self._widget.Fan1Obj.process1.terminate()
self._widget.Fan1Obj.process1.join()
if self._widget.supportFanNum == 2:
if self._widget.supportGPU == 1:
self._widget.Fan2Obj.process2.terminate()
self._widget.Fan2Obj.process2.join()
self._widget.form2_Fan1Obj.process1.terminate()
self._widget.form2_Fan1Obj.process1.join()
if self._widget.supportFanNum == 2:
if self._widget.supportGPU == 1:
self._widget.form2_Fan2Obj.process2.terminate()
self._widget.form2_Fan2Obj.process2.join()
except:
pass
super(FramelessWindow, self).closeEvent(QCloseEvent)
def isupdatetrigger(self):
if not test_internet():
if self.SwithFalg_CN == True:
msgBox = QMessageBox()
msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = msgBox.addButton("退出", QMessageBox.AcceptRole)
okButton = msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
msgBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
msgBox.setWindowTitle("网络")
msgBox.setText("网络异常: 网络连接已断开!")
msgBox.exec()
return
else:
msgBox = QMessageBox()
msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = msgBox.addButton("Exit", QMessageBox.AcceptRole)
okButton = msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
msgBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
msgBox.setWindowTitle("network")
msgBox.setText("The network connection has been lost!")
msgBox.exec()
return
else:
last_version = get_last_version_info()
if not last_version:
return
else:
if self.SwithFalg_CN == True:
if last_version != self.currentVersion:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前软件版本为: " + self.currentVersion + ", 最新版本是: " + last_version + ", 请确认是否更新\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("更新", QMessageBox.YesRole)
Qno = messageBox.addButton("取消", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
if messageBox.clickedButton() == Qyes:
processftp1 = multiprocessing.Process(target=ftp_connect_download, args=('/APP/BoxAPP/client1/lastest_release', ))
processftp1.start()
else:
return
else:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前版本为最新版本,无需更新!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("确认", QMessageBox.YesRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
messageBox.exec_()
return
elif last_version != self.currentVersion:
reply = QMessageBox(QMessageBox.Information, "Tips", "\nThe current version is " + self.currentVersion + ", The latest version is: " + last_version + ",\n\n Please check whether it is updated\n")
reply.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
reply.setIcon(QMessageBox.NoIcon)
reply.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = reply.addButton("Update", QMessageBox.YesRole)
Qno = reply.addButton("Cancel", QMessageBox.NoRole)
okButton = reply.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
reply.exec_()
if reply.clickedButton() == Qyes:
processftp1 = multiprocessing.Process(target=ftp_connect_download, args=('/APP/BoxAPP/client1/lastest_release', ))
processftp1.start()
else:
return
else:
reply = QMessageBox(QMessageBox.Information, "Tips", "\nThe current version is the latest version, no update required!\n")
reply.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
reply.setIcon(QMessageBox.NoIcon)
reply.setStyleSheet("QMessageBox QLabel{font-size: 12px;}")
Qyes = reply.addButton("Exit", QMessageBox.YesRole)
okButton = reply.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
reply.exec_()
return
def helpinfotrigger(self):
if self.SwithFalg_CN == True:
self.msgBox = QMessageBox()
self.msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = self.msgBox.addButton("退出", QMessageBox.AcceptRole)
okButton = self.msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 13px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
self.msgBox.setStyleSheet("QMessageBox QLabel{font-size: 15px;font-family:Microsoft YaHei;}")
self.msgBox.move(self.frameGeometry().center())
self.msgBox.setWindowTitle("关于")
self.msgBox.setText("版本: " + self.Version + "\n时间:2024.04.07 ")
self.msgBox.exec()
else:
self.msgBox1 = QMessageBox()
self.msgBox1.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = self.msgBox1.addButton("Exit", QMessageBox.AcceptRole)
okButton = self.msgBox1.buttons()
for button in okButton:
button.setStyleSheet("font-size: 13px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
self.msgBox1.setStyleSheet("QMessageBox QLabel{font-size: 15px;font-family:Microsoft YaHei;}")
self.msgBox1.move(self.frameGeometry().center())
self.msgBox1.setWindowTitle("About")
self.msgBox1.setText("Version : " + self.Version + "\nTime:2024.04.07")
self.msgBox1.exec()
def en_cn_translate_btnClicked(self):
if self.SwithFalg_CN == True:
self.titleBar.trans.load("en")
app = QApplication.instance()
app.installTranslator(self.titleBar.trans)
self.titleBar.language.setText("中文")
self.titleBar.helpinfo.setText("About")
self.retranslateUi(self)
self.SwithFalg_CN = False
else:
self.titleBar.trans.load("zn_CN")
app = QApplication.instance()
app.installTranslator(self.titleBar.trans)
self.titleBar.language.setText("English")
self.titleBar.helpinfo.setText("关于")
self.retranslateUi(self)
self.SwithFalg_CN = True
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
if self.SwithFalg_CN == True:
self._widget.setFont(QFont("Times New Roman"))
else:
self._widget.setFont(QFont("Microsoft YaHei"))
self._widget.setFont(QFont("Times New Roman"))
self._widget.recommend_button_1.setText(_translate("centerWidget", "模式设置"))
self._widget.recommend_button_2.setText(_translate("centerWidget", "风扇控制"))
self._widget.recommend_button_4.setText(_translate("centerWidget", "功能设定"))
self._widget.recommend_button_5.setText(_translate("centerWidget", "常规信息"))
if self._widget.ModeNum == 1:
self._widget.ModebtnSilence.setText(_translate("centerWidget", "安静模式"))
elif self._widget.ModeNum == 2:
self._widget.ModebtnSilence.setText(_translate("centerWidget", "安静模式"))
self._widget.ModebtnPerfermence.setText(_translate("centerWidget", "均衡模式"))
else:
if self._widget.ModeNum == 3:
self._widget.ModebtnSilence.setText(_translate("centerWidget", "安静模式"))
self._widget.ModebtnBalance.setText(_translate("centerWidget", "均衡模式"))
self._widget.ModebtnPerfermence.setText(_translate("centerWidget", "性能模式"))
self._widget.CPUTemperLabel.setText(_translate("centerWidget", "CPU温度"))
self._widget.memoryLabel.setText(_translate("centerWidget", "内存使用率"))
self._widget.CPUPerLabel.setText(_translate("centerWidget", "磁盘使用率"))
self._widget.FanLabel.setText(_translate("centerWidget", "风扇转速"))
self._widget.form2_LabelTip.setText(_translate("centerWidget", "风扇转速"))
self._widget.LabelOSDTip.setText(_translate("centerWidget", "热键图标提示"))
self._widget.OSDSwitchLabel.setText(_translate("centerWidget", " 打开功能,按下热键,会提示功能图标;关闭功能,按下热键,不会提示功能图标。"))
self._widget.form2_btn1.setText(_translate("centerWidget", "自动"))
self._widget.form2_btn2.setText(_translate("centerWidget", "自定义"))
self._widget.form2_btn4.setText(_translate("centerWidget", "最大"))
self._widget.labelInfo1_0.setText(_translate("centerWidget", "系统"))
self._widget.labelInfo4_0.setText(_translate("centerWidget", "处理器"))
self._widget.labelInfo5_0.setText(_translate("centerWidget", "主板"))
self._widget.labelInfo6_0.setText(_translate("centerWidget", "BIOS版本/日期"))
self._widget.labelInfo8_0.setText(_translate("centerWidget", "显示器"))
self._widget.biosbtn.setText(_translate("centerWidget", "BIOS 更新"))
self._widget.labelInfo10_0.setText(_translate("centerWidget", "OSD版本"))
self._widget.osd_update_btn.setText(_translate("centerWidget", "OSD 更新"))
self._widget.labelInfo11_0.setText(_translate("centerWidget", "磁盘信息"))
self._widget.labelInfo12_0.setText(_translate("centerWidget", "内存信息"))
if self.SwithFalg_CN == True:
res = GetPowerMode()
if res == 1:
self._widget.switchLabel.setPixmap(QPixmap("./imgs/PerformenceModeEnglish.png"))
elif res == 2:
self._widget.switchLabel.setPixmap(QPixmap("./imgs/SilenceModeEnglish.png"))
elif res == 0:
self._widget.switchLabel.setPixmap(QPixmap("./imgs/BalanceModeEnglish.png"))
else:
res = GetPowerMode()
if res == 1:
self._widget.switchLabel.setPixmap(QPixmap("./imgs/PerformenceMode.png"))
elif res == 2:
self._widget.switchLabel.setPixmap(QPixmap("./imgs/SilenceMode.png"))
elif res == 0:
self._widget.switchLabel.setPixmap(QPixmap("./imgs/BalanceMode.png"))
def setWidget(self, widget):
"""设置自己的控件"""
if hasattr(self, "_widget"):
return
self._widget = widget
self._widget.setAutoFillBackground(True)
palette = self._widget.palette()
palette.setColor(palette.Window, QColor(240, 240, 240))
self._widget.setPalette(palette)
self._widget.installEventFilter(self)
self.layout().addWidget(self._widget)
def move(self, pos):
if self.windowState() == Qt.WindowMaximized or self.windowState() == Qt.WindowFullScreen:
return
super(FramelessWindow, self).move(pos)
def eventFilter(self, obj, event):
"""事件过滤器,用于解决鼠标进入其它控件后还原为标准鼠标样式"""
if isinstance(event, QEnterEvent):
self.setCursor(Qt.ArrowCursor)
self.Direction = None
self._pressed = None
return super(FramelessWindow, self).eventFilter(obj, event)
def paintEvent(self, event):
"""由于是全透明背景窗口,重绘事件中绘制透明度为1的难以发现的边框,用于调整窗口大小"""
super(FramelessWindow, self).paintEvent(event)
painter = QPainter(self)
painter.setPen(QPen(QColor(255, 255, 255, 1), 2 * self.Margins))
painter.drawRect(self.rect())
def mousePressEvent(self, event):
"""鼠标点击事件"""
super(FramelessWindow, self).mousePressEvent(event)
if event.button() == Qt.LeftButton:
self._mpos = event.pos()
self._pressed = True
def mouseReleaseEvent(self, event):
"""鼠标弹起事件"""
super(FramelessWindow, self).mouseReleaseEvent(event)
self._pressed = False
self.Direction = None
def mouseMoveEvent(self, event):
"""鼠标移动事件"""
super(FramelessWindow, self).mouseMoveEvent(event)
pos = event.pos()
xPos, yPos = pos.x(), pos.y()
wm, hm = self.width() - self.Margins, self.height() - self.Margins
if self.isMaximized() or self.isFullScreen():
self.Direction = None
self.setCursor(Qt.ArrowCursor)
return
if event.buttons() == Qt.LeftButton:
if self._pressed:
self._resizeWidget(pos)
return
if xPos <= self.Margins:
if yPos <= self.Margins:
self.Direction = LeftTop
self.setCursor(Qt.SizeFDiagCursor)
if wm <= xPos <= self.width() and hm <= yPos <= self.height():
self.Direction = RightBottom
self.setCursor(Qt.SizeFDiagCursor)
else:
if wm <= xPos:
if yPos <= self.Margins:
self.Direction = RightTop
self.setCursor(Qt.SizeBDiagCursor)
if xPos <= self.Margins:
if hm <= yPos:
self.Direction = LeftBottom
self.setCursor(Qt.SizeBDiagCursor)
if 0 <= xPos <= self.Margins:
pass
if self.Margins <= yPos <= hm:
self.Direction = Left
self.setCursor(Qt.SizeHorCursor)
elif wm <= xPos <= self.width():
if self.Margins <= yPos <= hm:
self.Direction = Right
self.setCursor(Qt.SizeHorCursor)
if self.Margins <= xPos <= wm and 0 <= yPos <= self.Margins:
self.Direction = Top
self.setCursor(Qt.SizeVerCursor)
elif self.Margins <= xPos <= wm:
if hm <= yPos <= self.height():
self.Direction = Bottom
self.setCursor(Qt.SizeVerCursor)
def _resizeWidget(self, pos):
"""调整窗口大小"""
if self.Direction == None:
return
mpos = pos - self._mpos
xPos, yPos = mpos.x(), mpos.y()
geometry = self.geometry()
x, y, w, h = (geometry.x(), geometry.y(), geometry.width(), geometry.height())
if self.Direction == LeftTop:
if w - xPos > self.minimumWidth():
x += xPos
w -= xPos
if h - yPos > self.minimumHeight():
y += yPos
h -= yPos
elif self.Direction == RightBottom:
if w + xPos > self.minimumWidth():
w += xPos
self._mpos = pos
if h + yPos > self.minimumHeight():
h += yPos
self._mpos = pos
elif self.Direction == RightTop:
if h - yPos > self.minimumHeight():
y += yPos
h -= yPos
if w + xPos > self.minimumWidth():
w += xPos
self._mpos.setX(pos.x())
else:
if self.Direction == LeftBottom:
if w - xPos > self.minimumWidth():
x += xPos
w -= xPos
if h + yPos > self.minimumHeight():
h += yPos
self._mpos.setY(pos.y())
elif self.Direction == Left:
if w - xPos > self.minimumWidth():
x += xPos
w -= xPos
else:
return
elif self.Direction == Right:
if w + xPos > self.minimumWidth():
w += xPos
self._mpos = pos
else:
return
elif self.Direction == Top:
pass
if h - yPos > self.minimumHeight():
y += yPos
h -= yPos
else:
return
else:
if self.Direction == Bottom:
if h + yPos > self.minimumHeight():
h += yPos
self._mpos = pos
else:
return
self.setGeometry(x, y, w, h)
def GetPowerMode():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetPowerMode")
return objOutParams.CurrentPowerMode
except:
print("888888888888888888888888")
print("获取电源模式失败,可能是设备不支持")
def GetHWTemperture():
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "GetPowerMode")
return objOutParams.CurrentHWTemperture
except:
print("获取设备温度失败,可能是设备不支持")
def SetPowerMode(par):
try:
objWMIService = GetObject("winmgmts:/root/WMI")
objshare = objWMIService.Get("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'")
objInParam = objshare.Methods_("SetPowerMode").inParameters.SpawnInstance_()
objInParam.PowerMode = par
objOutParams = objWMIService.ExecMethod("PowerSwitchInterface.InstanceName='ACPI\\PNP0C14\\IP3POWERSWITCH_0'", "SetPowerMode", objInParam)
return objOutParams.ResultStatus
except:
print("777777777777777777777777")
print("设置电源模式不成功,可能是设备不支持")
class MainWindow(QWidget):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
layout = QHBoxLayout(self, spacing=0)
layout.setContentsMargins(0, 0, 0, 0)
self.setAttribute(Qt.WA_StyledBackground, True)
self.setObjectName("centerWidget")
self.setStyleSheet("#centerWidget{border-image:url(./imgs/back2.png);}")
self.left_widget = QtWidgets.QWidget(self)
self.left_widget.setObjectName("left_widget")
self.left_layout = QtWidgets.QVBoxLayout(self)
self.left_widget.setLayout(self.left_layout)
self.right_stacked_Widget = QStackedWidget(self)
self.right_stacked_Widget.setObjectName("right_stacked_Widget")
layout.addWidget(self.left_widget)
layout.addWidget(self.right_stacked_Widget)
layout.setSpacing(0)
layout.setStretch(0, 2)
layout.setStretch(1, 16)
self.left_widget.setStyleSheet("\n QToolButton{border:none;color:rgb(230,230,230);}\n \n QToolButton:hover{font-weight:500;color:rgb(240,240,240)}\n QToolButton:pressed{\n padding-left:3px;\n padding-top:3px;\n \n }\n \\#left_widget{border-image:url(./imgs/leftpng2.png);margin-top:15px;margin-bottom:15px;margin-left:15px;margin-right:15px;border:2px solid black;}\n #left_widget{border-image:url(./imgs/leftpng2.png);margin-top:15pt;margin-bottom:15pt;margin-right:15pt;margin-left:15pt;border:2px solid black;}\n \\#left_widget{border-image:url(./imgs/leftpng2.png);margin-top:10pt;margin-bottom:10pt;margin-right:10pt;margin-left:10pt;border:2px solid black;}\n \\#left_widget{border-image:url(./imgs/leftpng2.png);margin-top:0.1px;margin-bottom:0.1px;margin-right:15px;margin-left:15px;border:2px solid black;}\n ")
font2 = self.font()
pointsize1 = min(int(ui_sX / 35), int(ui_sY / 35))
font2.setPixelSize(pointsize1)
self.recommend_button_1 = QtWidgets.QToolButton(self)
toolbtnsize = QtCore.QSize(int(ui_sX / 8.7), int(ui_sY / 8.7))
self.recommend_button_1.setText("模式设置")
self.recommend_button_1.setFont(QFont(font2))
self.recommend_button_1.setIcon(QtGui.QIcon("./imgs/Modegray.png"))
self.recommend_button_1.setIconSize(toolbtnsize)
self.recommend_button_1.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.left_layout.addWidget((self.recommend_button_1), alignment=(Qt.AlignCenter))
self.recommend_button_2 = QtWidgets.QToolButton(self)
self.recommend_button_2.setText("风扇控制")
self.recommend_button_2.setFont(QFont(font2))
self.recommend_button_2.setIcon(QtGui.QIcon("./imgs/Fangray.png"))
self.recommend_button_2.setIconSize(toolbtnsize)
self.recommend_button_2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.left_layout.addWidget((self.recommend_button_2), alignment=(Qt.AlignCenter))
self.recommend_button_4 = QtWidgets.QToolButton(self)
self.recommend_button_4.setText("功能设定")
self.recommend_button_4.setFont(QFont(font2))
self.recommend_button_4.setIcon(QtGui.QIcon("./imgs/Regulargray.png"))
self.recommend_button_4.setIconSize(toolbtnsize)
self.recommend_button_4.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.left_layout.addWidget((self.recommend_button_4), alignment=(Qt.AlignCenter))
self.recommend_button_5 = QtWidgets.QToolButton(self)
self.recommend_button_5.setText("常规信息")
self.recommend_button_5.setFont(QFont(font2))
self.recommend_button_5.setIcon(QtGui.QIcon("./imgs/SysInfogray.png"))
self.recommend_button_5.setIconSize(toolbtnsize)
self.recommend_button_5.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.left_layout.addWidget((self.recommend_button_5), alignment=(Qt.AlignCenter))
self.recommend_button_1.setIcon(QtGui.QIcon("./imgs/Mode.png"))
self.recommend_button_1.setStyleSheet("color:#41aa94")
self.form1 = QWidget(self)
self.right_stacked_Widget.addWidget(self.form1)
self.formLayout1 = QtWidgets.QHBoxLayout(self.form1)
self.recommend_button_1.clicked.connect(self.left_button1_clicked)
self.form2 = QWidget(self)
self.right_stacked_Widget.addWidget(self.form2)
self.formLayout2 = QtWidgets.QVBoxLayout(self.form2)
self.recommend_button_2.clicked.connect(self.left_button2_clicked)
self.form4 = QWidget(self)
self.right_stacked_Widget.addWidget(self.form4)
self.formLayout4 = QtWidgets.QVBoxLayout(self.form4)
self.recommend_button_4.clicked.connect(self.left_button4_clicked)
self.form5 = QWidget(self)
self.right_stacked_Widget.addWidget(self.form5)
self.formLayout5 = QtWidgets.QVBoxLayout(self.form5)
self.recommend_button_5.clicked.connect(self.left_button5_clicked)
self.ModeLayoutLeft = QHBoxLayout(self)
self.ModeWidgetLeft = QWidget(self)
self.ModeWidgetLeft.setLayout(self.ModeLayoutLeft)
radius = int(ui_sY / 23)
self.ModeStyleSheetInit = " QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1,\n stop: 0 rgba(100,100,100,255),\n stop: 0.495 rgba(40,40,40,255),\n stop: 1 rgba(39,39,39,255));color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #41aa94;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #41aa94}}\n ".format(radius)
self.ModeStyleSheetClicked = "QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(120,120,120,255),\n stop: 0.495 rgba(39,39,39,255),\n stop: 0.505 rgba(39,39,39,255), \n stop: 0.8 #1b7b69,\n stop: 1 #41aa94);color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #41aa94;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #41aa94}}\n ".format(radius)
self.ModeStyleSheetInit1 = " QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(100,100,100,255),\n stop: 0.495 rgba(40,40,40,255),\n stop: 1 rgba(39,39,39,255));color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #87ceeb;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #87ceeb}}".format(radius)
self.ModeStyleSheetClicked1 = "QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(120,120,120,255),\n stop: 0.495 rgba(39,39,39,255),\n stop: 0.505 rgba(39,39,39,255), \n stop: 0.8 #87ceeb,\n stop: 1 #87ceeb);color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #87ceeb;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #87ceeb}}".format(radius)
self.ModeStyleSheetInit2 = " QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(100,100,100,255),\n stop: 0.495 rgba(40,40,40,255),\n stop: 1 rgba(39,39,39,255));color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #b52626;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #b52626}}".format(radius)
self.ModeStyleSheetClicked2 = "QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(120,120,120,255),\n stop: 0.495 rgba(39,39,39,255),\n stop: 0.505 rgba(39,39,39,255), \n stop: 0.8 #b52626,\n stop: 1 #b52626);color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #b52626;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #b52626}}".format(radius)
self.ModeStyleSheetInit3 = " QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(100,100,100,255),\n stop: 0.495 rgba(40,40,40,255),\n stop: 1 rgba(39,39,39,255));color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #ec18ff;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #ec18ff}}".format(radius)
self.ModeStyleSheetClicked3 = "QPushButton{{background-color: qlineargradient(spread:pad, x1:0, x2:0, y1:0, y2:1, \n stop: 0 rgba(120,120,120,255),\n stop: 0.495 rgba(39,39,39,255),\n stop: 0.505 rgba(39,39,39,255), \n stop: 0.8 #ec18ff,\n stop: 1 #ec18ff);color:rgb(200,200,200);border-radius:{0}px;}}\n QPushButton:hover{{font-weight:300;border:2px solid #ec18ff;}}\n QPushButton:pressed{{\n padding-left:3px;\n padding-top:3px;\n border:3px solid #ec18ff}}".format(radius)
form1_VLeft_Layout = QVBoxLayout(self)
form1_VLeft_Widget = QWidget(self)
form1_VLeft_Widget.setLayout(form1_VLeft_Layout)
font4 = self.font()
pointsize1 = int(ui_sY / 27)
font4.setPixelSize(pointsize1)
font7 = self.font()
pointsize2 = int(ui_sY / 32)
font7.setPixelSize(pointsize2)
self.ModeNum = GetModeNum()
print("设备当前可以读取几种模式?", self.ModeNum)
if self.ModeNum == -1:
self.ModeNum = 3
elif self.ModeNum == 1:
self.ModebtnSilence = QPushButton("安静模式", self)
self.ModebtnSilence.setFont(QFont(font7))
self.ModebtnSilence.setFixedSize(int(ui_sY / 3.5), int(ui_sY / 10))
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnSilence.clicked.connect(self.ModebtnSilenceClicked)
self.ModeLayoutLeft.addWidget(self.ModebtnSilence, 1)
form1_VLeft_Layout.addWidget(self.ModeWidgetLeft, 2)
elif self.ModeNum == 2:
self.ModebtnSilence = QPushButton("安静模式", self)
self.ModebtnSilence.setFont(QFont(font7))
self.ModebtnSilence.setFixedSize(int(ui_sY / 2.2), int(ui_sY / 9.5))
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnSilence.clicked.connect(self.ModebtnSilenceClicked)
self.ModebtnPerfermence = QPushButton("均衡模式", self)
self.ModebtnPerfermence.setFont(QFont(font7))
self.ModebtnPerfermence.setFixedSize(int(ui_sY / 2.2), int(ui_sY / 9.5))
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.ModebtnPerfermence.clicked.connect(self.ModebtnPerfermenceClicked)
self.ModeLayoutLeft.addWidget(self.ModebtnSilence, 1)
self.ModeLayoutLeft.setSpacing(int(ui_sY / 38))
self.ModeLayoutLeft.addWidget(self.ModebtnPerfermence, 1)
form1_VLeft_Layout.addWidget(self.ModeWidgetLeft, 2)
else:
if self.ModeNum == 3:
print("ModeNum", self.ModeNum)
self.ModebtnSilence = QPushButton("安静模式", self)
self.ModebtnSilence.setFont(QFont(font7))
self.ModebtnSilence.setFixedSize(int(ui_sY / 3.3), int(ui_sY / 15))
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnSilence.clicked.connect(self.ModebtnSilenceClicked)
print("ModebtnBalance---111111111111111111111111")
self.ModebtnBalance = QPushButton("均衡模式", self)
self.ModebtnBalance.setFont(QFont(font7))
self.ModebtnBalance.setFixedSize(int(ui_sY / 3.3), int(ui_sY / 15))
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnBalance.clicked.connect(self.ModebtnBalanceClicked)
print("ModebtnBalance---111111111111111111111111")
self.ModebtnPerfermence = QPushButton("性能模式", self)
self.ModebtnPerfermence.setFont(QFont(font7))
self.ModebtnPerfermence.setFixedSize(int(ui_sY / 3.3), int(ui_sY / 15))
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.ModebtnPerfermence.clicked.connect(self.ModebtnPerfermenceClicked)
self.ModeLayoutLeft.addWidget(self.ModebtnSilence, 1)
self.ModeLayoutLeft.addWidget(self.ModebtnBalance, 1)
self.ModeLayoutLeft.addWidget(self.ModebtnPerfermence, 1)
form1_VLeft_Layout.addWidget(self.ModeWidgetLeft, 2)
else:
self.switchLabel = QLabel(self)
self.pixmap1 = QtGui.QPixmap("./imgs/SilenceMode.png")
self.switchLabel.setPixmap(self.pixmap1)
self.switchLabel.setFixedSize(int(ui_sY / 1.6), int(ui_sY / 1.6))
self.switchLabel.setScaledContents(True)
form1_VLeft_Layout.addWidget((self.switchLabel), 2, alignment=(Qt.AlignHCenter))
self.FanLabel = QLabel("风扇转速", self)
self.FanLabel.setFont(QFont(font4))
self.FanLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 13))
self.FanLabel.setStyleSheet("color:rgb(200,200,200)")
form1_VLeft_Layout.addWidget(self.FanLabel, 1)
self.Fan_HLeft_Layout = QHBoxLayout(self)
self.Fan_HLeft_Widget = QWidget(self)
self.Fan_HLeft_Widget.setLayout(self.Fan_HLeft_Layout)
fan1q = Queue(maxsize=1)
fan2q = Queue(maxsize=1)
self.Fan1Obj = Fan1Circle(fan1q)
self.Fan1Obj.fan1process(fan1q)
self.Fan1Obj.OpenGetRPMTimer()
self.Fan1Obj.setMinimumSize(int(ui_sY / 2.9), int(ui_sY / 2.9))
self.supportFanNum = 1
self.supportGPU = 0
self.supportFanNum = GetFeatureValue_3()
self.supportGPU = GetFeatureValue_4()
if self.supportFanNum == 1:
self.supportFanNum = 1
elif self.supportFanNum == 2:
self.supportFanNum = 2
else:
self.supportFanNum = 1
if self.supportGPU != 1:
self.supportGPU = 0
print("supportFanNum", self.supportFanNum)
print("supportGPU", self.supportGPU)
if self.supportFanNum == 2:
if self.supportGPU == 1:
self.Fan2Obj = Fan2Circle(fan2q)
self.Fan2Obj.fan2process(fan2q)
self.Fan2Obj.OpenGetRPMTimer()
self.Fan2Obj.setMinimumSize(int(ui_sY / 2.9), int(ui_sY / 2.9))
self.Fan_HLeft_Layout.addWidget(self.Fan2Obj, 1)
self.Fan_HLeft_Layout.addWidget(self.Fan1Obj, 1)
form1_VLeft_Layout.addWidget(self.Fan_HLeft_Widget, 4)
form1_VLeft_Layout.setSpacing(0)
form1_VLeft_Layout.setContentsMargins(0, 0, 0, 0)
font24 = self.font()
pointsize1 = int(ui_sY / 30)
font24.setPixelSize(pointsize1)
rightSize = int(ui_sY / 4.5)
rightFont = QFont(font24)
rightColor = "color:rgb(240,240,240)"
form1_VRight_Layout = QVBoxLayout(self)
form1_VRight_Widget = QWidget(self)
form1_VRight_Widget.setLayout(form1_VRight_Layout)
self.CPUTemperLabel = QLabel("CPU温度", self)
self.CPUTemperLabel.setFont(rightFont)
self.CPUTemperLabel.setStyleSheet(rightColor)
temp1_Layout = QVBoxLayout(self)
temp1_Widget = QWidget(self)
temp1_Widget.setLayout(temp1_Layout)
temp1_Layout.addWidget((self.CPUTemperLabel), alignment=(Qt.AlignHCenter))
self.CPUOBJ = CircleCPUTemperature()
self.CPUOBJ.setFixedSize(rightSize, rightSize)
temp1_Layout.addWidget((self.CPUOBJ), alignment=(Qt.AlignHCenter))
form1_VRight_Layout.addWidget(temp1_Widget, 1, alignment=(Qt.AlignHCenter))
self.CPUPerLabel = QLabel("磁盘使用率", self)
self.CPUPerLabel.setFont(rightFont)
self.CPUPerLabel.setStyleSheet(rightColor)
self.cpuperObj = DiskInfo()
self.cpuperObj.setTestTimer(True)
self.cpuperObj.setFixedSize(rightSize, rightSize)
temp3_Layout = QVBoxLayout(self)
temp3_Widget = QWidget(self)
temp3_Widget.setLayout(temp3_Layout)
temp3_Layout.addWidget((self.CPUPerLabel), alignment=(Qt.AlignHCenter))
temp3_Layout.addWidget((self.cpuperObj), alignment=(Qt.AlignHCenter))
form1_VRight_Layout.addWidget(temp3_Widget, 1, alignment=(Qt.AlignHCenter))
self.memoryLabel = QLabel("内存使用率", self)
self.memoryLabel.setFont(rightFont)
self.memoryLabel.setStyleSheet(rightColor)
self.memoryObj = MemoryInfo()
self.memoryObj.setTestTimer(True)
self.memoryObj.setFixedSize(rightSize, rightSize)
temp4_Layout = QVBoxLayout(self)
temp4_Widget = QWidget(self)
temp4_Widget.setLayout(temp4_Layout)
temp4_Layout.addWidget((self.memoryLabel), alignment=(Qt.AlignHCenter))
temp4_Layout.addWidget((self.memoryObj), alignment=(Qt.AlignHCenter))
form1_VRight_Layout.addWidget(temp4_Widget, 1, alignment=(Qt.AlignHCenter))
VSpacer = QSpacerItem(int(ui_sY / 50), int(ui_sY / 6.2), QSizePolicy.Minimum, QSizePolicy.Expanding)
form1_VRight_Layout.addItem(VSpacer)
self.formLayout1.addWidget(form1_VLeft_Widget, 8)
self.formLayout1.addWidget(form1_VRight_Widget, 3)
self.timerrelation = QTimer(self)
self.timerrelation.setInterval(100)
self.timerrelation.timeout.connect(self.timerrelationTimeOut)
self.GetPowerModeRes = -1
self.timerrelation.start()
self.cpu_turbo_timer = QTimer(self)
self.cpu_turbo_timer.setInterval(2000)
self.cpu_turbo_timer.timeout.connect(self.cputurboTimerTimeOut)
self.osd_version_timer = QTimer(self)
self.osd_version_timer.setInterval(1500)
self.osd_version_timer.timeout.connect(self.osd_version_TimeOut)
self.bios_isexist_timer = QTimer(self)
self.bios_isexist_timer.setInterval(100)
self.bios_isexist_timer.timeout.connect(self.biosisexistTimerTimeOut)
self.osd_isexist_timer = QTimer(self)
self.osd_isexist_timer.setInterval(100)
self.osd_isexist_timer.timeout.connect(self.osdisexistTimerTimeOut)
self.memorycheck_timer = QTimer(self)
self.memorycheck_timer.setInterval(1500)
self.memorycheck_timer.timeout.connect(self.memorycheck_timerTimeOut)
self.diskcheck_timer = QTimer(self)
self.diskcheck_timer.setInterval(1500)
self.diskcheck_timer.timeout.connect(self.diskcheck_timerTimeOut)
self.osd_bios_flag = True
form2LabelTipHLayout = QHBoxLayout(self)
form2LabelTipHWidget = QWidget(self)
form2LabelTipHWidget.setLayout(form2LabelTipHLayout)
form2_btnstylesheet = "color:#989696"
form2LabelTipHLayout1 = QHBoxLayout(self)
form2LabelTipHWidget1 = QWidget(self)
form2LabelTipHWidget1.setLayout(form2LabelTipHLayout1)
form2toolbtnsize = QtCore.QSize(int(ui_sY / 6), int(ui_sY / 6))
form2_font = self.font()
pointsize1 = int(ui_sY / 27)
form2_font.setPixelSize(pointsize1)
self.form2_btn1 = QToolButton(self)
self.form2_btn1.setText("自动")
self.form2_btn1.setFont(form2_font)
self.form2_btn1.setIcon(QtGui.QIcon("./imgs/Automatic.png"))
self.form2_btn1.setIconSize(form2toolbtnsize)
self.form2_btn1.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.form2_btn1.setStyleSheet("color:#41aa94")
self.form2_btn1.clicked.connect(self.form2_btn1Clicked)
self.form2_btn2 = QToolButton(self)
self.form2_btn2.setText("自定义")
self.form2_btn2.setFont(form2_font)
self.form2_btn2.setIcon(QtGui.QIcon("./imgs/Customgray.png"))
self.form2_btn2.setIconSize(form2toolbtnsize)
self.form2_btn2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.form2_btn2.clicked.connect(self.form2_btn2Clicked)
self.form2_btn4 = QToolButton(self)
self.form2_btn4.setText("最大")
self.form2_btn4.setFont(form2_font)
self.form2_btn4.setIcon(QtGui.QIcon("./imgs/Maxgray.png"))
self.form2_btn4.setIconSize(form2toolbtnsize)
self.form2_btn4.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.form2_btn4.clicked.connect(self.form2_btn4Clicked)
form2LabelTipHLayout1.addWidget(self.form2_btn1, 1)
form2LabelTipHLayout1.addWidget(self.form2_btn2, 1)
form2LabelTipHLayout1.addWidget(self.form2_btn4, 1)
form2LabelTipHLayout1.addSpacing(ui_sY / 8)
self.formLayout2.addWidget(form2LabelTipHWidget1, 1)
self.form2_LabelTip = QLabel("风扇转速", self)
self.form2_LabelTip.setFont(QFont(font4))
self.form2_LabelTip.setStyleSheet(form2_btnstylesheet)
form2LabelTipHLayout.addWidget(self.form2_LabelTip)
self.formLayout2.addWidget(form2LabelTipHWidget, 2)
fan3queue = Queue()
fan4queue = Queue()
form2FanSize = QSize(int(ui_sY / 3.2), int(ui_sY / 3.2))
self.form2_Fan1Obj = Fan1Circle(fan3queue)
self.form2_Fan1Obj.fan1process(fan3queue)
self.form2_Fan1Obj.OpenGetRPMTimer()
if self.supportFanNum == 2:
if self.supportGPU == 1:
self.form2_Fan2Obj = Fan2Circle(fan4queue)
self.form2_Fan2Obj.fan2process(fan4queue)
self.form2_Fan2Obj.OpenGetRPMTimer()
self.form2_Fan2Obj.setFixedSize(form2FanSize)
self.form2_Fan1Obj.setFixedSize(form2FanSize)
self.fan1Slider = QSlider(Qt.Horizontal, self)
self.fan1Slider.setMinimum(35)
self.fan1Slider.setMaximum(100)
self.fan2Slider = QSlider(Qt.Horizontal)
self.fan2Slider.setMinimum(35)
self.fan2Slider.setMaximum(100)
self.fan1Slider.valueChanged.connect(self.fan1SliderValueChanged)
self.fan2Slider.valueChanged.connect(self.fan2SliderValueChanged)
self.form2SliderSize = QSize(int(ui_sX / 3.5), int(ui_sY / 7))
self.fan1Slider.setFixedSize(self.form2SliderSize)
self.fan2Slider.setFixedSize(self.form2SliderSize)
self.Slider1Label = QLabel(self)
self.Slider1Label.setText("0%")
temp_font = QFont(font4)
self.Slider1Label.setFont(temp_font)
self.Slider1Label.setStyleSheet("color:rgb(200,200,200)")
self.Slider2Label = QLabel()
self.Slider2Label.setText("0%")
self.Slider2Label.setFont(temp_font)
self.Slider2Label.setStyleSheet("color:rgb(200,200,200)")
form2Fan1HLayout1 = QHBoxLayout(self)
form2Fan1HWidget1 = QWidget(self)
form2Fan1HWidget1.setLayout(form2Fan1HLayout1)
form2Fan1HLayout1.addSpacing(40)
form2Fan1HLayout1.addWidget(self.fan1Slider)
form2Fan1HLayout1.addWidget(self.Slider1Label)
form2Fan1VLayout1 = QVBoxLayout(self)
form2Fan1VWidget1 = QWidget(self)
form2Fan1VWidget1.setLayout(form2Fan1VLayout1)
form2Fan1VLayout1.addWidget((self.form2_Fan1Obj), 6, alignment=(Qt.AlignHCenter))
form2Fan1VLayout1.addWidget(form2Fan1HWidget1, 2, alignment=(Qt.AlignHCenter))
form2Fan2HLayout1 = QHBoxLayout(self)
form2Fan2HWidget1 = QWidget(self)
form2Fan2HWidget1.setLayout(form2Fan2HLayout1)
if self.supportFanNum == 2:
if self.supportGPU == 1:
form2Fan2HLayout1.addSpacing(40)
form2Fan2HLayout1.addWidget(self.fan2Slider)
form2Fan2HLayout1.addWidget(self.Slider2Label)
form2Fan1VLayout2 = QVBoxLayout(self)
form2Fan1VWidget2 = QWidget(self)
form2Fan1VWidget2.setLayout(form2Fan1VLayout2)
if self.supportFanNum == 2:
if self.supportGPU == 1:
form2Fan1VLayout2.addWidget((self.form2_Fan2Obj), 6, alignment=(Qt.AlignHCenter))
form2Fan1VLayout2.addWidget(form2Fan2HWidget1, 2, alignment=(Qt.AlignHCenter))
else:
form2FanSliderBtnLayout = QHBoxLayout(self)
form2FanSliderBtnWidget = QWidget(self)
form2FanSliderBtnWidget.setLayout(form2FanSliderBtnLayout)
form2FanSliderBtnLayout.addSpacing(40)
if self.supportFanNum == 2:
if self.supportGPU == 1:
form2FanSliderBtnLayout.addWidget(form2Fan1VWidget2, 1)
form2FanSliderBtnLayout.addWidget(form2Fan1VWidget1, 1)
form2FanSliderBtnLayout.addSpacing(30)
form2FanSliderBtnLayout.addSpacing(60)
self.formLayout2.addWidget(form2FanSliderBtnWidget, 8)
self.SliderStyle = "QSlider::groove:horizontal{ border-radius:8px; height:16px; left:8px; right:8px; background:rgba(50,50,50,1); } QSlider::handle:horizontal{ border-radius:10px; width:30px; height:30px; margin-top:-10px; margin-bottom:-10px; margin-right:-10px; margin-left:-10px; image:url(./imgs/Slider.png); } QSlider::sub-page:horizontal{border-radius:8px;background:rgba(59,165,143,1);}"
self.SliderStyleDisable = "QSlider::groove:horizontal{ border-radius:8px; height:16px; left:8px; right:8px; background:gray; } QSlider::handle:horizontal{ border-radius:10px; width:30px; height:30px; margin-top:-10px; margin-bottom:-10px; margin-right:-10px; margin-left:-10px; image:url(./imgs/Slidergray.png); } QSlider::sub-page:horizontal{border-radius:8px;background:gray;}"
self.fan1Slider.setStyleSheet(self.SliderStyleDisable)
self.fan2Slider.setStyleSheet(self.SliderStyleDisable)
self.fan1Slider.setEnabled(False)
self.fan2Slider.setEnabled(False)
SetFan1Control(101)
SetFan2Control(101)
self.form2.setStyleSheet('\n QToolButton{border:none;color:#989696;font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;}\n\n QToolButton:hover{font-weight:500;}\n QToolButton:pressed{\n padding-left:3px;\n padding-top:3px;\n }\n ')
font15 = self.font()
pointsize1 = int(ui_sY / 31)
font15.setPixelSize(pointsize1)
form4_TempFont1 = QFont(font4)
form4_TempStyleSheet1 = "color:#40aa94"
form4_TempFont2 = QFont(font15)
form4_TempStyleSheet2 = "color:rgb(218,218,218)"
OSDSwitchWidget = QWidget(self)
OSDSwitchLayout = QVBoxLayout(self)
OSDSwitchWidget.setLayout(OSDSwitchLayout)
self.btnOSDSwitch = SwitchBtn()
SwitchBtnsize = QtCore.QSize(int(ui_sY / 7), int(ui_sY / 15))
self.btnOSDSwitch.setFixedSize(SwitchBtnsize)
self.btnOSDSwitch.checkedChanged.connect(self.btnOSDSwitchclicked)
self.LabelOSDTip = QLabel(self)
self.LabelOSDTip.setFont(form4_TempFont1)
self.LabelOSDTip.setText("热键图标提示")
self.LabelOSDTip.setStyleSheet(form4_TempStyleSheet1)
self.OSDSwitchLabel = QLabel(self)
self.OSDSwitchLabel.setText(" 打开功能,按下热键,会提示功能图标;关闭功能,按下热键,不会提示功能图标。")
self.OSDSwitchLabel.setWordWrap(True)
self.OSDSwitchLabel.setFont(form4_TempFont2)
self.OSDSwitchLabel.setStyleSheet(form4_TempStyleSheet2)
OSDSwitchLayout.addWidget(self.LabelOSDTip)
OSDSwitchLayout.addWidget(self.OSDSwitchLabel)
OSDSwitchLayout.setSpacing(0)
OSDSwitchLayout.setContentsMargins(0, 0, 0, 0)
OSDSwitchHWidget = QWidget(self)
OSDSwitchHLayout = QHBoxLayout(self)
OSDSwitchHWidget.setLayout(OSDSwitchHLayout)
OSDSwitchHWidget.setObjectName("outlinewidget1")
OSDSwitchHWidget.setStyleSheet("QWidget#outlinewidget1{border-bottom: 1px dashed #757575;};")
OSDSwitchHLayout.addWidget(OSDSwitchWidget)
OSDSwitchHLayout.addWidget(self.btnOSDSwitch)
OSDSwitchHLayout.addSpacing(30)
OSDSwitchHLayout.setContentsMargins(0, 0, 0, 0)
self.formLayout4.addWidget(OSDSwitchHWidget, 1)
return_is_cpu_turbo = whether_support_cpu_turbo()
if return_is_cpu_turbo == 1:
self.CPU_turbo_show()
self.cpu_turbo_timer.start()
VSpacer = QSpacerItem(int(ui_sY / 30), int(ui_sY / 1.5), QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout4.addItem(VSpacer)
self.formLayout4.setSpacing(0)
else:
print("return_is_cpu_turbo:", return_is_cpu_turbo)
print("不支持CPU Turbo功能")
VSpacer = QSpacerItem(int(ui_sY / 30), int(ui_sY / 1.1), QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout4.addItem(VSpacer)
self.formLayout4.setSpacing(0)
self.form4.setStyleSheet("margin-right:50px")
c = wmi.WMI()
sys1 = c.Win32_OperatingSystem()[0]
processor = c.Win32_Processor()[0]
ssd1 = c.Win32_DiskDrive()[0]
memory = c.Win32_PhysicalMemory()[0]
for bios_id in c.Win32_BIOS():
biosidstr = bios_id.Version
break
bios = wmi.WMI().Win32_BIOS()[0]
self.productname = wmi.WMI().Win32_BaseBoard()[0].Product
self.bios_version = bios.name
biosinfo = bios.Manufacturer + bios.Name + "," + bios.ReleaseDate[0:4] + "/" + bios.ReleaseDate[4:6] + "/" + bios.ReleaseDate[6:8]
cpuinfo = processor.Name.strip() + "," + str(int(psutil.cpu_freq().max)) + " MHz " + str(psutil.cpu_count(False)) + " Core(s) " + str(psutil.cpu_count()) + " Logical Processor(s)"
mem = str(round(float(psutil.virtual_memory().total) / 1024.0 / 1024.0 / 1024.0, 1)) + "GB"
hDC = win32gui.GetDC(0)
w = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
h = win32print.GetDeviceCaps(hDC, win32con.DESKTOPVERTRES)
screen_scale_rate = str(int(round(w / sX, 2) * 100)) + "%"
InfoWidget1 = QWidget(self)
InfoLayout1 = QHBoxLayout(self)
InfoWidget1.setLayout(InfoLayout1)
radubs = int(ui_sY / 35)
font16 = self.font()
pointsize1 = int(ui_sY / 32)
font16.setPixelSize(pointsize1)
fon1 = self.font()
pointsize11 = int(ui_sY / 40)
fon1.setPixelSize(pointsize11)
handa = QSize(int(ui_sX / 5), int(ui_sY / 20))
FontInfo = QFont(font16)
print("1314543656", FontInfo)
self.InfoTextColor = "color:rgb(218,218,218)"
self.labelInfo1_0 = QLabel(self)
self.labelInfo1_0.setFont(FontInfo)
self.labelInfo1_0.setStyleSheet(self.InfoTextColor)
self.labelInfo1_0.setText("系统")
self.labelInfo1_0.setFixedSize(handa)
self.labelInfo1_1 = QLabel(self)
self.labelInfo1_1.setFont(FontInfo)
self.labelInfo1_1.setStyleSheet(self.InfoTextColor)
self.labelInfo1_1.setText(sys1.Caption)
InfoLayout1.addSpacing(20)
InfoLayout1.addWidget(self.labelInfo1_0)
InfoLayout1.addWidget(self.labelInfo1_1)
InfoWidget4 = QWidget(self)
InfoLayout4 = QHBoxLayout(self)
InfoWidget4.setLayout(InfoLayout4)
self.labelInfo4_0 = QLabel(self)
self.labelInfo4_0.setFont(FontInfo)
self.labelInfo4_0.setStyleSheet(self.InfoTextColor)
self.labelInfo4_0.setText("处理器")
self.labelInfo4_0.setFixedSize(handa)
self.labelInfo4_1 = QLabel(self)
self.labelInfo4_1.setFont(FontInfo)
self.labelInfo4_1.setStyleSheet(self.InfoTextColor)
self.labelInfo4_1.setText(cpuinfo)
self.labelInfo4_1.setWordWrap(True)
InfoLayout4.addSpacing(20)
InfoLayout4.addWidget(self.labelInfo4_0)
InfoLayout4.addWidget(self.labelInfo4_1)
InfoWidget5 = QWidget(self)
InfoLayout5 = QHBoxLayout(self)
InfoWidget5.setLayout(InfoLayout5)
self.labelInfo5_0 = QLabel(self)
self.labelInfo5_0.setFont(FontInfo)
self.labelInfo5_0.setStyleSheet(self.InfoTextColor)
self.labelInfo5_0.setText("主板")
self.labelInfo5_0.setFixedSize(handa)
self.labelInfo5_1 = QLabel(self)
self.labelInfo5_1.setFont(FontInfo)
self.labelInfo5_1.setStyleSheet(self.InfoTextColor)
self.labelInfo5_1.setText(c.Win32_BaseBoard()[0].Product)
InfoLayout5.addSpacing(20)
InfoLayout5.addWidget(self.labelInfo5_0)
InfoLayout5.addWidget(self.labelInfo5_1)
InfoWidget6 = QWidget(self)
InfoLayout6 = QHBoxLayout(self)
InfoWidget6.setLayout(InfoLayout6)
self.labelInfo6_0 = QLabel(self)
self.labelInfo6_0.setFont(FontInfo)
self.labelInfo6_0.setStyleSheet(self.InfoTextColor)
self.labelInfo6_0.setText("BIOS版本/日期")
self.labelInfo6_0.setFixedSize(handa)
self.labelInfo6_1 = QLabel(self)
self.labelInfo6_1.setFont(FontInfo)
self.labelInfo6_1.setStyleSheet(self.InfoTextColor)
self.labelInfo6_1.setText(biosinfo)
self.labelInfo6_1.setWordWrap(True)
InfoLayout6.addSpacing(20)
InfoLayout6.addWidget(self.labelInfo6_0)
InfoLayout6.addWidget(self.labelInfo6_1)
self.biosbtn = QPushButton("BIOS 更新", self)
self.biosbtn.setFont(QFont(fon1))
self.biosbtn.setObjectName("biosbtn")
self.biosbtn.setStyleSheet("#biosbtn{{background-color:#4b4b54;color:rgb(240,240,240);border-radius:{0}px;}}\n #biosbtn:hover {{\n background-color:#41aa94}}\n #biosbtn:pressed {{\n background-color: #55555c;padding-left:3px;padding-top:3px;}}".format(radubs))
self.biosbtn.setFixedSize(int(ui_sY / 6), int(ui_sY / 15))
self.biosbtn.clicked.connect(self.biosbtn_slot)
InfoLayout6.addWidget(self.biosbtn)
self.biosbtn.hide()
InfoWidget8 = QWidget(self)
InfoLayout8 = QHBoxLayout(self)
InfoWidget8.setLayout(InfoLayout8)
self.labelInfo8_0 = QLabel(self)
self.labelInfo8_0.setFont(FontInfo)
self.labelInfo8_0.setStyleSheet(self.InfoTextColor)
self.labelInfo8_0.setText("显示器")
self.labelInfo8_0.setFixedSize(handa)
self.labelInfo8_1 = QLabel(self)
self.labelInfo8_1.setFont(FontInfo)
self.labelInfo8_1.setStyleSheet(self.InfoTextColor)
self.labelInfo8_1.setText(str(w) + "x" + str(h) + " " + screen_scale_rate)
InfoLayout8.addSpacing(20)
InfoLayout8.addWidget(self.labelInfo8_0)
InfoLayout8.addWidget(self.labelInfo8_1)
self.batteryInfoTimer = QTimer(self)
self.batteryInfoTimer.setInterval(2000)
self.batteryInfoTimer.start()
InfoWidget10 = QWidget(self)
InfoLayout10 = QHBoxLayout(self)
InfoWidget10.setLayout(InfoLayout10)
self.labelInfo10_0 = QLabel(self)
self.labelInfo10_0.setFont(FontInfo)
self.labelInfo10_0.setStyleSheet(self.InfoTextColor)
self.labelInfo10_0.setText("OSD版本")
self.labelInfo10_0.setFixedSize(handa)
self.labelInfo10_1 = QLabel(self)
self.labelInfo10_1.setFont(FontInfo)
self.labelInfo10_1.setStyleSheet(self.InfoTextColor)
osd_vesrion = get_OSD_version()
self.labelInfo10_1.setText(osd_vesrion)
self.osd_version_timer.start()
InfoLayout10.addSpacing(20)
InfoLayout10.addWidget(self.labelInfo10_0)
InfoLayout10.addWidget(self.labelInfo10_1)
self.osd_update_btn = QPushButton("OSD 更新", self)
self.osd_update_btn.setFont(QFont(fon1))
self.osd_update_btn.setObjectName("osdupdatebtn")
self.osd_update_btn.setStyleSheet("#osdupdatebtn{{background-color:#4b4b54;color:rgb(240,240,240);border-radius:15px;height:40;}}\n #osdupdatebtn:hover {{\n background-color:#41aa94}}\n #osdupdatebtn:pressed {{\n background-color: #55555c;padding-left:3px;padding-top:3px;}}".format(radubs))
self.osd_update_btn.setFixedSize(int(ui_sY / 6), int(ui_sY / 15))
self.osd_update_btn.clicked.connect(self.osd_update_btn_slot)
self.osd_update_btn.hide()
InfoLayout10.addWidget(self.osd_update_btn)
InfoWidget11 = QWidget(self)
InfoLayout11 = QHBoxLayout(self)
InfoWidget11.setLayout(InfoLayout11)
self.labelInfo11_0 = QLabel(self)
self.labelInfo11_0.setFont(FontInfo)
self.labelInfo11_0.setStyleSheet(self.InfoTextColor)
self.labelInfo11_0.setText("磁盘信息")
self.labelInfo11_0.setFixedSize(handa)
self.labelInfo11_1 = QLabel(self)
self.labelInfo11_1.setFont(FontInfo)
self.labelInfo11_1.setStyleSheet(self.InfoTextColor)
disk_per = str(round(psutil.disk_usage("/").percent))
disk_remain = str(int(psutil.disk_usage("/").free / 1024 / 1024 / 1024))
disk_total = str(int(psutil.disk_usage("/").total / 1024 / 1024 / 1024))
self.labelInfo11_1.setText("使用率: " + disk_per + "%, " + "可用/共有: " + disk_remain + " G/" + disk_total + " G")
self.diskcheck_timer.start()
InfoLayout11.addSpacing(20)
InfoLayout11.addWidget(self.labelInfo11_0)
InfoLayout11.addWidget(self.labelInfo11_1)
InfoWidget12 = QWidget(self)
InfoLayout12 = QHBoxLayout(self)
InfoWidget12.setLayout(InfoLayout12)
self.labelInfo12_0 = QLabel(self)
self.labelInfo12_0.setFont(FontInfo)
self.labelInfo12_0.setStyleSheet(self.InfoTextColor)
self.labelInfo12_0.setText("内存信息")
self.labelInfo12_0.setFixedSize(handa)
self.labelInfo12_1 = QLabel(self)
self.labelInfo12_1.setFont(FontInfo)
self.labelInfo12_1.setStyleSheet(self.InfoTextColor)
_totalMemory = round(float(psutil.virtual_memory().total) / 1024 / 1024 / 1024, 1)
_usedMemory = round(float(psutil.virtual_memory().used) / 1024 / 1024 / 1024, 1)
tMemory = round(psutil.virtual_memory().percent)
self.labelInfo12_1.setText("使用率: " + str(tMemory) + "%, " + "已用/共有: " + str(_usedMemory) + " G/" + str(_totalMemory) + " G")
self.memorycheck_timer.start()
InfoLayout12.addSpacing(20)
InfoLayout12.addWidget(self.labelInfo12_0)
InfoLayout12.addWidget(self.labelInfo12_1)
self.formLayout5.addWidget(InfoWidget1)
self.formLayout5.addWidget(InfoWidget4)
self.formLayout5.addWidget(InfoWidget5)
self.formLayout5.addWidget(InfoWidget6)
self.formLayout5.addWidget(InfoWidget8)
self.formLayout5.addWidget(InfoWidget10)
self.formLayout5.addWidget(InfoWidget11)
self.formLayout5.addWidget(InfoWidget12)
self.formLayout5.setSpacing(0)
form5yanghuVSpacer = QSpacerItem(int(ui_sY / 30), int(ui_sY / 4), QSizePolicy.Minimum, QSizePolicy.Expanding)
self.formLayout5.addItem(form5yanghuVSpacer)
getFeatureTemp0, getFeatureTemp1, getFeatureTemp2, cpu_turbo_flag, conversationModeFlag, self.ACPowerFlag, LIDFlag, OSDFlag = GetFeatureValue()
print("8888888888888888888GetFeatureValue", getFeatureTemp0, getFeatureTemp1, cpu_turbo_flag, conversationModeFlag, self.ACPowerFlag, LIDFlag, OSDFlag)
print("osd", OSDFlag)
if OSDFlag == 1:
self.btnOSDSwitch.setChecked(True)
else:
self.btnOSDSwitch.setChecked(False)
self.GetPowerModeInitialNize()
def Infoprocess(self, q):
process1 = multiprocessing.Process(target=PCInfoGet, args=(q,))
process1.daemon = True
process1.start()
def biosbtn_slot(self):
if not test_internet():
if self.parent().SwithFalg_CN == True:
msgBox = QMessageBox()
msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = msgBox.addButton("退出", QMessageBox.AcceptRole)
okButton = msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
msgBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
msgBox.setWindowTitle("网络")
msgBox.setText("网络异常: 网络连接已断开!")
msgBox.exec()
return
else:
msgBox = QMessageBox()
msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = msgBox.addButton("Exit", QMessageBox.AcceptRole)
okButton = msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
msgBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
msgBox.setWindowTitle("network")
msgBox.setText("The network connection has been lost!")
msgBox.exec()
return
else:
list_bios_info = get_all_bios_info()
list_bios_info.sort()
print(list_bios_info, "===================")
list_product = []
last_version = ""
for product in list_bios_info:
if self.productname == product[:product.find("Update")]:
print(product[:product.find("Update")], "111111111111111111111111111111")
list_product.append(product)
list_product.sort()
print(self.productname)
print(list_product, "----------------------------------")
if list_product:
package_name = list_product[-1]
char1 = "Update"
char2 = ".exe"
nPos1 = package_name.find(char1) + 6
print(nPos1)
print("-----------------------")
nPos2 = package_name.find(char2)
print(nPos2)
print("-----------------------")
last_version = package_name[nPos1:nPos2]
else:
if self.parent().SwithFalg_CN == True:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前Bios版本为最新版本,无需更新!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("确认", QMessageBox.YesRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
messageBox.exec_()
return
else:
reply = QMessageBox(QMessageBox.Information, "Tips", "\nThe current bios version is the latest version, no update required!\n")
reply.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
reply.setIcon(QMessageBox.NoIcon)
reply.setStyleSheet("QMessageBox QLabel{font-size: 12px;}")
Qyes = reply.addButton("exit", QMessageBox.YesRole)
okButton = reply.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
reply.exec_()
return
print(last_version)
if not last_version:
return
else:
if self.parent().SwithFalg_CN == True:
if last_version != self.bios_version:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前Bios版本为: " + self.bios_version + ", 最新版本是: " + last_version + ", 请确认是否更新\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("更新", QMessageBox.YesRole)
Qno = messageBox.addButton("取消", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
if messageBox.clickedButton() == Qyes:
try:
down_que = Queue(maxsize=1)
processftp1 = multiprocessing.Process(target=ftp_connect_download_bios, args=(
"/APP/BoxAPP/client1/bios_lastest_release", down_que,
list_product[-1]))
processftp1.start()
processftp1.join()
except:
pass
messageBox1 = QMessageBox(QMessageBox.Information, "提示", "\nBIOS更新需要插入电源, 且电量大于30%, 更新后自动进行重启, 确认无误后可点击更新\n")
messageBox1.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes1 = messageBox1.addButton(self.tr("更新"), QMessageBox.YesRole)
Qno1 = messageBox1.addButton(self.tr("退出"), QMessageBox.NoRole)
messageBox1.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
okButton = messageBox1.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox1.exec_()
if messageBox1.clickedButton() == Qyes1:
try:
down_file = down_que.get()
os.startfile(down_file)
except:
pass
else:
return
else:
return
else:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前Bios版本为最新版本,无需更新!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes = messageBox.addButton(self.tr("确认"), QMessageBox.YesRole)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
return
elif last_version != self.bios_version:
reply = QMessageBox(QMessageBox.Information, "Tips", "\nThe current bios version is :" + self.bios_version + ", The latest version is: " + last_version + ",\n\n Please check whether it is updated\n")
reply.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
reply.setIcon(QMessageBox.NoIcon)
reply.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = reply.addButton("update", QMessageBox.YesRole)
Qno = reply.addButton("cancel", QMessageBox.NoRole)
okButton = reply.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
reply.exec_()
if reply.clickedButton() == Qyes:
down_que = Queue(maxsize=1)
processftp1 = multiprocessing.Process(target=ftp_connect_download_bios, args=(
"/APP/BoxAPP/client1/bios_lastest_release", down_que,
list_product[-1]))
processftp1.start()
processftp1.join()
reply1 = QMessageBox(QMessageBox.Information, "Tips", "\nBIOS update needs to be plugged into a power supply, and the power is greater than 30%, and it will automatically restart after the update, and you can click Update after confirmation\n")
reply1.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes1 = reply1.addButton(self.tr("update"), QMessageBox.YesRole)
Qno1 = reply1.addButton(self.tr("quit"), QMessageBox.NoRole)
reply1.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
okButton = reply1.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
reply1.exec_()
if reply1 == QMessageBox.Yes:
try:
down_file = down_que.get()
os.startfile(down_file)
except:
pass
else:
return
else:
return
else:
messageBox = QMessageBox(QMessageBox.Information, "Tips", "\nThe current bios version is the latest version, no update required!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes = messageBox.addButton(self.tr("quit"), QMessageBox.YesRole)
okButton = messageBox.buttons()
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
return
def osd_update_btn_slot(self):
if not test_internet():
if self.parent().SwithFalg_CN == True:
msgBox = QMessageBox()
msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = msgBox.addButton("退出", QMessageBox.AcceptRole)
okButton = msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
msgBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
msgBox.setWindowTitle("网络")
msgBox.setText("网络异常: 网络连接已断开!")
msgBox.exec()
return
msgBox = QMessageBox()
msgBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
okButton = msgBox.addButton("Exit", QMessageBox.AcceptRole)
okButton = msgBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 10px; height: 10px;")
msgBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
msgBox.setWindowTitle("network")
msgBox.setText("The network connection has been lost!")
msgBox.exec()
return
else:
try:
list_osd_info = get_all_OSD_info()
list_osd_info.sort()
print(list_osd_info)
except:
return
else:
print(list_osd_info)
last_version = ""
if list_osd_info:
package_name = list_osd_info[-1]
char1 = "SetUpV"
char2 = ".exe"
nPos1 = package_name.find(char1) + 6
nPos2 = package_name.find(char2)
last_version = package_name[nPos1:nPos2]
if self.labelInfo10_1.text() == "No Find":
if self.parent().SwithFalg_CN == True:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n未发现OSD安装, 最新版本是: " + last_version + ", 请确认是否更新\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("更新", QMessageBox.YesRole)
Qno = messageBox.addButton("取消", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
if messageBox.clickedButton() == Qyes:
if messageBox.clickedButton() == Qyes:
try:
processftp1 = multiprocessing.Process(target=ftp_connect_download_osd, args=(
"/OSD/OSDSetup/OSD_Release",
list_osd_info[-1]))
processftp1.start()
self.osd_update_btn.hide()
except:
pass
else:
return
else:
messageBox = QMessageBox(QMessageBox.Information, "Tips", "\nNo OSD installations were found,The latest version is: " + last_version + ", Please check whether it is updated!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("update", QMessageBox.YesRole)
Qno = messageBox.addButton("quit", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
if messageBox.clickedButton() == Qyes:
if messageBox.clickedButton() == Qyes:
try:
processftp1 = multiprocessing.Process(target=ftp_connect_download_osd, args=(
"/OSD/OSDSetup/OSD_Release",
list_osd_info[-1]))
processftp1.start()
self.osd_update_btn.hide()
except:
pass
else:
return
elif self.parent().SwithFalg_CN == True:
try:
floatosdvesion = float(self.labelInfo10_1.text())
except:
return
else:
if float(last_version) > floatosdvesion:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前OSD版本为: " + self.labelInfo10_1.text() + ", 最新版本是: " + last_version + ", 请确认是否更新\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("更新", QMessageBox.YesRole)
Qno = messageBox.addButton("取消", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
if messageBox.clickedButton() == Qyes:
if messageBox.clickedButton() == Qyes:
try:
processftp1 = multiprocessing.Process(target=ftp_connect_download_osd, args=(
"/OSD/OSDSetup/OSD_Release",
list_osd_info[-1]))
processftp1.start()
self.osd_update_btn.hide()
except:
pass
else:
return
else:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前OSD版本为最新版本,无需更新!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes = messageBox.addButton(self.tr("退出"), QMessageBox.YesRole)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
return
try:
floatosdvesion = float(self.labelInfo10_1.text())
except:
return
if float(last_version) > floatosdvesion:
messageBox = QMessageBox(QMessageBox.Information, "Tips", "\nThe current osd version is :" + self.labelInfo10_1.text() + "The latest version is: " + last_version + ", Please check whether it is updated!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("update", QMessageBox.YesRole)
Qno = messageBox.addButton("quit", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
if messageBox.clickedButton() == Qyes:
if messageBox.clickedButton() == Qyes:
try:
processftp1 = multiprocessing.Process(target=ftp_connect_download_osd, args=(
"/OSD/OSDSetup/OSD_Release",
list_osd_info[-1]))
processftp1.start()
self.osd_update_btn.hide()
except:
pass
else:
return
else:
messageBox = QMessageBox(QMessageBox.Information, "Tips", "\nThe current osd version is the latest version, no update required!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes = messageBox.addButton(self.tr("quit"), QMessageBox.YesRole)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
return
else:
if self.parent().SwithFalg_CN == True:
messageBox = QMessageBox(QMessageBox.Information, "提示", "\n当前OSD版本为最新版本,无需更新!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
messageBox.setIcon(QMessageBox.NoIcon)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
Qyes = messageBox.addButton("update", QMessageBox.YesRole)
Qno = messageBox.addButton("quit", QMessageBox.NoRole)
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
return
messageBox = QMessageBox(QMessageBox.Information, "Tips", "\nThe current osd version is the latest version, no update required!\n")
messageBox.setWindowIcon(QtGui.QIcon("./imgs/Mode.png"))
Qyes = messageBox.addButton(self.tr("quit"), QMessageBox.YesRole)
messageBox.setStyleSheet("QMessageBox QLabel{font-size: 12px;font-family:Microsoft YaHei;}")
okButton = messageBox.buttons()
for button in okButton:
button.setStyleSheet("font-size: 10px;font-family:Microsoft YaHei; width: 6px; height: 6px;")
messageBox.exec_()
return
def cputurboTimerTimeOut(self):
if self.GetPowerModeRes == 1 or self.GetPowerModeRes == 3:
self.CputurboSwitch.enabled = True
self.CputurboSwitch.update()
else:
self.CputurboSwitch.enabled = False
self.CputurboSwitch.update()
def biosisexistTimerTimeOut(self):
try:
if test_internet():
list_bios_info = get_all_bios_info()
list_bios_info.sort()
print(list_bios_info)
list_product = []
last_version = ""
for product in list_bios_info:
if self.productname == product[:product.find("Update")]:
list_product.append(product)
list_product.sort()
print(list_product)
if list_product:
package_name = list_product[-1]
char1 = "Update"
char2 = ".exe"
nPos1 = package_name.find(char1) + 6
nPos2 = package_name.find(char2)
last_version = package_name[nPos1:nPos2]
if float(last_version) > float(self.bios_version):
self.biosbtn.show()
self.bios_isexist_timer.stop()
if self.bios_isexist_timer.isActive():
self.bios_isexist_timer.stop()
else:
if self.bios_isexist_timer.isActive():
self.bios_isexist_timer.stop()
except:
if self.bios_isexist_timer.isActive():
self.bios_isexist_timer.stop()
def osdisexistTimerTimeOut(self):
try:
if test_internet():
list_osd_info = get_all_OSD_info()
list_osd_info.sort()
print(list_osd_info)
last_version = ""
if list_osd_info:
package_name = list_osd_info[-1]
char1 = "SetUpV"
char2 = ".exe"
nPos1 = package_name.find(char1) + 6
nPos2 = package_name.find(char2)
last_version = package_name[nPos1:nPos2]
if self.labelInfo10_1.text() == "No Find":
self.osd_update_btn.show()
elif float(self.labelInfo10_1.text()) <= 2.2:
if float(last_version) > float(self.labelInfo10_1.text()):
self.osd_update_btn.show()
self.osd_isexist_timer.stop()
if self.osd_isexist_timer.isActive():
self.osd_isexist_timer.stop()
elif self.osd_isexist_timer.isActive():
self.osd_isexist_timer.stop()
except:
if self.osd_isexist_timer.isActive():
self.osd_isexist_timer.stop()
def memorycheck_timerTimeOut(self):
_totalMemory = round(float(psutil.virtual_memory().total) / 1024 / 1024 / 1024, 1)
_usedMemory = round(float(psutil.virtual_memory().used) / 1024 / 1024 / 1024, 1)
tMemory = round(psutil.virtual_memory().percent)
if self.parent().SwithFalg_CN == True:
self.labelInfo12_0.setText("内存信息")
self.labelInfo12_1.setText("使用率: " + str(tMemory) + "%, " + "已用/共有: " + str(_usedMemory) + " G/" + str(_totalMemory) + " G")
else:
self.labelInfo12_0.setText("Memory Information")
self.labelInfo12_1.setText("Memory Usage: " + str(tMemory) + "%, " + "Used/Total: " + str(_usedMemory) + " G/" + str(_totalMemory) + " G")
def diskcheck_timerTimeOut(self):
disk_per = str(round(psutil.disk_usage("/").percent))
disk_remain = str(int(psutil.disk_usage("/").free / 1024 / 1024 / 1024))
disk_total = str(int(psutil.disk_usage("/").total / 1024 / 1024 / 1024))
if self.parent().SwithFalg_CN == True:
self.labelInfo11_0.setText("磁盘信息")
self.labelInfo11_1.setText("使用率: " + disk_per + "%, " + "可用/共有: " + disk_remain + " G/" + disk_total + " G")
else:
self.labelInfo11_0.setText("Disk Information")
self.labelInfo11_1.setText("Disk Usage: " + disk_per + "%, " + "available/Total: " + disk_remain + " G/" + disk_total + " G")
def osd_version_TimeOut(self):
try:
osdversion = get_OSD_version()
self.labelInfo10_1.setText(osdversion)
except:
return
def timerrelationTimeOut(self):
self.GetPowerModeRes = GetPowerMode()
GetOSDValue = GetFeatureValue()
print("------------------1---------------")
print("获取到得模式是", self.GetPowerModeRes)
print("获取到几种模式", self.ModeNum)
print("当前的OSD开关是?", GetOSDValue)
if self.ModeNum == 1:
if self.GetPowerModeRes == 2:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.ModeNum == 2:
pass
if self.GetPowerModeRes == 2:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.GetPowerModeRes == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetClicked2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceModeEnglish.png"))
elif self.ModeNum == 3:
if self.GetPowerModeRes == 2:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.GetPowerModeRes == 0:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetClicked1)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceModeEnglish.png"))
elif self.GetPowerModeRes == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetClicked2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceModeEnglish.png"))
def form2_btn1Clicked(self):
self.form2_btn1.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.form2_btn2.setStyleSheet("QToolButton{border:none;}")
self.form2_btn4.setStyleSheet("QToolButton{border:none;}")
self.form2_btn1.setIcon(QtGui.QIcon("./imgs/Automatic.png"))
self.form2_btn2.setIcon(QtGui.QIcon("./imgs/Customgray.png"))
self.form2_btn4.setIcon(QtGui.QIcon("./imgs/Maxgray.png"))
self.fan1Slider.setEnabled(False)
self.fan2Slider.setEnabled(False)
self.fan1Slider.setStyleSheet(self.SliderStyleDisable)
self.fan2Slider.setStyleSheet(self.SliderStyleDisable)
SetFan1Control(101)
if self.supportFanNum == 2:
if self.supportGPU == 1:
SetFan2Control(101)
def form2_btn2Clicked(self):
self.form2_btn1.setStyleSheet("QToolButton{border:none;}")
self.form2_btn2.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.form2_btn4.setStyleSheet("QToolButton{border:none;}")
self.form2_btn1.setIcon(QtGui.QIcon("./imgs/Automaticgray.png"))
self.form2_btn2.setIcon(QtGui.QIcon("./imgs/Custom.png"))
self.form2_btn4.setIcon(QtGui.QIcon("./imgs/Maxgray.png"))
self.fan1Slider.setEnabled(True)
self.fan2Slider.setEnabled(True)
self.fan1Slider.setStyleSheet(self.SliderStyle)
self.fan2Slider.setStyleSheet(self.SliderStyle)
self.fan1Slider.setValue(50)
self.fan2Slider.setValue(50)
SetFan1Control(50)
if self.supportFanNum == 2:
if self.supportGPU == 1:
SetFan2Control(50)
def form2_btn4Clicked(self):
self.form2_btn1.setStyleSheet("QToolButton{border:none;}")
self.form2_btn2.setStyleSheet("QToolButton{border:none;}")
self.form2_btn4.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.form2_btn1.setIcon(QtGui.QIcon("./imgs/Automaticgray.png"))
self.form2_btn2.setIcon(QtGui.QIcon("./imgs/Customgray.png"))
self.form2_btn4.setIcon(QtGui.QIcon("./imgs/Max.png"))
self.fan1Slider.setEnabled(False)
self.fan2Slider.setEnabled(False)
self.fan1Slider.setStyleSheet(self.SliderStyleDisable)
self.fan2Slider.setStyleSheet(self.SliderStyleDisable)
self.fan1Slider.setValue(100)
self.fan2Slider.setValue(100)
SetFan1Control(100)
if self.supportFanNum == 2:
if self.supportGPU == 1:
SetFan2Control(100)
def fan1SliderValueChanged(self):
print("fan1valuechanged", self.fan1Slider.value())
self.Slider1Label.setText(str(self.fan1Slider.value()) + "%")
SetFan1Control(self.fan1Slider.value())
def fan2SliderValueChanged(self):
print("fan2valuechanged", self.fan2Slider.value())
self.Slider2Label.setText(str(self.fan2Slider.value()) + "%")
SetFan2Control(self.fan2Slider.value())
def CputurboSwitchclicked(self):
if self.CputurboSwitch.enabled:
if self.CputurboSwitch.checked:
SetFeatureValue(5, 1)
print("CPU Turbo on")
if self.CputurboSwitch.enabled:
if not self.CputurboSwitch.checked:
SetFeatureValue(5, 0)
print("CPU Turbo off")
def btnOSDSwitchclicked(self):
if self.btnOSDSwitch.checked:
print("OSD on")
SetFeatureValue(1, 1)
else:
print("OSD off")
SetFeatureValue(1, 0)
def btnLightSwitchclicked(self):
if self.btnlightSwitch.checked:
print("Light Mode on")
SetFeatureValue(7, 1)
else:
print("Light Mode off")
SetFeatureValue(7, 0)
def ProtectEyeSwitchclicked(self):
try:
if self.ProtectEyeSwitch.checked:
print("protect eye on")
p = protecthdll.GETProtectEyeMode()
p = protecthdll.NightModeNormal()
self.NightModeSwitch.setChecked(False)
conf.set("buttonset", "protecteyemode", "True")
conf.set("buttonset", "nightmode", "False")
conf.write(open("config.ini", "r+"))
else:
print("protect eye off")
p = protecthdll.EyeModeNormal()
conf.set("buttonset", "protecteyemode", "False")
conf.write(open("config.ini", "r+"))
except:
pass
def NightModeSwitchclicked(self):
try:
if self.NightModeSwitch.checked:
print("nightmode on")
p = protecthdll.GETNightMode()
p = protecthdll.EyeModeNormal()
self.ProtectEyeSwitch.setChecked(False)
conf.set("buttonset", "protecteyemode", "False")
conf.set("buttonset", "nightmode", "True")
conf.write(open("config.ini", "r+"))
else:
print("nightmode off")
p = protecthdll.NightModeNormal()
conf.set("buttonset", "nightmode", "False")
conf.write(open("config.ini", "r+"))
except:
pass
def InitSwitchState(self):
try:
ProtectEyeMode = conf.getboolean("buttonset", "protecteyemode")
NightMode = conf.getboolean("buttonset", "nightmode")
if ProtectEyeMode:
protecthdll.GETProtectEyeMode()
self.ProtectEyeSwitch.setChecked(True)
else:
protecthdll.EyeModeNormal()
self.ProtectEyeSwitch.setChecked(False)
if NightMode:
protecthdll.GETNightMode()
self.NightModeSwitch.setChecked(True)
else:
protecthdll.NightModeNormal()
self.NightModeSwitch.setChecked(False)
except:
pass
def ModebtnSilenceClicked(self):
if self.ModeNum == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
SetPowerMode(2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.ModeNum == 2:
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
SetPowerMode(2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.ModeNum == 3:
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
SetPowerMode(2)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
def ModebtnPerfermenceClicked(self):
if self.ModeNum == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
SetPowerMode(1)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.ModeNum == 2:
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetClicked2)
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
SetPowerMode(1)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceModeEnglish.png"))
elif self.ModeNum == 3:
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetClicked2)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
SetPowerMode(1)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceModeEnglish.png"))
def ModebtnBalanceClicked(self):
if self.ModeNum == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
SetPowerMode(0)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceModeEnglish.png"))
elif self.ModeNum == 2:
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetClicked)
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit2)
SetPowerMode(0)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceModeEnglish.png"))
elif self.ModeNum == 3:
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetClicked1)
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
SetPowerMode(0)
if self.parent().SwithFalg_CN == True:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceMode.png"))
else:
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceModeEnglish.png"))
def CPUTTimer_timeout_handle(self):
currentfre = random.randint(0, 100)
self._CPUTvalue = currentfre
self.CPUTdelayTimer.start(5)
def setCPUTTimer(self, flag):
if flag is True:
self.CPUTTimer.start(2000)
else:
self.CPUTTimer.stop()
def CPUTdelayTimer_timeout_handle(self):
self.CPUTCLabel.setText("{}".format(self._CPUTvalue) + "0".translate(str.maketrans("0", "⁰")) + "C")
if self._CPUTvalue > self.CPUTPro.value():
self.CPUTPro.setValue(self.CPUTPro.value() + 1)
if self._CPUTvalue == self.CPUTPro.value():
if self.CPUTdelayTimer.isActive():
self.CPUTdelayTimer.stop()
elif self._CPUTvalue < self.CPUTPro.value():
pass
self.CPUTPro.setValue(self.CPUTPro.value() - 1)
if self._CPUTvalue == self.CPUTPro.value():
if self.CPUTdelayTimer.isActive():
self.CPUTdelayTimer.stop()
elif self.CPUTdelayTimer.isActive():
self.CPUTdelayTimer.stop()
def GPUTTimer_timeout_handle(self):
currentfre = random.randint(0, 100)
self._GPUTvalue = currentfre
self.GPUTdelayTimer.start(5)
def FAN1Timer_timeout_handle(self):
currentfre = random.randint(0, 100)
self._FAN1SPeedCurRPM = currentfre
self._FAN1SpeedPercent = int(self._FAN1SPeedCurRPM / self._FAN1SpeedMaxRPM * 100)
self.FAN1delayTimer.start(5)
def setFAN1SpeedTimer(self, flag):
if flag is True:
self.FAN1Timer.start(2000)
else:
self.FAN1Timer.stop()
def FAN1delayTimer_timeout_handle(self):
self.FAN1SpeedLabel.setText("{}".format(self._FAN1SPeedCurRPM) + " RPM")
if self._FAN1SpeedPercent > self.FAN1SpeedPro.value():
self.FAN1SpeedPro.setValue(self.FAN1SpeedPro.value() + 1)
if self._FAN1SpeedPercent == self.FAN1SpeedPro.value():
if self.FAN1delayTimer.isActive():
self.FAN1delayTimer.stop()
elif self._FAN1SpeedPercent < self.FAN1SpeedPro.value():
pass
self.FAN1SpeedPro.setValue(self.FAN1SpeedPro.value() - 1)
if self._FAN1SpeedPercent == self.FAN1SpeedPro.value():
if self.FAN1delayTimer.isActive():
self.FAN1delayTimer.stop()
elif self.FAN1delayTimer.isActive():
self.FAN1delayTimer.stop()
def FAN2Timer_timeout_handle(self):
currentfre = random.randint(0, 100)
self._FAN2SPeedCurRPM = currentfre
self._FAN2SpeedPercent = int(self._FAN2SPeedCurRPM / self._FAN2SpeedMaxRPM * 100)
self.FAN2delayTimer.start(5)
def setFAN2SpeedTimer(self, flag):
if flag is True:
self.FAN2Timer.start(2000)
else:
self.FAN2Timer.stop()
def FAN2delayTimer_timeout_handle(self):
self.FAN2SpeedLabel.setText("{}".format(self._FAN2SPeedCurRPM) + " RPM")
if self._FAN2SpeedPercent > self.FAN2SpeedPro.value():
self.FAN2SpeedPro.setValue(self.FAN2SpeedPro.value() + 1)
if self._FAN2SpeedPercent == self.FAN2SpeedPro.value():
if self.FAN2delayTimer.isActive():
self.FAN2delayTimer.stop()
elif self._FAN2SpeedPercent < self.FAN2SpeedPro.value():
pass
self.FAN2SpeedPro.setValue(self.FAN2SpeedPro.value() - 1)
if self._FAN2SpeedPercent == self.FAN2SpeedPro.value():
if self.FAN2delayTimer.isActive():
self.FAN2delayTimer.stop()
elif self.FAN2delayTimer.isActive():
self.FAN2delayTimer.stop()
def GetPowerModeInitialNize(self):
self.GetPowerModeRes = GetPowerMode()
if self.ModeNum == 1:
if self.GetPowerModeRes == 2:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
self.switchLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 2))
self.switchLabel.setScaledContents(True)
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
elif self.ModeNum == 2:
pass
if self.GetPowerModeRes == 2:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.switchLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 2))
self.switchLabel.setScaledContents(True)
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
elif self.GetPowerModeRes == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetClicked2)
self.switchLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 2))
self.switchLabel.setScaledContents(True)
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceMode.png"))
elif self.ModeNum == 3:
if self.GetPowerModeRes == 2:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetClicked)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.switchLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 2))
self.switchLabel.setScaledContents(True)
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/SilenceMode.png"))
elif self.GetPowerModeRes == 0:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetClicked1)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetInit2)
self.switchLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 2))
self.switchLabel.setScaledContents(True)
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/BalanceMode.png"))
elif self.GetPowerModeRes == 1:
self.ModebtnSilence.setStyleSheet(self.ModeStyleSheetInit)
self.ModebtnBalance.setStyleSheet(self.ModeStyleSheetInit1)
self.ModebtnPerfermence.setStyleSheet(self.ModeStyleSheetClicked2)
self.switchLabel.setFixedSize(int(ui_sY / 2), int(ui_sY / 2))
self.switchLabel.setScaledContents(True)
self.switchLabel.setPixmap(QtGui.QPixmap("./imgs/PerformenceMode.png"))
def left_button1_clicked(self):
self.right_stacked_Widget.setCurrentIndex(0)
self.recommend_button_1.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.recommend_button_2.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_4.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_5.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_1.setIcon(QtGui.QIcon("./imgs/Mode.png"))
self.recommend_button_2.setIcon(QtGui.QIcon("./imgs/Fangray.png"))
self.recommend_button_4.setIcon(QtGui.QIcon("./imgs/Regulargray.png"))
self.recommend_button_5.setIcon(QtGui.QIcon("./imgs/SysInfogray.png"))
def left_button2_clicked(self):
self.right_stacked_Widget.setCurrentIndex(1)
self.recommend_button_1.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_2.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.recommend_button_4.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_5.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_1.setIcon(QtGui.QIcon("./imgs/Modegray.png"))
self.recommend_button_2.setIcon(QtGui.QIcon("./imgs/Fan.png"))
self.recommend_button_4.setIcon(QtGui.QIcon("./imgs/Regulargray.png"))
self.recommend_button_5.setIcon(QtGui.QIcon("./imgs/SysInfogray.png"))
def left_button4_clicked(self):
self.right_stacked_Widget.setCurrentIndex(2)
self.recommend_button_1.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_2.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_4.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.recommend_button_5.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_1.setIcon(QtGui.QIcon("./imgs/Modegray.png"))
self.recommend_button_2.setIcon(QtGui.QIcon("./imgs/Fangray.png"))
self.recommend_button_4.setIcon(QtGui.QIcon("./imgs/Regular.png"))
self.recommend_button_5.setIcon(QtGui.QIcon("./imgs/SysInfogray.png"))
def left_button5_clicked(self):
self.right_stacked_Widget.setCurrentIndex(3)
self.recommend_button_1.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_2.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_4.setStyleSheet("QToolButton{border:none;}")
self.recommend_button_5.setStyleSheet("QToolButton{border:none;color:#41aa94}")
self.recommend_button_1.setIcon(QtGui.QIcon("./imgs/Modegray.png"))
self.recommend_button_2.setIcon(QtGui.QIcon("./imgs/Fangray.png"))
self.recommend_button_4.setIcon(QtGui.QIcon("./imgs/Regulargray.png"))
self.recommend_button_5.setIcon(QtGui.QIcon("./imgs/SysInfo.png"))
def PCInfoGet(infoqueue):
try:
c = wmi.WMI()
sys1 = c.Win32_OperatingSystem()[0]
processor = c.Win32_Processor()[0]
ssd1 = c.Win32_DiskDrive()[0]
memory = c.Win32_PhysicalMemory()[0]
for bios_id in c.Win32_BIOS():
biosidstr = bios_id.Version
break
mem = str(round(float(psutil.virtual_memory().total) / 1024.0 / 1024.0 / 1024.0, 1)) + "GB"
hDC = win32gui.GetDC(0)
w = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
h = win32print.GetDeviceCaps(hDC, win32con.DESKTOPVERTRES)
screen_scale_rate = str(int(round(w / sX, 2) * 100)) + "%"
sysinfo, versionnum, sysbit, cpuinfo, boardinfo, biosversion, meminfo, diplay, ssdinfo, memoeysp = (sys1.Caption, platform.version(), sys1.OSArchitecture, processor.Name.strip(),
c.Win32_BaseBoard()[0].Product, biosidstr, mem,
"分辨率 " + str(w) + "x" + str(h) + " 缩放比例 " + screen_scale_rate, ssd1.Caption, memory.Speed)
infoqueue.put(sysinfo)
infoqueue.put(versionnum)
infoqueue.put(sysbit)
infoqueue.put(cpuinfo)
infoqueue.put(boardinfo)
infoqueue.put(biosversion)
infoqueue.put(meminfo)
infoqueue.put(diplay)
except:
print("获取设备基本信息异常")
class MySplashScreen(QSplashScreen):
def mousePressEvent(self, event):
return
import ctypes
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
from PyQt5.QtCore import Qt
if __name__ == "__main__":
if is_admin():
multiprocessing.freeze_support()
sX = win32api.GetSystemMetrics(0)
hDC = win32gui.GetDC(0)
w = win32print.GetDeviceCaps(hDC, win32con.DESKTOPHORZRES)
h = win32print.GetDeviceCaps(hDC, win32con.DESKTOPVERTRES)
ui_sX = int(w * 7 / 18)
ui_sY = int(h * 7 / 18)
print(w)
print(h)
print("ui_sx", ui_sX)
print("ui_sy", ui_sY)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
app.setStyleSheet(StyleSheet)
font = QFont("Microsoft YaHei")
pointsize = font.pointSize()
font.setPixelSize(int(pointsize * 90 / 73))
app.setFont(font)
mainWnd = FramelessWindow()
mainWnd.setWindowTitle("ControlCenter")
mainWnd.setWindowIcon(QIcon("./imgs/ICO.ico"))
mainWnd.resize(QSize(ui_sX, ui_sY))
centerWidget = MainWindow(mainWnd)
mainWnd.setWidget(centerWidget)
mainWnd.show()
sys.exit(app.exec_())
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
# okay decompiling ControlCenter.pyc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment