This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
GeneralSettingsTab.cpp
276 lines (234 loc) · 9.3 KB
/
GeneralSettingsTab.cpp
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/***************************************************************************//**
* @brief Thumbnail me 3.0
* Thumbnail me is a user interface for Movie thumbnailer.
* Generate thumbnails from any movie is now easier !
*
* @file GeneralSettingsTab.cpp
* @class GeneralSettingsTab
* Cette classe permet de configurer des paramètres généraux sur Thumbnail Me.
* Elle génère un widget disponible dans le widget "Settings".
*
* @author Quentin Rousseau\n
* @note Copyright (C) 2011-2012 Quentin Rousseau\n
* License: GNU General Public License version 2 (GPLv2) - http://www.gnu.org/licenses/gpl-2.0.html\n
* Site web: www.thumbnailme.com\n
* Email: [email protected]
*
* @since 3.0
* @version 3.0
* @date 2011-2012
*******************************************************************************/
#include "GeneralSettingsTab.h"
#include "IniManager.h"
#include <QGridLayout>
#include "defines.h"
/**
*@brief Constructeur.
*/
GeneralSettingsTab::GeneralSettingsTab()
{
settings = new QSettings(QSettings::IniFormat,DEFAULT_PATH_INI,APPLICATION_NAME,DEFAULT_FILE_INI,this);
//NeverAskSaveConfigOnExit
neverAskSaveConfigOnExit = new QCheckBox(this);
//neverLoadLastConfiguration
neverLoadLastConfiguration = new QCheckBox(this);
/*Background Color PreviewGraphicView Initialisation*/
backgroundColorPreviewGraphicViewLabel = new QLabel(this);
backgroundColorPicker = new QtColorPicker(this);
backgroundColorPicker->setStandardColors();
/*Output Suffix Initialisation*/
outputSuffixLineEdit = new QLineEdit(this);
outputSuffixCheckBox = new QCheckBox(this);
/*OpenGl Initialisation*/
activeOpenGlGraphicViewCheckBox = new QCheckBox(tr("Activate openGL to preview thumbnails"));
/*Animate Pixmap checkbox*/
animatedPixmapCheckBox = new QCheckBox(tr("Animate pixmap while rendering"));
/* Core processing */
threadsCountForProcessingLabel = new QLabel(this);
threadsCountForProcessingSpinBox = new QSpinBox(this);
threadsCountForProcessingSpinBox->setAccessibleName("TEST");
threadsCountForProcessingSpinBox->setMinimum(1);
threadsCountForProcessingSpinBox->setMaximum(QThread::idealThreadCount());
//Mise en place des layout
generalGroupBox = new QGroupBox(this);
QGridLayout *generalGroupBoxLayout = new QGridLayout(this);
generalGroupBoxLayout->addWidget(neverAskSaveConfigOnExit,0,0,1,3);
generalGroupBoxLayout->addWidget(neverLoadLastConfiguration,1,0,1,3);
generalGroupBoxLayout->addWidget(threadsCountForProcessingLabel,2,0);
generalGroupBoxLayout->addWidget(threadsCountForProcessingSpinBox,2,1,1,2);
generalGroupBoxLayout->addWidget(outputSuffixCheckBox,3,0);
generalGroupBoxLayout->addWidget(outputSuffixLineEdit,3,1);
generalGroupBoxLayout->addWidget(animatedPixmapCheckBox,4,0,1,2);
generalGroupBoxLayout->addWidget(activeOpenGlGraphicViewCheckBox,5,0,1,2);
generalGroupBoxLayout->addWidget(backgroundColorPreviewGraphicViewLabel,6,0);
generalGroupBoxLayout->addWidget(backgroundColorPicker,6,1,1,2);
generalGroupBox->setLayout(generalGroupBoxLayout);
QHBoxLayout *layoutPrincipal = new QHBoxLayout(this);
layoutPrincipal->addWidget(generalGroupBox);
this->initializeWidget();
this->setLayout(layoutPrincipal);
this->retranslate();
/*Connections*/
connect(outputSuffixCheckBox, SIGNAL(clicked(bool)), outputSuffixLineEdit, SLOT(setEnabled(bool)));
}
/**
*@brief Destructeur.
*/
GeneralSettingsTab::~GeneralSettingsTab()
{
}
/**
*@brief Initialisation des paramètres du widget.
*/
void GeneralSettingsTab::initializeWidget()
{
//NeverAskSaveConfigOnExit Initialisation
if (settings->value("Extras/neverAskSaveConfigOnExit").isNull())
settings->setValue("Extras/neverAskSaveConfigOnExit","false");
if (settings->value("Extras/neverAskSaveConfigOnExit").toBool())
neverAskSaveConfigOnExit->setCheckState(Qt::Checked);
else neverAskSaveConfigOnExit->setCheckState(Qt::Unchecked);
//NeverLoadLastConfiguration Initialisation
if (settings->value("Extras/neverLoadLastConfiguration").isNull())
settings->setValue("Extras/neverLoadLastConfiguration","false");
if (settings->value("Extras/neverLoadLastConfiguration").toBool())
neverLoadLastConfiguration->setCheckState(Qt::Checked);
else neverLoadLastConfiguration->setCheckState(Qt::Unchecked);
//Core count Initialisation
if (settings->value("Extras/coresToProcessCount").isNull())
{
settings->setValue("Extras/coresToProcessCount",QThread::idealThreadCount());
threadsCountForProcessingSpinBox->setValue(QThread::idealThreadCount());
}
else threadsCountForProcessingSpinBox->setValue(settings->value("Extras/coresToProcessCount").toInt());
//OutputSuffix Initialisation
if (!settings->value("Extras/outputSuffix").toString().isEmpty())
{
outputSuffixCheckBox->setChecked(true);
outputSuffixLineEdit->setEnabled(true);
outputSuffixLineEdit->setText(settings->value("Extras/outputSuffix").toString());
}
else
{
outputSuffixLineEdit->setEnabled(false);
}
//Animated Pixmap Initialisation
if (settings->value("Extras/animatedPixmap").isNull())
settings->setValue("Extras/animatedPixmap","true");
if (settings->value("Extras/animatedPixmap").toBool())
animatedPixmapCheckBox->setCheckState(Qt::Checked);
else animatedPixmapCheckBox->setCheckState(Qt::Unchecked);
//ActiveOpengGl Initialisation
if (settings->value("Extras/activeOpenGl").isNull())
settings->setValue("Extras/activeOpenGl","true");
if (settings->value("Extras/activeOpenGl").toBool())
activeOpenGlGraphicViewCheckBox->setCheckState(Qt::Checked);
else activeOpenGlGraphicViewCheckBox->setCheckState(Qt::Unchecked);
//BackgroundColorPreviewWindow Initialisation
if (settings->value("Extras/backgroundColorPreviewWindow").isNull())
backgroundColorPicker->setCurrentColor(Qt::lightGray);
else backgroundColorPicker->setCurrentColor("#"+settings->value("Extras/backgroundColorPreviewWindow").toString());
}
/**
*@brief Retourne vrai si la checkbox "neverAskSaveConfigOnExit" est coché sinon faux.
*@return bool - Vrai ou faux.
*/
bool GeneralSettingsTab::isNeverAskSaveConfigOnExitChecked()
{
return neverAskSaveConfigOnExit->isChecked();
}
/**
*@brief Retourne vrai si la checkbox "neverLoadLastConfiguration" est coché sinon faux.
*@return bool - Vrai ou faux.
*/
bool GeneralSettingsTab::isNeverLoadLastConfigurationChecked()
{
return neverLoadLastConfiguration->isChecked();
}
/**
*@brief Retourne vrai si la checkbox "outputSuffixCheckBox" est coché sinon faux.
*@return bool - Vrai ou faux.
*/
bool GeneralSettingsTab::isOutputSuffixCheckBoxChecked()
{
return outputSuffixCheckBox->isChecked();
}
/**
*@brief Retourne vrai si la checkbox "activeOpenGl" est coché sinon faux.
*@return bool - Vrai ou faux.
*/
bool GeneralSettingsTab::isActiveOpenGlGraphicViewCheckBoxChecked()
{
return activeOpenGlGraphicViewCheckBox->isChecked();
}
/**
*@brief Setteur de la checkBox "Activer OpenGl".
*@param value Vrai ou faux.
*/
void GeneralSettingsTab::setActiveOpenGlGraphicViewCheckBoxChecked(bool value)
{
activeOpenGlGraphicViewCheckBox->setChecked(value);
}
/**
*@brief Retourne vrai si la checkbox animatedPixmap" est coché sinon faux.
*@return bool - Vrai ou faux.
*/
bool GeneralSettingsTab::isAnimatedPixmapChecked()
{
return animatedPixmapCheckBox->isChecked();
}
/**
*@brief Retourne le suffixe de fichier paramétré.
*@return QString - Suffixe.
*/
QString GeneralSettingsTab::getOutputSuffixLineEdit()
{
return outputSuffixLineEdit->text();
}
/**
*@brief Retourne la couleur de "Arrière plan de la fenêtre de prévisualisation".
*@return QColor - Couleur.
*/
QColor GeneralSettingsTab::getColorBackgroundPreviewGraphicView()
{
return backgroundColorPicker->currentColor();
}
/**
*@brief Retourne le nombre de coeurs à utiliser pour traiter les images".
*@return int - Nombre de coeurs.
*/
int GeneralSettingsTab::getCoresCountToProcess()
{
return threadsCountForProcessingSpinBox->value();
}
/**
*@brief Fonction annulation - Réaffecte les paramètres d'origine.
*/
void GeneralSettingsTab::reject()
{
this->initializeWidget();
}
/**
*@brief ChangeEvent.
*@param *event Evenement.
*/
void GeneralSettingsTab::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange)
retranslate();
QWidget::changeEvent(event);
}
/**
*@brief Fonction de traduction dynamique.
*/
void GeneralSettingsTab::retranslate()
{
generalGroupBox->setTitle( tr("General Settings") );
neverAskSaveConfigOnExit->setText( tr("Never ask me to save my configuration on exit") );
neverLoadLastConfiguration->setText( tr("Don't load the last configuration on startup") );
threadsCountForProcessingLabel->setText( tr("Maximum threads count for processing") + " : " );
backgroundColorPreviewGraphicViewLabel->setText( tr("Background color of preview window") + " : " );
outputSuffixCheckBox->setText( tr("Output suffix:") );
activeOpenGlGraphicViewCheckBox->setText( tr("Activate openGL to preview thumbnails") );
animatedPixmapCheckBox->setText( tr("Animate pixmap while rendering") );
}