Skip to content

Commit

Permalink
v1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dmMaze committed Aug 31, 2022
1 parent 49e3d24 commit 4b1d45a
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 36 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelogs

### 2022-08-31
[v1.3.4](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.3.4)发布

1. 添加离线日译英模型Sugoi Translator(仅日译英, 作者[mingshiba](https://www.patreon.com/mingshiba), 已获得集成授权), 感谢[@Snowad14](https://github.com/Snowad14)提供CT2转换模型
2. 来自[bropines](https://github.com/bropines)的俄语本地化支持
3. 文本编辑支持字距调节
4. 调整竖排符号及半角字符位置规则, 详见https://github.com/dmMaze/BallonsTranslator/pull/30

### 2022-08-17
[v1.3.0](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.3.0)发布

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG_EN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelogs

### 2022-08-31
[v1.3.4](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.3.4) released

1. Add Sugoi Translator(Japanese-English only, created & authorized by [mingshiba](https://www.patreon.com/mingshiba)): download the [model](https://drive.google.com/drive/folders/1KnDlfUM9zbnYFTo6iCbnBaBKabXfnVJm) converted by [@Snowad14](https://github.com/Snowad14) and put "sugoi_translator" in the "data" folder.
2. Add support for russian, thanks to [bropines](https://github.com/bropines)
3. Support letter spacing adjustment.
4. Vertical type rework & text rendering bug fixes: https://github.com/dmMaze/BallonsTranslator/pull/30

### 2022-08-17
[v1.3.0](https://github.com/dmMaze/BallonsTranslator/releases/tag/v1.3.0) released

Expand Down
2 changes: 1 addition & 1 deletion ballontranslator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# 1. MAJOR version when you make incompatible API changes;
# 2. MINOR version when you add functionality in a backwards-compatible manner;
# 3. PATCH version when you make backwards-compatible bug fixes.
__version__ = "1.3.0"
__version__ = "1.3.4"
14 changes: 7 additions & 7 deletions ballontranslator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ def main():
else:
os.environ['QT_API'] = args.qt_api

if sys.platform == 'win32':
import ctypes
myappid = u'BalloonsTranslator' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

import qtpy
from qtpy.QtWidgets import QApplication
from qtpy.QtCore import QTranslator, QLocale
from qtpy.QtGui import QIcon

from ui.mainwindow import MainWindow
from ui import constants

if sys.platform == 'win32':
import ctypes
myappid = u'BalloonsTranslator' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

if qtpy.API_NAME[-1] == '6':
constants.FLAG_QT6 = True

from ui.mainwindow import MainWindow

os.chdir(constants.PROGRAM_PATH)
app = QApplication(sys.argv)
Expand Down
2 changes: 1 addition & 1 deletion ballontranslator/scripts/build_win.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nuitka --standalone --mingw64 --nofollow-imports --show-memory --show-progress ^
--enable-plugin=pyqt5 --include-qt-plugins=sensible,styles ^
--follow-import-to=dl,utils,ui --include-plugin-directory=ballontranslator/dl,ballontranslator/ui,ballontranslator/utils ^
--windows-product-version=1.3.0.0 --windows-company-name=DUMMY_WINDOWS_COMPANY_NAME --windows-product-name=BallonTranslator ^
--windows-product-version=1.3.4.0 --windows-company-name=DUMMY_WINDOWS_COMPANY_NAME --windows-product-name=BallonTranslator ^
--output-dir=release BallonTranslator
19 changes: 14 additions & 5 deletions ballontranslator/ui/configpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
import json

from qtpy.QtWidgets import QLayout, QHBoxLayout, QVBoxLayout, QTreeView, QWidget, QLabel, QSizePolicy, QSpacerItem, QCheckBox, QSplitter, QScrollArea, QGroupBox, QLineEdit
from qtpy.QtCore import Qt, QModelIndex, Signal, QSize
from qtpy.QtCore import Qt, QModelIndex, Signal, QSize, QEvent, QItemSelection
from qtpy.QtGui import QStandardItem, QStandardItemModel, QMouseEvent, QFont, QColor, QPalette
from qtpy import QtCore

from . import constants as C


# nuitka seems to require import QtCore explicitly
if C.FLAG_QT6:
from PyQt6 import QtCore
else:
from PyQt5 import QtCore


from utils.logger import logger as LOGGER
from .stylewidgets import Widget, ConfigComboBox
Expand Down Expand Up @@ -55,9 +64,9 @@ def setIdx(self, idx0: int, idx1: int) -> None:
self.idx0 = idx0
self.idx1 = idx1

def enterEvent(self, a0: QtCore.QEvent) -> None:
def enterEvent(self, e: QEvent) -> None:
self.pressed.emit(self.idx0, self.idx1)
return super().enterEvent(a0)
return super().enterEvent(e)


class ConfigBlock(Widget):
Expand Down Expand Up @@ -224,7 +233,7 @@ def addHeader(self, header: str) -> TableItem:
rootNode.appendRow(ti)
return ti

def selectionChanged(self, selected: QtCore.QItemSelection, deselected: QtCore.QItemSelection) -> None:
def selectionChanged(self, selected: QItemSelection, deselected: QItemSelection) -> None:
dis = deselected.indexes()
sel = selected.indexes()
model = self.model()
Expand Down
7 changes: 0 additions & 7 deletions ballontranslator/ui/dlconfig_parse_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
from utils.logger import logger as LOGGER
from .stylewidgets import ConfigComboBox
from .constants import CONFIG_FONTSIZE_CONTENT, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT
from . import constants as c

from qtpy.QtWidgets import QHBoxLayout, QVBoxLayout, QWidget, QLabel, QComboBox, QListView, QToolBar, QMenu, QSpacerItem, QPushButton, QCheckBox, QToolButton, QSplitter, QStylePainter, QStyleOption, QStyle, QScrollArea, QLineEdit, QGroupBox, QGraphicsSimpleTextItem
from qtpy.QtCore import Qt, Signal
from qtpy.QtGui import QFontMetricsF
if c.FLAG_QT6:
from qtpy.QtGui import QAction
else:
from qtpy.QtWidgets import QAction




class ParamNameLabel(QLabel):
Expand Down
2 changes: 1 addition & 1 deletion ballontranslator/ui/drawingpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def on_inpaint_failed(self):
self.clearInpaintItems()

def on_canvasctrl_released(self):
if self.currentTool == self.inpaintTool:
if self.isVisible() and self.currentTool == self.inpaintTool:
self.runInpaint()

def on_begin_scale_tool(self, pos: QPointF):
Expand Down
2 changes: 1 addition & 1 deletion ballontranslator/ui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from qtpy.QtWidgets import QMainWindow, QHBoxLayout, QVBoxLayout, QApplication, QStackedWidget, QWidget, QSplitter, QListWidget, QShortcut, QListWidgetItem
from qtpy.QtCore import Qt, QPoint, QSize
from qtpy.QtGui import QGuiApplication, QIcon, QCloseEvent, QKeySequence, QImage, QPainter, QFont
from qtpy.QtGui import QKeyEvent, QGuiApplication, QIcon, QCloseEvent, QKeySequence, QImage, QPainter, QFont

from utils.logger import logger as LOGGER
from utils.io_utils import json_dump_nested_obj
Expand Down
22 changes: 12 additions & 10 deletions ballontranslator/ui/mainwindowbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

from .stylewidgets import Widget, PaintQSlider
from .constants import WINDOW_BORDER_WIDTH, BOTTOMBAR_HEIGHT, DRAG_DIR_NONE, DRAG_DIR_VER, DRAG_DIR_BDIAG, DRAG_DIR_FDIAG
from . import constants as c


from qtpy.QtWidgets import QMainWindow, QHBoxLayout, QVBoxLayout, QFileDialog, QLabel, QSizePolicy, QToolBar, QMenu, QSpacerItem, QPushButton, QCheckBox, QToolButton
from qtpy.QtCore import Qt, Signal, QPoint
from qtpy.QtGui import QMouseEvent, QKeySequence
if c.FLAG_QT6:

from . import constants as C
if C.FLAG_QT6:
from qtpy.QtGui import QAction
else:
from qtpy.QtWidgets import QAction
Expand Down Expand Up @@ -297,7 +299,7 @@ def stateCheckerChanged(self, checker_type: str):

def mouseMoveEvent(self, e: QMouseEvent) -> None:
if not self.mainwindow.isMaximized():
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = e.globalPosition().toPoint()
else:
g_pos = e.globalPos()
Expand All @@ -317,7 +319,7 @@ def mouseMoveEvent(self, e: QMouseEvent) -> None:
return super().mouseMoveEvent(e)

def mousePressEvent(self, e: QMouseEvent) -> None:
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = e.globalPosition().toPoint()
else:
g_pos = e.globalPos()
Expand Down Expand Up @@ -346,7 +348,7 @@ def __init__(self, mainwindow: QMainWindow):

def mouseMoveEvent(self, e: QMouseEvent) -> None:
if not self.mainwindow.isMaximized():
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = e.globalPosition().toPoint()
else:
g_pos = e.globalPos()
Expand All @@ -366,7 +368,7 @@ def mouseMoveEvent(self, e: QMouseEvent) -> None:
return super().mouseMoveEvent(e)

def mousePressEvent(self, e: QMouseEvent) -> None:
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = e.globalPosition().toPoint()
else:
g_pos = e.globalPos()
Expand Down Expand Up @@ -436,7 +438,7 @@ def onMinBtnClicked(self):
self.mainwindow.showMinimized()

def mousePressEvent(self, event: QMouseEvent) -> None:
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = event.globalPosition().toPoint()
else:
g_pos = event.globalPos()
Expand Down Expand Up @@ -466,7 +468,7 @@ def mouseReleaseEvent(self, event: QMouseEvent) -> None:
return super().mouseReleaseEvent(event)

def mouseMoveEvent(self, event: QMouseEvent) -> None:
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = event.globalPosition().toPoint()
else:
g_pos = event.globalPos()
Expand Down Expand Up @@ -624,7 +626,7 @@ def transCheckerStateChanged(self):

def mouseMoveEvent(self, event: QMouseEvent) -> None:
if not self.mainwindow.isMaximized():
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = event.globalPosition().toPoint()
else:
g_pos = event.globalPos()
Expand Down Expand Up @@ -661,7 +663,7 @@ def mouseMoveEvent(self, event: QMouseEvent) -> None:
return super().mouseMoveEvent(event)

def mousePressEvent(self, e: QMouseEvent) -> None:
if c.FLAG_QT6:
if C.FLAG_QT6:
g_pos = e.globalPosition().toPoint()
else:
g_pos = e.globalPos()
Expand Down
2 changes: 1 addition & 1 deletion ballontranslator/ui/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ProjImgTrans:

def __init__(self, directory: str = None):
self.type = PROJTYPE_IMGTRANS
self.directory: str
self.directory: str = None
self.pages: OrderedDict[List[TextBlock]] = OrderedDict()
self.not_found_pages: Dict[List[TextBlock]] = {}
self.new_pages: List[str] = []
Expand Down
7 changes: 7 additions & 0 deletions ballontranslator/ui/scenetext_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def addTextBlkItem(self, textblk_item: TextBlkItem) -> TextBlkItem:
textblk_item.rotated.connect(self.onTextBlkItemRotated)
textblk_item.content_changed.connect(self.onTextBlkItemContentChanged)
textblk_item.doc_size_changed.connect(self.onTextBlkItemSizeChanged)
textblk_item.pasted.connect(self.onBlkitemPaste)
return textblk_item

def deleteTextblkItem(self, blkitem: TextBlkItem):
Expand Down Expand Up @@ -371,6 +372,12 @@ def onTextBlkItemSizeChanged(self, idx: int):
if self.txtblkShapeControl.blk_item == blk_item:
self.txtblkShapeControl.updateBoundingRect()

def onBlkitemPaste(self, idx: int):
blk_item = self.textblk_item_list[idx]
text = self.app.clipboard().text()
cursor = blk_item.textCursor()
cursor.insertText(text)

def onTextBlkItemBeginEdit(self, blk_id: int):
blk_item = self.textblk_item_list[blk_id]
self.txtblkShapeControl.setBlkItem(blk_item)
Expand Down
13 changes: 11 additions & 2 deletions ballontranslator/ui/textitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from qtpy.QtWidgets import QGraphicsItem, QWidget, QGraphicsSceneHoverEvent, QGraphicsTextItem, QStyleOptionGraphicsItem, QStyle, QGraphicsSceneMouseEvent
from qtpy.QtCore import Qt, QRect, QRectF, QPointF, Signal, QSizeF
from qtpy.QtGui import QFont, QTextCursor, QPixmap, QPainterPath, QTextDocument, QFocusEvent, QPainter, QPen, QColor, QTextCursor, QTextCharFormat, QTextDocument
from qtpy.QtGui import QKeyEvent, QFont, QTextCursor, QPixmap, QPainterPath, QTextDocument, QFocusEvent, QPainter, QPen, QColor, QTextCursor, QTextCharFormat, QTextDocument

from dl.textdetector.textblock import TextBlock
from utils.imgproc_utils import xywh2xyxypoly, rotate_polygons
Expand All @@ -27,6 +27,7 @@ class TextBlkItem(QGraphicsTextItem):
content_changed = Signal(QGraphicsTextItem)
leftbutton_pressed = Signal(int)
doc_size_changed = Signal(int)
pasted = Signal(int)
def __init__(self, blk: TextBlock = None, idx: int = 0, set_format=True, show_rect=False, *args, **kwargs):
super().__init__(*args, **kwargs)
self.blk = None
Expand Down Expand Up @@ -565,4 +566,12 @@ def get_char_fmts(self) -> List[QTextCharFormat]:
char_fmts.append(cursor.charFormat())
if cursor.atEnd():
break
return char_fmts
return char_fmts

def keyPressEvent(self, e: QKeyEvent) -> None:
if e.key() == Qt.Key.Key_V and e.modifiers() == Qt.KeyboardModifier.ControlModifier:
if self.isEditing() is not None:
e.accept()
self.pasted.emit(self.idx)
return
return super().keyPressEvent(e)

0 comments on commit 4b1d45a

Please sign in to comment.