mirror of
https://github.com/relativemodder/aegnux.git
synced 2025-12-10 05:29:38 +05:00
ui rework
This commit is contained in:
@@ -7,12 +7,13 @@ from PySide6.QtGui import QAction, QKeySequence
|
||||
from PySide6.QtWidgets import QFileDialog, QMessageBox
|
||||
from src.installationthread import InstallationThread
|
||||
from src.runaethread import RunAEThread
|
||||
from src.runexethread import RunExeThread
|
||||
from src.killaethread import KillAEThread
|
||||
from src.removeaethread import RemoveAEThread
|
||||
from src.utils import (
|
||||
check_aegnux_tip_marked, get_wine_bin_path_env,
|
||||
show_download_method_dialog, get_ae_plugins_dir, get_wineprefix_dir,
|
||||
check_aegnux_installed, mark_aegnux_tip_as_shown
|
||||
check_aegnux_installed, mark_aegnux_tip_as_shown, get_ae_install_dir, get_aegnux_installation_dir
|
||||
)
|
||||
from src.types import DownloadMethod
|
||||
|
||||
@@ -24,11 +25,7 @@ class MainWindow(MainWindowUI):
|
||||
self.setWindowTitle(gls('welcome_win_title'))
|
||||
self.install_button.clicked.connect(self.install_button_clicked)
|
||||
self.run_button.clicked.connect(self.run_ae_button_clicked)
|
||||
self.kill_button.clicked.connect(self.kill_ae_button_clicked)
|
||||
self.remove_aegnux_button.clicked.connect(self.remove_aegnux_button_clicked)
|
||||
self.toggle_logs_button.clicked.connect(self.toggle_logs)
|
||||
self.plugins_button.clicked.connect(self.plugins_folder_clicked)
|
||||
self.wineprefix_button.clicked.connect(self.wineprefix_folder_clicked)
|
||||
|
||||
self.install_thread = InstallationThread()
|
||||
self.install_thread.log_signal.connect(self._log)
|
||||
@@ -53,15 +50,62 @@ class MainWindow(MainWindowUI):
|
||||
self.ctrl_q_action.triggered.connect(self.run_command_ctrl_q)
|
||||
self.addAction(self.ctrl_q_action)
|
||||
|
||||
self._construct_menubar()
|
||||
self.init_installation()
|
||||
|
||||
self.ae_action.triggered.connect(self.run_ae_button_clicked)
|
||||
self.exe_action.triggered.connect(self.run_exe_button_clicked)
|
||||
self.reg_action.triggered.connect(self.reg_button_clicked)
|
||||
self.kill_action.triggered.connect(self.kill_ae_button_clicked)
|
||||
self.log_action.triggered.connect(self.toggle_logs)
|
||||
self.term_action.triggered.connect(self.run_command_alt_t)
|
||||
self.wpd_action.triggered.connect(self.wineprefix_folder_clicked)
|
||||
self.plugind_action.triggered.connect(self.plugins_folder_clicked)
|
||||
self.aed_action.triggered.connect(self.ae_folder_clicked)
|
||||
self.aeg_action.triggered.connect(self.aegnux_folder_clicked)
|
||||
|
||||
def init_installation(self):
|
||||
if check_aegnux_installed():
|
||||
self.install_button.hide()
|
||||
self.run_button.show()
|
||||
self.remove_aegnux_button.show()
|
||||
|
||||
self.runMenu.setEnabled(True)
|
||||
self.browseMenu.setEnabled(True)
|
||||
self.kill_action.setEnabled(True)
|
||||
self.term_action.setEnabled(True)
|
||||
|
||||
else:
|
||||
self.install_button.show()
|
||||
self.run_button.hide()
|
||||
self.remove_aegnux_button.hide()
|
||||
|
||||
self.runMenu.setEnabled(False)
|
||||
self.browseMenu.setEnabled(False)
|
||||
self.kill_action.setEnabled(False)
|
||||
self.term_action.setEnabled(False)
|
||||
|
||||
def _construct_menubar(self):
|
||||
self.runMenu = self.menuBar().addMenu(gls('run_menu'))
|
||||
self.ae_action = self.runMenu.addAction(gls('ae_action'))
|
||||
self.exe_action = self.runMenu.addAction(gls('exe_action'))
|
||||
self.reg_action = self.runMenu.addAction(gls('reg_action'))
|
||||
|
||||
self.browseMenu = self.menuBar().addMenu(gls('browse_menu'))
|
||||
self.wpd_action = self.browseMenu.addAction(gls('wpd_action'))
|
||||
self.plugind_action = self.browseMenu.addAction(gls('plugind_action'))
|
||||
self.aed_action = self.browseMenu.addAction(gls('aed_action'))
|
||||
self.aeg_action = self.browseMenu.addAction(gls('aeg_action'))
|
||||
|
||||
self.debugMenu = self.menuBar().addMenu(gls('debug_menu'))
|
||||
self.kill_action = self.debugMenu.addAction(gls('kill_action'))
|
||||
self.log_action = self.debugMenu.addAction(gls('log_action'))
|
||||
self.term_action = self.debugMenu.addAction(gls('term_action'))
|
||||
|
||||
def lock_ui(self, lock: bool = True):
|
||||
self.install_button.setEnabled(not lock)
|
||||
self.run_button.setEnabled(not lock)
|
||||
self.remove_aegnux_button.setEnabled(not lock)
|
||||
|
||||
if not self.logs_edit.isVisible():
|
||||
self.toggle_logs_button.setVisible(lock)
|
||||
|
||||
@Slot()
|
||||
def toggle_logs(self):
|
||||
@@ -117,6 +161,42 @@ class MainWindow(MainWindowUI):
|
||||
self.lock_ui()
|
||||
self.run_ae_thread.start()
|
||||
|
||||
@Slot()
|
||||
def run_exe_button_clicked(self):
|
||||
filename, _ = QFileDialog.getOpenFileName(
|
||||
self,
|
||||
gls('Open .exe'),
|
||||
"",
|
||||
"Exe Files (*.exe);;All Files (*)"
|
||||
)
|
||||
if filename == '':
|
||||
return
|
||||
|
||||
self.run_exe_thread = RunExeThread([filename])
|
||||
self.run_exe_thread.log_signal.connect(self._log)
|
||||
self.run_exe_thread.finished_signal.connect(self._finished)
|
||||
|
||||
self.lock_ui()
|
||||
self.run_exe_thread.start()
|
||||
|
||||
@Slot()
|
||||
def reg_button_clicked(self):
|
||||
filename, _ = QFileDialog.getOpenFileName(
|
||||
self,
|
||||
gls('Open .reg'),
|
||||
"",
|
||||
"Reg Files (*.reg);;All Files (*)"
|
||||
)
|
||||
if filename == '':
|
||||
return
|
||||
|
||||
self.reg_thread = RunExeThread(['regedit', filename])
|
||||
self.reg_thread.log_signal.connect(self._log)
|
||||
self.reg_thread.finished_signal.connect(self._finished)
|
||||
|
||||
self.lock_ui()
|
||||
self.reg_thread.start()
|
||||
|
||||
@Slot()
|
||||
def kill_ae_button_clicked(self):
|
||||
self.kill_ae_thread.start()
|
||||
@@ -134,6 +214,14 @@ class MainWindow(MainWindowUI):
|
||||
def wineprefix_folder_clicked(self):
|
||||
os.system(f'xdg-open "{get_wineprefix_dir()}"')
|
||||
|
||||
@Slot()
|
||||
def ae_folder_clicked(self):
|
||||
os.system(f'xdg-open "{get_ae_install_dir()}"')
|
||||
|
||||
@Slot()
|
||||
def aegnux_folder_clicked(self):
|
||||
os.system(f'xdg-open "{get_aegnux_installation_dir()}"')
|
||||
|
||||
@Slot()
|
||||
def run_command_alt_t(self):
|
||||
env = os.environ.copy()
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
from src.processthread import ProcessThread
|
||||
from src.utils import get_ae_install_dir
|
||||
from src.runexethread import RunExeThread
|
||||
|
||||
class RunAEThread(ProcessThread):
|
||||
class RunAEThread(RunExeThread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
super().__init__(['AfterFX.exe'])
|
||||
|
||||
def run(self):
|
||||
self.run_command(
|
||||
['wine', 'AfterFX.exe'],
|
||||
cwd=get_ae_install_dir(),
|
||||
in_prefix=True
|
||||
)
|
||||
|
||||
self.finished_signal.emit(True)
|
||||
super().run()
|
||||
16
src/runexethread.py
Normal file
16
src/runexethread.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from src.processthread import ProcessThread
|
||||
from src.utils import get_ae_install_dir
|
||||
|
||||
class RunExeThread(ProcessThread):
|
||||
def __init__(self, exe_args: list):
|
||||
super().__init__()
|
||||
self.exe_args = exe_args
|
||||
|
||||
def run(self):
|
||||
self.run_command(
|
||||
['wine'] + self.exe_args,
|
||||
cwd=get_ae_install_dir(),
|
||||
in_prefix=True
|
||||
)
|
||||
|
||||
self.finished_signal.emit(True)
|
||||
@@ -15,5 +15,18 @@ STRINGS = {
|
||||
'wineprefix': 'Wine prefix',
|
||||
'tip_alt_t': 'Tip: press ALT+T to open up a terminal with Wine environment and prefix set.',
|
||||
'confirm_exit': 'Confirm exit',
|
||||
'confirm_exit_text': 'Are you sure you want to quit Aegnux?'
|
||||
'confirm_exit_text': 'Are you sure you want to quit Aegnux?',
|
||||
'run_menu': 'Run',
|
||||
'ae_action': 'After Effects',
|
||||
'exe_action': 'Other .EXE file',
|
||||
'reg_action': 'Import Registry file',
|
||||
'browse_menu': 'Browse',
|
||||
'wpd_action': 'Wine prefix',
|
||||
'plugind_action': 'Plugins directory',
|
||||
'aed_action': 'AE Directory',
|
||||
'aeg_action': 'Aegnux installation directory',
|
||||
'debug_menu': 'Debug',
|
||||
'kill_action': 'Kill AE',
|
||||
'log_action': 'Toggle log',
|
||||
'term_action': 'Open Terminal'
|
||||
}
|
||||
@@ -29,24 +29,6 @@ class MainWindowUI(QMainWindow):
|
||||
self.root_layout.addItem(
|
||||
QSpacerItem(1, height, QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||
)
|
||||
|
||||
def init_installation(self):
|
||||
if check_aegnux_installed():
|
||||
self.install_button.hide()
|
||||
self.run_button.show()
|
||||
self.kill_button.show()
|
||||
self.remove_aegnux_button.show()
|
||||
|
||||
self.plugins_button.show()
|
||||
self.wineprefix_button.show()
|
||||
else:
|
||||
self.install_button.show()
|
||||
self.run_button.hide()
|
||||
self.kill_button.hide()
|
||||
self.remove_aegnux_button.hide()
|
||||
|
||||
self.plugins_button.hide()
|
||||
self.wineprefix_button.hide()
|
||||
|
||||
def _construct_ui(self):
|
||||
central_widget = QWidget()
|
||||
@@ -60,9 +42,9 @@ class MainWindowUI(QMainWindow):
|
||||
logo_pixmap = QPixmap(AE_ICON_PATH)
|
||||
|
||||
scaled_pixmap = logo_pixmap.scaled(
|
||||
64, # Ширина
|
||||
64, # Высота
|
||||
Qt.AspectRatioMode.KeepAspectRatio, # Сохранять соотношение сторон
|
||||
64,
|
||||
64,
|
||||
Qt.AspectRatioMode.KeepAspectRatio,
|
||||
Qt.TransformationMode.SmoothTransformation
|
||||
)
|
||||
|
||||
@@ -104,37 +86,8 @@ class MainWindowUI(QMainWindow):
|
||||
action_col.addWidget(self.run_button)
|
||||
self.run_button.hide()
|
||||
|
||||
folders_row = QHBoxLayout()
|
||||
self.plugins_button = QPushButton(gls('plugins'))
|
||||
self.plugins_button.setIcon(QIcon.fromTheme('document-open-folder'))
|
||||
self.plugins_button.setIconSize(QSize(25, 15))
|
||||
self.plugins_button.setObjectName('plugins_button')
|
||||
|
||||
self.wineprefix_button = QPushButton(gls('wineprefix'))
|
||||
self.wineprefix_button.setIcon(QIcon.fromTheme('document-open-folder'))
|
||||
self.wineprefix_button.setIconSize(QSize(25, 15))
|
||||
self.wineprefix_button.setObjectName('wineprefix_button')
|
||||
|
||||
self.toggle_logs_button = QPushButton(gls('toggle_logs'))
|
||||
self.toggle_logs_button.setIcon(QIcon.fromTheme('view-list-text'))
|
||||
self.toggle_logs_button.setIconSize(QSize(25, 15))
|
||||
self.toggle_logs_button.setObjectName('toggle_logs_button')
|
||||
self.toggle_logs_button.setVisible(False)
|
||||
action_col.addWidget(self.toggle_logs_button)
|
||||
|
||||
folders_row.addWidget(self.plugins_button)
|
||||
folders_row.addWidget(self.wineprefix_button)
|
||||
|
||||
action_col.addLayout(folders_row)
|
||||
|
||||
destruction_row = QHBoxLayout()
|
||||
|
||||
self.kill_button = QPushButton(gls('kill_ae'))
|
||||
self.kill_button.setObjectName('kill_ae')
|
||||
destruction_row.addWidget(self.kill_button)
|
||||
self.kill_button.hide()
|
||||
|
||||
|
||||
self.remove_aegnux_button = QPushButton(gls('remove_aegnux'))
|
||||
self.remove_aegnux_button.setObjectName('remove_aegnux_button')
|
||||
destruction_row.addWidget(self.remove_aegnux_button)
|
||||
|
||||
Reference in New Issue
Block a user