use selection input for cancel/apply/ok
This commit is contained in:
parent
00ab9ff499
commit
077f35ec5c
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from basemode import BaseMode
|
from basemode import BaseMode
|
||||||
|
from input_popup import SelectInput
|
||||||
|
|
||||||
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
|
@ -60,9 +62,9 @@ class Preferences(BaseMode):
|
||||||
_("Interface"), _("Other"), _("Daemon"), _("Queue"), _("Proxy"),
|
_("Interface"), _("Other"), _("Daemon"), _("Queue"), _("Proxy"),
|
||||||
_("Cache")] # , _("Plugins")]
|
_("Cache")] # , _("Plugins")]
|
||||||
self.cur_cat = 0
|
self.cur_cat = 0
|
||||||
self.cur_action = 0
|
|
||||||
self.popup = None
|
self.popup = None
|
||||||
self.messages = deque()
|
self.messages = deque()
|
||||||
|
self.action_input = None
|
||||||
|
|
||||||
self.active_zone = ZONE.CATEGORIES
|
self.active_zone = ZONE.CATEGORIES
|
||||||
|
|
||||||
|
@ -70,6 +72,8 @@ class Preferences(BaseMode):
|
||||||
self.div_off = 15
|
self.div_off = 15
|
||||||
|
|
||||||
BaseMode.__init__(self, stdscr, encoding)
|
BaseMode.__init__(self, stdscr, encoding)
|
||||||
|
self.action_input = SelectInput(self,None,None,["Cancel","Apply","OK"],0)
|
||||||
|
self.refresh()
|
||||||
|
|
||||||
def __draw_catetories(self):
|
def __draw_catetories(self):
|
||||||
for i,category in enumerate(self.categories):
|
for i,category in enumerate(self.categories):
|
||||||
|
@ -82,18 +86,10 @@ class Preferences(BaseMode):
|
||||||
self.stdscr.vline(1,self.div_off,'|',self.rows-2)
|
self.stdscr.vline(1,self.div_off,'|',self.rows-2)
|
||||||
|
|
||||||
def __draw_actions(self):
|
def __draw_actions(self):
|
||||||
c = self.cols-22
|
if self.action_input:
|
||||||
|
selected = self.active_zone == ZONE.ACTIONS
|
||||||
self.stdscr.hline(self.rows-3,self.div_off+1,"_",self.cols)
|
self.stdscr.hline(self.rows-3,self.div_off+1,"_",self.cols)
|
||||||
if self.active_zone != ZONE.ACTIONS:
|
self.action_input.render(self.stdscr,self.rows-2,self.cols,selected,self.cols-22)
|
||||||
self.add_string(self.rows-2,"[Cancel] [Apply] [OK]",col=c)
|
|
||||||
else:
|
|
||||||
if self.cur_action == 0:
|
|
||||||
self.add_string(self.rows-2,"[{!black,white,bold!}Cancel{!white,black!}] [Apply] [OK]",col=c)
|
|
||||||
elif self.cur_action == 1:
|
|
||||||
self.add_string(self.rows-2,"[Cancel] [{!black,white,bold!}Apply{!white,black!}] [OK]",col=c)
|
|
||||||
elif self.cur_action == 2:
|
|
||||||
self.add_string(self.rows-2,"[Cancel] [Apply] [{!black,white,bold!}OK{!white,black!}]",col=c)
|
|
||||||
|
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
if self.popup == None and self.messages:
|
if self.popup == None and self.messages:
|
||||||
|
@ -126,19 +122,15 @@ class Preferences(BaseMode):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __actions_read(self, c):
|
def __actions_read(self, c):
|
||||||
# Navigate actions
|
self.action_input.handle_read(c)
|
||||||
if c == curses.KEY_LEFT:
|
if c == curses.KEY_ENTER or c == 10:
|
||||||
self.cur_action = max(0,self.cur_action-1)
|
|
||||||
elif c == curses.KEY_RIGHT:
|
|
||||||
self.cur_action = min(2,self.cur_action+1)
|
|
||||||
elif c == curses.KEY_ENTER or c == 10:
|
|
||||||
# take action
|
# take action
|
||||||
if self.cur_action == 0: # cancel
|
if self.action_input.selidx == 0: # cancel
|
||||||
self.back_to_parent()
|
self.back_to_parent()
|
||||||
elif self.cur_action == 1: # apply
|
elif self.action_input.selidx == 1: # apply
|
||||||
# TODO: Actually apply
|
# TODO: Actually apply
|
||||||
pass
|
pass
|
||||||
elif self.cur_action == 2: # OK
|
elif self.action_input.selidx == 2: # OK
|
||||||
# TODO: Actually apply
|
# TODO: Actually apply
|
||||||
self.back_to_parent()
|
self.back_to_parent()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue