Loading main window from ui-file

This commit is contained in:
Dmitri Bogomolov 2018-11-07 18:25:11 +02:00
parent 1e640b3135
commit 49c9ef79f9
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
7 changed files with 459 additions and 408 deletions

View File

@ -23,7 +23,6 @@ import state
from debug import logger from debug import logger
from tr import _translate from tr import _translate
from addresses import decodeAddress, addBMIfNotPresent from addresses import decodeAddress, addBMIfNotPresent
from bitmessageui import Ui_MainWindow
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
import namecoin import namecoin
from messageview import MessageView from messageview import MessageView
@ -33,6 +32,7 @@ from foldertree import (
MessageList_AddressWidget, MessageList_SubjectWidget, MessageList_AddressWidget, MessageList_SubjectWidget,
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress, Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress,
MessageList_TimeWidget) MessageList_TimeWidget)
from main import Window
import settingsmixin import settingsmixin
import support import support
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
@ -84,7 +84,7 @@ def openKeysFile():
os.startfile(keysfile) # pylint: disable=no-member os.startfile(keysfile) # pylint: disable=no-member
class MyForm(settingsmixin.SMainWindow): class MainWindow(Window):
# the maximum frequency of message sounds in seconds # the maximum frequency of message sounds in seconds
maxSoundFrequencySec = 60 maxSoundFrequencySec = 60
@ -146,137 +146,137 @@ class MyForm(settingsmixin.SMainWindow):
logger.error("Failed to set locale to %s", lang, exc_info=True) logger.error("Failed to set locale to %s", lang, exc_info=True)
def init_file_menu(self): def init_file_menu(self):
QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL( QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL(
"triggered()"), self.quit) "triggered()"), self.quit)
QtCore.QObject.connect(self.ui.actionNetworkSwitch, QtCore.SIGNAL( QtCore.QObject.connect(self.actionNetworkSwitch, QtCore.SIGNAL(
"triggered()"), self.network_switch) "triggered()"), self.network_switch)
QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL( QtCore.QObject.connect(self.actionManageKeys, QtCore.SIGNAL(
"triggered()"), self.click_actionManageKeys) "triggered()"), self.click_actionManageKeys)
QtCore.QObject.connect(self.ui.actionDeleteAllTrashedMessages, QtCore.QObject.connect(self.actionDeleteAllTrashedMessages,
QtCore.SIGNAL( QtCore.SIGNAL(
"triggered()"), "triggered()"),
self.click_actionDeleteAllTrashedMessages) self.click_actionDeleteAllTrashedMessages)
QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.QObject.connect(self.actionRegenerateDeterministicAddresses,
QtCore.SIGNAL( QtCore.SIGNAL(
"triggered()"), "triggered()"),
self.click_actionRegenerateDeterministicAddresses) self.click_actionRegenerateDeterministicAddresses)
QtCore.QObject.connect(self.ui.pushButtonAddChan, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonAddChan, QtCore.SIGNAL(
"clicked()"), "clicked()"),
self.click_actionJoinChan) # also used for creating chans. self.click_actionJoinChan) # also used for creating chans.
QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonNewAddress, QtCore.SIGNAL(
"clicked()"), self.click_NewAddressDialog) "clicked()"), self.click_NewAddressDialog)
QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonAddAddressBook, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonAddAddressBook) "clicked()"), self.click_pushButtonAddAddressBook)
QtCore.QObject.connect(self.ui.pushButtonAddSubscription, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonAddSubscription, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonAddSubscription) "clicked()"), self.click_pushButtonAddSubscription)
QtCore.QObject.connect(self.ui.pushButtonTTL, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonTTL, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonTTL) "clicked()"), self.click_pushButtonTTL)
QtCore.QObject.connect(self.ui.pushButtonClear, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonClear, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonClear) "clicked()"), self.click_pushButtonClear)
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonSend, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonSend) "clicked()"), self.click_pushButtonSend)
QtCore.QObject.connect(self.ui.pushButtonFetchNamecoinID, QtCore.SIGNAL( QtCore.QObject.connect(self.pushButtonFetchNamecoinID, QtCore.SIGNAL(
"clicked()"), self.click_pushButtonFetchNamecoinID) "clicked()"), self.click_pushButtonFetchNamecoinID)
QtCore.QObject.connect(self.ui.actionSettings, QtCore.SIGNAL( QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL(
"triggered()"), self.click_actionSettings) "triggered()"), self.click_actionSettings)
QtCore.QObject.connect(self.ui.actionAbout, QtCore.SIGNAL( QtCore.QObject.connect(self.actionAbout, QtCore.SIGNAL(
"triggered()"), self.click_actionAbout) "triggered()"), self.click_actionAbout)
QtCore.QObject.connect(self.ui.actionSupport, QtCore.SIGNAL( QtCore.QObject.connect(self.actionSupport, QtCore.SIGNAL(
"triggered()"), self.click_actionSupport) "triggered()"), self.click_actionSupport)
QtCore.QObject.connect(self.ui.actionHelp, QtCore.SIGNAL( QtCore.QObject.connect(self.actionHelp, QtCore.SIGNAL(
"triggered()"), self.click_actionHelp) "triggered()"), self.click_actionHelp)
def init_inbox_popup_menu(self, connectSignal=True): def init_inbox_popup_menu(self, connectSignal=True):
# Popup menu for the Inbox tab # Popup menu for the Inbox tab
self.ui.inboxContextMenuToolbar = QtGui.QToolBar() self.inboxContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionReply = self.ui.inboxContextMenuToolbar.addAction(_translate( self.actionReply = self.inboxContextMenuToolbar.addAction(_translate(
"MainWindow", "Reply to sender"), self.on_action_InboxReply) "MainWindow", "Reply to sender"), self.on_action_InboxReply)
self.actionReplyChan = self.ui.inboxContextMenuToolbar.addAction(_translate( self.actionReplyChan = self.inboxContextMenuToolbar.addAction(_translate(
"MainWindow", "Reply to channel"), self.on_action_InboxReplyChan) "MainWindow", "Reply to channel"), self.on_action_InboxReplyChan)
self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction( self.actionAddSenderToAddressBook = self.inboxContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Add sender to your Address Book"), "MainWindow", "Add sender to your Address Book"),
self.on_action_InboxAddSenderToAddressBook) self.on_action_InboxAddSenderToAddressBook)
self.actionAddSenderToBlackList = self.ui.inboxContextMenuToolbar.addAction( self.actionAddSenderToBlackList = self.inboxContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Add sender to your Blacklist"), "MainWindow", "Add sender to your Blacklist"),
self.on_action_InboxAddSenderToBlackList) self.on_action_InboxAddSenderToBlackList)
self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction( self.actionTrashInboxMessage = self.inboxContextMenuToolbar.addAction(
_translate("MainWindow", "Move to Trash"), _translate("MainWindow", "Move to Trash"),
self.on_action_InboxTrash) self.on_action_InboxTrash)
self.actionUndeleteTrashedMessage = self.ui.inboxContextMenuToolbar.addAction( self.actionUndeleteTrashedMessage = self.inboxContextMenuToolbar.addAction(
_translate("MainWindow", "Undelete"), _translate("MainWindow", "Undelete"),
self.on_action_TrashUndelete) self.on_action_TrashUndelete)
self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction( self.actionForceHtml = self.inboxContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "View HTML code as formatted text"), "MainWindow", "View HTML code as formatted text"),
self.on_action_InboxMessageForceHtml) self.on_action_InboxMessageForceHtml)
self.actionSaveMessageAs = self.ui.inboxContextMenuToolbar.addAction( self.actionSaveMessageAs = self.inboxContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Save message as..."), "MainWindow", "Save message as..."),
self.on_action_InboxSaveMessageAs) self.on_action_InboxSaveMessageAs)
self.actionMarkUnread = self.ui.inboxContextMenuToolbar.addAction( self.actionMarkUnread = self.inboxContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Mark Unread"), self.on_action_InboxMarkUnread) "MainWindow", "Mark Unread"), self.on_action_InboxMarkUnread)
# contextmenu messagelists # contextmenu messagelists
self.ui.tableWidgetInbox.setContextMenuPolicy( self.tableWidgetInbox.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL( self.connect(self.tableWidgetInbox, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuInbox) self.on_context_menuInbox)
self.ui.tableWidgetInboxSubscriptions.setContextMenuPolicy( self.tableWidgetInboxSubscriptions.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.tableWidgetInboxSubscriptions, QtCore.SIGNAL( self.connect(self.tableWidgetInboxSubscriptions, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuInbox) self.on_context_menuInbox)
self.ui.tableWidgetInboxChans.setContextMenuPolicy( self.tableWidgetInboxChans.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.tableWidgetInboxChans, QtCore.SIGNAL( self.connect(self.tableWidgetInboxChans, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuInbox) self.on_context_menuInbox)
def init_identities_popup_menu(self, connectSignal=True): def init_identities_popup_menu(self, connectSignal=True):
# Popup menu for the Your Identities tab # Popup menu for the Your Identities tab
self.ui.addressContextMenuToolbarYourIdentities = QtGui.QToolBar() self.addressContextMenuToolbarYourIdentities = QtGui.QToolBar()
# Actions # Actions
self.actionNewYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction(_translate( self.actionNewYourIdentities = self.addressContextMenuToolbarYourIdentities.addAction(_translate(
"MainWindow", "New"), self.on_action_YourIdentitiesNew) "MainWindow", "New"), self.on_action_YourIdentitiesNew)
self.actionEnableYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionEnableYourIdentities = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Enable"), self.on_action_Enable) "MainWindow", "Enable"), self.on_action_Enable)
self.actionDisableYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionDisableYourIdentities = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Disable"), self.on_action_Disable) "MainWindow", "Disable"), self.on_action_Disable)
self.actionSetAvatarYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionSetAvatarYourIdentities = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Set avatar..."), "MainWindow", "Set avatar..."),
self.on_action_TreeWidgetSetAvatar) self.on_action_TreeWidgetSetAvatar)
self.actionClipboardYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionClipboardYourIdentities = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Copy address to clipboard"), "MainWindow", "Copy address to clipboard"),
self.on_action_Clipboard) self.on_action_Clipboard)
self.actionSpecialAddressBehaviorYourIdentities = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionSpecialAddressBehaviorYourIdentities = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Special address behavior..."), "MainWindow", "Special address behavior..."),
self.on_action_SpecialAddressBehaviorDialog) self.on_action_SpecialAddressBehaviorDialog)
self.actionEmailGateway = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionEmailGateway = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Email gateway"), "MainWindow", "Email gateway"),
self.on_action_EmailGatewayDialog) self.on_action_EmailGatewayDialog)
self.actionMarkAllRead = self.ui.addressContextMenuToolbarYourIdentities.addAction( self.actionMarkAllRead = self.addressContextMenuToolbarYourIdentities.addAction(
_translate( _translate(
"MainWindow", "Mark all messages as read"), "MainWindow", "Mark all messages as read"),
self.on_action_MarkAllRead) self.on_action_MarkAllRead)
self.ui.treeWidgetYourIdentities.setContextMenuPolicy( self.treeWidgetYourIdentities.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.treeWidgetYourIdentities, QtCore.SIGNAL( self.connect(self.treeWidgetYourIdentities, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuYourIdentities) self.on_context_menuYourIdentities)
@ -290,125 +290,125 @@ class MyForm(settingsmixin.SMainWindow):
except TypeError: except TypeError:
continue continue
self.menu_plugins['address'].append( self.menu_plugins['address'].append(
self.ui.addressContextMenuToolbarYourIdentities.addAction( self.addressContextMenuToolbarYourIdentities.addAction(
title, handler title, handler
)) ))
def init_chan_popup_menu(self, connectSignal=True): def init_chan_popup_menu(self, connectSignal=True):
# Actions # Actions
self.actionNew = self.ui.addressContextMenuToolbar.addAction(_translate( self.actionNew = self.addressContextMenuToolbar.addAction(_translate(
"MainWindow", "New"), self.on_action_YourIdentitiesNew) "MainWindow", "New"), self.on_action_YourIdentitiesNew)
self.actionDelete = self.ui.addressContextMenuToolbar.addAction( self.actionDelete = self.addressContextMenuToolbar.addAction(
_translate("MainWindow", "Delete"), _translate("MainWindow", "Delete"),
self.on_action_YourIdentitiesDelete) self.on_action_YourIdentitiesDelete)
self.actionEnable = self.ui.addressContextMenuToolbar.addAction( self.actionEnable = self.addressContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Enable"), self.on_action_Enable) "MainWindow", "Enable"), self.on_action_Enable)
self.actionDisable = self.ui.addressContextMenuToolbar.addAction( self.actionDisable = self.addressContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Disable"), self.on_action_Disable) "MainWindow", "Disable"), self.on_action_Disable)
self.actionSetAvatar = self.ui.addressContextMenuToolbar.addAction( self.actionSetAvatar = self.addressContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Set avatar..."), "MainWindow", "Set avatar..."),
self.on_action_TreeWidgetSetAvatar) self.on_action_TreeWidgetSetAvatar)
self.actionClipboard = self.ui.addressContextMenuToolbar.addAction( self.actionClipboard = self.addressContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Copy address to clipboard"), "MainWindow", "Copy address to clipboard"),
self.on_action_Clipboard) self.on_action_Clipboard)
self.actionSend = self.ui.addressContextMenuToolbar.addAction( self.actionSend = self.addressContextMenuToolbar.addAction(
_translate("MainWindow", "Send message to this chan"), _translate("MainWindow", "Send message to this chan"),
self.on_action_Send) self.on_action_Send)
self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction( self.actionSpecialAddressBehavior = self.addressContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Special address behavior..."), "MainWindow", "Special address behavior..."),
self.on_action_SpecialAddressBehaviorDialog) self.on_action_SpecialAddressBehaviorDialog)
self.ui.treeWidgetChans.setContextMenuPolicy( self.treeWidgetChans.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.treeWidgetChans, QtCore.SIGNAL( self.connect(self.treeWidgetChans, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuChan) self.on_context_menuChan)
def init_addressbook_popup_menu(self, connectSignal=True): def init_addressbook_popup_menu(self, connectSignal=True):
# Popup menu for the Address Book page # Popup menu for the Address Book page
self.ui.addressBookContextMenuToolbar = QtGui.QToolBar() self.addressBookContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction( self.actionAddressBookSend = self.addressBookContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Send message to this address"), "MainWindow", "Send message to this address"),
self.on_action_AddressBookSend) self.on_action_AddressBookSend)
self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction( self.actionAddressBookClipboard = self.addressBookContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Copy address to clipboard"), "MainWindow", "Copy address to clipboard"),
self.on_action_AddressBookClipboard) self.on_action_AddressBookClipboard)
self.actionAddressBookSubscribe = self.ui.addressBookContextMenuToolbar.addAction( self.actionAddressBookSubscribe = self.addressBookContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Subscribe to this address"), "MainWindow", "Subscribe to this address"),
self.on_action_AddressBookSubscribe) self.on_action_AddressBookSubscribe)
self.actionAddressBookSetAvatar = self.ui.addressBookContextMenuToolbar.addAction( self.actionAddressBookSetAvatar = self.addressBookContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Set avatar..."), "MainWindow", "Set avatar..."),
self.on_action_AddressBookSetAvatar) self.on_action_AddressBookSetAvatar)
self.actionAddressBookSetSound = \ self.actionAddressBookSetSound = \
self.ui.addressBookContextMenuToolbar.addAction( self.addressBookContextMenuToolbar.addAction(
_translate("MainWindow", "Set notification sound..."), _translate("MainWindow", "Set notification sound..."),
self.on_action_AddressBookSetSound) self.on_action_AddressBookSetSound)
self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction( self.actionAddressBookNew = self.addressBookContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Add New Address"), self.on_action_AddressBookNew) "MainWindow", "Add New Address"), self.on_action_AddressBookNew)
self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction( self.actionAddressBookDelete = self.addressBookContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Delete"), self.on_action_AddressBookDelete) "MainWindow", "Delete"), self.on_action_AddressBookDelete)
self.ui.tableWidgetAddressBook.setContextMenuPolicy( self.tableWidgetAddressBook.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL( self.connect(self.tableWidgetAddressBook, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuAddressBook) self.on_context_menuAddressBook)
def init_subscriptions_popup_menu(self, connectSignal=True): def init_subscriptions_popup_menu(self, connectSignal=True):
# Actions # Actions
self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsNew = self.subscriptionsContextMenuToolbar.addAction(
_translate("MainWindow", "New"), self.on_action_SubscriptionsNew) _translate("MainWindow", "New"), self.on_action_SubscriptionsNew)
self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsDelete = self.subscriptionsContextMenuToolbar.addAction(
_translate("MainWindow", "Delete"), _translate("MainWindow", "Delete"),
self.on_action_SubscriptionsDelete) self.on_action_SubscriptionsDelete)
self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsClipboard = self.subscriptionsContextMenuToolbar.addAction(
_translate("MainWindow", "Copy address to clipboard"), _translate("MainWindow", "Copy address to clipboard"),
self.on_action_SubscriptionsClipboard) self.on_action_SubscriptionsClipboard)
self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsEnable = self.subscriptionsContextMenuToolbar.addAction(
_translate("MainWindow", "Enable"), _translate("MainWindow", "Enable"),
self.on_action_SubscriptionsEnable) self.on_action_SubscriptionsEnable)
self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsDisable = self.subscriptionsContextMenuToolbar.addAction(
_translate("MainWindow", "Disable"), _translate("MainWindow", "Disable"),
self.on_action_SubscriptionsDisable) self.on_action_SubscriptionsDisable)
self.actionsubscriptionsSetAvatar = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsSetAvatar = self.subscriptionsContextMenuToolbar.addAction(
_translate("MainWindow", "Set avatar..."), _translate("MainWindow", "Set avatar..."),
self.on_action_TreeWidgetSetAvatar) self.on_action_TreeWidgetSetAvatar)
self.actionsubscriptionsSend = self.ui.addressContextMenuToolbar.addAction( self.actionsubscriptionsSend = self.addressContextMenuToolbar.addAction(
_translate("MainWindow", "Send message to this address"), _translate("MainWindow", "Send message to this address"),
self.on_action_Send) self.on_action_Send)
self.ui.treeWidgetSubscriptions.setContextMenuPolicy( self.treeWidgetSubscriptions.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
if connectSignal: if connectSignal:
self.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL( self.connect(self.treeWidgetSubscriptions, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'), 'customContextMenuRequested(const QPoint&)'),
self.on_context_menuSubscriptions) self.on_context_menuSubscriptions)
def init_sent_popup_menu(self, connectSignal=True): def init_sent_popup_menu(self, connectSignal=True):
# Actions # Actions
self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction( self.actionTrashSentMessage = self.sentContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Move to Trash"), self.on_action_SentTrash) "MainWindow", "Move to Trash"), self.on_action_SentTrash)
self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction( self.actionSentClipboard = self.sentContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Copy destination address to clipboard"), "MainWindow", "Copy destination address to clipboard"),
self.on_action_SentClipboard) self.on_action_SentClipboard)
self.actionForceSend = self.ui.sentContextMenuToolbar.addAction( self.actionForceSend = self.sentContextMenuToolbar.addAction(
_translate( _translate(
"MainWindow", "Force send"), self.on_action_ForceSend) "MainWindow", "Force send"), self.on_action_ForceSend)
self.actionSentReply = self.ui.sentContextMenuToolbar.addAction( self.actionSentReply = self.sentContextMenuToolbar.addAction(
_translate("MainWindow", "Send update"), _translate("MainWindow", "Send update"),
self.on_action_SentReply) self.on_action_SentReply)
# self.popMenuSent = QtGui.QMenu( self ) # self.popMenuSent = QtGui.QMenu( self )
@ -416,7 +416,7 @@ class MyForm(settingsmixin.SMainWindow):
# self.popMenuSent.addAction( self.actionTrashSentMessage ) # self.popMenuSent.addAction( self.actionTrashSentMessage )
def rerenderTabTreeSubscriptions(self): def rerenderTabTreeSubscriptions(self):
treeWidget = self.ui.treeWidgetSubscriptions treeWidget = self.treeWidgetSubscriptions
folders = Ui_FolderWidget.folderWeight.keys() folders = Ui_FolderWidget.folderWeight.keys()
folders.remove("new") folders.remove("new")
@ -500,9 +500,9 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderTabTree(self, tab): def rerenderTabTree(self, tab):
if tab == 'messages': if tab == 'messages':
treeWidget = self.ui.treeWidgetYourIdentities treeWidget = self.treeWidgetYourIdentities
elif tab == 'chan': elif tab == 'chan':
treeWidget = self.ui.treeWidgetChans treeWidget = self.treeWidgetChans
folders = Ui_FolderWidget.folderWeight.keys() folders = Ui_FolderWidget.folderWeight.keys()
# sort ascending when creating # sort ascending when creating
@ -521,10 +521,10 @@ class MyForm(settingsmixin.SMainWindow):
isMaillinglist = BMConfigParser().safeGetBoolean( isMaillinglist = BMConfigParser().safeGetBoolean(
toAddress, 'mailinglist') toAddress, 'mailinglist')
if treeWidget == self.ui.treeWidgetYourIdentities: if treeWidget == self.treeWidgetYourIdentities:
if isChan: if isChan:
continue continue
elif treeWidget == self.ui.treeWidgetChans: elif treeWidget == self.treeWidgetChans:
if not isChan: if not isChan:
continue continue
@ -542,7 +542,7 @@ class MyForm(settingsmixin.SMainWindow):
total += cnt total += cnt
if toaddress in db and folder in db[toaddress]: if toaddress in db and folder in db[toaddress]:
db[toaddress][folder] = cnt db[toaddress][folder] = cnt
if treeWidget == self.ui.treeWidgetYourIdentities: if treeWidget == self.treeWidgetYourIdentities:
db[None] = {} db[None] = {}
db[None]["inbox"] = total db[None]["inbox"] = total
db[None]["new"] = total db[None]["new"] = total
@ -614,9 +614,7 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget.setSortingEnabled(True) treeWidget.setSortingEnabled(True)
def __init__(self, parent=None): def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent) super(MainWindow, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.qmytranslator = self.qsystranslator = None self.qmytranslator = self.qsystranslator = None
self.indicatorUpdate = None self.indicatorUpdate = None
@ -666,7 +664,7 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
# Set welcome message # Set welcome message
self.ui.textEditInboxMessage.setText(_translate("MainWindow", """ self.textEditInboxMessage.setText(_translate("MainWindow", """
Welcome to easy and secure Bitmessage Welcome to easy and secure Bitmessage
* send messages to other people * send messages to other people
* send broadcast messages like twitter or * send broadcast messages like twitter or
@ -680,49 +678,49 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderSubscriptions() self.rerenderSubscriptions()
# Initialize the inbox search # Initialize the inbox search
QtCore.QObject.connect(self.ui.inboxSearchLineEdit, QtCore.SIGNAL( QtCore.QObject.connect(self.inboxSearchLineEdit, QtCore.SIGNAL(
"returnPressed()"), self.inboxSearchLineEditReturnPressed) "returnPressed()"), self.inboxSearchLineEditReturnPressed)
QtCore.QObject.connect(self.ui.inboxSearchLineEditSubscriptions, QtCore.SIGNAL( QtCore.QObject.connect(self.inboxSearchLineEditSubscriptions, QtCore.SIGNAL(
"returnPressed()"), self.inboxSearchLineEditReturnPressed) "returnPressed()"), self.inboxSearchLineEditReturnPressed)
QtCore.QObject.connect(self.ui.inboxSearchLineEditChans, QtCore.SIGNAL( QtCore.QObject.connect(self.inboxSearchLineEditChans, QtCore.SIGNAL(
"returnPressed()"), self.inboxSearchLineEditReturnPressed) "returnPressed()"), self.inboxSearchLineEditReturnPressed)
QtCore.QObject.connect(self.ui.inboxSearchLineEdit, QtCore.SIGNAL( QtCore.QObject.connect(self.inboxSearchLineEdit, QtCore.SIGNAL(
"textChanged(QString)"), self.inboxSearchLineEditUpdated) "textChanged(QString)"), self.inboxSearchLineEditUpdated)
QtCore.QObject.connect(self.ui.inboxSearchLineEditSubscriptions, QtCore.SIGNAL( QtCore.QObject.connect(self.inboxSearchLineEditSubscriptions, QtCore.SIGNAL(
"textChanged(QString)"), self.inboxSearchLineEditUpdated) "textChanged(QString)"), self.inboxSearchLineEditUpdated)
QtCore.QObject.connect(self.ui.inboxSearchLineEditChans, QtCore.SIGNAL( QtCore.QObject.connect(self.inboxSearchLineEditChans, QtCore.SIGNAL(
"textChanged(QString)"), self.inboxSearchLineEditUpdated) "textChanged(QString)"), self.inboxSearchLineEditUpdated)
# Initialize addressbook # Initialize addressbook
QtCore.QObject.connect(self.ui.tableWidgetAddressBook, QtCore.SIGNAL( QtCore.QObject.connect(self.tableWidgetAddressBook, QtCore.SIGNAL(
"itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged) "itemChanged(QTableWidgetItem *)"), self.tableWidgetAddressBookItemChanged)
# This is necessary for the completer to work if multiple recipients # This is necessary for the completer to work if multiple recipients
QtCore.QObject.connect(self.ui.lineEditTo, QtCore.SIGNAL( QtCore.QObject.connect(self.lineEditTo, QtCore.SIGNAL(
"cursorPositionChanged(int, int)"), self.ui.lineEditTo.completer().onCursorPositionChanged) "cursorPositionChanged(int, int)"), self.lineEditTo.completer().onCursorPositionChanged)
# show messages from message list # show messages from message list
QtCore.QObject.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL( QtCore.QObject.connect(self.tableWidgetInbox, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked) "itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
QtCore.QObject.connect(self.ui.tableWidgetInboxSubscriptions, QtCore.SIGNAL( QtCore.QObject.connect(self.tableWidgetInboxSubscriptions, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked) "itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
QtCore.QObject.connect(self.ui.tableWidgetInboxChans, QtCore.SIGNAL( QtCore.QObject.connect(self.tableWidgetInboxChans, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.tableWidgetInboxItemClicked) "itemSelectionChanged ()"), self.tableWidgetInboxItemClicked)
# tree address lists # tree address lists
QtCore.QObject.connect(self.ui.treeWidgetYourIdentities, QtCore.SIGNAL( QtCore.QObject.connect(self.treeWidgetYourIdentities, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked) "itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetYourIdentities, QtCore.SIGNAL( QtCore.QObject.connect(self.treeWidgetYourIdentities, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged) "itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL( QtCore.QObject.connect(self.treeWidgetSubscriptions, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked) "itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL( QtCore.QObject.connect(self.treeWidgetSubscriptions, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged) "itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL( QtCore.QObject.connect(self.treeWidgetChans, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked) "itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL( QtCore.QObject.connect(self.treeWidgetChans, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged) "itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect( QtCore.QObject.connect(
self.ui.tabWidget, QtCore.SIGNAL("currentChanged(int)"), self.tabWidget, QtCore.SIGNAL("currentChanged(int)"),
self.tabWidgetCurrentChanged self.tabWidgetCurrentChanged
) )
@ -744,11 +742,11 @@ class MyForm(settingsmixin.SMainWindow):
# Set the icon sizes for the identicons # Set the icon sizes for the identicons
identicon_size = 3*7 identicon_size = 3*7
self.ui.tableWidgetInbox.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.tableWidgetInbox.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.treeWidgetChans.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.treeWidgetChans.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.treeWidgetYourIdentities.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.treeWidgetYourIdentities.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.treeWidgetSubscriptions.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.treeWidgetSubscriptions.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.tableWidgetAddressBook.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.tableWidgetAddressBook.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.UISignalThread = UISignaler.get() self.UISignalThread = UISignaler.get()
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
@ -784,22 +782,22 @@ class MyForm(settingsmixin.SMainWindow):
self.UISignalThread.start() self.UISignalThread.start()
# Key press in tree view # Key press in tree view
self.ui.treeWidgetYourIdentities.keyPressEvent = self.treeWidgetKeyPressEvent self.treeWidgetYourIdentities.keyPressEvent = self.treeWidgetKeyPressEvent
self.ui.treeWidgetSubscriptions.keyPressEvent = self.treeWidgetKeyPressEvent self.treeWidgetSubscriptions.keyPressEvent = self.treeWidgetKeyPressEvent
self.ui.treeWidgetChans.keyPressEvent = self.treeWidgetKeyPressEvent self.treeWidgetChans.keyPressEvent = self.treeWidgetKeyPressEvent
# Key press in addressbook # Key press in addressbook
self.ui.tableWidgetAddressBook.keyPressEvent = self.addressbookKeyPressEvent self.tableWidgetAddressBook.keyPressEvent = self.addressbookKeyPressEvent
# Key press in messagelist # Key press in messagelist
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetKeyPressEvent self.tableWidgetInbox.keyPressEvent = self.tableWidgetKeyPressEvent
self.ui.tableWidgetInboxSubscriptions.keyPressEvent = self.tableWidgetKeyPressEvent self.tableWidgetInboxSubscriptions.keyPressEvent = self.tableWidgetKeyPressEvent
self.ui.tableWidgetInboxChans.keyPressEvent = self.tableWidgetKeyPressEvent self.tableWidgetInboxChans.keyPressEvent = self.tableWidgetKeyPressEvent
# Key press in messageview # Key press in messageview
self.ui.textEditInboxMessage.keyPressEvent = self.textEditKeyPressEvent self.textEditInboxMessage.keyPressEvent = self.textEditKeyPressEvent
self.ui.textEditInboxMessageSubscriptions.keyPressEvent = self.textEditKeyPressEvent self.textEditInboxMessageSubscriptions.keyPressEvent = self.textEditKeyPressEvent
self.ui.textEditInboxMessageChans.keyPressEvent = self.textEditKeyPressEvent self.textEditInboxMessageChans.keyPressEvent = self.textEditKeyPressEvent
# Below this point, it would be good if all of the necessary global data # Below this point, it would be good if all of the necessary global data
# structures were initialized. # structures were initialized.
@ -813,10 +811,10 @@ class MyForm(settingsmixin.SMainWindow):
TTL = 3600 TTL = 3600
elif TTL > 28*24*60*60: # 28 days elif TTL > 28*24*60*60: # 28 days
TTL = 28*24*60*60 TTL = 28*24*60*60
self.ui.horizontalSliderTTL.setSliderPosition((TTL - 3600) ** (1/3.199)) self.horizontalSliderTTL.setSliderPosition((TTL - 3600) ** (1/3.199))
self.updateHumanFriendlyTTLDescription(TTL) self.updateHumanFriendlyTTLDescription(TTL)
QtCore.QObject.connect(self.ui.horizontalSliderTTL, QtCore.SIGNAL( QtCore.QObject.connect(self.horizontalSliderTTL, QtCore.SIGNAL(
"valueChanged(int)"), self.updateTTL) "valueChanged(int)"), self.updateTTL)
self.initSettings() self.initSettings()
@ -826,7 +824,7 @@ class MyForm(settingsmixin.SMainWindow):
self.notifierInit() self.notifierInit()
self.updateStartOnLogon() self.updateStartOnLogon()
self.ui.updateNetworkSwitchMenuLabel() self.updateNetworkSwitchMenuLabel()
self._firstrun = BMConfigParser().safeGetBoolean( self._firstrun = BMConfigParser().safeGetBoolean(
'bitmessagesettings', 'dontconnect') 'bitmessagesettings', 'dontconnect')
@ -878,7 +876,7 @@ class MyForm(settingsmixin.SMainWindow):
stylesheet = "" stylesheet = ""
if numberOfHours < 48: if numberOfHours < 48:
self.ui.labelHumanFriendlyTTLDescription.setText( self.labelHumanFriendlyTTLDescription.setText(
_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfHours) + _translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfHours) +
", " + ", " +
_translate("MainWindow", "not recommended for chans", None, QtCore.QCoreApplication.CodecForTr) _translate("MainWindow", "not recommended for chans", None, QtCore.QCoreApplication.CodecForTr)
@ -887,10 +885,13 @@ class MyForm(settingsmixin.SMainWindow):
font.setBold(True) font.setBold(True)
else: else:
numberOfDays = int(round(TTL / (24*60*60))) numberOfDays = int(round(TTL / (24*60*60)))
self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n day(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfDays)) self.labelHumanFriendlyTTLDescription.setText(
_translate(
"MainWindow", "%n day(s)",
None, QtCore.QCoreApplication.CodecForTr, numberOfDays))
font.setBold(False) font.setBold(False)
self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet) self.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet)
self.ui.labelHumanFriendlyTTLDescription.setFont(font) self.labelHumanFriendlyTTLDescription.setFont(font)
# Show or hide the application window after clicking an item within the # Show or hide the application window after clicking an item within the
# tray icon or, on Windows, the try icon itself. # tray icon or, on Windows, the try icon itself.
@ -942,38 +943,38 @@ 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( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.inbox) self.tabWidget.indexOf(self.inbox)
) )
self.ui.treeWidgetYourIdentities.setCurrentItem( self.treeWidgetYourIdentities.setCurrentItem(
self.ui.treeWidgetYourIdentities.topLevelItem(0).child(0) self.treeWidgetYourIdentities.topLevelItem(0).child(0)
) )
if item: if item:
self.ui.tableWidgetInbox.setCurrentItem(item) self.tableWidgetInbox.setCurrentItem(item)
self.tableWidgetInboxItemClicked() self.tableWidgetInboxItemClicked()
else: else:
self.ui.tableWidgetInbox.setCurrentCell(0, 0) self.tableWidgetInbox.setCurrentCell(0, 0)
# 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( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.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( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.subscriptions) self.tabWidget.indexOf(self.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( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.chans) self.tabWidget.indexOf(self.chans)
) )
def updateUnreadStatus(self, widget, row, msgid, unread=True): def updateUnreadStatus(self, widget, row, msgid, unread=True):
@ -985,7 +986,7 @@ class MyForm(settingsmixin.SMainWindow):
if status != unread: if status != unread:
return return
widgets = [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans] widgets = [self.tableWidgetInbox, self.tableWidgetInboxChans]
rrow = None rrow = None
try: try:
widgets.remove(widget) widgets.remove(widget)
@ -1027,14 +1028,11 @@ class MyForm(settingsmixin.SMainWindow):
totalUnread[fld] += count totalUnread[fld] += count
except KeyError: except KeyError:
totalUnread[fld] = count totalUnread[fld] = count
if widget in ( widgets = [self.treeWidgetYourIdentities]
self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans): if widget not in (
widgets = (self.ui.treeWidgetYourIdentities,) self.treeWidgetSubscriptions, self.treeWidgetChans):
else: widgets += [
widgets = ( self.treeWidgetSubscriptions, self.treeWidgetChans]
self.ui.treeWidgetYourIdentities,
self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans
)
queryReturn = sqlQuery( queryReturn = sqlQuery(
'SELECT fromaddress, folder, COUNT(msgid) AS cnt' 'SELECT fromaddress, folder, COUNT(msgid) AS cnt'
' FROM inbox WHERE read = 0 AND toaddress = ?' ' FROM inbox WHERE read = 0 AND toaddress = ?'
@ -1201,11 +1199,11 @@ class MyForm(settingsmixin.SMainWindow):
# Load Sent items from database # Load Sent items from database
def loadSent(self, tableWidget, account, where="", what=""): def loadSent(self, tableWidget, account, where="", what=""):
if tableWidget == self.ui.tableWidgetInboxSubscriptions: if tableWidget == self.tableWidgetInboxSubscriptions:
tableWidget.setColumnHidden(0, True) tableWidget.setColumnHidden(0, True)
tableWidget.setColumnHidden(1, False) tableWidget.setColumnHidden(1, False)
xAddress = 'toaddress' xAddress = 'toaddress'
elif tableWidget == self.ui.tableWidgetInboxChans: elif tableWidget == self.tableWidgetInboxChans:
tableWidget.setColumnHidden(0, False) tableWidget.setColumnHidden(0, False)
tableWidget.setColumnHidden(1, True) tableWidget.setColumnHidden(1, True)
xAddress = 'both' xAddress = 'both'
@ -1240,7 +1238,7 @@ class MyForm(settingsmixin.SMainWindow):
self.loadSent(tableWidget, account, where, what) self.loadSent(tableWidget, account, where, what)
return return
if tableWidget == self.ui.tableWidgetInboxSubscriptions: if tableWidget == self.tableWidgetInboxSubscriptions:
xAddress = "fromaddress" xAddress = "fromaddress"
if not what: if not what:
where = _translate("MainWindow", "To") where = _translate("MainWindow", "To")
@ -1484,7 +1482,7 @@ class MyForm(settingsmixin.SMainWindow):
self.on_action_AddressBookDelete() self.on_action_AddressBookDelete()
else: else:
return QtGui.QTableWidget.keyPressEvent( return QtGui.QTableWidget.keyPressEvent(
self.ui.tableWidgetAddressBook, event) self.tableWidgetAddressBook, event)
# inbox / sent # inbox / sent
def tableWidgetKeyPressEvent(self, event): def tableWidgetKeyPressEvent(self, event):
@ -1517,7 +1515,7 @@ class MyForm(settingsmixin.SMainWindow):
messagelist.selectRow(currentRow - 1) messagelist.selectRow(currentRow - 1)
event.ignore() event.ignore()
elif event.key() == QtCore.Qt.Key_R: elif event.key() == QtCore.Qt.Key_R:
if messagelist == self.ui.tableWidgetInboxChans: if messagelist == self.tableWidgetInboxChans:
self.on_action_InboxReplyChan() self.on_action_InboxReplyChan()
else: else:
self.on_action_InboxReply() self.on_action_InboxReply()
@ -1526,13 +1524,13 @@ class MyForm(settingsmixin.SMainWindow):
currentAddress = self.getCurrentAccount() currentAddress = self.getCurrentAccount()
if currentAddress: if currentAddress:
self.setSendFromComboBox(currentAddress) self.setSendFromComboBox(currentAddress)
self.ui.tabWidgetSend.setCurrentIndex( self.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect) self.tabWidgetSend.indexOf(self.sendDirect)
) )
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
self.ui.lineEditTo.setFocus() self.lineEditTo.setFocus()
event.ignore() event.ignore()
elif event.key() == QtCore.Qt.Key_F: elif event.key() == QtCore.Qt.Key_F:
try: try:
@ -1581,12 +1579,12 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
self.rerenderTabTreeSubscriptions() self.rerenderTabTreeSubscriptions()
self.rerenderTabTreeChans() self.rerenderTabTreeChans()
if self.getCurrentFolder(self.ui.treeWidgetYourIdentities) == "trash": if self.getCurrentFolder(self.treeWidgetYourIdentities) == "trash":
self.loadMessagelist(self.ui.tableWidgetInbox, self.getCurrentAccount(self.ui.treeWidgetYourIdentities), "trash") self.loadMessagelist(self.tableWidgetInbox, self.getCurrentAccount(self.treeWidgetYourIdentities), "trash")
elif self.getCurrentFolder(self.ui.treeWidgetSubscriptions) == "trash": elif self.getCurrentFolder(self.treeWidgetSubscriptions) == "trash":
self.loadMessagelist(self.ui.tableWidgetInboxSubscriptions, self.getCurrentAccount(self.ui.treeWidgetSubscriptions), "trash") self.loadMessagelist(self.tableWidgetInboxSubscriptions, self.getCurrentAccount(self.treeWidgetSubscriptions), "trash")
elif self.getCurrentFolder(self.ui.treeWidgetChans) == "trash": elif self.getCurrentFolder(self.treeWidgetChans) == "trash":
self.loadMessagelist(self.ui.tableWidgetInboxChans, self.getCurrentAccount(self.ui.treeWidgetChans), "trash") self.loadMessagelist(self.tableWidgetInboxChans, self.getCurrentAccount(self.treeWidgetChans), "trash")
# menu button 'regenerate deterministic addresses' # menu button 'regenerate deterministic addresses'
def click_actionRegenerateDeterministicAddresses(self): def click_actionRegenerateDeterministicAddresses(self):
@ -1632,8 +1630,8 @@ class MyForm(settingsmixin.SMainWindow):
dialog.lineEditPassphrase.text().toUtf8(), dialog.lineEditPassphrase.text().toUtf8(),
dialog.checkBoxEighteenByteRipe.isChecked() dialog.checkBoxEighteenByteRipe.isChecked()
)) ))
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.chans) self.tabWidget.indexOf(self.chans)
) )
# opens 'join chan' dialog # opens 'join chan' dialog
@ -1644,7 +1642,7 @@ class MyForm(settingsmixin.SMainWindow):
dialog = dialogs.ConnectDialog(self) dialog = dialogs.ConnectDialog(self)
if dialog.exec_(): if dialog.exec_():
if dialog.radioButtonConnectNow.isChecked(): if dialog.radioButtonConnectNow.isChecked():
self.ui.updateNetworkSwitchMenuLabel(False) self.updateNetworkSwitchMenuLabel(False)
BMConfigParser().remove_option( BMConfigParser().remove_option(
'bitmessagesettings', 'dontconnect') 'bitmessagesettings', 'dontconnect')
BMConfigParser().save() BMConfigParser().save()
@ -1662,14 +1660,14 @@ class MyForm(settingsmixin.SMainWindow):
def changeEvent(self, event): def changeEvent(self, event):
if event.type() == QtCore.QEvent.LanguageChange: if event.type() == QtCore.QEvent.LanguageChange:
self.ui.retranslateUi(self) self.retranslateUi(self)
self.init_inbox_popup_menu(False) self.init_inbox_popup_menu(False)
self.init_identities_popup_menu(False) self.init_identities_popup_menu(False)
self.init_chan_popup_menu(False) self.init_chan_popup_menu(False)
self.init_addressbook_popup_menu(False) self.init_addressbook_popup_menu(False)
self.init_subscriptions_popup_menu(False) self.init_subscriptions_popup_menu(False)
self.init_sent_popup_menu(False) self.init_sent_popup_menu(False)
self.ui.blackwhitelist.init_blacklist_popup_menu(False) self.blackwhitelist.init_blacklist_popup_menu(False)
if event.type() == QtCore.QEvent.WindowStateChange: if event.type() == QtCore.QEvent.WindowStateChange:
if self.windowState() & QtCore.Qt.WindowMinimized: if self.windowState() & QtCore.Qt.WindowMinimized:
if BMConfigParser().getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform: if BMConfigParser().getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform:
@ -1815,16 +1813,16 @@ class MyForm(settingsmixin.SMainWindow):
def updateSentItemStatusByToAddress(self, toAddress, textToDisplay): def updateSentItemStatusByToAddress(self, toAddress, textToDisplay):
for sent in ( for sent in (
self.ui.tableWidgetInbox, self.tableWidgetInbox,
self.ui.tableWidgetInboxSubscriptions, self.tableWidgetInboxSubscriptions,
self.ui.tableWidgetInboxChans self.tableWidgetInboxChans
): ):
treeWidget = self.widgetConvert(sent) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent": if self.getCurrentFolder(treeWidget) != "sent":
continue continue
if treeWidget in ( if treeWidget in (
self.ui.treeWidgetSubscriptions, self.treeWidgetSubscriptions,
self.ui.treeWidgetChans self.treeWidgetChans
) and self.getCurrentAccount(treeWidget) != toAddress: ) and self.getCurrentAccount(treeWidget) != toAddress:
continue continue
@ -1846,9 +1844,9 @@ class MyForm(settingsmixin.SMainWindow):
if type(ackdata) is str: if type(ackdata) is str:
ackdata = QtCore.QByteArray(ackdata) ackdata = QtCore.QByteArray(ackdata)
for sent in ( for sent in (
self.ui.tableWidgetInbox, self.tableWidgetInbox,
self.ui.tableWidgetInboxSubscriptions, self.tableWidgetInboxSubscriptions,
self.ui.tableWidgetInboxChans self.tableWidgetInboxChans
): ):
treeWidget = self.widgetConvert(sent) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent": if self.getCurrentFolder(treeWidget) != "sent":
@ -1873,9 +1871,9 @@ class MyForm(settingsmixin.SMainWindow):
def removeInboxRowByMsgid(self, msgid): def removeInboxRowByMsgid(self, msgid):
# msgid and inventoryHash are the same thing # msgid and inventoryHash are the same thing
for inbox in ( for inbox in (
self.ui.tableWidgetInbox, self.tableWidgetInbox,
self.ui.tableWidgetInboxSubscriptions, self.tableWidgetInboxSubscriptions,
self.ui.tableWidgetInboxChans self.tableWidgetInboxChans
): ):
i = None i = None
for i in range(inbox.rowCount()): for i in range(inbox.rowCount()):
@ -1908,32 +1906,32 @@ class MyForm(settingsmixin.SMainWindow):
os._exit(0) os._exit(0)
def rerenderMessagelistFromLabels(self): def rerenderMessagelistFromLabels(self):
for messagelist in (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions): for messagelist in (self.tableWidgetInbox, self.tableWidgetInboxChans, self.tableWidgetInboxSubscriptions):
for i in range(messagelist.rowCount()): for i in range(messagelist.rowCount()):
messagelist.item(i, 1).setLabel() messagelist.item(i, 1).setLabel()
def rerenderMessagelistToLabels(self): def rerenderMessagelistToLabels(self):
for messagelist in (self.ui.tableWidgetInbox, self.ui.tableWidgetInboxChans, self.ui.tableWidgetInboxSubscriptions): for messagelist in (self.tableWidgetInbox, self.tableWidgetInboxChans, self.tableWidgetInboxSubscriptions):
for i in range(messagelist.rowCount()): for i in range(messagelist.rowCount()):
messagelist.item(i, 0).setLabel() messagelist.item(i, 0).setLabel()
def rerenderAddressBook(self): def rerenderAddressBook(self):
def addRow (address, label, type): def addRow (address, label, type):
self.ui.tableWidgetAddressBook.insertRow(0) self.tableWidgetAddressBook.insertRow(0)
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type) newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem) self.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type) newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem) self.tableWidgetAddressBook.setItem(0, 1, newItem)
oldRows = {} oldRows = {}
for i in range(self.ui.tableWidgetAddressBook.rowCount()): for i in range(self.tableWidgetAddressBook.rowCount()):
item = self.ui.tableWidgetAddressBook.item(i, 0) item = self.tableWidgetAddressBook.item(i, 0)
oldRows[item.address] = [item.label, item.type, i] oldRows[item.address] = [item.label, item.type, i]
if self.ui.tableWidgetAddressBook.rowCount() == 0: if self.tableWidgetAddressBook.rowCount() == 0:
self.ui.tableWidgetAddressBook.horizontalHeader().setSortIndicator(0, QtCore.Qt.AscendingOrder) self.tableWidgetAddressBook.horizontalHeader().setSortIndicator(0, QtCore.Qt.AscendingOrder)
if self.ui.tableWidgetAddressBook.isSortingEnabled(): if self.tableWidgetAddressBook.isSortingEnabled():
self.ui.tableWidgetAddressBook.setSortingEnabled(False) self.tableWidgetAddressBook.setSortingEnabled(False)
newRows = {} newRows = {}
# subscriptions # subscriptions
@ -1961,16 +1959,16 @@ class MyForm(settingsmixin.SMainWindow):
completerList.append( completerList.append(
newRows.pop(address)[0] + " <" + address + ">") newRows.pop(address)[0] + " <" + address + ">")
except KeyError: except KeyError:
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2]) self.tableWidgetAddressBook.removeRow(oldRows[address][2])
for address in newRows: for address in newRows:
addRow(address, newRows[address][0], newRows[address][1]) addRow(address, newRows[address][0], newRows[address][1])
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">") completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
# sort # sort
self.ui.tableWidgetAddressBook.sortByColumn( self.tableWidgetAddressBook.sortByColumn(
0, QtCore.Qt.AscendingOrder) 0, QtCore.Qt.AscendingOrder)
self.ui.tableWidgetAddressBook.setSortingEnabled(True) self.tableWidgetAddressBook.setSortingEnabled(True)
self.ui.lineEditTo.completer().model().setStringList(completerList) self.lineEditTo.completer().model().setStringList(completerList)
def rerenderSubscriptions(self): def rerenderSubscriptions(self):
self.rerenderTabTreeSubscriptions() self.rerenderTabTreeSubscriptions()
@ -1983,36 +1981,36 @@ class MyForm(settingsmixin.SMainWindow):
more work your computer must do to send the message. A Time-To-Live of four or five days is often appropriate."""), QtGui.QMessageBox.Ok) more work your computer must do to send the message. A Time-To-Live of four or five days is often appropriate."""), QtGui.QMessageBox.Ok)
def click_pushButtonClear(self): def click_pushButtonClear(self):
self.ui.lineEditSubject.setText("") self.lineEditSubject.setText("")
self.ui.lineEditTo.setText("") self.lineEditTo.setText("")
self.ui.textEditMessage.reset() self.textEditMessage.setText("")
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.comboBoxSendFrom.setCurrentIndex(0)
def click_pushButtonSend(self): def click_pushButtonSend(self):
encoding = 3 if QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier else 2 encoding = 3 if QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier else 2
self.statusbar.clearMessage() self.statusbar.clearMessage()
if self.ui.tabWidgetSend.currentIndex() == \ if self.tabWidgetSend.currentIndex() == \
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect): self.tabWidgetSend.indexOf(self.sendDirect):
# message to specific people # message to specific people
sendMessageToPeople = True sendMessageToPeople = True
fromAddress = str(self.ui.comboBoxSendFrom.itemData( fromAddress = str(self.comboBoxSendFrom.itemData(
self.ui.comboBoxSendFrom.currentIndex(), self.comboBoxSendFrom.currentIndex(),
QtCore.Qt.UserRole).toString()) QtCore.Qt.UserRole).toString())
toAddresses = str(self.ui.lineEditTo.text().toUtf8()) toAddresses = str(self.lineEditTo.text().toUtf8())
subject = str(self.ui.lineEditSubject.text().toUtf8()) subject = str(self.lineEditSubject.text().toUtf8())
message = str( message = str(
self.ui.textEditMessage.document().toPlainText().toUtf8()) self.textEditMessage.document().toPlainText().toUtf8())
else: else:
# broadcast message # broadcast message
sendMessageToPeople = False sendMessageToPeople = False
fromAddress = str(self.ui.comboBoxSendFromBroadcast.itemData( fromAddress = str(self.comboBoxSendFromBroadcast.itemData(
self.ui.comboBoxSendFromBroadcast.currentIndex(), self.comboBoxSendFromBroadcast.currentIndex(),
QtCore.Qt.UserRole).toString()) QtCore.Qt.UserRole).toString())
subject = str(self.ui.lineEditSubjectBroadcast.text().toUtf8()) subject = str(self.lineEditSubjectBroadcast.text().toUtf8())
message = str( message = str(
self.ui.textEditMessageBroadcast.document().toPlainText().toUtf8()) self.textEditMessageBroadcast.document().toPlainText().toUtf8())
""" """
The whole network message must fit in 2^18 bytes. The whole network message must fit in 2^18 bytes.
Let's assume 500 bytes of overhead. If someone wants to get that Let's assume 500 bytes of overhead. If someone wants to get that
@ -2182,11 +2180,11 @@ class MyForm(settingsmixin.SMainWindow):
self.click_pushButtonClear() self.click_pushButtonClear()
if self.replyFromTab is not None: if self.replyFromTab is not None:
self.ui.tabWidget.setCurrentIndex(self.replyFromTab) self.tabWidget.setCurrentIndex(self.replyFromTab)
self.replyFromTab = None self.replyFromTab = None
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Message queued.")) "MainWindow", "Message queued."))
# self.ui.tableWidgetInbox.setCurrentCell(0, 0) # self.tableWidgetInbox.setCurrentCell(0, 0)
else: else:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Your \'To\' field is empty.")) "MainWindow", "Your \'To\' field is empty."))
@ -2217,18 +2215,18 @@ class MyForm(settingsmixin.SMainWindow):
queues.workerQueue.put(('sendbroadcast', '')) queues.workerQueue.put(('sendbroadcast', ''))
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0) self.comboBoxSendFromBroadcast.setCurrentIndex(0)
self.ui.lineEditSubjectBroadcast.setText('') self.lineEditSubjectBroadcast.setText('')
self.ui.textEditMessageBroadcast.reset() self.textEditMessageBroadcast.reset()
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0) self.tableWidgetInboxSubscriptions.setCurrentCell(0, 0)
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Broadcast queued.")) "MainWindow", "Broadcast queued."))
def click_pushButtonLoadFromAddressBook(self): def click_pushButtonLoadFromAddressBook(self):
self.ui.tabWidget.setCurrentIndex(5) self.tabWidget.setCurrentIndex(5)
for i in range(4): for i in range(4):
time.sleep(0.1) time.sleep(0.1)
self.statusbar.clearMessage() self.statusbar.clearMessage()
@ -2247,22 +2245,22 @@ class MyForm(settingsmixin.SMainWindow):
_translate("MainWindow", "Error: %1").arg(err)) _translate("MainWindow", "Error: %1").arg(err))
else: else:
identities[-1] = addr identities[-1] = addr
self.ui.lineEditTo.setText("; ".join(identities)) self.lineEditTo.setText("; ".join(identities))
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Fetched address from namecoin identity.")) "MainWindow", "Fetched address from namecoin identity."))
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.
self.ui.tabWidgetSend.setCurrentIndex( self.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf( self.tabWidgetSend.indexOf(
self.ui.sendBroadcast self.sendBroadcast
if BMConfigParser().safeGetBoolean(str(address), 'mailinglist') if BMConfigParser().safeGetBoolean(str(address), 'mailinglist')
else self.ui.sendDirect else self.sendDirect
)) ))
def rerenderComboBoxSendFrom(self): def rerenderComboBoxSendFrom(self):
self.ui.comboBoxSendFrom.clear() self.comboBoxSendFrom.clear()
for addressInKeysFile in getSortedAccounts(): for addressInKeysFile in getSortedAccounts():
isEnabled = BMConfigParser().getboolean( isEnabled = BMConfigParser().getboolean(
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read. addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
@ -2271,22 +2269,22 @@ class MyForm(settingsmixin.SMainWindow):
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip() label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
if label == "": if label == "":
label = addressInKeysFile label = addressInKeysFile
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile) self.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
# self.ui.comboBoxSendFrom.model().sort(1, Qt.AscendingOrder) # self.comboBoxSendFrom.model().sort(1, Qt.AscendingOrder)
for i in range(self.ui.comboBoxSendFrom.count()): for i in range(self.comboBoxSendFrom.count()):
address = str(self.ui.comboBoxSendFrom.itemData( address = str(self.comboBoxSendFrom.itemData(
i, QtCore.Qt.UserRole).toString()) i, QtCore.Qt.UserRole).toString())
self.ui.comboBoxSendFrom.setItemData( self.comboBoxSendFrom.setItemData(
i, AccountColor(address).accountColor(), i, AccountColor(address).accountColor(),
QtCore.Qt.ForegroundRole) QtCore.Qt.ForegroundRole)
self.ui.comboBoxSendFrom.insertItem(0, '', '') self.comboBoxSendFrom.insertItem(0, '', '')
if(self.ui.comboBoxSendFrom.count() == 2): if(self.comboBoxSendFrom.count() == 2):
self.ui.comboBoxSendFrom.setCurrentIndex(1) self.comboBoxSendFrom.setCurrentIndex(1)
else: else:
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.comboBoxSendFrom.setCurrentIndex(0)
def rerenderComboBoxSendFromBroadcast(self): def rerenderComboBoxSendFromBroadcast(self):
self.ui.comboBoxSendFromBroadcast.clear() self.comboBoxSendFromBroadcast.clear()
for addressInKeysFile in getSortedAccounts(): for addressInKeysFile in getSortedAccounts():
isEnabled = BMConfigParser().getboolean( isEnabled = BMConfigParser().getboolean(
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read. addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
@ -2295,18 +2293,18 @@ class MyForm(settingsmixin.SMainWindow):
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip() label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
if label == "": if label == "":
label = addressInKeysFile label = addressInKeysFile
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile) self.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
for i in range(self.ui.comboBoxSendFromBroadcast.count()): for i in range(self.comboBoxSendFromBroadcast.count()):
address = str(self.ui.comboBoxSendFromBroadcast.itemData( address = str(self.comboBoxSendFromBroadcast.itemData(
i, QtCore.Qt.UserRole).toString()) i, QtCore.Qt.UserRole).toString())
self.ui.comboBoxSendFromBroadcast.setItemData( self.comboBoxSendFromBroadcast.setItemData(
i, AccountColor(address).accountColor(), i, AccountColor(address).accountColor(),
QtCore.Qt.ForegroundRole) QtCore.Qt.ForegroundRole)
self.ui.comboBoxSendFromBroadcast.insertItem(0, '', '') self.comboBoxSendFromBroadcast.insertItem(0, '', '')
if(self.ui.comboBoxSendFromBroadcast.count() == 2): if(self.comboBoxSendFromBroadcast.count() == 2):
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(1) self.comboBoxSendFromBroadcast.setCurrentIndex(1)
else: else:
self.ui.comboBoxSendFromBroadcast.setCurrentIndex(0) self.comboBoxSendFromBroadcast.setCurrentIndex(0)
# This function is called by the processmsg function when that function # This function is called by the processmsg function when that function
# receives a message to an address that is acting as a # receives a message to an address that is acting as a
@ -2319,9 +2317,9 @@ class MyForm(settingsmixin.SMainWindow):
acct.parseMessage(toAddress, fromAddress, subject, message) acct.parseMessage(toAddress, fromAddress, subject, message)
tab = -1 tab = -1
for sent in ( for sent in (
self.ui.tableWidgetInbox, self.tableWidgetInbox,
self.ui.tableWidgetInboxSubscriptions, self.tableWidgetInboxSubscriptions,
self.ui.tableWidgetInboxChans self.tableWidgetInboxChans
): ):
tab += 1 tab += 1
if tab == 1: if tab == 1:
@ -2329,13 +2327,15 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget = self.widgetConvert(sent) treeWidget = self.widgetConvert(sent)
if self.getCurrentFolder(treeWidget) != "sent": if self.getCurrentFolder(treeWidget) != "sent":
continue continue
if treeWidget == self.ui.treeWidgetYourIdentities \ if (
and self.getCurrentAccount(treeWidget) not in ( treeWidget == self.treeWidgetYourIdentities
fromAddress, None, False): and self.getCurrentAccount(treeWidget)
not in (fromAddress, None, False)
):
continue continue
elif treeWidget in ( elif treeWidget in (
self.ui.treeWidgetSubscriptions, self.treeWidgetSubscriptions,
self.ui.treeWidgetChans self.treeWidgetChans
) and self.getCurrentAccount(treeWidget) != toAddress: ) and self.getCurrentAccount(treeWidget) != toAddress:
continue continue
elif not helper_search.check_match( elif not helper_search.check_match(
@ -2361,9 +2361,9 @@ class MyForm(settingsmixin.SMainWindow):
ret = treeWidget = None ret = treeWidget = None
tab = -1 tab = -1
for treeWidget in ( for treeWidget in (
self.ui.treeWidgetYourIdentities, self.treeWidgetYourIdentities,
self.ui.treeWidgetSubscriptions, self.treeWidgetSubscriptions,
self.ui.treeWidgetChans self.treeWidgetChans
): ):
tab += 1 tab += 1
if tab == 1: if tab == 1:
@ -2381,7 +2381,7 @@ class MyForm(settingsmixin.SMainWindow):
if ((tableWidget == inbox if ((tableWidget == inbox
and current_account == acct.address and current_account == acct.address
and current_folder in ("inbox", None)) and current_folder in ("inbox", None))
or (treeWidget == self.ui.treeWidgetYourIdentities or (treeWidget == self.treeWidgetYourIdentities
and current_account is None and current_account is None
and current_folder in ("inbox", "new", None))): and current_folder in ("inbox", "new", None))):
ret = self.addMessageListItemInbox( ret = self.addMessageListItemInbox(
@ -2515,9 +2515,9 @@ class MyForm(settingsmixin.SMainWindow):
account_item = self.getCurrentItem() account_item = self.getCurrentItem()
if not account_item: if not account_item:
return return
self.ui.lineEditTo.setText(account_item.accountString()) self.lineEditTo.setText(account_item.accountString())
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
def on_action_SpecialAddressBehaviorDialog(self): def on_action_SpecialAddressBehaviorDialog(self):
@ -2535,24 +2535,24 @@ class MyForm(settingsmixin.SMainWindow):
# Only settings remain here # Only settings remain here
acct.settings() acct.settings()
for i in range(self.ui.comboBoxSendFrom.count()): for i in range(self.comboBoxSendFrom.count()):
if str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) \ if str(self.comboBoxSendFrom.itemData(i).toPyObject()) \
== acct.fromAddress: == acct.fromAddress:
self.ui.comboBoxSendFrom.setCurrentIndex(i) self.comboBoxSendFrom.setCurrentIndex(i)
break break
else: else:
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.comboBoxSendFrom.setCurrentIndex(0)
self.ui.lineEditTo.setText(acct.toAddress) self.lineEditTo.setText(acct.toAddress)
self.ui.lineEditSubject.setText(acct.subject) self.lineEditSubject.setText(acct.subject)
self.ui.textEditMessage.setText(acct.message) self.textEditMessage.setText(acct.message)
self.ui.tabWidgetSend.setCurrentIndex( self.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect) self.tabWidgetSend.indexOf(self.sendDirect)
) )
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
self.ui.textEditMessage.setFocus() self.textEditMessage.setFocus()
def on_action_MarkAllRead(self): def on_action_MarkAllRead(self):
if QtGui.QMessageBox.question( if QtGui.QMessageBox.question(
@ -2605,9 +2605,9 @@ class MyForm(settingsmixin.SMainWindow):
BMConfigParser().set( BMConfigParser().set(
'bitmessagesettings', 'dontconnect', str(dontconnect_option)) 'bitmessagesettings', 'dontconnect', str(dontconnect_option))
BMConfigParser().save() BMConfigParser().save()
self.ui.updateNetworkSwitchMenuLabel(dontconnect_option) self.updateNetworkSwitchMenuLabel(dontconnect_option)
self.ui.pushButtonFetchNamecoinID.setHidden( self.pushButtonFetchNamecoinID.setHidden(
dontconnect_option or self.namecoin.test()[0] == 'failed' dontconnect_option or self.namecoin.test()[0] == 'failed'
) )
@ -2771,7 +2771,7 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.AllEvents, 1000
) )
self.saveSettings() self.saveSettings()
for attr, obj in self.ui.__dict__.iteritems(): for attr, obj in self.__dict__.iteritems():
if hasattr(obj, "__class__") \ if hasattr(obj, "__class__") \
and isinstance(obj, settingsmixin.SettingsMixin): and isinstance(obj, settingsmixin.SettingsMixin):
saveMethod = getattr(obj, "saveSettings", None) saveMethod = getattr(obj, "saveSettings", None)
@ -2899,7 +2899,7 @@ class MyForm(settingsmixin.SMainWindow):
currentInboxRow = messagelist.currentRow() currentInboxRow = messagelist.currentRow()
address = messagelist.item(currentInboxRow, 0).address address = messagelist.item(currentInboxRow, 0).address
for box in ( for box in (
self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast self.comboBoxSendFrom, self.comboBoxSendFromBroadcast
): ):
for i in range(box.count()): for i in range(box.count()):
if str(box.itemData(i).toPyObject()) == address: if str(box.itemData(i).toPyObject()) == address:
@ -2925,7 +2925,7 @@ class MyForm(settingsmixin.SMainWindow):
reply_type = self.REPLY_TYPE_SENDER reply_type = self.REPLY_TYPE_SENDER
# save this to return back after reply is done # save this to return back after reply is done
self.replyFromTab = self.ui.tabWidget.currentIndex() self.replyFromTab = self.tabWidget.currentIndex()
column_to = 1 if reply_type == self.REPLY_TYPE_UPD else 0 column_to = 1 if reply_type == self.REPLY_TYPE_UPD else 0
column_from = 0 if reply_type == self.REPLY_TYPE_UPD else 1 column_from = 0 if reply_type == self.REPLY_TYPE_UPD else 1
@ -2948,14 +2948,14 @@ class MyForm(settingsmixin.SMainWindow):
tableWidget.item(currentInboxRow, 2).subject, tableWidget.item(currentInboxRow, 2).subject,
messageAtCurrentInboxRow) messageAtCurrentInboxRow)
widget = { widget = {
'subject': self.ui.lineEditSubject, 'subject': self.lineEditSubject,
'from': self.ui.comboBoxSendFrom, 'from': self.comboBoxSendFrom,
'message': self.ui.textEditMessage 'message': self.textEditMessage
} }
if toAddressAtCurrentInboxRow == str_broadcast_subscribers: if toAddressAtCurrentInboxRow == str_broadcast_subscribers:
self.ui.tabWidgetSend.setCurrentIndex( self.tabWidgetSend.setCurrentIndex(
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect) self.tabWidgetSend.indexOf(self.sendDirect)
) )
# toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow # toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
elif not BMConfigParser().has_section(toAddressAtCurrentInboxRow): elif not BMConfigParser().has_section(toAddressAtCurrentInboxRow):
@ -2978,24 +2978,24 @@ class MyForm(settingsmixin.SMainWindow):
), QtGui.QMessageBox.Ok) ), QtGui.QMessageBox.Ok)
else: else:
self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow) self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow)
broadcast_tab_index = self.ui.tabWidgetSend.indexOf( broadcast_tab_index = self.tabWidgetSend.indexOf(
self.ui.sendBroadcast self.sendBroadcast
) )
if self.ui.tabWidgetSend.currentIndex() == broadcast_tab_index: if self.tabWidgetSend.currentIndex() == broadcast_tab_index:
widget = { widget = {
'subject': self.ui.lineEditSubjectBroadcast, 'subject': self.lineEditSubjectBroadcast,
'from': self.ui.comboBoxSendFromBroadcast, 'from': self.comboBoxSendFromBroadcast,
'message': self.ui.textEditMessageBroadcast 'message': self.textEditMessageBroadcast
} }
self.ui.tabWidgetSend.setCurrentIndex(broadcast_tab_index) self.tabWidgetSend.setCurrentIndex(broadcast_tab_index)
toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
if fromAddressAtCurrentInboxRow == \ if fromAddressAtCurrentInboxRow == \
tableWidget.item(currentInboxRow, column_from).label or ( tableWidget.item(currentInboxRow, column_from).label or (
isinstance(acct, GatewayAccount) and isinstance(acct, GatewayAccount) and
fromAddressAtCurrentInboxRow == acct.relayAddress): fromAddressAtCurrentInboxRow == acct.relayAddress):
self.ui.lineEditTo.setText(str(acct.fromAddress)) self.lineEditTo.setText(str(acct.fromAddress))
else: else:
self.ui.lineEditTo.setText( self.lineEditTo.setText(
tableWidget.item(currentInboxRow, column_from).accountString() tableWidget.item(currentInboxRow, column_from).accountString()
) )
@ -3008,9 +3008,9 @@ class MyForm(settingsmixin.SMainWindow):
' reply to the chan address.') ' reply to the chan address.')
if toAddressAtCurrentInboxRow == \ if toAddressAtCurrentInboxRow == \
tableWidget.item(currentInboxRow, column_to).label: tableWidget.item(currentInboxRow, column_to).label:
self.ui.lineEditTo.setText(str(toAddressAtCurrentInboxRow)) self.lineEditTo.setText(str(toAddressAtCurrentInboxRow))
else: else:
self.ui.lineEditTo.setText( self.lineEditTo.setText(
tableWidget.item(currentInboxRow, column_to).accountString() tableWidget.item(currentInboxRow, column_to).accountString()
) )
@ -3025,8 +3025,8 @@ class MyForm(settingsmixin.SMainWindow):
else: else:
widget['subject'].setText( widget['subject'].setText(
'Re: ' + tableWidget.item(currentInboxRow, 2).label) 'Re: ' + tableWidget.item(currentInboxRow, 2).label)
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
widget['message'].setFocus() widget['message'].setFocus()
@ -3037,8 +3037,8 @@ class MyForm(settingsmixin.SMainWindow):
currentInboxRow = tableWidget.currentRow() currentInboxRow = tableWidget.currentRow()
addressAtCurrentInboxRow = tableWidget.item( addressAtCurrentInboxRow = tableWidget.item(
currentInboxRow, 1).data(QtCore.Qt.UserRole) currentInboxRow, 1).data(QtCore.Qt.UserRole)
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
self.click_pushButtonAddAddressBook( self.click_pushButtonAddAddressBook(
dialogs.AddAddressDialog(self, addressAtCurrentInboxRow)) dialogs.AddAddressDialog(self, addressAtCurrentInboxRow))
@ -3060,7 +3060,7 @@ class MyForm(settingsmixin.SMainWindow):
sqlExecute('''INSERT INTO blacklist VALUES (?,?, ?)''', sqlExecute('''INSERT INTO blacklist VALUES (?,?, ?)''',
label, label,
addressAtCurrentInboxRow, True) addressAtCurrentInboxRow, True)
self.ui.blackwhitelist.rerenderBlackWhiteList() self.blackwhitelist.rerenderBlackWhiteList()
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Entry added to the blacklist. Edit the label to your liking.") "Entry added to the blacklist. Edit the label to your liking.")
@ -3076,9 +3076,9 @@ class MyForm(settingsmixin.SMainWindow):
): ):
if messageLists is None: if messageLists is None:
messageLists = ( messageLists = (
self.ui.tableWidgetInbox, self.tableWidgetInbox,
self.ui.tableWidgetInboxChans, self.tableWidgetInboxChans,
self.ui.tableWidgetInboxSubscriptions self.tableWidgetInboxSubscriptions
) )
elif type(messageLists) not in (list, tuple): elif type(messageLists) not in (list, tuple):
messageLists = (messageLists,) messageLists = (messageLists,)
@ -3206,12 +3206,12 @@ class MyForm(settingsmixin.SMainWindow):
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Moved items to trash.")) "MainWindow", "Moved items to trash."))
self.ui.tableWidgetInbox.selectRow( self.tableWidgetInbox.selectRow(
currentRow if currentRow == 0 else currentRow - 1) currentRow if currentRow == 0 else currentRow - 1)
def on_action_ForceSend(self): def on_action_ForceSend(self):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.tableWidgetInbox.currentRow()
addressAtCurrentRow = self.ui.tableWidgetInbox.item( addressAtCurrentRow = self.tableWidgetInbox.item(
currentRow, 0).data(QtCore.Qt.UserRole) currentRow, 0).data(QtCore.Qt.UserRole)
toRipe = decodeAddress(addressAtCurrentRow)[3] toRipe = decodeAddress(addressAtCurrentRow)[3]
sqlExecute( sqlExecute(
@ -3225,8 +3225,8 @@ class MyForm(settingsmixin.SMainWindow):
queues.workerQueue.put(('sendmessage', '')) queues.workerQueue.put(('sendmessage', ''))
def on_action_SentClipboard(self): def on_action_SentClipboard(self):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.tableWidgetInbox.currentRow()
addressAtCurrentRow = self.ui.tableWidgetInbox.item( addressAtCurrentRow = self.tableWidgetInbox.item(
currentRow, 0).data(QtCore.Qt.UserRole) currentRow, 0).data(QtCore.Qt.UserRole)
clipboard = QtGui.QApplication.clipboard() clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow)) clipboard.setText(str(addressAtCurrentRow))
@ -3236,13 +3236,13 @@ class MyForm(settingsmixin.SMainWindow):
self.click_pushButtonAddAddressBook() self.click_pushButtonAddAddressBook()
def on_action_AddressBookDelete(self): def on_action_AddressBookDelete(self):
while self.ui.tableWidgetAddressBook.selectedIndexes() != []: while self.tableWidgetAddressBook.selectedIndexes() != []:
currentRow = self.ui.tableWidgetAddressBook.selectedIndexes()[ currentRow = self.tableWidgetAddressBook.selectedIndexes()[
0].row() 0].row()
item = self.ui.tableWidgetAddressBook.item(currentRow, 0) item = self.tableWidgetAddressBook.item(currentRow, 0)
sqlExecute( sqlExecute(
'DELETE FROM addressbook WHERE address=?', item.address) 'DELETE FROM addressbook WHERE address=?', item.address)
self.ui.tableWidgetAddressBook.removeRow(currentRow) self.tableWidgetAddressBook.removeRow(currentRow)
self.rerenderMessagelistFromLabels() self.rerenderMessagelistFromLabels()
self.rerenderMessagelistToLabels() self.rerenderMessagelistToLabels()
@ -3264,7 +3264,7 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "No addresses selected.")) "MainWindow", "No addresses selected."))
addresses_string = unicode( addresses_string = unicode(
self.ui.lineEditTo.text().toUtf8(), 'utf-8') self.lineEditTo.text().toUtf8(), 'utf-8')
for item in selected_items: for item in selected_items:
address_string = item.accountString() address_string = item.accountString()
if not addresses_string: if not addresses_string:
@ -3272,10 +3272,10 @@ class MyForm(settingsmixin.SMainWindow):
else: else:
addresses_string += '; ' + address_string addresses_string += '; ' + address_string
self.ui.lineEditTo.setText(addresses_string) self.lineEditTo.setText(addresses_string)
self.statusbar.clearMessage() self.statusbar.clearMessage()
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.tabWidget.indexOf(self.send)
) )
def on_action_AddressBookSubscribe(self): def on_action_AddressBookSubscribe(self):
@ -3290,8 +3290,8 @@ class MyForm(settingsmixin.SMainWindow):
" one if you want.")) " one if you want."))
continue continue
self.addSubscription(item.address, item.label) self.addSubscription(item.address, item.label)
self.ui.tabWidget.setCurrentIndex( self.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.subscriptions) self.tabWidget.indexOf(self.subscriptions)
) )
def on_context_menuAddressBook(self, point): def on_context_menuAddressBook(self, point):
@ -3318,7 +3318,7 @@ class MyForm(settingsmixin.SMainWindow):
for plugin in self.menu_plugins['address']: for plugin in self.menu_plugins['address']:
self.popMenuAddressBook.addAction(plugin) self.popMenuAddressBook.addAction(plugin)
self.popMenuAddressBook.exec_( self.popMenuAddressBook.exec_(
self.ui.tableWidgetAddressBook.mapToGlobal(point)) self.tableWidgetAddressBook.mapToGlobal(point))
# Group of functions for the Subscriptions dialog box # Group of functions for the Subscriptions dialog box
def on_action_SubscriptionsNew(self): def on_action_SubscriptionsNew(self):
@ -3399,31 +3399,31 @@ class MyForm(settingsmixin.SMainWindow):
if self.popMenuSubscriptions.isEmpty(): if self.popMenuSubscriptions.isEmpty():
return return
self.popMenuSubscriptions.exec_( self.popMenuSubscriptions.exec_(
self.ui.treeWidgetSubscriptions.mapToGlobal(point)) self.treeWidgetSubscriptions.mapToGlobal(point))
def widgetConvert(self, widget): def widgetConvert(self, widget):
if widget == self.ui.tableWidgetInbox: if widget == self.tableWidgetInbox:
return self.ui.treeWidgetYourIdentities return self.treeWidgetYourIdentities
elif widget == self.ui.tableWidgetInboxSubscriptions: elif widget == self.tableWidgetInboxSubscriptions:
return self.ui.treeWidgetSubscriptions return self.treeWidgetSubscriptions
elif widget == self.ui.tableWidgetInboxChans: elif widget == self.tableWidgetInboxChans:
return self.ui.treeWidgetChans return self.treeWidgetChans
elif widget == self.ui.treeWidgetYourIdentities: elif widget == self.treeWidgetYourIdentities:
return self.ui.tableWidgetInbox return self.tableWidgetInbox
elif widget == self.ui.treeWidgetSubscriptions: elif widget == self.treeWidgetSubscriptions:
return self.ui.tableWidgetInboxSubscriptions return self.tableWidgetInboxSubscriptions
elif widget == self.ui.treeWidgetChans: elif widget == self.treeWidgetChans:
return self.ui.tableWidgetInboxChans return self.tableWidgetInboxChans
else: else:
return None return None
def getCurrentTreeWidget(self): def getCurrentTreeWidget(self):
currentIndex = self.ui.tabWidget.currentIndex() currentIndex = self.tabWidget.currentIndex()
treeWidgetList = ( treeWidgetList = (
self.ui.treeWidgetYourIdentities, self.treeWidgetYourIdentities,
False, False,
self.ui.treeWidgetSubscriptions, self.treeWidgetSubscriptions,
self.ui.treeWidgetChans self.treeWidgetChans
) )
if currentIndex >= 0 and currentIndex < len(treeWidgetList): if currentIndex >= 0 and currentIndex < len(treeWidgetList):
return treeWidgetList[currentIndex] return treeWidgetList[currentIndex]
@ -3433,21 +3433,21 @@ class MyForm(settingsmixin.SMainWindow):
def getAccountTreeWidget(self, account): def getAccountTreeWidget(self, account):
try: try:
if account.type == AccountMixin.CHAN: if account.type == AccountMixin.CHAN:
return self.ui.treeWidgetChans return self.treeWidgetChans
elif account.type == AccountMixin.SUBSCRIPTION: elif account.type == AccountMixin.SUBSCRIPTION:
return self.ui.treeWidgetSubscriptions return self.treeWidgetSubscriptions
else: else:
return self.ui.treeWidgetYourIdentities return self.treeWidgetYourIdentities
except: except:
return self.ui.treeWidgetYourIdentities return self.treeWidgetYourIdentities
def getCurrentMessagelist(self): def getCurrentMessagelist(self):
currentIndex = self.ui.tabWidget.currentIndex() currentIndex = self.tabWidget.currentIndex()
messagelistList = ( messagelistList = (
self.ui.tableWidgetInbox, self.tableWidgetInbox,
False, False,
self.ui.tableWidgetInboxSubscriptions, self.tableWidgetInboxSubscriptions,
self.ui.tableWidgetInboxChans, self.tableWidgetInboxChans,
) )
if currentIndex >= 0 and currentIndex < len(messagelistList): if currentIndex >= 0 and currentIndex < len(messagelistList):
return messagelistList[currentIndex] return messagelistList[currentIndex]
@ -3455,13 +3455,13 @@ class MyForm(settingsmixin.SMainWindow):
def getAccountMessagelist(self, account): def getAccountMessagelist(self, account):
try: try:
if account.type == AccountMixin.CHAN: if account.type == AccountMixin.CHAN:
return self.ui.tableWidgetInboxChans return self.tableWidgetInboxChans
elif account.type == AccountMixin.SUBSCRIPTION: elif account.type == AccountMixin.SUBSCRIPTION:
return self.ui.tableWidgetInboxSubscriptions return self.tableWidgetInboxSubscriptions
else: else:
return self.ui.tableWidgetInbox return self.tableWidgetInbox
except: except:
return self.ui.tableWidgetInbox return self.tableWidgetInbox
def getCurrentMessageId(self): def getCurrentMessageId(self):
messagelist = self.getCurrentMessagelist() messagelist = self.getCurrentMessagelist()
@ -3471,12 +3471,12 @@ class MyForm(settingsmixin.SMainWindow):
return messagelist.item(currentRow, 3).data() return messagelist.item(currentRow, 3).data()
def getCurrentMessageTextedit(self): def getCurrentMessageTextedit(self):
currentIndex = self.ui.tabWidget.currentIndex() currentIndex = self.tabWidget.currentIndex()
messagelistList = ( messagelistList = (
self.ui.textEditInboxMessage, self.textEditInboxMessage,
False, False,
self.ui.textEditInboxMessageSubscriptions, self.textEditInboxMessageSubscriptions,
self.ui.textEditInboxMessageChans, self.textEditInboxMessageChans,
) )
if currentIndex >= 0 and currentIndex < len(messagelistList): if currentIndex >= 0 and currentIndex < len(messagelistList):
return messagelistList[currentIndex] return messagelistList[currentIndex]
@ -3484,22 +3484,22 @@ class MyForm(settingsmixin.SMainWindow):
def getAccountTextedit(self, account): def getAccountTextedit(self, account):
try: try:
if account.type == AccountMixin.CHAN: if account.type == AccountMixin.CHAN:
return self.ui.textEditInboxMessageChans return self.textEditInboxMessageChans
elif account.type == AccountMixin.SUBSCRIPTION: elif account.type == AccountMixin.SUBSCRIPTION:
return self.ui.textEditInboxSubscriptions return self.textEditInboxSubscriptions
else: else:
return self.ui.textEditInboxMessage return self.textEditInboxMessage
except: except:
return self.ui.textEditInboxMessage return self.textEditInboxMessage
def getCurrentSearchLine(self, currentIndex=None, retObj=False): def getCurrentSearchLine(self, currentIndex=None, retObj=False):
if currentIndex is None: if currentIndex is None:
currentIndex = self.ui.tabWidget.currentIndex() currentIndex = self.tabWidget.currentIndex()
messagelistList = ( messagelistList = (
self.ui.inboxSearchLineEdit, self.inboxSearchLineEdit,
False, False,
self.ui.inboxSearchLineEditSubscriptions, self.inboxSearchLineEditSubscriptions,
self.ui.inboxSearchLineEditChans, self.inboxSearchLineEditChans,
) )
if currentIndex >= 0 and currentIndex < len(messagelistList): if currentIndex >= 0 and currentIndex < len(messagelistList):
return ( return (
@ -3508,12 +3508,12 @@ class MyForm(settingsmixin.SMainWindow):
def getCurrentSearchOption(self, currentIndex=None): def getCurrentSearchOption(self, currentIndex=None):
if currentIndex is None: if currentIndex is None:
currentIndex = self.ui.tabWidget.currentIndex() currentIndex = self.tabWidget.currentIndex()
messagelistList = ( messagelistList = (
self.ui.inboxSearchOption, self.inboxSearchOption,
False, False,
self.ui.inboxSearchOptionSubscriptions, self.inboxSearchOptionSubscriptions,
self.ui.inboxSearchOptionChans, self.inboxSearchOptionChans,
) )
if currentIndex >= 0 and currentIndex < len(messagelistList): if currentIndex >= 0 and currentIndex < len(messagelistList):
return messagelistList[currentIndex].currentText() return messagelistList[currentIndex].currentText()
@ -3547,8 +3547,8 @@ class MyForm(settingsmixin.SMainWindow):
def getAddressbookSelectedItems(self): def getAddressbookSelectedItems(self):
return [ return [
self.ui.tableWidgetAddressBook.item(i.row(), 0) self.tableWidgetAddressBook.item(i.row(), 0)
for i in self.ui.tableWidgetAddressBook.selectedIndexes() for i in self.tableWidgetAddressBook.selectedIndexes()
if i.column() == 0 if i.column() == 0
] ]
@ -3647,8 +3647,8 @@ class MyForm(settingsmixin.SMainWindow):
self.setAvatar(address) self.setAvatar(address)
def on_action_AddressBookSetAvatar(self): def on_action_AddressBookSetAvatar(self):
self.on_action_SetAvatar(self.ui.tableWidgetAddressBook) self.on_action_SetAvatar(self.tableWidgetAddressBook)
def on_action_SetAvatar(self, thisTableWidget): def on_action_SetAvatar(self, thisTableWidget):
currentRow = thisTableWidget.currentRow() currentRow = thisTableWidget.currentRow()
addressAtCurrentRow = thisTableWidget.item( addressAtCurrentRow = thisTableWidget.item(
@ -3745,14 +3745,14 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderComboBoxSendFromBroadcast() self.rerenderComboBoxSendFromBroadcast()
self.rerenderMessagelistFromLabels() self.rerenderMessagelistFromLabels()
self.rerenderMessagelistToLabels() self.rerenderMessagelistToLabels()
self.ui.blackwhitelist.rerenderBlackWhiteList() self.blackwhitelist.rerenderBlackWhiteList()
# generate identicon # generate identicon
return False return False
return True return True
def on_action_AddressBookSetSound(self): def on_action_AddressBookSetSound(self):
widget = self.ui.tableWidgetAddressBook widget = self.tableWidgetAddressBook
self.setAddressSound(widget.item(widget.currentRow(), 0).text()) self.setAddressSound(widget.item(widget.currentRow(), 0).text())
def setAddressSound(self, addr): def setAddressSound(self, addr):
@ -3822,7 +3822,7 @@ class MyForm(settingsmixin.SMainWindow):
if self.popMenuYourIdentities.isEmpty(): if self.popMenuYourIdentities.isEmpty():
return return
self.popMenuYourIdentities.exec_( self.popMenuYourIdentities.exec_(
self.ui.treeWidgetYourIdentities.mapToGlobal(point)) self.treeWidgetYourIdentities.mapToGlobal(point))
# TODO make one popMenu # TODO make one popMenu
def on_context_menuChan(self, point): def on_context_menuChan(self, point):
@ -3851,7 +3851,7 @@ class MyForm(settingsmixin.SMainWindow):
if self.popMenu.isEmpty(): if self.popMenu.isEmpty():
return return
self.popMenu.exec_( self.popMenu.exec_(
self.ui.treeWidgetChans.mapToGlobal(point)) self.treeWidgetChans.mapToGlobal(point))
def on_context_menuInbox(self, point): def on_context_menuInbox(self, point):
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
@ -3875,7 +3875,7 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuInbox.addAction(self.actionReplyChan) self.popMenuInbox.addAction(self.actionReplyChan)
self.popMenuInbox.addAction(self.actionReply) self.popMenuInbox.addAction(self.actionReply)
self.popMenuInbox.addAction(self.actionAddSenderToAddressBook) self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
self.actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction( self.actionClipboardMessagelist = self.inboxContextMenuToolbar.addAction(
_translate("MainWindow", "Copy subject to clipboard") _translate("MainWindow", "Copy subject to clipboard")
if tableWidget.currentColumn() == 2 else if tableWidget.currentColumn() == 2 else
_translate("MainWindow", "Copy address to clipboard"), _translate("MainWindow", "Copy address to clipboard"),
@ -3897,10 +3897,10 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuInbox.exec_(tableWidget.mapToGlobal(point)) self.popMenuInbox.exec_(tableWidget.mapToGlobal(point))
def on_context_menuSent(self, point): def on_context_menuSent(self, point):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.tableWidgetInbox.currentRow()
self.popMenuSent = QtGui.QMenu(self) self.popMenuSent = QtGui.QMenu(self)
self.popMenuSent.addAction(self.actionSentClipboard) self.popMenuSent.addAction(self.actionSentClipboard)
self._contact_selected = self.ui.tableWidgetInbox.item(currentRow, 0) self._contact_selected = self.tableWidgetInbox.item(currentRow, 0)
# preloaded gui.menu plugins with prefix 'address' # preloaded gui.menu plugins with prefix 'address'
for plugin in self.menu_plugins['address']: for plugin in self.menu_plugins['address']:
self.popMenuSent.addAction(plugin) self.popMenuSent.addAction(plugin)
@ -3911,14 +3911,14 @@ class MyForm(settingsmixin.SMainWindow):
# Check to see if this item is toodifficult and display an additional # Check to see if this item is toodifficult and display an additional
# menu option (Force Send) if it is. # menu option (Force Send) if it is.
if currentRow >= 0: if currentRow >= 0:
ackData = self.ui.tableWidgetInbox.item(currentRow, 3).data() ackData = self.tableWidgetInbox.item(currentRow, 3).data()
queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', ackData) queryreturn = sqlQuery('''SELECT status FROM sent where ackdata=?''', ackData)
for row in queryreturn: for row in queryreturn:
status, = row status, = row
if status == 'toodifficult': if status == 'toodifficult':
self.popMenuSent.addAction(self.actionForceSend) self.popMenuSent.addAction(self.actionForceSend)
self.popMenuSent.exec_(self.ui.tableWidgetInbox.mapToGlobal(point)) self.popMenuSent.exec_(self.tableWidgetInbox.mapToGlobal(point))
def inboxSearchLineEditUpdated(self, text): def inboxSearchLineEditUpdated(self, text):
# dynamic search for too short text is slow # dynamic search for too short text is slow
@ -4046,17 +4046,17 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderComboBoxSendFrom() self.rerenderComboBoxSendFrom()
self.rerenderMessagelistFromLabels() self.rerenderMessagelistFromLabels()
self.rerenderMessagelistToLabels() self.rerenderMessagelistToLabels()
completerList = self.ui.lineEditTo.completer().model().stringList() completerList = self.lineEditTo.completer().model().stringList()
for i in range(len(completerList)): for i in range(len(completerList)):
if unicode(completerList[i]).endswith(" <" + item.address + ">"): if unicode(completerList[i]).endswith(" <" + item.address + ">"):
completerList[i] = item.label + " <" + item.address + ">" completerList[i] = item.label + " <" + item.address + ">"
self.ui.lineEditTo.completer().model().setStringList(completerList) self.lineEditTo.completer().model().setStringList(completerList)
def tabWidgetCurrentChanged(self, n): def tabWidgetCurrentChanged(self, n):
if n == self.ui.tabWidget.indexOf(self.ui.networkstatus): if n == self.tabWidget.indexOf(self.networkstatus):
self.ui.networkstatus.startUpdate() self.networkstatus.startUpdate()
else: else:
self.ui.networkstatus.stopUpdate() self.networkstatus.stopUpdate()
def writeNewAddressToTable(self, label, address, streamNumber): def writeNewAddressToTable(self, label, address, streamNumber):
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
@ -4102,7 +4102,7 @@ class MyForm(settingsmixin.SMainWindow):
def initSettings(self): def initSettings(self):
self.loadSettings() self.loadSettings()
for attr, obj in self.ui.__dict__.iteritems(): for attr, obj in self.__dict__.iteritems():
if hasattr(obj, "__class__") and \ if hasattr(obj, "__class__") and \
isinstance(obj, settingsmixin.SettingsMixin): isinstance(obj, settingsmixin.SettingsMixin):
loadMethod = getattr(obj, "loadSettings", None) loadMethod = getattr(obj, "loadSettings", None)
@ -4181,7 +4181,8 @@ def init():
def run(): def run():
global myapp global myapp
app = init() app = init()
myapp = MyForm() app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
myapp = MainWindow()
myapp.appIndicatorInit(app) myapp.appIndicatorInit(app)

38
src/bitmessageqt/main.py Normal file
View File

@ -0,0 +1,38 @@
from PyQt4 import QtCore, QtGui
import settingsmixin
import widgets
from bmconfigparser import BMConfigParser
from foldertree import AddressBookCompleter
from retranslateui import RetranslateMixin
from tr import _translate
class Window(settingsmixin.SMainWindow, RetranslateMixin):
"""The main PyBitmessage's window"""
def __init__(self, parent=None):
super(Window, self).__init__(parent)
widgets.load('bitmessageui.ui', self)
self.addressBookCompleter = AddressBookCompleter()
self.addressBookCompleter.setCompletionMode(
QtGui.QCompleter.PopupCompletion)
self.addressBookCompleter.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.addressBookCompleterModel = QtGui.QStringListModel()
self.addressBookCompleter.setModel(self.addressBookCompleterModel)
self.lineEditTo.setCompleter(self.addressBookCompleter)
def updateNetworkSwitchMenuLabel(self, dontconnect=None):
"""
Set the label for "Go online"/"Go offline" menu action
depending on 'dontconnect' setting
"""
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)
)

View File

@ -69,19 +69,19 @@ class MessageView(QtGui.QTextBrowser):
"""Show a dialog requesting URL opening confirmation""" """Show a dialog requesting URL opening confirmation"""
if link.scheme() == "mailto": if link.scheme() == "mailto":
window = QtGui.QApplication.activeWindow() window = QtGui.QApplication.activeWindow()
window.ui.lineEditTo.setText(link.path()) window.lineEditTo.setText(link.path())
if link.hasQueryItem("subject"): if link.hasQueryItem("subject"):
window.ui.lineEditSubject.setText( window.lineEditSubject.setText(
link.queryItemValue("subject")) link.queryItemValue("subject"))
if link.hasQueryItem("body"): if link.hasQueryItem("body"):
window.ui.textEditMessage.setText( window.textEditMessage.setText(
link.queryItemValue("body")) link.queryItemValue("body"))
window.setSendFromComboBox() window.setSendFromComboBox()
window.ui.tabWidgetSend.setCurrentIndex(0) window.tabWidgetSend.setCurrentIndex(0)
window.ui.tabWidget.setCurrentIndex( window.tabWidget.setCurrentIndex(
window.ui.tabWidget.indexOf(window.ui.send) window.tabWidget.indexOf(window.send)
) )
window.ui.textEditMessage.setFocus() window.textEditMessage.setFocus()
return return
reply = QtGui.QMessageBox.warning( reply = QtGui.QMessageBox.warning(
self, self,

View File

@ -64,15 +64,27 @@ class NewChanDialog(QtGui.QDialog):
self.chanPassPhrase.text().toUtf8(), self.chanPassPhrase.text().toUtf8(),
True)) True))
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True) addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address': if (
UISignalQueue.put(('updateStatusBar', _translate( addressGeneratorReturnValue and
"newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text())))) addressGeneratorReturnValue[0] !=
self.parent.ui.tabWidget.setCurrentIndex( 'chan name does not match address'
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans) ):
UISignalQueue.put((
'updateStatusBar',
_translate(
"newchandialog",
"Successfully created / joined chan %1"
).arg(unicode(self.chanPassPhrase.text()))
))
self.parent.tabWidget.setCurrentIndex(
self.parent.tabWidget.indexOf(self.parent.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")
))
self.done(QtGui.QDialog.Rejected) self.done(QtGui.QDialog.Rejected)
def reject(self): def reject(self):

View File

@ -105,14 +105,14 @@ def createSupportMessage(myapp):
if state.shutdown: if state.shutdown:
return return
myapp.ui.lineEditSubject.setText(SUPPORT_SUBJECT) myapp.lineEditSubject.setText(SUPPORT_SUBJECT)
addrIndex = myapp.ui.comboBoxSendFrom.findData( addrIndex = myapp.comboBoxSendFrom.findData(
address, QtCore.Qt.UserRole, address, QtCore.Qt.UserRole,
QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive) QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive)
if addrIndex == -1: # something is very wrong if addrIndex == -1: # something is very wrong
return return
myapp.ui.comboBoxSendFrom.setCurrentIndex(addrIndex) myapp.comboBoxSendFrom.setCurrentIndex(addrIndex)
myapp.ui.lineEditTo.setText(SUPPORT_ADDRESS) myapp.lineEditTo.setText(SUPPORT_ADDRESS)
version = softwareVersion version = softwareVersion
commit = paths.lastCommit().get('commit') commit = paths.lastCommit().get('commit')
@ -149,15 +149,15 @@ def createSupportMessage(myapp):
upnp = BMConfigParser().safeGet('bitmessagesettings', 'upnp', "N/A") upnp = BMConfigParser().safeGet('bitmessagesettings', 'upnp', "N/A")
connectedhosts = len(network.stats.connectedHostsList()) connectedhosts = len(network.stats.connectedHostsList())
myapp.ui.textEditMessage.setText(unicode(SUPPORT_MESSAGE, 'utf-8').format( myapp.textEditMessage.setText(unicode(SUPPORT_MESSAGE, 'utf-8').format(
version, os, architecture, pythonversion, opensslversion, frozen, version, os, architecture, pythonversion, opensslversion, frozen,
portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts)) portablemode, cpow, openclpow, locale, socks, upnp, connectedhosts))
# single msg tab # single msg tab
myapp.ui.tabWidgetSend.setCurrentIndex( myapp.tabWidgetSend.setCurrentIndex(
myapp.ui.tabWidgetSend.indexOf(myapp.ui.sendDirect) myapp.tabWidgetSend.indexOf(myapp.sendDirect)
) )
# send tab # send tab
myapp.ui.tabWidget.setCurrentIndex( myapp.tabWidget.setCurrentIndex(
myapp.ui.tabWidget.indexOf(myapp.ui.send) myapp.tabWidget.indexOf(myapp.send)
) )

View File

@ -20,7 +20,7 @@ class TestBase(unittest.TestCase):
or bitmessageqt.BitmessageQtApplication(sys.argv)) or bitmessageqt.BitmessageQtApplication(sys.argv))
self.window = self.app.activeWindow() self.window = self.app.activeWindow()
if not self.window: if not self.window:
self.window = bitmessageqt.MyForm() self.window = bitmessageqt.MainWindow()
self.window.appIndicatorInit(self.app) self.window.appIndicatorInit(self.app)
def tearDown(self): def tearDown(self):

View File

@ -14,7 +14,7 @@ class TestSupport(TestBase):
def test(self): def test(self):
"""trigger menu action "Contact Support" and check the result""" """trigger menu action "Contact Support" and check the result"""
ui = self.window.ui ui = self.window
self.assertEqual(ui.lineEditTo.text(), '') self.assertEqual(ui.lineEditTo.text(), '')
self.assertEqual(ui.lineEditSubject.text(), '') self.assertEqual(ui.lineEditSubject.text(), '')