Cancel button shouldn't give warning message if opened from autoconnect window

This commit is contained in:
Saptak S 2021-10-18 19:01:22 +05:30
parent 8f4c804b48
commit 8505bdcca1
No known key found for this signature in database
GPG Key ID: 7B7F1772C0C6FCBF
4 changed files with 23 additions and 18 deletions

View File

@ -49,12 +49,12 @@ class AutoConnect(QtWidgets.QWidget):
QtGui.QPixmap.fromImage( QtGui.QPixmap.fromImage(
QtGui.QImage( QtGui.QImage(
GuiCommon.get_resource_path( GuiCommon.get_resource_path(
"images/{}_logo_text.png".format(common.gui.color_mode) "images/{}_logo_text_bg.png".format(common.gui.color_mode)
) )
) )
) )
) )
self.image_label.setFixedSize(180, 40) self.image_label.setFixedSize(322, 65)
image_layout = QtWidgets.QVBoxLayout() image_layout = QtWidgets.QVBoxLayout()
image_layout.addWidget(self.image_label) image_layout.addWidget(self.image_label)
self.image = QtWidgets.QWidget() self.image = QtWidgets.QWidget()
@ -101,7 +101,7 @@ class AutoConnect(QtWidgets.QWidget):
content_layout.addWidget(cta_widget) content_layout.addWidget(cta_widget)
content_layout.addStretch() content_layout.addStretch()
content_layout.setAlignment(QtCore.Qt.AlignCenter) content_layout.setAlignment(QtCore.Qt.AlignCenter)
content_widget = QtWidgets.QWidgets() content_widget = QtWidgets.QWidget()
content_widget.setLayout(content_layout) content_widget.setLayout(content_layout)
self.layout = QtWidgets.QHBoxLayout() self.layout = QtWidgets.QHBoxLayout()

View File

@ -165,7 +165,9 @@ class MainWindow(QtWidgets.QMainWindow):
# Auto connect OnionShare? # Auto connect OnionShare?
auto_connect = AutoConnect(self.common, self) auto_connect = AutoConnect(self.common, self)
if not auto_connect.auto_connect_enabled: if not auto_connect.auto_connect_enabled:
auto_connect.configure_button.clicked.connect(self.open_tor_settings) auto_connect.configure_button.clicked.connect(
lambda: self.open_tor_settings("autoconnect")
)
auto_connect.connect_button.clicked.connect(self.start_onionshare) auto_connect.connect_button.clicked.connect(self.start_onionshare)
self.setCentralWidget(auto_connect) self.setCentralWidget(auto_connect)
self.show() self.show()
@ -259,12 +261,12 @@ class MainWindow(QtWidgets.QMainWindow):
# Wait 1ms for the event loop to finish closing the TorConnectionDialog # Wait 1ms for the event loop to finish closing the TorConnectionDialog
QtCore.QTimer.singleShot(1, self.open_tor_settings) QtCore.QTimer.singleShot(1, self.open_tor_settings)
def open_tor_settings(self): def open_tor_settings(self, openner=None):
""" """
Open the TorSettingsDialog. Open the TorSettingsDialog.
""" """
self.common.log("MainWindow", "open_tor_settings") self.common.log("MainWindow", "open_tor_settings")
d = TorSettingsDialog(self.common) d = TorSettingsDialog(self.common, openner)
d.settings_saved.connect(self.settings_have_changed) d.settings_saved.connect(self.settings_have_changed)
d.exec_() d.exec_()

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -42,10 +42,11 @@ class TorSettingsDialog(QtWidgets.QDialog):
settings_saved = QtCore.Signal() settings_saved = QtCore.Signal()
def __init__(self, common): def __init__(self, common, openner=None):
super(TorSettingsDialog, self).__init__() super(TorSettingsDialog, self).__init__()
self.common = common self.common = common
self.openner = openner
self.common.log("TorSettingsDialog", "__init__") self.common.log("TorSettingsDialog", "__init__")
@ -692,7 +693,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
self.settings_saved.emit() self.settings_saved.emit()
self.close() self.close()
def cancel_clicked(self): def cancel_clicked(self, openner):
""" """
Cancel button clicked. Cancel button clicked.
""" """
@ -700,6 +701,7 @@ class TorSettingsDialog(QtWidgets.QDialog):
if ( if (
not self.common.gui.local_only not self.common.gui.local_only
and not self.common.gui.onion.is_authenticated() and not self.common.gui.onion.is_authenticated()
and not (self.openner and self.openner == "autoconnect")
): ):
Alert( Alert(
self.common, self.common,
@ -831,10 +833,11 @@ class TorSettingsDialog(QtWidgets.QDialog):
return settings return settings
def closeEvent(self, e): def closeEvent(self, e, openner=None):
self.common.log("TorSettingsDialog", "closeEvent") self.common.log("TorSettingsDialog", "closeEvent")
# On close, if Tor isn't connected, then quit OnionShare altogether # On close, if Tor isn't connected, then quit OnionShare altogether
if not (self.openner and self.openner == "autoconnect"):
if not self.common.gui.local_only: if not self.common.gui.local_only:
if not self.common.gui.onion.is_authenticated(): if not self.common.gui.onion.is_authenticated():
self.common.log( self.common.log(