1 /*
2 * This file is part of Converseen, an open-source batch image converter
3 * and resizer.
4 *
5 * (C) Francesco Mondello 2009 - 2021
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 * Contact e-mail: Francesco Mondello <faster3ck@gmail.com>
21 *
22 */
23 
24 #ifndef MAINWINDOWIMPL_H
25 #define MAINWINDOWIMPL_H
26 
27 #include <QMainWindow>
28 #include <QFileInfo>
29 #include <QList>
30 #include <QSettings>
31 #include <QDropEvent>
32 #include <QFileDialog>
33 #include <QMessageBox>
34 #include <QFileDialog>
35 #include <QInputDialog>
36 #include <QDesktopServices>
37 #include <QUrl>
38 #include "ui_mainwindow.h"
39 #include "converter.h"
40 #include "dialogquality.h"
41 #include "dialogconversionstatus.h"
42 #include "pixtreewidget.h"
43 #include "mylabelpreviewer.h"
44 #include "cachingsystem.h"
45 
46 class QDropEvent;
47 
48 class MainWindowImpl : public QMainWindow, public Ui::MainWindow
49 {
50     Q_OBJECT
51 public:
52     MainWindowImpl( QWidget * parent = 0, Qt::WindowFlags f = 0 );
53     ~MainWindowImpl();
54     void importListFromArgv(QString fileName);
55 
56 private:
57     void createActions();
58     void setupMenu();
59     void createContextMenu();
60     void setFileInList(QString fileName);
61     bool checkDuplicates(QStringList fileNames, int e);
62     void convert();
63     void fillTreeView();
64     void loadFormats();
65     void loadOptions();
66     void loadQuality();
67 
68     void deleteItems(int selectedItems);
69 
70     void loadPreview(QString fileName);
71     void showPreviewAndInfos();   // quello che succede alla selezione dell'item.
72 
73     void resetDisplays();
74 
75     void checkVersion();
76 
77     void saveSettings();    // This method is called when the program is closed
78 
79     QString renameFileNameOnPrefixSuffix(QString oldFileName);
80     QString renameFileNameOnProgressiveN(QString oldFileName);
81     QString destinationPath();
82 
83     QList<ImageAttributes> *iAList;
84 
85     Converter *convertThread;
86     DialogConversionStatus *dlgCStatus;
87     int curr_index;             // Indice dell'immagine che si sta processando dalla lista iAList
88 
89     int jpgQuality;             // Imposta la qualità jpg anche nel file ini
90     int pngQuality;             // Imposta la qualità png anche nel file ini
91     int img_width,img_height;  /* vengono riempiti solo quando un'immagine è selezionata.
92                                   Riempire con dati su ImageAttributes potrebbe essere lento e non conveniente! */
93     int new_img_width,new_img_height; /* Vengono riempiti con numeri che rappresentano i pixel dato che non capisco come
94                                          si passa la corretta percentuale in virgola mobile a geometry*/
95     double m_xResolution, m_yResolution;
96 
97     bool abort_all;
98 
99     int m_progressiveNren;      // Incremented when the progressive number renaming is checked
100 
101     QString m_bgColor;
102 
103     IMFilterType m_resamplingFilter;
104 
105 private slots:
106     void loadFiles(QStringList fileNames);
107     void openFiles();
108     void addFiles();
109     void importIcoFile();
110     void importPdfFile();
111 
112     void openMultipageFile(QString fileName);   // !
113     void elabora();
114     void setCurrentDirectory();
115     void openOutDirectory();
116     void removeItems();
117     void removeAllItems();
118     void setQuality();
119     void selectGeometryUnit(QString unit);
120     void relativeSizeW();
121     void relativeSizeH();
122 
123     void showImageInformations(int orig_w, int orig_h, double orig_dens_x, double orig_dens_y);
124 
125     void onItemSelection();
126     void editSettings();
127 
128     void about();
129 
130     void enableRenameLine();
131     void enableShowPreview();
132     void enableProgressiveSpin();
133 
134     void showNewSizePreview();
135 
136     void onPushResetClick();
137 
138     void startConversion();
139     void nextConversion(int conv_status);
140 
141     void overwriteDialog(QString baseName);
142 
143     void stopProcess();
144     void errorMessage(QString err_status);
145 
146     void choseBackgroundColor();
147 
148     void openPaypalLink();
149 
150     void checkForUpdates();
151     void bugReport();
152 
153     void setRelativeSizeCheckboxes(int state);
154 };
155 #endif // MAINWINDOWIMPL_H
156