« get me outta code hell

Make Q key queue after selected track - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-09-11 17:19:05 -0300
committerFlorrie <towerofnix@gmail.com>2019-09-11 17:19:57 -0300
commit6be85bb511f9e3e55ab503c9b8b44afb31b84f2d (patch)
tree29157054804803813b4ca95a9c00063d911edf26
parent47bd859d1a02683395bbf941d7dc0375d7ef8334 (diff)
Make Q key queue after selected track
Also make it caseless: q = Q. See todo.txt (which also has a large new
note regarding duplicates in the selection system).
-rw-r--r--README.md3
-rw-r--r--todo.txt32
-rw-r--r--ui.js9
3 files changed, 36 insertions, 8 deletions
diff --git a/README.md b/README.md
index b760230..282452a 100644
--- a/README.md
+++ b/README.md
@@ -48,8 +48,7 @@ You're also welcome to share any ideas, suggestions, and questions through there
 * **In the main listing:**
   * <kbd>Enter</kbd> - if the selected item is a group, enter it; if it's a track, play it
   * <kbd>Backspace</kbd> - leave the current group (if in one)
-  * <kbd>q</kbd> - queue the selected track or group to play after any other items in the queue (usually after the current track)
-  * <kbd>Q</kbd> (shift+Q) - queue the selected track or group to play immediately after what's currently playing
+  * <kbd>q</kbd> - queue the selected track or group to play after the track which is selected in the queue
   * <kbd>d</kbd> - download the selected track (but don't play it)
 * **In the queue listing:**
   * <kbd>s</kbd> - shuffle the queue
diff --git a/todo.txt b/todo.txt
index 14c2dd1..eba924c 100644
--- a/todo.txt
+++ b/todo.txt
@@ -301,3 +301,35 @@ TODO: Pay closer attention to the ordering of queue items' context menu...
       queue one "above" the start pos = at the bottom) -- but it might make
       more logical sense to group 'play sooner', 'play next', and 'remove
       from queue' all into one section.
+
+TODO: Figure out duplicates in the selection system! Right now, it's possible
+      to have both a group and its children selected at the same time, which
+      actually treats them as separate items in the selection grouplike.
+      This /might/ be good for performing an action on a group as well as its
+      children, but that seems like a rare case (only relevant to labelling as
+      far as I can imagine), and it doesn't seem super intuitive UI-wise right
+      now.
+
+      Maybe we could make it so if you have a grouplike selected, then browse
+      within it to see its children (or subchildren, etc), those child items
+      would be highlighted, but only dimly? The idea is that no highlight = not
+      selected; dim highlight = a parent is selected and so actions like
+      queuing will apply to this item; full highlight = this item itself is
+      selected, so actions that only apply to individual items, like labelling,
+      will apply. It's not entirely obvious what this means, but I think it
+      more or less makes sense.
+
+      BTW: we'll need a new function, removeDuplicates, for said actions. One
+      of those "actions" is actually called just by opening the context menu --
+      the tally numbers showing the total tracks selected and the sum duration
+      of all of those tracks. Make sure to call removeDuplicates after
+      flattenGrouplike. (I considered putting that new behavior of rD into fG,
+      but it doesn't seem worth it - better to keep them separate and let us
+      explicitly decide when we do or don't want to consider duplicates.)
+
+TODO: Default to 'after selected track' in context menu, and make pressing Q
+      (the shorthand for queuing the selection) act as though that's the
+      selected option, instead of queuing at the end of the queue (which is
+      really only useful when you're building a queue at the start, assuming
+      you don't start by shuffling your entire queue anyway).
+      (Done!)
diff --git a/ui.js b/ui.js
index fb73061..c6bb448 100644
--- a/ui.js
+++ b/ui.js
@@ -73,8 +73,7 @@ const keyBindings = [
   ['isPreviousTab', 'T', {caseless: false}],
   ['isDownload', 'd'],
   ['isRemove', 'x'],
-  ['isQueueAtEnd', 'q', {caseless: false}],
-  ['isQueueAtStart', 'Q', {caseless: false}],
+  ['isQueueAfterSelectedTrack', 'q'],
   ['isShuffleQueue', 's'],
   ['isClearQueue', 'c'],
   ['isFocusMenubar', ';'],
@@ -2228,10 +2227,8 @@ class InteractiveGrouplikeItemElement extends BasicGrouplikeItemElement {
       }
     } else if (input.isDownload(keyBuf)) {
       this.emit('download')
-    } else if (input.isQueueAtEnd(keyBuf)) {
-      this.emit('queue', {where: 'end'})
-    } else if (input.isQueueAtStart(keyBuf)) {
-      this.emit('queue', {where: 'next'})
+    } else if (input.isQueueAfterSelectedTrack(keyBuf)) {
+      this.emit('queue', {where: 'next-selected'})
     } else if (telc.isEnter(keyBuf)) {
       if (isGroup(this.item)) {
         this.emit('browse')