1
0
Fork 0
mirror of synced 2024-06-02 10:44:40 +12:00

InstallDialog: Use ActionDialog base class

This commit is contained in:
loathingKernel 2024-01-02 15:12:07 +02:00
parent fd22d831eb
commit c7336ad04a
3 changed files with 146 additions and 220 deletions

View file

@ -3,20 +3,19 @@ import platform as pf
import shutil import shutil
from typing import Tuple, List, Union, Optional from typing import Tuple, List, Union, Optional
from PyQt5.QtCore import Qt, QThreadPool, QSettings, QCoreApplication from PyQt5.QtCore import QThreadPool, QSettings
from PyQt5.QtCore import pyqtSignal, pyqtSlot from PyQt5.QtCore import pyqtSignal, pyqtSlot
from PyQt5.QtGui import QCloseEvent, QKeyEvent, QShowEvent from PyQt5.QtGui import QShowEvent
from PyQt5.QtWidgets import QDialog, QFileDialog, QCheckBox, QLayout, QWidget, QVBoxLayout, QFormLayout from PyQt5.QtWidgets import QFileDialog, QCheckBox, QWidget, QVBoxLayout, QFormLayout
from legendary.utils.selective_dl import get_sdl_appname from legendary.utils.selective_dl import get_sdl_appname
from rare.models.game import RareGame from rare.models.game import RareGame
from rare.models.install import InstallDownloadModel, InstallQueueItemModel, InstallOptionsModel from rare.models.install import InstallDownloadModel, InstallQueueItemModel, InstallOptionsModel
from rare.shared import LegendaryCoreSingleton, ArgumentsSingleton
from rare.shared.workers.install_info import InstallInfoWorker from rare.shared.workers.install_info import InstallInfoWorker
from rare.ui.components.dialogs.install_dialog import Ui_InstallDialog from rare.ui.components.dialogs.install_dialog import Ui_InstallDialog
from rare.ui.components.dialogs.install_dialog_advanced import Ui_InstallDialogAdvanced from rare.ui.components.dialogs.install_dialog_advanced import Ui_InstallDialogAdvanced
from rare.utils import config_helper from rare.utils.misc import format_size, icon
from rare.utils.misc import format_size from rare.widgets.dialogs import ActionDialog, dialog_title_game
from rare.widgets.collapsible_widget import CollapsibleFrame from rare.widgets.collapsible_widget import CollapsibleFrame
from rare.widgets.indicator_edit import PathEdit, IndicatorReasonsCommon from rare.widgets.indicator_edit import PathEdit, IndicatorReasonsCommon
@ -30,22 +29,37 @@ class InstallDialogAdvanced(CollapsibleFrame):
super(InstallDialogAdvanced, self).__init__(widget=widget, title=title, parent=parent) super(InstallDialogAdvanced, self).__init__(widget=widget, title=title, parent=parent)
class InstallDialog(QDialog): class InstallDialog(ActionDialog):
result_ready = pyqtSignal(InstallQueueItemModel) result_ready = pyqtSignal(InstallQueueItemModel)
def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None): def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):
super(InstallDialog, self).__init__(parent=parent) super(InstallDialog, self).__init__(parent=parent)
header = self.tr("Install")
bicon = icon("ri.install-line")
if options.repair_mode:
header = self.tr("Repair")
bicon = icon("fa.wrench")
if options.repair_and_update:
header = self.tr("Repair and update")
elif options.update:
header = self.tr("Update")
elif options.reset_sdl:
header = self.tr("Modify")
bicon = icon("fa.gear")
self.setWindowTitle(dialog_title_game(header, rgame.app_title))
install_widget = QWidget(self)
self.ui = Ui_InstallDialog() self.ui = Ui_InstallDialog()
self.ui.setupUi(self) self.ui.setupUi(install_widget)
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint) self.ui.title_label.setText(f"<h4>{dialog_title_game(header, rgame.app_title)}</h4>")
# lk: set object names for CSS properties
self.ui.install_button.setObjectName("InstallButton")
self.core = rgame.core self.core = rgame.core
self.rgame = rgame self.rgame = rgame
self.options = options self.__options: InstallOptionsModel = options
self.__download: Optional[InstallDownloadModel] = None self.__download: Optional[InstallDownloadModel] = None
self.__queue_item: Optional[InstallQueueItemModel] = None
self.advanced = InstallDialogAdvanced(parent=self) self.advanced = InstallDialogAdvanced(parent=self)
self.ui.advanced_layout.addWidget(self.advanced) self.ui.advanced_layout.addWidget(self.advanced)
@ -54,25 +68,10 @@ class InstallDialog(QDialog):
self.ui.selectable_layout.addWidget(self.selectable) self.ui.selectable_layout.addWidget(self.selectable)
self.options_changed = False self.options_changed = False
self.worker_running = False
self.reject_close = True
self.threadpool = QThreadPool(self) self.threadpool = QThreadPool(self)
self.threadpool.setMaxThreadCount(1) self.threadpool.setMaxThreadCount(1)
if options.repair_mode:
header = self.tr("Repair")
if options.repair_and_update:
header = self.tr("Repair and update")
elif options.update:
header = self.tr("Update")
elif options.reset_sdl:
header = self.tr("Modify")
else:
header = self.tr("Install")
self.ui.title_label.setText(f'<h4>{header} "{self.rgame.app_title}"</h4>')
self.setWindowTitle(f'{header} "{self.rgame.app_title}" - {QCoreApplication.instance().applicationName()}')
if options.base_path: if options.base_path:
base_path = options.base_path base_path = options.base_path
elif rgame.is_installed: elif rgame.is_installed:
@ -87,8 +86,8 @@ class InstallDialog(QDialog):
save_func=self.save_install_edit, save_func=self.save_install_edit,
parent=self, parent=self,
) )
self.ui.install_dialog_layout.setWidget( self.ui.main_layout.setWidget(
self.ui.install_dialog_layout.getWidgetPosition(self.ui.install_dir_label)[0], self.ui.main_layout.getWidgetPosition(self.ui.install_dir_label)[0],
QFormLayout.FieldRole, self.install_dir_edit QFormLayout.FieldRole, self.install_dir_edit
) )
@ -139,9 +138,9 @@ class InstallDialog(QDialog):
self.reset_sdl_list(self.ui.platform_combo.currentIndex()) self.reset_sdl_list(self.ui.platform_combo.currentIndex())
self.check_incompatible_platform(self.ui.platform_combo.currentIndex()) self.check_incompatible_platform(self.ui.platform_combo.currentIndex())
self.ui.install_button.setEnabled(False) self.accept_button.setEnabled(False)
if self.options.overlay: if self.__options.overlay:
self.ui.platform_label.setEnabled(False) self.ui.platform_label.setEnabled(False)
self.ui.platform_combo.setEnabled(False) self.ui.platform_combo.setEnabled(False)
self.advanced.ui.ignore_space_label.setEnabled(False) self.advanced.ui.ignore_space_label.setEnabled(False)
@ -166,13 +165,17 @@ class InstallDialog(QDialog):
self.non_reload_option_changed("shortcut") self.non_reload_option_changed("shortcut")
self.ui.cancel_button.clicked.connect(self.__on_cancel) self.advanced.ui.install_prereqs_check.setChecked(self.__options.install_prereqs)
self.ui.verify_button.clicked.connect(self.__on_verify)
self.ui.install_button.clicked.connect(self.__on_install)
self.advanced.ui.install_prereqs_check.setChecked(self.options.install_prereqs) # lk: set object names for CSS properties
self.accept_button.setText(header)
self.accept_button.setIcon(bicon)
self.accept_button.setObjectName("InstallButton")
self.ui.install_dialog_layout.setSizeConstraint(QLayout.SetFixedSize) self.action_button.setText(self.tr("Verify"))
self.action_button.setIcon(icon("fa.check"))
self.setCentralWidget(install_widget)
def showEvent(self, a0: QShowEvent) -> None: def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous(): if a0.spontaneous():
@ -181,13 +184,11 @@ class InstallDialog(QDialog):
super().showEvent(a0) super().showEvent(a0)
def execute(self): def execute(self):
if self.options.silent: if self.__options.silent:
self.reject_close = False
self.get_download_info() self.get_download_info()
else: else:
self.setModal(True) self.action_handler()
self.__on_verify() self.open()
self.show()
@pyqtSlot(int) @pyqtSlot(int)
def reset_install_dir(self, index: int): def reset_install_dir(self, index: int):
@ -242,50 +243,46 @@ class InstallDialog(QDialog):
self.error_box() self.error_box()
def get_options(self): def get_options(self):
self.options.base_path = "" if self.rgame.is_installed else self.install_dir_edit.text() self.__options.base_path = "" if self.rgame.is_installed else self.install_dir_edit.text()
self.options.max_workers = self.advanced.ui.max_workers_spin.value() self.__options.max_workers = self.advanced.ui.max_workers_spin.value()
self.options.shared_memory = self.advanced.ui.max_memory_spin.value() self.__options.shared_memory = self.advanced.ui.max_memory_spin.value()
self.options.order_opt = self.advanced.ui.dl_optimizations_check.isChecked() self.__options.order_opt = self.advanced.ui.dl_optimizations_check.isChecked()
self.options.force = self.advanced.ui.force_download_check.isChecked() self.__options.force = self.advanced.ui.force_download_check.isChecked()
self.options.ignore_space = self.advanced.ui.ignore_space_check.isChecked() self.__options.ignore_space = self.advanced.ui.ignore_space_check.isChecked()
self.options.no_install = self.advanced.ui.download_only_check.isChecked() self.__options.no_install = self.advanced.ui.download_only_check.isChecked()
self.options.platform = self.ui.platform_combo.currentText() self.__options.platform = self.ui.platform_combo.currentText()
self.options.install_prereqs = self.advanced.ui.install_prereqs_check.isChecked() self.__options.install_prereqs = self.advanced.ui.install_prereqs_check.isChecked()
self.options.create_shortcut = self.ui.shortcut_check.isChecked() self.__options.create_shortcut = self.ui.shortcut_check.isChecked()
if self.selectable_checks: if self.selectable_checks:
self.options.install_tag = [""] self.__options.install_tag = [""]
for cb in self.selectable_checks: for cb in self.selectable_checks:
if data := cb.isChecked(): if data := cb.isChecked():
# noinspection PyTypeChecker # noinspection PyTypeChecker
self.options.install_tag.extend(data) self.__options.install_tag.extend(data)
def get_download_info(self): def get_download_info(self):
self.__download = None self.__download = None
info_worker = InstallInfoWorker(self.core, self.options) info_worker = InstallInfoWorker(self.core, self.__options)
info_worker.signals.result.connect(self.on_worker_result) info_worker.signals.result.connect(self.on_worker_result)
info_worker.signals.failed.connect(self.on_worker_failed) info_worker.signals.failed.connect(self.on_worker_failed)
info_worker.signals.finished.connect(self.on_worker_finished)
self.worker_running = True
self.threadpool.start(info_worker) self.threadpool.start(info_worker)
def __on_verify(self): def action_handler(self):
self.error_box() self.error_box()
message = self.tr("Updating...") message = self.tr("Updating...")
self.ui.download_size_text.setText(message) self.ui.download_size_text.setText(message)
self.ui.download_size_text.setStyleSheet("font-style: italic; font-weight: normal") self.ui.download_size_text.setStyleSheet("font-style: italic; font-weight: normal")
self.ui.install_size_text.setText(message) self.ui.install_size_text.setText(message)
self.ui.install_size_text.setStyleSheet("font-style: italic; font-weight: normal") self.ui.install_size_text.setStyleSheet("font-style: italic; font-weight: normal")
self.ui.cancel_button.setEnabled(False) self.setActive(True)
self.ui.verify_button.setEnabled(False)
self.ui.install_button.setEnabled(False)
self.options_changed = False self.options_changed = False
self.get_options() self.get_options()
self.get_download_info() self.get_download_info()
def option_changed(self, path) -> Tuple[bool, str, int]: def option_changed(self, path) -> Tuple[bool, str, int]:
self.options_changed = True self.options_changed = True
self.ui.install_button.setEnabled(False) self.accept_button.setEnabled(False)
self.ui.verify_button.setEnabled(not self.worker_running) self.action_button.setEnabled(not self.active())
return True, path, IndicatorReasonsCommon.VALID return True, path, IndicatorReasonsCommon.VALID
def save_install_edit(self, path: str): def save_install_edit(self, path: str):
@ -296,33 +293,18 @@ class InstallDialog(QDialog):
def non_reload_option_changed(self, option: str): def non_reload_option_changed(self, option: str):
if option == "download_only": if option == "download_only":
self.options.no_install = self.advanced.ui.download_only_check.isChecked() self.__options.no_install = self.advanced.ui.download_only_check.isChecked()
elif option == "shortcut": elif option == "shortcut":
QSettings().setValue("create_shortcut", self.ui.shortcut_check.isChecked()) QSettings().setValue("create_shortcut", self.ui.shortcut_check.isChecked())
self.options.create_shortcut = self.ui.shortcut_check.isChecked() self.__options.create_shortcut = self.ui.shortcut_check.isChecked()
elif option == "install_prereqs": elif option == "install_prereqs":
self.options.install_prereqs = self.advanced.ui.install_prereqs_check.isChecked() self.__options.install_prereqs = self.advanced.ui.install_prereqs_check.isChecked()
def __on_cancel(self):
if self.config_tags is not None:
config_helper.add_option(self.rgame.app_name, 'install_tags', ','.join(self.config_tags))
else:
# lk: this is purely for cleaning any install tags we might have added erroneously to the config
config_helper.remove_option(self.rgame.app_name, 'install_tags')
self.__download = None
self.reject_close = False
self.close()
def __on_install(self):
self.reject_close = False
self.close()
@staticmethod @staticmethod
def same_platform(download: InstallDownloadModel) -> bool: def same_platform(download: InstallDownloadModel) -> bool:
platform = download.igame.platform platform = download.igame.platform
if pf.system() == "Windows": if pf.system() == "Windows":
return platform == "Windows" or platform == "Win32" return platform in {"Windows", "Win32"}
elif pf.system() == "Darwin": elif pf.system() == "Darwin":
return platform == "Mac" return platform == "Mac"
else: else:
@ -330,6 +312,7 @@ class InstallDialog(QDialog):
@pyqtSlot(InstallDownloadModel) @pyqtSlot(InstallDownloadModel)
def on_worker_result(self, download: InstallDownloadModel): def on_worker_result(self, download: InstallDownloadModel):
self.setActive(False)
self.__download = download self.__download = download
download_size = download.analysis.dl_size download_size = download.analysis.dl_size
install_size = download.analysis.install_size install_size = download.analysis.install_size
@ -337,14 +320,13 @@ class InstallDialog(QDialog):
if download_size or (not download_size and (download.game.is_dlc or download.repair)): if download_size or (not download_size and (download.game.is_dlc or download.repair)):
self.ui.download_size_text.setText(format_size(download_size)) self.ui.download_size_text.setText(format_size(download_size))
self.ui.download_size_text.setStyleSheet("font-style: normal; font-weight: bold") self.ui.download_size_text.setStyleSheet("font-style: normal; font-weight: bold")
self.ui.install_button.setEnabled(not self.options_changed) self.accept_button.setEnabled(not self.options_changed)
else: else:
self.ui.install_size_text.setText(self.tr("Game already installed")) self.ui.install_size_text.setText(self.tr("Game already installed"))
self.ui.install_size_text.setStyleSheet("font-style: italics; font-weight: normal") self.ui.install_size_text.setStyleSheet("font-style: italics; font-weight: normal")
self.ui.install_size_text.setText(format_size(install_size)) self.ui.install_size_text.setText(format_size(install_size))
self.ui.install_size_text.setStyleSheet("font-style: normal; font-weight: bold") self.ui.install_size_text.setStyleSheet("font-style: normal; font-weight: bold")
self.ui.verify_button.setEnabled(self.options_changed) self.action_button.setEnabled(self.options_changed)
self.ui.cancel_button.setEnabled(True)
has_prereqs = bool(download.igame.prereq_info) and not download.igame.prereq_info.get("installed", False) has_prereqs = bool(download.igame.prereq_info) and not download.igame.prereq_info.get("installed", False)
if has_prereqs: if has_prereqs:
prereq_name = download.igame.prereq_info.get("name", "") prereq_name = download.igame.prereq_info.get("name", "")
@ -357,18 +339,19 @@ class InstallDialog(QDialog):
self.advanced.ui.install_prereqs_label.setEnabled(has_prereqs) self.advanced.ui.install_prereqs_label.setEnabled(has_prereqs)
self.advanced.ui.install_prereqs_check.setEnabled(has_prereqs) self.advanced.ui.install_prereqs_check.setEnabled(has_prereqs)
self.advanced.ui.install_prereqs_check.setChecked(has_prereqs and self.same_platform(download)) self.advanced.ui.install_prereqs_check.setChecked(has_prereqs and self.same_platform(download))
if self.options.silent: if self.__options.silent:
self.close() self.accept()
def on_worker_failed(self, message: str): def on_worker_failed(self, message: str):
self.setActive(False)
error_text = self.tr("Error") error_text = self.tr("Error")
self.ui.download_size_text.setText(error_text) self.ui.download_size_text.setText(error_text)
self.ui.install_size_text.setText(error_text) self.ui.install_size_text.setText(error_text)
self.error_box(error_text, message) self.error_box(error_text, message)
self.ui.verify_button.setEnabled(self.options_changed) self.action_button.setEnabled(self.options_changed)
self.ui.cancel_button.setEnabled(True) self.accept_button.setEnabled(False)
if self.options.silent: if self.__options.silent:
self.show() self.open()
def error_box(self, label: str = "", message: str = ""): def error_box(self, label: str = "", message: str = ""):
self.ui.warning_label.setVisible(bool(label)) self.ui.warning_label.setVisible(bool(label))
@ -376,25 +359,23 @@ class InstallDialog(QDialog):
self.ui.warning_text.setVisible(bool(message)) self.ui.warning_text.setVisible(bool(message))
self.ui.warning_text.setText(message) self.ui.warning_text.setText(message)
def on_worker_finished(self): def done_handler(self):
self.worker_running = False self.threadpool.clear()
self.threadpool.waitForDone()
self.result_ready.emit(self.__queue_item)
# lk: happens when close() is called, also when top right 'X' is pressed. # lk: __download is already set at this point so just do nothing.
# lk: reject any events not coming from the buttons in case the WM def accept_handler(self):
# lk: doesn't honor the window hints self.__queue_item = InstallQueueItemModel(options=self.__options, download=self.__download)
def closeEvent(self, a0: QCloseEvent) -> None:
if self.reject_close:
a0.ignore()
else:
self.threadpool.clear()
self.threadpool.waitForDone()
self.result_ready.emit(InstallQueueItemModel(options=self.options, download=self.__download))
super(InstallDialog, self).closeEvent(a0)
def keyPressEvent(self, e: QKeyEvent) -> None: def reject_handler(self):
if e.key() == Qt.Key_Escape: # FIXME: This is implemented through the selective downloads dialog now. remove soon
e.accept() # if self.config_tags is not None:
self.__on_cancel() # config_helper.set_option(self.rgame.app_name, 'install_tags', ','.join(self.config_tags))
# else:
# # lk: this is purely for cleaning any install tags we might have added erroneously to the config
# config_helper.remove_option(self.rgame.app_name, 'install_tags')
self.__queue_item = InstallQueueItemModel(options=self.__options, download=None)
class TagCheckBox(QCheckBox): class TagCheckBox(QCheckBox):

View file

@ -14,20 +14,20 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_InstallDialog(object): class Ui_InstallDialog(object):
def setupUi(self, InstallDialog): def setupUi(self, InstallDialog):
InstallDialog.setObjectName("InstallDialog") InstallDialog.setObjectName("InstallDialog")
InstallDialog.resize(272, 238) InstallDialog.resize(179, 204)
InstallDialog.setWindowTitle("InstallDialog") InstallDialog.setWindowTitle("InstallDialog")
self.install_dialog_layout = QtWidgets.QFormLayout(InstallDialog) self.main_layout = QtWidgets.QFormLayout(InstallDialog)
self.install_dialog_layout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.main_layout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.install_dialog_layout.setObjectName("install_dialog_layout") self.main_layout.setObjectName("main_layout")
self.title_label = QtWidgets.QLabel(InstallDialog) self.title_label = QtWidgets.QLabel(InstallDialog)
self.title_label.setObjectName("title_label") self.title_label.setObjectName("title_label")
self.install_dialog_layout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.title_label) self.main_layout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.title_label)
self.install_dir_label = QtWidgets.QLabel(InstallDialog) self.install_dir_label = QtWidgets.QLabel(InstallDialog)
self.install_dir_label.setObjectName("install_dir_label") self.install_dir_label.setObjectName("install_dir_label")
self.install_dialog_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.install_dir_label) self.main_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.install_dir_label)
self.platform_label = QtWidgets.QLabel(InstallDialog) self.platform_label = QtWidgets.QLabel(InstallDialog)
self.platform_label.setObjectName("platform_label") self.platform_label.setObjectName("platform_label")
self.install_dialog_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.platform_label) self.main_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.platform_label)
self.platform_combo = QtWidgets.QComboBox(InstallDialog) self.platform_combo = QtWidgets.QComboBox(InstallDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
@ -35,43 +35,54 @@ class Ui_InstallDialog(object):
sizePolicy.setHeightForWidth(self.platform_combo.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.platform_combo.sizePolicy().hasHeightForWidth())
self.platform_combo.setSizePolicy(sizePolicy) self.platform_combo.setSizePolicy(sizePolicy)
self.platform_combo.setObjectName("platform_combo") self.platform_combo.setObjectName("platform_combo")
self.install_dialog_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.platform_combo) self.main_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.platform_combo)
self.shortcut_label = QtWidgets.QLabel(InstallDialog) self.shortcut_label = QtWidgets.QLabel(InstallDialog)
self.shortcut_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.shortcut_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.shortcut_label.setObjectName("shortcut_label") self.shortcut_label.setObjectName("shortcut_label")
self.install_dialog_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.shortcut_label) self.main_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.shortcut_label)
self.shortcut_check = QtWidgets.QCheckBox(InstallDialog) self.shortcut_check = QtWidgets.QCheckBox(InstallDialog)
self.shortcut_check.setText("") self.shortcut_check.setText("")
self.shortcut_check.setObjectName("shortcut_check") self.shortcut_check.setObjectName("shortcut_check")
self.install_dialog_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.shortcut_check) self.main_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.shortcut_check)
self.selectable_layout = QtWidgets.QVBoxLayout() self.selectable_layout = QtWidgets.QVBoxLayout()
self.selectable_layout.setObjectName("selectable_layout") self.selectable_layout.setObjectName("selectable_layout")
self.install_dialog_layout.setLayout(4, QtWidgets.QFormLayout.SpanningRole, self.selectable_layout) self.main_layout.setLayout(4, QtWidgets.QFormLayout.SpanningRole, self.selectable_layout)
self.advanced_layout = QtWidgets.QVBoxLayout() self.advanced_layout = QtWidgets.QVBoxLayout()
self.advanced_layout.setObjectName("advanced_layout") self.advanced_layout.setObjectName("advanced_layout")
self.install_dialog_layout.setLayout(5, QtWidgets.QFormLayout.SpanningRole, self.advanced_layout) self.main_layout.setLayout(5, QtWidgets.QFormLayout.SpanningRole, self.advanced_layout)
self.download_size_label = QtWidgets.QLabel(InstallDialog) self.download_size_label = QtWidgets.QLabel(InstallDialog)
self.download_size_label.setObjectName("download_size_label") self.download_size_label.setObjectName("download_size_label")
self.install_dialog_layout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.download_size_label) self.main_layout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.download_size_label)
self.download_size_text = QtWidgets.QLabel(InstallDialog) self.download_size_text = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont() font = QtGui.QFont()
font.setItalic(True) font.setItalic(True)
self.download_size_text.setFont(font) self.download_size_text.setFont(font)
self.download_size_text.setObjectName("download_size_text") self.download_size_text.setObjectName("download_size_text")
self.install_dialog_layout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.download_size_text) self.main_layout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.download_size_text)
self.install_size_label = QtWidgets.QLabel(InstallDialog) self.install_size_label = QtWidgets.QLabel(InstallDialog)
self.install_size_label.setObjectName("install_size_label") self.install_size_label.setObjectName("install_size_label")
self.install_dialog_layout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.install_size_label) self.main_layout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.install_size_label)
self.install_size_text = QtWidgets.QLabel(InstallDialog) self.install_size_text = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont() font = QtGui.QFont()
font.setItalic(True) font.setItalic(True)
self.install_size_text.setFont(font) self.install_size_text.setFont(font)
self.install_size_text.setWordWrap(True) self.install_size_text.setWordWrap(True)
self.install_size_text.setObjectName("install_size_text") self.install_size_text.setObjectName("install_size_text")
self.install_dialog_layout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.install_size_text) self.main_layout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.install_size_text)
self.avail_space_label = QtWidgets.QLabel(InstallDialog)
self.avail_space_label.setObjectName("avail_space_label")
self.main_layout.setWidget(8, QtWidgets.QFormLayout.LabelRole, self.avail_space_label)
self.avail_space = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.avail_space.setFont(font)
self.avail_space.setText("")
self.avail_space.setObjectName("avail_space")
self.main_layout.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.avail_space)
self.warning_label = QtWidgets.QLabel(InstallDialog) self.warning_label = QtWidgets.QLabel(InstallDialog)
self.warning_label.setObjectName("warning_label") self.warning_label.setObjectName("warning_label")
self.install_dialog_layout.setWidget(9, QtWidgets.QFormLayout.LabelRole, self.warning_label) self.main_layout.setWidget(9, QtWidgets.QFormLayout.LabelRole, self.warning_label)
self.warning_text = QtWidgets.QLabel(InstallDialog) self.warning_text = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont() font = QtGui.QFont()
font.setItalic(True) font.setItalic(True)
@ -81,57 +92,29 @@ class Ui_InstallDialog(object):
self.warning_text.setWordWrap(True) self.warning_text.setWordWrap(True)
self.warning_text.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse) self.warning_text.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse)
self.warning_text.setObjectName("warning_text") self.warning_text.setObjectName("warning_text")
self.install_dialog_layout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.warning_text) self.main_layout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.warning_text)
self.button_layout = QtWidgets.QHBoxLayout()
self.button_layout.setObjectName("button_layout")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.button_layout.addItem(spacerItem)
self.cancel_button = QtWidgets.QPushButton(InstallDialog)
self.cancel_button.setObjectName("cancel_button")
self.button_layout.addWidget(self.cancel_button)
self.verify_button = QtWidgets.QPushButton(InstallDialog)
self.verify_button.setObjectName("verify_button")
self.button_layout.addWidget(self.verify_button)
self.install_button = QtWidgets.QPushButton(InstallDialog)
self.install_button.setObjectName("install_button")
self.button_layout.addWidget(self.install_button)
self.install_dialog_layout.setLayout(10, QtWidgets.QFormLayout.SpanningRole, self.button_layout)
self.avail_space_lbl = QtWidgets.QLabel(InstallDialog)
self.avail_space_lbl.setObjectName("avail_space_lbl")
self.install_dialog_layout.setWidget(8, QtWidgets.QFormLayout.LabelRole, self.avail_space_lbl)
self.avail_space = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.avail_space.setFont(font)
self.avail_space.setText("")
self.avail_space.setObjectName("avail_space")
self.install_dialog_layout.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.avail_space)
self.retranslateUi(InstallDialog) self.retranslateUi(InstallDialog)
def retranslateUi(self, InstallDialog): def retranslateUi(self, InstallDialog):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
self.title_label.setText(_translate("InstallDialog", "error")) self.title_label.setText(_translate("InstallDialog", "error"))
self.install_dir_label.setText(_translate("InstallDialog", "Install directory")) self.install_dir_label.setText(_translate("InstallDialog", "Install folder"))
self.platform_label.setText(_translate("InstallDialog", "Platform")) self.platform_label.setText(_translate("InstallDialog", "Platform"))
self.shortcut_label.setText(_translate("InstallDialog", "Create shortcut")) self.shortcut_label.setText(_translate("InstallDialog", "Create shortcut"))
self.download_size_label.setText(_translate("InstallDialog", "Download size")) self.download_size_label.setText(_translate("InstallDialog", "Download size"))
self.download_size_text.setText(_translate("InstallDialog", "Click verify...")) self.download_size_text.setText(_translate("InstallDialog", "Click verify..."))
self.install_size_label.setText(_translate("InstallDialog", "Total install size")) self.install_size_label.setText(_translate("InstallDialog", "Total install size"))
self.install_size_text.setText(_translate("InstallDialog", "Click verify...")) self.install_size_text.setText(_translate("InstallDialog", "Click verify..."))
self.avail_space_label.setText(_translate("InstallDialog", "Available space"))
self.warning_label.setText(_translate("InstallDialog", "Warning")) self.warning_label.setText(_translate("InstallDialog", "Warning"))
self.warning_text.setText(_translate("InstallDialog", "None")) self.warning_text.setText(_translate("InstallDialog", "None"))
self.cancel_button.setText(_translate("InstallDialog", "Cancel"))
self.verify_button.setText(_translate("InstallDialog", "Verify"))
self.install_button.setText(_translate("InstallDialog", "Install"))
self.avail_space_lbl.setText(_translate("InstallDialog", "Available space"))
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)
InstallDialog = QtWidgets.QDialog() InstallDialog = QtWidgets.QWidget()
ui = Ui_InstallDialog() ui = Ui_InstallDialog()
ui.setupUi(InstallDialog) ui.setupUi(InstallDialog)
InstallDialog.show() InstallDialog.show()

View file

@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>InstallDialog</class> <class>InstallDialog</class>
<widget class="QDialog" name="InstallDialog"> <widget class="QWidget" name="InstallDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>272</width> <width>179</width>
<height>238</height> <height>204</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string notr="true">InstallDialog</string> <string notr="true">InstallDialog</string>
</property> </property>
<layout class="QFormLayout" name="install_dialog_layout"> <layout class="QFormLayout" name="main_layout">
<property name="labelAlignment"> <property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
@ -27,7 +27,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="install_dir_label"> <widget class="QLabel" name="install_dir_label">
<property name="text"> <property name="text">
<string>Install directory</string> <string>Install folder</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -112,6 +112,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0">
<widget class="QLabel" name="avail_space_label">
<property name="text">
<string>Available space</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="avail_space">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="0"> <item row="9" column="0">
<widget class="QLabel" name="warning_label"> <widget class="QLabel" name="warning_label">
<property name="text"> <property name="text">
@ -143,64 +163,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0" colspan="2">
<layout class="QHBoxLayout" name="button_layout">
<item>
<spacer name="button_hspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancel_button">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="verify_button">
<property name="text">
<string>Verify</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="install_button">
<property name="text">
<string>Install</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0">
<widget class="QLabel" name="avail_space_lbl">
<property name="text">
<string>Available space</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="avail_space">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>