mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 08:34:13 +08:00
highdpi
This commit is contained in:
parent
a1616f9130
commit
5c4bdda3f0
@ -1,6 +1,7 @@
|
||||
import sys
|
||||
from PyQt5.QtCore import QCoreApplication ,Qt
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtGui import QFont
|
||||
import platform,os
|
||||
|
||||
if __name__ == "__main__" :
|
||||
@ -42,7 +43,14 @@ if __name__ == "__main__" :
|
||||
|
||||
gobject.overridepathexists()
|
||||
|
||||
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
|
||||
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
|
||||
font=QFont()
|
||||
font.setStyleStrategy(QFont.StyleStrategy.PreferAntialias)
|
||||
font.setHintingPreference(QFont.HintingPreference.PreferFullHinting)
|
||||
QApplication.setFont(font)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
app.setQuitOnLastWindowClosed(False)
|
||||
|
||||
|
@ -2,7 +2,6 @@ from myutils.config import globalconfig
|
||||
import sqlite3,os
|
||||
import winsharedutils,re
|
||||
from myutils.utils import argsort,autosql
|
||||
from traceback import print_exc
|
||||
class edict():
|
||||
def __init__(self):
|
||||
self.sql=None
|
||||
|
@ -85,7 +85,7 @@ class autoinitdialog(QDialog):
|
||||
lineW.addWidget(e)
|
||||
lineW.addWidget(bu)
|
||||
elif line['t']=='switch':
|
||||
lineW=MySwitch(parent.rate,sign=dd[key])
|
||||
lineW=MySwitch(sign=dd[key])
|
||||
regist.append([dd,key,lineW.isChecked])
|
||||
elif line['t']=='spin':
|
||||
lineW=QDoubleSpinBox()
|
||||
@ -143,14 +143,14 @@ class multicolorset(QDialog):
|
||||
|
||||
hori.addWidget(l)
|
||||
|
||||
b=MySwitch(parent.rate,sign=globalconfig['cixingcolorshow'][k] )
|
||||
b=MySwitch(sign=globalconfig['cixingcolorshow'][k] )
|
||||
b.clicked.connect(functools.partial(globalconfig['cixingcolorshow'].__setitem__,k))
|
||||
|
||||
|
||||
|
||||
p=QPushButton(qtawesome.icon("fa.paint-brush", color=globalconfig['cixingcolor'][k]), "" )
|
||||
|
||||
p.setIconSize(QSize(20*parent.rate,20*parent.rate))
|
||||
p.setIconSize(QSize(20,20))
|
||||
|
||||
p.setStyleSheet("background: transparent;")
|
||||
p.clicked.connect(functools.partial(selectcolor,self,globalconfig['cixingcolor'],k,p))
|
||||
|
@ -1,15 +1,14 @@
|
||||
|
||||
from PyQt5.QtCore import Qt,QSize,pyqtSignal
|
||||
from PyQt5.QtWidgets import QColorDialog,QSpinBox,QDoubleSpinBox,QPushButton,QComboBox,QLabel,QScrollArea,QWidget,QGridLayout,QApplication,QTabBar,QVBoxLayout
|
||||
from PyQt5.QtGui import QColor ,QResizeEvent
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QLabel,QScrollArea,QWidget,QGridLayout,QVBoxLayout
|
||||
from PyQt5.QtGui import QResizeEvent
|
||||
from PyQt5.QtWidgets import QTabWidget
|
||||
import qtawesome
|
||||
import functools,time
|
||||
import qtawesome
|
||||
import functools
|
||||
from traceback import print_exc
|
||||
from myutils.config import globalconfig ,_TR
|
||||
from myutils.utils import wavmp3player
|
||||
from myutils.config import globalconfig
|
||||
from myutils.hwnd import getScreenRate
|
||||
from myutils.config import globalconfig
|
||||
from gui.settingpage1 import setTabOne,setTabOne_direct
|
||||
from gui.settingpage2 import setTabTwo,settab2d
|
||||
from gui.settingpage_xianshishezhi import setTabThree ,setTabThree_direct
|
||||
@ -77,7 +76,7 @@ class Settin(closeashidewindow) :
|
||||
if save:
|
||||
savelist.append(ll)
|
||||
|
||||
grid.setRowMinimumHeight(nowr,int(35*self.rate))
|
||||
grid.setRowMinimumHeight(nowr,35)
|
||||
self.needfitcols.append([grid,maxl])
|
||||
|
||||
def __init__(self, parent):
|
||||
@ -92,13 +91,11 @@ class Settin(closeashidewindow) :
|
||||
|
||||
|
||||
self.setMinimumSize(100,100)
|
||||
# 界面缩放比例
|
||||
self.rate = getScreenRate()
|
||||
# 界面尺寸
|
||||
self.window_width = int((900 if globalconfig['languageuse']==0 else 1200)*self.rate)
|
||||
self.window_width = 900 if globalconfig['languageuse']==0 else 1200
|
||||
|
||||
self.window_height = int(500*self.rate)
|
||||
self.scrollwidth=20*self.rate
|
||||
self.window_height = 500
|
||||
self.scrollwidth=20
|
||||
self.savelastrect=None
|
||||
|
||||
|
||||
@ -136,7 +133,7 @@ class Settin(closeashidewindow) :
|
||||
width: %spx;
|
||||
height: %spx;
|
||||
font:%spt ; }
|
||||
'''%(50*self.rate,self.window_width*0.2,globalconfig['tabfont_chs'] if globalconfig['languageuse']==0 else globalconfig['tabfont_otherlang'] )
|
||||
'''%(50,self.window_width*0.2,globalconfig['tabfont_chs'] if globalconfig['languageuse']==0 else globalconfig['tabfont_otherlang'] )
|
||||
)
|
||||
self.tab_widget.setTabPosition(QTabWidget.West)
|
||||
setTabOne(self)
|
||||
@ -171,7 +168,7 @@ class Settin(closeashidewindow) :
|
||||
gridlayoutwidget.setLayout(gridlay)
|
||||
gridlayoutwidget.setStyleSheet("gridwidget{background-color:transparent;}")
|
||||
self.needfitwidgets.append(gridlayoutwidget)
|
||||
gridlayoutwidget.setFixedHeight(int(len(grid)*35*self.rate))
|
||||
gridlayoutwidget.setFixedHeight(len(grid)*35)
|
||||
margins=gridlay.contentsMargins()
|
||||
gridlay.setContentsMargins(margins.left(),0,margins.right(),0)
|
||||
self.automakegrid(gridlay,grid,save,savelist )
|
||||
|
@ -557,7 +557,7 @@ class Textbrowser( ):
|
||||
else:
|
||||
x=tl1.x()/2+tl2.x()/2-w/2
|
||||
y=tl2.y()-fh
|
||||
y+=globalconfig['buttonsize']*1.5 *self.parent.rate
|
||||
y+=globalconfig['buttonsize']*1.5
|
||||
y+=self.jiaming_y_delta
|
||||
|
||||
label.move(int(x),int(y))
|
||||
|
@ -19,7 +19,7 @@ import winsharedutils,queue
|
||||
from myutils.config import globalconfig,saveallconfig,_TR
|
||||
from myutils.subproc import endsubprocs
|
||||
from myutils.ocrutil import ocr_run,imageCut
|
||||
from myutils.hwnd import mouseselectwindow ,showintab,getScreenRate,grabwindow,getExeIcon
|
||||
from myutils.hwnd import mouseselectwindow ,showintab,grabwindow,getExeIcon
|
||||
from gui.dialog_savedgame import dialog_savedgame,dialog_savedgame_new
|
||||
from gui.dialog_memory import dialog_memory
|
||||
from gui.textbrowser import Textbrowser
|
||||
@ -69,7 +69,6 @@ class QUnFrameWindow(resizableframeless):
|
||||
except:
|
||||
pass
|
||||
self.move(self.pos().x()+ other[0],self.pos().y()+ other[1])
|
||||
#self.move(self.pos().x()+self.rate *other[0],self.pos().y()+self.rate *other[1])
|
||||
|
||||
def showres(self,name,color,res,onlyshowhist):
|
||||
try:
|
||||
@ -199,7 +198,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
"locktoolsbutton": globalconfig['locktools'], "hideocrrange": self.showhidestate, "bindwindow": self.isbindedwindow, "keepontop": globalconfig['keepontop']}
|
||||
onstatecolor="#FF69B4"
|
||||
|
||||
self._TitleLabel.setFixedHeight(int(globalconfig['buttonsize']*1.5*self.rate) )
|
||||
self._TitleLabel.setFixedHeight(int(globalconfig['buttonsize']*1.5) )
|
||||
for i in range(len(self.buttons)):
|
||||
name=self.buttons[i].name
|
||||
if name in colorstate:
|
||||
@ -211,17 +210,16 @@ class QUnFrameWindow(resizableframeless):
|
||||
else:
|
||||
icon=globalconfig['toolbutton']['buttons'][name]['icon']
|
||||
self.buttons[i].setIcon(qtawesome.icon(icon,color=color))#(icon[i])
|
||||
self.buttons[i].resize(int(globalconfig['buttonsize']*2 *self.rate),int(globalconfig['buttonsize']*1.5*self.rate))
|
||||
self.buttons[i].resize(int(globalconfig['buttonsize']*2),int(globalconfig['buttonsize']*1.5))
|
||||
|
||||
if self.buttons[i].adjast:
|
||||
self.buttons[i].adjast()
|
||||
self.buttons[i].setIconSize(QSize(int(globalconfig['buttonsize']*self.rate),
|
||||
int(globalconfig['buttonsize']*self.rate)))
|
||||
self.buttons[i].setIconSize(QSize(globalconfig['buttonsize'],globalconfig['buttonsize']))
|
||||
self.showhidetoolbuttons()
|
||||
self.translate_text.movep(0,globalconfig['buttonsize']*1.5*self.rate)
|
||||
self.translate_text.movep(0,globalconfig['buttonsize']*1.5)
|
||||
self.textAreaChanged()
|
||||
self.setMinimumHeight(int(globalconfig['buttonsize']*1.5*self.rate+10))
|
||||
self.setMinimumWidth(int(globalconfig['buttonsize']*2*self.rate))
|
||||
self.setMinimumHeight(int(globalconfig['buttonsize']*1.5+10))
|
||||
self.setMinimumWidth(globalconfig['buttonsize']*2)
|
||||
def addbuttons(self):
|
||||
def simulate_key_enter():
|
||||
windows.SetForegroundWindow(gobject.baseobject.textsource.hwnd)
|
||||
@ -376,7 +374,6 @@ class QUnFrameWindow(resizableframeless):
|
||||
self.lastrefreshtime=time.time()
|
||||
self.autohidestart=False
|
||||
threading.Thread(target=self.autohidedelaythread).start()
|
||||
self.rate = getScreenRate()
|
||||
self.muteprocessignal.connect(self.muteprocessfuntion)
|
||||
self.toolbarhidedelaysignal.connect(self.toolbarhidedelay)
|
||||
|
||||
@ -523,7 +520,7 @@ class QUnFrameWindow(resizableframeless):
|
||||
return
|
||||
newHeight = self.document.size().height()
|
||||
width = self.width()
|
||||
self.resize(width,int( 5+newHeight + globalconfig['buttonsize']*1.5*self.rate) )
|
||||
self.resize(width,int( 5+newHeight + globalconfig['buttonsize']*1.5) )
|
||||
|
||||
|
||||
def clickRange(self,auto):
|
||||
@ -578,9 +575,9 @@ class QUnFrameWindow(resizableframeless):
|
||||
def resizeEvent(self, e):
|
||||
super().resizeEvent(e);
|
||||
wh=globalconfig['buttonsize'] *1.5
|
||||
height = self.height() - wh *self.rate
|
||||
height = self.height() - wh
|
||||
|
||||
self.translate_text.resize(self.width()-5, height * self.rate)
|
||||
self.translate_text.resize(self.width()-5, height )
|
||||
for button in self.buttons[-2:]:
|
||||
button.adjast( )
|
||||
# 自定义窗口调整大小事件
|
||||
|
@ -7,7 +7,7 @@ from PyQt5.QtWidgets import QColorDialog,QSpinBox,QDoubleSpinBox,QPushButton,QC
|
||||
from traceback import print_exc
|
||||
import qtawesome ,functools,gobject,threading
|
||||
from myutils.wrapper import Singleton
|
||||
from myutils.hwnd import getScreenRate,showintab
|
||||
from myutils.hwnd import showintab
|
||||
@Singleton
|
||||
class dialog_showinfo(QDialog):
|
||||
|
||||
@ -92,7 +92,7 @@ class closeashidewindow(saveposwindow):
|
||||
event.ignore()
|
||||
super().closeEvent(event)
|
||||
class MySwitch(QPushButton):
|
||||
def __init__(self,rate, parent = None,sign=True ,enable=True):
|
||||
def __init__(self, parent = None,sign=True ,enable=True):
|
||||
self.status1=0
|
||||
self.status2=0
|
||||
self.colors=[
|
||||
@ -111,10 +111,9 @@ class MySwitch(QPushButton):
|
||||
color: black;
|
||||
border: 0px;
|
||||
font: 100 10pt;''')
|
||||
self.rate= rate
|
||||
|
||||
self.clicked.connect(self.setChecked)
|
||||
self.setIconSize(QSize(int(25*self.rate),
|
||||
int(25*self.rate)))
|
||||
self.setIconSize(QSize(25,25))
|
||||
self.setEnabled(enable)
|
||||
self.setCheckable(True)
|
||||
self.setChecked(sign)
|
||||
@ -335,8 +334,7 @@ def getcolorbutton(d,key,callback,name=None,parent=None,icon="fa.paint-brush",co
|
||||
qicon=qtawesome.icon(icon, color=constcolor if constcolor else d[key])
|
||||
b=QPushButton(qicon, "" )
|
||||
b.setEnabled(enable)
|
||||
b.setIconSize(QSize(int(20*getScreenRate()),
|
||||
int(20*getScreenRate())))
|
||||
b.setIconSize(QSize(20,20))
|
||||
if transparent:
|
||||
b.setStyleSheet('''background-color: rgba(255, 255, 255, 0);
|
||||
color: black;
|
||||
@ -362,7 +360,7 @@ def getsimpleswitch(d,key,enable=True,callback=None,name=None,pair=None,parent=N
|
||||
if key not in d:
|
||||
d[key]=default
|
||||
|
||||
b=MySwitch(getScreenRate(),sign=d[key],enable=enable)
|
||||
b=MySwitch(sign=d[key],enable=enable)
|
||||
b.clicked.connect(functools.partial(callbackwrap,d,key,callback) )
|
||||
|
||||
if pair:
|
||||
|
@ -4,10 +4,8 @@ from PyQt5.QtGui import QPixmap,QColor ,QIcon
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
import gobject
|
||||
import os
|
||||
import time,winrtutils,winsharedutils,base64,hashlib
|
||||
import time,winrtutils,winsharedutils,hashlib
|
||||
from myutils.wrapper import threader
|
||||
from myutils.utils import argsort
|
||||
from traceback import print_exc
|
||||
def pid_running(pid):
|
||||
try:
|
||||
process =windows.AutoHandle(windows.OpenProcess(windows.SYNCHRONIZE, False, pid))
|
||||
@ -57,11 +55,13 @@ def grabwindow():
|
||||
_()
|
||||
_=windows.GetClientRect(hwnd)
|
||||
rate=dynamic_rate(hwnd,_)
|
||||
h,w= int(_[2]/rate),int(_[3]/rate)
|
||||
p=QApplication.primaryScreen().grabWindow(hwnd,0,0,h,w)
|
||||
if(not p.toImage().allGray()):
|
||||
w,h= int(_[2]/rate),int(_[3]/rate)
|
||||
print(_)
|
||||
print(h,w,rate)
|
||||
p=QApplication.primaryScreen().grabWindow(hwnd,0,0,w,h)
|
||||
p=p.toImage().copy(0,0,w,h)
|
||||
if(not p.allGray()):
|
||||
p.save(fname+'_gdi.png')
|
||||
|
||||
gobject.baseobject.translation_ui.displaystatus.emit("saved to "+fname,'red',True,True)
|
||||
def dynamic_rate(hwnd,rect):
|
||||
if(getscreenp()==(rect[2],rect[3])):
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version":"v2.36.3",
|
||||
"version":"v2.36.4",
|
||||
"language_list_show":["简体中文","日本語","English","Русский язык","Español","한국어","Français","繁體中文","Tiếng Việt","Türkçe","Polski","Українська Мова","Italiano","اللغة العربية","ภาษาไทย"] ,
|
||||
"language_list_translator":["简体中文","日文","英文","俄语","西班牙语","韩语","法语","繁体中文","越南语","土耳其语","波兰语","乌克兰语","意大利语","阿拉伯语","泰语"],
|
||||
"language_list_translator_inner":["zh", "ja", "en","ru","es","ko","fr","cht","vi","tr","pl","uk","it","ar","th"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user