Followed the recommendation #527 about tab indexes

This commit is contained in:
Dmitri Bogomolov 2018-01-18 16:14:29 +02:00
parent 20288d4ab4
commit b899086d91
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
5 changed files with 86 additions and 35 deletions

View File

@ -884,7 +884,9 @@ class MyForm(settingsmixin.SMainWindow):
def appIndicatorInbox(self, item=None): def appIndicatorInbox(self, item=None):
self.appIndicatorShow() self.appIndicatorShow()
# select inbox # select inbox
self.ui.tabWidget.setCurrentIndex(0) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.inbox)
)
self.ui.treeWidgetYourIdentities.setCurrentItem( self.ui.treeWidgetYourIdentities.setCurrentItem(
self.ui.treeWidgetYourIdentities.topLevelItem(0).child(0) self.ui.treeWidgetYourIdentities.topLevelItem(0).child(0)
) )
@ -898,17 +900,23 @@ class MyForm(settingsmixin.SMainWindow):
# Show the program window and select send tab # Show the program window and select send tab
def appIndicatorSend(self): def appIndicatorSend(self):
self.appIndicatorShow() self.appIndicatorShow()
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
# Show the program window and select subscriptions tab # Show the program window and select subscriptions tab
def appIndicatorSubscribe(self): def appIndicatorSubscribe(self):
self.appIndicatorShow() self.appIndicatorShow()
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.subscriptions)
)
# Show the program window and select channels tab # Show the program window and select channels tab
def appIndicatorChannel(self): def appIndicatorChannel(self):
self.appIndicatorShow() self.appIndicatorShow()
self.ui.tabWidget.setCurrentIndex(3) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.chans)
)
def propagateUnreadCount(self, address = None, folder = "inbox", widget = None, type = 1): def propagateUnreadCount(self, address = None, folder = "inbox", widget = None, type = 1):
widgets = [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] widgets = [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]
@ -1373,8 +1381,12 @@ class MyForm(settingsmixin.SMainWindow):
currentAddress = self.getCurrentAccount() currentAddress = self.getCurrentAccount()
if currentAddress: if currentAddress:
self.setSendFromComboBox(currentAddress) self.setSendFromComboBox(currentAddress)
self.ui.tabWidgetSend.setCurrentIndex(0) self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
)
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
self.ui.lineEditTo.setFocus() self.ui.lineEditTo.setFocus()
event.ignore() event.ignore()
elif event.key() == QtCore.Qt.Key_F: elif event.key() == QtCore.Qt.Key_F:
@ -1455,7 +1467,9 @@ class MyForm(settingsmixin.SMainWindow):
return return
queues.addressGeneratorQueue.put(('createDeterministicAddresses', addressVersionNumber, streamNumberForAddress, "regenerated deterministic address", self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value( queues.addressGeneratorQueue.put(('createDeterministicAddresses', addressVersionNumber, streamNumberForAddress, "regenerated deterministic address", self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(
), self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(), self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked())) ), self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(), self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked()))
self.ui.tabWidget.setCurrentIndex(3) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.chans)
)
# opens 'join chan' dialog # opens 'join chan' dialog
def click_actionJoinChan(self): def click_actionJoinChan(self):
@ -1775,7 +1789,8 @@ class MyForm(settingsmixin.SMainWindow):
self.statusBar().clearMessage() self.statusBar().clearMessage()
if self.ui.tabWidgetSend.currentIndex() == 0: if self.ui.tabWidgetSend.currentIndex() == \
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect):
# message to specific people # message to specific people
sendMessageToPeople = True sendMessageToPeople = True
fromAddress = str(self.ui.comboBoxSendFrom.itemData( fromAddress = str(self.ui.comboBoxSendFrom.itemData(
@ -1979,7 +1994,9 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0) self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0)
self.ui.lineEditSubjectBroadcast.setText('') self.ui.lineEditSubjectBroadcast.setText('')
self.ui.textEditMessageBroadcast.reset() self.ui.textEditMessageBroadcast.reset()
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0) self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0)
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Broadcast queued."), 10000) "MainWindow", "Broadcast queued."), 10000)
@ -2009,10 +2026,12 @@ class MyForm(settingsmixin.SMainWindow):
def setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(self, address): def setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(self, address):
# If this is a chan then don't let people broadcast because no one # If this is a chan then don't let people broadcast because no one
# should subscribe to chan addresses. # should subscribe to chan addresses.
if BMConfigParser().safeGetBoolean(str(address), 'mailinglist'): self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.setCurrentIndex(1) self.ui.tabWidgetSend.indexOf(
else: self.ui.sendBroadcast
self.ui.tabWidgetSend.setCurrentIndex(0) if BMConfigParser().safeGetBoolean(str(address), 'mailinglist')
else self.ui.sendDirect
))
def rerenderComboBoxSendFrom(self): def rerenderComboBoxSendFrom(self):
self.ui.comboBoxSendFrom.clear() self.ui.comboBoxSendFrom.clear()
@ -2480,8 +2499,12 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.lineEditTo.setText(acct.toAddress) self.ui.lineEditTo.setText(acct.toAddress)
self.ui.lineEditSubject.setText(acct.subject) self.ui.lineEditSubject.setText(acct.subject)
self.ui.textEditMessage.setText(acct.message) self.ui.textEditMessage.setText(acct.message)
self.ui.tabWidgetSend.setCurrentIndex(0) self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
)
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
self.ui.textEditMessage.setFocus() self.ui.textEditMessage.setFocus()
elif self.dialog.ui.radioButtonRegister.isChecked(): elif self.dialog.ui.radioButtonRegister.isChecked():
email = str(self.dialog.ui.lineEditEmail.text().toUtf8()) email = str(self.dialog.ui.lineEditEmail.text().toUtf8())
@ -2870,7 +2893,9 @@ class MyForm(settingsmixin.SMainWindow):
'message': self.ui.textEditMessage 'message': self.ui.textEditMessage
} }
if toAddressAtCurrentInboxRow == str_broadcast_subscribers: if toAddressAtCurrentInboxRow == str_broadcast_subscribers:
self.ui.tabWidgetSend.setCurrentIndex(0) self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
)
# toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow # toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
elif not BMConfigParser().has_section(toAddressAtCurrentInboxRow): elif not BMConfigParser().has_section(toAddressAtCurrentInboxRow):
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate( QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate(
@ -2880,13 +2905,16 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok) "MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok)
else: else:
self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow) self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow)
if self.ui.tabWidgetSend.currentIndex() == 1: broadcast_tab_index = self.ui.tabWidgetSend.indexOf(
self.ui.sendBroadcast
)
if self.ui.tabWidgetSend.currentIndex() == broadcast_tab_index:
widget = { widget = {
'subject': self.ui.lineEditSubjectBroadcast, 'subject': self.ui.lineEditSubjectBroadcast,
'from': self.ui.comboBoxSendFromBroadcast, 'from': self.ui.comboBoxSendFromBroadcast,
'message': self.ui.textEditMessageBroadcast 'message': self.ui.textEditMessageBroadcast
} }
self.ui.tabWidgetSend.setCurrentIndex(1) self.ui.tabWidgetSend.setCurrentIndex(broadcast_tab_index)
toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
if fromAddressAtCurrentInboxRow == tableWidget.item(currentInboxRow, 1).label or ( if fromAddressAtCurrentInboxRow == tableWidget.item(currentInboxRow, 1).label or (
isinstance(acct, GatewayAccount) and fromAddressAtCurrentInboxRow == acct.relayAddress): isinstance(acct, GatewayAccount) and fromAddressAtCurrentInboxRow == acct.relayAddress):
@ -2910,7 +2938,9 @@ class MyForm(settingsmixin.SMainWindow):
widget['subject'].setText(tableWidget.item(currentInboxRow, 2).label) widget['subject'].setText(tableWidget.item(currentInboxRow, 2).label)
else: else:
widget['subject'].setText('Re: ' + tableWidget.item(currentInboxRow, 2).label) widget['subject'].setText('Re: ' + tableWidget.item(currentInboxRow, 2).label)
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
widget['message'].setFocus() widget['message'].setFocus()
def on_action_InboxAddSenderToAddressBook(self): def on_action_InboxAddSenderToAddressBook(self):
@ -2921,7 +2951,9 @@ class MyForm(settingsmixin.SMainWindow):
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject() # tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
addressAtCurrentInboxRow = tableWidget.item( addressAtCurrentInboxRow = tableWidget.item(
currentInboxRow, 1).data(Qt.UserRole) currentInboxRow, 1).data(Qt.UserRole)
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
dialog = dialogs.AddAddressDialog(self) dialog = dialogs.AddAddressDialog(self)
dialog.lineEditAddress.setText(addressAtCurrentInboxRow) dialog.lineEditAddress.setText(addressAtCurrentInboxRow)
self.click_pushButtonAddAddressBook(dialog) self.click_pushButtonAddAddressBook(dialog)
@ -3170,7 +3202,9 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "No addresses selected."), 10000) "MainWindow", "No addresses selected."), 10000)
else: else:
self.statusBar().clearMessage() self.statusBar().clearMessage()
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
def on_action_AddressBookSubscribe(self): def on_action_AddressBookSubscribe(self):
listOfSelectedRows = {} listOfSelectedRows = {}
@ -3184,7 +3218,9 @@ class MyForm(settingsmixin.SMainWindow):
continue continue
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8() labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()
self.addSubscription(addressAtCurrentRow, labelAtCurrentRow) self.addSubscription(addressAtCurrentRow, labelAtCurrentRow)
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.subscriptions)
)
def on_context_menuAddressBook(self, point): def on_context_menuAddressBook(self, point):
self.popMenuAddressBook = QtGui.QMenu(self) self.popMenuAddressBook = QtGui.QMenu(self)

View File

@ -634,8 +634,12 @@ class Ui_MainWindow(object):
self.menubar.addAction(self.menuHelp.menuAction()) self.menubar.addAction(self.menuHelp.menuAction())
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(
self.tabWidgetSend.setCurrentIndex(0) self.tabWidget.indexOf(self.inbox)
)
self.tabWidgetSend.setCurrentIndex(
self.tabWidgetSend.indexOf(self.sendDirect)
)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
MainWindow.setTabOrder(self.tableWidgetInbox, self.textEditInboxMessage) MainWindow.setTabOrder(self.tableWidgetInbox, self.textEditInboxMessage)
MainWindow.setTabOrder(self.textEditInboxMessage, self.comboBoxSendFrom) MainWindow.setTabOrder(self.textEditInboxMessage, self.comboBoxSendFrom)

View File

@ -53,15 +53,20 @@ class MessageView(QtGui.QTextBrowser):
def confirmURL(self, link): def confirmURL(self, link):
if link.scheme() == "mailto": if link.scheme() == "mailto":
QtGui.QApplication.activeWindow().ui.lineEditTo.setText(link.path()) window = QtGui.QApplication.activeWindow()
window.ui.lineEditTo.setText(link.path())
if link.hasQueryItem("subject"): if link.hasQueryItem("subject"):
QtGui.QApplication.activeWindow().ui.lineEditSubject.setText(link.queryItemValue("subject")) window.ui.lineEditSubject.setText(
link.queryItemValue("subject"))
if link.hasQueryItem("body"): if link.hasQueryItem("body"):
QtGui.QApplication.activeWindow().ui.textEditMessage.setText(link.queryItemValue("body")) window.ui.textEditMessage.setText(
QtGui.QApplication.activeWindow().setSendFromComboBox() link.queryItemValue("body"))
QtGui.QApplication.activeWindow().ui.tabWidgetSend.setCurrentIndex(0) window.setSendFromComboBox()
QtGui.QApplication.activeWindow().ui.tabWidget.setCurrentIndex(1) window.ui.tabWidgetSend.setCurrentIndex(0)
QtGui.QApplication.activeWindow().ui.textEditMessage.setFocus() window.ui.tabWidget.setCurrentIndex(
window.ui.tabWidget.indexOf(window.ui.send)
)
window.ui.textEditMessage.setFocus()
return return
reply = QtGui.QMessageBox.warning(self, reply = QtGui.QMessageBox.warning(self,
QtGui.QApplication.translate("MessageView", "Follow external link"), QtGui.QApplication.translate("MessageView", "Follow external link"),

View File

@ -36,7 +36,9 @@ class NewChanDialog(QtGui.QDialog, RetranslateMixin):
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True) addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
if len(addressGeneratorReturnValue) > 0 and addressGeneratorReturnValue[0] != 'chan name does not match address': if len(addressGeneratorReturnValue) > 0 and addressGeneratorReturnValue[0] != 'chan name does not match address':
UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text())))) UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text()))))
self.parent.ui.tabWidget.setCurrentIndex(3) self.parent.ui.tabWidget.setCurrentIndex(
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans)
)
self.done(QtGui.QDialog.Accepted) self.done(QtGui.QDialog.Accepted)
else: else:
UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining failed"))) UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining failed")))

View File

@ -129,6 +129,10 @@ def createSupportMessage(myapp):
myapp.ui.textEditMessage.setText(str(QtGui.QApplication.translate("Support", SUPPORT_MESSAGE)).format(version, os, architecture, pythonversion, opensslversion, frozen, portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts)) myapp.ui.textEditMessage.setText(str(QtGui.QApplication.translate("Support", SUPPORT_MESSAGE)).format(version, os, architecture, pythonversion, opensslversion, frozen, portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts))
# single msg tab # single msg tab
myapp.ui.tabWidgetSend.setCurrentIndex(0) myapp.ui.tabWidgetSend.setCurrentIndex(
myapp.ui.tabWidgetSend.indexOf(myapp.ui.sendDirect)
)
# send tab # send tab
myapp.ui.tabWidget.setCurrentIndex(1) myapp.ui.tabWidget.setCurrentIndex(
myapp.ui.tabWidget.indexOf(myapp.ui.send)
)