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):
self.appIndicatorShow()
# 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.topLevelItem(0).child(0)
)
@ -898,18 +900,24 @@ class MyForm(settingsmixin.SMainWindow):
# Show the program window and select send tab
def appIndicatorSend(self):
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
def appIndicatorSubscribe(self):
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
def appIndicatorChannel(self):
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):
widgets = [self.ui.treeWidgetYourIdentities, self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans]
queryReturn = sqlQuery("SELECT toaddress, folder, COUNT(msgid) AS cnt FROM inbox WHERE read = 0 GROUP BY toaddress, folder")
@ -1373,8 +1381,12 @@ class MyForm(settingsmixin.SMainWindow):
currentAddress = self.getCurrentAccount()
if currentAddress:
self.setSendFromComboBox(currentAddress)
self.ui.tabWidgetSend.setCurrentIndex(0)
self.ui.tabWidget.setCurrentIndex(1)
self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
)
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
self.ui.lineEditTo.setFocus()
event.ignore()
elif event.key() == QtCore.Qt.Key_F:
@ -1455,7 +1467,9 @@ class MyForm(settingsmixin.SMainWindow):
return
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.ui.tabWidget.setCurrentIndex(3)
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.chans)
)
# opens 'join chan' dialog
def click_actionJoinChan(self):
@ -1775,7 +1789,8 @@ class MyForm(settingsmixin.SMainWindow):
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
sendMessageToPeople = True
fromAddress = str(self.ui.comboBoxSendFrom.itemData(
@ -1979,7 +1994,9 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0)
self.ui.lineEditSubjectBroadcast.setText('')
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.statusBar().showMessage(_translate(
"MainWindow", "Broadcast queued."), 10000)
@ -2009,10 +2026,12 @@ class MyForm(settingsmixin.SMainWindow):
def setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(self, address):
# If this is a chan then don't let people broadcast because no one
# should subscribe to chan addresses.
if BMConfigParser().safeGetBoolean(str(address), 'mailinglist'):
self.ui.tabWidgetSend.setCurrentIndex(1)
else:
self.ui.tabWidgetSend.setCurrentIndex(0)
self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(
self.ui.sendBroadcast
if BMConfigParser().safeGetBoolean(str(address), 'mailinglist')
else self.ui.sendDirect
))
def rerenderComboBoxSendFrom(self):
self.ui.comboBoxSendFrom.clear()
@ -2480,8 +2499,12 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.lineEditTo.setText(acct.toAddress)
self.ui.lineEditSubject.setText(acct.subject)
self.ui.textEditMessage.setText(acct.message)
self.ui.tabWidgetSend.setCurrentIndex(0)
self.ui.tabWidget.setCurrentIndex(1)
self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
)
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
self.ui.textEditMessage.setFocus()
elif self.dialog.ui.radioButtonRegister.isChecked():
email = str(self.dialog.ui.lineEditEmail.text().toUtf8())
@ -2870,7 +2893,9 @@ class MyForm(settingsmixin.SMainWindow):
'message': self.ui.textEditMessage
}
if toAddressAtCurrentInboxRow == str_broadcast_subscribers:
self.ui.tabWidgetSend.setCurrentIndex(0)
self.ui.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect)
)
# toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
elif not BMConfigParser().has_section(toAddressAtCurrentInboxRow):
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)
else:
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 = {
'subject': self.ui.lineEditSubjectBroadcast,
'from': self.ui.comboBoxSendFromBroadcast,
'message': self.ui.textEditMessageBroadcast
}
self.ui.tabWidgetSend.setCurrentIndex(1)
self.ui.tabWidgetSend.setCurrentIndex(broadcast_tab_index)
toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
if fromAddressAtCurrentInboxRow == tableWidget.item(currentInboxRow, 1).label or (
isinstance(acct, GatewayAccount) and fromAddressAtCurrentInboxRow == acct.relayAddress):
@ -2910,7 +2938,9 @@ class MyForm(settingsmixin.SMainWindow):
widget['subject'].setText(tableWidget.item(currentInboxRow, 2).label)
else:
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()
def on_action_InboxAddSenderToAddressBook(self):
@ -2921,7 +2951,9 @@ class MyForm(settingsmixin.SMainWindow):
# tableWidget.item(currentRow,1).data(Qt.UserRole).toPyObject()
addressAtCurrentInboxRow = tableWidget.item(
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.lineEditAddress.setText(addressAtCurrentInboxRow)
self.click_pushButtonAddAddressBook(dialog)
@ -3170,7 +3202,9 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "No addresses selected."), 10000)
else:
self.statusBar().clearMessage()
self.ui.tabWidget.setCurrentIndex(1)
self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send)
)
def on_action_AddressBookSubscribe(self):
listOfSelectedRows = {}
@ -3184,7 +3218,9 @@ class MyForm(settingsmixin.SMainWindow):
continue
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()
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):
self.popMenuAddressBook = QtGui.QMenu(self)

View File

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

View File

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

View File

@ -36,7 +36,9 @@ class NewChanDialog(QtGui.QDialog, RetranslateMixin):
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
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()))))
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)
else:
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))
# single msg tab
myapp.ui.tabWidgetSend.setCurrentIndex(0)
myapp.ui.tabWidgetSend.setCurrentIndex(
myapp.ui.tabWidgetSend.indexOf(myapp.ui.sendDirect)
)
# send tab
myapp.ui.tabWidget.setCurrentIndex(1)
myapp.ui.tabWidget.setCurrentIndex(
myapp.ui.tabWidget.indexOf(myapp.ui.send)
)