diff --git a/Linux/Bungloo.py b/Linux/Bungloo.py index 995f3d4..3c357f8 100755 --- a/Linux/Bungloo.py +++ b/Linux/Bungloo.py @@ -49,7 +49,10 @@ class Bungloo: self.init_web_views() def init_web_views(self): - self.timeline = Windows.Timeline(self) + if not hasattr(self, "timeline"): + self.timeline = Windows.Timeline(self) + else: + self.timeline.evaluateJavaScript("start('timeline')") self.timeline.show() self.find_entity = Windows.FindEntity(self) @@ -78,9 +81,9 @@ class Bungloo: def log_out(self): self.oauth_implementation.log_out() - self.timeline.close() + self.timeline.hide() self.preferences.show() - #self.timeline.evaluateJavaScript("bungloo.sidebar.logout()") + self.timeline.evaluateJavaScript("bungloo.sidebar.logout()") class Controller(QtCore.QObject): @@ -142,12 +145,8 @@ class Controller(QtCore.QObject): @QtCore.pyqtSlot(int) def unreadMentions(self, count): - i = int(count) - if i > 0: - self.app.timeline.set_window_title("Bungloo (^" + str(i) + ")") - else: - self.app.timeline.set_window_title("Bungloo") - self.app.timeline.evaluateJavaScript("bungloo.mentions.unread_mentions = 0;") + script = "bungloo.sidebar.setUnreadMentions({});".format(int(count)) + self.app.timeline.evaluateJavaScript(script) @QtCore.pyqtSlot(str, str, str, str) def notificateUserAboutMentionFromNameWithPostIdAndEntity(self, text, name, post_id, entity): diff --git a/Linux/Helper.py b/Linux/Helper.py index f3733ac..c822256 100644 --- a/Linux/Helper.py +++ b/Linux/Helper.py @@ -42,7 +42,6 @@ class WebViewCreator(QtWebKit.QWebView): self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.context_menu_requested) self.actions = [] - QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) def copy_link(): self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard) diff --git a/Linux/Windows.py b/Linux/Windows.py index 88eeeca..ac1eded 100644 --- a/Linux/Windows.py +++ b/Linux/Windows.py @@ -103,17 +103,17 @@ class Timeline: def initUI(self): menubar = self.window.menuBar() - newPostAction = QtGui.QAction("&New post", self.window) + newPostAction = QtGui.QAction("&New Post", self.window) newPostAction.setShortcut("Ctrl+N") newPostAction.setStatusTip("Open new post window") newPostAction.triggered.connect(self.app.controller.openNewMessageWidow) - findEntityAction = QtGui.QAction("&Open profile for entity ...", self.window) + findEntityAction = QtGui.QAction("&Open Profile for Entity ...", self.window) findEntityAction.setShortcut("Ctrl+u") findEntityAction.setStatusTip("Find entity and open its profile view") findEntityAction.triggered.connect(self.app.find_entity_show) - logOutAction = QtGui.QAction("&Log out", self.window) + logOutAction = QtGui.QAction("&Log Out", self.window) logOutAction.setStatusTip("Log out from this entity") logOutAction.triggered.connect(self.app.log_out) @@ -165,8 +165,13 @@ class Timeline: aboutAction.setStatusTip("Open about page in Webbrowser") aboutAction.triggered.connect(self.app.open_about) + developerExtrasAction = QtGui.QAction("&Developer Extras", self.window) + developerExtrasAction.setStatusTip("Activate webkit inspector") + developerExtrasAction.triggered.connect(self.developer_extras) + helpMenu = menubar.addMenu("&Help") helpMenu.addAction(aboutAction) + helpMenu.addAction(developerExtrasAction) def show(self): self.window.show() @@ -188,6 +193,9 @@ class Timeline: def evaluateJavaScript(self, func): return self.webView.page().mainFrame().evaluateJavaScript(func) + def developer_extras(self, widget): + QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) + class Oauth: diff --git a/WebKit/css/default.css b/WebKit/css/default.css index afb1159..4d94b0f 100644 --- a/WebKit/css/default.css +++ b/WebKit/css/default.css @@ -42,6 +42,23 @@ a { border-radius: 8px; } +#sidebar .unread_mentions { + color: white; + background: red; + border: 2px solid white; + border-radius: 1em; + box-shadow: 0 0 1em black; + padding: 0 0.3em; + position: absolute; + top: 100px; + right: 10px; + font-weight: bold; +} + +#sidebar .unread_mentions:empty { + /*display: none;*/ +} + #content { margin-left: 62px; } diff --git a/WebKit/scripts/controller/Sidebar.js b/WebKit/scripts/controller/Sidebar.js index 5e52e7d..81d5599 100644 --- a/WebKit/scripts/controller/Sidebar.js +++ b/WebKit/scripts/controller/Sidebar.js @@ -33,6 +33,11 @@ function(HostApp, Paths, Cache) { this.body.appendChild(this.menu.entityProfile); this.body.appendChild(this.menu.search); + this.unreadMentionsSpan = document.createElement("span"); + this.unreadMentionsSpan.className = "unread_mentions"; + this.menu.mentions.appendChild(this.unreadMentionsSpan); + this.setUnreadMentions(0); + document.getElementById("sidebar").appendChild(this.body); this.setEntityAvatar(); @@ -158,6 +163,15 @@ function(HostApp, Paths, Cache) { img.src = img.src_active; } + Sidebar.prototype.setUnreadMentions = function(count) { + this.unreadMentionsSpan.innerHTML = count == 0 ? "" : count; + if (count > 0) { + $(this.unreadMentionsSpan).show(); + } else { + $(this.unreadMentionsSpan).hide(); + } + } + Sidebar.prototype.onEntity = function() { bungloo.entityProfile.showProfileForEntity(); this.onEntityProfile(); @@ -191,6 +205,9 @@ function(HostApp, Paths, Cache) { bungloo.conversation.logout(); bungloo.entityProfile.logout(); bungloo.search.logout(); + + document.getElementById("sidebar").innerHTML = ""; + document.getElementById("content").innerHTML = ""; } return Sidebar;