Permalink
Browse files

"Add with high priority" action.

  • Loading branch information...
1 parent 461d2f0 commit 49acdf04195c225c1d90eeef2187bbbc09211da6 @tsufeki committed Jul 10, 2013
Showing with 68 additions and 49 deletions.
  1. +10 −4 qygmy/browser.py
  2. +10 −10 qygmy/lists.py
  3. +35 −31 qygmy/translations/qygmy_pl.ts
  4. +9 −0 qygmy/ui/browser.ui
  5. +4 −4 qygmy/uiutils.py
View
@@ -63,7 +63,9 @@ def closeEvent(self, e):
def contextMenuEvent(self, e):
e.accept()
- self.ui.add.setVisible(self.current_view.can_add_to_queue())
+ can_add = self.current_view.can_add_to_queue()
+ for act in ('add', 'addplay', 'replace', 'replaceplay', 'addhighprio'):
+ getattr(self.ui, act).setVisible(can_add)
self.ui.remove.setVisible(self.current_view.can_remove())
self.ui.rename.setVisible(self.current_view.can_rename())
self.ui.details.setVisible(self.current_view.details() is not None)
@@ -72,7 +74,7 @@ def contextMenuEvent(self, e):
def on_state_changed(self, state):
c = state != 'disconnect'
for act in ('search', 'add', 'addplay', 'replace', 'replaceplay',
- 'remove', 'rename', 'details'):
+ 'addhighprio', 'remove', 'rename', 'details'):
getattr(self.ui, act).setEnabled(c)
self.ui.dbpath.setEnabled(c)
self.ui.plpath.setEnabled(c)
@@ -88,8 +90,8 @@ def on_search_triggered(self):
self.srv.search.cd((self.ui.what.currentIndex(), self.ui.query.text()))
@Slot()
- def on_add_triggered(self, play=False, replace=False):
- self.current_view.add_selected_to_queue(play, replace)
+ def on_add_triggered(self, play=False, replace=False, priority=0):
+ self.current_view.add_selected_to_queue(play, replace, priority)
@Slot()
def on_addplay_triggered(self):
@@ -104,6 +106,10 @@ def on_replaceplay_triggered(self):
self.on_add_triggered(True, True)
@Slot()
+ def on_addhighprio_triggered(self):
+ self.on_add_triggered(priority=1)
+
+ @Slot()
def on_remove_triggered(self):
self.current_view.remove_selected()
View
@@ -263,10 +263,10 @@ def ls(self, _=None):
return self.conn.playlistinfo()
@mpd_cmd(fallback=False)
- def add(self, items, pos=None, play=False, replace=False, high_priority=False):
+ def add(self, items, pos=None, play=False, replace=False, priority=0):
if replace:
self.conn.clear()
- r = super().add(items, pos, high_priority=high_priority)
+ r = super().add(items, pos, priority=priority)
if play and r:
if replace:
playpos = 0
@@ -275,20 +275,20 @@ def add(self, items, pos=None, play=False, replace=False, high_priority=False):
self.conn.play(playpos)
return r
- def can_add_directly(self, item, pos, high_priority):
- return 'file' in item or ('playlist' in item and pos is None and not high_priority)
+ def can_add_directly(self, item, pos, priority):
+ return 'file' in item or ('playlist' in item and pos is None and priority == 0)
- def add_one(self, item, pos, last, high_priority):
- if 'playlist' in item and pos is None and not high_priority:
+ def add_one(self, item, pos, last, priority):
+ if 'playlist' in item and pos is None and priority == 0:
self.conn.load(item['playlist'])
elif 'file' in item:
if pos is None:
pos = last
self.conn.add(item['file'])
else:
self.conn.addid(item['file'], pos)
- if high_priority:
- self.conn.prio(1, pos)
+ if priority != 0:
+ self.conn.prio(priority, pos)
def remove_one(self, item):
self.conn.deleteid(item['id'])
@@ -332,10 +332,10 @@ class BrowserList(SongList):
def can_add_to_queue(self, positions):
return len(positions) > 0
- def add_to_queue(self, positions, play=False, replace=False, high_priority=False):
+ def add_to_queue(self, positions, play=False, replace=False, priority=0):
if self.can_add_to_queue(positions):
self.parent.queue.add([self[i] for i in sorted(positions)],
- play=play, replace=replace, high_priority=high_priority)
+ play=play, replace=replace, priority=priority)
def item_chosen(self, pos):
self.add_to_queue([pos])
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.0" language="pl">
+<!DOCTYPE TS><TS version="1.1" language="pl">
<context>
<name>Browser</name>
<message>
- <location filename="../browser.py" line="117"/>
+ <location filename="../browser.py" line="123"/>
<source>Details</source>
<translation>Szczegóły</translation>
</message>
@@ -220,7 +219,7 @@
<context>
<name>Playlists</name>
<message>
- <location filename="../lists.py" line="369"/>
+ <location filename="../lists.py" line="375"/>
<source>New playlist</source>
<translation>Nowa lista</translation>
</message>
@@ -292,140 +291,145 @@
<context>
<name>browser</name>
<message>
- <location filename="../ui/browser.py" line="238"/>
+ <location filename="../ui/browser.py" line="242"/>
<source>Music database</source>
<translation>Baza muzyki</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="239"/>
+ <location filename="../ui/browser.py" line="243"/>
<source>&amp;Database</source>
<translation>&amp;Baza</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="240"/>
+ <location filename="../ui/browser.py" line="244"/>
<source>&amp;Playlists</source>
<translation>&amp;Listy</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="241"/>
+ <location filename="../ui/browser.py" line="245"/>
<source>Tag to search</source>
<translation>Szukany tag</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="242"/>
+ <location filename="../ui/browser.py" line="246"/>
<source>Any</source>
<translation>Wszystko</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="243"/>
+ <location filename="../ui/browser.py" line="247"/>
<source>Title</source>
<translation>Tytuł</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="244"/>
+ <location filename="../ui/browser.py" line="248"/>
<source>Artist</source>
<translation>Artysta</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="245"/>
+ <location filename="../ui/browser.py" line="249"/>
<source>Album</source>
<translation>Album</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="246"/>
+ <location filename="../ui/browser.py" line="250"/>
<source>Comment</source>
<translation>Komentarz</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="247"/>
+ <location filename="../ui/browser.py" line="251"/>
<source>File name</source>
<translation>Nazwa pliku</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="248"/>
+ <location filename="../ui/browser.py" line="252"/>
<source>&amp;Search</source>
<translation>&amp;Szukaj</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="249"/>
+ <location filename="../ui/browser.py" line="253"/>
<source>&amp;Add selected</source>
<translation>&amp;Dodaj zaznaczone</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="250"/>
+ <location filename="../ui/browser.py" line="254"/>
<source>Add selected songs to the current playlist</source>
<translation>Dodaj zaznaczone utwory do głównej listy</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="251"/>
+ <location filename="../ui/browser.py" line="255"/>
<source>&amp;Close</source>
<translation>&amp;Zamknij</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="252"/>
+ <location filename="../ui/browser.py" line="256"/>
<source>Close this window</source>
<translation>Zamknij to okno</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="253"/>
+ <location filename="../ui/browser.py" line="257"/>
<source>Ctrl+W</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../ui/browser.py" line="254"/>
+ <location filename="../ui/browser.py" line="258"/>
<source>Search</source>
<translation>Szukaj</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="255"/>
+ <location filename="../ui/browser.py" line="259"/>
<source>&amp;Remove selected</source>
<translation>&amp;Usuń zaznaczone</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="256"/>
+ <location filename="../ui/browser.py" line="260"/>
<source>Del</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../ui/browser.py" line="257"/>
+ <location filename="../ui/browser.py" line="261"/>
<source>Add selected and &amp;play</source>
<translation>Dodaj zaznaczone i &amp;odtwarzaj</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="258"/>
+ <location filename="../ui/browser.py" line="262"/>
<source>Shift+Return</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../ui/browser.py" line="259"/>
+ <location filename="../ui/browser.py" line="263"/>
<source>Song &amp;details...</source>
<translation>&amp;Szczegóły...</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="260"/>
+ <location filename="../ui/browser.py" line="264"/>
<source>Ctrl+I</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../ui/browser.py" line="261"/>
+ <location filename="../ui/browser.py" line="265"/>
<source>Re&amp;name</source>
<translation>Zmień &amp;nazwę</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="262"/>
+ <location filename="../ui/browser.py" line="266"/>
<source>F2</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../ui/browser.py" line="263"/>
+ <location filename="../ui/browser.py" line="267"/>
<source>R&amp;eplace the current playlist</source>
<translation>Za&amp;stąp główną listę</translation>
</message>
<message>
- <location filename="../ui/browser.py" line="264"/>
+ <location filename="../ui/browser.py" line="268"/>
<source>Rep&amp;lace and play</source>
<translation>Zas&amp;tąp i odtwarzaj</translation>
</message>
+ <message>
+ <location filename="../ui/browser.py" line="269"/>
+ <source>Add with &amp;high priority</source>
+ <translation>Dodaj z &amp;wysokim priorytetem</translation>
+ </message>
</context>
<context>
<name>infodialog</name>
View
@@ -407,6 +407,7 @@
<addaction name="addplay"/>
<addaction name="replace"/>
<addaction name="replaceplay"/>
+ <addaction name="addhighprio"/>
<addaction name="separator"/>
<addaction name="remove"/>
<addaction name="rename"/>
@@ -527,6 +528,14 @@
<bool>false</bool>
</property>
</action>
+ <action name="addhighprio">
+ <property name="text">
+ <string>Add with &amp;high priority</string>
+ </property>
+ <property name="autoRepeat">
+ <bool>false</bool>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
View
@@ -159,11 +159,11 @@ def can_remove(self):
def can_rename(self):
return self.model().can_rename(self.selection())
- def can_set_priority(self, prio):
- return self.model().can_set_priority(self.selection(), prio)
+ def can_set_priority(self, priority):
+ return self.model().can_set_priority(self.selection(), priority)
- def add_selected_to_queue(self, play=False, replace=False):
- self.model().add_to_queue(self.selection(), play, replace)
+ def add_selected_to_queue(self, play=False, replace=False, priority=0):
+ self.model().add_to_queue(self.selection(), play, replace, priority)
def remove_selected(self):
self.model().remove(self.selection())

0 comments on commit 49acdf0

Please sign in to comment.