| 1 | /* |
| 2 | * midisnoop - MIDI monitor and prober |
| 3 | * Copyright (C) 2012 Devin Anderson |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License as published by the Free |
| 7 | * Software Foundation; either version 2 of the License, or (at your option) |
| 8 | * any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program; if not, write to the Free Software Foundation, Inc., 675 Mass |
| 17 | * Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "configureview.h" |
| 21 | #include "util.h" |
| 22 | |
| 23 | ConfigureView::ConfigureView(QObject *parent): |
| 24 | DesignerView(":/midisnoop/configureview.ui", parent) |
| 25 | { |
| 26 | QWidget *rootWidget = getRootWidget(); |
| 27 | |
| 28 | driver = getChild<QComboBox>(rootWidget, "driver"); |
| 29 | connect(driver, SIGNAL(activated(int)), |
| 30 | SLOT(handleDriverActivation(int))); |
| 31 | |
| 32 | ignoreActiveSensingEvents = |
| 33 | getChild<QCheckBox>(rootWidget, "ignoreActiveSensingEvents"); |
| 34 | connect(ignoreActiveSensingEvents, SIGNAL(clicked(bool)), |
| 35 | SIGNAL(ignoreActiveSensingEventsChangeRequest(bool))); |
| 36 | |
| 37 | ignoreSystemExclusiveEvents = |
| 38 | getChild<QCheckBox>(rootWidget, "ignoreSystemExclusiveEvents"); |
| 39 | connect(ignoreSystemExclusiveEvents, SIGNAL(clicked(bool)), |
| 40 | SIGNAL(ignoreSystemExclusiveEventsChangeRequest(bool))); |
| 41 | |
| 42 | ignoreTimeEvents = getChild<QCheckBox>(rootWidget, "ignoreTimeEvents"); |
| 43 | connect(ignoreTimeEvents, SIGNAL(clicked(bool)), |
| 44 | SIGNAL(ignoreTimeEventsChangeRequest(bool))); |
| 45 | |
| 46 | inputPort = getChild<QComboBox>(rootWidget, "inputPort"); |
| 47 | connect(inputPort, SIGNAL(activated(int)), |
| 48 | SLOT(handleInputPortActivation(int))); |
| 49 | |
| 50 | outputPort = getChild<QComboBox>(rootWidget, "outputPort"); |
| 51 | connect(outputPort, SIGNAL(activated(int)), |
| 52 | SLOT(handleOutputPortActivation(int))); |
| 53 | |
| 54 | closeButton = getChild<QPushButton>(rootWidget, "closeButton"); |
| 55 | connect(closeButton, SIGNAL(clicked()), SIGNAL(closeRequest())); |
| 56 | } |
| 57 | |
| 58 | ConfigureView::~ConfigureView() |
| 59 | { |
| 60 | // Empty |
| 61 | } |
| 62 | |
| 63 | void |
| 64 | ConfigureView::addDriver(int index, const QString &name) |
| 65 | { |
| 66 | driver->insertItem(index + 1, name); |
| 67 | } |
| 68 | |
| 69 | void |
| 70 | ConfigureView::addInputPort(int index, const QString &name) |
| 71 | { |
| 72 | inputPort->insertItem(index + 1, name); |
| 73 | } |
| 74 | |
| 75 | void |
| 76 | ConfigureView::addOutputPort(int index, const QString &name) |
| 77 | { |
| 78 | outputPort->insertItem(index + 1, name); |
| 79 | } |
| 80 | |
| 81 | void |
| 82 | ConfigureView::handleDriverActivation(int index) |
| 83 | { |
| 84 | emit driverChangeRequest(index - 1); |
| 85 | } |
| 86 | |
| 87 | void |
| 88 | ConfigureView::handleInputPortActivation(int index) |
| 89 | { |
| 90 | emit inputPortChangeRequest(index - 1); |
| 91 | } |
| 92 | |
| 93 | void |
| 94 | ConfigureView::handleOutputPortActivation(int index) |
| 95 | { |
| 96 | emit outputPortChangeRequest(index - 1); |
| 97 | } |
| 98 | |
| 99 | void |
| 100 | ConfigureView::removeInputPort(int index) |
| 101 | { |
| 102 | inputPort->removeItem(index + 1); |
| 103 | } |
| 104 | |
| 105 | void |
| 106 | ConfigureView::removeOutputPort(int index) |
| 107 | { |
| 108 | outputPort->removeItem(index + 1); |
| 109 | } |
| 110 | |
| 111 | void |
| 112 | ConfigureView::setDriver(int index) |
| 113 | { |
| 114 | driver->setCurrentIndex(index + 1); |
| 115 | } |
| 116 | |
| 117 | void |
| 118 | ConfigureView::setIgnoreActiveSensingEvents(bool ignore) |
| 119 | { |
| 120 | ignoreActiveSensingEvents->setChecked(ignore); |
| 121 | } |
| 122 | |
| 123 | void |
| 124 | ConfigureView::setIgnoreSystemExclusiveEvents(bool ignore) |
| 125 | { |
| 126 | ignoreSystemExclusiveEvents->setChecked(ignore); |
| 127 | } |
| 128 | |
| 129 | void |
| 130 | ConfigureView::setIgnoreTimeEvents(bool ignore) |
| 131 | { |
| 132 | ignoreTimeEvents->setChecked(ignore); |
| 133 | } |
| 134 | |
| 135 | void |
| 136 | ConfigureView::setInputPort(int index) |
| 137 | { |
| 138 | inputPort->setCurrentIndex(index + 1); |
| 139 | } |
| 140 | |
| 141 | void |
| 142 | ConfigureView::setOutputPort(int index) |
| 143 | { |
| 144 | outputPort->setCurrentIndex(index + 1); |
| 145 | } |