summaryrefslogtreecommitdiff
path: root/src/screen_type.cpp
blob: 3f9c4f5936eef266795827c3be0e046758209fdd (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/***************************************************************************
 *   Copyright (C) 2008-2014 by Andrzej Rybczak                            *
 *   electricityispower@gmail.com                                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   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.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
 ***************************************************************************/

#include "config.h"
#include "screen_type.h"

#include "browser.h"
#include "clock.h"
#include "help.h"
#include "lastfm.h"
#include "lyrics.h"
#include "media_library.h"
#include "outputs.h"
#include "playlist.h"
#include "playlist_editor.h"
#include "search_engine.h"
#include "sel_items_adder.h"
#include "server_info.h"
#include "song_info.h"
#include "sort_playlist.h"
#include "tag_editor.h"
#include "tiny_tag_editor.h"
#include "visualizer.h"

std::string screenTypeToString(ScreenType st)
{
	switch (st)
	{
	case ScreenType::Browser:
		return "browser";
#ifdef ENABLE_CLOCK
	case ScreenType::Clock:
		return "clock";
#endif // ENABLE_CLOCK
	case ScreenType::Help:
		return "help";
#ifdef HAVE_CURL_CURL_H
	case ScreenType::Lastfm:
		return "last_fm";
#endif // HAVE_CURL_CURL_H
	case ScreenType::Lyrics:
		return "lyrics";
	case ScreenType::MediaLibrary:
		return "media_library";
#ifdef ENABLE_OUTPUTS
	case ScreenType::Outputs:
		return "outputs";
#endif // ENABLE_OUTPUTS
	case ScreenType::Playlist:
		return "playlist";
	case ScreenType::PlaylistEditor:
		return "playlist_editor";
	case ScreenType::SearchEngine:
		return "search_engine";
	case ScreenType::SelectedItemsAdder:
		return "selected_items_adder";
	case ScreenType::ServerInfo:
		return "server_info";
	case ScreenType::SongInfo:
		return "song_info";
	case ScreenType::SortPlaylistDialog:
		return "sort_playlist_dialog";
#ifdef HAVE_TAGLIB_H
	case ScreenType::TagEditor:
		return "tag_editor";
	case ScreenType::TinyTagEditor:
		return "tiny_tag_editor";
#endif // HAVE_TAGLIB_H
	case ScreenType::Unknown:
		return "unknown";
#ifdef ENABLE_VISUALIZER
	case ScreenType::Visualizer:
		return "visualizer";
#endif // ENABLE_VISUALIZER
	}
}

ScreenType stringtoStartupScreenType(const std::string &s)
{
	ScreenType result = ScreenType::Unknown;
	if (s == "browser")
		result = ScreenType::Browser;
#	ifdef ENABLE_CLOCK
	else if (s == "clock")
		result = ScreenType::Clock;
#	endif // ENABLE_CLOCK
	else if (s == "help")
		result = ScreenType::Help;
	else if (s == "media_library")
		result = ScreenType::MediaLibrary;
#	ifdef ENABLE_OUTPUTS
	else if (s == "outputs")
		result = ScreenType::Outputs;
#	endif // ENABLE_OUTPUTS
	else if (s == "playlist")
		result = ScreenType::Playlist;
	else if (s == "playlist_editor")
		result = ScreenType::PlaylistEditor;
	else if (s == "search_engine")
		result = ScreenType::SearchEngine;
#	ifdef HAVE_TAGLIB_H
	else if (s == "tag_editor")
		result = ScreenType::TagEditor;
#	endif // HAVE_TAGLIB_H
#	ifdef ENABLE_VISUALIZER
	else if (s == "visualizer")
		result = ScreenType::Visualizer;
#	endif // ENABLE_VISUALIZER
	return result;
}

ScreenType stringToScreenType(const std::string &s)
{
	ScreenType result = stringtoStartupScreenType(s);
	if (result == ScreenType::Unknown)
	{
		if (s == "lyrics")
			result = ScreenType::Lyrics;
#		ifdef HAVE_CURL_CURL_H
		else if (s == "last_fm")
			result = ScreenType::Lastfm;
#		endif // HAVE_CURL_CURL_H
		else if (s == "selected_items_adder")
			result = ScreenType::SelectedItemsAdder;
		else if (s == "server_info")
			result = ScreenType::ServerInfo;
		else if (s == "song_info")
			result = ScreenType::SongInfo;
		else if (s == "sort_playlist_dialog")
			result = ScreenType::SortPlaylistDialog;
#		ifdef HAVE_TAGLIB_H
		else if (s == "tiny_tag_editor")
			result = ScreenType::TinyTagEditor;
#		endif // HAVE_TAGLIB_H
	}
	return result;
}

BaseScreen *toScreen(ScreenType st)
{
	switch (st)
	{
		case ScreenType::Browser:
			return myBrowser;
#		ifdef ENABLE_CLOCK
		case ScreenType::Clock:
			return myClock;
#		endif // ENABLE_CLOCK
		case ScreenType::Help:
			return myHelp;
#		ifdef HAVE_CURL_CURL_H
		case ScreenType::Lastfm:
			return myLastfm;
#		endif // HAVE_CURL_CURL_H
		case ScreenType::Lyrics:
			return myLyrics;
		case ScreenType::MediaLibrary:
			return myLibrary;
#		ifdef ENABLE_OUTPUTS
		case ScreenType::Outputs:
			return myOutputs;
#		endif // ENABLE_OUTPUTS
		case ScreenType::Playlist:
			return myPlaylist;
		case ScreenType::PlaylistEditor:
			return myPlaylistEditor;
		case ScreenType::SearchEngine:
			return mySearcher;
		case ScreenType::SelectedItemsAdder:
			return mySelectedItemsAdder;
		case ScreenType::ServerInfo:
			return myServerInfo;
		case ScreenType::SongInfo:
			return mySongInfo;
		case ScreenType::SortPlaylistDialog:
			return mySortPlaylistDialog;
#		ifdef HAVE_TAGLIB_H
		case ScreenType::TagEditor:
			return myTagEditor;
		case ScreenType::TinyTagEditor:
			return myTinyTagEditor;
#		endif // HAVE_TAGLIB_H
#		ifdef ENABLE_VISUALIZER
		case ScreenType::Visualizer:
			return myVisualizer;
#		endif // ENABLE_VISUALIZER
		default:
			return nullptr;
	}
}