Skip to content

Commit

Permalink
Adjustable pool size + hiding dialogs is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
metate committed Mar 21, 2016
1 parent 0803e1e commit 0f8fc9c
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 51 deletions.
6 changes: 5 additions & 1 deletion plugin.video.meta/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def get_string(t):
_ALL['automatic movies library server'] = 32304
_ALL['set added time to release date'] = 32305
_ALL['use simple selection dialog'] = 32402
_ALL['attempt to hide keyboard while meta is searching (may not work or cause issues on some skins)'] = 32403
_ALL['number of simultaneous searches'] = 32404
_ALL['attempt to hide dialogs while meta is searching'] = 32410
_ALL['hide progress dialogs'] = 32411
_ALL['hide information dialogs'] = 32412
_ALL['hide keyboard dialog'] = 32413
_ALL['would you like to automatically set meta as a movies video source?'] = 31000
_ALL['genres'] = 31001
_ALL['select stream...'] = 31002
Expand Down
20 changes: 18 additions & 2 deletions plugin.video.meta/resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,24 @@ msgctxt "#32402"
msgid "Use simple selection dialog"
msgstr ""

msgctxt "#32403"
msgid "Attempt to hide keyboard while Meta is searching (may not work or cause issues on some skins)"
msgctxt "#32404"
msgid "Number of simultaneous searches"
msgstr ""

msgctxt "#32410"
msgid "Attempt to hide dialogs while Meta is searching"
msgstr ""

msgctxt "#32411"
msgid "Hide progress dialogs"
msgstr ""

msgctxt "#32412"
msgid "Hide information dialogs"
msgstr ""

msgctxt "#32413"
msgid "Hide keyboard dialog"
msgstr ""

msgctxt "#31000"
Expand Down
24 changes: 24 additions & 0 deletions plugin.video.meta/resources/language/Hebrew/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,34 @@ msgctxt "#32304"
msgid "Automatic movies library server"
msgstr "שרת עבור קיר סרטים אוטומטי"

msgctxt "#32305"
msgid "Set added time to release date"
msgstr "קבע זמן הוספה כזמן שחרור הסרט או פרק"

msgctxt "#32402"
msgid "Use simple selection dialog"
msgstr "השתמש בדיאלוג בחירה פשוט"

msgctxt "#32404"
msgid "Number of simultaneous searches"
msgstr "מספר חיפושים לבצע במקביל"

msgctxt "#32410"
msgid "Attempt to hide dialogs while Meta is searching"
msgstr "הסתר חלונות משנה בזמן שהתוסף מבצע חיפוש"

msgctxt "#32411"
msgid "הסתר חלון התקדמות"
msgstr ""

msgctxt "#32412"
msgid "הסתר התראות מידע"
msgstr ""

msgctxt "#32413"
msgid "הסתר מקלדת"
msgstr ""

msgctxt "#31000"
msgid "Would you like to automatically set Meta as a movies video source?"
msgstr "האם ברצונך שאגדיר באופן אוטומטי את ספריית התוסף כמקור סרטי וידאו?"
Expand Down
74 changes: 40 additions & 34 deletions plugin.video.meta/resources/lib/meta/gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@
from threading import Thread, RLock
from xbmcswift2 import xbmc, xbmcgui, xbmcaddon
from meta import plugin
from settings import SETTING_ADVANCED_KEYBOARD_HACKS
from settings import *

def wait_for_dialog(dialog, timeout=None, interval=500):
return wait_for_any_dialog([dialog], timeout, interval)

def wait_for_any_dialog(dialogs, timeout=None, interval=500):
def wait_for_dialog(dialog_id, timeout=None, interval=500):
start = time.time()

while not xbmc.abortRequested and (not timeout or time.time() - start < timeout):
any_active = bool(filter(bool, [xbmc.getCondVisibility("Window.IsActive(%s)" % x) for x in dialogs]))

if any_active:
return True

while not xbmc.getCondVisibility("Window.IsActive(%s)" % dialog_id):
if xbmc.abortRequested or \
(timeout and time.time() - start >= timeout):
return False
xbmc.sleep(interval)

return False
return True

def ok(title, msg):
xbmcgui.Dialog().ok(title, msg)
Expand All @@ -38,7 +33,7 @@ def select_ext(title, populator, tasks_count):
dlg = SelectorDialog("DialogSelect.xml", addonPath, title = title,
populator = populator, steps=tasks_count)

with ExtendedDialogHacks(dlg):
with ExtendedDialogHacks():
dlg.doModal()
selection = dlg.get_selection()
del dlg
Expand All @@ -56,47 +51,58 @@ def __init__(self):
self.addControl(control_fanart)

class ExtendedDialogHacks(object):
def __init__(self, dlg):
self.dlg = dlg
def __init__(self):
self.active = False


self.hide_progress = False
self.hide_info = False

self.autohidedialogs = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS, converter=bool)
if self.autohidedialogs:
self.hide_progress = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_PROGRESS, converter=bool)
self.hide_info = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_INFO, converter=bool)

if not self.hide_progress and not self.hide_info:
self.autohidedialogs = False

def __enter__(self):
self.active = True

self.numeric_keyboard = None
# self.numeric_keyboard = None
self.fanart_window = FanArtWindow()

## Keyboard hack
if plugin.get_setting(SETTING_ADVANCED_KEYBOARD_HACKS, converter=bool):
self.numeric_keyboard = xbmcgui.Window(10109)
Thread(target = lambda: self.numeric_keyboard.show()).start()
wait_for_dialog('numericinput', interval=50)
# if plugin.get_setting(SETTING_ADVANCED_KEYBOARD_HACKS, converter=bool):
# self.numeric_keyboard = xbmcgui.Window(10109)
# Thread(target = lambda: self.numeric_keyboard.show()).start()
# wait_for_dialog('numericinput', interval=50)

# Show fanart background
self.fanart_window.show()

# Run background task
Thread(target = self.background_task).start()
if self.autohidedialogs:
Thread(target = self.background_task).start()

def background_task(self):
xbmc.sleep(1000)
while not xbmc.abortRequested and self.active:
active_window = xbmcgui.getCurrentWindowDialogId()
if active_window in [10101,10151,10107]:
xbmc.executebuiltin("Dialog.Close(%d, true)" % active_window)
if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
xbmc.executebuiltin('Dialog.Close(infodialog, true)')

if self.hide_progress:
active_window = xbmcgui.getCurrentWindowDialogId()
if active_window in [10101,10151]:
xbmc.executebuiltin("Dialog.Close(%d, true)" % active_window)
if self.hide_info:
if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
xbmc.executebuiltin('Dialog.Close(infodialog, true)')
xbmc.sleep(100)
del self.dlg

def __exit__(self, exc_type, exc_value, traceback):
self.active = False

if self.numeric_keyboard is not None:
self.numeric_keyboard.close()
del self.numeric_keyboard
xbmc.executebuiltin("Dialog.Close(numericinput, true)")
# if self.numeric_keyboard is not None:
# self.numeric_keyboard.close()
# del self.numeric_keyboard
# xbmc.executebuiltin("Dialog.Close(numericinput, true)")

self.fanart_window.close()
del self.fanart_window
Expand Down
5 changes: 3 additions & 2 deletions plugin.video.meta/resources/lib/meta/play/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from meta.play.players import get_players
from meta.play.lister import Lister

from settings import SETTING_MOVIES_ENABLED_PLAYERS, SETTING_TV_ENABLED_PLAYERS
from settings import *
from language import get_string as _


Expand Down Expand Up @@ -79,7 +79,8 @@ def get_video_link(players, params, mode, use_simple=False):
pDialog = xbmcgui.DialogProgress()
pDialog.create('Meta', 'Working...')
dialogs.wait_for_dialog("progressdialog", 5)
populator = lambda : execute(resolve_f, players, lister.stop_flag)
pool_size = plugin.get_setting(SETTING_POOL_SIZE, converter=int)
populator = lambda : execute(resolve_f, players, lister.stop_flag, pool_size)
selection = dialogs.select_ext(_("Play with..."), populator, len(players))

else:
Expand Down
19 changes: 13 additions & 6 deletions plugin.video.meta/resources/lib/meta/play/lister.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# These are replace with whitespace in labels and parameters
IGNORE_CHARS = ('.', '%20')#('+', '-', '%20', '.', ' ')

from settings import *


class KeyboardMonitor(Thread):
def __init__(self):
Expand All @@ -19,7 +21,9 @@ def __init__(self):
self.active = True
self.lock = Lock()
self.search_term = None


self.hide_keyboard = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS, converter=bool) and plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_KEYBOARD, converter=bool)

def stop(self):
self.active = False

Expand All @@ -43,13 +47,15 @@ def run(self):
while self.active and not xbmc.abortRequested:
if dialogs.wait_for_dialog("virtualkeyboard", timeout=5,interval=100):
if self.search_term is not None:
xbmc.executebuiltin('Dialog.Close(virtualkeyboard, true)')
if self.hide_keyboard:
xbmc.executebuiltin('Dialog.Close(virtualkeyboard, true)')

# Send search term
text = self.prep_search_str(self.search_term)
RPC.Input.SendText(text=text, done=True)
# TODO: needed?
while xbmc.getCondVisibility("Window.IsActive(virtualkeyboard)"):
xbmc.sleep(100)
#while xbmc.getCondVisibility("Window.IsActive(virtualkeyboard)"):
# xbmc.sleep(100)
self.release()

def regex_escape(string):
Expand Down Expand Up @@ -238,8 +244,9 @@ def _browse_external(self, path, guidance, parameters, unescaped_parameters, dep
except:
break
finally:
if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
xbmc.executebuiltin('Dialog.Close(infodialog, true)')
#if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
# xbmc.executebuiltin('Dialog.Close(infodialog, true)')

if keyboard_hint is not None:
keyboard_hint = None

Expand Down
22 changes: 17 additions & 5 deletions plugin.video.meta/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@

<!-- Library -->
<category label="32300">
<!-- Force library update -->
<setting label="32303" type="action" action="RunPlugin(plugin://plugin.video.meta/update_library)"/>

<!-- Set date to release date -->
<setting label="32305" type="bool" id="library_set_date" default="false"/>

<!-- Movies -->
Expand All @@ -65,16 +69,24 @@

<!-- Simple selector -->
<setting label="32402" type="bool" id="use_simple_selector" default="false"/>


<!-- Attempt to hide keyboard -->
<setting label="32403" type="bool" id="advanced_keyboard_hacks" default="false" enable="eq(-1,false)"/>
<!-- Attempt to hide dialogs -->
<setting label="32410" type="bool" id="auto_hide_dialogs" default="false" enable="eq(-1,false)"/>

<setting subsetting="true" label="32411" type="bool" id="auto_hide_dialogs_progress" default="true" enable="eq(-1,true)"/>

<setting subsetting="true" label="32412" type="bool" id="auto_hide_dialogs_info" default="true" enable="eq(-2,true)"/>

<setting subsetting="true" label="32413" type="bool" id="auto_hide_dialogs_keyboard" default="true" enable="eq(-3,true)"/>


<!-- Simple selector -->
<setting label="32404" type="slider" id="pool_size" default="5" range="1,15" option="int" />

<!-- Clear cache -->
<setting label="32401" type="action" action="RunPlugin(plugin://plugin.video.meta/clear_cache)"/>

<!-- Force library update -->
<setting label="32303" type="action" action="RunPlugin(plugin://plugin.video.meta/update_library)"/>


</category>

Expand Down
6 changes: 5 additions & 1 deletion plugin.video.meta/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@
SETTING_MOVIES_LIBRARY_FOLDER = "movies_library_folder"
SETTING_TV_LIBRARY_FOLDER = "tv_library_folder"
SETTING_USE_SIMPLE_SELECTOR = "use_simple_selector"
SETTING_ADVANCED_KEYBOARD_HACKS = "advanced_keyboard_hacks"
SETTING_AUTO_HIDE_DIALOGS = "auto_hide_dialogs"
SETTING_AUTO_HIDE_DIALOGS_PROGRESS = "auto_hide_dialogs_progress"
SETTING_AUTO_HIDE_DIALOGS_INFO = "auto_hide_dialogs_info"
SETTING_AUTO_HIDE_DIALOGS_KEYBOARD = "auto_hide_dialogs_keyboard"
SETTING_POOL_SIZE = "pool_size"

0 comments on commit 0f8fc9c

Please sign in to comment.