1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
import QtQuick
import "../.."
import "../../companion/Lines.js" as Lines
// The lines the companion says when a track by an artist she knows starts,
// matched as a case-insensitive substring of the player's artist. Same
// draft, Save and Reset as PhrasesModule, on Prefs.companionArtists and
// Lines.artists; the page's cls field holds the artist.
Module {
id: am
name: "artists"
label: "Companion artists"
// nf-fa-music, present in Inconsolata Nerd Font.
icon: "\uf001"
settings: true
group: "Companion"
keywords: ["companion", "artist", "music", "song", "track", "line", "say", "2b"]
searchItems: am.shown.map((a, i) => ({ text: a.cls + ": " + a.lines.join(" / "), key: "app:" + i }))
property var draft: null
property bool resetting: false
readonly property var shown: am.draft ?? Lines.appList(Prefs.companionArtists, Lines.artists)
readonly property bool valid: am.shown.every(a => String(a.cls).trim() !== ""
&& (a.lines || []).some(l => String(l).trim() !== ""))
dirty: am.draft !== null
function edit(list) { am.draft = list; am.resetting = false; }
function reset() { am.draft = Lines.appList(null, Lines.artists); am.resetting = true; }
function save() {
if (am.resetting) Prefs.resetCompanionArtists();
else Prefs.setCompanionArtists(Lines.toMap(am.draft));
am.discard();
}
function discard() { am.draft = null; am.resetting = false; }
page: Component {
Page {
title: "Companion artists"
actions: Component {
SaveBar { dirty: am.dirty; valid: am.valid; note: "every artist needs a name and a phrase"
onSave: am.save(); onDiscard: am.discard() }
}
PhrasesPage {
width: parent.width
owner: am
intro: "When a track by an artist she knows starts or changes, she says one of their lines at "
+ "random, under her 30 s line cooldown. The name matches any part of the player's artist, "
+ "ignoring case, so \"daft punk\" also catches \"Daft Punk, Pharrell Williams\". "
+ "Save applies at once."
keyHint: "artist, e.g. linkin park"
addText: "Add artist"
saved: Prefs.companionArtists
}
}
}
}
|