From 65883892f9fbc93d98887bc1a5d38531844bee61 Mon Sep 17 00:00:00 2001 From: Jeena Date: Sun, 30 Dec 2012 05:41:53 +0100 Subject: [PATCH 1/4] [Linux] calling notification center on new mention --- .gitignore | 1 + Linux/Tentia.py | 12 +++++++++--- WebKit/scripts/helper/HostApp.js | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6c97669..6b81198 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dsa_priv.pem Mac/.DS_Store build .DS_Store +*~ diff --git a/Linux/Tentia.py b/Linux/Tentia.py index 9bd9d51..62ffac4 100755 --- a/Linux/Tentia.py +++ b/Linux/Tentia.py @@ -14,7 +14,7 @@ class Tentia: self.preferences = Windows.Preferences(self) self.preferences.show() - self.oauth_implementation = Windows.Oauth(self) + self.oauth_implementation = Windows.Oauth(self) if self.controller.stringForKey("user_access_token") != "": self.authentification_succeded() @@ -111,8 +111,14 @@ class Controller(QtCore.QObject): self.app.mentions.evaluateJavaScript("tentia_instance.unread_mentions = 0;") @QtCore.pyqtSlot(str, str, str, str) - def notificateUserAboutMention(self, text, name, post_id, entity): - print "notificateUserAboutMention is not implemented yet" + def notificateUserAboutMentionFromNameWithPostIdAndEntity(self, text, name, post_id, entity): + try: + subprocess.check_output(['kdialog', '--passivepopup', name + ' mentioned you: ' + text]) + except OSError: + try: + subprocess.check_output(['notify-send', '-i', 'dialog-information', name + 'mentioned you on Tent', text]) + except OSError: + pass @QtCore.pyqtSlot(str) def openNewMessageWidow(self, string): diff --git a/WebKit/scripts/helper/HostApp.js b/WebKit/scripts/helper/HostApp.js index 29358cf..8d6ff45 100644 --- a/WebKit/scripts/helper/HostApp.js +++ b/WebKit/scripts/helper/HostApp.js @@ -107,7 +107,9 @@ define(function() { HostApp.notificateUserAboutMention = function(text, name, post_id, entity) { if (OS_TYPE == "mac") { controller.notificateUserAboutMention_fromName_withPostId_andEntity_(text, name, post_id, entity); - } + } else { + controller.notificateUserAboutMentionFromNameWithPostIdAndEntity(text, name, post_id, entity); + } } HostApp.alertTitleWithMessage = function(title, message) { From 7e44a54bfbde26fe3ca627dde43815691f204d1e Mon Sep 17 00:00:00 2001 From: Jeena Date: Sun, 30 Dec 2012 17:05:20 +0100 Subject: [PATCH 2/4] fixed typo --- Linux/Tentia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux/Tentia.py b/Linux/Tentia.py index 62ffac4..7fe5f2b 100755 --- a/Linux/Tentia.py +++ b/Linux/Tentia.py @@ -116,7 +116,7 @@ class Controller(QtCore.QObject): subprocess.check_output(['kdialog', '--passivepopup', name + ' mentioned you: ' + text]) except OSError: try: - subprocess.check_output(['notify-send', '-i', 'dialog-information', name + 'mentioned you on Tent', text]) + subprocess.check_output(['notify-send', '-i', 'dialog-information', name + ' mentioned you on Tent', text]) except OSError: pass From b0e550c6d1bc11443aa5d71047ec293ce7da94c2 Mon Sep 17 00:00:00 2001 From: Jeena Date: Sun, 30 Dec 2012 22:19:03 +0100 Subject: [PATCH 3/4] now saving the position of the windows --- Linux/Helper.py | 29 +++++++++++++++++++++++++++++ Linux/Windows.py | 24 ++++-------------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Linux/Helper.py b/Linux/Helper.py index 59940b7..73dc912 100644 --- a/Linux/Helper.py +++ b/Linux/Helper.py @@ -5,6 +5,8 @@ from PyQt4.QtGui import * from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply from PyQt4.QtWebKit import QWebView +import array + class WebPage(QtWebKit.QWebPage): def __init__(self, parent=0, app=None): super(QtWebKit.QWebPage, self).__init__(parent) @@ -84,3 +86,30 @@ class PostModel: self.imageFilePath = None self.isPrivate = False +class RestorableWindow(QtGui.QMainWindow): + + def __init__(self, action, app): + self.action = action + self.app = app + QtGui.QMainWindow.__init__(self) + self.restoreGeometry(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowGeometry-" + self.action))) + self.restoreState(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowState-" + self.action))) + + def closeEvent(self, event): + self._saveGeometry() + + def _saveGeometry(self): + self.app.controller.setStringForKey(self.saveGeometry(), "mainWindowGeometry-" + self.action) + self.app.controller.setStringForKey(self.saveState(), "mainWindowState-" + self.action) + + def hide(self): + self._saveGeometry() + QtGui.QMainWindow.hide(self) + + def sizeHint(self): + return QtCore.QSize(300, 500) + + def show(self): + QtGui.QMainWindow.show(self) + self.activateWindow() + self.raise_() \ No newline at end of file diff --git a/Linux/Windows.py b/Linux/Windows.py index e7831e7..3e47163 100644 --- a/Linux/Windows.py +++ b/Linux/Windows.py @@ -81,32 +81,16 @@ class Timeline: self.action = action self.title = title - self.window = QtGui.QMainWindow() - + self.window = Helper.RestorableWindow(action, self.app) self.window.setWindowTitle(title) - - self.window.resize(380, 600) - self.window.setMinimumSize(200, 200) -# - #x, y = 0, 0 - #if action == "mentions": - # x, y = 20, 20 - #elif action == "conversation": - # x, y = 40, 20 - #elif action == "profile": - # x, y = 40, 40 - - #self.moveWindow(x, y) + self.window.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png")) self.webView = Helper.WebViewCreator(self.app, True, self.window) self.webView.load_local(self.load_finished) self.window.setCentralWidget(self.webView) - # 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,10 +231,10 @@ class Login(QtGui.QDialog): #self.buttonLogin.clicked.connect(callback) #self.label.setText("The server " + url.host() + " requires a username and password.") -class NewPost(QtGui.QMainWindow): +class NewPost(Helper.RestorableWindow): def __init__(self, app): self.app = app - QtGui.QPlainTextEdit.__init__(self) + Helper.RestorableWindow.__init__(self, "newpost", self.app) self.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png")) From 940eb89903fdd53e7b3568020fcffabc392cc0a8 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Sun, 30 Dec 2012 22:31:10 +0100 Subject: [PATCH 4/4] test --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index b610761..bde95c4 100644 --- a/README.markdown +++ b/README.markdown @@ -19,3 +19,4 @@ Thanks everyone in the Open Source community! Tentia is using: - Qt - http://qt.digia.com/ - python - http://www.python.org/ - PyQt - http://wiki.python.org/moin/PyQt +- test