Debian Codegraph @

src/midilearndialog.cpp

raw symbols SCIP
1 #include "midilearndialog.h"
2 #include "ui_midilearndialog.h"
3
4 #include <QDebug>
5
6 MidiLearnDialog::MidiLearnDialog(QWidget *parent) :
7 QDialog(parent),
8 ui(new Ui::MidiLearnDialog)
9 {
10 ui->setupUi(this);
11 m_widget = 0;
12 m_cc = -1; m_channel = -1;
13 }
14
15 MidiLearnDialog::~MidiLearnDialog()
16 {
17 delete ui;
18 }
19
20 void MidiLearnDialog::setCurrentWidget(QuteWidget *widget)
21 {
22 m_widget = widget;
23 if (widget) {
24 if (widget->acceptsMidi()) {
25 int cc = m_widget->property("QCS_midicc").toInt();
26 int channel = m_widget->property("QCS_midichan").toInt();
27 if (channel <= 0) {
28 ui->channelLabel->setText(QString::number(channel));
29 ui->ccLabel->setText(QString::number(cc));
30 } else {
31 ui->channelLabel->setText(tr("(None)"));
32 ui->ccLabel->setText(tr("(None)"));
33 }
34 } else {
35 ui->channelLabel->setText(tr("(No MIDI)"));
36 ui->ccLabel->setText(tr("(No MIDI)"));
37 }
38 //qDebug() << "MidiLearnDialog::setCurrentWidget";
39 } else {
40 ui->channelLabel->setText(tr("(None)"));
41 ui->ccLabel->setText(tr("(None)"));
42 }
43 }
44
45 //void MidiLearnDialog::closeEvent(QCloseEvent *event)
46 //{
47 // qDebug() << "MIDI learn closed";
48
49 //}
50
51 void MidiLearnDialog::setMidiController(int channel, int cc)
52 {
53 m_channel = channel; m_cc = cc;
54 ui->channelLabel->setText(QString::number(channel));
55 ui->ccLabel->setText(QString::number(cc));
56 }
57
58 void MidiLearnDialog::on_setButton_clicked()
59 {
60 if (m_cc<0 || m_channel<0 ) {
61 QMessageBox::warning(this, tr("Controller not set"), tr("MIDI controller is not selected!"));
62 return;
63 }
64 if (m_widget && m_widget->acceptsMidi()) {
65 m_widget->setProperty("QCS_midicc", m_cc);
66 m_widget->setProperty("QCS_midichan", m_channel);
67 m_widget->applyInternalProperties();
68 m_widget->markChanged();
69
70 m_widget->updateDialogWindow(m_cc,m_channel);
71 }
72 }
73
74 void MidiLearnDialog::on_cancelButton_clicked()
75 {
76 this->close();
77 }
78
79 void MidiLearnDialog::on_closeButton_clicked()
80 {
81 on_setButton_clicked();
82 this->close();
83 }