drumstick 2.10.0
C++ MIDI libraries using Qt objects, idioms, and style.
configurationdialogs.cpp
Go to the documentation of this file.
1/*
2 Drumstick MIDI Sequencer C++ library
3 Copyright (C) 2006-2024, 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>
22
23#if defined(ENABLE_FLUIDSYNTH)
24#include "fluidsettingsdialog.h"
25#endif
26#if defined(ENABLE_NETWORK)
28#endif
29#if defined(ENABLE_SONIVOX)
31#endif
32#if defined(Q_OS_MACOS)
34#endif
35
40
45
46namespace drumstick { namespace widgets {
47
53bool inputDriverIsConfigurable(const QString driver)
54{
55 // internal configuration dialogs:
56 if (driver == "Network") {
57 return true;
58 }
59 // external configuration dialogs (residing on plugins):
61 auto obj = man.inputBackendByName(driver);
62 if (obj == nullptr) {
63 return false;
64 }
65 auto metaObj = obj->metaObject();
66 if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
67 (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
68 auto configurable = obj->property("isconfigurable");
69 if (configurable.isValid()) {
70 return configurable.toBool();
71 }
72 }
73 return false;
74}
75
81bool outputDriverIsConfigurable(const QString driver)
82{
83 // internal configuration dialogs
84 if ((driver == "Network")
85#if defined(ENABLE_SONIVOX)
86 || (driver == "SonivoxEAS")
87#endif
88#if defined(Q_OS_MACOS)
89 || (driver == "DLS Synth")
90#endif
91#if defined(ENABLE_FLUIDSYNTH)
92 || (driver == "FluidSynth")
93#endif
94 ) {
95 return true;
96 }
97 // external configuration dialogs (residing on plugins)
99 auto obj = man.outputBackendByName(driver);
100 if (obj == nullptr) {
101 return false;
102 }
103 auto metaObj = obj->metaObject();
104 if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
105 (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
106 auto configurable = obj->property("isconfigurable");
107 if (configurable.isValid()) {
108 return configurable.toBool();
109 }
110 }
111 return false;
112}
113
123bool configureInputDriver(const QString driver, QWidget* parent)
124{
125 // internal configuration dialogs
126#if defined(ENABLE_NETWORK)
127 if (driver == "Network") {
128 NetworkSettingsDialog dlg(true, parent);
129 return (dlg.exec() == QDialog::Accepted);
130 }
131#endif
132 // external configuration dialogs (residing on plugins):
134 auto obj = man.inputBackendByName(driver);
135 if (obj == nullptr) {
136 return false;
137 }
138 auto metaObj = obj->metaObject();
139 if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
140 (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
141 auto configurable = obj->property("isconfigurable");
142 if (configurable.isValid() && configurable.toBool()) {
143 bool ret{false};
144 QMetaObject::invokeMethod(obj, "configure", Q_RETURN_ARG(bool, ret), Q_ARG(QWidget*, parent));
145 return ret;
146 }
147 }
148 return false;
149}
150
161bool configureOutputDriver(const QString driver, QWidget* parent)
162{
163 // internal configuration dialogs
164#if defined(ENABLE_NETWORK)
165 if (driver == "Network") {
166 NetworkSettingsDialog dlg(false, parent);
167 return (dlg.exec() == QDialog::Accepted);
168 }
169#endif
170#if defined(ENABLE_FLUIDSYNTH)
171 if (driver == "FluidSynth") {
172 FluidSettingsDialog dlg(parent);
173 return (dlg.exec() == QDialog::Accepted);
174 }
175#endif
176#if defined(ENABLE_SONIVOX)
177 if (driver == "SonivoxEAS") {
178 SonivoxSettingsDialog dlg(parent);
179 return (dlg.exec() == QDialog::Accepted);
180 }
181#endif
182#if defined(Q_OS_MACOS)
183 if (driver == "DLS Synth") {
184 MacSynthSettingsDialog dlg(parent);
185 return (dlg.exec() == QDialog::Accepted);
186 }
187#endif
188 // external configuration dialogs (residing on plugins):
190 auto obj = man.outputBackendByName(driver);
191 if (obj == nullptr) {
192 return false;
193 }
194 auto metaObj = obj->metaObject();
195 if ((metaObj->indexOfProperty("isconfigurable") != -1) &&
196 (metaObj->indexOfMethod("configure(QWidget*)") != -1)) {
197 auto configurable = obj->property("isconfigurable");
198 if (configurable.isValid() && configurable.toBool()) {
199 bool ret{true};
200 QMetaObject::invokeMethod(obj, "configure", Q_RETURN_ARG(bool, ret), Q_ARG(QWidget*, parent));
201 return ret;
202 }
203 }
204 return false;
205}
206
217void changeSoundFont(const QString driver, const QString fileName, QWidget* parent)
218{
219#if defined(ENABLE_FLUIDSYNTH)
220 if (driver == "FluidSynth") {
221 FluidSettingsDialog dlg(parent);
222 dlg.changeSoundFont(fileName);
223 }
224#endif
225#if defined(ENABLE_SONIVOX)
226 if (driver == "SonivoxEAS") {
227 SonivoxSettingsDialog dlg(parent);
228 dlg.changeSoundFont(fileName);
229 }
230#endif
231#if defined(Q_OS_MACOS)
232 if (driver == "DLS Synth") {
233 MacSynthSettingsDialog dlg(parent);
234 dlg.changeSoundFont(fileName);
235 }
236#endif
237}
238
244{
245 return QStringLiteral(QT_STRINGIFY(VERSION));
246}
247
248} // namespace widgets
249} // namespace drumstick
250
BackendManager class declaration.
The BackendManager class manages lists of dynamic and static backends for applications based on drums...
MIDIOutput * outputBackendByName(const QString name)
outputBackendByName
MIDIInput * inputBackendByName(const QString name)
inputBackendByName
Functions providing configuration dialogs.
Declaration of the Fluidsynth configuration dialog.
Declaration of the Mac Synth configuration dialog.
Drumstick Widgets library MIDI related widgets and functions.
bool DRUMSTICK_WIDGETS_EXPORT inputDriverIsConfigurable(const QString driver)
inputDriverIsConfigurable
QString DRUMSTICK_WIDGETS_EXPORT libraryVersion()
libraryVersion returns the runtime library version as a QString
bool DRUMSTICK_WIDGETS_EXPORT outputDriverIsConfigurable(const QString driver)
outputDriverIsConfigurable
bool DRUMSTICK_WIDGETS_EXPORT configureInputDriver(const QString driver, QWidget *parent=nullptr)
Input Driver configuration dialog Some RT input drivers can be configured.
void DRUMSTICK_WIDGETS_EXPORT changeSoundFont(const QString driver, const QString fileName, QWidget *parent=nullptr)
Changes the sound font configuration Some RT output drivers accept soundfonts.
bool DRUMSTICK_WIDGETS_EXPORT configureOutputDriver(const QString driver, QWidget *parent=nullptr)
Output Driver configuration dialog Some RT output drivers can be configured.
Drumstick common.
Declaration of the Network configuration dialog.
Definition of the Sonivox Synth configuration dialog.