Permalink
Browse files

"Copy selected" action.

  • Loading branch information...
1 parent cb71c52 commit 33c04a4c4b8374350781391b38f6d946ad8a70c9 @tsufeki committed Jul 8, 2013
Showing with 149 additions and 97 deletions.
  1. +8 −5 qygmy/browser.py
  2. +13 −0 qygmy/lists.py
  3. +3 −0 qygmy/qygmy.py
  4. +101 −92 qygmy/translations/qygmy_pl.ts
  5. +9 −0 qygmy/ui/browser.ui
  6. +9 −0 qygmy/ui/main.ui
  7. +6 −0 qygmy/uiutils.py
View
@@ -25,6 +25,7 @@ def setup_ui(self):
self.ui.search_results.setup(self.srv.search)
self.ui.search_button.setDefaultAction(self.ui.search)
self.srv.state.changed.connect(self.on_state_changed)
+ self.ui.close.triggered.connect(self.close)
try:
if 'browser_geometry' in self.main.settings['guistate']:
@@ -42,6 +43,7 @@ def setup_icons(self):
('remove', 'edit-delete'),
('close', 'window-close'),
('search', 'edit-find'),
+ ('copy', 'edit-copy'),
):
getattr(self.ui, action).setIcon(QIcon.fromTheme(icon))
for i, icon in enumerate(['folder-sound', 'document-multiple', 'edit-find']):
@@ -66,24 +68,21 @@ def contextMenuEvent(self, e):
self.ui.add.setVisible(self.current_view.can_add_to_queue())
self.ui.remove.setVisible(self.current_view.can_remove())
self.ui.rename.setVisible(self.current_view.can_rename())
+ self.ui.copy.setVisible(self.current_view.can_copy())
self.ui.details.setVisible(self.current_view.details() is not None)
self.ui.context_menu.popup(e.globalPos())
def on_state_changed(self, state):
c = state != 'disconnect'
for act in ('search', 'add', 'addplay', 'replace', 'replaceplay',
- 'remove', 'rename', 'details'):
+ 'remove', 'rename', 'copy', 'details'):
getattr(self.ui, act).setEnabled(c)
self.ui.dbpath.setEnabled(c)
self.ui.plpath.setEnabled(c)
self.ui.what.setEnabled(c)
self.ui.query.setEnabled(c)
@Slot()
- def on_close_triggered(self):
- self.close()
-
- @Slot()
def on_search_triggered(self):
self.srv.search.cd((self.ui.what.currentIndex(), self.ui.query.text()))
@@ -112,6 +111,10 @@ def on_rename_triggered(self):
self.current_view.rename_selected()
@Slot()
+ def on_copy_triggered(self):
+ self.current_view.copy_selected()
+
+ @Slot()
def on_details_triggered(self):
d = self.current_view.details()
if d is not None:
View
@@ -65,6 +65,9 @@ def can_rename(self, positions):
def can_set_priority(self, positions, prio):
return False
+ def can_copy(self, positions):
+ return False
+
@abstractmethod
def item_chosen(self, pos):
"""i.e. double-clicked or Return pressed."""
@@ -192,6 +195,13 @@ def remove(self, positions):
def remove_one(self, item):
pass
+ def can_copy(self, positions):
+ return len(positions) > 0
+
+ def copy(self, positions):
+ if self.can_copy(positions):
+ self.add([self[i] for i in positions], max(positions) + 1)
+
@mpd_cmd
def move(self, items, pos):
if len(items) == 0:
@@ -421,6 +431,9 @@ def remove_one(self, item):
else:
self.conn.playlistdelete(self.current.value, item['pos'])
+ def can_copy(self, positions):
+ return False if self.current.value == '' else super().can_copy(positions)
+
def move_one(self, item, pos):
if self.current.value != '':
self.conn.playlistmove(self.current.value, item['pos'], pos)
View
@@ -70,6 +70,7 @@ def setup_icons(self):
('add', 'list-add'),
('remove', 'list-remove'),
('clear', 'edit-clear-list'),
+ ('copy', 'edit-copy'),
('repeat', 'media-playlist-repeat'),
('shuffle', 'media-playlist-shuffle'),
('single', 'go-last'),
@@ -138,6 +139,7 @@ def slot(checked, act=act, var=var):
self.ui.add.triggered.connect(self.browser.activateWindow)
self.ui.remove.triggered.connect(self.ui.queue.remove_selected)
self.ui.clear.triggered.connect(self.srv.clear)
+ self.ui.copy.triggered.connect(self.ui.queue.copy_selected)
self.ui.randomize.triggered.connect(self.srv.randomize_queue)
self.ui.reverse.triggered.connect(self.srv.queue.reverse)
self.ui.updatedb.triggered.connect(self.srv.updatedb)
@@ -193,6 +195,7 @@ def contextMenuEvent(self, e):
e.accept()
self.ui.highprio.setEnabled(self.ui.queue.can_set_priority(1))
self.ui.normprio.setEnabled(self.ui.queue.can_set_priority(0))
+ self.ui.copy.setEnabled(self.ui.queue.can_copy())
self.ui.details.setEnabled(self.ui.queue.details() is not None)
self.ui.context_menu.popup(e.globalPos())
Oops, something went wrong.

0 comments on commit 33c04a4

Please sign in to comment.