Skip to content

Commit

Permalink
qtui: make playlist tab visibility a tri-state ({shown, auto-hidden, …
Browse files Browse the repository at this point in the history
…hidden}).
  • Loading branch information
kaniini committed Oct 27, 2019
1 parent 236466d commit 89365b7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
20 changes: 19 additions & 1 deletion src/qtui/playlist_tabs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "playlist_tabs.h"
#include "menus.h"
#include "search_bar.h"
#include "settings.h"

#include <QBoxLayout>
#include <QKeyEvent>
Expand Down Expand Up @@ -349,7 +350,24 @@ void PlaylistTabBar::mouseDoubleClickEvent (QMouseEvent * e)
void PlaylistTabBar::updateSettings ()
{
#if QT_VERSION >= 0x050400
setAutoHide (! aud_get_bool ("qtui", "playlist_tabs_visible"));
setAutoHide (false);
#endif

switch (aud_get_int ("qtui", "playlist_tabs_visible"))
{
#if QT_VERSION >= 0x050400
case PlaylistTabVisibility::AutoHide:
setAutoHide (true);
break;
#endif
case PlaylistTabVisibility::Always:
show ();
break;

case PlaylistTabVisibility::Never:
hide ();
break;
}

setTabsClosable (aud_get_bool ("qtui", "close_button_visible"));
}
15 changes: 10 additions & 5 deletions src/qtui/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const char * const qtui_defaults[] = {
"infoarea_show_vis", "TRUE",
"infoarea_visible", "TRUE",
"menu_visible", "TRUE",
"playlist_tabs_visible", "TRUE",
"playlist_tabs_visible", aud::numeric_string<PlaylistTabVisibility::AutoHide>::str,
"statusbar_visible", "TRUE",
"entry_count_visible", "FALSE",
"close_button_visible", "TRUE",
Expand All @@ -48,12 +48,17 @@ static void qtui_update_playlist_settings ()
hook_call ("qtui update playlist settings", nullptr);
}

static const ComboItem playlist_tabs_options[] = {
ComboItem (N_("Always"), PlaylistTabVisibility::Always),
ComboItem (N_("Auto-hide"), PlaylistTabVisibility::AutoHide),
ComboItem (N_("Never"), PlaylistTabVisibility::Never)
};

static const PreferencesWidget qtui_widgets[] = {
WidgetLabel (N_("<b>Playlist Tabs</b>")),
#if QT_VERSION >= 0x050400
WidgetCheck (N_("Always show tabs"),
WidgetBool ("qtui", "playlist_tabs_visible", qtui_update_playlist_settings)),
#endif
WidgetCombo (N_("Show playlist tabs:"),
WidgetInt ("qtui", "playlist_tabs_visible", qtui_update_playlist_settings),
{{playlist_tabs_options}}),
WidgetCheck (N_("Show entry counts"),
WidgetBool ("qtui", "entry_count_visible", qtui_update_playlist_settings)),
WidgetCheck (N_("Show close buttons"),
Expand Down
6 changes: 6 additions & 0 deletions src/qtui/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@

#define DEFAULT_COLUMNS "playing title artist album queued length"

enum PlaylistTabVisibility {
Always,
AutoHide,
Never
};

struct PluginPreferences;
extern const PluginPreferences qtui_prefs;

Expand Down

4 comments on commit 89365b7

@jlindgren90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wildstar84
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When/what does "autohide" hide? If set to hidden, tabs are hidden, otherwise tabs seem to always be visible.

@jlindgren90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-hide is the same as the existing behavior: show tabs only if number of tabs > 1.

@jlindgren90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.