Skip to content

Commit 6e4637a

Browse files
author
Вена
committed
Add legacy visualization widget for translation progress
- Implemented OldVisualizerWidget to display translation progress using a legacy design. - Integrated data loading from DataManager and structured UI with scrollable project views. - Added functionality to export the visualization as a PNG image. - Included detailed progress tracking with tables and progress bars for each game section. - Enhanced UI with custom styles for better user experience.
1 parent d880024 commit 6e4637a

5 files changed

Lines changed: 468 additions & 439 deletions

File tree

editor.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,38 @@ def init_ui(self):
6363
QLineEdit, QSpinBox {{
6464
background-color: {COLORS['surface']};
6565
border: 1px solid {COLORS['border']};
66-
border-radius: 4px;
67-
padding: 8px;
68-
font-size: 14px;
66+
border-radius: 8px;
67+
padding: 8px 10px;
68+
font-size: 13px;
6969
color: {COLORS['text']};
70-
min-height: 20px;
71-
min-width: 100px;
70+
height: 28px;
71+
margin: 2px;
72+
}}
73+
QSpinBox::up-button, QSpinBox::down-button {{
74+
width: 0px;
75+
height: 0px;
7276
}}
7377
QLineEdit:focus, QSpinBox:focus {{
7478
border: 1px solid {COLORS['accent']};
7579
}}
7680
QTableWidget {{
7781
background-color: {COLORS['surface']};
7882
border: 1px solid {COLORS['border']};
79-
border-radius: 8px;
8083
gridline-color: {COLORS['border']};
8184
color: {COLORS['text']};
85+
font-size: 13px;
8286
}}
8387
QTableWidget::item {{
84-
padding: 4px;
88+
padding: 0px;
89+
margin: 0px;
8590
}}
8691
QHeaderView::section {{
8792
background-color: {COLORS['overlay']};
8893
color: {COLORS['text']};
89-
padding: 6px;
94+
padding: 10px;
9095
border: none;
9196
font-weight: bold;
97+
font-size: 13px;
9298
}}
9399
""")
94100

@@ -207,6 +213,20 @@ def create_editor_panel(self) -> QWidget:
207213
name_label.setFixedWidth(100)
208214
self.game_name_input = QLineEdit()
209215
self.game_name_input.setPlaceholderText("Введіть назву гри...")
216+
self.game_name_input.setStyleSheet(f"""
217+
QLineEdit {{
218+
background-color: {COLORS['surface']};
219+
border: 1px solid {COLORS['border']};
220+
border-radius: 12px;
221+
padding: 10px;
222+
font-size: 14px;
223+
color: {COLORS['text']};
224+
min-height: 32px;
225+
}}
226+
QLineEdit:focus {{
227+
border: 1px solid {COLORS['accent']};
228+
}}
229+
""")
210230
name_layout.addWidget(name_label)
211231
name_layout.addWidget(self.game_name_input)
212232
info_layout.addLayout(name_layout)
@@ -263,6 +283,8 @@ def create_editor_panel(self) -> QWidget:
263283

264284
self.sections_table.verticalHeader().setVisible(False)
265285
self.sections_table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
286+
287+
self.sections_table.setShowGrid(False)
266288
layout.addWidget(self.sections_table)
267289

268290
# Add section button
@@ -378,42 +400,36 @@ def add_section_to_table(self, section: dict = None):
378400
name_input = QLineEdit()
379401
name_input.setText(section.get('name', '') if section else '')
380402
name_input.setPlaceholderText("Назва секції")
381-
name_input.setMinimumWidth(200)
382403
self.sections_table.setCellWidget(row, 0, name_input)
383404

384405
# Total
385406
total_spin = QSpinBox()
386407
total_spin.setMaximum(999999999)
387408
total_spin.setValue(section.get('total', 0) if section else 0)
388-
total_spin.setMinimumWidth(100)
389409
self.sections_table.setCellWidget(row, 1, total_spin)
390410

391411
# Translated
392412
translated_spin = QSpinBox()
393413
translated_spin.setMaximum(999999999)
394414
translated_spin.setValue(section.get('translated', 0) if section else 0)
395-
translated_spin.setMinimumWidth(100)
396415
self.sections_table.setCellWidget(row, 2, translated_spin)
397416

398417
# Translated Label (custom)
399418
trans_label_input = QLineEdit()
400419
trans_label_input.setText(section.get('translated_label', '') if section else '')
401420
trans_label_input.setPlaceholderText("Перекладено")
402-
trans_label_input.setMinimumWidth(120)
403421
self.sections_table.setCellWidget(row, 3, trans_label_input)
404422

405423
# Approved
406424
approved_spin = QSpinBox()
407425
approved_spin.setMaximum(999999999)
408426
approved_spin.setValue(section.get('approved', 0) if section else 0)
409-
approved_spin.setMinimumWidth(100)
410427
self.sections_table.setCellWidget(row, 4, approved_spin)
411428

412429
# Approved Label (custom)
413430
appr_label_input = QLineEdit()
414431
appr_label_input.setText(section.get('approved_label', '') if section else '')
415432
appr_label_input.setPlaceholderText("Затверджено")
416-
appr_label_input.setMinimumWidth(120)
417433
self.sections_table.setCellWidget(row, 5, appr_label_input)
418434

419435
# Exclude checkbox
@@ -428,20 +444,29 @@ def add_section_to_table(self, section: dict = None):
428444

429445
# Delete button
430446
delete_btn = QPushButton("🗑️")
431-
delete_btn.setFixedSize(30, 30)
447+
delete_btn.setMaximumWidth(24)
448+
delete_btn.setMaximumHeight(24)
432449
delete_btn.clicked.connect(lambda: self.delete_section(row))
433450
delete_btn.setStyleSheet(f"""
434451
QPushButton {{
435452
background-color: {COLORS['error']};
436453
border: none;
437-
border-radius: 4px;
454+
border-radius: 3px;
438455
color: white;
456+
padding: 0px;
457+
margin: 0px;
458+
font-size: 12px;
439459
}}
440460
QPushButton:hover {{
441461
background-color: #e74c6c;
442462
}}
443463
""")
444-
self.sections_table.setCellWidget(row, 7, delete_btn)
464+
delete_widget = QWidget()
465+
delete_layout = QHBoxLayout(delete_widget)
466+
delete_layout.addWidget(delete_btn)
467+
delete_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
468+
delete_layout.setContentsMargins(0, 0, 0, 0)
469+
self.sections_table.setCellWidget(row, 7, delete_widget)
445470

446471
def add_section(self):
447472
"""Add new empty section"""

icon.ico

96.7 KB
Binary file not shown.

main.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from PyQt6.QtGui import QIcon, QPalette, QColor
1010

1111
from visualizer import VisualizerWidget
12+
from old_visualizer import OldVisualizerWidget
1213
from editor import EditorWidget
1314
from colors import COLORS
1415

@@ -24,10 +25,12 @@ def __init__(self):
2425

2526
# Create interfaces
2627
self.visualizer = VisualizerWidget(self)
28+
self.old_visualizer = OldVisualizerWidget(self)
2729
self.editor = EditorWidget(self)
2830

29-
# Connect editor data changes to visualizer refresh
31+
# Connect editor data changes to both visualizers refresh
3032
self.editor.data_changed.connect(self.visualizer.refresh)
33+
self.editor.data_changed.connect(self.old_visualizer.refresh)
3134

3235
# Create main widget and layout
3336
main_widget = QWidget()
@@ -43,6 +46,7 @@ def __init__(self):
4346
# Create stacked widget for views
4447
self.stacked_widget = QStackedWidget()
4548
self.stacked_widget.addWidget(self.visualizer)
49+
self.stacked_widget.addWidget(self.old_visualizer)
4650
self.stacked_widget.addWidget(self.editor)
4751
layout.addWidget(self.stacked_widget)
4852

@@ -65,24 +69,32 @@ def create_nav_bar(self) -> QWidget:
6569

6670
layout.addStretch()
6771

68-
# View button
69-
view_btn = QPushButton("Перегляд")
70-
view_btn.setCheckable(True)
71-
view_btn.setChecked(True)
72-
view_btn.clicked.connect(lambda: self.switch_view(0, view_btn, edit_btn))
73-
view_btn.setStyleSheet(self.get_nav_button_style(True))
74-
layout.addWidget(view_btn)
72+
# Modern view button
73+
modern_btn = QPushButton("Сучасніший вигляд")
74+
modern_btn.setCheckable(True)
75+
modern_btn.setChecked(True)
76+
modern_btn.clicked.connect(lambda: self.switch_view(0, modern_btn, old_btn, edit_btn))
77+
modern_btn.setStyleSheet(self.get_nav_button_style(True))
78+
layout.addWidget(modern_btn)
79+
80+
# Old view button
81+
old_btn = QPushButton("Старий вигляд")
82+
old_btn.setCheckable(True)
83+
old_btn.clicked.connect(lambda: self.switch_view(1, old_btn, modern_btn, edit_btn))
84+
old_btn.setStyleSheet(self.get_nav_button_style(False))
85+
layout.addWidget(old_btn)
7586

7687
# Edit button
7788
edit_btn = QPushButton("Редагування")
7889
edit_btn.setCheckable(True)
79-
edit_btn.clicked.connect(lambda: self.switch_view(1, edit_btn, view_btn))
90+
edit_btn.clicked.connect(lambda: self.switch_view(2, edit_btn, modern_btn, old_btn))
8091
edit_btn.setStyleSheet(self.get_nav_button_style(False))
8192
layout.addWidget(edit_btn)
8293

8394
layout.addStretch()
8495

85-
self.view_btn = view_btn
96+
self.modern_btn = modern_btn
97+
self.old_btn = old_btn
8698
self.edit_btn = edit_btn
8799

88100
return nav_widget
@@ -119,11 +131,12 @@ def get_nav_button_style(self, active: bool) -> str:
119131
}}
120132
"""
121133

122-
def switch_view(self, index: int, active_btn: QPushButton, inactive_btn: QPushButton):
134+
def switch_view(self, index: int, active_btn: QPushButton, inactive_btn1: QPushButton, inactive_btn2: QPushButton):
123135
"""Switch between views"""
124136
self.stacked_widget.setCurrentIndex(index)
125137
active_btn.setStyleSheet(self.get_nav_button_style(True))
126-
inactive_btn.setStyleSheet(self.get_nav_button_style(False))
138+
inactive_btn1.setStyleSheet(self.get_nav_button_style(False))
139+
inactive_btn2.setStyleSheet(self.get_nav_button_style(False))
127140

128141
def apply_custom_style(self):
129142
"""Apply custom Catppuccin Mocha colors"""

0 commit comments

Comments
 (0)