From 382dbce4acc7f0b8e2931b372ba2230ab3424559 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Thu, 8 Apr 2021 15:43:26 -0500 Subject: [PATCH] added qrcode for dropbox setup --- addon.xml | 4 +- changelog.md | 4 + default.py | 1 - .../resource.language.en_gb/strings.po | 4 +- resources/lib/authorizers.py | 40 +++++++++- .../default/1080i/script-backup-qrcode.xml | 74 ++++++++++++++++++ .../skins/default/media/background-black.png | Bin 0 -> 166 bytes resources/skins/default/media/dialog-bg.png | Bin 0 -> 1891 bytes .../skins/default/media/dialogbutton-fo.png | Bin 0 -> 1082 bytes .../skins/default/media/dialogbutton-nofo.png | Bin 0 -> 1078 bytes 10 files changed, 122 insertions(+), 5 deletions(-) create mode 100644 resources/skins/default/1080i/script-backup-qrcode.xml create mode 100644 resources/skins/default/media/background-black.png create mode 100644 resources/skins/default/media/dialog-bg.png create mode 100644 resources/skins/default/media/dialogbutton-fo.png create mode 100644 resources/skins/default/media/dialogbutton-nofo.png diff --git a/addon.xml b/addon.xml index 400369a..59035c9 100644 --- a/addon.xml +++ b/addon.xml @@ -1,11 +1,12 @@  + name="Backup" version="1.6.7~beta2" provider-name="robweber"> + executable @@ -91,6 +92,7 @@ Version 1.6.7 - fixed issue with RunScript not launching Advanced Editor in some cases + - added qr code for Dropbox setup diff --git a/changelog.md b/changelog.md index eb8df80..28f780f 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased](https://github.com/robweber/xbmcbackup/compare/matrix-1.6.5...robweber:matrix) +### Added + +- added QRcode when setting up Dropbox, uses pyqrcode + ### Fixed - fixed issue when using ```RunScript()``` within settings to launch Advanced Editor diff --git a/default.py b/default.py index bef946a..8fb563d 100644 --- a/default.py +++ b/default.py @@ -63,7 +63,6 @@ if("mode" in params): elif(params['mode'] == 'launcher'): mode = LAUNCHER - # if mode wasn't passed in as arg, get from user if(mode == -1): # by default, Backup,Restore,Open Settings diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 7f6da03..95402f5 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -213,8 +213,8 @@ msgid "Removing backup" msgstr "Removing backup" msgctxt "#30056" -msgid "Go to this URL to authorize" -msgstr "Go to this URL to authorize" +msgid "Scan or click this URL to authorize, click OK AFTER completion" +msgstr "Scan or click this URL to authorize, click OK AFTER completion" msgctxt "#30057" msgid "Click OK AFTER completion" diff --git a/resources/lib/authorizers.py b/resources/lib/authorizers.py index 028b3f9..3923be9 100644 --- a/resources/lib/authorizers.py +++ b/resources/lib/authorizers.py @@ -1,5 +1,6 @@ import xbmcgui import xbmcvfs +import pyqrcode import resources.lib.tinyurl as tinyurl import resources.lib.utils as utils @@ -11,6 +12,30 @@ except ImportError: pass +class QRCode(xbmcgui.WindowXMLDialog): + def __init__(self, *args, **kwargs): + self.image = kwargs["image"] + self.text = kwargs["text"] + self.url = kwargs['url'] + + def onInit(self): + self.imagecontrol = 501 + self.textbox1 = 502 + self.textbox2 = 504 + self.okbutton = 503 + self.showdialog() + + def showdialog(self): + self.getControl(self.imagecontrol).setImage(self.image) + self.getControl(self.textbox1).setText(self.text) + self.getControl(self.textbox2).setText(self.url) + self.setFocus(self.getControl(self.okbutton)) + + def onClick(self, controlId): + if (controlId == self.okbutton): + self.close() + + class DropboxAuthorizer: APP_KEY = "" APP_SECRET = "" @@ -52,7 +77,20 @@ class DropboxAuthorizer: # print url in log utils.log("Authorize URL: " + url) - xbmcgui.Dialog().ok(utils.getString(30010), '%s\n%s\n%s' % (utils.getString(30056), utils.getString(30057), str(tinyurl.shorten(url), 'utf-8'))) + + # create a QR Code + shortUrl = str(tinyurl.shorten(url), 'utf-8') + imageFile = xbmcvfs.translatePath(utils.data_dir() + '/qrcode.png') + qrIMG = pyqrcode.create(shortUrl) + qrIMG.png(imageFile, scale=10) + + # show the dialog prompt to authorize + qr = QRCode("script-backup-qrcode.xml", utils.addon_dir(), "default", image=imageFile, text=utils.getString(30056), url=shortUrl) + qr.doModal() + + # cleanup + del qr + xbmcvfs.delete(imageFile) # get the auth code code = xbmcgui.Dialog().input(utils.getString(30027) + ' ' + utils.getString(30103)) diff --git a/resources/skins/default/1080i/script-backup-qrcode.xml b/resources/skins/default/1080i/script-backup-qrcode.xml new file mode 100644 index 0000000..fbff708 --- /dev/null +++ b/resources/skins/default/1080i/script-backup-qrcode.xml @@ -0,0 +1,74 @@ + + + + 502 + 345 + + + + + + + + + + + + -1920 + -1080 + 5760 + 3240 + WindowOpen + WindowClose + background-black.png + + + 0 + 0 + 915 + 450 + dialog-bg.png + + + 0 + 20 + 915 + 300 + font12_title + center + top + FF000000 + + + 0 + 60 + 915 + 300 + font12_title + center + top + FF000000 + + + 300 + 80 + 300 + 300 + keep + + + 302 + 350 + 300 + 90 + font12_title + FFF0F0F0 + 20 + + center + center + dialogbutton-fo.png + dialogbutton-nofo.png + + + diff --git a/resources/skins/default/media/background-black.png b/resources/skins/default/media/background-black.png new file mode 100644 index 0000000000000000000000000000000000000000..2ff1770d5334378c2c7646c1c8b1e6fc95c0b1f4 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^EFjDXBp4dI7GDNZ3dtTpz6=aiY77hwEes65fII(3R2di=ni&{= z{s+=885l|p7#Ln9FfdrnU|pA>)84XBnW$=lt9;eUJonf*W>XMsm#F#`j)5C}6~ zx?A@LD9B#o>FdgVpOckAhB=F8);|UYwiBK%jv*Dd-d;9jWH8`q*wD4IzPEIvtO{4f z3|66M?)PWyl37GiI1|Gq$`eK?uJqbQGysspJ$9gRbfGSvx~fvR4*@EUeg)TYBm zHivV{u%scAQGE>KnKoflRCkYOtJ)OAU>r^uR-9gWu}A|$kJG1PN?5TIuwV?89XMJZ z$!g^(P1Nb0)T90+1eB&3Bo z4hRCnMPq`%9RqxrF+t)xLG`1FH%HG)8F`@Ui|pcb0b^TY*6ijd~E!mLGKo`w88o9W9oA1h&5)M=`aGl(Jl`S{h8rahhl_hM`M+qRb0IvWpXCj^mPo*wx=9 zM-vG#F%XlZkz|c4BW=cn7Orvib*@;K>oH33 zsW#@;kpmA-@69_FnwM$>4peA=sFv0u8}-Laf@I|A;L8cv%{Jez*7B?l157 hD+IU!q*V&;rGCF}?zsHs&O!e*r;;P`)Bdrme*gv`OLPDL literal 0 HcmV?d00001 diff --git a/resources/skins/default/media/dialogbutton-nofo.png b/resources/skins/default/media/dialogbutton-nofo.png new file mode 100644 index 0000000000000000000000000000000000000000..5d242794fb443cf677027a6b6554f70c763b77ff GIT binary patch literal 1078 zcmaJ=&ui0A9M5VUUDt%%$Lu^b@-?^5Z#~&f{DaFQ6K3XfC8O23m%oU}-C`3^ikOeGjH7>eQH7 zsp6`7MbeSQXaR=tEr+lvDm~*nn!XA#ScWU6Ez^f@-qOG{WO`9hIn~L+x;ek)!iBA3 zMc-Q0QwBXV4br|u1T2U(;9G09C;2kn)Ro9OIA&?kgy2<~J`Sp?mOvJ{5C}{nrgJ_EJubI<0mCSl;TOy`e@?KHEL2>$+vuwolMs;b|jWYzPbh9~jKz2a{?l21&DJf9Qi1VK!R zlbK9P;6*;qwYdt?H!Nu5HrF`ePW9vl&0smivjSc7CN%OcvOqIw$?P4A&{MC)HG0P) z_T;i87&f@tuB&bzk^TvmoyH}bPU}OP^t($MJJG*1Kpw@Df|9BDpT2$mFtiN@XES{9 z{oc8cd#~qyt%n}=|NKIYEtP-QpFPd(Umu~uk>LkaC>$wKeWCF9HnC^lEq*#kPtcEF z;o8oC|MJYi{=MB~7pfaOOBhi=?CD`*LlI*8!jbQ{<)f>Q{tWD1o37pI=yqYh4qglm YQrV;E;r)@mgWx3>az*9E+>Kj*0Xq~#O8@`> literal 0 HcmV?d00001