Debian Codegraph @

src/modes.cpp

raw
1 /*
2 * This file is part of Bino, a 3D video player.
3 *
4 * Copyright (C) 2022, 2023, 2024, 2025
5 * Martin Lambers <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <QCoreApplication>
22
23 #include "modes.hpp"
24
25
26 const char* inputModeToString(InputMode mode)
27 {
28 switch (mode) {
29 case Input_Unknown:
30 return "unknown";
31 break;
32 case Input_Mono:
33 return "mono";
34 break;
35 case Input_Top_Bottom:
36 return "top-bottom";
37 break;
38 case Input_Top_Bottom_Half:
39 return "top-bottom-half";
40 break;
41 case Input_Bottom_Top:
42 return "bottom-top";
43 break;
44 case Input_Bottom_Top_Half:
45 return "bottom-top-half";
46 break;
47 case Input_Left_Right:
48 return "left-right";
49 break;
50 case Input_Left_Right_Half:
51 return "left-right-half";
52 break;
53 case Input_Right_Left:
54 return "right-left";
55 break;
56 case Input_Right_Left_Half:
57 return "right-left-half";
58 break;
59 case Input_Alternating_LR:
60 return "alternating-left-right";
61 break;
62 case Input_Alternating_RL:
63 return "alternating-right-left";
64 break;
65 };
66 return nullptr;
67 }
68
69 QString inputModeToStringUI(InputMode mode)
70 {
71 switch (mode) {
72 case Input_Unknown:
73 return QCoreApplication::translate("Mode", "Input autodetection");
74 break;
75 case Input_Mono:
76 return QCoreApplication::translate("Mode", "Input 2D");
77 break;
78 case Input_Top_Bottom:
79 return QCoreApplication::translate("Mode", "Input top/bottom");
80 break;
81 case Input_Top_Bottom_Half:
82 return QCoreApplication::translate("Mode", "Input top/bottom half height");
83 break;
84 case Input_Bottom_Top:
85 return QCoreApplication::translate("Mode", "Input bottom/top");
86 break;
87 case Input_Bottom_Top_Half:
88 return QCoreApplication::translate("Mode", "Input bottom/top half height");
89 break;
90 case Input_Left_Right:
91 return QCoreApplication::translate("Mode", "Input left/right");
92 break;
93 case Input_Left_Right_Half:
94 return QCoreApplication::translate("Mode", "Input left/right half width");
95 break;
96 case Input_Right_Left:
97 return QCoreApplication::translate("Mode", "Input right/left");
98 break;
99 case Input_Right_Left_Half:
100 return QCoreApplication::translate("Mode", "Input right/left half width");
101 break;
102 case Input_Alternating_LR:
103 return QCoreApplication::translate("Mode", "Input alternating left/right");
104 break;
105 case Input_Alternating_RL:
106 return QCoreApplication::translate("Mode", "Input alternating right/left");
107 break;
108 };
109 return QString();
110 }
111
112 InputMode inputModeFromString(const QString& s, bool* ok)
113 {
114 InputMode mode = Input_Unknown;
115 bool r = true;
116 if (s == "mono")
117 mode = Input_Mono;
118 else if (s == "top-bottom")
119 mode = Input_Top_Bottom;
120 else if (s == "top-bottom-half")
121 mode = Input_Top_Bottom_Half;
122 else if (s == "bottom-top")
123 mode = Input_Bottom_Top;
124 else if (s == "bottom-top-half")
125 mode = Input_Bottom_Top_Half;
126 else if (s == "left-right")
127 mode = Input_Left_Right;
128 else if (s == "left-right-half")
129 mode = Input_Left_Right_Half;
130 else if (s == "right-left")
131 mode = Input_Right_Left;
132 else if (s == "right-left-half")
133 mode = Input_Right_Left_Half;
134 else if (s == "alternating-left-right")
135 mode = Input_Alternating_LR;
136 else if (s == "alternating-right-left")
137 mode = Input_Alternating_RL;
138 else
139 r = false;
140 if (ok)
141 *ok = r;
142 return mode;
143 }
144
145 const char* surroundModeToString(SurroundMode mode)
146 {
147 switch (mode) {
148 case Surround_Unknown:
149 return "unknown";
150 break;
151 case Surround_Off:
152 return "off";
153 break;
154 case Surround_180:
155 return "180";
156 break;
157 case Surround_360:
158 return "360";
159 break;
160 }
161 return nullptr;
162 }
163
164 QString surroundModeToStringUI(SurroundMode mode)
165 {
166 switch (mode) {
167 case Surround_Unknown:
168 return QCoreApplication::translate("Mode", "Surround autodetection");
169 break;
170 case Surround_Off:
171 return QCoreApplication::translate("Mode", "Surround off");
172 break;
173 case Surround_180:
174 return QCoreApplication::translate("Mode", "Surround 180°");
175 break;
176 case Surround_360:
177 return QCoreApplication::translate("Mode", "Surround 360°");
178 break;
179 }
180 return QString();
181 }
182
183 SurroundMode surroundModeFromString(const QString& s, bool* ok)
184 {
185 SurroundMode mode = Surround_Unknown;
186 bool r = true;
187 if (s == "off")
188 mode = Surround_Off;
189 else if (s == "180")
190 mode = Surround_180;
191 else if (s == "360")
192 mode = Surround_360;
193 else
194 r = false;
195 if (ok)
196 *ok = r;
197 return mode;
198 }
199
200 const char* outputModeToString(OutputMode mode)
201 {
202 switch (mode) {
203 case Output_Left:
204 return "left";
205 break;
206 case Output_Right:
207 return "right";
208 break;
209 case Output_OpenGL_Stereo:
210 return "stereo";
211 break;
212 case Output_Alternating:
213 return "alternating";
214 break;
215 case Output_HDMI_Frame_Pack:
216 return "hdmi-frame-pack";
217 break;
218 case Output_Left_Right:
219 return "left-right";
220 break;
221 case Output_Left_Right_Half:
222 return "left-right-half";
223 break;
224 case Output_Right_Left:
225 return "right-left";
226 break;
227 case Output_Right_Left_Half:
228 return "right-left-half";
229 break;
230 case Output_Top_Bottom:
231 return "top-bottom";
232 break;
233 case Output_Top_Bottom_Half:
234 return "top-bottom-half";
235 break;
236 case Output_Bottom_Top:
237 return "bottom-top";
238 break;
239 case Output_Bottom_Top_Half:
240 return "bottom-top-half";
241 break;
242 case Output_Even_Odd_Rows:
243 return "even-odd-rows";
244 break;
245 case Output_Even_Odd_Columns:
246 return "even-odd-columns";
247 break;
248 case Output_Checkerboard:
249 return "checkeroard";
250 break;
251 case Output_Red_Cyan_Dubois:
252 return "red-cyan-dubois";
253 break;
254 case Output_Red_Cyan_FullColor:
255 return "red-cyan-fullcolor";
256 break;
257 case Output_Red_Cyan_HalfColor:
258 return "red-cyan-halfcolor";
259 break;
260 case Output_Red_Cyan_Monochrome:
261 return "red-cyan-monochrome";
262 break;
263 case Output_Green_Magenta_Dubois:
264 return "green-magenta-dubois";
265 break;
266 case Output_Green_Magenta_FullColor:
267 return "green-magenta-fullcolor";
268 break;
269 case Output_Green_Magenta_HalfColor:
270 return "green-magenta-halfcolor";
271 break;
272 case Output_Green_Magenta_Monochrome:
273 return "green-magenta-monochrome";
274 break;
275 case Output_Amber_Blue_Dubois:
276 return "amber-blue-dubois";
277 break;
278 case Output_Amber_Blue_FullColor:
279 return "amber-blue-fullcolor";
280 break;
281 case Output_Amber_Blue_HalfColor:
282 return "amber-blue-halfcolor";
283 break;
284 case Output_Amber_Blue_Monochrome:
285 return "amber-blue-monochrome";
286 break;
287 case Output_Red_Green_Monochrome:
288 return "red-green-monochrome";
289 break;
290 case Output_Red_Blue_Monochrome:
291 return "red-blue-monochrome";
292 break;
293 }
294 return nullptr;
295 }
296
297 QString outputModeToStringUI(OutputMode mode)
298 {
299 switch (mode) {
300 case Output_Left:
301 return QCoreApplication::translate("Mode", "Output 2D left");
302 break;
303 case Output_Right:
304 return QCoreApplication::translate("Mode", "Output 2D right");
305 break;
306 case Output_OpenGL_Stereo:
307 return QCoreApplication::translate("Mode", "Output 3D OpenGL Stereo");
308 break;
309 case Output_Alternating:
310 return QCoreApplication::translate("Mode", "Output 3D alternating");
311 break;
312 case Output_HDMI_Frame_Pack:
313 return QCoreApplication::translate("Mode", "Output HDMI frame pack");
314 break;
315 case Output_Left_Right:
316 return QCoreApplication::translate("Mode", "Output left/right");
317 break;
318 case Output_Left_Right_Half:
319 return QCoreApplication::translate("Mode", "Output left/right half width");
320 break;
321 case Output_Right_Left:
322 return QCoreApplication::translate("Mode", "Output right/left");
323 break;
324 case Output_Right_Left_Half:
325 return QCoreApplication::translate("Mode", "Output right/left half width");
326 break;
327 case Output_Top_Bottom:
328 return QCoreApplication::translate("Mode", "Output top/bottom");
329 break;
330 case Output_Top_Bottom_Half:
331 return QCoreApplication::translate("Mode", "Output top/bottom half height");
332 break;
333 case Output_Bottom_Top:
334 return QCoreApplication::translate("Mode", "Output bottom/top");
335 break;
336 case Output_Bottom_Top_Half:
337 return QCoreApplication::translate("Mode", "Output bottom/top half height");
338 break;
339 case Output_Even_Odd_Rows:
340 return QCoreApplication::translate("Mode", "Output even/odd rows");
341 break;
342 case Output_Even_Odd_Columns:
343 return QCoreApplication::translate("Mode", "Output even/odd columns");
344 break;
345 case Output_Checkerboard:
346 return QCoreApplication::translate("Mode", "Output checkerboard");
347 break;
348 case Output_Red_Cyan_Dubois:
349 return QCoreApplication::translate("Mode", "Output red/cyan high quality");
350 break;
351 case Output_Red_Cyan_FullColor:
352 return QCoreApplication::translate("Mode", "Output red/cyan full color");
353 break;
354 case Output_Red_Cyan_HalfColor:
355 return QCoreApplication::translate("Mode", "Output red/cyan half color");
356 break;
357 case Output_Red_Cyan_Monochrome:
358 return QCoreApplication::translate("Mode", "Output red/cyan monochrome");
359 break;
360 case Output_Green_Magenta_Dubois:
361 return QCoreApplication::translate("Mode", "Output green/magenta high quality");
362 break;
363 case Output_Green_Magenta_FullColor:
364 return QCoreApplication::translate("Mode", "Output green/magenta full color");
365 break;
366 case Output_Green_Magenta_HalfColor:
367 return QCoreApplication::translate("Mode", "Output green/magenta half color");
368 break;
369 case Output_Green_Magenta_Monochrome:
370 return QCoreApplication::translate("Mode", "Output green/magenta monochrome");
371 break;
372 case Output_Amber_Blue_Dubois:
373 return QCoreApplication::translate("Mode", "Output amber/blue high quality");
374 break;
375 case Output_Amber_Blue_FullColor:
376 return QCoreApplication::translate("Mode", "Output amber/blue full color");
377 break;
378 case Output_Amber_Blue_HalfColor:
379 return QCoreApplication::translate("Mode", "Output amber/blue half color");
380 break;
381 case Output_Amber_Blue_Monochrome:
382 return QCoreApplication::translate("Mode", "Output amber/blue monochrome");
383 break;
384 case Output_Red_Green_Monochrome:
385 return QCoreApplication::translate("Mode", "Output red/green monochrome");
386 break;
387 case Output_Red_Blue_Monochrome:
388 return QCoreApplication::translate("Mode", "Output red/blue monochrome");
389 break;
390 }
391 return nullptr;
392 }
393
394 OutputMode outputModeFromString(const QString& s, bool* ok)
395 {
396 OutputMode mode = Output_Left;
397 bool r = true;
398 if (s == "left")
399 mode = Output_Left;
400 else if (s == "right")
401 mode = Output_Right;
402 else if (s == "stereo")
403 mode = Output_OpenGL_Stereo;
404 else if (s == "alternating")
405 mode = Output_Alternating;
406 else if (s == "hdmi-frame-pack")
407 mode = Output_HDMI_Frame_Pack;
408 else if (s == "left-right")
409 mode = Output_Left_Right;
410 else if (s == "left-right-half")
411 mode = Output_Left_Right_Half;
412 else if (s == "right-left")
413 mode = Output_Right_Left;
414 else if (s == "right-left-half")
415 mode = Output_Right_Left_Half;
416 else if (s == "top-bottom")
417 mode = Output_Top_Bottom;
418 else if (s == "top-bottom-half")
419 mode = Output_Top_Bottom_Half;
420 else if (s == "bottom-top")
421 mode = Output_Bottom_Top;
422 else if (s == "bottom-top-half")
423 mode = Output_Bottom_Top_Half;
424 else if (s == "even-odd-rows")
425 mode = Output_Even_Odd_Rows;
426 else if (s == "even-odd-columns")
427 mode = Output_Even_Odd_Columns;
428 else if (s == "checkerboard")
429 mode = Output_Checkerboard;
430 else if (s == "red-cyan-dubois")
431 mode = Output_Red_Cyan_Dubois;
432 else if (s == "red-cyan-fullcolor")
433 mode = Output_Red_Cyan_FullColor;
434 else if (s == "red-cyan-halfcolor")
435 mode = Output_Red_Cyan_HalfColor;
436 else if (s == "red-cyan-monochrome")
437 mode = Output_Red_Cyan_Monochrome;
438 else if (s == "green-magenta-dubois")
439 mode = Output_Green_Magenta_Dubois;
440 else if (s == "green-magenta-fullcolor")
441 mode = Output_Green_Magenta_FullColor;
442 else if (s == "green-magenta-halfcolor")
443 mode = Output_Green_Magenta_HalfColor;
444 else if (s == "green-magenta-monochrome")
445 mode = Output_Green_Magenta_Monochrome;
446 else if (s == "amber-blue-dubois")
447 mode = Output_Amber_Blue_Dubois;
448 else if (s == "amber-blue-fullcolor")
449 mode = Output_Amber_Blue_FullColor;
450 else if (s == "amber-blue-halfcolor")
451 mode = Output_Amber_Blue_HalfColor;
452 else if (s == "amber-blue-monochrome")
453 mode = Output_Amber_Blue_Monochrome;
454 else if (s == "red-green-monochrome")
455 mode = Output_Red_Green_Monochrome;
456 else if (s == "red-blue-monochrome")
457 mode = Output_Red_Blue_Monochrome;
458 else
459 r = false;
460 if (ok)
461 *ok = r;
462 return mode;
463 }
464
465 const char* loopModeToString(LoopMode mode)
466 {
467 switch (mode) {
468 case Loop_Off:
469 return "off";
470 break;
471 case Loop_One:
472 return "one";
473 break;
474 case Loop_All:
475 return "all";
476 break;
477 }
478 return nullptr;
479
480 }
481
482 QString loopModeToStringUI(LoopMode mode)
483 {
484 switch (mode) {
485 case Loop_Off:
486 return QCoreApplication::translate("Mode", "Loop off");
487 break;
488 case Loop_One:
489 return QCoreApplication::translate("Mode", "Loop one");
490 break;
491 case Loop_All:
492 return QCoreApplication::translate("Mode", "Loop all");
493 break;
494 }
495 return QString();
496 }
497
498 LoopMode loopModeFromString(const QString& s, bool* ok)
499 {
500 LoopMode mode = Loop_Off;
501 bool r = true;
502 if (s == "off")
503 mode = Loop_Off;
504 else if (s == "one")
505 mode = Loop_One;
506 else if (s == "all")
507 mode = Loop_All;
508 else
509 r = false;
510 if (ok)
511 *ok = r;
512 return mode;
513 }
514
515 const char* waitModeToString(WaitMode mode)
516 {
517 switch (mode) {
518 case Wait_Off:
519 return "off";
520 break;
521 case Wait_On:
522 return "on";
523 break;
524 }
525 return nullptr;
526
527 }
528
529 QString waitModeToStringUI(WaitMode mode)
530 {
531 switch (mode) {
532 case Wait_Off:
533 return QCoreApplication::translate("Mode", "Wait off");
534 break;
535 case Wait_On:
536 return QCoreApplication::translate("Mode", "Wait on");
537 break;
538 }
539 return QString();
540 }
541
542 WaitMode waitModeFromString(const QString& s, bool* ok)
543 {
544 WaitMode mode = Wait_Off;
545 bool r = true;
546 if (s == "off")
547 mode = Wait_Off;
548 else if (s == "on")
549 mode = Wait_On;
550 else
551 r = false;
552 if (ok)
553 *ok = r;
554 return mode;
555 }