refactor(mpd): Replace icon-repeatone with icon-single

The repeatone button doesn't influence repeating behaviour at all, so
the name is misleading.

This deprecates icon-repeatone for now, until we can completely remove
it

Fixes #1279
This commit is contained in:
patrick96 2018-06-21 17:00:26 +02:00 committed by Patrick Ziegler
parent a06eb8cdac
commit 028b1413ef
2 changed files with 28 additions and 10 deletions

View File

@ -40,7 +40,16 @@ namespace modules {
static constexpr const char* TAG_LABEL_TIME{"<label-time>"}; static constexpr const char* TAG_LABEL_TIME{"<label-time>"};
static constexpr const char* TAG_ICON_RANDOM{"<icon-random>"}; static constexpr const char* TAG_ICON_RANDOM{"<icon-random>"};
static constexpr const char* TAG_ICON_REPEAT{"<icon-repeat>"}; static constexpr const char* TAG_ICON_REPEAT{"<icon-repeat>"};
/*
* Deprecated
*/
static constexpr const char* TAG_ICON_REPEAT_ONE{"<icon-repeatone>"}; static constexpr const char* TAG_ICON_REPEAT_ONE{"<icon-repeatone>"};
/*
* Replaces icon-repeatone
*
* repeatone is misleading, since it doesn't actually affect the repeating behaviour
*/
static constexpr const char* TAG_ICON_SINGLE{"<icon-single>"};
static constexpr const char* TAG_ICON_CONSUME{"<icon-consume>"}; static constexpr const char* TAG_ICON_CONSUME{"<icon-consume>"};
static constexpr const char* TAG_ICON_PREV{"<icon-prev>"}; static constexpr const char* TAG_ICON_PREV{"<icon-prev>"};
static constexpr const char* TAG_ICON_STOP{"<icon-stop>"}; static constexpr const char* TAG_ICON_STOP{"<icon-stop>"};
@ -59,7 +68,7 @@ namespace modules {
static constexpr const char* EVENT_PREV{"mpdprev"}; static constexpr const char* EVENT_PREV{"mpdprev"};
static constexpr const char* EVENT_NEXT{"mpdnext"}; static constexpr const char* EVENT_NEXT{"mpdnext"};
static constexpr const char* EVENT_REPEAT{"mpdrepeat"}; static constexpr const char* EVENT_REPEAT{"mpdrepeat"};
static constexpr const char* EVENT_REPEAT_ONE{"mpdrepeatone"}; static constexpr const char* EVENT_SINGLE{"mpdsingle"};
static constexpr const char* EVENT_RANDOM{"mpdrandom"}; static constexpr const char* EVENT_RANDOM{"mpdrandom"};
static constexpr const char* EVENT_CONSUME{"mpdconsume"}; static constexpr const char* EVENT_CONSUME{"mpdconsume"};
static constexpr const char* EVENT_SEEK{"mpdseek"}; static constexpr const char* EVENT_SEEK{"mpdseek"};

View File

@ -24,7 +24,7 @@ namespace modules {
for (auto&& format : {FORMAT_PLAYING, FORMAT_PAUSED, FORMAT_STOPPED}) { for (auto&& format : {FORMAT_PLAYING, FORMAT_PAUSED, FORMAT_STOPPED}) {
m_formatter->add(format, format_online, m_formatter->add(format, format_online,
{TAG_BAR_PROGRESS, TAG_TOGGLE, TAG_TOGGLE_STOP, TAG_LABEL_SONG, TAG_LABEL_TIME, TAG_ICON_RANDOM, {TAG_BAR_PROGRESS, TAG_TOGGLE, TAG_TOGGLE_STOP, TAG_LABEL_SONG, TAG_LABEL_TIME, TAG_ICON_RANDOM,
TAG_ICON_REPEAT, TAG_ICON_REPEAT_ONE, TAG_ICON_PREV, TAG_ICON_STOP, TAG_ICON_PLAY, TAG_ICON_PAUSE, TAG_ICON_REPEAT, TAG_ICON_REPEAT_ONE, TAG_ICON_SINGLE, TAG_ICON_PREV, TAG_ICON_STOP, TAG_ICON_PLAY, TAG_ICON_PAUSE,
TAG_ICON_NEXT, TAG_ICON_SEEKB, TAG_ICON_SEEKF, TAG_ICON_CONSUME}); TAG_ICON_NEXT, TAG_ICON_SEEKB, TAG_ICON_SEEKF, TAG_ICON_CONSUME});
auto mod_format = m_formatter->get(format); auto mod_format = m_formatter->get(format);
mod_format->fg = m_conf.get(name(), FORMAT_ONLINE + "-foreground"s, mod_format->fg); mod_format->fg = m_conf.get(name(), FORMAT_ONLINE + "-foreground"s, mod_format->fg);
@ -71,9 +71,17 @@ namespace modules {
if (m_formatter->has(TAG_ICON_REPEAT)) { if (m_formatter->has(TAG_ICON_REPEAT)) {
m_icons->add("repeat", load_icon(m_conf, name(), TAG_ICON_REPEAT)); m_icons->add("repeat", load_icon(m_conf, name(), TAG_ICON_REPEAT));
} }
if (m_formatter->has(TAG_ICON_REPEAT_ONE)) {
m_icons->add("repeat_one", load_icon(m_conf, name(), TAG_ICON_REPEAT_ONE)); if (m_formatter->has(TAG_ICON_SINGLE)) {
m_icons->add("single", load_icon(m_conf, name(), TAG_ICON_SINGLE));
} }
else if(m_formatter->has(TAG_ICON_REPEAT_ONE)){
m_conf.warn_deprecated(name(), "icon-repeatone", "icon-single");
m_icons->add("single", load_icon(m_conf, name(), TAG_ICON_REPEAT_ONE));
}
if (m_formatter->has(TAG_ICON_CONSUME)) { if (m_formatter->has(TAG_ICON_CONSUME)) {
m_icons->add("consume", load_icon(m_conf, name(), TAG_ICON_CONSUME)); m_icons->add("consume", load_icon(m_conf, name(), TAG_ICON_CONSUME));
} }
@ -85,7 +93,8 @@ namespace modules {
m_label_time = load_optional_label(m_conf, name(), TAG_LABEL_TIME, "%elapsed% / %total%"); m_label_time = load_optional_label(m_conf, name(), TAG_LABEL_TIME, "%elapsed% / %total%");
} }
if (m_formatter->has(TAG_ICON_RANDOM) || m_formatter->has(TAG_ICON_REPEAT) || if (m_formatter->has(TAG_ICON_RANDOM) || m_formatter->has(TAG_ICON_REPEAT) ||
m_formatter->has(TAG_ICON_REPEAT_ONE) || m_formatter->has(TAG_ICON_CONSUME)) { m_formatter->has(TAG_ICON_REPEAT_ONE) || m_formatter->has(TAG_ICON_SINGLE) ||
m_formatter->has(TAG_ICON_CONSUME)) {
m_toggle_on_color = m_conf.get(name(), "toggle-on-foreground", ""s); m_toggle_on_color = m_conf.get(name(), "toggle-on-foreground", ""s);
m_toggle_off_color = m_conf.get(name(), "toggle-off-foreground", ""s); m_toggle_off_color = m_conf.get(name(), "toggle-off-foreground", ""s);
} }
@ -256,8 +265,8 @@ namespace modules {
if (m_icons->has("repeat")) { if (m_icons->has("repeat")) {
m_icons->get("repeat")->m_foreground = m_status && m_status->repeat() ? m_toggle_on_color : m_toggle_off_color; m_icons->get("repeat")->m_foreground = m_status && m_status->repeat() ? m_toggle_on_color : m_toggle_off_color;
} }
if (m_icons->has("repeat_one")) { if (m_icons->has("single")) {
m_icons->get("repeat_one")->m_foreground = m_icons->get("single")->m_foreground =
m_status && m_status->single() ? m_toggle_on_color : m_toggle_off_color; m_status && m_status->single() ? m_toggle_on_color : m_toggle_off_color;
} }
if (m_icons->has("consume")) { if (m_icons->has("consume")) {
@ -305,8 +314,8 @@ namespace modules {
builder->cmd(mousebtn::LEFT, EVENT_RANDOM, m_icons->get("random")); builder->cmd(mousebtn::LEFT, EVENT_RANDOM, m_icons->get("random"));
} else if (tag == TAG_ICON_REPEAT) { } else if (tag == TAG_ICON_REPEAT) {
builder->cmd(mousebtn::LEFT, EVENT_REPEAT, m_icons->get("repeat")); builder->cmd(mousebtn::LEFT, EVENT_REPEAT, m_icons->get("repeat"));
} else if (tag == TAG_ICON_REPEAT_ONE) { } else if (tag == TAG_ICON_REPEAT_ONE || tag == TAG_ICON_SINGLE) {
builder->cmd(mousebtn::LEFT, EVENT_REPEAT_ONE, m_icons->get("repeat_one")); builder->cmd(mousebtn::LEFT, EVENT_SINGLE, m_icons->get("single"));
} else if (tag == TAG_ICON_CONSUME) { } else if (tag == TAG_ICON_CONSUME) {
builder->cmd(mousebtn::LEFT, EVENT_CONSUME, m_icons->get("consume")); builder->cmd(mousebtn::LEFT, EVENT_CONSUME, m_icons->get("consume"));
} else if (tag == TAG_ICON_PREV) { } else if (tag == TAG_ICON_PREV) {
@ -357,7 +366,7 @@ namespace modules {
mpd->prev(); mpd->prev();
} else if (cmd == EVENT_NEXT && !is_stopped) { } else if (cmd == EVENT_NEXT && !is_stopped) {
mpd->next(); mpd->next();
} else if (cmd == EVENT_REPEAT_ONE) { } else if (cmd == EVENT_SINGLE) {
mpd->set_single(!status->single()); mpd->set_single(!status->single());
} else if (cmd == EVENT_REPEAT) { } else if (cmd == EVENT_REPEAT) {
mpd->set_repeat(!status->repeat()); mpd->set_repeat(!status->repeat());