From 1eeaf78a6353f9d173bb7e0f8648a0814d41cbd5 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Sun, 30 Dec 2012 02:48:22 +0100 Subject: [PATCH] [Linux] added private posts and posting of images --- .gitignore | 1 + Linux/Helper.py | 4 +- Linux/Tentia.py | 10 ++++- Linux/Windows.py | 54 ++++++++++++++++++++++++--- images/Actions-insert-image-icon.png | Bin 0 -> 719 bytes Icon.png => images/Icon.png | Bin Icon.psd => images/Icon.psd | Bin images/Lock-Lock-icon.png | Bin 0 -> 617 bytes images/Lock-Unlock-icon.png | Bin 0 -> 516 bytes 9 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 images/Actions-insert-image-icon.png rename Icon.png => images/Icon.png (100%) rename Icon.psd => images/Icon.psd (100%) create mode 100644 images/Lock-Lock-icon.png create mode 100644 images/Lock-Unlock-icon.png 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 0000000000000000000000000000000000000000..05adf9a3a8d6086c45f829db6e8773dfffc4ea92 GIT binary patch literal 719 zcmV;=0xMg_SxC-9mL_ z7CbL@<^XARS2Ew6LO|dMT>@|-kW2$<Jf#;%Wr5NG16&cHs|hJJSqURk3eTA))Hk07ll%fm9{@d*n?f_G z(IhPhWU)Z~WBmY-RAj05d?Q2;gKRd7K!8V}oC9xU@Iz&>tFzDvz_V^Ta0Q=VO~5M% zd4Md-Qs_hje4+={0UH&520O9?Rp;P146Lk8U>i2WQnQs)bK~2NLw_L;P!vUKZEZ!s zFW}Q(whe)lhV144wRK}Xm8dC zU}1IL!KY0JmLtIH^&%RLB6zC`0?(mlt0~^q)pf%#jODxr1PF)2wCSL|MMF)6jrZ#u zHomhEODfRa-Hk{jf~nLvN_{-8nte-}rcI^Q^n?qDkSGi8n6B$whvnQ?bRosVmqXax zTSsGE9ZkbwFTICg;5Z(&KY8Gu2$C30e=~b57Q40*Tpm{TchPXn4^d?Cb!Qtbbtf@- zWp;?c5ivM8D2$Gd-sd>(dfU@rXJxGq3%wr~9UCvEXQrPY2`ENFPQ;=!m&P+>_16Q7 z!}O`oiVpv$7#kZC`tSDNBMUHd^K%n@clr#s{u>y;1lNxcc3}Vj002ovPDHLkV1ipg BIuQT> literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..45079c95fa9bfdc8567df3cc7a3799237ea774f8 GIT binary patch literal 617 zcmV-v0+#)WP)jA)vL1%-rnRM#|^1P2E)aB*>g z6@2~njbZKD^$cw-4QJlHd+PxddW+Qn4i3&u(`PUA)z;BsShajP!Wwt6*$xsQa~d_qG(E*b1mzgtMF1oa*`}w!W^; z|64Y$)(47RMmHd%tfpnUhNc!na!km)|Ns9bqxhAPY3_^#E0P{PxW~|1Uy%tEnt^UW zaamn^kBpQgLtaKg1CZZ{7C!a0ZT$_rT$~JL1sNqkelM~CwyH`D3z9P8lyo)K7@8Yu z-T=kkpcx<%7Mm)fAS1z0QPzC#_C1CKpx9xs0ir?-JDwe7aA#p+APW5X$G{+E&9L+J zI|dK10rHXz`yZ@haA5dPoB<$rD+Dndc=(*b5n_M@(17JY1JJ;CW(dvs7t;)dNT2~P zU#L4)5Lh0d5JOL)#tyT&p!H{1qxpPE4RQAh7k8F00000NkvXXu0mjf DAxspF literal 0 HcmV?d00001 diff --git a/images/Lock-Unlock-icon.png b/images/Lock-Unlock-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..627d59fb3bd8f0a6408885708c7f6c9262b7d8e4 GIT binary patch literal 516 zcmV+f0{i`mP)5o7R{9 z|NnmqAp@ccORAQJhJ`Y$S+$bk*|Vn%a`Flc!6Bgx^XJa}KV#a&0K5js$jV=sy>PjH zO?lDlv!_o40EI3Av5AeH)B39VW`X#~;3IeqFt@h5y&loi8HgX%vri- zTXJV}?K_YGHb5MNEj$cOtqY1v%Nb(A{7wV8?LfR99B_<`lNYYqoHMbj^#h}eHN)dA za~Ncpn6N|PP|(EiXWCK*5uor#AZ}Gs)l7Q%{OL!=crS+c3#x(9^B;d` zb}VCHsGP)rV&d`if+ zVFL|ozx`Z(>IWzmzMvQY#9Bb?!9X})90%fK7*WkYApig+HkNwzjQ>CY0000