Add "Attach File" button to message composition.
This commit is contained in:
parent
32bb2a6e44
commit
186139654c
|
@ -11,6 +11,7 @@ import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import base64
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from sqlite3 import register_adapter
|
from sqlite3 import register_adapter
|
||||||
|
|
||||||
|
@ -161,6 +162,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
"clicked()"), self.click_pushButtonTTL)
|
"clicked()"), self.click_pushButtonTTL)
|
||||||
QtCore.QObject.connect(self.ui.pushButtonClear, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.ui.pushButtonClear, QtCore.SIGNAL(
|
||||||
"clicked()"), self.click_pushButtonClear)
|
"clicked()"), self.click_pushButtonClear)
|
||||||
|
QtCore.QObject.connect(self.ui.pushButtonAttach, QtCore.SIGNAL(
|
||||||
|
"clicked()"), self.click_pushButtonAttach)
|
||||||
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.ui.pushButtonSend, QtCore.SIGNAL(
|
||||||
"clicked()"), self.click_pushButtonSend)
|
"clicked()"), self.click_pushButtonSend)
|
||||||
QtCore.QObject.connect(self.ui.pushButtonFetchNamecoinID, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.ui.pushButtonFetchNamecoinID, QtCore.SIGNAL(
|
||||||
|
@ -1951,6 +1954,21 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.ui.textEditMessage.reset()
|
self.ui.textEditMessage.reset()
|
||||||
self.ui.comboBoxSendFrom.setCurrentIndex(0)
|
self.ui.comboBoxSendFrom.setCurrentIndex(0)
|
||||||
|
|
||||||
|
def click_pushButtonAttach(self):
|
||||||
|
filename = QtGui.QFileDialog.getOpenFileName(self, "Attach File")
|
||||||
|
if filename:
|
||||||
|
f = open(filename, 'rb')
|
||||||
|
data = f.read()
|
||||||
|
f.close()
|
||||||
|
data_b64 = base64.b64encode(data)
|
||||||
|
html_data = '<a href="data:application/octet-stream;base64,' + data_b64 + '">' + os.path.basename(unicode(filename)) + '</a>'
|
||||||
|
if self.ui.tabWidgetSend.currentIndex() == self.ui.tabWidgetSend.indexOf(self.ui.sendDirect):
|
||||||
|
#send direct message
|
||||||
|
self.ui.textEditMessage.insertPlainText(html_data)
|
||||||
|
else:
|
||||||
|
#send broadcast message
|
||||||
|
self.ui.textEditMessageBroadcast.insertPlainText(html_data)
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
@ -340,6 +340,9 @@ class Ui_MainWindow(object):
|
||||||
self.pushButtonClear = QtGui.QPushButton(self.send)
|
self.pushButtonClear = QtGui.QPushButton(self.send)
|
||||||
self.pushButtonClear.setObjectName(_fromUtf8("pushButtonClear"))
|
self.pushButtonClear.setObjectName(_fromUtf8("pushButtonClear"))
|
||||||
self.horizontalLayout_5.addWidget(self.pushButtonClear, 0, QtCore.Qt.AlignRight)
|
self.horizontalLayout_5.addWidget(self.pushButtonClear, 0, QtCore.Qt.AlignRight)
|
||||||
|
self.pushButtonAttach = QtGui.QPushButton(self.send)
|
||||||
|
self.pushButtonAttach.setObjectName(_fromUtf8("pushButtonAttach"))
|
||||||
|
self.horizontalLayout_5.addWidget(self.pushButtonAttach, 0, QtCore.Qt.AlignRight)
|
||||||
self.pushButtonSend = QtGui.QPushButton(self.send)
|
self.pushButtonSend = QtGui.QPushButton(self.send)
|
||||||
self.pushButtonSend.setObjectName(_fromUtf8("pushButtonSend"))
|
self.pushButtonSend.setObjectName(_fromUtf8("pushButtonSend"))
|
||||||
self.horizontalLayout_5.addWidget(self.pushButtonSend, 0, QtCore.Qt.AlignRight)
|
self.horizontalLayout_5.addWidget(self.pushButtonSend, 0, QtCore.Qt.AlignRight)
|
||||||
|
@ -713,6 +716,7 @@ class Ui_MainWindow(object):
|
||||||
pass
|
pass
|
||||||
self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, hours))
|
self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, hours))
|
||||||
self.pushButtonClear.setText(_translate("MainWindow", "Clear", None))
|
self.pushButtonClear.setText(_translate("MainWindow", "Clear", None))
|
||||||
|
self.pushButtonAttach.setText(_translate("MainWindow", "Attach File", None))
|
||||||
self.pushButtonSend.setText(_translate("MainWindow", "Send", None))
|
self.pushButtonSend.setText(_translate("MainWindow", "Send", None))
|
||||||
self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send", None))
|
self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send", None))
|
||||||
self.treeWidgetSubscriptions.headerItem().setText(0, _translate("MainWindow", "Subscriptions", None))
|
self.treeWidgetSubscriptions.headerItem().setText(0, _translate("MainWindow", "Subscriptions", None))
|
||||||
|
|
|
@ -594,6 +594,19 @@ p, li { white-space: pre-wrap; }
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonAttach">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attach File</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Reference in New Issue
Block a user