1 /*************************************************************************** 2 ** ** 3 ** Polyphone, a soundfont editor ** 4 ** Copyright (C) 2013-2020 Davy Triponney ** 5 ** ** 6 ** This program is free software: you can redistribute it and/or modify ** 7 ** it under the terms of the GNU General Public License as published by ** 8 ** the Free Software Foundation, either version 3 of the License, or ** 9 ** (at your option) any later version. ** 10 ** ** 11 ** This program is distributed in the hope that it will be useful, ** 12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 14 ** GNU General Public License for more details. ** 15 ** ** 16 ** You should have received a copy of the GNU General Public License ** 17 ** along with this program. If not, see http://www.gnu.org/licenses/. ** 18 ** ** 19 **************************************************************************** 20 ** Author: Davy Triponney ** 21 ** Website/Contact: https://www.polyphone-soundfonts.com ** 22 ** Date: 01.01.2013 ** 23 ***************************************************************************/ 24 25 #include "tooldefaultmod_gui.h" 26 #include "ui_tooldefaultmod_gui.h" 27 #include "tooldefaultmod_parameters.h" 28 #include "modulatorcell.h" ModulatorComboDest(QWidget * parent)29 30 ToolDefaultMod_gui::ToolDefaultMod_gui(QWidget *parent) : 31 AbstractToolGui(parent), 32 ui(new Ui::ToolDefaultMod_gui) 33 { 34 ui->setupUi(this); 35 } 36 37 ToolDefaultMod_gui::~ToolDefaultMod_gui() 38 { 39 delete ui; 40 } 41 42 void ToolDefaultMod_gui::updateInterface(AbstractToolParameters * parameters, IdList ids) 43 { 44 // The interface doesn't depend on the parameters or ids 45 Q_UNUSED(parameters) 46 Q_UNUSED(ids) 47 48 // Fill the list with all default modulators 49 ui->listWidget->clear(); 50 quint16 count = ModulatorData::defaultModulatorNumber(); 51 ModulatorData modData; 52 for (quint16 i = 0; i < count; i++) 53 { 54 modData.loadDefaultModulator(i); 55 modData.index = i; 56 57 // Add a new cell 58 ModulatorCell * cell = new ModulatorCell(modData); 59 QListWidgetItem * item = new QListWidgetItem(); 60 item->setSizeHint(cell->size()); 61 ui->listWidget->addItem(item); 62 ui->listWidget->setItemWidget(item, cell); 63 } 64 } 65 66 void ToolDefaultMod_gui::saveParameters(AbstractToolParameters * parameters) 67 { 68 ToolDefaultMod_parameters * params = dynamic_cast<ToolDefaultMod_parameters *>(parameters); 69 70 // Get the selected modulators 71 QList<ModulatorData> modData = ui->listWidget->getSelectedModulators(); 72 73 // Possibly set the amount of all modulators to 0 74 if (_isActionDisable) 75 for (int i = 0; i < modData.count(); i++) 76 modData[i].amount = 0; 77 78 // Store the result 79 params->setModulators(modData); 80 } 81 82 void ToolDefaultMod_gui::on_pushCancel_clicked() 83 { 84 emit(canceled()); 85 } 86 87 void ToolDefaultMod_gui::on_pushOverride_clicked() 88 { 89 _isActionDisable = false; 90 emit(validated()); 91 } 92 93 void ToolDefaultMod_gui::on_pushDisable_clicked() 94 { 95 _isActionDisable = true; 96 emit(validated()); 97 } 98 99 void ToolDefaultMod_gui::on_listWidget_itemSelectionChanged() 100 { 101 ui->pushDisable->setEnabled(!ui->listWidget->selectedItems().empty()); initialize(quint16 index)102 ui->pushOverride->setEnabled(!ui->listWidget->selectedItems().empty()); 103 } 104