From d681f0a059b3c04423d4e06a919e6ad747c077bc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 14 Apr 2014 19:09:47 +0100 Subject: [PATCH] Start to improve remote --- openlp/plugins/remotes/lib/httpserver.py | 56 ++++++++++++++++------- openlp/plugins/remotes/remoteplugin.py | 11 ++++- resources/images/network_auth.png | Bin 0 -> 608 bytes resources/images/network_server.png | Bin 0 -> 1133 bytes resources/images/network_ssl.png | Bin 0 -> 577 bytes resources/images/openlp-2.qrc | 5 ++ 6 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 resources/images/network_auth.png create mode 100644 resources/images/network_server.png create mode 100644 resources/images/network_ssl.png diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 22d0349f8..cc2d02ff3 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -38,9 +38,10 @@ import os import logging import time -from PyQt4 import QtCore +from PyQt4 import QtCore, QtGui -from openlp.core.common import AppLocation, Settings +from openlp.core.common import AppLocation, Settings, RegistryProperties +from openlp.core.lib import build_icon from openlp.plugins.remotes.lib import HttpRouter @@ -95,12 +96,13 @@ class HttpThread(QtCore.QThread): self.http_server.start_server() -class OpenLPServer(): +class OpenLPServer(RegistryProperties): def __init__(self): """ Initialise the http server, and start the server of the correct type http / https """ - log.debug('Initialise httpserver') + super(OpenLPServer, self).__init__() + log.debug('Initialise OpenLP') self.settings_section = 'remotes' self.http_thread = HttpThread(self) self.http_thread.start() @@ -112,25 +114,47 @@ class OpenLPServer(): address = Settings().value(self.settings_section + '/ip address') if Settings().value(self.settings_section + '/https enabled'): port = Settings().value(self.settings_section + '/https port') - self.httpd = HTTPSServer((address, port), CustomHandler) - log.debug('Started ssl httpd...') + self.start_server_instance(address, port, HTTPSServer) else: port = Settings().value(self.settings_section + '/port') - loop = 1 - while loop < 3: - try: - self.httpd = ThreadingHTTPServer((address, port), CustomHandler) - except OSError: - loop += 1 - time.sleep(0.1) - except: - log.error('Failed to start server ') - log.debug('Started non ssl httpd...') + self.start_server_instance(address, port, ThreadingHTTPServer) if hasattr(self, 'httpd') and self.httpd: self.httpd.serve_forever() + icon = QtGui.QImage(':/remote/network_server.png') + icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + overlay = QtGui.QImage(':/remote/network_ssl.png') + overlay = overlay.scaled(40, 40, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + painter = QtGui.QPainter(icon) + painter.drawImage(0, 0, overlay) + painter.end() + print("Hi") + self.default_theme_label.setText("hello") + self.default_theme_label.setIcon(build_icon(icon)) + self.default_theme_label.show() else: log.debug('Failed to start server') + def start_server_instance(self, address, port, server_class): + """ + Start the server + + :param address: The server address + :param port: The run port + :param server_class: the class to start + """ + loop = 1 + while loop < 4: + try: + self.httpd = server_class((address, port), CustomHandler) + log.debug("Server started for class %s %s %d" % (server_class, address, port)) + except OSError: + log.debug("failed to start http server thread state %d %s" % + (loop, self.http_thread.isRunning() is True)) + loop += 1 + time.sleep(0.1) + except: + log.error('Failed to start server ') + def stop_server(self): """ Stop the server diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 393f08dd9..0e3825bdd 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -30,6 +30,8 @@ import logging import time +from PyQt4 import QtGui + from openlp.core.lib import Plugin, StringContent, translate, build_icon from openlp.plugins.remotes.lib import RemoteTab, OpenLPServer @@ -67,6 +69,13 @@ class RemotesPlugin(Plugin): log.debug('initialise') super(RemotesPlugin, self).initialise() self.server = OpenLPServer() + self.default_theme_label = QtGui.QToolButton(self.main_window.status_bar) + self.default_theme_label.setCheckable(False) + self.default_theme_label.setAutoRaise(True) + self.default_theme_label.setObjectName('default_theme_label') + self.main_window.status_bar.insertPermanentWidget(2, self.default_theme_label) + self.default_theme_label.hide() + self.server.default_theme_label = self.default_theme_label def finalise(self): """ @@ -108,5 +117,5 @@ class RemotesPlugin(Plugin): """ log.debug('remote config changed') self.finalise() - time.sleep(0.5) + time.sleep(1) self.initialise() diff --git a/resources/images/network_auth.png b/resources/images/network_auth.png new file mode 100644 index 0000000000000000000000000000000000000000..45e7a5c1788d214b1e63abdb2746cdfb938598ec GIT binary patch literal 608 zcmV-m0-ybfP)FV7f{fuWJai358$p+0R>_w(?=`@XQp(zNRTr6`JD zTAEkp{ksO;ZujtdCY#H=&xmo#D8?zHq~0av#q+hC!|52_5%i3mA6;Et$!7~`aon{F z*AN~dJVdyPjNBZNXe=V3x%;nOF2`t_Q?-rRa_Z7Xb7RP*xXG&5;V_^F)Ze>u1Ft$d+)n z_Y8$%;W1F%X&EP>0Z#l3bp8^Mc%UqV?hM_A55Oj{ z4t#=({S(CF@j2k-zi!DeJ$=2jlwK6ej77{h%yMrzC}SQ^2{7#TAP0O`e5peIjbzhV u86Urp0tWun*zuQ;F5q~}CxOPEyz4hAGR?5R1SdxT0000swx|LFf3SGE$k@yK*Te>U# z3R9R5P`Z&)XX9cjh!m!1y0BF;OpPYby!Z0nz2|oEUSeWpCMkJ01d{vCyZ3j_|D1C# zq0jN-ix+<3lf1}gGL%k#K*>Y`ni;>ndWFv(KQ_MKqGr=Em$ge%sr<=bKYNzwXI;@R zz*Vg_;xrvut6d4#bt#!lQYx9GqoX5ACK5sjNz7U(rKDy(((k%`17ydu$mMdFDHKqz z*E{o;lmGxC0+9d_VUW=`fYusXD=4iYqD_3QVUMOGfLmJ=2Y@jK0D%Y)B7DvD1Dxk) zBOnUBCj!L>02tE_Hz8?BOjQ4dX-9w%!k8EVfZGTpq(ruU8O>7oA;KUb7#tw-zCC9E zkO;%xmH@Fy5INTkAcVl{*MD^E2Frj!0N5asxu?{a84L6C;kE<_(Y6{kKp5;c!GH3? z05Ht(JP%3*!v_e001dl=R?CO)`=S1w$}mt`!*xA4jss?np%F2o)oLLK0tCUWhqrQs zK+L8mGDFP))(pPmdACI2Gad-Q>euk*#>VyaH7v`5jQW4iHilqK2*_~&q|<3kOiUn~ z%_5V@pwkw+$~2UKVK@c}{2;*f^%Yva53O}i1WW|L+JsUWjwc5o1ekSqcLInY1che+ znXp{rkRbGs!TL7I*ciC3i(2gpj^m)&Y{GF|IIcVV2(aPsP7r0e0bsPohf-pEd>s4x zzvAWoOQcdsj969-0L;*=JEf?Ug6}vOYc!yO00e?{}LeINh4eGAWZQ79DP zdLE|Vyn*Ao`25Ke%oi7MesK{`Cj>&hNf0s*AA+?8h%ol_DQ<3VVB0ntwvA@93D&Uy z071)#){K_#!w&+aMn{ofS%K%e;rXB$TIt?O8OE4<^hicO#{f(NSXf$G`k_=RnR2;o z0DJ+U7(Gh^!0gD|3yZfDHQ$*q;VX4OK5kitbBF%OxIfD@bD1UJGz`P2KjtGx4ypq zO^?n(pjxe-0C+z@tyZJ6v$IaWCn9*B2ivw$sZ`MA*uC9SN(s;NdM+hWO4RFhYmgie z_xx9-Qt1f5r|$wN7K_ifwzf9ztU&1r;P)(<+F=08q_00t&F1I%F#z!2z#$c(OoM@BmdoR*iyz z*z*Dgm?;aVIHxQOoC9YDX3HNE9{l7AL>!(vR2-fx9e4_&D+m7@K~?ZQ@I52tgDr%# zI?^7bJVX2?C;6!YJG+6uH;wH;lOVo2JV9(6~ytwJuv$Vf4-@_QLj?2 P00000NkvXXu0mjf+JX4) literal 0 HcmV?d00001 diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 6af0e77a5..79036f08f 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -149,6 +149,11 @@ messagebox_info.png messagebox_warning.png + + network_server.png + network_ssl.png + network_auth.png + song_usage_active.png song_usage_inactive.png