This commit is contained in:
恍兮惚兮 2024-05-16 15:05:14 +08:00
parent 8a4b868099
commit daef84823f
19 changed files with 147 additions and 50 deletions

View File

@ -182,16 +182,15 @@ class regexedit(QDialog):
self.apply()
def autoinitdialog_items(dict):
def autoinitdialog_items(dic):
items = []
for arg in dict["args"]:
items.append({"l": arg, "d": dict["args"], "k": arg})
if "argstype" in dict and arg in dict["argstype"]:
for arg in dic["args"]:
default = dict(name=arg, d=dic["args"], k=arg, type="lineedit")
items[-1].update(dict["argstype"][arg])
else:
items[-1].update({"t": "lineedit"})
items.append({"t": "okcancel"})
if "argstype" in dic and arg in dic["argstype"]:
default.update(dic["argstype"][arg])
items.append(default)
items.append({"type": "okcancel"})
return items
@ -233,20 +232,18 @@ class autoinitdialog(QDialog):
edit.setText(res)
for line in lines:
if "type" in line:
line["t"] = line["type"]
if "d" in line:
dd = line["d"]
if "k" in line:
key = line["k"]
if line["t"] == "label":
if line["type"] == "label":
if "islink" in line and line["islink"]:
lineW = QLabel(makehtml(dd[key]))
lineW.setOpenExternalLinks(True)
else:
lineW = QLabel(_TR(dd[key]))
elif line["t"] == "combo":
elif line["type"] == "combo":
lineW = QComboBox()
if "list_function" in line:
try:
@ -264,7 +261,7 @@ class autoinitdialog(QDialog):
lineW.currentIndexChanged.connect(
functools.partial(dd.__setitem__, key)
)
elif line["t"] == "okcancel":
elif line["type"] == "okcancel":
lineW = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
lineW.rejected.connect(self.close)
lineW.accepted.connect(
@ -275,10 +272,10 @@ class autoinitdialog(QDialog):
lineW.button(QDialogButtonBox.Ok).setText(_TR("确定"))
lineW.button(QDialogButtonBox.Cancel).setText(_TR("取消"))
elif line["t"] == "lineedit":
elif line["type"] == "lineedit":
lineW = QLineEdit(dd[key])
regist.append([dd, key, lineW.text])
elif line["t"] == "file":
elif line["type"] == "file":
e = QLineEdit(dd[key])
regist.append([dd, key, e.text])
bu = QPushButton(_TR("选择" + ("文件夹" if line["dir"] else "文件")))
@ -294,10 +291,10 @@ class autoinitdialog(QDialog):
lineW = QHBoxLayout()
lineW.addWidget(e)
lineW.addWidget(bu)
elif line["t"] == "switch":
elif line["type"] == "switch":
lineW = MySwitch(sign=dd[key])
regist.append([dd, key, lineW.isChecked])
elif line["t"] == "spin":
elif line["type"] == "spin":
lineW = QDoubleSpinBox()
lineW.setMinimum(0 if "min" not in line else line["min"])
lineW.setMaximum(100 if "max" not in line else line["max"])
@ -305,15 +302,15 @@ class autoinitdialog(QDialog):
lineW.setValue(dd[key])
lineW.valueChanged.connect(functools.partial(dd.__setitem__, key))
elif line["t"] == "intspin":
elif line["type"] == "intspin":
lineW = QSpinBox()
lineW.setMinimum(0 if "min" not in line else line["min"])
lineW.setMaximum(100 if "max" not in line else line["max"])
lineW.setSingleStep(1 if "step" not in line else line["step"])
lineW.setValue(dd[key])
lineW.valueChanged.connect(functools.partial(dd.__setitem__, key))
if "l" in line:
formLayout.addRow(_TR(line["l"]), lineW)
if "name" in line:
formLayout.addRow(_TR(line["name"]), lineW)
else:
formLayout.addRow(lineW)
self.show()
@ -327,8 +324,15 @@ def getsomepath1(
title,
800,
[
{"t": "file", "l": label, "d": d, "k": k, "dir": isdir, "filter": filter1},
{"t": "okcancel", "callback": callback},
{
"type": "file",
"name": label,
"d": d,
"k": k,
"dir": isdir,
"filter": filter1,
},
{"type": "okcancel", "callback": callback},
],
)

View File

@ -206,14 +206,14 @@ def setTabTwo_lazy(self):
]
_items = [
{
"t": "file",
"type": "file",
"dir": False,
"filter": "*.exe",
"l": "Chromium_路径",
"name": "Chromium_路径",
"d": globalconfig,
"k": "chromepath",
},
{"t": "okcancel"},
{"type": "okcancel"},
]
developgrid = [

View File

@ -39,7 +39,6 @@ from gui.rangeselect import rangeselct_function
class AnkiWindow(QWidget):
setcurrenttext = pyqtSignal(str)
__ocrsettext = pyqtSignal(str)
refreshhtml = pyqtSignal()
@ -67,7 +66,8 @@ class AnkiWindow(QWidget):
img.save(fname)
self.editpath.setText("")
self.editpath.setText(os.path.abspath(fname))
self.asyncocr(fname)
if globalconfig["ankiconnect"]["ocrcroped"]:
self.asyncocr(fname)
rangeselct_function(self, ocroncefunction, False, False)
@ -250,7 +250,7 @@ class AnkiWindow(QWidget):
wid = QWidget()
wid.setLayout(layout)
layout.addRow(
_TR("port"), getspinbox(0, 65536, globalconfig["ankiconnect"], "port")
_TR("端口号"), getspinbox(0, 65536, globalconfig["ankiconnect"], "port")
)
layout.addRow(
_TR("DeckName"), getlineedit(globalconfig["ankiconnect"], "DeckName")
@ -260,13 +260,17 @@ class AnkiWindow(QWidget):
)
layout.addRow(
_TR("allowDuplicate"),
_TR("允许重复"),
getsimpleswitch(globalconfig["ankiconnect"], "allowDuplicate"),
)
layout.addRow(
_TR("autoUpdateModel"),
_TR("添加时更新模板"),
getsimpleswitch(globalconfig["ankiconnect"], "autoUpdateModel"),
)
layout.addRow(
_TR("截图后进行OCR"),
getsimpleswitch(globalconfig["ankiconnect"], "ocrcroped"),
)
return wid
@ -368,9 +372,7 @@ class AnkiWindow(QWidget):
btn.clicked.connect(self.errorwrap)
layout.addWidget(btn)
self.setcurrenttext.connect(self.reset)
self.__ocrsettext.connect(self.example.insertPlainText)
self.__ocrsettext.connect(self.example.appendPlainText)
self.reset("")
return wid
@ -621,12 +623,13 @@ class searchwordW(closeashidewindow):
sentence = self.searchtext.text() + sentence
self.searchtext.setText(sentence)
self.ankiwindow.example.setPlainText(gobject.baseobject.currenttext)
self.search(sentence)
def search(self, sentence):
if sentence == "":
return
self.ankiwindow.setcurrenttext.emit(sentence)
self.ankiwindow.reset(sentence)
for i in range(self.tab.count()):
self.tab.removeTab(0)
self.tabks.clear()

View File

@ -181,7 +181,8 @@
"DeckName": "lunadeck",
"ModelName2": "lunamodel2",
"allowDuplicate": true,
"autoUpdateModel": true
"autoUpdateModel": true,
"ocrcroped": false
},
"ankiwindow": [
100,
@ -686,10 +687,12 @@
"argstype": {
"path": {
"type": "file",
"name": "路径",
"dir": true
},
"codec": {
"type": "combo",
"name": "编码",
"list": [
"utf8",
"shiftjis"
@ -718,11 +721,13 @@
"argstype": {
"path": {
"type": "file",
"name": "路径",
"dir": false,
"filter": "*.db"
},
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -741,11 +746,13 @@
"argstype": {
"path": {
"type": "file",
"name": "路径",
"dir": false,
"filter": "*.db"
},
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -762,10 +769,12 @@
"argstype": {
"path": {
"type": "file",
"name": "路径",
"dir": false
},
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -782,10 +791,12 @@
"argstype": {
"path": {
"type": "file",
"name": "路径",
"dir": true
},
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -801,6 +812,7 @@
"argstype": {
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -816,6 +828,7 @@
"argstype": {
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -831,6 +844,7 @@
"argstype": {
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1
@ -846,6 +860,7 @@
"argstype": {
"priority": {
"type": "intspin",
"name": "优先级",
"min": 0,
"max": 10000,
"step": 1

View File

@ -783,5 +783,10 @@
"样式": "نمط",
"恢复": "استعاد",
"模板": "قالب .",
"截图": "لقطة"
"截图": "لقطة",
"允许重复": "يسمح التكرار",
"添加时更新模板": "تحديث القالب عند إضافة",
"截图后进行OCR": "التعرف الضوئي على الحروف",
"优先级": "الأولوية",
"编码": "ترميز"
}

View File

@ -783,5 +783,10 @@
"样式": "樣式",
"恢复": "恢復",
"模板": "範本",
"截图": "截圖"
"截图": "截圖",
"允许重复": "允許重複",
"添加时更新模板": "添加時更新範本",
"截图后进行OCR": "截圖後進行OCR",
"优先级": "優先順序",
"编码": "編碼"
}

View File

@ -783,5 +783,10 @@
"样式": "style",
"恢复": "recovery",
"模板": "Template",
"截图": "screenshot"
"截图": "screenshot",
"允许重复": "Allow duplicates",
"添加时更新模板": "Update template when adding",
"截图后进行OCR": "Perform OCR after taking screenshots",
"优先级": "priority",
"编码": "coding"
}

View File

@ -783,5 +783,10 @@
"样式": "Estilo",
"恢复": "Recuperación",
"模板": "Plantilla",
"截图": "Captura de pantalla"
"截图": "Captura de pantalla",
"允许重复": "Permitir la repetición",
"添加时更新模板": "Actualizar la plantilla al agregar",
"截图后进行OCR": "OCR después de la captura de pantalla",
"优先级": "Prioridad",
"编码": "Codificación"
}

View File

@ -783,5 +783,10 @@
"样式": "Style",
"恢复": "Récupération",
"模板": "Modèle",
"截图": "Capture d'écran"
"截图": "Capture d'écran",
"允许重复": "Permettre la répétition",
"添加时更新模板": "Mettre à jour le modèle lorsque vous l'ajoutez",
"截图后进行OCR": "OCR après capture d'écran",
"优先级": "Priorité",
"编码": "Codage"
}

View File

@ -783,5 +783,10 @@
"样式": "stile",
"恢复": "recupero",
"模板": "Modello",
"截图": "screenshot"
"截图": "screenshot",
"允许重复": "Consenti duplicati",
"添加时更新模板": "Aggiorna modello quando aggiungi",
"截图后进行OCR": "Esegui OCR dopo aver scattato screenshot",
"优先级": "priorità",
"编码": "codifica"
}

View File

@ -783,5 +783,10 @@
"样式": "スタイル",
"恢复": "リカバリ",
"模板": "テンプレート",
"截图": "スクリーンショット"
"截图": "スクリーンショット",
"允许重复": "繰り返しを許可",
"添加时更新模板": "追加時にテンプレートを更新する",
"截图后进行OCR": "スクリーンショット後にOCR",
"优先级": "優先度",
"编码": "エンコード"
}

View File

@ -783,5 +783,10 @@
"样式": "스타일",
"恢复": "복구",
"模板": "템플릿",
"截图": "캡처"
"截图": "캡처",
"允许重复": "반복 허용",
"添加时更新模板": "추가 시 템플릿 업데이트",
"截图后进行OCR": "캡처해서 OCR 진행하도록 하겠습니다.",
"优先级": "우선 순위",
"编码": "인코딩"
}

View File

@ -783,5 +783,10 @@
"样式": "styl",
"恢复": "odzyskiwanie",
"模板": "Szablon",
"截图": "zrzut ekranu"
"截图": "zrzut ekranu",
"允许重复": "Zezwalaj na duplikaty",
"添加时更新模板": "Aktualizuj szablon podczas dodawania",
"截图后进行OCR": "Wykonanie OCR po wykonaniu zrzutów ekranu",
"优先级": "priorytet",
"编码": "kodowanie"
}

View File

@ -783,5 +783,10 @@
"样式": "Стиль",
"恢复": "Восстановление",
"模板": "Шаблоны:",
"截图": "Снимок экрана"
"截图": "Снимок экрана",
"允许重复": "Разрешить повторение",
"添加时更新模板": "Обновить шаблон при добавлении",
"截图后进行OCR": "Снимок экрана после OCR",
"优先级": "Приоритеты",
"编码": "Код"
}

View File

@ -783,5 +783,10 @@
"样式": "สไตล์",
"恢复": "การกู้คืน",
"模板": "เทมเพลต",
"截图": "ภาพหน้าจอ"
"截图": "ภาพหน้าจอ",
"允许重复": "อนุญาตให้ทำซ้ำ",
"添加时更新模板": "ปรับปรุงแม่แบบเมื่อคุณเพิ่ม",
"截图后进行OCR": "ทำ OCR หลังจากจับภาพหน้าจอ",
"优先级": "ลำดับความสำคัญ",
"编码": "การเข้ารหัส"
}

View File

@ -783,5 +783,10 @@
"样式": "stil",
"恢复": "iyileştirme",
"模板": "Şablon",
"截图": "ekran fotoğrafı"
"截图": "ekran fotoğrafı",
"允许重复": "Allow duplicates",
"添加时更新模板": "Eklence şablonu güncelle",
"截图后进行OCR": "Ekran fotoğraflarını aldıktan sonra OCR yap",
"优先级": "Prioritet",
"编码": "coding"
}

View File

@ -783,5 +783,10 @@
"样式": "стиль",
"恢复": "відновлення",
"模板": "Шаблон",
"截图": "знімок екрана"
"截图": "знімок екрана",
"允许重复": "Дозволити дублікати",
"添加时更新模板": "Оновити шаблон під час додавання",
"截图后进行OCR": "Виконати OCR після роботи знімків екрана",
"优先级": "пріоритет",
"编码": "кодування"
}

View File

@ -783,5 +783,10 @@
"样式": "Kiểu dáng",
"恢复": "Phục hồi",
"模板": "Mẫu",
"截图": "Ảnh chụp màn hình"
"截图": "Ảnh chụp màn hình",
"允许重复": "Cho phép lặp lại",
"添加时更新模板": "Cập nhật mẫu khi thêm",
"截图后进行OCR": "OCR sau khi chụp ảnh màn hình",
"优先级": "Ưu tiên",
"编码": "Mã hóa"
}

View File

@ -783,5 +783,10 @@
"样式": "",
"恢复": "",
"模板": "",
"截图": ""
"截图": "",
"允许重复": "",
"添加时更新模板": "",
"截图后进行OCR": "",
"优先级": "",
"编码": ""
}