diff --git a/.gitignore b/.gitignore index fde9fb2..6c97669 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dsa_priv.pem *.pyc Mac/.DS_Store build +.DS_Store diff --git a/Linux/Helper.py b/Linux/Helper.py index 54c5df8..59940b7 100644 --- a/Linux/Helper.py +++ b/Linux/Helper.py @@ -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 \ No newline at end of file + self.isPrivate = False + diff --git a/Linux/Tentia.py b/Linux/Tentia.py index c8fff1d..88329e5 100755 --- a/Linux/Tentia.py +++ b/Linux/Tentia.py @@ -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) diff --git a/Linux/Windows.py b/Linux/Windows.py index 681592a..b9c3324 100644 --- a/Linux/Windows.py +++ b/Linux/Windows.py @@ -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 + + + diff --git a/images/Actions-insert-image-icon.png b/images/Actions-insert-image-icon.png new file mode 100644 index 0000000..05adf9a Binary files /dev/null and b/images/Actions-insert-image-icon.png differ diff --git a/Icon.png b/images/Icon.png similarity index 100% rename from Icon.png rename to images/Icon.png diff --git a/Icon.psd b/images/Icon.psd similarity index 100% rename from Icon.psd rename to images/Icon.psd diff --git a/images/Lock-Lock-icon.png b/images/Lock-Lock-icon.png new file mode 100644 index 0000000..45079c9 Binary files /dev/null and b/images/Lock-Lock-icon.png differ diff --git a/images/Lock-Unlock-icon.png b/images/Lock-Unlock-icon.png new file mode 100644 index 0000000..627d59f Binary files /dev/null and b/images/Lock-Unlock-icon.png differ