Clean up gui
This commit is contained in:
parent
f381ec1113
commit
13ffaa42ab
2 changed files with 78 additions and 8 deletions
73
gui/main.py
73
gui/main.py
|
|
@ -13,8 +13,8 @@ from PyQt5.QtWidgets import (
|
||||||
QWidget, QPushButton, QLabel, QFileDialog, QMessageBox, QProgressBar,
|
QWidget, QPushButton, QLabel, QFileDialog, QMessageBox, QProgressBar,
|
||||||
QTextEdit, QSplitter, QGroupBox, QStatusBar
|
QTextEdit, QSplitter, QGroupBox, QStatusBar
|
||||||
)
|
)
|
||||||
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer
|
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer, QSettings
|
||||||
from PyQt5.QtGui import QIcon, QFont, QPixmap
|
from PyQt5.QtGui import QIcon, QFont, QPixmap, QScreen
|
||||||
|
|
||||||
# Import configuration widgets
|
# Import configuration widgets
|
||||||
from gui.config_tab import ConfigTab
|
from gui.config_tab import ConfigTab
|
||||||
|
|
@ -29,9 +29,40 @@ class DazedMTLGUI(QMainWindow):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.settings = QSettings("DazedTranslations", "DazedMTLTool")
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
self.setup_status_bar()
|
self.setup_status_bar()
|
||||||
self.setup_font_scaling()
|
self.setup_font_scaling()
|
||||||
|
self.restore_window_state()
|
||||||
|
|
||||||
|
def restore_window_state(self):
|
||||||
|
"""Restore window geometry and state from settings."""
|
||||||
|
try:
|
||||||
|
# Restore window geometry
|
||||||
|
geometry = self.settings.value("geometry")
|
||||||
|
if geometry:
|
||||||
|
self.restoreGeometry(geometry)
|
||||||
|
|
||||||
|
# Restore window state (maximized, etc.)
|
||||||
|
window_state = self.settings.value("windowState")
|
||||||
|
if window_state:
|
||||||
|
self.restoreState(window_state)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Could not restore window state: {e}")
|
||||||
|
|
||||||
|
def save_window_state(self):
|
||||||
|
"""Save window geometry and state to settings."""
|
||||||
|
try:
|
||||||
|
self.settings.setValue("geometry", self.saveGeometry())
|
||||||
|
self.settings.setValue("windowState", self.saveState())
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Warning: Could not save window state: {e}")
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
"""Handle application close event."""
|
||||||
|
self.save_window_state()
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def setup_font_scaling(self):
|
def setup_font_scaling(self):
|
||||||
"""Set up font scaling based on configuration."""
|
"""Set up font scaling based on configuration."""
|
||||||
|
|
@ -75,7 +106,23 @@ class DazedMTLGUI(QMainWindow):
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
"""Initialize the user interface."""
|
"""Initialize the user interface."""
|
||||||
self.setWindowTitle("DazedMTLTool - Visual Translation Interface")
|
self.setWindowTitle("DazedMTLTool - Visual Translation Interface")
|
||||||
self.setGeometry(100, 100, 1200, 800)
|
|
||||||
|
# Get screen geometry and set window size more responsively
|
||||||
|
screen = QApplication.primaryScreen()
|
||||||
|
screen_geometry = screen.availableGeometry()
|
||||||
|
|
||||||
|
# Set window size to 80% of screen size, with reasonable minimums
|
||||||
|
window_width = max(1200, int(screen_geometry.width() * 0.8))
|
||||||
|
window_height = max(800, int(screen_geometry.height() * 0.8))
|
||||||
|
|
||||||
|
# Center the window on screen
|
||||||
|
x = (screen_geometry.width() - window_width) // 2
|
||||||
|
y = (screen_geometry.height() - window_height) // 2
|
||||||
|
|
||||||
|
self.setGeometry(x, y, window_width, window_height)
|
||||||
|
|
||||||
|
# Set minimum size to prevent the window from becoming too small
|
||||||
|
self.setMinimumSize(1000, 600)
|
||||||
|
|
||||||
# Set window icon if available
|
# Set window icon if available
|
||||||
icon_path = Path("screens/tool.png")
|
icon_path = Path("screens/tool.png")
|
||||||
|
|
@ -102,7 +149,10 @@ class DazedMTLGUI(QMainWindow):
|
||||||
# Add widgets to splitter
|
# Add widgets to splitter
|
||||||
main_splitter.addWidget(self.tab_widget)
|
main_splitter.addWidget(self.tab_widget)
|
||||||
main_splitter.addWidget(self.log_viewer)
|
main_splitter.addWidget(self.log_viewer)
|
||||||
main_splitter.setSizes([800, 400])
|
|
||||||
|
# Set proportional sizes instead of fixed pixel sizes
|
||||||
|
main_splitter.setStretchFactor(0, 2) # Main content gets 2/3
|
||||||
|
main_splitter.setStretchFactor(1, 1) # Log viewer gets 1/3
|
||||||
|
|
||||||
# Set main layout
|
# Set main layout
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
@ -340,7 +390,22 @@ def main():
|
||||||
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
|
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
|
||||||
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
|
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
|
||||||
|
|
||||||
|
# Additional DPI handling for better compatibility
|
||||||
|
if hasattr(Qt, 'AA_DisableWindowContextHelpButton'):
|
||||||
|
QApplication.setAttribute(Qt.AA_DisableWindowContextHelpButton, True)
|
||||||
|
|
||||||
|
# Set high DPI scale factor policy
|
||||||
|
if hasattr(QApplication, 'setHighDpiScaleFactorRoundingPolicy'):
|
||||||
|
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
|
# Additional screen-aware settings
|
||||||
|
screen = app.primaryScreen()
|
||||||
|
if screen:
|
||||||
|
dpi = screen.logicalDotsPerInch()
|
||||||
|
print(f"Screen DPI: {dpi}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to create QApplication: {e}")
|
print(f"Failed to create QApplication: {e}")
|
||||||
print("Make sure PyQt5 is properly installed:")
|
print("Make sure PyQt5 is properly installed:")
|
||||||
|
|
|
||||||
|
|
@ -519,7 +519,9 @@ class TranslationTab(QWidget):
|
||||||
output_widget = self.create_output_files_widget()
|
output_widget = self.create_output_files_widget()
|
||||||
file_management_splitter.addWidget(output_widget)
|
file_management_splitter.addWidget(output_widget)
|
||||||
|
|
||||||
file_management_splitter.setSizes([300, 300])
|
# Set proportional sizes instead of fixed pixel sizes
|
||||||
|
file_management_splitter.setStretchFactor(0, 1)
|
||||||
|
file_management_splitter.setStretchFactor(1, 1)
|
||||||
layout.addWidget(file_management_splitter)
|
layout.addWidget(file_management_splitter)
|
||||||
|
|
||||||
# Console log at the bottom
|
# Console log at the bottom
|
||||||
|
|
@ -628,7 +630,8 @@ class TranslationTab(QWidget):
|
||||||
input_layout = QVBoxLayout()
|
input_layout = QVBoxLayout()
|
||||||
|
|
||||||
self.input_list = QListWidget()
|
self.input_list = QListWidget()
|
||||||
self.input_list.setMaximumHeight(120)
|
self.input_list.setMinimumHeight(80)
|
||||||
|
self.input_list.setMaximumHeight(150)
|
||||||
input_layout.addWidget(self.input_list)
|
input_layout.addWidget(self.input_list)
|
||||||
|
|
||||||
input_buttons = QHBoxLayout()
|
input_buttons = QHBoxLayout()
|
||||||
|
|
@ -655,7 +658,8 @@ class TranslationTab(QWidget):
|
||||||
output_layout = QVBoxLayout()
|
output_layout = QVBoxLayout()
|
||||||
|
|
||||||
self.output_list = QListWidget()
|
self.output_list = QListWidget()
|
||||||
self.output_list.setMaximumHeight(120)
|
self.output_list.setMinimumHeight(80)
|
||||||
|
self.output_list.setMaximumHeight(150)
|
||||||
output_layout.addWidget(self.output_list)
|
output_layout.addWidget(self.output_list)
|
||||||
|
|
||||||
output_buttons = QHBoxLayout()
|
output_buttons = QHBoxLayout()
|
||||||
|
|
@ -721,7 +725,8 @@ class TranslationTab(QWidget):
|
||||||
self.log_display = QTextEdit()
|
self.log_display = QTextEdit()
|
||||||
self.log_display.setReadOnly(True)
|
self.log_display.setReadOnly(True)
|
||||||
self.log_display.setFont(QFont("Consolas", 9))
|
self.log_display.setFont(QFont("Consolas", 9))
|
||||||
self.log_display.setMinimumHeight(200)
|
self.log_display.setMinimumHeight(150)
|
||||||
|
self.log_display.setMaximumHeight(300)
|
||||||
self.log_display.setStyleSheet("""
|
self.log_display.setStyleSheet("""
|
||||||
QTextEdit {
|
QTextEdit {
|
||||||
background-color: #1e1e1e;
|
background-color: #1e1e1e;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue