Set parent of widgets for smoother startup
This commit is contained in:
parent
e8b6726f2f
commit
517d94e641
|
@ -24,7 +24,6 @@ logging.basicConfig(
|
|||
format='[%(name)s] %(levelname)s: %(message)s',
|
||||
level=logging.INFO,
|
||||
filename=file_name,
|
||||
filemode="w"
|
||||
)
|
||||
logger = logging.getLogger("Rare")
|
||||
|
||||
|
@ -62,7 +61,7 @@ class App(QApplication):
|
|||
lang = settings.value("language", get_lang(), type=str)
|
||||
if os.path.exists(lang_path + lang + ".qm"):
|
||||
self.translator.load(lang_path + lang + ".qm")
|
||||
logger.info("Your language is supported")
|
||||
logger.info("Your language is supported: " + lang)
|
||||
elif not lang == "en":
|
||||
logger.info("Your language is not supported")
|
||||
self.installTranslator(self.translator)
|
||||
|
@ -74,7 +73,8 @@ class App(QApplication):
|
|||
# launch app
|
||||
self.launch_dialog = LaunchDialog(self.core)
|
||||
self.launch_dialog.start_app.connect(self.start_app)
|
||||
self.launch_dialog.show()
|
||||
if not args.silent:
|
||||
self.launch_dialog.show()
|
||||
|
||||
def start_app(self):
|
||||
self.mainwindow = MainWindow(self.core, self.args)
|
||||
|
@ -87,6 +87,8 @@ class App(QApplication):
|
|||
QSystemTrayIcon.Information, 4000) if update else None)
|
||||
self.launch_dialog.close()
|
||||
|
||||
self.mainwindow.show()
|
||||
|
||||
def tray(self, reason):
|
||||
if reason == QSystemTrayIcon.DoubleClick:
|
||||
self.mainwindow.show()
|
||||
|
|
|
@ -25,7 +25,7 @@ class MainWindow(QMainWindow):
|
|||
|
||||
self.setGeometry(0, 0, width, height)
|
||||
self.setWindowTitle("Rare - GUI for legendary")
|
||||
self.tab_widget = TabWidget(core)
|
||||
self.tab_widget = TabWidget(core, self)
|
||||
self.setCentralWidget(self.tab_widget)
|
||||
|
||||
# Discord RPC on game launch
|
||||
|
@ -52,7 +52,6 @@ class MainWindow(QMainWindow):
|
|||
self.timer.timeout.connect(self.timer_finished)
|
||||
self.timer.start(1000)
|
||||
|
||||
self.show()
|
||||
|
||||
def timer_finished(self):
|
||||
file_path = os.path.expanduser("~/.cache/rare/lockfile")
|
||||
|
|
|
@ -17,24 +17,25 @@ from rare.utils.models import InstallOptions
|
|||
class TabWidget(QTabWidget):
|
||||
delete_presence = pyqtSignal()
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(TabWidget, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(TabWidget, self).__init__(parent=parent)
|
||||
disabled_tab = 3
|
||||
self.core = core
|
||||
self.setTabBar(TabBar(disabled_tab))
|
||||
|
||||
# Generate Tabs
|
||||
self.games_tab = GameTab(core)
|
||||
updates = self.games_tab.default_widget.game_list.updates
|
||||
self.downloadTab = DownloadTab(core, updates)
|
||||
self.cloud_saves = SyncSaves(core)
|
||||
|
||||
self.settings = SettingsTab(core)
|
||||
|
||||
# add tabs
|
||||
self.games_tab = GameTab(core, self)
|
||||
self.addTab(self.games_tab, self.tr("Games"))
|
||||
|
||||
updates = self.games_tab.default_widget.game_list.updates
|
||||
self.downloadTab = DownloadTab(core, updates, self)
|
||||
self.addTab(self.downloadTab, "Downloads" + (" (" + str(len(updates)) + ")" if len(updates) != 0 else ""))
|
||||
|
||||
self.cloud_saves = SyncSaves(core, self)
|
||||
self.addTab(self.cloud_saves, "Cloud Saves")
|
||||
|
||||
self.settings = SettingsTab(core, self)
|
||||
|
||||
# Space Tab
|
||||
self.addTab(QWidget(), "")
|
||||
self.setTabEnabled(disabled_tab, False)
|
||||
|
|
|
@ -27,8 +27,8 @@ class LoadThread(QThread):
|
|||
class SyncSaves(QScrollArea):
|
||||
finished = pyqtSignal(str)
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(SyncSaves, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(SyncSaves, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
self.load_saves()
|
||||
|
|
|
@ -24,36 +24,36 @@ class DownloadTab(QWidget):
|
|||
thread: QThread
|
||||
dl_queue = []
|
||||
|
||||
def __init__(self, core: LegendaryCore, updates: list):
|
||||
super(DownloadTab, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, updates: list, parent):
|
||||
super(DownloadTab, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.layout = QVBoxLayout()
|
||||
self.active_game: Game = None
|
||||
|
||||
self.installing_game = QLabel(self.tr("No active Download"))
|
||||
self.dl_speed = QLabel()
|
||||
self.cache_used = QLabel()
|
||||
self.downloaded = QLabel()
|
||||
self.time_left = QLabel()
|
||||
|
||||
self.info_layout = QGridLayout()
|
||||
|
||||
self.installing_game = QLabel(self.tr("No active Download"))
|
||||
self.info_layout.addWidget(self.installing_game, 0, 0)
|
||||
self.dl_speed = QLabel()
|
||||
self.info_layout.addWidget(self.dl_speed, 0, 1)
|
||||
self.cache_used = QLabel()
|
||||
self.info_layout.addWidget(self.cache_used, 1, 0)
|
||||
self.downloaded = QLabel()
|
||||
self.info_layout.addWidget(self.downloaded, 1, 1)
|
||||
self.time_left = QLabel()
|
||||
self.info_layout.addWidget(self.time_left, 2, 0)
|
||||
|
||||
self.layout.addLayout(self.info_layout)
|
||||
|
||||
self.mini_layout = QHBoxLayout()
|
||||
self.prog_bar = QProgressBar()
|
||||
self.prog_bar.setMaximum(100)
|
||||
self.mini_layout.addWidget(self.prog_bar)
|
||||
self.prog_bar.setMaximum(100)
|
||||
|
||||
self.kill_button = QPushButton(self.tr("Stop Download"))
|
||||
self.mini_layout.addWidget(self.kill_button)
|
||||
self.kill_button.setDisabled(True)
|
||||
self.kill_button.clicked.connect(self.stop_download)
|
||||
self.mini_layout.addWidget(self.kill_button)
|
||||
|
||||
self.layout.addLayout(self.mini_layout)
|
||||
|
||||
|
@ -62,25 +62,27 @@ class DownloadTab(QWidget):
|
|||
self.queue_widget.update_list.connect(self.update_dl_queue)
|
||||
|
||||
self.updates = QGroupBox(self.tr("Updates"))
|
||||
self.updates.setObjectName("group")
|
||||
self.layout.addWidget(self.updates)
|
||||
self.update_layout = QVBoxLayout()
|
||||
self.updates.setLayout(self.update_layout)
|
||||
|
||||
self.updates.setObjectName("group")
|
||||
|
||||
self.update_widgets = {}
|
||||
|
||||
self.update_text = QLabel(self.tr("No updates available"))
|
||||
self.update_text.setVisible(len(updates) == 0)
|
||||
self.update_layout.addWidget(self.update_text)
|
||||
self.update_text.setVisible(len(updates) == 0)
|
||||
|
||||
for igame in updates:
|
||||
widget = UpdateWidget(core, igame)
|
||||
self.update_widgets[igame.app_name] = widget
|
||||
widget = UpdateWidget(core, igame, self)
|
||||
self.update_layout.addWidget(widget)
|
||||
self.update_widgets[igame.app_name] = widget
|
||||
widget.update.connect(self.update_game)
|
||||
if QSettings().value("auto_update", False, bool):
|
||||
self.update_game(igame.app_name, True)
|
||||
widget.update_button.setDisabled(True)
|
||||
|
||||
self.updates.setLayout(self.update_layout)
|
||||
self.layout.addWidget(self.updates)
|
||||
self.layout.addStretch(1)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
@ -282,8 +284,8 @@ class DownloadTab(QWidget):
|
|||
class UpdateWidget(QWidget):
|
||||
update = pyqtSignal(str)
|
||||
|
||||
def __init__(self, core: LegendaryCore, game: InstalledGame):
|
||||
super(UpdateWidget, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, game: InstalledGame, parent):
|
||||
super(UpdateWidget, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.game = game
|
||||
|
||||
|
|
|
@ -9,21 +9,22 @@ from rare.utils.extra_widgets import SelectViewWidget
|
|||
|
||||
|
||||
class GameTab(QWidget):
|
||||
def __init__(self, core):
|
||||
super(GameTab, self).__init__()
|
||||
def __init__(self, core, parent):
|
||||
super(GameTab, self).__init__(parent=parent)
|
||||
self.layout = QStackedLayout()
|
||||
self.default_widget = Games(core)
|
||||
self.default_widget = Games(core, self)
|
||||
# Signal to show info
|
||||
self.default_widget.game_list.show_game_info.connect(self.show_info)
|
||||
self.default_widget.head_bar.import_game.clicked.connect(lambda: self.layout.setCurrentIndex(2))
|
||||
self.layout.addWidget(self.default_widget)
|
||||
self.game_info = InfoTabs(core)
|
||||
|
||||
self.game_info = InfoTabs(core, self)
|
||||
self.game_info.info.update_list.connect(self.update_list)
|
||||
self.layout.addWidget(self.game_info)
|
||||
|
||||
self.default_widget.head_bar.refresh_list.clicked.connect(self.update_list)
|
||||
|
||||
self.import_widget = ImportWidget(core)
|
||||
self.import_widget = ImportWidget(core, self)
|
||||
self.layout.addWidget(self.import_widget)
|
||||
self.import_widget.back_button.clicked.connect(lambda: self.layout.setCurrentIndex(0))
|
||||
self.import_widget.update_list.connect(self.update_list)
|
||||
|
@ -40,14 +41,14 @@ class GameTab(QWidget):
|
|||
|
||||
|
||||
class Games(QWidget):
|
||||
def __init__(self, core):
|
||||
super(Games, self).__init__()
|
||||
def __init__(self, core, parent):
|
||||
super(Games, self).__init__(parent=parent)
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
self.head_bar = GameListHeadBar()
|
||||
self.head_bar = GameListHeadBar(self)
|
||||
self.head_bar.setObjectName("head_bar")
|
||||
|
||||
self.game_list = GameList(core)
|
||||
self.game_list = GameList(core, self)
|
||||
|
||||
self.head_bar.search_bar.textChanged.connect(
|
||||
lambda: self.game_list.filter(self.head_bar.search_bar.text()))
|
||||
|
@ -69,8 +70,8 @@ class Games(QWidget):
|
|||
|
||||
|
||||
class GameListHeadBar(QWidget):
|
||||
def __init__(self):
|
||||
super(GameListHeadBar, self).__init__()
|
||||
def __init__(self, parent):
|
||||
super(GameListHeadBar, self).__init__(parent=parent)
|
||||
self.layout = QHBoxLayout()
|
||||
self.installed_only = QCheckBox(self.tr("Installed only"))
|
||||
self.settings = QSettings()
|
||||
|
|
|
@ -19,8 +19,8 @@ from custom_legendary.models.game import InstalledGame, Game
|
|||
|
||||
|
||||
class InfoTabs(QTabWidget):
|
||||
def __init__(self, core):
|
||||
super(InfoTabs, self).__init__()
|
||||
def __init__(self, core, parent):
|
||||
super(InfoTabs, self).__init__(parent=parent)
|
||||
self.app_name = ""
|
||||
self.core = core
|
||||
self.setTabBar(SideTabBar())
|
||||
|
@ -29,14 +29,14 @@ class InfoTabs(QTabWidget):
|
|||
self.addTab(QWidget(), icon("mdi.keyboard-backspace", color="white"), self.tr("Back"))
|
||||
self.tabBarClicked.connect(lambda x: self.parent().layout.setCurrentIndex(0) if x == 0 else None)
|
||||
|
||||
self.info = GameInfo(core)
|
||||
self.info = GameInfo(core, self)
|
||||
self.addTab(self.info, self.tr("Game Info"))
|
||||
|
||||
self.settings = GameSettings(core)
|
||||
self.settings = GameSettings(core, self)
|
||||
self.addTab(self.settings, self.tr("Settings"))
|
||||
self.tabBar().setCurrentIndex(1)
|
||||
|
||||
self.dlc_tab = DlcTab(core)
|
||||
self.dlc_tab = DlcTab(core, self)
|
||||
self.addTab(self.dlc_tab, self.tr("DLCs"))
|
||||
|
||||
def update_game(self, app_name, dlcs: list):
|
||||
|
@ -63,8 +63,8 @@ class GameInfo(QScrollArea):
|
|||
verify_game = pyqtSignal(str)
|
||||
verify_threads = {}
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(GameInfo, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(GameInfo, self).__init__(parent=parent)
|
||||
self.widget = QWidget()
|
||||
self.core = core
|
||||
self.layout = QVBoxLayout()
|
||||
|
|
|
@ -15,8 +15,8 @@ class DlcTab(QScrollArea):
|
|||
install_dlc = pyqtSignal(InstallOptions)
|
||||
game: Game
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(DlcTab, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(DlcTab, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.widget = QGroupBox("DLCs")
|
||||
self.widget.setObjectName("group")
|
||||
|
|
|
@ -18,8 +18,8 @@ class GameSettings(QScrollArea):
|
|||
# variable to no update when changing game
|
||||
change = False
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(GameSettings, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(GameSettings, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.widget = QWidget()
|
||||
self.settings = QSettings()
|
||||
|
|
|
@ -28,8 +28,8 @@ class GameList(QStackedWidget):
|
|||
running_games = []
|
||||
active_game = ("", 0)
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(GameList, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(GameList, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.setObjectName("list_widget")
|
||||
|
||||
|
@ -39,10 +39,10 @@ class GameList(QStackedWidget):
|
|||
self.init_ui(icon_view)
|
||||
|
||||
def init_ui(self, icon_view=True):
|
||||
self.icon_scrollarea = QScrollArea()
|
||||
self.icon_widget = QWidget()
|
||||
self.list_scrollarea = QScrollArea()
|
||||
self.list_widget = QWidget()
|
||||
self.icon_scrollarea = QScrollArea(parent=self)
|
||||
self.icon_widget = QWidget(parent=self.icon_scrollarea)
|
||||
self.list_scrollarea = QScrollArea(parent=self)
|
||||
self.list_widget = QWidget(parent=self.list_scrollarea)
|
||||
|
||||
self.icon_scrollarea.setWidgetResizable(True)
|
||||
self.icon_scrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||
|
@ -83,7 +83,10 @@ class GameList(QStackedWidget):
|
|||
pixmap = QPixmap(f"{IMAGE_DIR}/{igame.app_name}/DieselGameBoxTall.png")
|
||||
|
||||
icon_widget = GameWidgetInstalled(igame, self.core, pixmap)
|
||||
self.icon_layout.addWidget(icon_widget)
|
||||
|
||||
list_widget = InstalledListWidget(igame, self.core, pixmap)
|
||||
self.list_layout.addWidget(list_widget)
|
||||
|
||||
icon_widget.show_info.connect(self.show_game_info.emit)
|
||||
list_widget.show_info.connect(self.show_game_info.emit)
|
||||
|
@ -95,8 +98,7 @@ class GameList(QStackedWidget):
|
|||
list_widget.finish_signal.connect(self.finished)
|
||||
list_widget.update_list.connect(lambda: self.update_list(self.settings.value("icon_view", True, bool)))
|
||||
|
||||
self.icon_layout.addWidget(icon_widget)
|
||||
self.list_layout.addWidget(list_widget)
|
||||
|
||||
|
||||
if icon_widget.update_available:
|
||||
self.updates.append(igame)
|
||||
|
|
|
@ -18,8 +18,8 @@ logger = getLogger("Import")
|
|||
class ImportWidget(QWidget):
|
||||
update_list = pyqtSignal()
|
||||
|
||||
def __init__(self, core: LegendaryCore):
|
||||
super(ImportWidget, self).__init__()
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(ImportWidget, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.game_list = [i.app_name for i in self.core.get_game_list()]
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ from rare.utils.extra_widgets import SideTabBar
|
|||
|
||||
|
||||
class SettingsTab(QTabWidget):
|
||||
def __init__(self, core):
|
||||
super(SettingsTab, self).__init__()
|
||||
def __init__(self, core, parent):
|
||||
super(SettingsTab, self).__init__(parent=parent)
|
||||
self.core = core
|
||||
self.setTabBar(SideTabBar())
|
||||
self.setTabPosition(QTabWidget.West)
|
||||
|
|
Loading…
Reference in a new issue