drumstick  2.7.2
configurationdialogs.cpp
Go to the documentation of this file.
1 /*
2  Drumstick MIDI Sequencer C++ library
3  Copyright (C) 2006-2022, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include <QMetaMethod>
20 #include "fluidsettingsdialog.h"
21 #include "networksettingsdialog.h"
24 #if defined(Q_OS_LINUX)
25 #include "sonivoxsettingsdialog.h"
26 #endif
27 #if defined(Q_OS_MACOS)
28 #include "macsynthsettingsdialog.h"
29 #endif
30 
41 namespace drumstick { namespace widgets {
42 
48 bool inputDriverIsConfigurable(const QString driver)
49 {
50  // internal configuration dialogs:
51  if (driver == "Network") {
52  return true;
53  }
54  // external configuration dialogs (residing on plugins):
56  auto obj = man.inputBackendByName(driver);
57  if (obj == nullptr) {
58  return false;
59  }
60  auto metaObj = obj->metaObject();
61  if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
62  (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
63  auto configurable = obj->property("isconfigurable");
64  if (configurable.isValid()) {
65  return configurable.toBool();
66  }
67  }
68  return false;
69 }
70 
76 bool outputDriverIsConfigurable(const QString driver)
77 {
78  // internal configuration dialogs
79  if ((driver == "Network")
80 #if defined(Q_OS_LINUX)
81  || (driver == "SonivoxEAS")
82 #endif
83 #if defined(Q_OS_MACOS)
84  || (driver == "DLS Synth")
85 #endif
86  || (driver == "FluidSynth")) {
87  return true;
88  }
89  // external configuration dialogs (residing on plugins)
91  auto obj = man.outputBackendByName(driver);
92  if (obj == nullptr) {
93  return false;
94  }
95  auto metaObj = obj->metaObject();
96  if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
97  (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
98  auto configurable = obj->property("isconfigurable");
99  if (configurable.isValid()) {
100  return configurable.toBool();
101  }
102  }
103  return false;
104 }
105 
115 bool configureInputDriver(const QString driver, QWidget* parent)
116 {
117  // internal configuration dialogs
118  if (driver == "Network") {
119  NetworkSettingsDialog dlg(true, parent);
120  return (dlg.exec() == QDialog::Accepted);
121  }
122  // external configuration dialogs (residing on plugins):
124  auto obj = man.inputBackendByName(driver);
125  if (obj == nullptr) {
126  return false;
127  }
128  auto metaObj = obj->metaObject();
129  if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
130  (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
131  auto configurable = obj->property("isconfigurable");
132  if (configurable.isValid() && configurable.toBool()) {
133  bool ret;
134  QMetaObject::invokeMethod(obj, "configure", Q_RETURN_ARG(bool, ret), Q_ARG(QWidget*, parent));
135  return ret;
136  }
137  }
138  return false;
139 }
140 
151 bool configureOutputDriver(const QString driver, QWidget* parent)
152 {
153  // internal configuration dialogs
154  if (driver == "Network") {
155  NetworkSettingsDialog dlg(false, parent);
156  return (dlg.exec() == QDialog::Accepted);
157  } else if (driver == "FluidSynth") {
158  FluidSettingsDialog dlg(parent);
159  return (dlg.exec() == QDialog::Accepted);
160 #if defined(Q_OS_LINUX)
161  } else if (driver == "SonivoxEAS") {
162  SonivoxSettingsDialog dlg(parent);
163  return (dlg.exec() == QDialog::Accepted);
164 #endif
165 #if defined(Q_OS_MACOS)
166  } else if (driver == "DLS Synth") {
167  MacSynthSettingsDialog dlg(parent);
168  return (dlg.exec() == QDialog::Accepted);
169 #endif
170  }
171  // external configuration dialogs (residing on plugins):
173  auto obj = man.outputBackendByName(driver);
174  if (obj == nullptr) {
175  return false;
176  }
177  auto metaObj = obj->metaObject();
178  if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
179  (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
180  auto configurable = obj->property("isconfigurable");
181  if (configurable.isValid() && configurable.toBool()) {
182  bool ret;
183  QMetaObject::invokeMethod(obj, "configure", Q_RETURN_ARG(bool, ret), Q_ARG(QWidget*, parent));
184  return ret;
185  }
186  }
187  return false;
188 }
189 
200 void changeSoundFont(const QString driver, const QString fileName, QWidget* parent)
201 {
202  if (driver == "FluidSynth") {
203  FluidSettingsDialog dlg(parent);
204  dlg.changeSoundFont(fileName);
205 #if defined(Q_OS_MACOS)
206  } else if (driver == "DLS Synth") {
207  MacSynthSettingsDialog dlg(parent);
208  dlg.changeSoundFont(fileName);
209 #endif
210  }
211 }
212 
217 QString libraryVersion()
218 {
219  return QStringLiteral(QT_STRINGIFY(VERSION));
220 }
221 
222 } // namespace widgets
223 } // namespace drumstick
224 
bool DRUMSTICK_EXPORT configureInputDriver(const QString driver, QWidget *parent=nullptr)
Input Driver configuration dialog Some RT input drivers can be configured.
bool DRUMSTICK_EXPORT configureOutputDriver(const QString driver, QWidget *parent=nullptr)
Output Driver configuration dialog Some RT output drivers can be configured.
The BackendManager class manages lists of dynamic and static backends for applications based on drums...
void DRUMSTICK_EXPORT changeSoundFont(const QString driver, const QString fileName, QWidget *parent=nullptr)
Changes the sound font configuration Some RT output drivers accept soundfonts.
BackendManager class declaration.
Drumstick common.
Definition: alsaclient.cpp:68
Definition of the Sonivox Synth configuration dialog.
Functions providing configuration dialogs.
Declaration of the Fluidsynth configuration dialog.
QString DRUMSTICK_EXPORT libraryVersion()
libraryVersion returns the runtime library version as a QString
Declaration of the Mac Synth configuration dialog.
Declaration of the Network configuration dialog.
MIDIOutput * outputBackendByName(const QString name)
outputBackendByName
MIDIInput * inputBackendByName(const QString name)
inputBackendByName
bool DRUMSTICK_EXPORT outputDriverIsConfigurable(const QString driver)
outputDriverIsConfigurable
bool DRUMSTICK_EXPORT inputDriverIsConfigurable(const QString driver)
inputDriverIsConfigurable