[Linux] added private posts and posting of images
This commit is contained in:
parent
3995beaf6d
commit
1eeaf78a63
9 changed files with 61 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ dsa_priv.pem
|
|||
*.pyc
|
||||
Mac/.DS_Store
|
||||
build
|
||||
.DS_Store
|
||||
|
|
|
@ -53,6 +53,7 @@ class WebViewCreator(QtWebKit.QWebView):
|
|||
if callback:
|
||||
callback(ok)
|
||||
|
||||
|
||||
class NetworkAccessManager(QNetworkAccessManager):
|
||||
|
||||
def __init__(self, old_manager, tentia_callback):
|
||||
|
@ -81,4 +82,5 @@ class PostModel:
|
|||
self.inReplyToEntity = None
|
||||
self.location = None
|
||||
self.imageFilePath = None
|
||||
self.isPrivate = False
|
||||
self.isPrivate = False
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
import os, sys, pickle
|
||||
import os, sys, pickle, subprocess
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
import Windows, Helper
|
||||
|
||||
|
@ -108,6 +108,7 @@ class Controller(QtCore.QObject):
|
|||
self.app.timeline.set_window_title("Tentia (^" + str(i) + ")")
|
||||
else:
|
||||
self.app.timeline.set_window_title("Tentia")
|
||||
self.app.mentions.evaluateJavaScript("tentia_instance.unread_mentions = 0;")
|
||||
|
||||
@QtCore.pyqtSlot(str, str, str, str)
|
||||
def notificateUserAboutMention(self, text, name, post_id, entity):
|
||||
|
@ -148,7 +149,11 @@ class Controller(QtCore.QObject):
|
|||
#}
|
||||
|
||||
imageFilePath = "null"
|
||||
#if (post.imageFilePath) {
|
||||
if message.imageFilePath is not None:
|
||||
mimeType = subprocess.check_output(['file', '-b', '--mime', message.imageFilePath]).split(";")[0]
|
||||
base64 = open(message.imageFilePath, "rb").read().encode("base64").replace("\n", "")
|
||||
imageFilePath = "\"data:{};base64,{}\"".format(mimeType, base64)
|
||||
|
||||
# NSError *error;
|
||||
# NSString *mimeType = [MimeType mimeTypeForFileAtPath:post.imageFilePath error:&error];
|
||||
# NSData *data = [[NSData alloc] initWithContentsOfFile:post.imageFilePath];
|
||||
|
@ -162,6 +167,7 @@ class Controller(QtCore.QObject):
|
|||
isPrivate = "true"
|
||||
|
||||
func = "tentia_instance.sendNewMessage(\"{}\", \"{}\", \"{}\", {}, {}, {});".format(text, in_reply_to_status_id, in_reply_to_entity, locationObject, imageFilePath, isPrivate)
|
||||
print func
|
||||
self.app.timeline.evaluateJavaScript(func)
|
||||
|
||||
@QtCore.pyqtSlot(str, str)
|
||||
|
|
|
@ -15,12 +15,14 @@ class Preferences:
|
|||
self.window.setMaximumSize(480, 186)
|
||||
|
||||
# image view
|
||||
image = QtGui.QPixmap(self.app.resources_path() + "/Icon.png")
|
||||
image = QtGui.QPixmap(self.app.resources_path() + "/images/Icon.png")
|
||||
image_view = QtGui.QLabel(self.window)
|
||||
image_view.setGeometry(20, 20, 146, 146)
|
||||
image_view.setPixmap(image)
|
||||
image_view.setScaledContents(True)
|
||||
|
||||
self.window.setWindowIcon(QtGui.QIcon(image))
|
||||
|
||||
# info text
|
||||
info_text = QtGui.QLabel(self.window)
|
||||
info_text.setGeometry(194, 60, 262, 17)
|
||||
|
@ -71,6 +73,7 @@ class Preferences:
|
|||
else:
|
||||
self.activity_indicator.hide()
|
||||
|
||||
|
||||
class Timeline:
|
||||
|
||||
def __init__(self, app, action="timeline", title="Tentia"):
|
||||
|
@ -102,6 +105,8 @@ class Timeline:
|
|||
# self.window.addWidget(self.webView)
|
||||
self.initUI()
|
||||
|
||||
self.window.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png"))
|
||||
|
||||
def moveWindow(self, x=0, y=0):
|
||||
self.show()
|
||||
geo = self.window.geometry()
|
||||
|
@ -247,6 +252,8 @@ class NewPost(QtGui.QMainWindow):
|
|||
self.app = app
|
||||
QtGui.QPlainTextEdit.__init__(self)
|
||||
|
||||
self.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png"))
|
||||
|
||||
self.textInput = QtGui.QPlainTextEdit(self)
|
||||
self.setCentralWidget(self.textInput)
|
||||
self.textInput.textChanged.connect(self.onChanged)
|
||||
|
@ -256,9 +263,10 @@ class NewPost(QtGui.QMainWindow):
|
|||
self.setMinimumSize(100, 100)
|
||||
self.initUI()
|
||||
|
||||
self.isPrivate = False
|
||||
self.setIsPrivate(False)
|
||||
self.status_id = None
|
||||
self.reply_to_entity = None
|
||||
self.imageFilePath = None
|
||||
|
||||
def initUI(self):
|
||||
newPostAction = QtGui.QAction("&New Post", self)
|
||||
|
@ -271,12 +279,33 @@ class NewPost(QtGui.QMainWindow):
|
|||
sendPostAction.setStatusTip("Send post")
|
||||
sendPostAction.triggered.connect(self.sendMessage)
|
||||
|
||||
exitAction = QtGui.QAction("&Exit", self)
|
||||
exitAction.setShortcut("Ctrl+Q")
|
||||
exitAction.setStatusTip("Exit Tentia")
|
||||
exitAction.triggered.connect(QtGui.qApp.quit)
|
||||
|
||||
self.statusBar().showMessage('256')
|
||||
|
||||
self.addButton = QtGui.QToolButton()
|
||||
self.addButton.clicked.connect(self.openFileDialog)
|
||||
self.addButton.setAutoRaise(True)
|
||||
addIcon = QtGui.QIcon.fromTheme("insert-image", QtGui.QIcon(self.app.resources_path() + "/images/Actions-insert-image-icon.png"));
|
||||
self.addButton.setIcon(addIcon)
|
||||
self.statusBar().addPermanentWidget(self.addButton)
|
||||
|
||||
self.isPrivateButton = QtGui.QToolButton()
|
||||
self.isPrivateButton.clicked.connect(self.toggleIsPrivate)
|
||||
self.isPrivateButton.setAutoRaise(True)
|
||||
self.isPrivateIcon = QtGui.QIcon.fromTheme("mail-unread", QtGui.QIcon(self.app.resources_path() + "/images/Lock-Lock-icon.png"))
|
||||
self.isNotPrivateIcon = QtGui.QIcon.fromTheme("mail-signet-verified", QtGui.QIcon(self.app.resources_path() + "/images/Lock-Unlock-icon.png"))
|
||||
self.isPrivateButton.setIcon(self.isNotPrivateIcon)
|
||||
self.statusBar().addPermanentWidget(self.isPrivateButton)
|
||||
|
||||
menubar = self.menuBar()
|
||||
fileMenu = menubar.addMenu("&File")
|
||||
fileMenu.addAction(newPostAction)
|
||||
fileMenu.addAction(sendPostAction)
|
||||
fileMenu.addAction(exitAction)
|
||||
|
||||
timelineAction = QtGui.QAction("&Timeline", self)
|
||||
timelineAction.setShortcut("Ctrl+1")
|
||||
|
@ -300,9 +329,14 @@ class NewPost(QtGui.QMainWindow):
|
|||
|
||||
def setIsPrivate(self, is_private):
|
||||
self.isPrivate = is_private
|
||||
icon = self.isNotPrivateIcon
|
||||
if self.isPrivate:
|
||||
icon = self.isPrivateIcon
|
||||
|
||||
def toggle_is_private(self):
|
||||
self.isPrivate = not self.isPrivate
|
||||
self.isPrivateButton.setIcon(icon)
|
||||
|
||||
def toggleIsPrivate(self):
|
||||
self.setIsPrivate(not self.isPrivate)
|
||||
|
||||
def inReplyToStatusIdWithString(self, reply_to, status_id, string):
|
||||
self.reply_to_entity = reply_to
|
||||
|
@ -325,9 +359,19 @@ class NewPost(QtGui.QMainWindow):
|
|||
message.inReplyTostatusId = self.status_id
|
||||
message.inReplyToEntity = self.reply_to_entity
|
||||
message.location = None
|
||||
message.imageFilePath = None
|
||||
message.imageFilePath = self.imageFilePath
|
||||
message.isPrivate = self.isPrivate
|
||||
self.app.controller.sendMessage(message)
|
||||
self.close()
|
||||
else:
|
||||
QtGui.qApp.beep()
|
||||
|
||||
def openFileDialog(self):
|
||||
fileNamePath = QtGui.QFileDialog.getOpenFileName(self, "Choose a image", "", "Images (*.png *.gif *.jpg *.jpeg)")
|
||||
if len(fileNamePath) > 0:
|
||||
self.imageFilePath = str(fileNamePath)
|
||||
else:
|
||||
self.imageFilePath = None
|
||||
|
||||
|
||||
|
||||
|
|
BIN
images/Actions-insert-image-icon.png
Normal file
BIN
images/Actions-insert-image-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 719 B |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
BIN
images/Lock-Lock-icon.png
Normal file
BIN
images/Lock-Lock-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 617 B |
BIN
images/Lock-Unlock-icon.png
Normal file
BIN
images/Lock-Unlock-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 516 B |
Reference in a new issue