Add parent=self for AppMainWindow handling

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2025-06-04 16:15:50 +08:00
parent 9d40e84bb7
commit f47bb99bd3
3 changed files with 31 additions and 13 deletions
+14 -5
View File
@@ -73,6 +73,7 @@ class UpdatesManager(WebGETManager):
super().__init__(parent, actionMessage=actionMessage)
def successCallback(self, networkReply, **kwargs):
parent = kwargs.pop('parent', None)
showMessageBox = kwargs.pop('showMessageBox', True)
hasNewVersionCallback = kwargs.pop('hasNewVersionCallback', None)
@@ -86,7 +87,7 @@ class UpdatesManager(WebGETManager):
logger.error(f'bad network reply while checking for updates. {ex}')
if showMessageBox:
self.showErrorMessageBox()
self.showErrorMessageBox(parent)
else:
newVersion = info['tag_name']
@@ -108,7 +109,10 @@ class UpdatesManager(WebGETManager):
hasNewVersionCallback(newVersion)
if showMessageBox:
mbox = QuestionUpdateMBox(icon=AppQMessageBox.Icon.Information)
mbox = QuestionUpdateMBox(
parent=parent,
icon=AppQMessageBox.Icon.Information,
)
mbox.version = newVersion
mbox.setText(mbox.customText())
mbox.setInformativeText(_('Go to download page?'))
@@ -118,7 +122,10 @@ class UpdatesManager(WebGETManager):
mbox.open()
else:
if showMessageBox:
mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Information)
mbox = AppQMessageBox(
parent=parent,
icon=AppQMessageBox.Icon.Information,
)
mbox.setWindowTitle(_(APPLICATION_NAME))
mbox.setText(_(f'{APPLICATION_NAME} is already the latest version'))
@@ -126,8 +133,8 @@ class UpdatesManager(WebGETManager):
mbox.open()
@staticmethod
def showErrorMessageBox():
mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Critical)
def showErrorMessageBox(parent=None):
mbox = AppQMessageBox(parent=parent, icon=AppQMessageBox.Icon.Critical)
mbox.setWindowTitle(_(APPLICATION_NAME))
mbox.setText(_('Check for updates failed'))
@@ -144,9 +151,11 @@ class UpdatesManager(WebGETManager):
self,
showMessageBox=True,
hasNewVersionCallback: Callable[[str], None] = None,
**kwargs,
):
self.webGET(
self.API_URL,
showMessageBox=showMessageBox,
hasNewVersionCallback=hasNewVersionCallback,
**kwargs,
)
@@ -183,6 +183,7 @@ class SubscriptionManager(WebGETManager):
mbox = UpdateSubsInfoMBox(
successArgs=successArgs,
failureArgs=failureArgs,
parent=kwargs.pop('parent', None),
)
if successArgs:
+16 -8
View File
@@ -107,11 +107,12 @@ class AppMainWindow(AppQMainWindow):
# TODO: Need this?
# self.setAttribute(QtCore.Qt.WidgetAttribute.WA_ShowWithoutActivating)
self.updatesManager = UpdatesManager()
self.updatesManager = UpdatesManager(parent=self)
self.networkStateManager = AppNetworkStateManager(parent=self)
self.userServersQTableWidget = UserServersQTableWidget(parent=self)
self.userSubsWindow = UserSubsWindow(
parent=self,
deleteUniqueCallback=lambda unique: self.userServersQTableWidget.deleteItemByIndex(
list(
index
@@ -120,7 +121,7 @@ class AppMainWindow(AppQMainWindow):
)
),
)
self.xrayAssetViewerWindow = XrayAssetViewerWindow()
self.xrayAssetViewerWindow = XrayAssetViewerWindow(parent=self)
self.mainTab = AppQTabWidget()
self.mainTab.addTab(self.userServersQTableWidget, _('Server'))
@@ -204,18 +205,23 @@ class AppMainWindow(AppQMainWindow):
AppQAction(
_('Update Subscription (Use Current Proxy)'),
callback=lambda: self.userServersQTableWidget.updateSubs(
connectedHttpProxyEndpoint()
connectedHttpProxyEndpoint(),
parent=self,
),
),
AppQAction(
_('Update Subscription (Force Proxy)'),
callback=lambda: self.userServersQTableWidget.updateSubs(
'127.0.0.1:10809'
'127.0.0.1:10809',
parent=self,
),
),
AppQAction(
_('Update Subscription (No Proxy)'),
callback=lambda: self.userServersQTableWidget.updateSubs(None),
callback=lambda: self.userServersQTableWidget.updateSubs(
None,
parent=self,
),
),
AppQSeperator(),
AppQAction(
@@ -296,7 +302,7 @@ class AppMainWindow(AppQMainWindow):
_('Check For Updates'),
icon=bootstrapIcon('download.svg'),
checkable=False,
callback=lambda: self.checkForUpdates(),
callback=lambda: self.checkForUpdates(parent=self),
),
AppQSeperator(),
AppQAction(
@@ -340,7 +346,7 @@ class AppMainWindow(AppQMainWindow):
_('Check For Updates'),
icon=bootstrapIcon('download.svg'),
checkable=False,
callback=lambda: self.checkForUpdates(),
callback=lambda: self.checkForUpdates(parent=self),
),
AppQSeperator(),
AppQAction(
@@ -407,7 +413,9 @@ class AppMainWindow(AppQMainWindow):
def getGuiTUNSettings(self, **kwargs):
@functools.lru_cache(None)
def cachedGuiTUNSettings():
return GuiTUNSettings(self, **kwargs)
parent = kwargs.pop('parent', self)
return GuiTUNSettings(parent=parent, **kwargs)
guiTUNSettings = cachedGuiTUNSettings()
guiTUNSettings.factoryToInput(AS_UserTUNSettings())