Menu

[r556]: / src / biblesettingwidget.cpp  Maximize  Restore  History

Download this file

320 lines (270 with data), 10.4 kB

  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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#include "biblesettingwidget.h"
#include "ui_biblesettingwidget.h"
BibleSettingWidget::BibleSettingWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::BibleSettingWidget)
{
ui->setupUi(this);
}
BibleSettingWidget::~BibleSettingWidget()
{
delete ui;
}
void BibleSettingWidget::setSettings(BibleSettings settings)
{
mySettings = settings;
loadSettings();
}
BibleSettings BibleSettingWidget::getSettings()
{
int pbx = ui->comboBox_primaryBible->currentIndex();
int sbx = ui->comboBox_secondaryBible->currentIndex();
int tbx = ui->comboBox_trinaryBible->currentIndex();
int obx = ui->comboBox_operatorBible->currentIndex();
// QString pb,sb,tb,ob;
// Get Bible version settings
if(pbx != -1)
{
// Primary
mySettings.primaryBible = bible_id_list.at(pbx);
// Secondary
if(sbx <=0)
mySettings.secondaryBible = "none";
else
mySettings.secondaryBible = secondary_id_list.at(sbx-1);
// Trinary
if(tbx <=0)
mySettings.trinaryBible = "none";
else
mySettings.trinaryBible = trinary_id_list.at(tbx-1);
// Operatror
if(obx <=0)
mySettings.operatorBible = "same";
else
mySettings.operatorBible = operator_id_list.at(obx-1);
}
else
{
// There are no bibles in the database
mySettings.primaryBible = "none";
mySettings.secondaryBible = "none";
mySettings.trinaryBible = "none";
mySettings.operatorBible = "same";
}
// Effects
mySettings.useShadow = ui->checkBox_useShadow->isChecked();
mySettings.useFading = ui->checkBox_useFading->isChecked();
mySettings.useBlurShadow = ui->checkBox_useBlurredShadow->isChecked();
// Backgroud
mySettings.useBackground = ui->groupBox_Background->isChecked();
mySettings.backgroundPath = ui->lineEdit_BackPath->text();
//Alingment
mySettings.textAlingmentV = ui->comboBox_verticalAling->currentIndex();
mySettings.textAlingmentH = ui->comboBox_horizontalAling->currentIndex();
mySettings.useAbbriviations = ui->checkBox_abbiviations->isChecked();
// Max screen use
mySettings.maxScreen = ui->spinBox_maxScreen->value();
if(ui->radioButton_maxTop->isChecked())
mySettings.maxScreenFrom = "top";
if(ui->radioButton_maxBottom->isChecked())
mySettings.maxScreenFrom = "bottom";
return mySettings;
}
void BibleSettingWidget::loadSettings()
{
// Clear items if exitst
bibles.clear();
bible_id_list.clear();
// Get Bibles that exist in the database
QSqlQuery sq;
sq.exec("SELECT bible_name, id FROM BibleVersions");
while(sq.next()){
bibles << sq.value(0).toString();
bible_id_list << sq.value(1).toString();
}
sq.clear();
// Fill bibles comboboxes
ui->comboBox_primaryBible->clear();
ui->comboBox_primaryBible->addItems(bibles);
ui->comboBox_secondaryBible->addItem(tr("None"));
ui->comboBox_secondaryBible->addItems(bibles);
ui->comboBox_trinaryBible->addItem(tr("None"));
ui->comboBox_trinaryBible->addItems(bibles);
ui->comboBox_operatorBible->addItem(tr("Same as primary Bible"));
ui->comboBox_operatorBible->addItems(bibles);
// Set current primary bible
if(mySettings.primaryBible == "none")
ui->comboBox_primaryBible->setCurrentIndex(0);
else
ui->comboBox_primaryBible->setCurrentIndex(bible_id_list.indexOf(mySettings.primaryBible));
// Set current secondary bible
if(mySettings.secondaryBible == "none")
ui->comboBox_secondaryBible->setCurrentIndex(0);
else
ui->comboBox_secondaryBible->setCurrentIndex(bible_id_list.indexOf(mySettings.secondaryBible)+1);
// Set current trinaty bibile
if(mySettings.trinaryBible == "none")
ui->comboBox_trinaryBible->setCurrentIndex(0);
else
ui->comboBox_trinaryBible->setCurrentIndex(bible_id_list.indexOf(mySettings.trinaryBible)+1);
updateSecondaryBibleMenu();
// Set current operator bibile
if(mySettings.operatorBible == "same")
ui->comboBox_operatorBible->setCurrentIndex(0);
else
ui->comboBox_operatorBible->setCurrentIndex(bible_id_list.indexOf(mySettings.operatorBible)+1);
updateOperatorBibleMenu();
// Set Effects
ui->checkBox_useShadow->setChecked(mySettings.useShadow);
ui->checkBox_useFading->setChecked(mySettings.useFading);
ui->checkBox_useBlurredShadow->setChecked(mySettings.useBlurShadow);
// Set background use
ui->groupBox_Background->setChecked(mySettings.useBackground);
ui->lineEdit_BackPath->setText(mySettings.backgroundPath);
// Set alingment
ui->comboBox_verticalAling->setCurrentIndex(mySettings.textAlingmentV);
ui->comboBox_horizontalAling->setCurrentIndex(mySettings.textAlingmentH);
// Set text color
QPalette p;
p.setColor(QPalette::Base,mySettings.textColor);
ui->graphicView_textColor->setPalette(p);
// Set text font
QString st(QString("%1: %2").arg(mySettings.textFont.rawName()).arg(mySettings.textFont.pointSize()));
if(mySettings.textFont.bold())
st += ", Bold";
if(mySettings.textFont.italic())
st += ", Italic";
if(mySettings.textFont.strikeOut())
st += ", StrikeOut";
if(mySettings.textFont.underline())
st += ", Underline";
ui->label_font->setText(st);
// Set abbriviations use
ui->checkBox_abbiviations->setChecked(mySettings.useAbbriviations);
// Set max screen use
ui->spinBox_maxScreen->setValue(mySettings.maxScreen);
if(mySettings.maxScreenFrom == "top")
ui->radioButton_maxTop->setChecked(true);
else if(mySettings.maxScreenFrom == "bottom")
ui->radioButton_maxBottom->setChecked(true);
}
void BibleSettingWidget::updateSecondaryBibleMenu()
{
QString pbible = ui->comboBox_primaryBible->currentText();
QString sbible = ui->comboBox_secondaryBible->currentText();
secondary_bibles = bibles;
secondary_bibles.removeOne(pbible);
secondary_id_list = bible_id_list;
secondary_id_list.removeAt(ui->comboBox_primaryBible->currentIndex());
ui->comboBox_secondaryBible->clear();
ui->comboBox_secondaryBible->addItem(tr("None"));
ui->comboBox_secondaryBible->addItems(secondary_bibles);
int i = ui->comboBox_secondaryBible->findText(sbible);
if( i != -1 )
// The same secondary bible is still available
ui->comboBox_secondaryBible->setCurrentIndex(i);
updateTrinaryBibleMenu();
}
void BibleSettingWidget::updateTrinaryBibleMenu()
{
if (ui->comboBox_secondaryBible->currentIndex() == 0)
{
ui->comboBox_trinaryBible->setCurrentIndex(0);
ui->comboBox_trinaryBible->setEnabled(false);
}
else
{
ui->comboBox_trinaryBible->setEnabled(true);
QString sbible = ui->comboBox_secondaryBible->currentText();
QString tbible = ui->comboBox_trinaryBible->currentText();
QStringList trinary_bibles = secondary_bibles;
trinary_bibles.removeOne(sbible);
trinary_id_list = secondary_id_list;
trinary_id_list.removeAt(ui->comboBox_secondaryBible->currentIndex()-1);
ui->comboBox_trinaryBible->clear();
ui->comboBox_trinaryBible->addItem(tr("None"));
ui->comboBox_trinaryBible->addItems(trinary_bibles);
int i = ui->comboBox_trinaryBible->findText(tbible);
if( i != -1 )
// The same secondary bible is still available
ui->comboBox_trinaryBible->setCurrentIndex(i);
}
}
void BibleSettingWidget::updateOperatorBibleMenu()
{
QString pbible = ui->comboBox_primaryBible->currentText();
QString obible = ui->comboBox_operatorBible->currentText();
QStringList operator_bibles = bibles;
operator_bibles.removeOne(pbible);
operator_id_list = bible_id_list;
operator_id_list.removeAt(ui->comboBox_primaryBible->currentIndex());
ui->comboBox_operatorBible->clear();
ui->comboBox_operatorBible->addItem(tr("Same as primary Bible"));
ui->comboBox_operatorBible->addItems(operator_bibles);
int i = ui->comboBox_operatorBible->findText(obible);
if( i != -1 )
// The same operaotr bible is still available
ui->comboBox_operatorBible->setCurrentIndex(i);
}
void BibleSettingWidget::on_comboBox_primaryBible_activated(const QString &arg1)
{
updateSecondaryBibleMenu();
updateOperatorBibleMenu();
}
void BibleSettingWidget::on_comboBox_secondaryBible_activated(const QString &arg1)
{
updateTrinaryBibleMenu();
}
void BibleSettingWidget::on_comboBox_trinaryBible_activated(const QString &arg1)
{
// qDebug()<< trinary_id_list.at(ui->comboBox_trinaryBible->currentIndex()-1);
}
void BibleSettingWidget::on_button_BrowseBackground_clicked()
{
QString filename = QFileDialog::getOpenFileName(this, tr("Select a image for Bible wallpaper"),
".", tr("Images (*.png *.jpg *.jpeg)"));
if(!filename.isNull())
ui->lineEdit_BackPath->setText(filename);
}
void BibleSettingWidget::on_button_textColor_clicked()
{
QColor c(QColorDialog::getColor(mySettings.textColor,this));
if(c.isValid())
mySettings.textColor = c;
QPalette p;
p.setColor(QPalette::Base,mySettings.textColor);
ui->graphicView_textColor->setPalette(p);
}
void BibleSettingWidget::on_button_font_clicked()
{
bool ok;
QFont font = QFontDialog::getFont(&ok,mySettings.textFont,this);
if(ok)
mySettings.textFont = font;
QString st(QString("%1: %2").arg(mySettings.textFont.rawName()).arg(mySettings.textFont.pointSize()));
if(mySettings.textFont.bold())
st += ", Bold";
if(mySettings.textFont.italic())
st += ", Italic";
if(mySettings.textFont.strikeOut())
st += ", StrikeOut";
if(mySettings.textFont.underline())
st += ", Underline";
ui->label_font->setText(st);
}
void BibleSettingWidget::on_pushButton_default_clicked()
{
BibleSettings b;
mySettings = b;
loadSettings();
}
void BibleSettingWidget::on_checkBox_useShadow_stateChanged(int arg1)
{
if(arg1==2)
ui->checkBox_useBlurredShadow->setEnabled(true);
else
{
ui->checkBox_useBlurredShadow->setChecked(false);
ui->checkBox_useBlurredShadow->setEnabled(false);
}
}