Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250
|
@ -15,6 +15,7 @@ import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from sqlite3 import register_adapter
|
from sqlite3 import register_adapter
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from PyQt4.QtNetwork import QLocalSocket, QLocalServer
|
from PyQt4.QtNetwork import QLocalSocket, QLocalServer
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
paths.codePath(), 'translations', 'qt_' + newlocale)
|
paths.codePath(), 'translations', 'qt_' + newlocale)
|
||||||
else:
|
else:
|
||||||
translationpath = os.path.join(
|
translationpath = os.path.join(
|
||||||
str(QtCore.QLibraryInfo.location(
|
ustr(QtCore.QLibraryInfo.location(
|
||||||
QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
|
QtCore.QLibraryInfo.TranslationsPath)), 'qt_' + newlocale)
|
||||||
self.qsystranslator.load(translationpath)
|
self.qsystranslator.load(translationpath)
|
||||||
QtGui.QApplication.installTranslator(self.qsystranslator)
|
QtGui.QApplication.installTranslator(self.qsystranslator)
|
||||||
|
@ -1186,11 +1187,11 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
items = [
|
items = [
|
||||||
MessageList_AddressWidget(
|
MessageList_AddressWidget(
|
||||||
toAddress, unicode(acct.toLabel, 'utf-8')),
|
toAddress, unic(ustr(acct.toLabel))),
|
||||||
MessageList_AddressWidget(
|
MessageList_AddressWidget(
|
||||||
fromAddress, unicode(acct.fromLabel, 'utf-8')),
|
fromAddress, unic(ustr(acct.fromLabel))),
|
||||||
MessageList_SubjectWidget(
|
MessageList_SubjectWidget(
|
||||||
str(subject), unicode(acct.subject, 'utf-8', 'replace')),
|
ustr(subject), unic(ustr(acct.subject))),
|
||||||
MessageList_TimeWidget(
|
MessageList_TimeWidget(
|
||||||
statusText, False, lastactiontime, ackdata)]
|
statusText, False, lastactiontime, ackdata)]
|
||||||
self.addMessageListItem(tableWidget, items)
|
self.addMessageListItem(tableWidget, items)
|
||||||
|
@ -1211,11 +1212,11 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
items = [
|
items = [
|
||||||
MessageList_AddressWidget(
|
MessageList_AddressWidget(
|
||||||
toAddress, unicode(acct.toLabel, 'utf-8'), not read),
|
toAddress, unic(ustr(acct.toLabel)), not read),
|
||||||
MessageList_AddressWidget(
|
MessageList_AddressWidget(
|
||||||
fromAddress, unicode(acct.fromLabel, 'utf-8'), not read),
|
fromAddress, unic(ustr(acct.fromLabel)), not read),
|
||||||
MessageList_SubjectWidget(
|
MessageList_SubjectWidget(
|
||||||
str(subject), unicode(acct.subject, 'utf-8', 'replace'),
|
ustr(subject), unic(ustr(acct.subject)),
|
||||||
not read),
|
not read),
|
||||||
MessageList_TimeWidget(
|
MessageList_TimeWidget(
|
||||||
l10n.formatTimestamp(received), not read, received, msgid)
|
l10n.formatTimestamp(received), not read, received, msgid)
|
||||||
|
@ -1496,7 +1497,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self, title, subtitle, category, label=None, icon=None):
|
self, title, subtitle, category, label=None, icon=None):
|
||||||
self.playSound(category, label)
|
self.playSound(category, label)
|
||||||
self._notifier(
|
self._notifier(
|
||||||
unicode(title), unicode(subtitle), category, label, icon)
|
unic(ustr(title)), unic(ustr(subtitle)), category, label, icon)
|
||||||
|
|
||||||
# tree
|
# tree
|
||||||
def treeWidgetKeyPressEvent(self, event):
|
def treeWidgetKeyPressEvent(self, event):
|
||||||
|
@ -1699,7 +1700,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
addressVersionNumber, streamNumberForAddress,
|
addressVersionNumber, streamNumberForAddress,
|
||||||
"regenerated deterministic address",
|
"regenerated deterministic address",
|
||||||
dialog.spinBoxNumberOfAddressesToMake.value(),
|
dialog.spinBoxNumberOfAddressesToMake.value(),
|
||||||
dialog.lineEditPassphrase.text().toUtf8(),
|
ustr(dialog.lineEditPassphrase.text()),
|
||||||
dialog.checkBoxEighteenByteRipe.isChecked()
|
dialog.checkBoxEighteenByteRipe.isChecked()
|
||||||
))
|
))
|
||||||
self.ui.tabWidget.setCurrentIndex(
|
self.ui.tabWidget.setCurrentIndex(
|
||||||
|
@ -1995,9 +1996,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def rerenderAddressBook(self):
|
def rerenderAddressBook(self):
|
||||||
def addRow (address, label, type):
|
def addRow (address, label, type):
|
||||||
self.ui.tableWidgetAddressBook.insertRow(0)
|
self.ui.tableWidgetAddressBook.insertRow(0)
|
||||||
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
|
newItem = Ui_AddressBookWidgetItemLabel(address, unic(ustr(label)), type)
|
||||||
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
|
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
|
||||||
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
|
newItem = Ui_AddressBookWidgetItemAddress(address, unic(ustr(label)), type)
|
||||||
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
|
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
|
||||||
|
|
||||||
oldRows = {}
|
oldRows = {}
|
||||||
|
@ -2038,7 +2039,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
|
self.ui.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(unic(ustr(newRows[address][0]) + " <" + ustr(address) + ">"))
|
||||||
|
|
||||||
# sort
|
# sort
|
||||||
self.ui.tableWidgetAddressBook.sortByColumn(
|
self.ui.tableWidgetAddressBook.sortByColumn(
|
||||||
|
@ -2076,22 +2077,22 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect):
|
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect):
|
||||||
# message to specific people
|
# message to specific people
|
||||||
sendMessageToPeople = True
|
sendMessageToPeople = True
|
||||||
fromAddress = str(self.ui.comboBoxSendFrom.itemData(
|
fromAddress = ustr(self.ui.comboBoxSendFrom.itemData(
|
||||||
self.ui.comboBoxSendFrom.currentIndex(),
|
self.ui.comboBoxSendFrom.currentIndex(),
|
||||||
QtCore.Qt.UserRole).toString())
|
QtCore.Qt.UserRole))
|
||||||
toAddresses = str(self.ui.lineEditTo.text().toUtf8())
|
toAddresses = ustr(self.ui.lineEditTo.text())
|
||||||
subject = str(self.ui.lineEditSubject.text().toUtf8())
|
subject = ustr(self.ui.lineEditSubject.text())
|
||||||
message = str(
|
message = ustr(
|
||||||
self.ui.textEditMessage.document().toPlainText().toUtf8())
|
self.ui.textEditMessage.document().toPlainText())
|
||||||
else:
|
else:
|
||||||
# broadcast message
|
# broadcast message
|
||||||
sendMessageToPeople = False
|
sendMessageToPeople = False
|
||||||
fromAddress = str(self.ui.comboBoxSendFromBroadcast.itemData(
|
fromAddress = ustr(self.ui.comboBoxSendFromBroadcast.itemData(
|
||||||
self.ui.comboBoxSendFromBroadcast.currentIndex(),
|
self.ui.comboBoxSendFromBroadcast.currentIndex(),
|
||||||
QtCore.Qt.UserRole).toString())
|
QtCore.Qt.UserRole))
|
||||||
subject = str(self.ui.lineEditSubjectBroadcast.text().toUtf8())
|
subject = ustr(self.ui.lineEditSubjectBroadcast.text())
|
||||||
message = str(
|
message = ustr(
|
||||||
self.ui.textEditMessageBroadcast.document().toPlainText().toUtf8())
|
self.ui.textEditMessageBroadcast.document().toPlainText())
|
||||||
"""
|
"""
|
||||||
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
|
||||||
|
@ -2164,7 +2165,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3]
|
status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3]
|
||||||
if status != 'success':
|
if status != 'success':
|
||||||
try:
|
try:
|
||||||
toAddress = unicode(toAddress, 'utf-8', 'ignore')
|
toAddress = unic(ustr(toAddress))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
|
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
|
||||||
|
@ -2338,7 +2339,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
))
|
))
|
||||||
|
|
||||||
def click_pushButtonFetchNamecoinID(self):
|
def click_pushButtonFetchNamecoinID(self):
|
||||||
identities = str(self.ui.lineEditTo.text().toUtf8()).split(";")
|
identities = ustr(self.ui.lineEditTo.text()).split(";")
|
||||||
err, addr = self.namecoin.query(identities[-1].strip())
|
err, addr = self.namecoin.query(identities[-1].strip())
|
||||||
if err is not None:
|
if err is not None:
|
||||||
self.updateStatusBar(
|
self.updateStatusBar(
|
||||||
|
@ -2355,7 +2356,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.tabWidgetSend.setCurrentIndex(
|
self.ui.tabWidgetSend.setCurrentIndex(
|
||||||
self.ui.tabWidgetSend.indexOf(
|
self.ui.tabWidgetSend.indexOf(
|
||||||
self.ui.sendBroadcast
|
self.ui.sendBroadcast
|
||||||
if config.safeGetBoolean(str(address), 'mailinglist')
|
if config.safeGetBoolean(ustr(address), 'mailinglist')
|
||||||
else self.ui.sendDirect
|
else self.ui.sendDirect
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -2368,14 +2369,14 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
addressInKeysFile, 'enabled')
|
addressInKeysFile, 'enabled')
|
||||||
isMaillinglist = config.safeGetBoolean(addressInKeysFile, 'mailinglist')
|
isMaillinglist = config.safeGetBoolean(addressInKeysFile, 'mailinglist')
|
||||||
if isEnabled and not isMaillinglist:
|
if isEnabled and not isMaillinglist:
|
||||||
label = unicode(config.get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
label = unic(ustr(config.get(addressInKeysFile, 'label')).strip())
|
||||||
if label == "":
|
if label == "":
|
||||||
label = addressInKeysFile
|
label = addressInKeysFile
|
||||||
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
||||||
# self.ui.comboBoxSendFrom.model().sort(1, Qt.AscendingOrder)
|
# self.ui.comboBoxSendFrom.model().sort(1, Qt.AscendingOrder)
|
||||||
for i in range(self.ui.comboBoxSendFrom.count()):
|
for i in range(self.ui.comboBoxSendFrom.count()):
|
||||||
address = str(self.ui.comboBoxSendFrom.itemData(
|
address = ustr(self.ui.comboBoxSendFrom.itemData(
|
||||||
i, QtCore.Qt.UserRole).toString())
|
i, QtCore.Qt.UserRole))
|
||||||
self.ui.comboBoxSendFrom.setItemData(
|
self.ui.comboBoxSendFrom.setItemData(
|
||||||
i, AccountColor(address).accountColor(),
|
i, AccountColor(address).accountColor(),
|
||||||
QtCore.Qt.ForegroundRole)
|
QtCore.Qt.ForegroundRole)
|
||||||
|
@ -2392,13 +2393,13 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
addressInKeysFile, 'enabled')
|
addressInKeysFile, 'enabled')
|
||||||
isChan = config.safeGetBoolean(addressInKeysFile, 'chan')
|
isChan = config.safeGetBoolean(addressInKeysFile, 'chan')
|
||||||
if isEnabled and not isChan:
|
if isEnabled and not isChan:
|
||||||
label = unicode(config.get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
|
label = unic(ustr(config.get(addressInKeysFile, 'label')).strip())
|
||||||
if label == "":
|
if label == "":
|
||||||
label = addressInKeysFile
|
label = addressInKeysFile
|
||||||
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
|
||||||
for i in range(self.ui.comboBoxSendFromBroadcast.count()):
|
for i in range(self.ui.comboBoxSendFromBroadcast.count()):
|
||||||
address = str(self.ui.comboBoxSendFromBroadcast.itemData(
|
address = ustr(self.ui.comboBoxSendFromBroadcast.itemData(
|
||||||
i, QtCore.Qt.UserRole).toString())
|
i, QtCore.Qt.UserRole))
|
||||||
self.ui.comboBoxSendFromBroadcast.setItemData(
|
self.ui.comboBoxSendFromBroadcast.setItemData(
|
||||||
i, AccountColor(address).accountColor(),
|
i, AccountColor(address).accountColor(),
|
||||||
QtCore.Qt.ForegroundRole)
|
QtCore.Qt.ForegroundRole)
|
||||||
|
@ -2498,7 +2499,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.notifierShow(
|
self.notifierShow(
|
||||||
_translate("MainWindow", "New Message"),
|
_translate("MainWindow", "New Message"),
|
||||||
_translate("MainWindow", "From {0}").format(
|
_translate("MainWindow", "From {0}").format(
|
||||||
unicode(acct.fromLabel, 'utf-8')),
|
unic(ustr(acct.fromLabel))),
|
||||||
sound.SOUND_UNKNOWN
|
sound.SOUND_UNKNOWN
|
||||||
)
|
)
|
||||||
if self.getCurrentAccount() is not None and (
|
if self.getCurrentAccount() is not None and (
|
||||||
|
@ -2636,7 +2637,7 @@ 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.ui.comboBoxSendFrom.count()):
|
||||||
if str(self.ui.comboBoxSendFrom.itemData(i).toPyObject()) \
|
if ustr(self.ui.comboBoxSendFrom.itemData(i)) \
|
||||||
== acct.fromAddress:
|
== acct.fromAddress:
|
||||||
self.ui.comboBoxSendFrom.setCurrentIndex(i)
|
self.ui.comboBoxSendFrom.setCurrentIndex(i)
|
||||||
break
|
break
|
||||||
|
@ -2703,7 +2704,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if reply != QtGui.QMessageBox.Yes:
|
if reply != QtGui.QMessageBox.Yes:
|
||||||
return
|
return
|
||||||
config.set(
|
config.set(
|
||||||
'bitmessagesettings', 'dontconnect', str(dontconnect_option))
|
'bitmessagesettings', 'dontconnect', ustr(dontconnect_option))
|
||||||
config.save()
|
config.save()
|
||||||
self.ui.updateNetworkSwitchMenuLabel(dontconnect_option)
|
self.ui.updateNetworkSwitchMenuLabel(dontconnect_option)
|
||||||
|
|
||||||
|
@ -2934,8 +2935,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
lines[i] = '<br><br>'
|
lines[i] = '<br><br>'
|
||||||
content = ' '.join(lines) # To keep the whitespace between lines
|
content = ' '.join(lines) # To keep the whitespace between lines
|
||||||
content = shared.fixPotentiallyInvalidUTF8Data(content)
|
content = shared.fixPotentiallyInvalidUTF8Data(content)
|
||||||
content = unicode(content, 'utf-8)')
|
content = unic(ustr(content))
|
||||||
textEdit.setHtml(QtCore.QString(content))
|
textEdit.setHtml(content)
|
||||||
|
|
||||||
def on_action_InboxMarkUnread(self):
|
def on_action_InboxMarkUnread(self):
|
||||||
tableWidget = self.getCurrentMessagelist()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
|
@ -3002,7 +3003,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast
|
self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast
|
||||||
):
|
):
|
||||||
for i in range(box.count()):
|
for i in range(box.count()):
|
||||||
if str(box.itemData(i).toPyObject()) == address:
|
if ustr(box.itemData(i)) == ustr(address):
|
||||||
box.setCurrentIndex(i)
|
box.setCurrentIndex(i)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -3093,7 +3094,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
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.ui.lineEditTo.setText(ustr(acct.fromAddress))
|
||||||
else:
|
else:
|
||||||
self.ui.lineEditTo.setText(
|
self.ui.lineEditTo.setText(
|
||||||
tableWidget.item(currentInboxRow, column_from).accountString()
|
tableWidget.item(currentInboxRow, column_from).accountString()
|
||||||
|
@ -3108,7 +3109,7 @@ 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.ui.lineEditTo.setText(ustr(toAddressAtCurrentInboxRow))
|
||||||
else:
|
else:
|
||||||
self.ui.lineEditTo.setText(
|
self.ui.lineEditTo.setText(
|
||||||
tableWidget.item(currentInboxRow, column_to).accountString()
|
tableWidget.item(currentInboxRow, column_to).accountString()
|
||||||
|
@ -3117,7 +3118,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
|
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
|
||||||
|
|
||||||
quotedText = self.quoted_text(
|
quotedText = self.quoted_text(
|
||||||
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
|
unic(ustr(messageAtCurrentInboxRow)))
|
||||||
widget['message'].setPlainText(quotedText)
|
widget['message'].setPlainText(quotedText)
|
||||||
if acct.subject[0:3] in ('Re:', 'RE:'):
|
if acct.subject[0:3] in ('Re:', 'RE:'):
|
||||||
widget['subject'].setText(
|
widget['subject'].setText(
|
||||||
|
@ -3262,7 +3263,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return
|
return
|
||||||
currentInboxRow = tableWidget.currentRow()
|
currentInboxRow = tableWidget.currentRow()
|
||||||
try:
|
try:
|
||||||
subjectAtCurrentInboxRow = str(tableWidget.item(
|
subjectAtCurrentInboxRow = ustr(tableWidget.item(
|
||||||
currentInboxRow, 2).data(QtCore.Qt.UserRole))
|
currentInboxRow, 2).data(QtCore.Qt.UserRole))
|
||||||
except:
|
except:
|
||||||
subjectAtCurrentInboxRow = ''
|
subjectAtCurrentInboxRow = ''
|
||||||
|
@ -3334,7 +3335,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
addressAtCurrentRow = self.ui.tableWidgetInbox.item(
|
addressAtCurrentRow = self.ui.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(ustr(addressAtCurrentRow))
|
||||||
|
|
||||||
# Group of functions for the Address Book dialog box
|
# Group of functions for the Address Book dialog box
|
||||||
def on_action_AddressBookNew(self):
|
def on_action_AddressBookNew(self):
|
||||||
|
@ -3368,8 +3369,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return self.updateStatusBar(_translate(
|
return self.updateStatusBar(_translate(
|
||||||
"MainWindow", "No addresses selected."))
|
"MainWindow", "No addresses selected."))
|
||||||
|
|
||||||
addresses_string = unicode(
|
addresses_string = unic(ustr(
|
||||||
self.ui.lineEditTo.text().toUtf8(), 'utf-8')
|
self.ui.lineEditTo.text()))
|
||||||
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:
|
||||||
|
@ -3455,7 +3456,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def on_action_SubscriptionsClipboard(self):
|
def on_action_SubscriptionsClipboard(self):
|
||||||
address = self.getCurrentAccount()
|
address = self.getCurrentAccount()
|
||||||
clipboard = QtGui.QApplication.clipboard()
|
clipboard = QtGui.QApplication.clipboard()
|
||||||
clipboard.setText(str(address))
|
clipboard.setText(ustr(address))
|
||||||
|
|
||||||
def on_action_SubscriptionsEnable(self):
|
def on_action_SubscriptionsEnable(self):
|
||||||
address = self.getCurrentAccount()
|
address = self.getCurrentAccount()
|
||||||
|
@ -3607,9 +3608,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.inboxSearchLineEditChans,
|
self.ui.inboxSearchLineEditChans,
|
||||||
)
|
)
|
||||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||||
return (
|
return ustr(
|
||||||
messagelistList[currentIndex] if retObj
|
messagelistList[currentIndex] if retObj
|
||||||
else messagelistList[currentIndex].text().toUtf8().data())
|
else ustr(messagelistList[currentIndex].text()))
|
||||||
|
|
||||||
def getCurrentSearchOption(self, currentIndex=None):
|
def getCurrentSearchOption(self, currentIndex=None):
|
||||||
if currentIndex is None:
|
if currentIndex is None:
|
||||||
|
@ -3678,7 +3679,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
" delete the channel?"
|
" delete the channel?"
|
||||||
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
|
||||||
) == QtGui.QMessageBox.Yes:
|
) == QtGui.QMessageBox.Yes:
|
||||||
config.remove_section(str(account.address))
|
config.remove_section(ustr(account.address))
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -3711,7 +3712,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
account.setEnabled(False)
|
account.setEnabled(False)
|
||||||
|
|
||||||
def disableIdentity(self, address):
|
def disableIdentity(self, address):
|
||||||
config.set(str(address), 'enabled', 'false')
|
config.set(ustr(address), 'enabled', 'false')
|
||||||
config.save()
|
config.save()
|
||||||
shared.reloadMyAddressHashes()
|
shared.reloadMyAddressHashes()
|
||||||
self.rerenderAddressBook()
|
self.rerenderAddressBook()
|
||||||
|
@ -3719,7 +3720,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def on_action_Clipboard(self):
|
def on_action_Clipboard(self):
|
||||||
address = self.getCurrentAccount()
|
address = self.getCurrentAccount()
|
||||||
clipboard = QtGui.QApplication.clipboard()
|
clipboard = QtGui.QApplication.clipboard()
|
||||||
clipboard.setText(str(address))
|
clipboard.setText(ustr(address))
|
||||||
|
|
||||||
def on_action_ClipboardMessagelist(self):
|
def on_action_ClipboardMessagelist(self):
|
||||||
tableWidget = self.getCurrentMessagelist()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
|
@ -3739,7 +3740,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if isinstance(account, GatewayAccount) and otherAddress == account.relayAddress and (
|
if isinstance(account, GatewayAccount) and otherAddress == account.relayAddress and (
|
||||||
(currentColumn in [0, 2] and self.getCurrentFolder() == "sent") or
|
(currentColumn in [0, 2] and self.getCurrentFolder() == "sent") or
|
||||||
(currentColumn in [1, 2] and self.getCurrentFolder() != "sent")):
|
(currentColumn in [1, 2] and self.getCurrentFolder() != "sent")):
|
||||||
text = str(tableWidget.item(currentRow, currentColumn).label)
|
text = ustr(tableWidget.item(currentRow, currentColumn).label)
|
||||||
else:
|
else:
|
||||||
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
|
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
|
||||||
|
|
||||||
|
@ -3756,8 +3757,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
def on_action_SetAvatar(self, thisTableWidget):
|
def on_action_SetAvatar(self, thisTableWidget):
|
||||||
currentRow = thisTableWidget.currentRow()
|
currentRow = thisTableWidget.currentRow()
|
||||||
addressAtCurrentRow = thisTableWidget.item(
|
addressAtCurrentRow = ustr(thisTableWidget.item(
|
||||||
currentRow, 1).text()
|
currentRow, 1).text())
|
||||||
setToIdenticon = not self.setAvatar(addressAtCurrentRow)
|
setToIdenticon = not self.setAvatar(addressAtCurrentRow)
|
||||||
if setToIdenticon:
|
if setToIdenticon:
|
||||||
thisTableWidget.item(
|
thisTableWidget.item(
|
||||||
|
@ -3858,23 +3859,23 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
def on_action_AddressBookSetSound(self):
|
def on_action_AddressBookSetSound(self):
|
||||||
widget = self.ui.tableWidgetAddressBook
|
widget = self.ui.tableWidgetAddressBook
|
||||||
self.setAddressSound(widget.item(widget.currentRow(), 0).text())
|
self.setAddressSound(ustr(widget.item(widget.currentRow(), 0).text()))
|
||||||
|
|
||||||
def setAddressSound(self, addr):
|
def setAddressSound(self, addr):
|
||||||
filters = [unicode(_translate(
|
filters = [unic(_translate(
|
||||||
"MainWindow", "Sound files (%s)" %
|
"MainWindow", "Sound files (%s)" %
|
||||||
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
|
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
|
||||||
))]
|
))]
|
||||||
sourcefile = unicode(QtGui.QFileDialog.getOpenFileName(
|
sourcefile = unic(ustr(QtGui.QFileDialog.getOpenFileName(
|
||||||
self, _translate("MainWindow", "Set notification sound..."),
|
self, _translate("MainWindow", "Set notification sound..."),
|
||||||
filter=';;'.join(filters)
|
filter=';;'.join(filters)
|
||||||
))
|
)))
|
||||||
|
|
||||||
if not sourcefile:
|
if not sourcefile:
|
||||||
return
|
return
|
||||||
|
|
||||||
destdir = os.path.join(state.appdata, 'sounds')
|
destdir = os.path.join(state.appdata, 'sounds')
|
||||||
destfile = unicode(addr) + os.path.splitext(sourcefile)[-1]
|
destfile = unic(ustr(addr) + os.path.splitext(sourcefile)[-1])
|
||||||
destination = os.path.join(destdir, destfile)
|
destination = os.path.join(destdir, destfile)
|
||||||
|
|
||||||
if sourcefile == destination:
|
if sourcefile == destination:
|
||||||
|
@ -4027,7 +4028,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
def inboxSearchLineEditUpdated(self, text):
|
def inboxSearchLineEditUpdated(self, text):
|
||||||
# dynamic search for too short text is slow
|
# dynamic search for too short text is slow
|
||||||
text = text.toUtf8()
|
text = ustr(text)
|
||||||
if 0 < len(text) < 3:
|
if 0 < len(text) < 3:
|
||||||
return
|
return
|
||||||
messagelist = self.getCurrentMessagelist()
|
messagelist = self.getCurrentMessagelist()
|
||||||
|
@ -4042,7 +4043,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
logger.debug("Search return pressed")
|
logger.debug("Search return pressed")
|
||||||
searchLine = self.getCurrentSearchLine()
|
searchLine = self.getCurrentSearchLine()
|
||||||
messagelist = self.getCurrentMessagelist()
|
messagelist = self.getCurrentMessagelist()
|
||||||
if messagelist and len(str(searchLine)) < 3:
|
if messagelist and len(ustr(searchLine)) < 3:
|
||||||
searchOption = self.getCurrentSearchOption()
|
searchOption = self.getCurrentSearchOption()
|
||||||
account = self.getCurrentAccount()
|
account = self.getCurrentAccount()
|
||||||
folder = self.getCurrentFolder()
|
folder = self.getCurrentFolder()
|
||||||
|
@ -4084,7 +4085,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if item.type == AccountMixin.ALL:
|
if item.type == AccountMixin.ALL:
|
||||||
return
|
return
|
||||||
|
|
||||||
newLabel = unicode(item.text(0), 'utf-8', 'ignore')
|
newLabel = unic(ustr(item.text(0)))
|
||||||
oldLabel = item.defaultLabel()
|
oldLabel = item.defaultLabel()
|
||||||
|
|
||||||
# unchanged, do not do anything either
|
# unchanged, do not do anything either
|
||||||
|
@ -4155,8 +4156,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.rerenderMessagelistToLabels()
|
self.rerenderMessagelistToLabels()
|
||||||
completerList = self.ui.lineEditTo.completer().model().stringList()
|
completerList = self.ui.lineEditTo.completer().model().stringList()
|
||||||
for i in range(len(completerList)):
|
for i in range(len(completerList)):
|
||||||
if unicode(completerList[i]).endswith(" <" + item.address + ">"):
|
if unic(ustr(completerList[i])).endswith(" <" + ustr(item.address) + ">"):
|
||||||
completerList[i] = item.label + " <" + item.address + ">"
|
completerList[i] = ustr(item.label) + " <" + ustr(item.address) + ">"
|
||||||
self.ui.lineEditTo.completer().model().setStringList(completerList)
|
self.ui.lineEditTo.completer().model().setStringList(completerList)
|
||||||
|
|
||||||
def tabWidgetCurrentChanged(self, n):
|
def tabWidgetCurrentChanged(self, n):
|
||||||
|
|
|
@ -14,6 +14,7 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from ver import ustr
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
import queues
|
import queues
|
||||||
|
@ -131,6 +132,8 @@ class BMAccount(object):
|
||||||
"""Get a label for this bitmessage account"""
|
"""Get a label for this bitmessage account"""
|
||||||
if address is None:
|
if address is None:
|
||||||
address = self.address
|
address = self.address
|
||||||
|
else:
|
||||||
|
address = ustr(address)
|
||||||
label = config.safeGet(address, 'label', address)
|
label = config.safeGet(address, 'label', address)
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select label from addressbook where address=?''', address)
|
'''select label from addressbook where address=?''', address)
|
||||||
|
@ -148,15 +151,12 @@ class BMAccount(object):
|
||||||
def parseMessage(self, toAddress, fromAddress, subject, message):
|
def parseMessage(self, toAddress, fromAddress, subject, message):
|
||||||
"""Set metadata and address labels on self"""
|
"""Set metadata and address labels on self"""
|
||||||
|
|
||||||
self.toAddress = toAddress
|
self.toAddress = ustr(toAddress)
|
||||||
self.fromAddress = fromAddress
|
self.fromAddress = ustr(fromAddress)
|
||||||
if isinstance(subject, unicode):
|
self.subject = ustr(subject)
|
||||||
self.subject = str(subject)
|
self.message = ustr(message)
|
||||||
else:
|
self.fromLabel = ustr(self.getLabel(fromAddress))
|
||||||
self.subject = subject
|
self.toLabel = ustr(self.getLabel(toAddress))
|
||||||
self.message = message
|
|
||||||
self.fromLabel = self.getLabel(fromAddress)
|
|
||||||
self.toLabel = self.getLabel(toAddress)
|
|
||||||
|
|
||||||
|
|
||||||
class NoAccount(BMAccount):
|
class NoAccount(BMAccount):
|
||||||
|
|
|
@ -5,6 +5,7 @@ Dialogs that work with BM address.
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import queues
|
import queues
|
||||||
|
@ -29,12 +30,12 @@ class AddressCheckMixin(object):
|
||||||
def _onSuccess(self, addressVersion, streamNumber, ripe):
|
def _onSuccess(self, addressVersion, streamNumber, ripe):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addressChanged(self, QString):
|
def addressChanged(self, addr):
|
||||||
"""
|
"""
|
||||||
Address validation callback, performs validation and gives feedback
|
Address validation callback, performs validation and gives feedback
|
||||||
"""
|
"""
|
||||||
status, addressVersion, streamNumber, ripe = decodeAddress(
|
status, addressVersion, streamNumber, ripe = decodeAddress(
|
||||||
str(QString))
|
ustr(addr))
|
||||||
self.valid = status == 'success'
|
self.valid = status == 'success'
|
||||||
if self.valid:
|
if self.valid:
|
||||||
self.labelAddressCheck.setText(
|
self.labelAddressCheck.setText(
|
||||||
|
@ -90,8 +91,8 @@ class AddressDataDialog(QtGui.QDialog, AddressCheckMixin):
|
||||||
"""Callback for QDIalog accepting value"""
|
"""Callback for QDIalog accepting value"""
|
||||||
if self.valid:
|
if self.valid:
|
||||||
self.data = (
|
self.data = (
|
||||||
addBMIfNotPresent(str(self.lineEditAddress.text())),
|
addBMIfNotPresent(ustr(self.lineEditAddress.text())),
|
||||||
str(self.lineEditLabel.text().toUtf8())
|
ustr(self.lineEditLabel.text())
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
queues.UISignalQueue.put(('updateStatusBar', _translate(
|
queues.UISignalQueue.put(('updateStatusBar', _translate(
|
||||||
|
@ -142,12 +143,12 @@ class NewAddressDialog(QtGui.QDialog):
|
||||||
self.comboBoxExisting.currentText())[2]
|
self.comboBoxExisting.currentText())[2]
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'createRandomAddress', 4, streamNumberForAddress,
|
'createRandomAddress', 4, streamNumberForAddress,
|
||||||
str(self.newaddresslabel.text().toUtf8()), 1, "",
|
ustr(self.newaddresslabel.text()), 1, "",
|
||||||
self.checkBoxEighteenByteRipe.isChecked()
|
self.checkBoxEighteenByteRipe.isChecked()
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
if self.lineEditPassphrase.text() != \
|
if ustr(self.lineEditPassphrase.text()) != \
|
||||||
self.lineEditPassphraseAgain.text():
|
ustr(self.lineEditPassphraseAgain.text()):
|
||||||
QtGui.QMessageBox.about(
|
QtGui.QMessageBox.about(
|
||||||
self, _translate("MainWindow", "Passphrase mismatch"),
|
self, _translate("MainWindow", "Passphrase mismatch"),
|
||||||
_translate(
|
_translate(
|
||||||
|
@ -169,7 +170,7 @@ class NewAddressDialog(QtGui.QDialog):
|
||||||
'createDeterministicAddresses', 4, streamNumberForAddress,
|
'createDeterministicAddresses', 4, streamNumberForAddress,
|
||||||
"unused deterministic address",
|
"unused deterministic address",
|
||||||
self.spinBoxNumberOfAddressesToMake.value(),
|
self.spinBoxNumberOfAddressesToMake.value(),
|
||||||
self.lineEditPassphrase.text().toUtf8(),
|
ustr(self.lineEditPassphrase.text()),
|
||||||
self.checkBoxEighteenByteRipe.isChecked()
|
self.checkBoxEighteenByteRipe.isChecked()
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -234,7 +235,7 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
||||||
def __init__(self, parent=None, config=global_config):
|
def __init__(self, parent=None, config=global_config):
|
||||||
super(SpecialAddressBehaviorDialog, self).__init__(parent)
|
super(SpecialAddressBehaviorDialog, self).__init__(parent)
|
||||||
widgets.load('specialaddressbehavior.ui', self)
|
widgets.load('specialaddressbehavior.ui', self)
|
||||||
self.address = parent.getCurrentAccount()
|
self.address = ustr(parent.getCurrentAccount())
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
@ -259,7 +260,7 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
||||||
self.radioButtonBehaveNormalAddress.click()
|
self.radioButtonBehaveNormalAddress.click()
|
||||||
mailingListName = config.safeGet(self.address, 'mailinglistname', '')
|
mailingListName = config.safeGet(self.address, 'mailinglistname', '')
|
||||||
self.lineEditMailingListName.setText(
|
self.lineEditMailingListName.setText(
|
||||||
unicode(mailingListName, 'utf-8')
|
unic(ustr(mailingListName))
|
||||||
)
|
)
|
||||||
|
|
||||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||||
|
@ -271,7 +272,7 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
||||||
if self.address_is_chan:
|
if self.address_is_chan:
|
||||||
return
|
return
|
||||||
if self.radioButtonBehaveNormalAddress.isChecked():
|
if self.radioButtonBehaveNormalAddress.isChecked():
|
||||||
self.config.set(str(self.address), 'mailinglist', 'false')
|
self.config.set(self.address, 'mailinglist', 'false')
|
||||||
# Set the color to either black or grey
|
# Set the color to either black or grey
|
||||||
if self.config.getboolean(self.address, 'enabled'):
|
if self.config.getboolean(self.address, 'enabled'):
|
||||||
self.parent.setCurrentItemColor(
|
self.parent.setCurrentItemColor(
|
||||||
|
@ -280,9 +281,9 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog):
|
||||||
else:
|
else:
|
||||||
self.parent.setCurrentItemColor(QtGui.QColor(128, 128, 128))
|
self.parent.setCurrentItemColor(QtGui.QColor(128, 128, 128))
|
||||||
else:
|
else:
|
||||||
self.config.set(str(self.address), 'mailinglist', 'true')
|
self.config.set(self.address, 'mailinglist', 'true')
|
||||||
self.config.set(str(self.address), 'mailinglistname', str(
|
self.config.set(self.address, 'mailinglistname', ustr(
|
||||||
self.lineEditMailingListName.text().toUtf8()))
|
self.lineEditMailingListName.text()))
|
||||||
self.parent.setCurrentItemColor(
|
self.parent.setCurrentItemColor(
|
||||||
QtGui.QColor(137, 4, 177)) # magenta
|
QtGui.QColor(137, 4, 177)) # magenta
|
||||||
self.parent.rerenderComboBoxSendFrom()
|
self.parent.rerenderComboBoxSendFrom()
|
||||||
|
@ -344,7 +345,7 @@ class EmailGatewayDialog(QtGui.QDialog):
|
||||||
|
|
||||||
if self.radioButtonRegister.isChecked() \
|
if self.radioButtonRegister.isChecked() \
|
||||||
or self.radioButtonRegister.isHidden():
|
or self.radioButtonRegister.isHidden():
|
||||||
email = str(self.lineEditEmail.text().toUtf8())
|
email = ustr(self.lineEditEmail.text())
|
||||||
self.acct.register(email)
|
self.acct.register(email)
|
||||||
self.config.set(self.acct.fromAddress, 'label', email)
|
self.config.set(self.acct.fromAddress, 'label', email)
|
||||||
self.config.set(self.acct.fromAddress, 'gateway', 'mailchuck')
|
self.config.set(self.acct.fromAddress, 'gateway', 'mailchuck')
|
||||||
|
|
|
@ -5,6 +5,7 @@ Address validator module.
|
||||||
|
|
||||||
from Queue import Empty
|
from Queue import Empty
|
||||||
|
|
||||||
|
from ver import ustr
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from addresses import decodeAddress, addBMIfNotPresent
|
from addresses import decodeAddress, addBMIfNotPresent
|
||||||
|
@ -108,13 +109,13 @@ class AddressPassPhraseValidatorMixin(object):
|
||||||
if self.addressObject is None:
|
if self.addressObject is None:
|
||||||
address = None
|
address = None
|
||||||
else:
|
else:
|
||||||
address = str(self.addressObject.text().toUtf8())
|
address = ustr(self.addressObject.text())
|
||||||
if address == "":
|
if address == "":
|
||||||
address = None
|
address = None
|
||||||
if self.passPhraseObject is None:
|
if self.passPhraseObject is None:
|
||||||
passPhrase = ""
|
passPhrase = ""
|
||||||
else:
|
else:
|
||||||
passPhrase = str(self.passPhraseObject.text().toUtf8())
|
passPhrase = ustr(self.passPhraseObject.text())
|
||||||
if passPhrase == "":
|
if passPhrase == "":
|
||||||
passPhrase = None
|
passPhrase = None
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ class AddressPassPhraseValidatorMixin(object):
|
||||||
|
|
||||||
# check through generator
|
# check through generator
|
||||||
if address is None:
|
if address is None:
|
||||||
addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + str(passPhrase), passPhrase, False))
|
addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + ustr(passPhrase), passPhrase, False))
|
||||||
else:
|
else:
|
||||||
addressGeneratorQueue.put(
|
addressGeneratorQueue.put(
|
||||||
('joinChan', addBMIfNotPresent(address),
|
('joinChan', addBMIfNotPresent(address),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import widgets
|
import widgets
|
||||||
|
@ -59,7 +60,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
if self.NewBlacklistDialogInstance.exec_():
|
if self.NewBlacklistDialogInstance.exec_():
|
||||||
if self.NewBlacklistDialogInstance.labelAddressCheck.text() == \
|
if self.NewBlacklistDialogInstance.labelAddressCheck.text() == \
|
||||||
_translate("MainWindow", "Address is valid."):
|
_translate("MainWindow", "Address is valid."):
|
||||||
address = addBMIfNotPresent(str(
|
address = addBMIfNotPresent(ustr(
|
||||||
self.NewBlacklistDialogInstance.lineEditAddress.text()))
|
self.NewBlacklistDialogInstance.lineEditAddress.text()))
|
||||||
# First we must check to see if the address is already in the
|
# First we must check to see if the address is already in the
|
||||||
# address book. The user cannot add it again or else it will
|
# address book. The user cannot add it again or else it will
|
||||||
|
@ -73,8 +74,8 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
if queryreturn == []:
|
if queryreturn == []:
|
||||||
self.tableWidgetBlacklist.setSortingEnabled(False)
|
self.tableWidgetBlacklist.setSortingEnabled(False)
|
||||||
self.tableWidgetBlacklist.insertRow(0)
|
self.tableWidgetBlacklist.insertRow(0)
|
||||||
newItem = QtGui.QTableWidgetItem(unicode(
|
newItem = QtGui.QTableWidgetItem(unic(ustr(
|
||||||
self.NewBlacklistDialogInstance.lineEditLabel.text().toUtf8(), 'utf-8'))
|
self.NewBlacklistDialogInstance.lineEditLabel.text())))
|
||||||
newItem.setIcon(avatarize(address))
|
newItem.setIcon(avatarize(address))
|
||||||
self.tableWidgetBlacklist.setItem(0, 0, newItem)
|
self.tableWidgetBlacklist.setItem(0, 0, newItem)
|
||||||
newItem = QtGui.QTableWidgetItem(address)
|
newItem = QtGui.QTableWidgetItem(address)
|
||||||
|
@ -82,7 +83,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||||
self.tableWidgetBlacklist.setItem(0, 1, newItem)
|
self.tableWidgetBlacklist.setItem(0, 1, newItem)
|
||||||
self.tableWidgetBlacklist.setSortingEnabled(True)
|
self.tableWidgetBlacklist.setSortingEnabled(True)
|
||||||
t = (str(self.NewBlacklistDialogInstance.lineEditLabel.text().toUtf8()), address, True)
|
t = (ustr(self.NewBlacklistDialogInstance.lineEditLabel.text()), address, True)
|
||||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||||
sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
|
sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
|
||||||
else:
|
else:
|
||||||
|
@ -111,10 +112,10 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
if isinstance(addressitem, QtGui.QTableWidgetItem):
|
if isinstance(addressitem, QtGui.QTableWidgetItem):
|
||||||
if self.radioButtonBlacklist.isChecked():
|
if self.radioButtonBlacklist.isChecked():
|
||||||
sqlExecute('''UPDATE blacklist SET label=? WHERE address=?''',
|
sqlExecute('''UPDATE blacklist SET label=? WHERE address=?''',
|
||||||
str(item.text()), str(addressitem.text()))
|
ustr(item.text()), ustr(addressitem.text()))
|
||||||
else:
|
else:
|
||||||
sqlExecute('''UPDATE whitelist SET label=? WHERE address=?''',
|
sqlExecute('''UPDATE whitelist SET label=? WHERE address=?''',
|
||||||
str(item.text()), str(addressitem.text()))
|
ustr(item.text()), ustr(addressitem.text()))
|
||||||
|
|
||||||
def init_blacklist_popup_menu(self, connectSignal=True):
|
def init_blacklist_popup_menu(self, connectSignal=True):
|
||||||
# Popup menu for the Blacklist page
|
# Popup menu for the Blacklist page
|
||||||
|
@ -172,7 +173,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
label, address, enabled = row
|
label, address, enabled = row
|
||||||
self.tableWidgetBlacklist.insertRow(0)
|
self.tableWidgetBlacklist.insertRow(0)
|
||||||
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
|
newItem = QtGui.QTableWidgetItem(unic(ustr(label)))
|
||||||
if not enabled:
|
if not enabled:
|
||||||
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
newItem.setTextColor(QtGui.QColor(128, 128, 128))
|
||||||
newItem.setIcon(avatarize(address))
|
newItem.setIcon(avatarize(address))
|
||||||
|
@ -191,18 +192,18 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
|
|
||||||
def on_action_BlacklistDelete(self):
|
def on_action_BlacklistDelete(self):
|
||||||
currentRow = self.tableWidgetBlacklist.currentRow()
|
currentRow = self.tableWidgetBlacklist.currentRow()
|
||||||
labelAtCurrentRow = self.tableWidgetBlacklist.item(
|
labelAtCurrentRow = ustr(self.tableWidgetBlacklist.item(
|
||||||
currentRow, 0).text().toUtf8()
|
currentRow, 0).text())
|
||||||
addressAtCurrentRow = self.tableWidgetBlacklist.item(
|
addressAtCurrentRow = self.tableWidgetBlacklist.item(
|
||||||
currentRow, 1).text()
|
currentRow, 1).text()
|
||||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''DELETE FROM blacklist WHERE label=? AND address=?''',
|
'''DELETE FROM blacklist WHERE label=? AND address=?''',
|
||||||
str(labelAtCurrentRow), str(addressAtCurrentRow))
|
ustr(labelAtCurrentRow), ustr(addressAtCurrentRow))
|
||||||
else:
|
else:
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''DELETE FROM whitelist WHERE label=? AND address=?''',
|
'''DELETE FROM whitelist WHERE label=? AND address=?''',
|
||||||
str(labelAtCurrentRow), str(addressAtCurrentRow))
|
ustr(labelAtCurrentRow), ustr(addressAtCurrentRow))
|
||||||
self.tableWidgetBlacklist.removeRow(currentRow)
|
self.tableWidgetBlacklist.removeRow(currentRow)
|
||||||
|
|
||||||
def on_action_BlacklistClipboard(self):
|
def on_action_BlacklistClipboard(self):
|
||||||
|
@ -210,7 +211,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
addressAtCurrentRow = self.tableWidgetBlacklist.item(
|
addressAtCurrentRow = self.tableWidgetBlacklist.item(
|
||||||
currentRow, 1).text()
|
currentRow, 1).text()
|
||||||
clipboard = QtGui.QApplication.clipboard()
|
clipboard = QtGui.QApplication.clipboard()
|
||||||
clipboard.setText(str(addressAtCurrentRow))
|
clipboard.setText(ustr(addressAtCurrentRow))
|
||||||
|
|
||||||
def on_context_menuBlacklist(self, point):
|
def on_context_menuBlacklist(self, point):
|
||||||
self.popMenuBlacklist.exec_(
|
self.popMenuBlacklist.exec_(
|
||||||
|
@ -227,11 +228,11 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE blacklist SET enabled=1 WHERE address=?''',
|
'''UPDATE blacklist SET enabled=1 WHERE address=?''',
|
||||||
str(addressAtCurrentRow))
|
ustr(addressAtCurrentRow))
|
||||||
else:
|
else:
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE whitelist SET enabled=1 WHERE address=?''',
|
'''UPDATE whitelist SET enabled=1 WHERE address=?''',
|
||||||
str(addressAtCurrentRow))
|
ustr(addressAtCurrentRow))
|
||||||
|
|
||||||
def on_action_BlacklistDisable(self):
|
def on_action_BlacklistDisable(self):
|
||||||
currentRow = self.tableWidgetBlacklist.currentRow()
|
currentRow = self.tableWidgetBlacklist.currentRow()
|
||||||
|
@ -243,10 +244,10 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
|
||||||
currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
|
currentRow, 1).setTextColor(QtGui.QColor(128, 128, 128))
|
||||||
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
if config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE blacklist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
|
'''UPDATE blacklist SET enabled=0 WHERE address=?''', ustr(addressAtCurrentRow))
|
||||||
else:
|
else:
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE whitelist SET enabled=0 WHERE address=?''', str(addressAtCurrentRow))
|
'''UPDATE whitelist SET enabled=0 WHERE address=?''', ustr(addressAtCurrentRow))
|
||||||
|
|
||||||
def on_action_BlacklistSetAvatar(self):
|
def on_action_BlacklistSetAvatar(self):
|
||||||
self.window().on_action_SetAvatar(self.tableWidgetBlacklist)
|
self.window().on_action_SetAvatar(self.tableWidgetBlacklist)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
Custom dialog classes
|
Custom dialog classes
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
from ver import ustr
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
import paths
|
import paths
|
||||||
|
@ -36,7 +37,7 @@ class AboutDialog(QtGui.QDialog):
|
||||||
if commit:
|
if commit:
|
||||||
version += '-' + commit[:7]
|
version += '-' + commit[:7]
|
||||||
self.labelVersion.setText(
|
self.labelVersion.setText(
|
||||||
self.labelVersion.text().replace(
|
ustr(self.labelVersion.text()).replace(
|
||||||
':version:', version
|
':version:', version
|
||||||
).replace(':branch:', commit or 'v%s' % version)
|
).replace(':branch:', commit or 'v%s' % version)
|
||||||
)
|
)
|
||||||
|
@ -44,8 +45,8 @@ class AboutDialog(QtGui.QDialog):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.label_2.setText(
|
self.label_2.setText(
|
||||||
self.label_2.text().replace(
|
ustr(self.label_2.text()).replace(
|
||||||
'2022', str(last_commit.get('time').year)
|
'2022', ustr(last_commit.get('time').year)
|
||||||
))
|
))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -6,6 +6,7 @@ Folder tree and messagelist widgets definitions.
|
||||||
|
|
||||||
from cgi import escape
|
from cgi import escape
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from bmconfigparser import config
|
from bmconfigparser import config
|
||||||
|
@ -62,7 +63,7 @@ class AccountMixin(object):
|
||||||
|
|
||||||
def accountString(self):
|
def accountString(self):
|
||||||
"""Account string suitable for use in To: field: label <address>"""
|
"""Account string suitable for use in To: field: label <address>"""
|
||||||
label = self._getLabel()
|
label = ustr(self._getLabel())
|
||||||
return (
|
return (
|
||||||
self.address if label == self.address
|
self.address if label == self.address
|
||||||
else '%s <%s>' % (label, self.address)
|
else '%s <%s>' % (label, self.address)
|
||||||
|
@ -73,7 +74,7 @@ class AccountMixin(object):
|
||||||
if address is None:
|
if address is None:
|
||||||
self.address = None
|
self.address = None
|
||||||
else:
|
else:
|
||||||
self.address = str(address)
|
self.address = ustr(address)
|
||||||
|
|
||||||
def setUnreadCount(self, cnt):
|
def setUnreadCount(self, cnt):
|
||||||
"""Set number of unread messages"""
|
"""Set number of unread messages"""
|
||||||
|
@ -124,8 +125,8 @@ class AccountMixin(object):
|
||||||
AccountMixin.NORMAL,
|
AccountMixin.NORMAL,
|
||||||
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||||
try:
|
try:
|
||||||
retval = unicode(
|
retval = unic(ustr(
|
||||||
config.get(self.address, 'label'), 'utf-8')
|
config.get(self.address, 'label')))
|
||||||
except Exception:
|
except Exception:
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select label from addressbook where address=?''', self.address)
|
'''select label from addressbook where address=?''', self.address)
|
||||||
|
@ -136,12 +137,11 @@ class AccountMixin(object):
|
||||||
if queryreturn != []:
|
if queryreturn != []:
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
retval, = row
|
retval, = row
|
||||||
retval = unicode(retval, 'utf-8')
|
retval = unic(ustr(retval))
|
||||||
elif self.address is None or self.type == AccountMixin.ALL:
|
elif self.address is None or self.type == AccountMixin.ALL:
|
||||||
return unicode(
|
return unic(_translate("MainWindow", "All accounts"))
|
||||||
str(_translate("MainWindow", "All accounts")), 'utf-8')
|
|
||||||
|
|
||||||
return retval or unicode(self.address, 'utf-8')
|
return retval or unic(self.address)
|
||||||
|
|
||||||
|
|
||||||
class BMTreeWidgetItem(QtGui.QTreeWidgetItem, AccountMixin):
|
class BMTreeWidgetItem(QtGui.QTreeWidgetItem, AccountMixin):
|
||||||
|
@ -154,7 +154,7 @@ class BMTreeWidgetItem(QtGui.QTreeWidgetItem, AccountMixin):
|
||||||
self._setup(parent, pos)
|
self._setup(parent, pos)
|
||||||
|
|
||||||
def _getAddressBracket(self, unreadCount=False):
|
def _getAddressBracket(self, unreadCount=False):
|
||||||
return " (" + str(self.unreadCount) + ")" if unreadCount else ""
|
return " (" + ustr(self.unreadCount) + ")" if unreadCount else ""
|
||||||
|
|
||||||
def data(self, column, role):
|
def data(self, column, role):
|
||||||
"""Override internal QT method for returning object data"""
|
"""Override internal QT method for returning object data"""
|
||||||
|
@ -191,7 +191,7 @@ class Ui_FolderWidget(BMTreeWidgetItem):
|
||||||
|
|
||||||
def setFolderName(self, fname):
|
def setFolderName(self, fname):
|
||||||
"""Set folder name (for QT UI)"""
|
"""Set folder name (for QT UI)"""
|
||||||
self.folderName = str(fname)
|
self.folderName = ustr(fname)
|
||||||
|
|
||||||
def data(self, column, role):
|
def data(self, column, role):
|
||||||
"""Override internal QT method for returning object data"""
|
"""Override internal QT method for returning object data"""
|
||||||
|
@ -232,15 +232,14 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
|
||||||
|
|
||||||
def _getLabel(self):
|
def _getLabel(self):
|
||||||
if self.address is None:
|
if self.address is None:
|
||||||
return unicode(_translate(
|
return unic(_translate(
|
||||||
"MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore')
|
"MainWindow", "All accounts"))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
return unicode(
|
return unic(ustr(
|
||||||
config.get(self.address, 'label'),
|
config.get(self.address, 'label')))
|
||||||
'utf-8', 'ignore')
|
|
||||||
except:
|
except:
|
||||||
return unicode(self.address, 'utf-8')
|
return unic(self.address)
|
||||||
|
|
||||||
def _getAddressBracket(self, unreadCount=False):
|
def _getAddressBracket(self, unreadCount=False):
|
||||||
ret = "" if self.isExpanded() \
|
ret = "" if self.isExpanded() \
|
||||||
|
@ -264,8 +263,8 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
|
||||||
if role == QtCore.Qt.EditRole \
|
if role == QtCore.Qt.EditRole \
|
||||||
and self.type != AccountMixin.SUBSCRIPTION:
|
and self.type != AccountMixin.SUBSCRIPTION:
|
||||||
config.set(
|
config.set(
|
||||||
str(self.address), 'label',
|
self.address, 'label',
|
||||||
str(value.toString().toUtf8())
|
ustr(value)
|
||||||
if isinstance(value, QtCore.QVariant)
|
if isinstance(value, QtCore.QVariant)
|
||||||
else value.encode('utf-8')
|
else value.encode('utf-8')
|
||||||
)
|
)
|
||||||
|
@ -311,8 +310,8 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
|
||||||
if queryreturn != []:
|
if queryreturn != []:
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
retval, = row
|
retval, = row
|
||||||
return unicode(retval, 'utf-8', 'ignore')
|
return unic(ustr(retval))
|
||||||
return unicode(self.address, 'utf-8')
|
return unic(self.address)
|
||||||
|
|
||||||
def setType(self):
|
def setType(self):
|
||||||
"""Set account type"""
|
"""Set account type"""
|
||||||
|
@ -323,10 +322,10 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
|
||||||
"""Save subscription label to database"""
|
"""Save subscription label to database"""
|
||||||
if role == QtCore.Qt.EditRole:
|
if role == QtCore.Qt.EditRole:
|
||||||
if isinstance(value, QtCore.QVariant):
|
if isinstance(value, QtCore.QVariant):
|
||||||
label = str(
|
label = ustr(
|
||||||
value.toString().toUtf8()).decode('utf-8', 'ignore')
|
value)
|
||||||
else:
|
else:
|
||||||
label = unicode(value, 'utf-8', 'ignore')
|
label = unic(ustr(value))
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
||||||
label, self.address)
|
label, self.address)
|
||||||
|
@ -407,9 +406,8 @@ class MessageList_AddressWidget(BMAddressWidget):
|
||||||
AccountMixin.NORMAL,
|
AccountMixin.NORMAL,
|
||||||
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||||
try:
|
try:
|
||||||
newLabel = unicode(
|
newLabel = unic(ustr(
|
||||||
config.get(self.address, 'label'),
|
config.get(self.address, 'label')))
|
||||||
'utf-8', 'ignore')
|
|
||||||
except:
|
except:
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'''select label from addressbook where address=?''', self.address)
|
'''select label from addressbook where address=?''', self.address)
|
||||||
|
@ -418,7 +416,7 @@ class MessageList_AddressWidget(BMAddressWidget):
|
||||||
'''select label from subscriptions where address=?''', self.address)
|
'''select label from subscriptions where address=?''', self.address)
|
||||||
if queryreturn:
|
if queryreturn:
|
||||||
for row in queryreturn:
|
for row in queryreturn:
|
||||||
newLabel = unicode(row[0], 'utf-8', 'ignore')
|
newLabel = unic(ustr(row[0]))
|
||||||
|
|
||||||
self.label = newLabel
|
self.label = newLabel
|
||||||
|
|
||||||
|
@ -454,9 +452,9 @@ class MessageList_SubjectWidget(BMTableWidgetItem):
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
"""Return object data (QT UI)"""
|
"""Return object data (QT UI)"""
|
||||||
if role == QtCore.Qt.UserRole:
|
if role == QtCore.Qt.UserRole:
|
||||||
return self.subject
|
return ustr(self.subject)
|
||||||
if role == QtCore.Qt.ToolTipRole:
|
if role == QtCore.Qt.ToolTipRole:
|
||||||
return escape(unicode(self.subject, 'utf-8'))
|
return escape(unic(ustr(self.subject)))
|
||||||
return super(MessageList_SubjectWidget, self).data(role)
|
return super(MessageList_SubjectWidget, self).data(role)
|
||||||
|
|
||||||
# label (or address) alphabetically, disabled at the end
|
# label (or address) alphabetically, disabled at the end
|
||||||
|
@ -491,9 +489,9 @@ class MessageList_TimeWidget(BMTableWidgetItem):
|
||||||
"""
|
"""
|
||||||
data = super(MessageList_TimeWidget, self).data(role)
|
data = super(MessageList_TimeWidget, self).data(role)
|
||||||
if role == TimestampRole:
|
if role == TimestampRole:
|
||||||
return int(data.toPyObject())
|
return int(data)
|
||||||
if role == QtCore.Qt.UserRole:
|
if role == QtCore.Qt.UserRole:
|
||||||
return str(data.toPyObject())
|
return ustr(data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,8 +511,8 @@ class Ui_AddressBookWidgetItem(BMAddressWidget):
|
||||||
def setData(self, role, value):
|
def setData(self, role, value):
|
||||||
"""Set data"""
|
"""Set data"""
|
||||||
if role == QtCore.Qt.EditRole:
|
if role == QtCore.Qt.EditRole:
|
||||||
self.label = str(
|
self.label = ustr(
|
||||||
value.toString().toUtf8()
|
value
|
||||||
if isinstance(value, QtCore.QVariant) else value
|
if isinstance(value, QtCore.QVariant) else value
|
||||||
)
|
)
|
||||||
if self.type in (
|
if self.type in (
|
||||||
|
@ -546,7 +544,7 @@ class Ui_AddressBookWidgetItem(BMAddressWidget):
|
||||||
class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem):
|
class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem):
|
||||||
"""Addressbook label item"""
|
"""Addressbook label item"""
|
||||||
def __init__(self, address, label, acc_type):
|
def __init__(self, address, label, acc_type):
|
||||||
self.address = address
|
self.address = ustr(address)
|
||||||
super(Ui_AddressBookWidgetItemLabel, self).__init__(label, acc_type)
|
super(Ui_AddressBookWidgetItemLabel, self).__init__(label, acc_type)
|
||||||
|
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
|
@ -558,7 +556,7 @@ class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem):
|
||||||
class Ui_AddressBookWidgetItemAddress(Ui_AddressBookWidgetItem):
|
class Ui_AddressBookWidgetItemAddress(Ui_AddressBookWidgetItem):
|
||||||
"""Addressbook address item"""
|
"""Addressbook address item"""
|
||||||
def __init__(self, address, label, acc_type):
|
def __init__(self, address, label, acc_type):
|
||||||
self.address = address
|
self.address = ustr(address)
|
||||||
super(Ui_AddressBookWidgetItemAddress, self).__init__(address, acc_type)
|
super(Ui_AddressBookWidgetItemAddress, self).__init__(address, acc_type)
|
||||||
|
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
|
@ -584,14 +582,14 @@ class AddressBookCompleter(QtGui.QCompleter):
|
||||||
|
|
||||||
def splitPath(self, path):
|
def splitPath(self, path):
|
||||||
"""Split on semicolon"""
|
"""Split on semicolon"""
|
||||||
text = unicode(path.toUtf8(), 'utf-8')
|
text = unic(ustr(path))
|
||||||
return [text[:self.widget().cursorPosition()].split(';')[-1].strip()]
|
return [text[:self.widget().cursorPosition()].split(';')[-1].strip()]
|
||||||
|
|
||||||
def pathFromIndex(self, index):
|
def pathFromIndex(self, index):
|
||||||
"""Perform autocompletion (reimplemented QCompleter method)"""
|
"""Perform autocompletion (reimplemented QCompleter method)"""
|
||||||
autoString = unicode(
|
autoString = unic(ustr(
|
||||||
index.data(QtCore.Qt.EditRole).toString().toUtf8(), 'utf-8')
|
index.data(QtCore.Qt.EditRole)))
|
||||||
text = unicode(self.widget().text().toUtf8(), 'utf-8')
|
text = unic(ustr(self.widget().text()))
|
||||||
|
|
||||||
# If cursor position was saved, restore it, else save it
|
# If cursor position was saved, restore it, else save it
|
||||||
if self.cursorPos != -1:
|
if self.cursorPos != -1:
|
||||||
|
|
|
@ -5,6 +5,7 @@ zoom and URL click warning popup
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from safehtmlparser import SafeHTMLParser
|
from safehtmlparser import SafeHTMLParser
|
||||||
|
@ -56,7 +57,7 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
|
||||||
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
|
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
|
||||||
QtGui.QApplication.activeWindow().statusBar().showMessage(_translate(
|
QtGui.QApplication.activeWindow().statusBar().showMessage(_translate(
|
||||||
"MainWindow", "Zoom level {0}%").format(str(zoom)))
|
"MainWindow", "Zoom level {0}%").format(ustr(zoom)))
|
||||||
|
|
||||||
def setWrappingWidth(self, width=None):
|
def setWrappingWidth(self, width=None):
|
||||||
"""Set word-wrapping width"""
|
"""Set word-wrapping width"""
|
||||||
|
@ -91,7 +92,7 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
QtGui.QApplication.translate(
|
QtGui.QApplication.translate(
|
||||||
"MessageView",
|
"MessageView",
|
||||||
"The link \"{0}\" will open in a browser. It may be a security risk, it could de-anonymise you"
|
"The link \"{0}\" will open in a browser. It may be a security risk, it could de-anonymise you"
|
||||||
" or download malicious data. Are you sure?").format(unicode(link.toString())),
|
" or download malicious data. Are you sure?").format(unic(ustr(link))),
|
||||||
QtGui.QMessageBox.Yes,
|
QtGui.QMessageBox.Yes,
|
||||||
QtGui.QMessageBox.No)
|
QtGui.QMessageBox.No)
|
||||||
if reply == QtGui.QMessageBox.Yes:
|
if reply == QtGui.QMessageBox.Yes:
|
||||||
|
@ -124,7 +125,7 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
if pos > self.outpos:
|
if pos > self.outpos:
|
||||||
self.outpos = pos + 1
|
self.outpos = pos + 1
|
||||||
cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.MoveAnchor)
|
cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.MoveAnchor)
|
||||||
cursor.insertHtml(QtCore.QString(self.out[startpos:self.outpos]))
|
cursor.insertHtml(unic(self.out[startpos:self.outpos]))
|
||||||
self.verticalScrollBar().setValue(position)
|
self.verticalScrollBar().setValue(position)
|
||||||
self.rendering = False
|
self.rendering = False
|
||||||
|
|
||||||
|
@ -133,9 +134,9 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
self.mode = MessageView.MODE_PLAIN
|
self.mode = MessageView.MODE_PLAIN
|
||||||
out = self.html.raw
|
out = self.html.raw
|
||||||
if self.html.has_html:
|
if self.html.has_html:
|
||||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(
|
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unic(ustr(
|
||||||
QtGui.QApplication.translate(
|
QtGui.QApplication.translate(
|
||||||
"MessageView", "HTML detected, click here to display")) + "</b></div><br/>" + out
|
"MessageView", "HTML detected, click here to display")) + "</b></div><br/>" + out)
|
||||||
self.out = out
|
self.out = out
|
||||||
self.outpos = 0
|
self.outpos = 0
|
||||||
self.setHtml("")
|
self.setHtml("")
|
||||||
|
@ -145,8 +146,8 @@ class MessageView(QtGui.QTextBrowser):
|
||||||
"""Render message as HTML"""
|
"""Render message as HTML"""
|
||||||
self.mode = MessageView.MODE_HTML
|
self.mode = MessageView.MODE_HTML
|
||||||
out = self.html.sanitised
|
out = self.html.sanitised
|
||||||
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unicode(
|
out = "<div align=\"center\" style=\"text-decoration: underline;\"><b>" + unic(ustr(
|
||||||
QtGui.QApplication.translate("MessageView", "Click here to disable HTML")) + "</b></div><br/>" + out
|
QtGui.QApplication.translate("MessageView", "Click here to disable HTML")) + "</b></div><br/>" + out)
|
||||||
self.out = out
|
self.out = out
|
||||||
self.outpos = 0
|
self.outpos = 0
|
||||||
self.setHtml("")
|
self.setHtml("")
|
||||||
|
|
|
@ -204,9 +204,9 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
|
||||||
if not connectionpool.pool.inboundConnections:
|
if not connectionpool.pool.inboundConnections:
|
||||||
self.window().setStatusIcon('yellow')
|
self.window().setStatusIcon('yellow')
|
||||||
for i in range(self.tableWidgetConnectionCount.rowCount()):
|
for i in range(self.tableWidgetConnectionCount.rowCount()):
|
||||||
if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.UserRole).toPyObject() != destination:
|
if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.UserRole) != destination:
|
||||||
continue
|
continue
|
||||||
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.UserRole).toPyObject() == outbound:
|
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.UserRole) == outbound:
|
||||||
self.tableWidgetConnectionCount.removeRow(i)
|
self.tableWidgetConnectionCount.removeRow(i)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ src/bitmessageqt/newchandialog.py
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import widgets
|
import widgets
|
||||||
|
@ -52,21 +53,21 @@ class NewChanDialog(QtGui.QDialog):
|
||||||
self.timer.stop()
|
self.timer.stop()
|
||||||
self.hide()
|
self.hide()
|
||||||
apiAddressGeneratorReturnQueue.queue.clear()
|
apiAddressGeneratorReturnQueue.queue.clear()
|
||||||
if self.chanAddress.text().toUtf8() == "":
|
if ustr(self.chanAddress.text()) == "":
|
||||||
addressGeneratorQueue.put(
|
addressGeneratorQueue.put(
|
||||||
('createChan', 4, 1, str_chan + ' ' + str(self.chanPassPhrase.text().toUtf8()),
|
('createChan', 4, 1, str_chan + ' ' + ustr(self.chanPassPhrase.text()),
|
||||||
self.chanPassPhrase.text().toUtf8(),
|
ustr(self.chanPassPhrase.text()),
|
||||||
True))
|
True))
|
||||||
else:
|
else:
|
||||||
addressGeneratorQueue.put(
|
addressGeneratorQueue.put(
|
||||||
('joinChan', addBMIfNotPresent(self.chanAddress.text().toUtf8()),
|
('joinChan', addBMIfNotPresent(ustr(self.chanAddress.text())),
|
||||||
str_chan + ' ' + str(self.chanPassPhrase.text().toUtf8()),
|
str_chan + ' ' + ustr(self.chanPassPhrase.text()),
|
||||||
self.chanPassPhrase.text().toUtf8(),
|
ustr(self.chanPassPhrase.text()),
|
||||||
True))
|
True))
|
||||||
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
|
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
|
||||||
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address':
|
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address':
|
||||||
UISignalQueue.put(('updateStatusBar', _translate(
|
UISignalQueue.put(('updateStatusBar', _translate(
|
||||||
"newchandialog", "Successfully created / joined chan {0}").format(unicode(self.chanPassPhrase.text()))))
|
"newchandialog", "Successfully created / joined chan {0}").format(unic(ustr(self.chanPassPhrase.text())))))
|
||||||
self.parent.ui.tabWidget.setCurrentIndex(
|
self.parent.ui.tabWidget.setCurrentIndex(
|
||||||
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans)
|
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from os import path
|
from os import path
|
||||||
|
from ver import ustr
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
from debug import logger
|
from debug import logger
|
||||||
import widgets
|
import widgets
|
||||||
|
@ -10,11 +11,11 @@ class RetranslateMixin(object):
|
||||||
for attr, value in defaults.__dict__.iteritems():
|
for attr, value in defaults.__dict__.iteritems():
|
||||||
setTextMethod = getattr(value, "setText", None)
|
setTextMethod = getattr(value, "setText", None)
|
||||||
if callable(setTextMethod):
|
if callable(setTextMethod):
|
||||||
getattr(self, attr).setText(getattr(defaults, attr).text())
|
getattr(self, attr).setText(ustr(getattr(defaults, attr).text()))
|
||||||
elif isinstance(value, QtGui.QTableWidget):
|
elif isinstance(value, QtGui.QTableWidget):
|
||||||
for i in range (value.columnCount()):
|
for i in range (value.columnCount()):
|
||||||
getattr(self, attr).horizontalHeaderItem(i).setText(
|
getattr(self, attr).horizontalHeaderItem(i).setText(
|
||||||
getattr(defaults, attr).horizontalHeaderItem(i).text())
|
ustr(getattr(defaults, attr).horizontalHeaderItem(i).text()))
|
||||||
for i in range (value.rowCount()):
|
for i in range (value.rowCount()):
|
||||||
getattr(self, attr).verticalHeaderItem(i).setText(
|
getattr(self, attr).verticalHeaderItem(i).setText(
|
||||||
getattr(defaults, attr).verticalHeaderItem(i).text())
|
ustr(getattr(defaults, attr).verticalHeaderItem(i).text()))
|
||||||
|
|
|
@ -7,6 +7,7 @@ from HTMLParser import HTMLParser
|
||||||
from urllib import quote_plus
|
from urllib import quote_plus
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
|
|
||||||
class SafeHTMLParser(HTMLParser):
|
class SafeHTMLParser(HTMLParser):
|
||||||
"""HTML parser with sanitisation"""
|
"""HTML parser with sanitisation"""
|
||||||
|
@ -123,10 +124,7 @@ class SafeHTMLParser(HTMLParser):
|
||||||
self.sanitised += "&" + name + ";"
|
self.sanitised += "&" + name + ";"
|
||||||
|
|
||||||
def feed(self, data):
|
def feed(self, data):
|
||||||
try:
|
data = unic(ustr(data))
|
||||||
data = unicode(data, 'utf-8')
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
data = unicode(data, 'utf-8', errors='replace')
|
|
||||||
HTMLParser.feed(self, data)
|
HTMLParser.feed(self, data)
|
||||||
tmp = SafeHTMLParser.replace_pre(data)
|
tmp = SafeHTMLParser.replace_pre(data)
|
||||||
tmp = self.uriregex1.sub(r'<a href="\1">\1</a>', tmp)
|
tmp = self.uriregex1.sub(r'<a href="\1">\1</a>', tmp)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
from ver import ustr
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import debug
|
import debug
|
||||||
|
@ -175,7 +176,7 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
else:
|
else:
|
||||||
if self.checkBoxOnionOnly.isChecked():
|
if self.checkBoxOnionOnly.isChecked():
|
||||||
self.checkBoxOnionOnly.setText(
|
self.checkBoxOnionOnly.setText(
|
||||||
self.checkBoxOnionOnly.text() + ", " + _translate(
|
ustr(self.checkBoxOnionOnly.text()) + ", " + _translate(
|
||||||
"MainWindow", "may cause connection problems!"))
|
"MainWindow", "may cause connection problems!"))
|
||||||
self.checkBoxOnionOnly.setStyleSheet(
|
self.checkBoxOnionOnly.setStyleSheet(
|
||||||
"QCheckBox { color : red; }")
|
"QCheckBox { color : red; }")
|
||||||
|
@ -312,10 +313,10 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
_translate("MainWindow", "Testing..."))
|
_translate("MainWindow", "Testing..."))
|
||||||
nc = namecoin.namecoinConnection({
|
nc = namecoin.namecoinConnection({
|
||||||
'type': self.getNamecoinType(),
|
'type': self.getNamecoinType(),
|
||||||
'host': str(self.lineEditNamecoinHost.text().toUtf8()),
|
'host': ustr(self.lineEditNamecoinHost.text()),
|
||||||
'port': str(self.lineEditNamecoinPort.text().toUtf8()),
|
'port': ustr(self.lineEditNamecoinPort.text()),
|
||||||
'user': str(self.lineEditNamecoinUser.text().toUtf8()),
|
'user': ustr(self.lineEditNamecoinUser.text()),
|
||||||
'password': str(self.lineEditNamecoinPassword.text().toUtf8())
|
'password': ustr(self.lineEditNamecoinPassword.text())
|
||||||
})
|
})
|
||||||
status, text = nc.test()
|
status, text = nc.test()
|
||||||
self.labelNamecoinTestResult.setText(text)
|
self.labelNamecoinTestResult.setText(text)
|
||||||
|
@ -349,7 +350,7 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.checkBoxReplyBelow.isChecked()))
|
self.checkBoxReplyBelow.isChecked()))
|
||||||
|
|
||||||
lang = str(self.languageComboBox.itemData(
|
lang = str(self.languageComboBox.itemData(
|
||||||
self.languageComboBox.currentIndex()).toString())
|
self.languageComboBox.currentIndex()))
|
||||||
self.config.set('bitmessagesettings', 'userlocale', lang)
|
self.config.set('bitmessagesettings', 'userlocale', lang)
|
||||||
self.parent.change_translation()
|
self.parent.change_translation()
|
||||||
|
|
||||||
|
@ -448,13 +449,13 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
self.config.set(
|
self.config.set(
|
||||||
'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType())
|
'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType())
|
||||||
self.config.set('bitmessagesettings', 'namecoinrpchost', str(
|
self.config.set('bitmessagesettings', 'namecoinrpchost', ustr(
|
||||||
self.lineEditNamecoinHost.text()))
|
self.lineEditNamecoinHost.text()))
|
||||||
self.config.set('bitmessagesettings', 'namecoinrpcport', str(
|
self.config.set('bitmessagesettings', 'namecoinrpcport', ustr(
|
||||||
self.lineEditNamecoinPort.text()))
|
self.lineEditNamecoinPort.text()))
|
||||||
self.config.set('bitmessagesettings', 'namecoinrpcuser', str(
|
self.config.set('bitmessagesettings', 'namecoinrpcuser', ustr(
|
||||||
self.lineEditNamecoinUser.text()))
|
self.lineEditNamecoinUser.text()))
|
||||||
self.config.set('bitmessagesettings', 'namecoinrpcpassword', str(
|
self.config.set('bitmessagesettings', 'namecoinrpcpassword', ustr(
|
||||||
self.lineEditNamecoinPassword.text()))
|
self.lineEditNamecoinPassword.text()))
|
||||||
self.parent.resetNamecoinConnection()
|
self.parent.resetNamecoinConnection()
|
||||||
|
|
||||||
|
@ -472,11 +473,11 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
float(self.lineEditSmallMessageDifficulty.text())
|
float(self.lineEditSmallMessageDifficulty.text())
|
||||||
* defaults.networkDefaultPayloadLengthExtraBytes)))
|
* defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||||
|
|
||||||
if self.comboBoxOpenCL.currentText().toUtf8() != self.config.safeGet(
|
if ustr(self.comboBoxOpenCL.currentText()) != ustr(self.config.safeGet(
|
||||||
'bitmessagesettings', 'opencl'):
|
'bitmessagesettings', 'opencl')):
|
||||||
self.config.set(
|
self.config.set(
|
||||||
'bitmessagesettings', 'opencl',
|
'bitmessagesettings', 'opencl',
|
||||||
str(self.comboBoxOpenCL.currentText()))
|
ustr(self.comboBoxOpenCL.currentText()))
|
||||||
queues.workerQueue.put(('resetPoW', ''))
|
queues.workerQueue.put(('resetPoW', ''))
|
||||||
|
|
||||||
acceptableDifficultyChanged = False
|
acceptableDifficultyChanged = False
|
||||||
|
|
|
@ -5,6 +5,7 @@ src/settingsmixin.py
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from ver import ustr
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ class SettingsMixin(object):
|
||||||
self.warnIfNoObjectName()
|
self.warnIfNoObjectName()
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
try:
|
try:
|
||||||
geom = settings.value("/".join([str(self.objectName()), "geometry"]))
|
geom = settings.value("/".join([ustr(self.objectName()), "geometry"]))
|
||||||
target.restoreGeometry(geom.toByteArray() if hasattr(geom, 'toByteArray') else geom)
|
target.restoreGeometry(geom.toByteArray() if hasattr(geom, 'toByteArray') else geom)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
@ -50,7 +51,7 @@ class SettingsMixin(object):
|
||||||
self.warnIfNoObjectName()
|
self.warnIfNoObjectName()
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
try:
|
try:
|
||||||
state = settings.value("/".join([str(self.objectName()), "state"]))
|
state = settings.value("/".join([ustr(self.objectName()), "state"]))
|
||||||
target.restoreState(state.toByteArray() if hasattr(state, 'toByteArray') else state)
|
target.restoreState(state.toByteArray() if hasattr(state, 'toByteArray') else state)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -6,6 +6,7 @@ import ssl
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from ver import ustr, unic
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
import account
|
import account
|
||||||
|
@ -72,7 +73,7 @@ def checkAddressBook(myapp):
|
||||||
if queryreturn == []:
|
if queryreturn == []:
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'INSERT INTO addressbook VALUES (?,?)',
|
'INSERT INTO addressbook VALUES (?,?)',
|
||||||
SUPPORT_LABEL.toUtf8(), SUPPORT_ADDRESS)
|
ustr(SUPPORT_LABEL), SUPPORT_ADDRESS)
|
||||||
myapp.rerenderAddressBook()
|
myapp.rerenderAddressBook()
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ def createAddressIfNeeded(myapp):
|
||||||
if not checkHasNormalAddress():
|
if not checkHasNormalAddress():
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
'createRandomAddress', 4, 1,
|
'createRandomAddress', 4, 1,
|
||||||
str(SUPPORT_MY_LABEL.toUtf8()),
|
ustr(SUPPORT_MY_LABEL),
|
||||||
1, "", False,
|
1, "", False,
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||||
defaults.networkDefaultPayloadLengthExtraBytes
|
defaults.networkDefaultPayloadLengthExtraBytes
|
||||||
|
@ -122,7 +123,7 @@ def createSupportMessage(myapp):
|
||||||
os = sys.platform
|
os = sys.platform
|
||||||
if os == "win32":
|
if os == "win32":
|
||||||
windowsversion = sys.getwindowsversion()
|
windowsversion = sys.getwindowsversion()
|
||||||
os = "Windows " + str(windowsversion[0]) + "." + str(windowsversion[1])
|
os = "Windows " + ustr(windowsversion[0]) + "." + ustr(windowsversion[1])
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
from os import uname
|
from os import uname
|
||||||
|
@ -141,7 +142,7 @@ def createSupportMessage(myapp):
|
||||||
frozen = paths.frozen
|
frozen = paths.frozen
|
||||||
portablemode = "True" if state.appdata == paths.lookupExeFolder() else "False"
|
portablemode = "True" if state.appdata == paths.lookupExeFolder() else "False"
|
||||||
cpow = "True" if proofofwork.bmpow else "False"
|
cpow = "True" if proofofwork.bmpow else "False"
|
||||||
openclpow = str(
|
openclpow = ustr(
|
||||||
config.safeGet('bitmessagesettings', 'opencl')
|
config.safeGet('bitmessagesettings', 'opencl')
|
||||||
) if openclEnabled() else "None"
|
) if openclEnabled() else "None"
|
||||||
locale = getTranslationLanguage()
|
locale = getTranslationLanguage()
|
||||||
|
@ -149,9 +150,9 @@ def createSupportMessage(myapp):
|
||||||
upnp = config.safeGet('bitmessagesettings', 'upnp', "N/A")
|
upnp = config.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.ui.textEditMessage.setText(unic(ustr(SUPPORT_MESSAGE).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.ui.tabWidgetSend.setCurrentIndex(
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestMain(unittest.TestCase):
|
||||||
"""Check the results of _translate() with various args"""
|
"""Check the results of _translate() with various args"""
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
_translate("MainWindow", "Test"),
|
_translate("MainWindow", "Test"),
|
||||||
QtCore.QString
|
str
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ from shared import isAddressInMyAddressBook
|
||||||
|
|
||||||
from main import TestBase
|
from main import TestBase
|
||||||
|
|
||||||
|
from ver import ustr
|
||||||
|
|
||||||
|
|
||||||
class TestSupport(TestBase):
|
class TestSupport(TestBase):
|
||||||
"""A test case for support module"""
|
"""A test case for support module"""
|
||||||
|
@ -26,8 +28,8 @@ class TestSupport(TestBase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
ui.tabWidget.currentIndex(), ui.tabWidget.indexOf(ui.send))
|
ui.tabWidget.currentIndex(), ui.tabWidget.indexOf(ui.send))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
ui.lineEditTo.text(), self.SUPPORT_ADDRESS)
|
ustr(ui.lineEditTo.text()), ustr(self.SUPPORT_ADDRESS))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
ui.lineEditSubject.text(), self.SUPPORT_SUBJECT)
|
ustr(ui.lineEditSubject.text()), ustr(self.SUPPORT_SUBJECT))
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
sys.version, ui.textEditMessage.toPlainText())
|
sys.version, ui.textEditMessage.toPlainText())
|
||||||
|
|
|
@ -383,6 +383,15 @@ def check_pyqt():
|
||||||
Here we are checking for PyQt4 with its version, as for it require
|
Here we are checking for PyQt4 with its version, as for it require
|
||||||
PyQt 4.8 or later.
|
PyQt 4.8 or later.
|
||||||
"""
|
"""
|
||||||
|
sip_found = False
|
||||||
|
try:
|
||||||
|
import sip
|
||||||
|
sip.setapi("QString", 2)
|
||||||
|
sip.setapi("QVariant", 2)
|
||||||
|
sip_found = True
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
QtCore = try_import(
|
QtCore = try_import(
|
||||||
'PyQt4.QtCore', 'PyBitmessage requires PyQt 4.8 or later and Qt 4.7 or later.')
|
'PyQt4.QtCore', 'PyBitmessage requires PyQt 4.8 or later and Qt 4.7 or later.')
|
||||||
|
|
||||||
|
@ -402,6 +411,11 @@ def check_pyqt():
|
||||||
'This version of Qt is too old. PyBitmessage requries'
|
'This version of Qt is too old. PyBitmessage requries'
|
||||||
' Qt 4.7 or later.')
|
' Qt 4.7 or later.')
|
||||||
passed = False
|
passed = False
|
||||||
|
|
||||||
|
if passed and not sip_found:
|
||||||
|
logger.info("sip is not found although PyQt is found")
|
||||||
|
return False
|
||||||
|
|
||||||
return passed
|
return passed
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ Translating text
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from ver import ustr
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import state
|
import state
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -30,7 +32,7 @@ class translateClass:
|
||||||
|
|
||||||
def _translate(context, text, disambiguation=None, encoding=None, n=None):
|
def _translate(context, text, disambiguation=None, encoding=None, n=None):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
return translateText(context, text, n)
|
return ustr(translateText(context, text, n))
|
||||||
|
|
||||||
|
|
||||||
def translateText(context, text, n=None):
|
def translateText(context, text, n=None):
|
||||||
|
|
30
src/ver.py
Normal file
30
src/ver.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if not hasattr(sys, "hexversion"):
|
||||||
|
sys.exit("Python version: {0}\n"
|
||||||
|
"PyBitmessage requires Python 2.7.4 or greater"
|
||||||
|
.format(sys.version))
|
||||||
|
|
||||||
|
if sys.hexversion < 0x3000000:
|
||||||
|
VER = 2
|
||||||
|
else:
|
||||||
|
VER = 3
|
||||||
|
|
||||||
|
def ustr(v):
|
||||||
|
if VER == 3:
|
||||||
|
if isinstance(v, str):
|
||||||
|
return v
|
||||||
|
else:
|
||||||
|
return str(v)
|
||||||
|
# assume VER == 2
|
||||||
|
if isinstance(v, unicode):
|
||||||
|
return v.encode("utf-8", "replace")
|
||||||
|
return str(v)
|
||||||
|
|
||||||
|
def unic(v):
|
||||||
|
if VER == 3:
|
||||||
|
return v
|
||||||
|
# assume VER == 2
|
||||||
|
if isinstance(v, unicode):
|
||||||
|
return v
|
||||||
|
return unicode(v, "utf-8", "replace")
|
Reference in New Issue
Block a user