1 /* GUI_CoverEdit.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
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 
22 
23 #ifndef GUI_COVEREDIT_H
24 #define GUI_COVEREDIT_H
25 
26 #include "Gui/Utils/Widgets/Widget.h"
27 #include "Utils/Pimpl.h"
28 
UI_FWD(GUI_CoverEdit)29 UI_FWD(GUI_CoverEdit)
30 
31 namespace Tagging
32 {
33 	class Editor;
34 }
35 
36 class MetaData;
37 class MetaDataList;
38 class QPixmap;
39 
40 namespace Tagging
41 {
42 	class Editor;
43 }
44 
45 /**
46  * @brief The GUI_CoverEdit class
47  * @ingroup GuiTagging
48  */
49 class GUI_CoverEdit :
50 	public Gui::Widget
51 {
52 	Q_OBJECT
53 	PIMPL(GUI_CoverEdit)
54 	UI_CLASS(GUI_CoverEdit)
55 
56 	public:
57 		/**
58 		 * @brief GUI_CoverEdit
59 		 * @param editor The same tag editor as used in GUI_TagEdit
60 		 * @param parent
61 		 */
62 		explicit GUI_CoverEdit(Tagging::Editor* tagEditor, QWidget* parent);
63 		~GUI_CoverEdit() override;
64 
65 		/**
66 		 * @brief Shows the current cover (if there) and offers to replace it
67 		 * Every other widget is hidden
68 		 */
69 		void reset();
70 
71 		/**
72 		 * @brief refetches the track from the tag editor
73 		 * and sets the cover to the left button
74 		 */
75 		void refreshCurrentTrack();
76 
77 		/**
78 		 * @brief sets the current index for a track which is currently processed
79 		 * @param index
80 		 */
81 		void setCurrentIndex(int index);
82 
83 		/**
84 		 * @brief returns the new cover for a current track.
85 		 * @param index
86 		 * @return empty pixmap if index is invalid, or no new cover is desired a track
87 		 */
88 		QPixmap selectedCover(int index) const;
89 
90 	private:
91 		void setCover(const MetaData& track);
92 		void showReplacementField(bool b);
93 		bool isCoverReplacementActive() const;
94 
95 	private slots:
96 		/**
97 		 * @brief When button has finished setting up its button
98 		 */
99 		void coverChanged();
100 		void replaceToggled(bool b);
101 		void coverAllToggled(bool b);
102 		void setMetadata(const MetaDataList& tracks);
103 
104 	protected:
105 		void languageChanged() override;
106 };
107 
108 #endif // GUI_COVEREDIT_H
109