1 /*
2  * Strawberry Music Player
3  * This file was part of Clementine.
4  * Copyright 2010, David Sansome <me@davidsansome.com>
5  * Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
6  *
7  * Strawberry 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  * Strawberry 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 Strawberry.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ALBUMCOVEREXPORT_H
23 #define ALBUMCOVEREXPORT_H
24 
25 #include "config.h"
26 
27 #include <QObject>
28 #include <QDialog>
29 #include <QString>
30 
31 class QWidget;
32 class Ui_AlbumCoverExport;
33 
34 // Controller for the "Export covers" dialog.
35 class AlbumCoverExport : public QDialog {
36   Q_OBJECT
37 
38  public:
39   explicit AlbumCoverExport(QWidget *parent = nullptr);
40   ~AlbumCoverExport() override;
41 
42   enum OverwriteMode {
43     OverwriteMode_None = 0,
44     OverwriteMode_All = 1,
45     OverwriteMode_Smaller = 2
46   };
47 
48   struct DialogResult {
49     DialogResult() : cancelled_(false), export_downloaded_(false), export_embedded_(false), forcesize_(false), width_(0), height_(0) {}
50     bool cancelled_;
51 
52     bool export_downloaded_;
53     bool export_embedded_;
54 
55     QString filename_;
56     OverwriteMode overwrite_;
57     bool forcesize_;
58     int width_;
59     int height_;
60 
61     bool IsSizeForced() const {
62       return forcesize_ && width_ > 0 && height_ > 0;
63     }
64 
65     bool RequiresCoverProcessing() const {
66       return IsSizeForced() || overwrite_ == OverwriteMode_Smaller;
67     }
68   };
69 
70   DialogResult Exec();
71 
72  private slots:
73   void ForceSizeToggled(int state);
74 
75  private:
76   Ui_AlbumCoverExport *ui_;
77 
78   static const char *kSettingsGroup;
79 };
80 
81 #endif  // ALBUMCOVEREXPORT_H
82