This commit is contained in:
恍兮惚兮 2024-06-10 01:07:46 +08:00
parent 7f9b4c657e
commit 1294f4fee5
8 changed files with 31 additions and 13 deletions

View File

@ -3,7 +3,7 @@ import functools
from myutils.utils import checkencoding
from myutils.config import globalconfig, _TR, _TRL
from myutils.wrapper import Singleton
from gui.usefulwidget import getspinbox, threebuttons, getlineedit
from gui.usefulwidget import getspinbox, threebuttons, getlineedit, FocusCombo
nowsuppertcodes = _TRL(
[
@ -62,7 +62,7 @@ class codeacceptdialog(QDialog):
itemsaver = QStandardItem()
self.model.setItem(row, 0, itemsaver)
index = self.model.index(row, 0)
codecombox = QComboBox()
codecombox = FocusCombo()
codecombox.addItems((nowsuppertcodes))
codecombox.setCurrentIndex(idx)
self.table.setIndexWidget(index, codecombox)
@ -109,7 +109,7 @@ class codeacceptdialog(QDialog):
def clicked1(self):
itemsaver = QStandardItem()
self.model.insertRow(0, [itemsaver])
codecombox = QComboBox()
codecombox = FocusCombo()
codecombox.addItems((nowsuppertcodes))
self._setcode_i(codecombox, itemsaver)
codecombox.currentIndexChanged.connect(

View File

@ -40,6 +40,7 @@ from gui.specialwidget import (
)
from gui.usefulwidget import (
yuitsu_switch,
FocusCombo,
saveposwindow,
getsimplepatheditor,
getboxlayout,
@ -322,7 +323,7 @@ class TagWidget(QWidget):
self.setLayout(layout)
self.lineEdit = QComboBox()
self.lineEdit = FocusCombo()
self.lineEdit.setLineEdit(QLineEdit())
self.lineEdit.lineEdit().returnPressed.connect(

View File

@ -12,7 +12,8 @@ from gui.usefulwidget import (
listediterline,
getsimplepatheditor,
FocusSpin,
FocusDoubleSpin
FocusDoubleSpin,
FocusCombo
)
@ -228,7 +229,7 @@ class autoinitdialog(QDialog):
lineW = QHBoxLayout()
lineW.addWidget(e)
elif line["type"] == "combo":
lineW = QComboBox()
lineW = FocusCombo()
if "list_function" in line:
try:
func = getattr(

View File

@ -3,7 +3,7 @@ import sqlite3, os, json, functools
from traceback import print_exc
from myutils.config import globalconfig, _TR
from myutils.utils import autosql
from gui.usefulwidget import getQMessageBox
from gui.usefulwidget import getQMessageBox, FocusCombo
def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
@ -47,7 +47,7 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
formLayout = QFormLayout(dialog) # 配置layout
dialog.setLayout(formLayout)
combo = QComboBox()
combo = FocusCombo()
combo.addItems([globalconfig["fanyi"][_]["name"] for _ in collect])
formLayout.addRow(_TR("首选翻译"), combo)

View File

@ -13,7 +13,8 @@ from gui.usefulwidget import (
getsimplecombobox,
getsimpleswitch,
textbrowappendandmovetoend,
FocusSpin
FocusSpin,
FocusCombo
)
@ -263,7 +264,7 @@ class searchhookparam(QDialog):
if len(_list) == 0:
regwid = addwid = line
else:
combo = QComboBox()
combo = FocusCombo()
combo.addItems(_list)
combo.setLineEdit(line)

View File

@ -25,6 +25,7 @@ from gui.usefulwidget import (
D_getsimpleswitch,
makesubtab_lazy,
makescrollgrid,
FocusCombo
)
@ -211,7 +212,7 @@ def getunknowgameexe(self):
formLayout = QFormLayout(dialog)
dialog.setLayout(formLayout)
combo = QComboBox()
combo = FocusCombo()
combo.addItems([savehook_new_data[_]["title"] for _ in savehook_new_list])
formLayout.addRow(_TR("选择游戏"), combo)

View File

@ -9,6 +9,7 @@ from gui.usefulwidget import (
makescrollgrid,
D_getcolorbutton,
yuitsu_switch,
FocusCombo,
D_getsimpleswitch,
)
@ -34,7 +35,7 @@ def changevoice(self, text):
def createvoicecombo(self):
self.voicecombo = QComboBox()
self.voicecombo = FocusCombo()
self.voicecombo.currentTextChanged.connect(lambda x: changevoice(self, x))
try:
vl, idx = self.voicecombo_cache

View File

@ -12,6 +12,19 @@ from myutils.config import _TR, globalconfig
from myutils.wrapper import Singleton, Singleton_close
class FocusCombo(QComboBox):
def __init__(self, parent: QWidget = None) -> None:
super().__init__(parent)
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
def wheelEvent(self, e: QWheelEvent) -> None:
if not self.hasFocus():
e.ignore()
return
else:
return super().wheelEvent(e)
class FocusSpin(QSpinBox):
def __init__(self, parent: QWidget = None) -> None:
super().__init__(parent)
@ -412,7 +425,7 @@ def comboboxcallbackwrap(internallist, d, k, call, _):
def getsimplecombobox(lst, d, k, callback=None, fixedsize=False, internallist=None):
s = QComboBox()
s = FocusCombo()
s.addItems(lst)
if internallist: