From 8fcb826d428443522afaaf4a5ba6791e5f5ea930 Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 11:21:55 -0200 Subject: Implement a proper JS client (#292) --- scudcloud-1.0/lib/scudcloud.py | 11 +--- scudcloud-1.0/lib/wrapper.py | 29 ++------- scudcloud-1.0/resources/scudcloud.js | 2 +- scudcloud-1.0/scudcloud-src.js | 122 +++++++++++++++++++++++++---------- 4 files changed, 94 insertions(+), 70 deletions(-) diff --git a/scudcloud-1.0/lib/scudcloud.py b/scudcloud-1.0/lib/scudcloud.py index 3fb3b2c..abcc8ca 100755 --- a/scudcloud-1.0/lib/scudcloud.py +++ b/scudcloud-1.0/lib/scudcloud.py @@ -61,8 +61,6 @@ class ScudCloud(QtGui.QMainWindow): self.systray(ScudCloud.minimized) self.installEventFilter(self) self.statusBar().showMessage('Loading Slack...') - # Starting unread msgs counter - self.setupTimer() def addWrapper(self, url): webView = Wrapper(self) @@ -73,12 +71,6 @@ class ScudCloud(QtGui.QMainWindow): self.stackedWidget.addWidget(webView) self.stackedWidget.setCurrentWidget(webView) - def setupTimer(self): - self.timer = QTimer(self) - self.timer.timeout.connect(self.count) - self.timer.setInterval(2000) - self.timer.start() - def webSettings(self): self.cookiesjar = PersistentCookieJar(self) self.zoom = self.readZoom() @@ -281,7 +273,6 @@ class ScudCloud(QtGui.QMainWindow): break if not exists: self.addWrapper(url) - self.enableMenus(self.current().isConnected()) self.updateEditMenu() def eventFilter(self, obj, event): @@ -367,7 +358,7 @@ class ScudCloud(QtGui.QMainWindow): total = 0 for i in range(0, self.stackedWidget.count()): widget = self.stackedWidget.widget(i) - messages = widget.count() + messages = widget.highlights if messages == 0: self.leftPane.stopAlert(widget.team()) else: diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index 084c631..115cbe9 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -10,6 +10,7 @@ from PyQt4.QtNetwork import QNetworkProxy class Wrapper(QWebView): + highlights = 0 icon = None def __init__(self, window): @@ -26,18 +27,6 @@ class Wrapper(QWebView): self.linkClicked.connect(self._linkClicked) self.page().featurePermissionRequested.connect(self.permissionRequested) self.addActions() - self.setupTimer() - - # Starting a timer that will check by server side reloads (which drops ScudCloud notification) - def setupTimer(self): - timer = QTimer(self) - timer.timeout.connect(self.overrideNotifications) - # Hope each 10 minutes will not be produce high CPU usage - timer.setInterval(600000) - timer.start() - - def overrideNotifications(self): - self.call("overrideNotifications") def permissionRequested(self, frame, feature): self.page().setFeaturePermission(frame, feature, QWebPage.PermissionGrantedByUser) @@ -104,7 +93,6 @@ class Wrapper(QWebView): def _loadFinished(self, ok=True): self.page().currentFrame().addToJavaScriptWindowObject("desktop", self) self.page().currentFrame().evaluateJavaScript(self.js) - self.window.enableMenus(self.isConnected()) self.window.statusBar().hide() def systemOpen(self, url): @@ -127,9 +115,6 @@ class Wrapper(QWebView): self.window.show() self.call("preferences") - def isConnected(self): - return self.call("isConnected") - def createSnippet(self): self.call("createSnippet") @@ -148,9 +133,6 @@ class Wrapper(QWebView): def about(self): subprocess.call(('xdg-open', "https://github.com/raelgc/scudcloud")) - def isConnected(self): - return self.call("isConnected") - def listChannels(self): return self.call("listChannels") @@ -158,11 +140,10 @@ class Wrapper(QWebView): self.call("join", menuitem.property_get("id")) self.window.show() - def count(self): - try: - return self.call("count") - except: - return 0 + @QtCore.pyqtSlot(int, int) + def setBadgeCount(self, highlight, unread): + self.highlights = highlight + self.window.count() @QtCore.pyqtSlot(str) def populate(self, serialized): diff --git a/scudcloud-1.0/resources/scudcloud.js b/scudcloud-1.0/resources/scudcloud.js index 5e121c6..bf1f5d6 100644 --- a/scudcloud-1.0/resources/scudcloud.js +++ b/scudcloud-1.0/resources/scudcloud.js @@ -1 +1 @@ -var ScudCloud={overrideNotifications:function(){TS.ui.growls.no_notifications=!1,TS.ui.growls.checkPermission=function(){return!0},TS.ui.growls.getPermissionLevel=function(){return"granted"},TS.ui.growls.show=function(n,e){desktop.sendMessage(n,e)},TS.ui.banner.close()},overrideConnect:function(){TS.ms.connected_sig.add(function(){ScudCloud.connect(!0)}),TS.ms.disconnected_sig.add(function(){ScudCloud.connect(!1)})},overrideBanner:function(){ScudCloud.showBanner=TS.ui.banner.show,TS.ui.banner.show=function(){ScudCloud.showBanner(),ScudCloud.overrideNotifications()}},connect:function(n){desktop.enableMenus(n),n&&(ScudCloud.overrideNotifications(),desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44})))},count:function(){var n=0;return $("span.unread_highlight").not(".hidden").each(function(){n+=new Number($(this).text().replace("+",""))}),n},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var n=TS.getAllTeams();return n[0].team_icon={image_44:TS.model.team.icon.image_44},n},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(n){return TS.channels.join(n)},setClipboard:function(n){TS.client.ui.file_pasted_sig.dispatch(n,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var n=TS.getAllTeams();if(null!=n)for(var e=0;n.length;e++)if(n[e].team_url==TS.boot_data.team_url)return n[e].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()},isConnected:function(){return"undefined"!=typeof TS&&"undefined"!=typeof TS.model&&TS.model.ms_connected}};"undefined"!=typeof TS&&(document.onpaste=function(){desktop.pasted(!1)},ScudCloud.overrideNotifications(),ScudCloud.overrideConnect(),ScudCloud.overrideBanner()); +ScudCloud={hasPreference:function(e){return ScudCloud.na("hasPreference")},getPreference:function(e){return ScudCloud.na("getPreference")},setPreference:function(e,n){return ScudCloud.na("setPreference")},canShowHtmlNotifications:function(){return ScudCloud.na("canShowHtmlNotifications")},call:function(e,n){switch(ScudCloud.log(e),e){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(n);case"notify":return ScudCloud.notify(n);case"setBadgeCount":return ScudCloud.setBadgeCount(n);case"displayTeam":return ScudCloud.displayTeam(n);case"getModifierKeys":case"updateTitleBarColor":case"disableSecureInput":case"setImage":case"listWindows":case"focusWindow":case"openWindow":case"closeWindow":case"getGeometryForWindow":case"startDownload":case"supportsOpenFileAtPath":case"cancelDownloadWithToken":case"openFileAtPath":case"retryDownloadWithToken":case"pruneTokensFromHistory":case"metadataForDownloads":case"readFindString":}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.populate()},setConnectionStatus:function(e){switch(e){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(e){desktop.sendMessage(e.title,e.content)},setBadgeCount:function(e){desktop.setBadgeCount(e.all_unread_highlights_cnt,e.all_unread_cnt)},displayTeam:function(e){},na:function(e){return ScudCloud.log(e),!1},log:function(e){console.log("ScudCloud."+e)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var e=TS.getAllTeams();return e[0].team_icon={image_44:TS.model.team.icon.image_44},e},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(e){return TS.channels.join(e)},setClipboard:function(e){TS.client.ui.file_pasted_sig.dispatch(e,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var e=TS.getAllTeams();if(null!=e)for(var n=0;e.length;n++)if(e[n].team_url==TS.boot_data.team_url)return e[n].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},"undefined"!=typeof TS&&(document.onpaste=function(e){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud); diff --git a/scudcloud-1.0/scudcloud-src.js b/scudcloud-1.0/scudcloud-src.js index c16a0b9..4cf759b 100644 --- a/scudcloud-1.0/scudcloud-src.js +++ b/scudcloud-1.0/scudcloud-src.js @@ -1,33 +1,90 @@ -var ScudCloud = { - overrideNotifications: function(){ - TS.ui.growls.no_notifications = false; - TS.ui.growls.checkPermission = function() { return true; }; - TS.ui.growls.getPermissionLevel = function() { return 'granted'; }; - TS.ui.growls.show = function(j,f,o,p){ desktop.sendMessage(j,f); }; - TS.ui.banner.close(); - }, - overrideConnect: function(){ - TS.ms.connected_sig.add(function(){ScudCloud.connect(true);}); - TS.ms.disconnected_sig.add(function(){ScudCloud.connect(false);}); - }, - overrideBanner: function(){ - ScudCloud.showBanner = TS.ui.banner.show; - TS.ui.banner.show = function(){ ScudCloud.showBanner(); ScudCloud.overrideNotifications(); }; - }, - connect: function(b){ - desktop.enableMenus(b); - if(b){ - ScudCloud.overrideNotifications(); - desktop.populate(JSON.stringify({'channels': ScudCloud.listChannels(), 'teams': ScudCloud.listTeams(), 'icon': TS.model.team.icon.image_44})); +ScudCloud = { + // App functions + hasPreference: function(name){ + return ScudCloud.na("hasPreference"); + }, + getPreference: function(name){ + return ScudCloud.na("getPreference"); + }, + setPreference: function(name, value){ + return ScudCloud.na("setPreference"); + }, + canShowHtmlNotifications: function(){ + return ScudCloud.na("canShowHtmlNotifications"); + }, + // TSSSB.call + call: function(name, args){ + ScudCloud.log(name); + switch(name){ + case "reload": + return ScudCloud.reload(); + case "didStartLoading": + return ScudCloud.didStartLoading(); + case "didFinishLoading": + return ScudCloud.didFinishLoading(); + case "setConnectionStatus": + return ScudCloud.setConnectionStatus(args); + case "notify": + return ScudCloud.notify(args); + case "setBadgeCount": + return ScudCloud.setBadgeCount(args); + case "displayTeam": + return ScudCloud.displayTeam(args); + case "getModifierKeys": + case "updateTitleBarColor": + case "disableSecureInput": + case "setImage": + case "listWindows": + case "focusWindow": + case "openWindow": + case "closeWindow": + case "getGeometryForWindow": + case "startDownload": + case "supportsOpenFileAtPath": + case "cancelDownloadWithToken": + case "openFileAtPath": + case "retryDownloadWithToken": + case "pruneTokensFromHistory": + case "metadataForDownloads": + case "readFindString": + } + return false; + }, + // TSSSB.call implementations + reload: function(){ + window.location.reload(); + }, + didStartLoading: function(){ + }, + didFinishLoading: function(){ + ScudCloud.populate(); + }, + setConnectionStatus: function(status){ + // "online", "connecting", "offline" + switch(status){ + case "online": desktop.enableMenus(true); break; + default: desktop.enableMenus(false); } }, - count: function(){ - var total=0; - $('span.unread_highlight').not('.hidden').each(function(i){ - total+= new Number($(this).text().replace('+','')); } - ); - return total; - }, + notify: function(args){ + desktop.sendMessage(args.title, args.content); + }, + setBadgeCount: function(args){ + desktop.setBadgeCount(args.all_unread_highlights_cnt, args.all_unread_cnt); + }, + displayTeam: function(id){ + }, + // ScudCloud internal functions + na: function(name){ + ScudCloud.log(name); + return false; + }, + log: function(name){ + console.log("ScudCloud."+name); + }, + populate: function(){ + desktop.populate(JSON.stringify({'channels': ScudCloud.listChannels(), 'teams': ScudCloud.listTeams(), 'icon': TS.model.team.icon.image_44})); + }, createSnippet: function(){ return TS.ui.snippet_dialog.start(); }, @@ -69,14 +126,9 @@ var ScudCloud = { }, help: function(){ return TS.help_dialog.start(); - }, - isConnected: function(){ - return "undefined" != typeof TS && "undefined" != typeof TS.model && TS.model.ms_connected; - } + } }; if("undefined" != typeof TS){ document.onpaste = function(e){desktop.pasted(false);}; - ScudCloud.overrideNotifications(); - ScudCloud.overrideConnect(); - ScudCloud.overrideBanner(); + window.winssb = TSSSB = ScudCloud; } -- cgit v1.1 From 702883e521e9db324f71f77983aafa5c690ae4d8 Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 12:41:17 -0200 Subject: Small changes to make JS faster (#292) --- scudcloud-1.0/resources/scudcloud.js | 2 +- scudcloud-1.0/scudcloud-src.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scudcloud-1.0/resources/scudcloud.js b/scudcloud-1.0/resources/scudcloud.js index bf1f5d6..b7a2710 100644 --- a/scudcloud-1.0/resources/scudcloud.js +++ b/scudcloud-1.0/resources/scudcloud.js @@ -1 +1 @@ -ScudCloud={hasPreference:function(e){return ScudCloud.na("hasPreference")},getPreference:function(e){return ScudCloud.na("getPreference")},setPreference:function(e,n){return ScudCloud.na("setPreference")},canShowHtmlNotifications:function(){return ScudCloud.na("canShowHtmlNotifications")},call:function(e,n){switch(ScudCloud.log(e),e){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(n);case"notify":return ScudCloud.notify(n);case"setBadgeCount":return ScudCloud.setBadgeCount(n);case"displayTeam":return ScudCloud.displayTeam(n);case"getModifierKeys":case"updateTitleBarColor":case"disableSecureInput":case"setImage":case"listWindows":case"focusWindow":case"openWindow":case"closeWindow":case"getGeometryForWindow":case"startDownload":case"supportsOpenFileAtPath":case"cancelDownloadWithToken":case"openFileAtPath":case"retryDownloadWithToken":case"pruneTokensFromHistory":case"metadataForDownloads":case"readFindString":}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.populate()},setConnectionStatus:function(e){switch(e){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(e){desktop.sendMessage(e.title,e.content)},setBadgeCount:function(e){desktop.setBadgeCount(e.all_unread_highlights_cnt,e.all_unread_cnt)},displayTeam:function(e){},na:function(e){return ScudCloud.log(e),!1},log:function(e){console.log("ScudCloud."+e)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var e=TS.getAllTeams();return e[0].team_icon={image_44:TS.model.team.icon.image_44},e},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(e){return TS.channels.join(e)},setClipboard:function(e){TS.client.ui.file_pasted_sig.dispatch(e,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var e=TS.getAllTeams();if(null!=e)for(var n=0;e.length;n++)if(e[n].team_url==TS.boot_data.team_url)return e[n].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},"undefined"!=typeof TS&&(document.onpaste=function(e){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud); +ScudCloud={hasPreference:function(e){return ScudCloud.na("hasPreference")},getPreference:function(e){return ScudCloud.na("getPreference")},setPreference:function(e,n){return ScudCloud.na("setPreference")},canShowHtmlNotifications:function(){return ScudCloud.na("canShowHtmlNotifications")},call:function(e,n){switch(ScudCloud.log(e),e){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(n);case"notify":return ScudCloud.notify(n);case"setBadgeCount":return ScudCloud.setBadgeCount(n);case"displayTeam":return ScudCloud.displayTeam(n);case"getModifierKeys":case"updateTitleBarColor":case"disableSecureInput":case"setImage":case"listWindows":case"focusWindow":case"openWindow":case"closeWindow":case"getGeometryForWindow":case"startDownload":case"supportsOpenFileAtPath":case"cancelDownloadWithToken":case"openFileAtPath":case"retryDownloadWithToken":case"pruneTokensFromHistory":case"metadataForDownloads":case"readFindString":}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.populate()},setConnectionStatus:function(e){switch(e){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(e){desktop.sendMessage(e.title,e.content)},setBadgeCount:function(e){desktop.setBadgeCount(e.all_unread_highlights_cnt,e.all_unread_cnt)},displayTeam:function(e){},na:function(e){return ScudCloud.log(e),!1},log:function(e){console.log("ScudCloud."+e)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var e=TS.getAllTeams();return e[0].team_icon={image_44:TS.model.team.icon.image_44},e},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(e){return TS.channels.join(e)},setClipboard:function(e){TS.client.ui.file_pasted_sig.dispatch(e,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var e=TS.getAllTeams();if(null!=e)for(var n=0;e.length;n++)if(e[n].team_url==TS.boot_data.team_url)return e[n].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(e){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud; diff --git a/scudcloud-1.0/scudcloud-src.js b/scudcloud-1.0/scudcloud-src.js index 4cf759b..2f253d1 100644 --- a/scudcloud-1.0/scudcloud-src.js +++ b/scudcloud-1.0/scudcloud-src.js @@ -128,7 +128,5 @@ ScudCloud = { return TS.help_dialog.start(); } }; -if("undefined" != typeof TS){ - document.onpaste = function(e){desktop.pasted(false);}; - window.winssb = TSSSB = ScudCloud; -} +document.onpaste = function(e){desktop.pasted(false);}; +window.winssb = TSSSB = ScudCloud; -- cgit v1.1 From 47885a6a2c4f1239232dff6983456ed405f06fa5 Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 13:29:20 -0200 Subject: Short message title (#292) --- scudcloud-1.0/lib/wrapper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index 115cbe9..f018163 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -12,6 +12,7 @@ class Wrapper(QWebView): highlights = 0 icon = None + name = '' def __init__(self, window): self.configure_proxy() @@ -151,8 +152,8 @@ class Wrapper(QWebView): self.window.teams(data['teams']) if self.window.current() == self: self.window.quicklist(data['channels']) - iconFile = data['teams'][0]['team_name']+'.png' - filename, headers = request.urlretrieve(data['icon'], tempfile.gettempdir()+'/'+iconFile) + self.name = data['teams'][0]['team_name'] + filename, headers = request.urlretrieve(data['icon'], tempfile.gettempdir()+'/'+self.name+'.png') self.icon = filename @QtCore.pyqtSlot(bool) @@ -172,6 +173,6 @@ class Wrapper(QWebView): @QtCore.pyqtSlot(str, str) def sendMessage(self, title, message): - self.window.notify(str(title).replace("New message from ", "").replace("New message in ", ""), str(message), self.icon) + self.window.notify(str(title).replace('New message from ', '', 1).replace('New message in ', '', 1).replace('['+self.name.lower()+'] in ', '', 1), str(message), self.icon) -- cgit v1.1 From 6b503543ae75fcd1172e9c557b6ed2752aa4d943 Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 14:03:46 -0200 Subject: Better code for sendMessage replacement (#292) --- scudcloud-1.0/lib/wrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index f018163..13be430 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -173,6 +173,9 @@ class Wrapper(QWebView): @QtCore.pyqtSlot(str, str) def sendMessage(self, title, message): - self.window.notify(str(title).replace('New message from ', '', 1).replace('New message in ', '', 1).replace('['+self.name.lower()+'] in ', '', 1), str(message), self.icon) + erase = ['New message from ', 'New message in ', '['+self.name.lower()+'] in '] + for s in erase: + title = str(title).replace(s, '', 1) + self.window.notify(title, str(message), self.icon) -- cgit v1.1 From 5c75d1a37803dd6a6b805c040ca9bed1e23ddc8b Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 14:10:06 -0200 Subject: Renaming setBadgeCount method to count (#292) --- scudcloud-1.0/lib/wrapper.py | 2 +- scudcloud-1.0/resources/scudcloud.js | 2 +- scudcloud-1.0/scudcloud-src.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index 13be430..1a62fad 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -142,7 +142,7 @@ class Wrapper(QWebView): self.window.show() @QtCore.pyqtSlot(int, int) - def setBadgeCount(self, highlight, unread): + def count(self, highlight, unread): self.highlights = highlight self.window.count() diff --git a/scudcloud-1.0/resources/scudcloud.js b/scudcloud-1.0/resources/scudcloud.js index b7a2710..23a8597 100644 --- a/scudcloud-1.0/resources/scudcloud.js +++ b/scudcloud-1.0/resources/scudcloud.js @@ -1 +1 @@ -ScudCloud={hasPreference:function(e){return ScudCloud.na("hasPreference")},getPreference:function(e){return ScudCloud.na("getPreference")},setPreference:function(e,n){return ScudCloud.na("setPreference")},canShowHtmlNotifications:function(){return ScudCloud.na("canShowHtmlNotifications")},call:function(e,n){switch(ScudCloud.log(e),e){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(n);case"notify":return ScudCloud.notify(n);case"setBadgeCount":return ScudCloud.setBadgeCount(n);case"displayTeam":return ScudCloud.displayTeam(n);case"getModifierKeys":case"updateTitleBarColor":case"disableSecureInput":case"setImage":case"listWindows":case"focusWindow":case"openWindow":case"closeWindow":case"getGeometryForWindow":case"startDownload":case"supportsOpenFileAtPath":case"cancelDownloadWithToken":case"openFileAtPath":case"retryDownloadWithToken":case"pruneTokensFromHistory":case"metadataForDownloads":case"readFindString":}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.populate()},setConnectionStatus:function(e){switch(e){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(e){desktop.sendMessage(e.title,e.content)},setBadgeCount:function(e){desktop.setBadgeCount(e.all_unread_highlights_cnt,e.all_unread_cnt)},displayTeam:function(e){},na:function(e){return ScudCloud.log(e),!1},log:function(e){console.log("ScudCloud."+e)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var e=TS.getAllTeams();return e[0].team_icon={image_44:TS.model.team.icon.image_44},e},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(e){return TS.channels.join(e)},setClipboard:function(e){TS.client.ui.file_pasted_sig.dispatch(e,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var e=TS.getAllTeams();if(null!=e)for(var n=0;e.length;n++)if(e[n].team_url==TS.boot_data.team_url)return e[n].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(e){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud; +ScudCloud={hasPreference:function(e){return ScudCloud.na("hasPreference")},getPreference:function(e){return ScudCloud.na("getPreference")},setPreference:function(e,n){return ScudCloud.na("setPreference")},canShowHtmlNotifications:function(){return ScudCloud.na("canShowHtmlNotifications")},call:function(e,n){switch(ScudCloud.log(e),e){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(n);case"notify":return ScudCloud.notify(n);case"setBadgeCount":return ScudCloud.setBadgeCount(n);case"displayTeam":return ScudCloud.displayTeam(n);case"getModifierKeys":case"updateTitleBarColor":case"disableSecureInput":case"setImage":case"listWindows":case"focusWindow":case"openWindow":case"closeWindow":case"getGeometryForWindow":case"startDownload":case"supportsOpenFileAtPath":case"cancelDownloadWithToken":case"openFileAtPath":case"retryDownloadWithToken":case"pruneTokensFromHistory":case"metadataForDownloads":case"readFindString":}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.populate()},setConnectionStatus:function(e){switch(e){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(e){desktop.sendMessage(e.title,e.content)},setBadgeCount:function(e){desktop.count(e.all_unread_highlights_cnt,e.all_unread_cnt)},displayTeam:function(e){},na:function(e){return ScudCloud.log(e),!1},log:function(e){console.log("ScudCloud."+e)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var e=TS.getAllTeams();return e[0].team_icon={image_44:TS.model.team.icon.image_44},e},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(e){return TS.channels.join(e)},setClipboard:function(e){TS.client.ui.file_pasted_sig.dispatch(e,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var e=TS.getAllTeams();if(null!=e)for(var n=0;e.length;n++)if(e[n].team_url==TS.boot_data.team_url)return e[n].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(e){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud; diff --git a/scudcloud-1.0/scudcloud-src.js b/scudcloud-1.0/scudcloud-src.js index 2f253d1..3af0a53 100644 --- a/scudcloud-1.0/scudcloud-src.js +++ b/scudcloud-1.0/scudcloud-src.js @@ -70,7 +70,7 @@ ScudCloud = { desktop.sendMessage(args.title, args.content); }, setBadgeCount: function(args){ - desktop.setBadgeCount(args.all_unread_highlights_cnt, args.all_unread_cnt); + desktop.count(args.all_unread_highlights_cnt, args.all_unread_cnt); }, displayTeam: function(id){ }, -- cgit v1.1 From 6d3df640b7cc469910d8f22a3d10e9950ff936dc Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 15:53:54 -0200 Subject: More notification replacements (#292) --- scudcloud-1.0/lib/wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index 1a62fad..6ac594a 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -173,7 +173,7 @@ class Wrapper(QWebView): @QtCore.pyqtSlot(str, str) def sendMessage(self, title, message): - erase = ['New message from ', 'New message in ', '['+self.name.lower()+'] in '] + erase = ['['+self.name.lower()+'] in ', '['+self.name.lower()+'] from '] for s in erase: title = str(title).replace(s, '', 1) self.window.notify(title, str(message), self.icon) -- cgit v1.1 From b05e1291c8154ee2d492514e572c9a78b8df671e Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 16:29:31 -0200 Subject: Starting the webkit-JS bridge earlier (#292) --- scudcloud-1.0/lib/wrapper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index 6ac594a..65c6c6b 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -83,6 +83,8 @@ class Wrapper(QWebView): def _loadStarted(self): # Some custom CSS to clean/fix UX self.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(Resources.get_path("resources.css"))) + # Starting the webkit-JS bridge + self.page().currentFrame().addToJavaScriptWindowObject("desktop", self) def _urlChanged(self, qUrl): url = qUrl.toString() @@ -92,7 +94,6 @@ class Wrapper(QWebView): self.load(QUrl("https://"+qUrl.host()+"/messages/general")) def _loadFinished(self, ok=True): - self.page().currentFrame().addToJavaScriptWindowObject("desktop", self) self.page().currentFrame().evaluateJavaScript(self.js) self.window.statusBar().hide() -- cgit v1.1 From 6601bcb0fd52e5ea49697dcc60e2613e14f67057 Mon Sep 17 00:00:00 2001 From: Rael Date: Wed, 18 Nov 2015 16:29:53 -0200 Subject: Double checking didFinishLoading (#292) --- scudcloud-1.0/resources/scudcloud.js | 2 +- scudcloud-1.0/scudcloud-src.js | 39 ++++++++++++------------------------ 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/scudcloud-1.0/resources/scudcloud.js b/scudcloud-1.0/resources/scudcloud.js index 23a8597..34bbec3 100644 --- a/scudcloud-1.0/resources/scudcloud.js +++ b/scudcloud-1.0/resources/scudcloud.js @@ -1 +1 @@ -ScudCloud={hasPreference:function(e){return ScudCloud.na("hasPreference")},getPreference:function(e){return ScudCloud.na("getPreference")},setPreference:function(e,n){return ScudCloud.na("setPreference")},canShowHtmlNotifications:function(){return ScudCloud.na("canShowHtmlNotifications")},call:function(e,n){switch(ScudCloud.log(e),e){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(n);case"notify":return ScudCloud.notify(n);case"setBadgeCount":return ScudCloud.setBadgeCount(n);case"displayTeam":return ScudCloud.displayTeam(n);case"getModifierKeys":case"updateTitleBarColor":case"disableSecureInput":case"setImage":case"listWindows":case"focusWindow":case"openWindow":case"closeWindow":case"getGeometryForWindow":case"startDownload":case"supportsOpenFileAtPath":case"cancelDownloadWithToken":case"openFileAtPath":case"retryDownloadWithToken":case"pruneTokensFromHistory":case"metadataForDownloads":case"readFindString":}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.populate()},setConnectionStatus:function(e){switch(e){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(e){desktop.sendMessage(e.title,e.content)},setBadgeCount:function(e){desktop.count(e.all_unread_highlights_cnt,e.all_unread_cnt)},displayTeam:function(e){},na:function(e){return ScudCloud.log(e),!1},log:function(e){console.log("ScudCloud."+e)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var e=TS.getAllTeams();return e[0].team_icon={image_44:TS.model.team.icon.image_44},e},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(e){return TS.channels.join(e)},setClipboard:function(e){TS.client.ui.file_pasted_sig.dispatch(e,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var e=TS.getAllTeams();if(null!=e)for(var n=0;e.length;n++)if(e[n].team_url==TS.boot_data.team_url)return e[n].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(e){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud; +ScudCloud={unloaded:!0,hasPreference:function(n){return!1},getPreference:function(n){return!1},setPreference:function(n,e){return!1},canShowHtmlNotifications:function(){return!1},call:function(n,e){switch(ScudCloud.log(n),n){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(e);case"notify":return ScudCloud.notify(e);case"setBadgeCount":return ScudCloud.setBadgeCount(e);case"displayTeam":return ScudCloud.displayTeam(e)}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.unloaded&&(TS.ui.banner.close(),ScudCloud.populate(),ScudCloud.unloaded=!1)},setConnectionStatus:function(n){switch(n){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(n){desktop.sendMessage(n.title,n.content)},setBadgeCount:function(n){desktop.count(n.all_unread_highlights_cnt,n.all_unread_cnt)},displayTeam:function(n){},log:function(n){console.log("ScudCloud."+n)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var n=TS.getAllTeams();return n[0].team_icon={image_44:TS.model.team.icon.image_44},n},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(n){return TS.channels.join(n)},setClipboard:function(n){TS.client.ui.file_pasted_sig.dispatch(n,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var n=TS.getAllTeams();if(null!=n)for(var e=0;n.length;e++)if(n[e].team_url==TS.boot_data.team_url)return n[e].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(n){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud,ScudCloud.didFinishLoading(); diff --git a/scudcloud-1.0/scudcloud-src.js b/scudcloud-1.0/scudcloud-src.js index 3af0a53..36ce89e 100644 --- a/scudcloud-1.0/scudcloud-src.js +++ b/scudcloud-1.0/scudcloud-src.js @@ -1,16 +1,18 @@ ScudCloud = { + unloaded: true, // App functions hasPreference: function(name){ - return ScudCloud.na("hasPreference"); + return false; }, getPreference: function(name){ - return ScudCloud.na("getPreference"); + return false; }, setPreference: function(name, value){ - return ScudCloud.na("setPreference"); + return false; }, canShowHtmlNotifications: function(){ - return ScudCloud.na("canShowHtmlNotifications"); + // Ubuntu cannot display HTML notifications + return false; }, // TSSSB.call call: function(name, args){ @@ -30,23 +32,6 @@ ScudCloud = { return ScudCloud.setBadgeCount(args); case "displayTeam": return ScudCloud.displayTeam(args); - case "getModifierKeys": - case "updateTitleBarColor": - case "disableSecureInput": - case "setImage": - case "listWindows": - case "focusWindow": - case "openWindow": - case "closeWindow": - case "getGeometryForWindow": - case "startDownload": - case "supportsOpenFileAtPath": - case "cancelDownloadWithToken": - case "openFileAtPath": - case "retryDownloadWithToken": - case "pruneTokensFromHistory": - case "metadataForDownloads": - case "readFindString": } return false; }, @@ -57,7 +42,11 @@ ScudCloud = { didStartLoading: function(){ }, didFinishLoading: function(){ - ScudCloud.populate(); + if(ScudCloud.unloaded){ + TS.ui.banner.close(); + ScudCloud.populate(); + ScudCloud.unloaded = false; + } }, setConnectionStatus: function(status){ // "online", "connecting", "offline" @@ -75,10 +64,6 @@ ScudCloud = { displayTeam: function(id){ }, // ScudCloud internal functions - na: function(name){ - ScudCloud.log(name); - return false; - }, log: function(name){ console.log("ScudCloud."+name); }, @@ -130,3 +115,5 @@ ScudCloud = { }; document.onpaste = function(e){desktop.pasted(false);}; window.winssb = TSSSB = ScudCloud; +// Sometimes didFinishLoading is not loaded +ScudCloud.didFinishLoading(); -- cgit v1.1 From 018b3ad8e1656a1c08ba69d58f53e5a60ac74e79 Mon Sep 17 00:00:00 2001 From: Rael Date: Thu, 19 Nov 2015 09:16:33 -0200 Subject: Don't block didFinishLoading to run again (#292) --- scudcloud-1.0/resources/scudcloud.js | 2 +- scudcloud-1.0/scudcloud-src.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scudcloud-1.0/resources/scudcloud.js b/scudcloud-1.0/resources/scudcloud.js index 34bbec3..82a7621 100644 --- a/scudcloud-1.0/resources/scudcloud.js +++ b/scudcloud-1.0/resources/scudcloud.js @@ -1 +1 @@ -ScudCloud={unloaded:!0,hasPreference:function(n){return!1},getPreference:function(n){return!1},setPreference:function(n,e){return!1},canShowHtmlNotifications:function(){return!1},call:function(n,e){switch(ScudCloud.log(n),n){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(e);case"notify":return ScudCloud.notify(e);case"setBadgeCount":return ScudCloud.setBadgeCount(e);case"displayTeam":return ScudCloud.displayTeam(e)}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){ScudCloud.unloaded&&(TS.ui.banner.close(),ScudCloud.populate(),ScudCloud.unloaded=!1)},setConnectionStatus:function(n){switch(n){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(n){desktop.sendMessage(n.title,n.content)},setBadgeCount:function(n){desktop.count(n.all_unread_highlights_cnt,n.all_unread_cnt)},displayTeam:function(n){},log:function(n){console.log("ScudCloud."+n)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var n=TS.getAllTeams();return n[0].team_icon={image_44:TS.model.team.icon.image_44},n},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(n){return TS.channels.join(n)},setClipboard:function(n){TS.client.ui.file_pasted_sig.dispatch(n,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var n=TS.getAllTeams();if(null!=n)for(var e=0;n.length;e++)if(n[e].team_url==TS.boot_data.team_url)return n[e].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(n){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud,ScudCloud.didFinishLoading(); +ScudCloud={unloaded:!0,hasPreference:function(n){return!1},getPreference:function(n){return!1},setPreference:function(n,e){return!1},canShowHtmlNotifications:function(){return!1},call:function(n,e){switch(ScudCloud.log(n),n){case"reload":return ScudCloud.reload();case"didStartLoading":return ScudCloud.didStartLoading();case"didFinishLoading":return ScudCloud.didFinishLoading();case"setConnectionStatus":return ScudCloud.setConnectionStatus(e);case"notify":return ScudCloud.notify(e);case"setBadgeCount":return ScudCloud.setBadgeCount(e);case"displayTeam":return ScudCloud.displayTeam(e)}return!1},reload:function(){window.location.reload()},didStartLoading:function(){},didFinishLoading:function(){TS.ui.banner.close(),ScudCloud.populate(),ScudCloud.unloaded=!1},setConnectionStatus:function(n){switch(n){case"online":desktop.enableMenus(!0);break;default:desktop.enableMenus(!1)}},notify:function(n){desktop.sendMessage(n.title,n.content)},setBadgeCount:function(n){desktop.count(n.all_unread_highlights_cnt,n.all_unread_cnt)},displayTeam:function(n){},log:function(n){console.log("ScudCloud."+n)},populate:function(){desktop.populate(JSON.stringify({channels:ScudCloud.listChannels(),teams:ScudCloud.listTeams(),icon:TS.model.team.icon.image_44}))},createSnippet:function(){return TS.ui.snippet_dialog.start()},listChannels:function(){return TS.channels.getUnarchivedChannelsForUser()},listTeams:function(){var n=TS.getAllTeams();return n[0].team_icon={image_44:TS.model.team.icon.image_44},n},quicklist:function(){desktop.quicklist(ScudCloud.listChannels())},join:function(n){return TS.channels.join(n)},setClipboard:function(n){TS.client.ui.file_pasted_sig.dispatch(n,TS.model.shift_key_pressed)},preferences:function(){return TS.ui.prefs_dialog.start()},addTeam:function(){document.location=TS.boot_data.signin_url},getCurrentTeam:function(){var n=TS.getAllTeams();if(null!=n)for(var e=0;n.length;e++)if(n[e].team_url==TS.boot_data.team_url)return n[e].id;return""},logout:function(){document.location=TS.boot_data.logout_url},help:function(){return TS.help_dialog.start()}},document.onpaste=function(n){desktop.pasted(!1)},window.winssb=TSSSB=ScudCloud,ScudCloud.unloaded&&ScudCloud.didFinishLoading(); diff --git a/scudcloud-1.0/scudcloud-src.js b/scudcloud-1.0/scudcloud-src.js index 36ce89e..3bb9beb 100644 --- a/scudcloud-1.0/scudcloud-src.js +++ b/scudcloud-1.0/scudcloud-src.js @@ -1,3 +1,4 @@ + ScudCloud = { unloaded: true, // App functions @@ -42,11 +43,9 @@ ScudCloud = { didStartLoading: function(){ }, didFinishLoading: function(){ - if(ScudCloud.unloaded){ - TS.ui.banner.close(); - ScudCloud.populate(); - ScudCloud.unloaded = false; - } + TS.ui.banner.close(); + ScudCloud.populate(); + ScudCloud.unloaded = false; }, setConnectionStatus: function(status){ // "online", "connecting", "offline" @@ -116,4 +115,6 @@ ScudCloud = { document.onpaste = function(e){desktop.pasted(false);}; window.winssb = TSSSB = ScudCloud; // Sometimes didFinishLoading is not loaded -ScudCloud.didFinishLoading(); +if(ScudCloud.unloaded){ + ScudCloud.didFinishLoading(); +} -- cgit v1.1 From a33bb67eb0755edbf6bc8d5ecf124a57c3a522f3 Mon Sep 17 00:00:00 2001 From: Rael Date: Thu, 19 Nov 2015 09:39:39 -0200 Subject: Adding some comments --- scudcloud-1.0/lib/wrapper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scudcloud-1.0/lib/wrapper.py b/scudcloud-1.0/lib/wrapper.py index 65c6c6b..9d1c348 100644 --- a/scudcloud-1.0/lib/wrapper.py +++ b/scudcloud-1.0/lib/wrapper.py @@ -83,8 +83,6 @@ class Wrapper(QWebView): def _loadStarted(self): # Some custom CSS to clean/fix UX self.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(Resources.get_path("resources.css"))) - # Starting the webkit-JS bridge - self.page().currentFrame().addToJavaScriptWindowObject("desktop", self) def _urlChanged(self, qUrl): url = qUrl.toString() @@ -94,6 +92,9 @@ class Wrapper(QWebView): self.load(QUrl("https://"+qUrl.host()+"/messages/general")) def _loadFinished(self, ok=True): + # Starting the webkit-JS bridge + self.page().currentFrame().addToJavaScriptWindowObject("desktop", self) + # Loading ScudCloud JS client self.page().currentFrame().evaluateJavaScript(self.js) self.window.statusBar().hide() -- cgit v1.1