~ubuntu-branches/ubuntu/raring/muse/raring

« back to all changes in this revision

Viewing changes to synti/simpledrums/simpledrumsgui.cpp

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2011-08-12 11:16:41 UTC
  • mfrom: (1.1.9) (10.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20110812111641-sjz0e93fr0ozfv0b
Tags: 2.0~beta2-1
* New maintainer (see bug 637185#12), thanks Daniel!
* New upstream release (Closes: #627371):
  - New interface Qt4-based (Closes: #604584)
* Refresh packaging:
  - Move to DH7 and source format 3.0 (quilt).
  - Refresh patchset.
  - Fix a bunch lintian warnings.
  - debian/postinst:
    + Use set -e in the body rather than pass -e on the #! line to make it
      have actually effect if it is run by hand with "sh /path/to/script".
  - Update instructions on how-to increase RTC clock frequency.
    Thanks to Torquil Macdonald Sørensen for the report (Closes: #570833).
  - Bump Standards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
//
11
11
//
12
12
 
13
 
#include <qbuttongroup.h>
 
13
#include <q3buttongroup.h>
14
14
#include <qlabel.h>
15
 
#include <qfiledialog.h>
 
15
#include <q3filedialog.h>
16
16
#include <qsocketnotifier.h>
17
17
#include <qlayout.h>
 
18
#include <qtooltip.h>
 
19
#include <qlineedit.h>
 
20
#include <QtGui>
 
21
//Added by qt3to4:
 
22
#include <Q3HBoxLayout>
 
23
#include <Q3GridLayout>
 
24
#include <Q3VBoxLayout>
18
25
 
19
26
#include "simpledrumsgui.h"
20
 
#include "libsynti/mpevent.h"
 
27
//#include "libsynti/mpevent.h"
 
28
#include "muse/mpevent.h"   
21
29
#include "muse/midi.h"
22
30
#include "ssplugingui.h"
23
31
 
206
214
      pluginGui = new SS_PluginGui(this);
207
215
      pluginGui->hide();
208
216
 
209
 
      QVBoxLayout* mainLayout = new QVBoxLayout(this, 3);
210
 
      QHBoxLayout* channelLayout = new QHBoxLayout(mainLayout, 1, "channellayout");
 
217
      Q3VBoxLayout* mainLayout = new Q3VBoxLayout(this, 3);
 
218
      Q3HBoxLayout* channelLayout = new Q3HBoxLayout(mainLayout, 1, "channellayout");
211
219
 
212
220
      //this->setFixedWidth(SS_GUI_WINDOW_WIDTH);
213
221
      //this->setFixedHeight(SS_GUI_WINDOW_HEIGHT);
214
222
      for (int i=0; i<SS_NR_OF_CHANNELS; i++) {
215
 
            channelButtonGroups[i] = new QButtonGroup(this);
 
223
            channelButtonGroups[i] = new Q3ButtonGroup(this);
216
224
            channelButtonGroups[i]->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
217
225
            channelButtonGroups[i]->setTitle(QString::number(i + 1));
218
226
 
221
229
 
222
230
            channelLayout->add(channelButtonGroups[i]);
223
231
 
224
 
            QVBoxLayout* inchnlLayout = new QVBoxLayout(channelButtonGroups[i], 2, 0, "channelinternallayout");
 
232
            Q3VBoxLayout* inchnlLayout = new Q3VBoxLayout(channelButtonGroups[i], 2, 0, "channelinternallayout");
225
233
            inchnlLayout->setAlignment(Qt::AlignHCenter);
226
234
 
227
235
            onOff[i] = new QChannelCheckbox(channelButtonGroups[i], i);
230
238
            inchnlLayout->add(onOff[i]);
231
239
            connect(onOff[i], SIGNAL(channelState(int, bool)), SLOT(channelOnOff(int, bool)));
232
240
 
233
 
            volumeSliders[i] = new QInvertedChannelSlider(QSlider::Vertical, i, channelButtonGroups[i], name);
 
241
            volumeSliders[i] = new QInvertedChannelSlider(Qt::Vertical, i, channelButtonGroups[i], name);
234
242
            volumeSliders[i]->setMinValue(SS_VOLUME_MIN_VALUE);
235
243
            volumeSliders[i]->setMaxValue(SS_VOLUME_MAX_VALUE);
236
244
            volumeSliders[i]->setValue(SS_VOLUME_MAX_VALUE - SS_VOLUME_DEFAULT_VALUE);
251
259
            inchnlLayout->add(nOffIgnore[i]);
252
260
            connect(nOffIgnore[i], SIGNAL(channelState(int, bool)),SLOT(channelNoteOffIgnore(int, bool)));
253
261
 
254
 
            panSliders[i] = new QChannelSlider(QSlider::Horizontal, i, channelButtonGroups[i]);
 
262
            panSliders[i] = new QChannelSlider(Qt::Horizontal, i, channelButtonGroups[i]);
255
263
            panSliders[i]->setRange(0, 127);
256
264
            panSliders[i]->setValue(SS_PANSLDR_DEFAULT_VALUE);
257
265
            panSliders[i]->setMinimumSize(SS_PANSLDR_WIDTH, SS_PANSLDR_LENGTH);
259
267
            inchnlLayout->add(panSliders[i]);
260
268
            connect(panSliders[i], SIGNAL(valueChanged(int, int)), SLOT(panChanged(int, int)));
261
269
 
262
 
            QGridLayout* dialGrid = new QGridLayout(inchnlLayout, 2, 2, 0);
 
270
            Q3GridLayout* dialGrid = new Q3GridLayout(inchnlLayout, 2, 2, 0);
263
271
            sendFxDial[i][0] = new QChannelDial(channelButtonGroups[i], i, 0);
264
272
            sendFxDial[i][0]->setRange(0, 127);
265
273
            sendFxDial[i][0]->setMaximumSize(SS_SENDFX_WIDTH, SS_SENDFX_HEIGHT);
298
306
            }
299
307
 
300
308
      //Master buttongroup:
301
 
      masterButtonGroup = new QButtonGroup(this, "masterButtonGroup");
 
309
      masterButtonGroup = new Q3ButtonGroup(this, "masterButtonGroup");
302
310
      channelLayout->add(masterButtonGroup);
303
 
      QVBoxLayout* mbgLayout = new QVBoxLayout(masterButtonGroup, 0);
 
311
      Q3VBoxLayout* mbgLayout = new Q3VBoxLayout(masterButtonGroup, 0);
304
312
      mbgLayout->setAlignment(Qt::AlignCenter);
305
313
      masterButtonGroup->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
306
 
      masterSlider = new QInvertedSlider(QSlider::Vertical, masterButtonGroup);
 
314
      masterSlider = new QInvertedSlider(Qt::Vertical, masterButtonGroup);
307
315
      QToolTip::add(masterSlider, "Master volume");
308
316
      mbgLayout->add(masterSlider);
309
317
      masterSlider->setRange(0, 127);
312
320
      connect(masterSlider, SIGNAL(invertedValueChanged(int)), SLOT(masterVolChanged(int)));
313
321
 
314
322
      //Main groupbox
315
 
      mainGroupBox = new QGroupBox(this, "mainGroupBox");
 
323
      mainGroupBox = new Q3GroupBox(this, "mainGroupBox");
316
324
      mainLayout->add(mainGroupBox);
317
325
 
318
 
      QGridLayout* mgbLayout = new QGridLayout(mainGroupBox, 8, 3, 1);
 
326
      Q3GridLayout* mgbLayout = new Q3GridLayout(mainGroupBox, 8, 3, 1);
319
327
 
320
328
      int i=0;
321
329
 
322
330
      for (int c=0; c<2; c++) {
323
331
            for (int r=0; r<SS_NR_OF_CHANNELS/2; r++) {
324
 
                  QHBoxLayout* strip = new QHBoxLayout;//(mgbLayout, 5);
 
332
                  Q3HBoxLayout* strip = new Q3HBoxLayout;//(mgbLayout, 5);
325
333
                  mgbLayout->addLayout(strip, r, c);
326
334
 
327
335
                  QLabel* channelLabel = new QLabel(QString("Ch ") + QString::number(i + 1), mainGroupBox);
348
356
            }
349
357
 
350
358
      // Right bottom panel:
351
 
      QButtonGroup* rbPanel= new QButtonGroup(mainGroupBox, "right_bottom_panel");
 
359
      Q3ButtonGroup* rbPanel= new Q3ButtonGroup(mainGroupBox, "right_bottom_panel");
352
360
      mgbLayout->addMultiCellWidget(rbPanel, 1, 8, 3, 3, Qt::AlignCenter);
353
 
      QGridLayout* rbLayout = new QGridLayout(rbPanel, 6, 1, 8, 5);
 
361
      Q3GridLayout* rbLayout = new Q3GridLayout(rbPanel, 6, 1, 8, 5);
354
362
      openPluginsButton = new QPushButton("&Send Effects", rbPanel);
355
363
      QToolTip::add(openPluginsButton, "Configure LADSPA send effects");
356
364
      connect(openPluginsButton, SIGNAL(clicked()), SLOT(openPluginButtonClicked()));
504
512
                              QString filename = (const char*) (data+2);
505
513
                              sampleNameLineEdit[ch]->setText(filename.section('/',-1,-1));
506
514
                              if (SS_DEBUG_MIDI) {
507
 
                                    printf("SimpleSynthGui - sample %s loaded OK on channel: %d\n", filename.latin1(), ch);
 
515
                                    printf("SimpleSynthGui - sample %s loaded OK on channel: %d\n", filename.toLatin1(), ch);
508
516
                                    }
509
517
                              if (!onOff[ch]->isChecked()) {
510
518
                                    onOff[ch]->blockSignals(true);
592
600
                              QFile theFile(fileInfo.filePath());
593
601
 
594
602
                              // Write data
595
 
                              if (theFile.open(IO_WriteOnly)) {
 
603
                              if (theFile.open(QIODevice::WriteOnly)) {
596
604
                                    theFile.writeBlock((const char*)&initdata_len, sizeof(initdata_len)); // First write length
597
605
                                    if (theFile.writeBlock((const char*)init_data, initdata_len) == -1) {
598
606
                                          // Fatal error writing
599
 
                                          QMessageBox* msgBox = new QMessageBox("IO error", "Fatal error when writing to file. Setup not saved.", QMessageBox::Warning,
600
 
                                                QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this, "SimpleDrums error Dialog");
601
 
                                          msgBox->exec();
602
 
                                          delete msgBox;
 
607
                                          QMessageBox msgBox("IO error", "Fatal error when writing to file. Setup not saved.",
 
608
                                                 QMessageBox::Warning,
 
609
                                                QMessageBox::Ok,
 
610
                                                QMessageBox::NoButton,
 
611
                                                QMessageBox::NoButton,
 
612
                                                this);
 
613
                                          msgBox.exec();
603
614
                                          }
604
615
                                    theFile.close();
605
616
                                    }
606
617
                              else {
607
618
                                    // An error occured when opening
608
 
                                    QMessageBox* msgBox = new QMessageBox("IO error", "Error opening file. Setup was not saved.", QMessageBox::Warning,
609
 
                                          QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this, "SimpleDrums error Dialog");
610
 
                                    msgBox->exec();
611
 
                                    delete msgBox;
 
619
                                    QMessageBox msgBox("IO error", "Error opening file. Setup was not saved.", QMessageBox::Warning,
 
620
                                          QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this);
 
621
                                    msgBox.exec();
612
622
                                    }
613
623
 
614
624
                              break;
689
699
void SimpleSynthGui::loadSampleDialogue(int channel)
690
700
      {
691
701
      QString filename =
692
 
            QFileDialog::getOpenFileName(lastDir,
 
702
            Q3FileDialog::getOpenFileName(lastDir,
693
703
                                       QString("*.wav;*.WAV"),
694
704
                                       this,
695
705
                                       "Load sample dialog","Choose sample");
698
708
            lastDir = filename.left(filename.findRev("/"));
699
709
 
700
710
            if (SS_DEBUG)
701
 
                  printf("lastDir = %s\n", lastDir.latin1());
 
711
                  printf("lastDir = %s\n", lastDir.toLatin1());
702
712
 
703
713
            int l = filename.length() + 4;
704
714
            byte d[l];
706
716
            d[0] = SS_SYSEX_LOAD_SAMPLE;
707
717
            d[1] = (byte) channel;
708
718
            d[2] = (byte) filename.length();
709
 
            memcpy(d+3, filename.latin1(), filename.length()+1);
 
719
            memcpy(d+3, filename.toLatin1(), filename.length()+1);
710
720
            sendSysex(d, l);
711
721
            }
712
722
      }
743
753
      byte d[l];
744
754
      d[0] = SS_SYSEX_LOAD_SENDEFFECT;
745
755
      d[1] = (byte) fxid;
746
 
      memcpy (d+2, lib.latin1(), lib.length()+1);
747
 
      memcpy (d+3+lib.length(), label.latin1(), label.length()+1);
 
756
      memcpy (d+2, lib.toLatin1(), lib.length()+1);
 
757
      memcpy (d+3+lib.length(), label.toLatin1(), label.length()+1);
748
758
      sendSysex(d, l);
749
759
      }
750
760
 
815
825
      QString caption = "SimpleDrums ver";
816
826
      caption+= SS_VERSIONSTRING;
817
827
      QString text = caption + "\n\n(C) Copyright 2000-2005 Mathias Lundgren (lunar_shuttle@users.sf.net), Werner Schweer\nPublished under the GNU Public License";
818
 
      QMessageBox* msgBox = new QMessageBox(caption, text, QMessageBox::NoIcon,
819
 
            QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this, "SimpleDrums About Dialog");
820
 
      msgBox->exec();
821
 
      delete msgBox;
 
828
      QMessageBox msgBox(caption, text, QMessageBox::NoIcon,
 
829
            QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this);
 
830
      msgBox.exec();
822
831
      }
823
832
 
824
833
 
831
840
      {
832
841
      bool success = true;
833
842
      QString filename =
834
 
            QFileDialog::getOpenFileName(lastProjectDir,
 
843
            Q3FileDialog::getOpenFileName(lastProjectDir,
835
844
                                       QString("*.sds;*.SDS"),
836
845
                                       this,
837
846
                                       "Load setup dialog", "Choose SimpleDrums setup");
838
847
 
839
848
      if (filename != QString::null) {
840
849
            QFile theFile(filename);
841
 
            if (theFile.open(IO_ReadOnly)) {
 
850
            if (theFile.open(QIODevice::ReadOnly)) {
842
851
                  unsigned initdata_len = 0;
843
852
                  if (theFile.readBlock((char*)&initdata_len, sizeof(initdata_len)) == -1)
844
853
                     success = false;
848
857
                     success = false;
849
858
 
850
859
                  if (!success) {
851
 
                        QMessageBox* msgBox = new QMessageBox("IO error", "Error opening/reading from file. Setup not loaded.", QMessageBox::Warning,
852
 
                              QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this, "SimpleDrums error Dialog");
853
 
                        msgBox->exec();
854
 
                        delete msgBox;
 
860
                        QMessageBox msgBox("IO error", "Error opening/reading from file. Setup not loaded.", QMessageBox::Warning,
 
861
                              QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this);
 
862
                        msgBox.exec();
855
863
                        }
856
864
                  else {
857
865
                        sendSysex(init_data, initdata_len);
870
878
void SimpleSynthGui::saveSetup()
871
879
      {
872
880
      QString filename =
873
 
            QFileDialog::getSaveFileName(lastProjectDir,
 
881
            Q3FileDialog::getSaveFileName(lastProjectDir,
874
882
                                       QString("*.sds;*.SDS"),
875
883
                                       this,
876
884
                                       "Save setup dialog", "Save SimpleDrums setup");