~ubuntu-branches/ubuntu/trusty/muse/trusty

« back to all changes in this revision

Viewing changes to muse/appearance.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2013-08-28 16:25:57 UTC
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: package-import@ubuntu.com-20130828162557-knls3ip7j262eepx
Tags: upstream-2.1.2
ImportĀ upstreamĀ versionĀ 2.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <QFileInfo>
33
33
#include <QPainter>
34
34
#include <QtGlobal>
 
35
#include <QMessageBox>
35
36
 
36
37
#include "icons.h"
37
38
#include "appearance.h"
145
146
      global_bg->setFlags(Qt::ItemIsEnabled);
146
147
      user_bg = new QTreeWidgetItem(backgroundTree, QStringList(tr("Custom")), 0);
147
148
      user_bg->setFlags(Qt::ItemIsEnabled);
148
 
      colorframe->setAutoFillBackground(true);
 
149
      colorwidget->setAutoFillBackground(true);
149
150
      aPalette = new QButtonGroup(aPaletteBox);
150
151
 
151
152
      aPalette->addButton(palette0, 0);
177
178
             new IdListViewItem(0x400 + i, id, MusEGlobal::config.partColorNames[i]);
178
179
           
179
180
           new IdListViewItem(0x41c, aid, "part canvas background");
 
181
           new IdListViewItem(0x41f, aid, "Ruler background");
 
182
           new IdListViewItem(0x420, aid, "Ruler text");
 
183
           new IdListViewItem(0x424, aid, "Ruler current marker space");
 
184
           new IdListViewItem(0x425, aid, "part wave peak");
 
185
           new IdListViewItem(0x426, aid, "part wave rms");
 
186
           new IdListViewItem(0x427, aid, "part midi event for light part color");
 
187
           new IdListViewItem(0x428, aid, "part midi event for dark part color");
 
188
 
180
189
      id = new IdListViewItem(0, aid, "Track List");
181
190
           new IdListViewItem(0x411, id, "background");
182
191
           new IdListViewItem(0x412, id, "midi background");
190
199
           new IdListViewItem(0x419, id, "synth background");
191
200
           new IdListViewItem(0x41a, id, "selected track background");
192
201
           new IdListViewItem(0x41b, id, "selected track foreground");
193
 
           //   0x41e is already used (between 413 and 414)
 
202
           //   0x41c - 0x420 is already used (see above)
194
203
      id = new IdListViewItem(0, itemList, "BigTime");
195
204
           new IdListViewItem(0x100, id, "background");
196
205
           new IdListViewItem(0x101, id, "foreground");
197
206
      id = new IdListViewItem(0, itemList, "Transport");
198
207
           new IdListViewItem(0x200, id, "handle");
199
208
      id = new IdListViewItem(0, itemList, "Midi Editor");
200
 
           new IdListViewItem(0x41d, id, "controller graph");
 
209
           new IdListViewItem(0x41d, id, "controller graph color");
 
210
           new IdListViewItem(0x423, id, "controller graph background");
 
211
           new IdListViewItem(0x421, id, "background");
 
212
           new IdListViewItem(0x422, id, "drum list");
 
213
 
201
214
      id = new IdListViewItem(0, itemList, "Wave Editor");
202
 
           new IdListViewItem(0x300, id, "background");
 
215
           new IdListViewItem(0x300, id, "Background");
 
216
           new IdListViewItem(0x301, id, "Wave peak color");
 
217
           new IdListViewItem(0x302, id, "Wave rms color");
 
218
           new IdListViewItem(0x303, id, "Wave peak color selected");
 
219
           new IdListViewItem(0x304, id, "Wave rms color selected");
 
220
           new IdListViewItem(0x305, id, "Wave nonselected part");
 
221
 
203
222
      id = new IdListViewItem(0, itemList, "Mixer");
204
223
           new IdListViewItem(0x500, id, "background");
205
224
           new IdListViewItem(0x501, id, "midi label");
237
256
      connect(addToPalette, SIGNAL(clicked()), SLOT(addToPaletteClicked()));
238
257
 
239
258
      //---------------------------------------------------
240
 
        //    STYLE
 
259
      //    STYLE
241
260
      //---------------------------------------------------
242
261
      openStyleSheet->setIcon(*openIcon);
243
262
      connect(openStyleSheet, SIGNAL(clicked()), SLOT(browseStyleSheet()));
245
264
      connect(defaultStyleSheet, SIGNAL(clicked()), SLOT(setDefaultStyleSheet()));
246
265
      
247
266
      //---------------------------------------------------
248
 
        //    Fonts
 
267
      //    THEMES
 
268
      //---------------------------------------------------
 
269
      connect(changeThemeButton, SIGNAL(clicked()), SLOT(changeTheme()));
 
270
 
 
271
      QDir themeDir(MusEGlobal::museGlobalShare + QString("/themes"));
 
272
      QStringList list;
 
273
 
 
274
      QStringList fileTypes;
 
275
      fileTypes.append("*.cfg");
 
276
      list = themeDir.entryList(fileTypes);
 
277
 
 
278
      colorSchemeComboBox->addItems(list);
 
279
 
 
280
      //---------------------------------------------------
 
281
      //    Fonts
249
282
      //---------------------------------------------------
250
283
 
251
284
      fontBrowse0->setIcon(QIcon(*openIcon));
270
303
      connect(removeBgButton, SIGNAL(clicked()), SLOT(removeBackground()));
271
304
      connect(clearBgButton, SIGNAL(clicked()), SLOT(clearBackground()));
272
305
      connect(partShowevents, SIGNAL(toggled(bool)), eventButtonGroup, SLOT(setEnabled(bool)));
 
306
 
273
307
      //updateColor();
274
308
      }
275
309
 
458
492
      }
459
493
 
460
494
//---------------------------------------------------------
 
495
//   changeTheme
 
496
//
 
497
//---------------------------------------------------------
 
498
 
 
499
void Appearance::changeTheme()
 
500
{
 
501
    if (colorSchemeComboBox->currentIndex() == 0) {
 
502
      return;
 
503
    }
 
504
    if(QMessageBox::question(MusEGlobal::muse, QString("Muse"),
 
505
        tr("Do you really want to reset colors to theme default?"), tr("&Ok"), tr("&Cancel"),
 
506
        QString::null, 0, 1 ) == 1)
 
507
    {
 
508
        return;
 
509
    }
 
510
 
 
511
 
 
512
    QString currentTheme = colorSchemeComboBox->currentText();
 
513
    printf("Changing to theme %s\n", currentTheme.toLatin1().constData() );
 
514
 
 
515
    QString themeDir = MusEGlobal::museGlobalShare + "/themes/";
 
516
    backgroundTree->reset();
 
517
    if (QFile::exists(themeDir + QFileInfo(currentTheme).baseName()+ ".qss"))
 
518
    {
 
519
      styleSheetPath->setText(themeDir + QFileInfo(currentTheme).baseName()+ ".qss");
 
520
      MusEGlobal::config.styleSheetFile = styleSheetPath->text();
 
521
    }
 
522
    else
 
523
    {
 
524
      styleSheetPath->setText("arg");
 
525
      MusEGlobal::muse->loadStyleSheetFile("");
 
526
      MusEGlobal::config.styleSheetFile = "";
 
527
    }
 
528
 
 
529
    QString configPath = themeDir + currentTheme;
 
530
    MusECore::readConfiguration(configPath.toLatin1().constData());
 
531
    colorSchemeComboBox->setCurrentIndex(0);
 
532
    MusEGlobal::muse->changeConfig(true);
 
533
 
 
534
    close();
 
535
}
 
536
//---------------------------------------------------------
461
537
//   apply
462
538
//---------------------------------------------------------
463
539
 
464
540
void Appearance::apply()
465
541
      {
 
542
//
 
543
//
466
544
      int showPartEvent = 0;
467
545
      int showPartType = 0;
468
546
 
469
 
      if (partShownames->isChecked())           
 
547
      if (partShownames->isChecked())
470
548
                showPartType  |= 1;
471
 
      if (partShowevents->isChecked())          
 
549
      if (partShowevents->isChecked())
472
550
                showPartType  |= 2;
473
 
      if (partCakeStretch->isChecked())         
 
551
      if (partCakeStretch->isChecked())
474
552
                showPartType  |= 4;
475
553
 
476
554
      config->canvasShowPartType = showPartType;
477
555
 
478
 
      if (eventNoteon->isChecked())             
 
556
      if (eventNoteon->isChecked())
479
557
                showPartEvent |= (1 << 0);
480
 
      if (eventPolypressure->isChecked())       
 
558
      if (eventPolypressure->isChecked())
481
559
                showPartEvent |= (1 << 1);
482
 
      if (eventController->isChecked()) 
 
560
      if (eventController->isChecked())
483
561
                showPartEvent |= (1 << 2);
484
 
      if (eventProgramchange->isChecked())      
 
562
      if (eventProgramchange->isChecked())
485
563
                showPartEvent |= (1 << 3);
486
 
      if (eventAftertouch->isChecked()) 
 
564
      if (eventAftertouch->isChecked())
487
565
                showPartEvent |= (1 << 4);
488
 
      if (eventPitchbend->isChecked())          
 
566
      if (eventPitchbend->isChecked())
489
567
                showPartEvent |= (1 << 5);
490
 
      if (eventSpecial->isChecked())            
 
568
      if (eventSpecial->isChecked())
491
569
                showPartEvent |= (1 << 6);
492
570
 
493
571
      config->canvasShowPartEvent = showPartEvent;
502
580
      config->canvasCustomBgList = QStringList();
503
581
      for (int i = 0; i < user_bg->childCount(); ++i)
504
582
            config->canvasCustomBgList << user_bg->child(i)->data(0, Qt::UserRole).toString();
505
 
      
 
583
 
506
584
      config->styleSheetFile = styleSheetPath->text();
507
 
      
 
585
 
508
586
      config->fonts[0].setFamily(fontName0->text());
509
 
      
 
587
 
510
588
      config->fonts[0].setPointSize(fontSize0->value());
511
589
      config->fonts[0].setItalic(italic0->isChecked());
512
590
      config->fonts[0].setBold(bold0->isChecked());
543
621
      config->fonts[6].setBold(bold6->isChecked());
544
622
 
545
623
      config->style = themeComboBox->currentIndex() == 0 ? QString() : themeComboBox->currentText();
546
 
        // setting up a new theme might change the fontsize, so re-read
 
624
      // setting up a new theme might change the fontsize, so re-read
547
625
      fontSize0->setValue(QApplication::font().pointSize());
548
626
 
549
627
      config->canvasShowGrid = arrGrid->isChecked();
550
 
      
 
628
 
551
629
      config->globalAlphaBlend = globalAlphaVal->value();
552
 
      
553
630
      // set colors...
554
631
      MusEGlobal::config = *config;
 
632
 
555
633
      MusEGlobal::muse->changeConfig(true);
556
634
      }
557
635
 
692
770
            case 0x101: color = &config->bigTimeForegroundColor; break;
693
771
            case 0x200: color = &config->transportHandleColor; break;
694
772
            case 0x300: color = &config->waveEditBackgroundColor; break;
 
773
            case 0x301: color = &config->wavePeakColor; break;
 
774
            case 0x302: color = &config->waveRmsColor; break;
 
775
            case 0x303: color = &config->wavePeakColorSelected; break;
 
776
            case 0x304: color = &config->waveRmsColorSelected; break;
 
777
            case 0x305: color = &config->waveNonselectedPart; break;
 
778
 
695
779
            case 0x411: color = &config->trackBg;       break;
696
780
            case 0x412: color = &config->midiTrackBg;   break;
697
781
            case 0x413: color = &config->drumTrackBg;   break;
706
790
            case 0x41b: color = &config->selectTrackFg;  break;
707
791
            case 0x41c: color = &config->partCanvasBg; break;
708
792
            case 0x41d: color = &config->ctrlGraphFg; break;
 
793
 
709
794
            //   0x41e is already used (between 413 and 414)
710
795
 
 
796
            case 0x41f: color = &config->rulerBg; break;
 
797
            case 0x420: color = &config->rulerFg; break;
 
798
            case 0x421: color = &config->midiCanvasBg; break;
 
799
            case 0x422: color = &config->drumListBg; break;
 
800
            case 0x423: color = &config->midiControllerViewBg; break;
 
801
            case 0x424: color = &config->rulerCurrent; break;
 
802
            case 0x425: color = &config->partWaveColorPeak; break;
 
803
            case 0x426: color = &config->partWaveColorRms; break;
 
804
            case 0x427: color = &config->partMidiDarkEventColor; break;
 
805
            case 0x428: color = &config->partMidiLightEventColor; break;
 
806
 
711
807
            case 0x500: color = &config->mixerBg;   break;
712
808
            case 0x501: color = &config->midiTrackLabelBg;   break;
713
809
            case 0x502: color = &config->drumTrackLabelBg;   break;
752
848
      QPalette pal;
753
849
      QColor cfc(*color);
754
850
      
755
 
      pal.setColor(colorframe->backgroundRole(), cfc);
756
 
      colorframe->setPalette(pal);
 
851
      colorwidget->setColor(cfc);
 
852
 
757
853
      color->getRgb(&r, &g, &b);
758
854
      color->getHsv(&h, &s, &v);
759
855