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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: appearance.cpp,v 1.11.2.5 2009/11/14 03:37:48 terminator356 Exp $
//=========================================================
#include <QAbstractButton>
#include <QButtonGroup>
#include <QColor>
#include <QFontDialog>
#include <QStyleFactory>
#include <QToolTip>
#include <QByteArray>
#include <QFile>
#include <QFileDialog>
#include <QFileInfo>
#include <QPainter>
#include <QtGlobal>
#include "icons.h"
#include "appearance.h"
#include "track.h"
#include "app.h"
#include "song.h"
#include "event.h"
#include "arranger.h"
#include "widgets/filedialog.h"
#include "waveedit/waveedit.h"
#include "globals.h"
#include "conf.h"
#include "gconfig.h"
int BG_ITEM_HEIGHT = 30;
class BgPreviewWidget : public QWidget {
QPixmap pixmap;
QString imagefile;
QTreeWidget* t_widget;
int text_h;
int text_w;
protected:
void paintEvent(QPaintEvent* event)
{
QPainter p(this);
int w = t_widget->width() - 65;
p.drawTiledPixmap(1,1,w,BG_ITEM_HEIGHT-2, pixmap);
const QPalette& pal = palette();
QColor dark = pal.dark().color();
// We can also draw a rectangle behind the text:
//p.fillRect(QRect(w/2 - text_w/2,6,text_w + 20,text_h+4), dark);
QFontMetrics fm = p.fontMetrics();
text_w = fm.width(imagefile);
text_h = fm.height();
// Do the text shadow first
p.save();
p.setPen(dark);
p.drawText(w/2 - text_w/2 + 1, 7, text_w + 20, text_h+4, Qt::AlignCenter, imagefile);
p.restore();
p.drawText(w/2 - text_w/2,6, text_w + 20, text_h+4, Qt::AlignCenter, imagefile);
QWidget::paintEvent(event);
}
public:
BgPreviewWidget(QString imagepath, QTreeWidget *treewidget)
{
pixmap = QPixmap(imagepath);
imagefile = imagepath.right(imagepath.length() - imagepath.lastIndexOf("/") - 1 );
t_widget = treewidget;
}
};
//---------------------------------------------------------
// IdListViewItem
//---------------------------------------------------------
class IdListViewItem : public QTreeWidgetItem {
int _id;
public:
IdListViewItem(int id, QTreeWidgetItem* parent, QString s)
: QTreeWidgetItem(parent, QStringList(s))
{
_id = id;
}
IdListViewItem(int id, QTreeWidget* parent, QString s)
: QTreeWidgetItem(parent, QStringList(s))
{
_id = id;
}
int id() const { return _id; }
};
//---------------------------------------------------------
// Appearance
//---------------------------------------------------------
Appearance::Appearance(Arranger* a, QWidget* parent)
: QDialog(parent, Qt::Window)
{
setupUi(this);
arr = a;
color = 0;
config = new GlobalConfigValues;
lastSelectedColorItem = 0;
lastSelectedBgItem = 0;
fontName0->setToolTip(tr("Main application font, and default font for any\n controls not defined here."));
fontName1->setToolTip(tr("For small controls like mixer strips.\nAlso timescale small numbers, arranger part name overlay,\n and effects rack."));
fontName2->setToolTip(tr("Midi track info panel. Transport controls."));
fontName3->setToolTip(tr("Controller graph and S/X buttons. Large numbers for time\n and tempo scale, and time signature."));
fontName4->setToolTip(tr("Time scale markers."));
fontName5->setToolTip(tr("List editor: meta event edit dialog multi-line edit box."));
fontName6->setToolTip(tr("Mixer label font. Auto-font-sizing up to chosen font size.\nWord-breaking but only with spaces."));
fontSize6->setToolTip(tr("Maximum mixer label auto-font-sizing font size."));
globalAlphaSlider->setToolTip(tr("Global opacity (opposite of transparency)."));
// ARRANGER
global_bg = new QTreeWidgetItem(backgroundTree, QStringList(tr("Standard")), 0);
global_bg->setFlags(Qt::ItemIsEnabled);
user_bg = new QTreeWidgetItem(backgroundTree, QStringList(tr("Custom")), 0);
user_bg->setFlags(Qt::ItemIsEnabled);
/*
partShownames->setChecked(config->canvasShowPartType & 1);
partShowevents->setChecked(config->canvasShowPartType & 2);
partShowCakes->setChecked(!(config->canvasShowPartType & 2));
eventNoteon->setChecked(config->canvasShowPartEvent & (1 << 0));
eventPolypressure->setChecked(config->canvasShowPartEvent & (1 << 1));
eventController->setChecked(config->canvasShowPartEvent & (1 << 2));
eventProgramchange->setChecked(config->canvasShowPartEvent & (1 << 3));
eventAftertouch->setChecked(config->canvasShowPartEvent & (1 << 4));
eventPitchbend->setChecked(config->canvasShowPartEvent & (1 << 5));
eventSpecial->setChecked(config->canvasShowPartEvent & (1 << 6));
eventButtonGroup->setEnabled(config->canvasShowPartType == 2);
arrGrid->setChecked(config->canvasShowGrid);
*/
colorframe->setAutoFillBackground(true);
aPalette = new QButtonGroup(aPaletteBox);
// There must be an easier way to do this by a for loop. No? :
aPalette->addButton(palette0, 0);
aPalette->addButton(palette1, 1);
aPalette->addButton(palette2, 2);
aPalette->addButton(palette3, 3);
aPalette->addButton(palette4, 4);
aPalette->addButton(palette5, 5);
aPalette->addButton(palette6, 6);
aPalette->addButton(palette7, 7);
aPalette->addButton(palette8, 8);
aPalette->addButton(palette9, 9);
aPalette->addButton(palette10, 10);
aPalette->addButton(palette11, 11);
aPalette->addButton(palette12, 12);
aPalette->addButton(palette13, 13);
aPalette->addButton(palette14, 14);
aPalette->addButton(palette15, 15);
aPalette->setExclusive(true);
// COLORS
IdListViewItem* id;
IdListViewItem* aid;
itemList->clear();
aid = new IdListViewItem(0, itemList, "Arranger");
id = new IdListViewItem(0, aid, "PartColors");
// Names moved into global config by Tim.
/*
new IdListViewItem(0x400, id, "Default");
new IdListViewItem(0x401, id, "Refrain");
new IdListViewItem(0x402, id, "Bridge");
new IdListViewItem(0x403, id, "Intro");
new IdListViewItem(0x404, id, "Coda");
new IdListViewItem(0x405, id, "Chorus");
new IdListViewItem(0x406, id, "Solo");
new IdListViewItem(0x407, id, "Brass");
new IdListViewItem(0x408, id, "Percussion");
new IdListViewItem(0x409, id, "Drums");
new IdListViewItem(0x40a, id, "Guitar");
new IdListViewItem(0x40b, id, "Bass");
new IdListViewItem(0x40c, id, "Flute");
new IdListViewItem(0x40d, id, "Strings");
new IdListViewItem(0x40e, id, "Keyboard");
new IdListViewItem(0x40f, id, "Piano");
new IdListViewItem(0x410, id, "Saxophon");
*/
for(int i = 0; i < NUM_PARTCOLORS; ++i)
new IdListViewItem(0x400 + i, id, ::config.partColorNames[i]);
new IdListViewItem(0x41c, aid, "part canvas background");
id = new IdListViewItem(0, aid, "Track List");
new IdListViewItem(0x411, id, "background");
new IdListViewItem(0x412, id, "midi background");
new IdListViewItem(0x413, id, "drum background");
new IdListViewItem(0x414, id, "wave background");
new IdListViewItem(0x415, id, "output background");
new IdListViewItem(0x416, id, "input background");
new IdListViewItem(0x417, id, "group background");
new IdListViewItem(0x418, id, "aux background");
new IdListViewItem(0x419, id, "synth background");
new IdListViewItem(0x41a, id, "selected track background");
new IdListViewItem(0x41b, id, "selected track foreground");
id = new IdListViewItem(0, itemList, "BigTime");
new IdListViewItem(0x100, id, "background");
new IdListViewItem(0x101, id, "foreground");
id = new IdListViewItem(0, itemList, "Transport");
new IdListViewItem(0x200, id, "handle");
id = new IdListViewItem(0, itemList, "Midi Editor");
new IdListViewItem(0x41d, id, "controller graph");
id = new IdListViewItem(0, itemList, "Wave Editor");
new IdListViewItem(0x300, id, "background");
id = new IdListViewItem(0, itemList, "Mixer");
new IdListViewItem(0x500, id, "background");
new IdListViewItem(0x501, id, "midi label");
new IdListViewItem(0x502, id, "drum label");
new IdListViewItem(0x503, id, "wave label");
new IdListViewItem(0x504, id, "audio output label");
new IdListViewItem(0x505, id, "audio input label");
new IdListViewItem(0x506, id, "group label");
new IdListViewItem(0x507, id, "aux label");
new IdListViewItem(0x508, id, "synth label");
colorNameLineEdit->setEnabled(false);
connect(colorNameLineEdit, SIGNAL(editingFinished()), SLOT(colorNameEditFinished()));
connect(itemList, SIGNAL(itemSelectionChanged()), SLOT(colorItemSelectionChanged()));
connect(aPalette, SIGNAL(buttonClicked(int)), SLOT(paletteClicked(int)));
connect(globalAlphaSlider, SIGNAL(valueChanged(int)), SLOT(asliderChanged(int)));
connect(rslider, SIGNAL(valueChanged(int)), SLOT(rsliderChanged(int)));
connect(gslider, SIGNAL(valueChanged(int)), SLOT(gsliderChanged(int)));
connect(bslider, SIGNAL(valueChanged(int)), SLOT(bsliderChanged(int)));
connect(hslider, SIGNAL(valueChanged(int)), SLOT(hsliderChanged(int)));
connect(sslider, SIGNAL(valueChanged(int)), SLOT(ssliderChanged(int)));
connect(vslider, SIGNAL(valueChanged(int)), SLOT(vsliderChanged(int)));
connect(globalAlphaVal, SIGNAL(valueChanged(int)), SLOT(aValChanged(int)));
connect(rval, SIGNAL(valueChanged(int)), SLOT(rsliderChanged(int)));
connect(gval, SIGNAL(valueChanged(int)), SLOT(gsliderChanged(int)));
connect(bval, SIGNAL(valueChanged(int)), SLOT(bsliderChanged(int)));
connect(hval, SIGNAL(valueChanged(int)), SLOT(hsliderChanged(int)));
connect(sval, SIGNAL(valueChanged(int)), SLOT(ssliderChanged(int)));
connect(vval, SIGNAL(valueChanged(int)), SLOT(vsliderChanged(int)));
connect(addToPalette, SIGNAL(clicked()), SLOT(addToPaletteClicked()));
//---------------------------------------------------
// STYLE
//---------------------------------------------------
/*
themeComboBox->clear();
QString cs = muse->style().name();
cs = cs.lower();
themeComboBox->insertStringList(QStyleFactory::keys());
for (int i = 0; i < themeComboBox->count(); ++i) {
if (themeComboBox->text(i).lower() == cs) {
themeComboBox->setCurrentItem(i);
}
}
*/
openStyleSheet->setIcon(*openIcon);
connect(openStyleSheet, SIGNAL(clicked()), SLOT(browseStyleSheet()));
defaultStyleSheet->setIcon(*undoIcon);
connect(defaultStyleSheet, SIGNAL(clicked()), SLOT(setDefaultStyleSheet()));
//---------------------------------------------------
// Fonts
//---------------------------------------------------
fontBrowse0->setIcon(QIcon(*openIcon));
fontBrowse1->setIcon(QIcon(*openIcon));
fontBrowse2->setIcon(QIcon(*openIcon));
fontBrowse3->setIcon(QIcon(*openIcon));
fontBrowse4->setIcon(QIcon(*openIcon));
fontBrowse5->setIcon(QIcon(*openIcon));
fontBrowse6->setIcon(QIcon(*openIcon));
connect(fontBrowse0, SIGNAL(clicked()), SLOT(browseFont0()));
connect(fontBrowse1, SIGNAL(clicked()), SLOT(browseFont1()));
connect(fontBrowse2, SIGNAL(clicked()), SLOT(browseFont2()));
connect(fontBrowse3, SIGNAL(clicked()), SLOT(browseFont3()));
connect(fontBrowse4, SIGNAL(clicked()), SLOT(browseFont4()));
connect(fontBrowse5, SIGNAL(clicked()), SLOT(browseFont5()));
connect(fontBrowse6, SIGNAL(clicked()), SLOT(browseFont6()));
connect(applyButton, SIGNAL(clicked()), SLOT(apply()));
connect(okButton, SIGNAL(clicked()), SLOT(ok()));
connect(cancelButton, SIGNAL(clicked()), SLOT(cancel()));
connect(addBgButton, SIGNAL(clicked()), SLOT(addBackground()));
connect(removeBgButton, SIGNAL(clicked()), SLOT(removeBackground()));
connect(clearBgButton, SIGNAL(clicked()), SLOT(clearBackground()));
connect(partShowevents, SIGNAL(toggled(bool)), eventButtonGroup, SLOT(setEnabled(bool)));
//updateColor();
}
//---------------------------------------------------------
// resetValues
//---------------------------------------------------------
void Appearance::resetValues()
{
*config = ::config; // init with global config values
styleSheetPath->setText(config->styleSheetFile);
updateFonts();
QPalette pal;
/*
pal.setColor(palette0->backgroundRole(), config->palette[0]);
palette0->setPalette(pal);
pal.setColor(palette1->backgroundRole(), config->palette[1]);
palette1->setPalette(pal);
pal.setColor(palette2->backgroundRole(), config->palette[2]);
palette2->setPalette(pal);
pal.setColor(palette3->backgroundRole(), config->palette[3]);
palette3->setPalette(pal);
pal.setColor(palette4->backgroundRole(), config->palette[4]);
palette4->setPalette(pal);
pal.setColor(palette5->backgroundRole(), config->palette[5]);
palette5->setPalette(pal);
pal.setColor(palette6->backgroundRole(), config->palette[6]);
palette6->setPalette(pal);
pal.setColor(palette7->backgroundRole(), config->palette[7]);
palette7->setPalette(pal);
pal.setColor(palette8->backgroundRole(), config->palette[8]);
palette8->setPalette(pal);
pal.setColor(palette9->backgroundRole(), config->palette[9]);
palette9->setPalette(pal);
pal.setColor(palette10->backgroundRole(), config->palette[10]);
palette10->setPalette(pal);
pal.setColor(palette11->backgroundRole(), config->palette[11]);
palette11->setPalette(pal);
pal.setColor(palette12->backgroundRole(), config->palette[12]);
palette12->setPalette(pal);
pal.setColor(palette13->backgroundRole(), config->palette[13]);
palette13->setPalette(pal);
pal.setColor(palette14->backgroundRole(), config->palette[14]);
palette14->setPalette(pal);
pal.setColor(palette15->backgroundRole(), config->palette[15]);
palette15->setPalette(pal);
*/
/*
pal.setColor(QPalette::Window, config->palette[0]);
palette0->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[1]);
palette1->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[2]);
palette2->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[3]);
palette3->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[4]);
palette4->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[5]);
palette5->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[6]);
palette6->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[7]);
palette7->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[8]);
palette8->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[9]);
palette9->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[10]);
palette10->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[11]);
palette11->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[12]);
palette12->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[13]);
palette13->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[14]);
palette14->setPalette(pal);
pal.setColor(QPalette::Window, config->palette[15]);
palette15->setPalette(pal);
*/
/*
pal.setColor(QPalette::Button, config->palette[0]);
palette0->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[1]);
palette1->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[2]);
palette2->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[3]);
palette3->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[4]);
palette4->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[5]);
palette5->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[6]);
palette6->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[7]);
palette7->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[8]);
palette8->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[9]);
palette9->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[10]);
palette10->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[11]);
palette11->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[12]);
palette12->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[13]);
palette13->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[14]);
palette14->setPalette(pal);
pal.setColor(QPalette::Button, config->palette[15]);
palette15->setPalette(pal);
*/
palette0->setStyleSheet(QString("background-color: ") + config->palette[0].name());
palette1->setStyleSheet(QString("background-color: ") + config->palette[1].name());
palette2->setStyleSheet(QString("background-color: ") + config->palette[2].name());
palette3->setStyleSheet(QString("background-color: ") + config->palette[3].name());
palette4->setStyleSheet(QString("background-color: ") + config->palette[4].name());
palette5->setStyleSheet(QString("background-color: ") + config->palette[5].name());
palette6->setStyleSheet(QString("background-color: ") + config->palette[6].name());
palette7->setStyleSheet(QString("background-color: ") + config->palette[7].name());
palette8->setStyleSheet(QString("background-color: ") + config->palette[8].name());
palette9->setStyleSheet(QString("background-color: ") + config->palette[9].name());
palette10->setStyleSheet(QString("background-color: ") + config->palette[10].name());
palette11->setStyleSheet(QString("background-color: ") + config->palette[11].name());
palette12->setStyleSheet(QString("background-color: ") + config->palette[12].name());
palette13->setStyleSheet(QString("background-color: ") + config->palette[13].name());
palette14->setStyleSheet(QString("background-color: ") + config->palette[14].name());
palette15->setStyleSheet(QString("background-color: ") + config->palette[15].name());
global_bg->takeChildren();
user_bg->takeChildren();
QDir bgdir = museGlobalShare + "/wallpapers/";
QStringList filters;
filters << "*.jpg" << "*.jpeg" << "*.png" << "*.gif";
bgdir.setNameFilters(filters);
backgroundTree->model()->setData(backgroundTree->model()->index(0,0),
QVariant(QSize(200,BG_ITEM_HEIGHT)),
Qt::SizeHintRole);
QStringList bglist = bgdir.entryList(QDir::Files, QDir::Name);
foreach (const QString &bgfile, bglist)
{
QTreeWidgetItem* item = new QTreeWidgetItem(global_bg, 0);
item->setData(0, Qt::UserRole, QVariant(museGlobalShare + "/wallpapers/" + bgfile));
BgPreviewWidget* bgw = new BgPreviewWidget(museGlobalShare + "/wallpapers/" + bgfile, backgroundTree);
backgroundTree->setItemWidget(item, 0, bgw);
if (config->canvasBgPixmap == museGlobalShare + "/wallpapers/" + bgfile)
backgroundTree->setCurrentItem(item);
}
foreach (const QString &bgfile, config->canvasCustomBgList)
{
QTreeWidgetItem* item = new QTreeWidgetItem(user_bg, 0);
BgPreviewWidget* bgw = new BgPreviewWidget(bgfile, backgroundTree);
backgroundTree->setItemWidget(item, 0, bgw);
item->setData(0, Qt::UserRole, QVariant(bgfile));
if (config->canvasBgPixmap == bgfile)
backgroundTree->setCurrentItem(item);
}
removeBgButton->setEnabled(false);
backgroundTree->expandAll();
connect(backgroundTree,
SIGNAL(itemClicked(QTreeWidgetItem*, int )),
SLOT(bgSelectionChanged(QTreeWidgetItem*)));
partShownames->setChecked(config->canvasShowPartType & 1);
partShowevents->setChecked(config->canvasShowPartType & 2);
partShowCakes->setChecked(!(config->canvasShowPartType & 2));
eventNoteon->setChecked(config->canvasShowPartEvent & (1 << 0));
eventPolypressure->setChecked(config->canvasShowPartEvent & (1 << 1));
eventController->setChecked(config->canvasShowPartEvent & (1 << 2));
eventProgramchange->setChecked(config->canvasShowPartEvent & (1 << 3));
eventAftertouch->setChecked(config->canvasShowPartEvent & (1 << 4));
eventPitchbend->setChecked(config->canvasShowPartEvent & (1 << 5));
eventSpecial->setChecked(config->canvasShowPartEvent & (1 << 6));
//eventButtonGroup->setEnabled(config->canvasShowPartType == 2);
eventButtonGroup->setEnabled(config->canvasShowPartType & 2);
arrGrid->setChecked(config->canvasShowGrid);
themeComboBox->clear();
QString cs = muse->style()->objectName();
//printf("Appearance::resetValues style:%s\n", cs.toAscii().data());
//printf("Appearance::resetValues App styleSheet:%s\n", qApp->styleSheet().toAscii().data());
cs = cs.toLower();
themeComboBox->insertItems(0, QStyleFactory::keys());
for (int i = 0; i < themeComboBox->count(); ++i) {
if (themeComboBox->itemText(i).toLower() == cs) {
themeComboBox->setCurrentIndex(i);
}
}
globalAlphaSlider->blockSignals(true);
globalAlphaVal->blockSignals(true);
globalAlphaSlider->setValue(config->globalAlphaBlend);
globalAlphaVal->setValue(config->globalAlphaBlend);
globalAlphaSlider->blockSignals(false);
globalAlphaVal->blockSignals(false);
updateColor();
}
//---------------------------------------------------------
// bgSelectionChanged
//---------------------------------------------------------
void Appearance::bgSelectionChanged(QTreeWidgetItem* item)
{
if (item->text(0).length() && lastSelectedBgItem)
{
backgroundTree->setCurrentItem(lastSelectedBgItem);
item = lastSelectedBgItem;
}
removeBgButton->setEnabled(false);
QTreeWidgetItem* parent = item->parent();
if (parent)
if (parent->text(0) == user_bg->text(0))
removeBgButton->setEnabled(true);
lastSelectedBgItem = item;
muse->arranger->getCanvas()->setBg(QPixmap(item->data(0, Qt::UserRole).toString()));
}
//---------------------------------------------------------
// Appearance
//---------------------------------------------------------
Appearance::~Appearance()
{
delete config;
}
//---------------------------------------------------------
// updateFonts
//---------------------------------------------------------
void Appearance::updateFonts()
{
fontSize0->setValue(config->fonts[0].pointSize());
fontName0->setText(config->fonts[0].family());
italic0->setChecked(config->fonts[0].italic());
bold0->setChecked(config->fonts[0].bold());
fontSize1->setValue(config->fonts[1].pointSize());
fontName1->setText(config->fonts[1].family());
italic1->setChecked(config->fonts[1].italic());
bold1->setChecked(config->fonts[1].bold());
fontSize2->setValue(config->fonts[2].pointSize());
fontName2->setText(config->fonts[2].family());
italic2->setChecked(config->fonts[2].italic());
bold2->setChecked(config->fonts[2].bold());
fontSize3->setValue(config->fonts[3].pointSize());
fontName3->setText(config->fonts[3].family());
italic3->setChecked(config->fonts[3].italic());
bold3->setChecked(config->fonts[3].bold());
fontSize4->setValue(config->fonts[4].pointSize());
fontName4->setText(config->fonts[4].family());
italic4->setChecked(config->fonts[4].italic());
bold4->setChecked(config->fonts[4].bold());
fontSize5->setValue(config->fonts[5].pointSize());
fontName5->setText(config->fonts[5].family());
italic5->setChecked(config->fonts[5].italic());
bold5->setChecked(config->fonts[5].bold());
fontSize6->setValue(config->fonts[6].pointSize());
fontName6->setText(config->fonts[6].family());
italic6->setChecked(config->fonts[6].italic());
bold6->setChecked(config->fonts[6].bold());
}
//---------------------------------------------------------
// apply
//---------------------------------------------------------
void Appearance::apply()
{
int showPartEvent = 0;
int showPartType = 0;
if (partShownames->isChecked())
showPartType |= 1;
if (partShowevents->isChecked())
showPartType |= 2;
//if (partShowCakes->isChecked())
// showPartType |= 4;
config->canvasShowPartType = showPartType;
if (eventNoteon->isChecked())
showPartEvent |= (1 << 0);
if (eventPolypressure->isChecked())
showPartEvent |= (1 << 1);
if (eventController->isChecked())
showPartEvent |= (1 << 2);
if (eventProgramchange->isChecked())
showPartEvent |= (1 << 3);
if (eventAftertouch->isChecked())
showPartEvent |= (1 << 4);
if (eventPitchbend->isChecked())
showPartEvent |= (1 << 5);
if (eventSpecial->isChecked())
showPartEvent |= (1 << 6);
config->canvasShowPartEvent = showPartEvent;
QTreeWidgetItem* cbgitem = backgroundTree->currentItem();
if (cbgitem)
config->canvasBgPixmap = cbgitem->data(0, Qt::UserRole).toString();
else
config->canvasBgPixmap = QString();
config->canvasCustomBgList = QStringList();
for (int i = 0; i < user_bg->childCount(); ++i)
config->canvasCustomBgList << user_bg->child(i)->data(0, Qt::UserRole).toString();
config->styleSheetFile = styleSheetPath->text();
config->fonts[0].setFamily(fontName0->text());
config->fonts[0].setPointSize(fontSize0->value());
config->fonts[0].setItalic(italic0->isChecked());
config->fonts[0].setBold(bold0->isChecked());
QApplication::setFont(config->fonts[0]);
config->fonts[1].setFamily(fontName1->text());
config->fonts[1].setPointSize(fontSize1->value());
config->fonts[1].setItalic(italic1->isChecked());
config->fonts[1].setBold(bold1->isChecked());
config->fonts[2].setFamily(fontName2->text());
config->fonts[2].setPointSize(fontSize2->value());
config->fonts[2].setItalic(italic2->isChecked());
config->fonts[2].setBold(bold2->isChecked());
config->fonts[3].setFamily(fontName3->text());
config->fonts[3].setPointSize(fontSize3->value());
config->fonts[3].setItalic(italic3->isChecked());
config->fonts[3].setBold(bold3->isChecked());
config->fonts[4].setFamily(fontName4->text());
config->fonts[4].setPointSize(fontSize4->value());
config->fonts[4].setItalic(italic4->isChecked());
config->fonts[4].setBold(bold4->isChecked());
config->fonts[5].setFamily(fontName5->text());
config->fonts[5].setPointSize(fontSize5->value());
config->fonts[5].setItalic(italic5->isChecked());
config->fonts[5].setBold(bold5->isChecked());
config->fonts[6].setFamily(fontName6->text());
config->fonts[6].setPointSize(fontSize6->value());
config->fonts[6].setItalic(italic6->isChecked());
config->fonts[6].setBold(bold6->isChecked());
config->style = themeComboBox->currentText();
// setting up a new theme might change the fontsize, so re-read
fontSize0->setValue(QApplication::font().pointSize());
config->canvasShowGrid = arrGrid->isChecked();
config->globalAlphaBlend = globalAlphaVal->value();
// set colors...
::config = *config;
muse->changeConfig(true);
}
//---------------------------------------------------------
// colorNameEditFinished
//---------------------------------------------------------
void Appearance::colorNameEditFinished()
{
if(!lastSelectedColorItem)
return;
IdListViewItem* item = (IdListViewItem*)lastSelectedColorItem;
int id = item->id();
if(id == 0)
return;
QString etxt = colorNameLineEdit->text();
QString txt = item->text(0);
// We only support part color names, for now.
if(id >= 0x400 && id < (0x400 + NUM_PARTCOLORS))
config->partColorNames[id & 0xff] = etxt;
if(etxt != txt)
item->setText(0, etxt);
}
//---------------------------------------------------------
// ok
//---------------------------------------------------------
void Appearance::ok()
{
apply();
close();
}
//---------------------------------------------------------
// cancel
//---------------------------------------------------------
void Appearance::cancel()
{
muse->arranger->getCanvas()->setBg(QPixmap(config->canvasBgPixmap));
close();
}
//---------------------------------------------------------
// removeBackground
//---------------------------------------------------------
void Appearance::removeBackground()
{
QTreeWidgetItem* item = backgroundTree->currentItem();
muse->arranger->getCanvas()->setBg(QPixmap());
user_bg->takeChild(user_bg->indexOfChild(item));
backgroundTree->setCurrentItem (0);
removeBgButton->setEnabled(false);
}
//---------------------------------------------------------
// addBackground
//---------------------------------------------------------
void Appearance::addBackground()
{
QString cur = getenv("HOME");
QString user_bgfile = getImageFileName(cur, image_file_pattern, this,
tr("MusE: load image"));
bool image_exists = false;
for (int i = 0; i < global_bg->childCount(); ++i)
if (global_bg->child(i)->data(0, Qt::UserRole).toString() == user_bgfile)
image_exists = true;
for (int i = 0; i < user_bg->childCount(); ++i)
if (user_bg->child(i)->data(0, Qt::UserRole).toString() == user_bgfile)
image_exists = true;
if (! image_exists)
{
QTreeWidgetItem* item = new QTreeWidgetItem(user_bg, 0);
item->setData(0, Qt::UserRole, QVariant(user_bgfile));
BgPreviewWidget* bgw = new BgPreviewWidget(user_bgfile, backgroundTree);
backgroundTree->setItemWidget(item, 0, bgw);
}
}
//---------------------------------------------------------
// clearBackground
//---------------------------------------------------------
void Appearance::clearBackground()
{
muse->arranger->getCanvas()->setBg(QPixmap());
backgroundTree->setCurrentItem (0);
removeBgButton->setEnabled(false);
}
//---------------------------------------------------------
// selectionChanged
//---------------------------------------------------------
void Appearance::colorItemSelectionChanged()
{
IdListViewItem* item = (IdListViewItem*)itemList->selectedItems()[0];
lastSelectedColorItem = 0;
QString txt = item->text(0);
int id = item->id();
if (id == 0) {
color = 0;
lastSelectedColorItem = 0;
colorNameLineEdit->setEnabled(false);
return;
}
bool enle = false;
switch(id) {
case 0x400: // "Default"
case 0x401: // "Refrain"
case 0x402: // "Bridge"
case 0x403: // "Intro"
case 0x404: // "Coda"
case 0x405: // "Chorus"
case 0x406: // "Solo"
case 0x407: // "Brass"
case 0x408: // "Percussion"
case 0x409: // "Drums"
case 0x40a: // "Guitar"
case 0x40b: // "Bass"
case 0x40c: // "Flute"
case 0x40d: // "Strings
case 0x40e: // "Keyboard
case 0x40f: // "Piano
case 0x410: // "Saxophon
lastSelectedColorItem = item;
color = &config->partColors[id & 0xff];
enle = true;
break;
case 0x100: color = &config->bigTimeBackgroundColor; break;
case 0x101: color = &config->bigTimeForegroundColor; break;
case 0x200: color = &config->transportHandleColor; break;
case 0x300: color = &config->waveEditBackgroundColor; break;
case 0x411: color = &config->trackBg; break;
case 0x412: color = &config->midiTrackBg; break;
case 0x413: color = &config->drumTrackBg; break;
case 0x414: color = &config->waveTrackBg; break;
case 0x415: color = &config->outputTrackBg; break;
case 0x416: color = &config->inputTrackBg; break;
case 0x417: color = &config->groupTrackBg; break;
case 0x418: color = &config->auxTrackBg; break;
case 0x419: color = &config->synthTrackBg; break;
case 0x41a: color = &config->selectTrackBg; break;
case 0x41b: color = &config->selectTrackFg; break;
case 0x41c: color = &config->partCanvasBg; break;
case 0x41d: color = &config->ctrlGraphFg; break;
case 0x500: color = &config->mixerBg; break;
case 0x501: color = &config->midiTrackLabelBg; break;
case 0x502: color = &config->drumTrackLabelBg; break;
case 0x503: color = &config->waveTrackLabelBg; break;
case 0x504: color = &config->outputTrackLabelBg; break;
case 0x505: color = &config->inputTrackLabelBg; break;
case 0x506: color = &config->groupTrackLabelBg; break;
case 0x507: color = &config->auxTrackLabelBg; break;
case 0x508: color = &config->synthTrackLabelBg; break;
default:
color = 0;
break;
}
colorNameLineEdit->setEnabled(enle);
QString s;
if(enle)
s = config->partColorNames[id & 0xff];
colorNameLineEdit->setText(s);
updateColor();
}
void Appearance::updateColor()
{
int r, g, b, h, s, v;
//globalAlphaSlider->setEnabled(color);
rslider->setEnabled(color);
gslider->setEnabled(color);
bslider->setEnabled(color);
hslider->setEnabled(color);
sslider->setEnabled(color);
vslider->setEnabled(color);
//globalAlphaVal->setEnabled(color);
rval->setEnabled(color);
gval->setEnabled(color);
bval->setEnabled(color);
hval->setEnabled(color);
sval->setEnabled(color);
vval->setEnabled(color);
if (color == 0)
return;
QPalette pal;
QColor cfc(*color);
// Oops can't do this - affects all colour items. Need to filter.
///cfc.setAlpha(globalAlphaVal->value());
pal.setColor(colorframe->backgroundRole(), cfc);
colorframe->setPalette(pal);
color->getRgb(&r, &g, &b);
color->getHsv(&h, &s, &v);
//a = color->alpha();
//a = config->globalAlphaBlend;
rslider->blockSignals(true);
gslider->blockSignals(true);
bslider->blockSignals(true);
hslider->blockSignals(true);
sslider->blockSignals(true);
vslider->blockSignals(true);
rval->blockSignals(true);
gval->blockSignals(true);
bval->blockSignals(true);
hval->blockSignals(true);
sval->blockSignals(true);
vval->blockSignals(true);
rslider->setValue(r);
gslider->setValue(g);
bslider->setValue(b);
hslider->setValue(h);
sslider->setValue(s);
vslider->setValue(v);
rval->setValue(r);
gval->setValue(g);
bval->setValue(b);
hval->setValue(h);
sval->setValue(s);
vval->setValue(v);
rslider->blockSignals(false);
gslider->blockSignals(false);
bslider->blockSignals(false);
hslider->blockSignals(false);
sslider->blockSignals(false);
vslider->blockSignals(false);
rval->blockSignals(false);
gval->blockSignals(false);
bval->blockSignals(false);
hval->blockSignals(false);
sval->blockSignals(false);
vval->blockSignals(false);
}
void Appearance::asliderChanged(int val)
{
globalAlphaVal->blockSignals(true);
globalAlphaVal->setValue(val);
globalAlphaVal->blockSignals(false);
updateColor();
}
void Appearance::aValChanged(int val)
{
globalAlphaSlider->blockSignals(true);
globalAlphaSlider->setValue(val);
globalAlphaSlider->blockSignals(false);
updateColor();
}
void Appearance::rsliderChanged(int val)
{
int r, g, b;
if (color) {
color->getRgb(&r, &g, &b);
color->setRgb(val, g, b);
}
updateColor();
}
void Appearance::gsliderChanged(int val)
{
int r, g, b;
if (color) {
color->getRgb(&r, &g, &b);
color->setRgb(r, val, b);
}
updateColor();
}
void Appearance::bsliderChanged(int val)
{
int r, g, b;
if (color) {
color->getRgb(&r, &g, &b);
color->setRgb(r, g, val);
}
updateColor();
}
void Appearance::hsliderChanged(int val)
{
int h, s, v;
if (color) {
color->getHsv(&h, &s, &v);
color->setHsv(val, s, v);
}
updateColor();
}
void Appearance::ssliderChanged(int val)
{
int h, s, v;
if (color) {
color->getHsv(&h, &s, &v);
color->setHsv(h, val, v);
}
updateColor();
}
void Appearance::vsliderChanged(int val)
{
int h, s, v;
if (color) {
color->getHsv(&h, &s, &v);
color->setHsv(h, s, val);
}
updateColor();
}
//---------------------------------------------------------
// addToPaletteClicked
//---------------------------------------------------------
void Appearance::addToPaletteClicked()
{
if (!color)
return;
QAbstractButton* button = (QAbstractButton*)aPalette->checkedButton(); // ddskrjo
int r, g, b;
QColor c;
if (button) {
int id = aPalette->id(button);
c = config->palette[id];
c.getRgb(&r, &g, &b);
}
if (button == 0 || r != 0xff || g != 0xff || b != 0xff) {
for (int i = 0; i < 16; ++i) {
c = config->palette[i];
c.getRgb(&r, &g, &b);
if (r == 0xff && g == 0xff && b == 0xff) {
// found empty slot
aPalette->button(i)->toggle();
//aPalette->moveFocus(i); ddskrjo
button = (QAbstractButton*)aPalette->button(i); // ddskrjo
break;
}
}
}
if (button) {
int id = aPalette->id(button);
config->palette[id] = *color;
//QPalette pal;
//pal.setColor(button->backgroundRole(), *color);
//pal.setColor(QPalette::Window, *color);
//pal.setColor(QPalette::Button, *color);
//button->setPalette(pal);
button->setStyleSheet(QString("background-color: ") + color->name());
button->update(); //??
}
}
//---------------------------------------------------------
// paletteClicked
//---------------------------------------------------------
void Appearance::paletteClicked(int id)
{
if (!color)
return;
QAbstractButton* button = (QAbstractButton*)aPalette->button(id); // ddskrjo
if (button) {
QColor c = button->palette().color(QPalette::Window);
//QColor c = button->palette().color(button->backgroundRole());
int r, g, b;
c.getRgb(&r, &g, &b);
if (r == 0xff && g == 0xff && b == 0xff)
return; // interpret palette slot as empty
*color = c;
updateColor();
}
}
//---------------------------------------------------------
// browseStyleSheet
//---------------------------------------------------------
void Appearance::browseStyleSheet()
{
QString path;
if(!config->styleSheetFile.isEmpty())
{
QFileInfo info(config->styleSheetFile);
path = info.absolutePath();
}
QString file = QFileDialog::getOpenFileName(this, tr("Select style sheet"), path, tr("Qt style sheets (*.qss)"));
styleSheetPath->setText(file);
}
//---------------------------------------------------------
// setDefaultStyleSheet
//---------------------------------------------------------
void Appearance::setDefaultStyleSheet()
{
// Set the style sheet to the default compiled-in resource :/style.qss
styleSheetPath->setText(QString(":/style.qss"));
}
//---------------------------------------------------------
// browseFont
//---------------------------------------------------------
void Appearance::browseFont0() { browseFont(0); }
void Appearance::browseFont1() { browseFont(1); }
void Appearance::browseFont2() { browseFont(2); }
void Appearance::browseFont3() { browseFont(3); }
void Appearance::browseFont4() { browseFont(4); }
void Appearance::browseFont5() { browseFont(5); }
void Appearance::browseFont6() { browseFont(6); }
void Appearance::browseFont(int n)
{
bool ok;
QFont font = QFontDialog::getFont(&ok, config->fonts[n], this, "browseFont");
if (ok) {
config->fonts[n] = font;
updateFonts();
}
}
|