Added menu entry "File -> Go offline/Go online" switching dontconnect

config variable and "Work offline" option to connectDialog.
This commit is contained in:
Dmitri Bogomolov 2018-01-24 18:37:05 +02:00
parent cc63c1270b
commit 25ef9fec51
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 31 additions and 3 deletions

View File

@ -143,6 +143,8 @@ class MyForm(settingsmixin.SMainWindow):
def init_file_menu(self):
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL(
"triggered()"), self.quit)
QtCore.QObject.connect(self.ui.actionNetworkSwitch, QtCore.SIGNAL(
"triggered()"), self.network_switch)
QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL(
"triggered()"), self.click_actionManageKeys)
QtCore.QObject.connect(self.ui.actionDeleteAllTrashedMessages,
@ -1471,7 +1473,7 @@ class MyForm(settingsmixin.SMainWindow):
BMConfigParser().remove_option(
'bitmessagesettings', 'dontconnect')
BMConfigParser().save()
else:
elif self.connectDialogInstance.ui.radioButtonConfigureNetwork.isChecked():
self.click_actionSettings()
def showMigrationWizard(self, level):
@ -2585,6 +2587,14 @@ class MyForm(settingsmixin.SMainWindow):
else:
logger.debug('new address dialog box rejected')
def network_switch(self):
dontconnect_option = not BMConfigParser().safeGetBoolean(
'bitmessagesettings', 'dontconnect')
BMConfigParser().set(
'bitmessagesettings', 'dontconnect', str(dontconnect_option))
BMConfigParser().save()
self.ui.updateNetworkSwitchMenuLabel(dontconnect_option)
# Quit selected from menu or application indicator
def quit(self):
'''quit_msg = "Are you sure you want to exit Bitmessage?"
@ -4446,6 +4456,7 @@ def run():
'bitmessagesettings', 'dontconnect')
if myapp._firstrun:
myapp.showConnectDialog() # ask the user if we may connect
myapp.ui.updateNetworkSwitchMenuLabel()
# try:
# if BMConfigParser().get('bitmessagesettings', 'mailchuck') < 1:

View File

@ -586,6 +586,8 @@ class Ui_MainWindow(object):
icon = QtGui.QIcon.fromTheme(_fromUtf8("dialog-password"))
self.actionManageKeys.setIcon(icon)
self.actionManageKeys.setObjectName(_fromUtf8("actionManageKeys"))
self.actionNetworkSwitch = QtGui.QAction(MainWindow)
self.actionNetworkSwitch.setObjectName(_fromUtf8("actionNetworkSwitch"))
self.actionExit = QtGui.QAction(MainWindow)
icon = QtGui.QIcon.fromTheme(_fromUtf8("application-exit"))
self.actionExit.setIcon(icon)
@ -621,6 +623,7 @@ class Ui_MainWindow(object):
self.menuFile.addAction(self.actionManageKeys)
self.menuFile.addAction(self.actionDeleteAllTrashedMessages)
self.menuFile.addAction(self.actionRegenerateDeterministicAddresses)
self.menuFile.addAction(self.actionNetworkSwitch)
self.menuFile.addAction(self.actionExit)
self.menuSettings.addAction(self.actionSettings)
self.menuHelp.addAction(self.actionHelp)
@ -641,6 +644,16 @@ class Ui_MainWindow(object):
MainWindow.setTabOrder(self.lineEditSubject, self.textEditMessage)
MainWindow.setTabOrder(self.textEditMessage, self.pushButtonAddSubscription)
def updateNetworkSwitchMenuLabel(self, dontconnect=None):
if dontconnect is None:
dontconnect = BMConfigParser().safeGetBoolean(
'bitmessagesettings', 'dontconnect')
self.actionNetworkSwitch.setText(
_translate("MainWindow", "Go online", None)
if dontconnect else
_translate("MainWindow", "Go offline", None)
)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Bitmessage", None))
self.treeWidgetYourIdentities.headerItem().setText(0, _translate("MainWindow", "Identities", None))

View File

@ -39,13 +39,16 @@ class Ui_connectDialog(object):
self.radioButtonConfigureNetwork = QtGui.QRadioButton(connectDialog)
self.radioButtonConfigureNetwork.setObjectName(_fromUtf8("radioButtonConfigureNetwork"))
self.gridLayout.addWidget(self.radioButtonConfigureNetwork, 2, 0, 1, 2)
self.radioButtonWorkOffline = QtGui.QRadioButton(connectDialog)
self.radioButtonWorkOffline.setObjectName(_fromUtf8("radioButtonWorkOffline"))
self.gridLayout.addWidget(self.radioButtonWorkOffline, 3, 0, 1, 2)
spacerItem = QtGui.QSpacerItem(185, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 3, 0, 1, 1)
self.gridLayout.addItem(spacerItem, 4, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(connectDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.gridLayout.addWidget(self.buttonBox, 3, 1, 1, 1)
self.gridLayout.addWidget(self.buttonBox, 4, 1, 1, 1)
self.retranslateUi(connectDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), connectDialog.accept)
@ -57,4 +60,5 @@ class Ui_connectDialog(object):
self.label.setText(_translate("connectDialog", "Bitmessage won\'t connect to anyone until you let it. ", None))
self.radioButtonConnectNow.setText(_translate("connectDialog", "Connect now", None))
self.radioButtonConfigureNetwork.setText(_translate("connectDialog", "Let me configure special network settings first", None))
self.radioButtonWorkOffline.setText(_translate("connectDialog", "Work offline", None))