Commit 04fbdab7 authored by dmMaze's avatar dmMaze
Browse files

fix scaling

parent e1645e08
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ def main():
    else:
        os.environ['QT_API'] = args.qt_api

    os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "1"

    if sys.platform == 'win32':
        import ctypes
        myappid = u'BalloonsTranslator' # arbitrary string
@@ -23,9 +25,11 @@ def main():

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

    QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)

    from ui import constants
    if qtpy.API_NAME[-1] == '6':
        constants.FLAG_QT6 = True
+132 −230
Original line number Diff line number Diff line
@@ -48,23 +48,23 @@ ConfigSubBlock::hover {
}

SourceTextEdit {
    font-size: 25px;
    font-size: 17px;
    background-color: #e1e4eb;
    border-radius: 10px;
    border-radius: 7px;
    border-style: none;
}

TransTextEdit {
    font-size: 25px;
    font-size: 17px;
    /* background-color: #e1e4eb; */
    border-radius: 10px;
    border-radius: 7px;
    background-color: whitesmoke;
}

QComboBox {
    height: 40px;
    font-size: 20px;
    padding-left: 12px;
    height: 27px;
    font-size: 14px;
    padding-left: 8px;
    border: 1px solid whitesmoke;
}

@@ -79,17 +79,17 @@ QComboBox::hover {

QComboBox::down-arrow {
    image: url(data/icons/combobox_arrow.svg);
    width: 16px;
    height: 16px;
    padding-right: 20px;
    width: 11px;
    height: 11px;
    padding-right: 13px;
}

QFontComboBox#FontFamilyBox {
    width: 160px;
    height: 40px;
    font-size: 20px;
    padding-right: 20px;
    padding-left: 10px;
    width: 106px;
    height: 26px;
    font-size: 14px;
    padding-right: 14px;
    padding-left: 6px;
    border-color: #b3b6bf;
}

@@ -97,19 +97,11 @@ QFontComboBox#FontFamilyBox::hover {
    border: 1px solid rgb(30, 147, 229);
}

QFontComboBox#FontFamilyBox::down-arrow {
    image: url(data/icons/combobox_arrow.svg);
    width: 32px;
    height: 16px;
    padding-right: 0px;
    margin-right: 10px;
}

SizeComboBox {
    padding-left: 8px;
    padding-right: 5px;
    font-size: 20px;
    width: 52px;
    padding-left: 6px;
    padding-right: 3px;
    font-size: 14px;
    width: 34px;
    border-color: #b3b6bf;
}

@@ -119,49 +111,47 @@ SizeComboBox::hover {

SizeComboBox::down-arrow {
    image: url(data/icons/combobox_arrow.svg);
    width: 42px;
    height: 16px;
    padding-right: 5px;
    margin-right: 5px;
    width: 28px;
    height: 11px;
    padding-right: 3px;
    margin-right: 3px;
}

QLabel#lineSpacingLabel {
    image: url(data/icons/fontfmt_linespacing.svg);
    max-width: 38px;
    max-height: 38px;
    min-width: 38px;
    min-height: 38px;
    max-width: 25px;
    max-height: 25px;
    min-width: 25px;
    min-height: 25px;
}

QLabel#letterSpacingLabel {
    image: url(data/icons/fontfmt_letterspacing.svg);
    max-width: 42px;
    max-height: 42px;
    min-width: 42px;
    min-height: 42px;
    max-width: 28px;
    max-height: 28px;
    min-width: 28px;
    min-height: 28px;
}

ColorPicker {
    max-height: 38px;
    min-height: 38px;
    min-width: 38px;
    max-width: 38px;
    border: 3px solid #b3b6bf;
    max-height: 25px;
    min-height: 25px;
    min-width: 25px;
    max-width: 25px;
    border: 2px solid #b3b6bf;
}

ColorPicker::hover {
    border: 3px solid rgb(30, 147, 229);
    border: 2px solid rgb(30, 147, 229);
}

AlignmentChecker {
    /* max-height: 30px; */
    /* max-width: 52px; */
    margin: 0px;
}

AlignmentChecker::indicator {
    height: 42px;
    width: 42px;
    height: 28px;
    width: 28px;
    border: 2px solid #b3b6bf;
}

@@ -175,8 +165,8 @@ AlignmentChecker::indicator:hover {

AlignmentChecker#AlignLeftChecker::indicator {
    border-right: none;
    min-width: 54px;
    max-width: 54px;
    min-width: 36px;
    max-width: 36px;
    image: url(data/icons/fontfmt_alignl.svg);
}

@@ -187,8 +177,8 @@ AlignmentChecker#AlignLeftChecker::indicator:checked {
AlignmentChecker#AlignCenterChecker::indicator {
    border-right: none;
    border-left: none;
    min-width: 54px;
    max-width: 54px;
    min-width: 36px;
    max-width: 36px;
    image: url(data/icons/fontfmt_alignc.svg);
}

@@ -198,8 +188,8 @@ AlignmentChecker#AlignCenterChecker::indicator:checked {

AlignmentChecker#AlignRightChecker::indicator {
    border-left: none;
    min-width: 52px;
    max-width: 52px;
    min-width: 35px;
    max-width: 35px;
    image: url(data/icons/fontfmt_alignr.svg);
}

@@ -208,12 +198,12 @@ AlignmentChecker#AlignRightChecker::indicator:checked {
}

QFontChecker {
    max-width: 49px;
    max-width: 32px;
}

QFontChecker::indicator {
    width: 45px;
    height: 45px;
    width: 30px;
    height: 30px;
    border: 2px solid rgba(30, 147, 229, 0);
}

@@ -267,7 +257,7 @@ PageListView {
}

QAction {
    min-height: 100px;
    min-height: 66px;
}

QMenu {
@@ -276,19 +266,19 @@ QMenu {
}

QMenu::item {
    height: 42px;
    width: 512px;
    height: 28px;
    width: 342px;
    margin: 0px;
    background-color: #e1e4eb;
    padding-left: 50px;
    padding-right: 50px;
    padding-left: 32px;
    padding-right: 32px;
}

QMenu::separator {
    height: 8px;
    height: 5px;
    /* background: lightblue; */
    margin-left: 20px;
    margin-right: 20px;
    margin-left: 12px;
    margin-right: 12px;
}

/* QMenu::item {
@@ -309,24 +299,13 @@ QGroupBox {
    background-color: #e1e4eb;
}


QTabWidget {
    font: normal, "Comic Sans MS";
    font-size: 13px;
    background-color: #e1e4eb;
    border: 0px;
}


QPushButton {
    /* width: 140px; */
    max-width: 140px;
    height: 50px;
    /* min-width: 140px; */
    font-size: 20;
    max-width: 94px;
    height: 32px;
    font-size: 14px;
    background-color: rgba(198, 201, 207, 33%);
    border: 1px solid #999999;
    border-radius: 5px;
    border-radius: 3px;
}

QPushButton::hover {
@@ -341,12 +320,12 @@ QPushButton#minBtn {
    border-radius: 0px;
    background-color: rgba(0, 0, 0, 0);
    border: 0px;
    width: 24px;
    height: 24px;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-left: 24px;
    padding-right: 24px;
    width: 16px;
    height: 16px;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 16px;
    padding-right: 16px;
    image: url(data/icons/titlebar_min.svg);
}

@@ -359,19 +338,19 @@ StatusButton {
    max-width: 10800px;
    /* height: 50px; */
    /* min-width: 140px; */
    font-size: 18px;
    padding-left: 10px;
    padding-left: 10px;
    font-size: 12px;
    padding-left: 7px;
    padding-left: 7px;
    border: none;
}

QCheckBox#maxBtn::indicator{
    height: 26px;
    width: 26px;
    padding-top: 7px;
    padding-bottom: 7px;
    padding-left: 24px;
    padding-right: 24px;
    height: 17px;
    width: 17px;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left: 16px;
    padding-right: 16px;
    image: url(data/icons/titlebar_max.svg);
}

@@ -388,12 +367,12 @@ QPushButton#closeBtn {
    border-radius: 0px;
    background-color: rgba(0, 0, 0, 0);
    border: 0px;
    width: 20px;
    height: 20px;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 24px;
    padding-right: 24px;
    width: 14px;
    height: 14px;
    padding-top: 7px;
    padding-bottom: 7px;
    padding-left: 16px;
    padding-right: 16px;
    image: url(data/icons/titlebar_close.svg);
}

@@ -402,32 +381,25 @@ QPushButton#closeBtn::hover {
    image: url(data/icons/titlebar_close_activate.svg);
}



QTableWidget {
    border: 0px solid gray;
    selection-background-color: darkgray;
}

TextChecker::hover {
    background-color: rgba(30, 147, 229, 20%);
}

TextChecker#OCRChecker {
    height: 50px;
    width: 100;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 32px;
    height: 34px;
    width: 66;
    padding-left: 7px;
    padding-right: 7px;
    font-size: 22px;
}

QCheckBox#TransChecker::indicator {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 4px;
    padding-bottom: 4px;
    height: 40px;
    width: 40px;
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 3px;
    padding-bottom: 3px;
    height: 27px;
    width: 27px;
    image: url(data/icons/bottombar_translate.svg);
}

@@ -440,12 +412,12 @@ QCheckBox#TransChecker::indicator:hover {
}

QCheckBox#PaintChecker::indicator {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 12px;
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 8px;
    /* padding-bottom: 4px; */
    height: 50px;
    width: 50px;
    height: 33px;
    width: 33px;
    image: url(data/icons/bottombar_paintmode.svg);
}

@@ -458,12 +430,12 @@ QCheckBox#PaintChecker::indicator:hover {
}

QCheckBox#TexteditChecker::indicator {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 4px;
    padding-bottom: 4px;
    height: 42px;
    width: 42px;
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 3px;
    padding-bottom: 3px;
    height: 28px;
    width: 28px;
    image: url(data/icons/bottombar_textedit.svg);
}

@@ -476,12 +448,12 @@ QCheckBox#TexteditChecker::indicator:hover {
}

QCheckBox#TextblockChecker::indicator{
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 4px;
    padding-bottom: 4px;
    height: 42px;
    width: 42px;
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 3px;
    padding-bottom: 3px;
    height: 28px;
    width: 28px;
    image: url(data/icons/bottombar_textblock.svg);
}

@@ -493,26 +465,6 @@ QCheckBox#TextblockChecker::indicator:checked{
    image: url(data/icons/bottombar_textblock_activate.svg);
}

QSlider#OpacitySlider {
    max-width: 50;
    min-width: 50;
    max-height: 200;
    min-height: 200;
}

QSlider#OpacitySlider::hover {
    opacity: 100;
}



QSlider#SizeSlider {
    max-width: 200;
    min-width: 200;
    max-height: 50;
    min-height: 50;
}

OpenBtn {
    border-style: none;
    image: url(data/icons/openbtn.svg);
@@ -535,59 +487,9 @@ QProgressBar {
    max-height: 45px;
}

QToolButton#genDocBtn
{
    image: url(data/icons/word.svg);
}

QToolButton#genPsdBtn
{
    image: url(data/icons/psd.svg);
}


QCheckBox#ocrPage::indicator
{
    image: url(data/icons/ocr.svg);
}
QCheckBox#ocrPage::indicator:hover
{
    image: url(data/icons/ocr_activate.svg);
}
QCheckBox#ocrPage::indicator:checked
{
    background-color: #cad7ed;
}

QCheckBox#transLab::indicator
{
    image: url(data/icons/translation.svg);
}
QCheckBox#transLab::indicator:hover
{
    image: url(data/icons/translation_activate.svg);
}
QCheckBox#transLab::indicator:checked
{
    background-color: #cad7ed;
}

QCheckBox#saveLab::indicator
{
    image: url(data/icons/save.svg);
}
QCheckBox#saveLab::indicator:hover
{
    image: url(data/icons/save_activate.svg);
}
QCheckBox#saveLab::indicator:checked
{
    background-color: #cad7ed;
}

ShowPageListChecker::indicator{
    height: 56px;
    width: 56px;
    height: 37px;
    width: 37px;
    image: url(data/icons/showpagelist.svg);
}

@@ -601,8 +503,8 @@ ShowPageListChecker::indicator:checked
}

StateChecker#ImgTransChecker::indicator{
    height: 56px;
    width: 56px;
    height: 37px;
    width: 37px;
    image: url(data/icons/leftbar_imgtrans.svg);
}

@@ -616,8 +518,8 @@ StateChecker#ImgTransChecker::indicator:checked
}

StateChecker#ConfigChecker::indicator{
    height: 56px;
    width: 56px;
    height: 37px;
    width: 37px;
    image: url(data/icons/leftbar_config.svg);
}

@@ -631,14 +533,14 @@ StateChecker#ConfigChecker::indicator:checked
}

StateChecker#OCRChecker::indicator{
    height: 42px;
    width: 42px;
    height: 28px;
    width: 28px;
    image: url(data/icons/bottombar_ocr.svg);
}

StateChecker#OCRChecker::indicator:checked{
    height: 42px;
    width: 42px;
    height: 28px;
    width: 28px;
    background-color: rgba(30, 147, 229);
    image: url(data/icons/bottombar_ocr_activate.svg);
}
@@ -733,8 +635,8 @@ QScrollBar::add-line {

.IncrementalBtn {
    border-radius: 0px;
    height: 20px;
    width: 20px;
    height: 13px;
    width: 13px;
}
.IncrementalBtn#FsizeIncrementUp {
    border-image: url(data/icons/incre_up.svg) 0 0 0 0 stretch stretch;
@@ -745,18 +647,18 @@ QScrollBar::add-line {

.FadeLabel {
    background: rgba(0, 0, 0, 85);
    border-radius: 25px;
    border-radius: 16px;
    border: none;
    font-size: 33px;
    min-height: 55px;
    max-height: 55px;
    min-width: 110px;
    max-width: 110px;
    font-size: 22px;
    min-height: 36px;
    max-height: 36px;
    min-width: 72px;
    max-width: 72px;
    color: rgba(255, 255, 255, 150);
}

QLabel#TitleLabel {
    font-size: 18px;
    font-size: 13px;
    color: #5d5d5f;
}

@@ -773,10 +675,10 @@ QLabel#angleLabel {
}

DrawToolCheckBox::indicator {
    height: 50px;
    width: 50px;
    border-radius: 9px;
    padding: 10px;
    height: 34px;
    width: 34px;
    border-radius: 6px;
    padding: 6px;
}

DrawToolCheckBox::indicator:checked {
+2 −2
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ class TreeModel(QStandardItemModel):
        if role == Qt.ItemDataRole.SizeHintRole:
            size = QSize()
            item = self.itemFromIndex(index)
            size.setHeight(item.font().pointSize()+40)
            size.setHeight(item.font().pointSize()+26)
            return size
        else:
            return super().data(index, role)
@@ -224,7 +224,7 @@ class ConfigTable(QTreeView):
        self.selected: TableItem = None
        self.last_selected: TableItem = None
        self.setHeaderHidden(True)
        self.setMinimumWidth(400)
        self.setMinimumWidth(260)
        self.expandAll()

    def addHeader(self, header: str) -> TableItem:
+12 −7
Original line number Diff line number Diff line
@@ -10,16 +10,20 @@ LIBS_PATH = osp.join(PROGRAM_PATH, 'data/libs')
STYLESHEET_PATH = osp.join(PROGRAM_PATH, 'data/config/stylesheet.css')
CONFIG_PATH = osp.join(PROGRAM_PATH, 'data/config/config.json')

CONFIG_FONTSIZE_HEADER = 24
CONFIG_FONTSIZE_HEADER = 18
CONFIG_FONTSIZE_TABLE = 14
CONFIG_FONTSIZE_CONTENT = 14

CONFIG_COMBOBOX_HEIGHT = 45 
CONFIG_COMBOBOX_SHORT = 300
CONFIG_COMBOBOX_MIDEAN = 500
CONFIG_COMBOBOX_LONG = 700
CONFIG_COMBOBOX_HEIGHT = 30 
CONFIG_COMBOBOX_SHORT = 200
CONFIG_COMBOBOX_MIDEAN = 332
CONFIG_COMBOBOX_LONG = 468

WIDGET_SPACING_CLOSE = 12
WIDGET_SPACING_CLOSE = 8
TEXTEDIT_FIXWIDTH = 350

LEFTBAR_WIDTH = 60
LEFTBTN_WIDTH = 38

LDPI = 96.
DPI = 188.75
@@ -27,7 +31,8 @@ DPI = 188.75
DEFAULT_FONT_FAMILY = 'Microsoft YaHei UI'

WINDOW_BORDER_WIDTH = 4
BOTTOMBAR_HEIGHT = 48
BOTTOMBAR_HEIGHT = 32
TITLEBAR_HEIGHT = 26

DRAG_DIR_NONE = -1
DRAG_DIR_HOR = 0
+5 −5
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ from dl import VALID_INPAINTERS, VALID_TEXTDETECTORS, VALID_TRANSLATORS, VALID_O
    TranslatorBase, DEFAULT_DEVICE
from utils.logger import logger as LOGGER
from .stylewidgets import ConfigComboBox
from .constants import CONFIG_FONTSIZE_CONTENT, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT
from .constants import CONFIG_FONTSIZE_CONTENT, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT, CONFIG_COMBOBOX_HEIGHT

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
@@ -32,7 +32,7 @@ class ParamEditor(QLineEdit):
        super().__init__( *args, **kwargs)
        self.param_key = param_key
        self.setFixedWidth(CONFIG_COMBOBOX_MIDEAN)
        self.setFixedHeight(45)
        self.setFixedHeight(CONFIG_COMBOBOX_HEIGHT)
        self.textChanged.connect(self.on_text_changed)

    def on_text_changed(self):
@@ -45,7 +45,7 @@ class ParamComboBox(QComboBox):
        super().__init__( *args, **kwargs)
        self.param_key = param_key
        self.setFixedWidth(size)
        self.setFixedHeight(45)
        self.setFixedHeight(CONFIG_COMBOBOX_HEIGHT)
        options = [str(opt) for opt in options]
        self.addItems(options)
        self.currentTextChanged.connect(self.on_select_changed)
@@ -80,7 +80,7 @@ class ParamWidget(QWidget):
        param_layout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
        
        param_layout.setContentsMargins(0, 0, 0, 0)
        param_layout.setSpacing(20)
        param_layout.setSpacing(14)
        for param_key in params:
            param_label = ParamNameLabel(param_key)
            if param_key == 'description':
@@ -112,7 +112,7 @@ class ParamWidget(QWidget):
                    param_widget.paramwidget_edited.connect(self.paramwidget_edited)
            layout = QHBoxLayout()
            layout.setContentsMargins(0, 0, 0, 0)
            layout.setSpacing(15)
            layout.setSpacing(10)
            layout.addWidget(param_label)
            layout.addWidget(param_widget)
            layout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
Loading