-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathconfigdialog.cpp
1431 lines (1293 loc) · 55.6 KB
/
configdialog.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
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
* copyright : (C) 2003-2007 by Pascal Brachet *
* http://www.xm1math.net/texmaker/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qjsonarray.h"
#ifdef INTERNAL_TERMINAL
#include <qtermwidget5/qtermwidget.h>
#endif
#include "configdialog.h"
#include "configmanager.h"
#include "updatechecker.h"
#include "qdocument.h"
#include "spellerutility.h"
#include "latexeditorview_config.h"
#include "smallUsefulFunctions.h"
#include "qformatconfig.h"
#include "filedialog.h"
#include <QJsonDocument>
const QString ShortcutDelegate::addRowButton = "<internal: add row>";
const QString ShortcutDelegate::deleteRowButton = "<internal: delete row>";
static const QString nameSeparator = "separator";
ShortcutComboBox::ShortcutComboBox(QWidget *parent): QComboBox(parent)
{
const Qt::Key SpecialKeys[] = {Qt::Key_Tab, Qt::Key_Backspace, Qt::Key_Delete};
const int SpecialKeysCount = 3;
setObjectName("ShortcutComboBox");
setMaxVisibleItems(15);
addItem(tr("<default>"));
addItem(tr("<none>"));
for (int k = Qt::Key_F1; k <= Qt::Key_F12; k++)
addItem(QKeySequence(k).toString(SHORTCUT_FORMAT));
for (int m = 0; m <= 1; m++)
for (int c = 0; c <= 1; c++)
for (int s = 0; s <= 1; s++)
for (int a = 0; a <= 1; a++) {
if (a || c || s || m) {
for (int k = Qt::Key_F1; k <= Qt::Key_F12; k++)
addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META + k).toString(SHORTCUT_FORMAT));
for (int k = Qt::Key_0; k <= Qt::Key_9; k++)
addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META + k).toString(SHORTCUT_FORMAT));
for (int k = Qt::Key_A; k <= Qt::Key_Z; k++)
addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META + k).toString(SHORTCUT_FORMAT));
if (a || c) {
for (int k = Qt::Key_Left; k <= Qt::Key_Down; k++)
addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META + k).toString(SHORTCUT_FORMAT));
for (int k = Qt::Key_PageUp; k <= Qt::Key_PageDown; k++)
addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META + k).toString(SHORTCUT_FORMAT));
}
}
for (int ik = 0; ik < SpecialKeysCount; ik++)
addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META
+ SpecialKeys[ik]).toString(SHORTCUT_FORMAT));
//addItem(QKeySequence(c * Qt::CTRL + s * Qt::SHIFT + a * Qt::ALT + m * Qt::META + Qt::Key_Tab).toString(SHORTCUT_FORMAT));
}
setEditable(true);
}
void ShortcutComboBox::keyPressEvent(QKeyEvent *e)
{
if ( (e->modifiers() != 0 && e->text() != "+" && e->key() != Qt::Key_Alt && e->key() != Qt::Key_Shift && e->key() != Qt::Key_Control && e->key() != Qt::Key_AltGr && e->key() != Qt::Key_Meta && e->key() != 0 && e->key() != Qt::Key_Super_L && e->key() != Qt::Key_Super_R)
|| (e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35)
|| (e->key() == Qt::Key_Home)
|| (e->key() == Qt::Key_End)
|| (e->key() == Qt::Key_PageUp)
|| (e->key() == Qt::Key_PageDown)
|| (e->key() == Qt::Key_Up)
|| (e->key() == Qt::Key_Down)
) {
// FIXME: Qt currently does not handle KeypadModifier correctly.
// as a workaround we just take it away, so there is no difference between keypad and non-keypad keys,
// but at least keypad keys don't produce rubbish. See also sf.net bug item 3525266
QString newShortCut = QKeySequence((e->modifiers() | e->key()) & ~Qt::KeypadModifier).toString(SHORTCUT_FORMAT);
int index = findText(newShortCut);
if (index != -1) setCurrentIndex(index);
else setEditText(newShortCut);
return;
}
QComboBox::keyPressEvent(e);
}
void ShortcutComboBox::focusInEvent(QFocusEvent *e)
{
Q_UNUSED(e)
this->lineEdit()->selectAll();
}
ShortcutDelegate::ShortcutDelegate(QObject *parent): treeWidget(nullptr)
{
Q_UNUSED(parent)
}
QWidget *ShortcutDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option ,
const QModelIndex &index) const
{
Q_UNUSED(option)
if (!index.isValid()) return nullptr;
const QAbstractItemModel *model = index.model();
if (model->index(index.row(), 0, index.parent()).isValid() &&
model->data(model->index(index.row(), 0, index.parent()), Qt::DisplayRole) == deleteRowButton) {
//editor key replacement
if (index.column() == 0) return nullptr;
return new QLineEdit(parent);
}
//basic key
if (isBasicEditorKey(index)) {
if (index.column() == 0) {
QComboBox *ops = new QComboBox(parent);
foreach (int o, LatexEditorViewConfig::possibleEditOperations()) {
ops->addItem(LatexEditorViewConfig::translateEditOperation(o), o);
}
return ops;
}
if (index.column() != 2) return nullptr;
//continue as key
}
//menu shortcut key
if (index.column() != 2 && index.column() != 3) {
UtilsUi::txsWarning(tr("To change a shortcut, edit the column \"Current Shortcut\" or \"Additional Shortcut\"."));
return nullptr;
}
ShortcutComboBox *editor = new ShortcutComboBox(parent);
return editor;
}
void ShortcutDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QComboBox *box = qobject_cast<QComboBox *>(editor);
//basic editor key
if (box && isBasicEditorKey(index) && index.column() == 0) {
box->setCurrentIndex(LatexEditorViewConfig::possibleEditOperations().indexOf(index.model()->data(index, Qt::UserRole).toInt()));
return;
}
QString value = index.model()->data(index, Qt::EditRole).toString();
//menu shortcut key
if (box) {
QString normalized = QKeySequence(value).toString(SHORTCUT_FORMAT);
int pos = box->findText(normalized);
if (pos == -1) box->setEditText(value);
else box->setCurrentIndex(pos);
if (box->lineEdit()) box->lineEdit()->selectAll();
return;
}
//editor key replacement
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
if (le) {
le->setText(value);
}
}
void ShortcutDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
REQUIRE(model);
QComboBox *box = qobject_cast<QComboBox *>(editor);
//basic editor key
if (box && isBasicEditorKey(index) && index.column() == 0) {
model->setData(index, box->itemData(box->currentIndex(), Qt::UserRole), Qt::UserRole);
model->setData(index, box->itemText(box->currentIndex()), Qt::EditRole);
model->setData(index, box->itemText(box->currentIndex()), Qt::DisplayRole);
return;
}
//editor key replacement
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
if (le) {
if (le->text().size() != 1 && index.column() == 1) {
UtilsUi::txsWarning(tr("Only single characters are allowed as key"));
return;
}
model->setData(index, le->text(), Qt::EditRole);
return;
}
//menu shortcut key
if (index.column() != 2 && index.column() != 3) return;
if (!box) return;
QString value = box->currentText();
if (value == "" || value == "none" || value == tr("<none>")) value = "";
else if (value == "<default>") ;
else {
value = QKeySequence(box->currentText()).toString(SHORTCUT_FORMAT);
if (value == "" || (value.endsWith("+") && !value.endsWith("++"))) { //Alt+wrong=>Alt+
UtilsUi::txsWarning(ConfigDialog::tr("The shortcut you entered is invalid."));
return;
}
QString value_alternative = QKeySequence(box->currentText()).toString(QKeySequence::PortableText);
QRegularExpression rxCharKey("^(Shift\\+)?.$"); // matches all single characters and single characters with shift like "Shift+A", should not match e.g. "F1" or "DEL"
if (value_alternative.indexOf(rxCharKey) == 0) {
if (!UtilsUi::txsConfirmWarning(ConfigDialog::tr("The shortcut you entered is a standard character key.\n"
"You will not be able to type this character. Do you wish\n"
"to set the key anyway?"))) {
return;
}
}
/*int r=-1;
for (int i=0;i<model->rowCount();i++)
if (model->data(model->index(i,2))==value) {
r=i;
break;
}*/
if (treeWidget) {
QList<QTreeWidgetItem *> li = treeWidget->findItems(value, Qt::MatchRecursive | Qt::MatchFixedString, 2);
if (!li.empty() && li[0] && li[0]->text(0) == model->data(model->index(index.row(), 0, index.parent()))) li.removeFirst();
QList<QTreeWidgetItem *> li2 = treeWidget->findItems(value, Qt::MatchRecursive | Qt::MatchFixedString, 3);
if (!li2.empty() && li2[0] && li2[0]->text(0) == model->data(model->index(index.row(), 0, index.parent()))) li2.removeFirst();
li << li2;
// filter out elements which belong to other window i.e. pdfviewer <-> editor
QModelIndex idx=model->index(index.row(),0,index.parent());
QString id=idx.data(Qt::UserRole).toString();
QStringList ids=id.split("/");
QString progType=ids.value(0);
for(int k=(li.size()-1);k>=0;k--){
QTreeWidgetItem *item=li.at(k);
QString id = item->data(0, Qt::UserRole).toString();
QStringList ids=id.split("/");
if(ids.value(0,"")!=progType){
if(progType=="pdf" || ids.value(0,"")=="pdf"){
li.removeAll(item);
}
}
}
REQUIRE(treeWidget->topLevelItem(1));
REQUIRE(treeWidget->topLevelItem(1)->childCount() >= 1);
QTreeWidgetItem *editorKeys = treeWidget->topLevelItem(1)->child(0);
REQUIRE(editorKeys);
if (!li.empty() && li.first()) {
QStringList duplicates;
foreach (QTreeWidgetItem *twi, li) {
if (twi) duplicates << twi->text(0);
}
QString duplicate = duplicates.join("\n");
if (UtilsUi::txsConfirmWarning(QString(ConfigDialog::tr("The shortcut <%1> is already assigned to the command:")).arg(value) + "\n" + duplicate + "\n\n" + ConfigDialog::tr("Do you wish to remove the old assignment and bind the shortcut to the new command?"))) {
//model->setData(mil[0],"",Qt::DisplayRole);
foreach (QTreeWidgetItem *twi, li) {
if (twi) {
if (twi->text(2) == value) twi->setText(2, "");
if (twi->text(3) == value) twi->setText(3, "");
}
}
} else {
return;
}
}
}
}
model->setData(index, value, Qt::EditRole);
}
void ShortcutDelegate ::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
{
editor->setGeometry(option.rect);
}
void ShortcutDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
{
QStyle *style = QApplication::style();
if (!style) QItemDelegate::drawDisplay(painter, option, rect, text);
else if (text == "<internal: delete row>") {
QStyleOptionButton sob;
sob.text = tr("delete row");
sob.state = QStyle::State_Enabled;
sob.rect = rect;
style->drawControl(QStyle::CE_PushButton, &sob, painter);
} else if (text == "<internal: add row>") {
QStyleOptionButton sob;
sob.text = tr("add row");
sob.state = QStyle::State_Enabled;
sob.rect = rect;
style->drawControl(QStyle::CE_PushButton, & sob, painter);
} else QItemDelegate::drawDisplay(painter, option, rect, text);
}
void ShortcutDelegate::treeWidgetItemClicked(QTreeWidgetItem *item, int column)
{
Q_ASSERT(item);
if (column != 0 || !item) return;
/*QStyle *style = QApplication::style ();
QPainter p(item->treeWidget ());
QStyleOptionButton sob;
sob.rect=item->treeWidget ()->visualItemRect(item);
sob.state = QStyle::State_Enabled|QStyle::State_Sunken;
if (style)
if (item->text(0)=="<internal: delete row>") {
sob.text = tr("delete row");
style->drawControl(QStyle::CE_PushButton, &sob, &p);
} else if (item->text(0)=="<internal: add row>"){
sob.text = tr("add row");
style->drawControl(QStyle::CE_PushButton, & sob, &p);
}*/
if (item->text(0) == deleteRowButton) {
if (UtilsUi::txsConfirm(ConfigDialog::tr("Do you really want to delete this row?"))) {
Q_ASSERT(item->parent());
if (!item->parent()) return;
item->parent()->removeChild(item);
}
} else if (item->text(0) == addRowButton) {
REQUIRE(item->parent());
REQUIRE(item->treeWidget());
REQUIRE(item->treeWidget()->topLevelItem(1));
QString newText = item->parent() == item->treeWidget()->topLevelItem(1)->child(1) ? deleteRowButton : "";
QTreeWidgetItem *twi = new QTreeWidgetItem((QTreeWidgetItem *)nullptr, QStringList() << newText);
twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
item->parent()->insertChild(item->parent()->childCount() - 1, twi);
}
}
bool ShortcutDelegate::isBasicEditorKey(const QModelIndex &index) const
{
#ifdef NO_POPPLER_PREVIEW
const int cRow=1;
#else
const int cRow=2;
#endif
return index.parent().isValid() && index.parent().parent().isValid() &&
!index.parent().parent().parent().isValid() &&
index.parent().row() == 0 &&
index.parent().parent().row() == cRow;
}
ComboBoxDelegate::ComboBoxDelegate(QObject *parent): QItemDelegate(parent)
{
activeColumn = 2;
}
QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() != activeColumn)
return QItemDelegate::createEditor(parent, option, index);
QComboBox *editor = new QComboBox(parent);
editor->addItems(defaultItems);
editor->setEditable(true);
return editor;
}
void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
if (index.column() != activeColumn) {
QItemDelegate::setEditorData(editor, index);
return;
}
QComboBox *cb = qobject_cast<QComboBox *>(editor);
REQUIRE(cb);
QString s = index.data(Qt::EditRole).toString();
if (s.contains('(')) s = s.left(s.indexOf('('));
for (int i = 0; i < cb->count(); i++)
if (cb->itemText(i).startsWith(s)) {
cb->setCurrentIndex(i);
break;
}
cb->setEditText(index.data(Qt::EditRole).toString());
}
void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
if (index.column() != activeColumn) {
QItemDelegate::setModelData(editor, model, index);
return;
}
QComboBox *cb = qobject_cast<QComboBox *>(editor);
REQUIRE(cb);
model->setData(index, cb->currentText());
}
void ComboBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.column() != activeColumn) {
QItemDelegate::updateEditorGeometry(editor, option, index);
return;
}
editor->setGeometry(option.rect);
}
int ConfigDialog::lastUsedPage = 0;
ConfigDialog::ConfigDialog(QWidget *parent): QDialog(parent,Qt::Dialog|Qt::WindowMinMaxButtonsHint|Qt::WindowCloseButtonHint), checkboxInternalPDFViewer(nullptr), riddled(false), oldToolbarIndex(-1), mBuildManager(nullptr)
{
// adapt icon size to dpi
double dpi=QGuiApplication::primaryScreen()->logicalDotsPerInch();
double scale=dpi/96;
int systemdpi = qRound(QGuiApplication::primaryScreen()->physicalDotsPerInch()); // main screen dpi
if (systemdpi < 10 || dpi > 1000)
systemdpi = 96;
QString labelSystemdpi = tr("Screen Resolution (System: %1 dpi):").arg(systemdpi);
setModal(true);
ui.setupUi(this);
UtilsUi::enableTouchScrolling(ui.scrollAreaGeneral);
UtilsUi::enableTouchScrolling(ui.scrollAreaBuild);
UtilsUi::enableTouchScrolling(ui.menuTree);
UtilsUi::enableTouchScrolling(ui.scrollAreaAdvancedEditor);
UtilsUi::enableTouchScrolling(ui.scrollAreaGrammar);
UtilsUi::enableTouchScrolling(ui.scrollAreaPreview);
UtilsUi::enableTouchScrolling(ui.scrollAreaPDFviewer);
#ifdef Q_OS_MAC
ui.labelSwitchKeyboardLayout->setDisabled(true);
ui.checkBoxSwitchLanguagesDirection->setChecked(false);
ui.checkBoxSwitchLanguagesDirection->setDisabled(true);
ui.checkBoxSwitchLanguagesMath->setChecked(false);
ui.checkBoxSwitchLanguagesMath->setDisabled(true);
#endif
#ifdef Q_OS_WIN
ui.checkBoxUseQSaveWrite->setVisible(false);
#endif
//ui.checkBoxShowCommentedElementsInStructure->setVisible(false); // hide non-functional option, maybe it can be fixed in future
ui.contentsWidget->setIconSize(QSize(qRound(32*scale), qRound(32*scale)));
//ui.contentsWidget->setViewMode(QListView::ListMode);
//ui.contentsWidget->setMovement(QListView::Static);
//pageGeneral
connect(ui.pushButtonImportDictionary, SIGNAL(clicked()), this, SLOT(importDictionary()));
connect(ui.pushButtonUpdateCheckNow, SIGNAL(clicked()), this, SLOT(updateCheckNow()));
connect(UpdateChecker::instance(), SIGNAL(checkCompleted()), this, SLOT(refreshLastUpdateTime()));
refreshLastUpdateTime();
//pageditor
populateComboBoxFont(false);
connect(ui.checkBoxShowOnlyMonospacedFonts, SIGNAL(toggled(bool)), this, SLOT(populateComboBoxFont(bool)));
QComboBox * encodingBoxes[3] = {ui.comboBoxEncoding, ui.comboBoxBibFileEncoding, ui.comboBoxLogFileEncoding};
ui.comboBoxLogFileEncoding->addItem("Document"); //not translated so the config is language independent
for (int i=0;i<3;i++) encodingBoxes[i]->addItem("UTF-8");
foreach (int mib, QTextCodec::availableMibs()) {
QTextCodec *codec = QTextCodec::codecForMib(mib);
if (!codec) continue;
if (codec->name() != "UTF-8") {
for (int i=0;i<3;i++)
encodingBoxes[i]->addItem(codec->name());
}
}
ui.comboBoxThesaurusFileName->setCompleter(nullptr);
#ifdef INTERNAL_TERMINAL
populateTerminalColorSchemes();
populateTerminalComboBoxFont(true);
#endif
connect(ui.pushButtonDictDir, SIGNAL(clicked()), this, SLOT(browseDictDir()));
connect(ui.leDictDir, SIGNAL(textChanged(QString)), this, SLOT(updateDefaultDictSelection(QString)));
connect(ui.btSelectThesaurusFileName, SIGNAL(clicked()), this, SLOT(browseThesaurus()));
connect(ui.pushButtonPathLog, SIGNAL(clicked()), this, SLOT(browsePathLog()));
connect(ui.pushButtonPathBib, SIGNAL(clicked()), this, SLOT(browsePathBib()));
connect(ui.pushButtonPathImages, SIGNAL(clicked()), this, SLOT(browsePathImages()));
connect(ui.pushButtonPathPdf, SIGNAL(clicked()), this, SLOT(browsePathPdf()));
connect(ui.pushButtonPathCommands, SIGNAL(clicked()), this, SLOT(browsePathCommands()));
connect(ui.comboBoxThesaurusFileName, SIGNAL(editTextChanged(QString)), this, SLOT(comboBoxWithPathEdited(QString)));
#if QT_VERSION>=QT_VERSION_CHECK(5,14,0)
connect(ui.comboBoxThesaurusFileName, SIGNAL(textHighlighted(QString)), this, SLOT(comboBoxWithPathHighlighted(QString)));
#else
connect(ui.comboBoxThesaurusFileName, SIGNAL(highlighted(QString)), this, SLOT(comboBoxWithPathHighlighted(QString)));
#endif
ui.labelGetDic->setText(tr("Download additional dictionaries from %1 or %2")
.arg("<a href=\"https://extensions.openoffice.org/de/search?f[0]=field_project_tags%3A157\">OpenOffice</a>",
"<a href=\"https://extensions.libreoffice.org/?Tag%5B0%5D=50&q=&Tags%5B%5D=50\">LibreOffice</a>"));
ui.labelGetDic->setOpenExternalLinks(true);
//pagequick
connect(ui.pushButtonGrammarWordlists, SIGNAL(clicked()), this, SLOT(browseGrammarWordListsDir()));
connect(ui.pushButtonGrammarLTPath, SIGNAL(clicked()), this, SLOT(browseGrammarLTPath()));
connect(ui.pushButtonGrammarLTJava, SIGNAL(clicked()), this, SLOT(browseGrammarLTJavaPath()));
connect(ui.pushButtonResetLTURL, SIGNAL(clicked()), this, SLOT(resetLTURL()));
connect(ui.pushButtonResetLTArgs, SIGNAL(clicked()), this, SLOT(resetLTArgs()));
fmConfig = new QFormatConfig(ui.formatConfigBox, qApp->styleSheet().isEmpty());
fmConfig->setToolTip(tr("Here the syntax highlighting for various commands, environments and selections can be changed."));
fmConfig->addCategory(tr("Basic highlighting")) << "normal" << "background" << "comment" << "magicComment" << "commentTodo" << "keyword" << "extra-keyword" << "math-delimiter" << "math-keyword" << "math-text" << "numbers" << "text" << "align-ampersand" << "environment" << "structure" << "link" << "escapeseq" << "verbatim" << "picture" << "picture-keyword" << "preedit";
fmConfig->addCategory(tr("LaTeX checking")) << "braceMatch" << "braceMismatch" << "latexSyntaxMistake" << "referencePresent" << "referenceMissing" << "referenceMultiple" << "citationPresent" << "citationMissing" << "packagePresent" << "packageMissing" << "temporaryCodeCompletion";
fmConfig->addCategory(tr("Language checking")) << "spellingMistake" << "wordRepetition" << "wordRepetitionLongRange" << "badWord" << "grammarMistake" << "grammarMistakeSpecial1" << "grammarMistakeSpecial2" << "grammarMistakeSpecial3" << "grammarMistakeSpecial4";
fmConfig->addCategory(tr("Line highlighting")) << "line:error" << "line:warning" << "line:badbox" << "line:bookmark" << "line:bookmark0" << "line:bookmark1" << "line:bookmark2" << "line:bookmark3" << "line:bookmark4" << "line:bookmark5" << "line:bookmark6" << "line:bookmark7" << "line:bookmark8" << "line:bookmark9" << "current";
fmConfig->addCategory(tr("Search")) << "search" << "replacement" << "selection";
fmConfig->addCategory(tr("Diff")) << "diffDelete" << "diffAdd" << "diffReplace";
fmConfig->addCategory(tr("Preview")) << "previewSelection";
fmConfig->addCategory(tr("DTX files")) << "dtx:guard" << "dtx:macro" << "dtx:verbatim" << "dtx:specialchar" << "dtx:commands";
fmConfig->addCategory(tr("Sweave / Pweave")) << "sweave-delimiter" << "sweave-block" << "pweave-delimiter" << "pweave-block";
fmConfig->addCategory(tr("Asymptote")) << "asymptote:block" << "asymptote:keyword" << "asymptote:type" << "asymptote:numbers" << "asymptote:string" << "asymptote:comment";
fmConfig->addCategory(tr("Lua")) << "lua:keyword" << "lua:comment";
fmConfig->addCategory(tr("QtScript")) << "qtscript:comment" << "qtscript:string" << "qtscript:number" << "qtscript:keyword" << "qtscript:txs-variable" << "qtscript:txs-function";
connect(ui.spinBoxSize, SIGNAL(valueChanged(int)), fmConfig, SLOT(setBasePointSize(int)));
connect(ui.leCompletionFilter,&QLineEdit::textChanged,this,&ConfigDialog::filterCompletionList);
//fmConfig->setMaximumSize(490,300);
//fmConfig->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored);
QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, ui.formatConfigBox);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
layout->setMargin(0);
#else
layout->setContentsMargins(0,0,0,0);
#endif
layout->insertWidget(0, fmConfig);
ConfigManager *config = dynamic_cast<ConfigManager *>(ConfigManagerInterface::getInstance());
ui.shortcutTree->setHeaderLabels(QStringList() << tr("Command") << tr("Default Shortcut") << tr("Current Shortcut") << tr("Additional Shortcut"));
if(config){
ui.shortcutTree->setColumnWidth(0, config->getOption("GUI/ConfigShorcutColumnWidth",200).toInt());
}else{
ui.shortcutTree->setColumnWidth(0, 200);
}
//create icons
createIcon(tr("General"), getRealIcon("config_general"));
createIcon(tr("Commands"), getRealIcon("config_commands"));
createIcon(tr("Build"), getRealIcon("config_quickbuild"));
createIcon(tr("Shortcuts"), getRealIcon("config_shortcut"));
createIcon(tr("Menus"), getRealIcon("config_latexmenus"), CONTENTS_ADVANCED);
createIcon(tr("Toolbars"), getRealIcon("config_toolbars"), CONTENTS_ADVANCED);
createIcon(tr("GUI Scaling"), getRealIcon("config_toolbars"), CONTENTS_ADVANCED);
createIcon(tr("Editor"), getRealIcon("config_editor"));
createIcon(tr("Adv. Editor"), getRealIcon("config_advancededitor"), CONTENTS_ADVANCED);
createIcon(tr("Syntax Highlighting"), getRealIcon("config_highlighting"));
createIcon(tr("Completion"), getRealIcon("config_completion"));
createIcon(tr("Language Checking"), getRealIcon("config_editor"));
createIcon(tr("Preview"), getRealIcon("config_preview"));
createIcon(tr("Internal PDF Viewer"), getRealIcon("config_preview"));
createIcon(tr("SVN/GIT"), getRealIcon("config_svn"));
createIcon(
tr("Internal Terminal"),
getRealIcon("config_terminal"),
#ifdef INTERNAL_TERMINAL
CONTENTS_ADVANCED
#else
CONTENTS_DISABLED
#endif
);
// tweak all comboboxes in adv. editor pane to not change on scroll wheel as it messes with scrolling through the pane (#2977)
tweakFocusSettings(ui.scrollAreaWidgetContents_2->children());
Q_ASSERT(ui.pagesWidget->count() == ui.contentsWidget->count());
connect(ui.contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
ui.contentsWidget->setCurrentRow(lastUsedPage);
connect(ui.checkBoxShowAdvancedOptions, SIGNAL(toggled(bool)), this, SLOT(advancedOptionsToggled(bool)));
connect(ui.checkBoxShowAdvancedOptions, SIGNAL(clicked(bool)), this, SLOT(advancedOptionsClicked(bool)));
// custom toolbars
connect(ui.comboBoxToolbars, SIGNAL(currentIndexChanged(int)), SLOT(toolbarChanged(int)));
ui.listCustomToolBar->setIconSize(QSize(qRound(22*scale), qRound(22*scale)));
ui.listCustomToolBar->setViewMode(QListView::ListMode);
ui.listCustomToolBar->setMovement(QListView::Snap);
ui.listCustomToolBar->setDragDropMode(QAbstractItemView::InternalMove);
connect(this, SIGNAL(accepted()), SLOT(checkToolbarMoved()));
connect(ui.pbToToolbar, SIGNAL(clicked()), this, SLOT(toToolbarClicked()));
connect(ui.pbFromToolbar, SIGNAL(clicked()), this, SLOT(fromToolbarClicked()));
ui.listCustomToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui.listCustomToolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu(QPoint)));
connect(ui.listCustomToolBar, SIGNAL(doubleClicked(QModelIndex)), SLOT(fromToolbarClicked()));
connect(ui.comboBoxActions, SIGNAL(currentIndexChanged(int)), SLOT(actionsChanged(int)));
connect(ui.treePossibleToolbarActions, SIGNAL(doubleClicked(QModelIndex)), SLOT(toToolbarClicked()));
ui.treePossibleToolbarActions->setHeaderHidden(true);
ui.lineEditMetaFilter->setPlaceholderText(tr("(option filter)"));
connect(ui.lineEditMetaFilter, SIGNAL(textChanged(QString)), SLOT(metaFilterChanged(QString)));
// poppler preview
#ifdef NO_POPPLER_PREVIEW
int l = ui.comboBoxDvi2PngMode->count();
ui.comboBoxDvi2PngMode->removeItem(l - 1);
l = ui.comboBoxPreviewMode->count();
ui.comboBoxPreviewMode->removeItem(l - 1);
// maybe add some possibility to disable some preview modes in poppler mode
#endif
ui.labelScreenResolution->setText(labelSystemdpi);
// set-up GUI scaling
connect(ui.tbRevertIcon, SIGNAL(clicked()), this, SLOT(revertClicked()));
connect(ui.tbRevertCentralIcon, SIGNAL(clicked()), this, SLOT(revertClicked()));
connect(ui.tbRevertSymbol, SIGNAL(clicked()), this, SLOT(revertClicked()));
connect(ui.tbRevertPDF, SIGNAL(clicked()), this, SLOT(revertClicked()));
// ai chat
connect(ui.cbAIProvider, SIGNAL(currentIndexChanged(int)), this, SLOT(aiProviderChanged(int)));
connect(ui.pbRetrieveModels, &QPushButton::clicked, this, &ConfigDialog::retrieveModels);
connect(ui.pbResetAIURL, &QPushButton::clicked, this, &ConfigDialog::resetAIURL);
// fill in the known models
aiFillInKnownModels();
}
void ConfigDialog::showAndLimitSize() {
show();
QRect screen = QGuiApplication::primaryScreen()->availableGeometry();
if (!screen.isEmpty()) {
int nwidth = width(), nheight = height(),
heightDiff = frameGeometry().height() - geometry().height(),
maxHeight = screen.height() - heightDiff, maxWidth = screen.width();
if (nwidth > maxWidth) nwidth = maxWidth;
if (nheight > maxHeight) nheight = maxHeight;
if (nwidth == width() && nheight == height()) return;
resize(nwidth, nheight);
move(frameGeometry().right() > screen.right() ? screen.left() : x(),
frameGeometry().bottom() > screen.bottom() ? screen.top() : y());
}
}
ConfigDialog::~ConfigDialog()
{
ConfigManager *config = dynamic_cast<ConfigManager *>(ConfigManagerInterface::getInstance());
if(config){
config->setOption("GUI/ConfigShorcutColumnWidth",ui.shortcutTree->columnWidth(0));
}
}
QListWidgetItem *ConfigDialog::createIcon(const QString &caption, const QIcon &icon, ContentsType contentsType)
{
QListWidgetItem *button = new QListWidgetItem(ui.contentsWidget);
button->setIcon(icon);
button->setText(caption);
button->setToolTip(caption);
//button->setTextAlignment(Qt::AlignVCenter);
button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
button->setData(Qt::UserRole, contentsType);
if (contentsType == CONTENTS_DISABLED) {
button->setHidden(true);
}
return button;
}
void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
{
if (!current)
current = previous;
lastUsedPage = ui.contentsWidget->row(current);
ui.pagesWidget->setCurrentIndex(lastUsedPage);
}
void ConfigDialog::revertClicked()
{
QToolButton *bt = qobject_cast<QToolButton *>(sender());
if (bt) {
if (bt->objectName() == "tbRevertIcon") {
ui.horizontalSliderIcon->setValue(24);
}
if (bt->objectName() == "tbRevertCentralIcon") {
ui.horizontalSliderCentraIcon->setValue(16);
}
if (bt->objectName() == "tbRevertSymbol") {
ui.horizontalSliderSymbol->setValue(32);
}
if (bt->objectName() == "tbRevertPDF") {
ui.horizontalSliderPDF->setValue(16);
}
}
}
/*!
* \brief adapt model list depending on ai provider
* \param[provider] 0: mistral
* 1: openai
*/
void ConfigDialog::aiProviderChanged(int provider)
{
bool activateCustomURL=false;
switch(provider){
case 0:
ui.cbAIPreferredModel->clear();
ui.cbAIPreferredModel->addItem("open-mistral-7b");
ui.cbAIPreferredModel->addItem("open-mixtral-8x7b");
ui.cbAIPreferredModel->addItem("mistral-small-latest");
ui.cbAIPreferredModel->addItem("mistral-medium-latest");
ui.cbAIPreferredModel->addItem("mistral-large-latest");
break;
case 1:
ui.cbAIPreferredModel->clear();
ui.cbAIPreferredModel->addItem("gpt-4o-mini");
ui.cbAIPreferredModel->addItem("gpt-3.5-turbo");
ui.cbAIPreferredModel->addItem("gpt-4");
ui.cbAIPreferredModel->addItem("gpt-4o");
break;
default:
ui.cbAIPreferredModel->clear();
activateCustomURL=true;
break;
}
ui.leAIAPIURL->setEnabled(activateCustomURL);
ui.pbResetAIURL->setEnabled(activateCustomURL);
}
/*!
* \brief retieve the current list of available model from AI provider
* API key is needed
*/
void ConfigDialog::retrieveModels()
{
if(!ui.leAIAPIKey->text().isEmpty()){
QString provider=ui.cbAIProvider->currentText();
QString key=ui.leAIAPIKey->text();
QString url;
switch(ui.cbAIProvider->currentIndex()){
case 0:
url="https://api.mistral.ai/v1/models";
break;
case 1:
url="https://api.openai.com/v1/models";
break;
case 2:
url=ui.leAIAPIURL->text();
url=url.replace("chat/completions","models");
break;
default:
break;
}
QNetworkRequest request(url);
request.setRawHeader("Authorization",QString("Bearer "+key).toUtf8());
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager,&QNetworkAccessManager::finished,this,&ConfigDialog::modelsRetrieved);
manager->get(request);
}
}
/*!
* \brief reset custom ai api url to default
*/
void ConfigDialog::resetAIURL()
{
ui.leAIAPIURL->setText("http://localhost:8080/v1/chat/completions");
}
void ConfigDialog::modelsRetrieved(QNetworkReply *reply)
{
if(reply->error() == QNetworkReply::NoError){
QByteArray data = reply->readAll();
QJsonDocument doc=QJsonDocument::fromJson(data);
QJsonObject obj=doc.object();
QStringList models;
QJsonArray lst=obj["data"].toArray();
foreach (const QJsonValue & value, lst) {
models.append(value.toObject()["id"].toString());
}
ui.cbAIPreferredModel->clear();
ui.cbAIPreferredModel->addItems(models);
if(!models.isEmpty()){
ConfigManager *config = dynamic_cast<ConfigManager *>(ConfigManagerInterface::getInstance());
if (config){
config->ai_knownModels=models;
}
}
}
reply->deleteLater();
}
/*!
* \brief fill in known models for AI provider
*/
void ConfigDialog::aiFillInKnownModels()
{
ConfigManager *config = dynamic_cast<ConfigManager *>(ConfigManagerInterface::getInstance());
if (!config) return;
if(!config->ai_knownModels.isEmpty()){
ui.cbAIPreferredModel->clear();
ui.cbAIPreferredModel->addItems(config->ai_knownModels);
ui.cbAIPreferredModel->setCurrentText(config->ai_preferredModel);
}
}
//sets the items of a combobox to the filenames and sub-directory names in the directory which name
//is the current text of the combobox
void ConfigDialog::comboBoxWithPathEdited(const QString &newText)
{
if (newText.isEmpty()) return;
QComboBox *box = qobject_cast<QComboBox *>(sender());
if (!box) return;
if (box->property("lastDirInDropDown").toString() == newText && !newText.endsWith("/") && !newText.endsWith(QDir::separator())) {
box->setEditText(newText + QDir::separator());
box->setProperty("lastDirInDropDown", "");
return;
}
QString path;
int lastSep = qMax(newText.lastIndexOf("/"), newText.lastIndexOf(QDir::separator()));
if ((lastSep > 0) || (newText == "") || (QDir::separator() != '/') ) path = newText.mid(0, lastSep);
else path = "/";
QString oldPath = box->property("dir").toString();
if (path == oldPath) return;
//prevent endless recursion + dir caching
box->setProperty("dir", path);
int curPos = box->lineEdit()->cursorPosition();
box->clear();
box->addItem(newText); //adding a new item in the empty list will set the edit text to it
box->lineEdit()->setCursorPosition(curPos); // set Cursor to position before clearing
QDir dir(path);
QString absPath = dir.absolutePath();
if (absPath == oldPath || (absPath + QDir::separator()) == oldPath) return;
if (!absPath.endsWith("/") && !absPath.endsWith(QDir::separator())) absPath += QDir::separator();
QStringList entries = dir.entryList(QStringList() << box->property("dirFilter").toString(), QDir::Files);
foreach (const QString &file, entries)
if (absPath + file != newText)
box->addItem(absPath + file);
entries = dir.entryList(QStringList(), QDir::AllDirs);
foreach (const QString &file, entries)
if (absPath + file != newText && file != ".")
box->addItem(absPath + file);
}
void ConfigDialog::comboBoxWithPathHighlighted(const QString &newText)
{
QComboBox *cb = qobject_cast<QComboBox *> (sender());
Q_ASSERT(cb);
if (!cb) return;
if (!QFileInfo(newText).isDir()) {
cb->setProperty("lastDirInDropDown", "");
return;
}
cb->setProperty("lastDirInDropDown", newText);
}
void ConfigDialog::browseThesaurus()
{
UtilsUi::browse(ui.comboBoxThesaurusFileName, tr("Select thesaurus database"), "Database (*.dat)");
}
void ConfigDialog::browseGrammarWordListsDir()
{
UtilsUi::browse(ui.lineEditGrammarWordlists, tr("Select the grammar word lists dir"), "/");
}
void ConfigDialog::browseGrammarLTPath()
{
UtilsUi::browse(ui.lineEditGrammarLTPath, tr("Select the LanguageTool jar"), "Java-Program (*.jar)");
}
void ConfigDialog::browseGrammarLTJavaPath()
{
UtilsUi::browse(ui.lineEditGrammarLTJava, tr("Select java"), "Java (*)");
}
void ConfigDialog::resetLTArgs(){
ui.lineEditGrammarLTArguments->setText("org.languagetool.server.HTTPServer -p 8081");
}
void ConfigDialog::resetLTURL(){
ui.lineEditGrammarLTUrl->setText("http://localhost:8081/");
}
void ConfigDialog::browseDictDir()
{
UtilsUi::browse(ui.leDictDir, tr("Select dictionary directory"), "/");
}
void ConfigDialog::browsePathLog()
{
UtilsUi::browse(ui.lineEditPathLog, tr("Search Path for Logs"), "/", QDir::currentPath(), true);
}
void ConfigDialog::browsePathBib()
{
UtilsUi::browse(ui.lineEditPathBib, tr("Search Path .bib Files"), "/", QDir::currentPath(), true);
}
void ConfigDialog::browsePathImages()
{
UtilsUi::browse(ui.lineEditPathImages, tr("Search Path for Images"), "/", QDir::currentPath(), true);
}
void ConfigDialog::browsePathPdf()
{
UtilsUi::browse(ui.lineEditPathPDF, tr("Search Path for PDFs"), "/", QDir::currentPath(), true);
}
void ConfigDialog::browsePathCommands()
{
UtilsUi::browse(ui.lineEditPathCommands, tr("Search Path for Commands"), "/", QDir::rootPath(), true);
}
void ConfigDialog::updateDefaultDictSelection(const QString &dictPaths, const QString &newDefault)
{
QString lang = ui.comboBoxSpellcheckLang->currentText();
ui.comboBoxSpellcheckLang->clear();
ConfigManager *config = dynamic_cast<ConfigManager *>(ConfigManagerInterface::getInstance());
if (!config) return;
SpellerManager sm;
sm.setDictPaths(config->parseDirList(dictPaths));
ui.comboBoxSpellcheckLang->addItems(sm.availableDicts());
if (ui.comboBoxSpellcheckLang->count() == 0) {
ui.comboBoxSpellcheckLang->addItem("<none>");
}
// update selected language
int index = -1;
if (!newDefault.isNull()) index = ui.comboBoxSpellcheckLang->findText(newDefault);
if (index < 0) index = ui.comboBoxSpellcheckLang->findText(lang); // keep selected language
if (index >= 0) {
ui.comboBoxSpellcheckLang->setCurrentIndex(index);
}
}
void ConfigDialog::hideShowAdvancedOptions(QWidget *w, bool on)
{
foreach (QObject *o, w->children()) {
QWidget *w = qobject_cast<QWidget *> (o);
if (!w) continue;
if (w->property("advancedOption").toBool()) {
bool realOn = on && !w->property("hideWidget").toBool();
w->setVisible(realOn);
}
// special treatment for metacommads
static QStringList simpleMetaOptions = QStringList() << "quick" << "compile" << "view" << "view-pdf" << "bibliography";
if (simpleMetaOptions.contains(w->objectName())) {
QComboBox *cb = qobject_cast<QComboBox *> (o);
if (cb) {
if (on) {
CommandMapping tempCommands = mBuildManager->getAllCommands();
CommandInfo cmd = tempCommands.value(w->objectName());
QString text = cb->currentText();
int i = cb->findText(text);
if (i >= 0)
text = cmd.metaSuggestionList.value(i, tr("<unknown>"));
cb->clear();
cb->addItems(cmd.metaSuggestionList);
cb->setEditable(true);
cb->setEditText(text);
} else {
CommandMapping tempCommands = mBuildManager->getAllCommands();
CommandInfo cmd = tempCommands.value(w->objectName());
QString text = cb->currentText();
int i = cmd.metaSuggestionList.indexOf(text);
//if(i>=0)
// text=cmd.simpleDescriptionList.value(i,tr("<unknown>"));
cb->clear();
if (i >= 0) {
foreach (QString elem, cmd.simpleDescriptionList) {
elem = qApp->translate("BuildManager", qPrintable(elem));
cb->addItem(elem);
}
cb->setCurrentIndex(i);
cb->setEditable(false);
} else {
cb->addItems(cmd.metaSuggestionList);
cb->setEditable(true);
cb->setEditText(text);
}
}
}
}
hideShowAdvancedOptions(w, on);
}
}
/*!
* \brief change focus and eventfilter to avoid accidental scrollen
* See #2977
* \param objList
*/
void ConfigDialog::tweakFocusSettings(QObjectList objList)
{
for(auto *elem:objList){
QComboBox *cb=qobject_cast<QComboBox *>(elem);
if(cb){
cb->setFocusPolicy(Qt::StrongFocus);
cb->installEventFilter(this);
}
QSpinBox *sb=qobject_cast<QSpinBox *>(elem);
if(sb){
sb->setFocusPolicy(Qt::StrongFocus);
sb->installEventFilter(this);
}
auto *gb=qobject_cast<QGroupBox *>(elem);
if(gb){