Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1765 lines
68KB

  1. /*
  2. * Carla settings code
  3. * Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or 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. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "carla_settings.hpp"
  18. //---------------------------------------------------------------------------------------------------------------------
  19. // Imports (Global)
  20. #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  21. # pragma GCC diagnostic push
  22. # pragma GCC diagnostic ignored "-Wconversion"
  23. # pragma GCC diagnostic ignored "-Weffc++"
  24. # pragma GCC diagnostic ignored "-Wsign-conversion"
  25. #endif
  26. // --------------------------------------------------------------------------------------------------------------------
  27. #include <QtCore/QStringList>
  28. #include <QtWidgets/QFileDialog>
  29. // --------------------------------------------------------------------------------------------------------------------
  30. #include "ui_carla_settings.hpp"
  31. #include "ui_carla_settings_driver.hpp"
  32. // --------------------------------------------------------------------------------------------------------------------
  33. #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  34. # pragma GCC diagnostic pop
  35. #endif
  36. //---------------------------------------------------------------------------------------------------------------------
  37. // Imports (Custom)
  38. #include "carla_host.hpp"
  39. #include "patchcanvas/theme.hpp"
  40. #include "CarlaHost.h"
  41. #include "CarlaMathUtils.hpp"
  42. // --------------------------------------------------------------------------------------------------------------------
  43. static const char* const AUTOMATIC_OPTION = "(Auto)";
  44. static const QList<uint> BUFFER_SIZE_LIST = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
  45. static const QList<double> SAMPLE_RATE_LIST = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000 };
  46. CARLA_BACKEND_USE_NAMESPACE;
  47. // --------------------------------------------------------------------------------------------------------------------
  48. // Driver Settings
  49. struct DriverSettingsW::PrivateData {
  50. Ui::DriverSettingsW ui;
  51. uint fDriverIndex;
  52. QString fDriverName;
  53. QStringList fDeviceNames;
  54. QList<uint> fBufferSizes;
  55. QList<double> fSampleRates;
  56. PrivateData(DriverSettingsW* const self, const uint driverIndex, const QString driverName)
  57. : ui(),
  58. fDriverIndex(driverIndex),
  59. fDriverName(driverName),
  60. fDeviceNames(),
  61. fBufferSizes(BUFFER_SIZE_LIST),
  62. fSampleRates(SAMPLE_RATE_LIST)
  63. {
  64. ui.setupUi(self);
  65. const char* const* const deviceNames = carla_get_engine_driver_device_names(driverIndex);
  66. CARLA_SAFE_ASSERT_RETURN(deviceNames != nullptr,);
  67. fillQStringListFromStringArray(fDeviceNames, deviceNames);
  68. }
  69. void loadSettings(DriverSettingsW* const self)
  70. {
  71. const QSafeSettings settings("falkTX", "Carla2");
  72. const QString prefix(QString("%1%2").arg(CARLA_KEY_ENGINE_DRIVER_PREFIX).arg(fDriverName));
  73. const QCarlaString audioDevice = settings.valueString(QString("%1/Device").arg(prefix), "");
  74. const uint audioBufferSize = settings.valueUInt(QString("%1/BufferSize").arg(prefix), CARLA_DEFAULT_AUDIO_BUFFER_SIZE);
  75. const uint audioSampleRate = settings.valueUInt(QString("%1/SampleRate").arg(prefix), CARLA_DEFAULT_AUDIO_SAMPLE_RATE);
  76. const bool audioTripleBuffer = settings.valueBool(QString("%1/TripleBuffer").arg(prefix), CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER);
  77. if (audioDevice.isNotEmpty() && fDeviceNames.contains(audioDevice))
  78. ui.cb_device->setCurrentIndex(fDeviceNames.indexOf(audioDevice));
  79. else
  80. ui.cb_device->setCurrentIndex(-1);
  81. // fill combo-boxes first
  82. self->slot_updateDeviceInfo();
  83. if (audioBufferSize != 0 && fBufferSizes.contains(audioBufferSize))
  84. ui.cb_buffersize->setCurrentIndex(fBufferSizes.indexOf(audioBufferSize));
  85. else if (fBufferSizes == BUFFER_SIZE_LIST)
  86. ui.cb_buffersize->setCurrentIndex(BUFFER_SIZE_LIST.indexOf(CARLA_DEFAULT_AUDIO_BUFFER_SIZE));
  87. else
  88. ui.cb_buffersize->setCurrentIndex(fBufferSizes.size()/2);
  89. if (audioSampleRate != 0 && fSampleRates.contains(audioSampleRate))
  90. ui.cb_samplerate->setCurrentIndex(getIndexOfQDoubleListValue(fSampleRates, audioSampleRate));
  91. else if (isQDoubleListEqual(fSampleRates, SAMPLE_RATE_LIST))
  92. ui.cb_samplerate->setCurrentIndex(getIndexOfQDoubleListValue(SAMPLE_RATE_LIST, CARLA_DEFAULT_AUDIO_SAMPLE_RATE));
  93. else
  94. ui.cb_samplerate->setCurrentIndex(fSampleRates.size()/2);
  95. ui.cb_triple_buffer->setChecked(audioTripleBuffer && ui.cb_triple_buffer->isEnabled());
  96. }
  97. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData)
  98. };
  99. DriverSettingsW::DriverSettingsW(QWidget* const parent, const uint driverIndex, const QString driverName)
  100. : QDialog(parent),
  101. self(new PrivateData(this, driverIndex, driverName))
  102. {
  103. // ----------------------------------------------------------------------------------------------------------------
  104. // Set-up GUI
  105. for (const auto& name : self->fDeviceNames)
  106. self->ui.cb_device->addItem(name);
  107. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  108. // ----------------------------------------------------------------------------------------------------------------
  109. // Load settings
  110. self->loadSettings(this);
  111. // ----------------------------------------------------------------------------------------------------------------
  112. // Set-up connections
  113. connect(this, SIGNAL(accepted()), SLOT(slot_saveSettings()));
  114. connect(self->ui.b_panel, SIGNAL(clicked()), SLOT(slot_showDevicePanel()));
  115. connect(self->ui.cb_device, SIGNAL(currentIndexChanged(int)), SLOT(slot_updateDeviceInfo()));
  116. }
  117. DriverSettingsW::~DriverSettingsW()
  118. {
  119. delete self;
  120. }
  121. // --------------------------------------------------------------------------------------------------------------------
  122. void DriverSettingsW::slot_saveSettings()
  123. {
  124. QSafeSettings settings("falkTX", "Carla2");
  125. QString bufferSize = self->ui.cb_buffersize->currentText();
  126. QString sampleRate = self->ui.cb_samplerate->currentText();
  127. if (bufferSize == AUTOMATIC_OPTION)
  128. bufferSize = "0";
  129. if (sampleRate == AUTOMATIC_OPTION)
  130. sampleRate = "0";
  131. const QString prefix(QString("%1%2").arg(CARLA_KEY_ENGINE_DRIVER_PREFIX).arg(self->fDriverName));
  132. settings.setValue(QString("%1/Device").arg(prefix), self->ui.cb_device->currentText());
  133. settings.setValue(QString("%1/BufferSize").arg(prefix), bufferSize);
  134. settings.setValue(QString("%1/SampleRate").arg(prefix), sampleRate);
  135. settings.setValue(QString("%1/TripleBuffer").arg(prefix), self->ui.cb_triple_buffer->isChecked());
  136. }
  137. void DriverSettingsW::slot_showDevicePanel()
  138. {
  139. carla_show_engine_driver_device_control_panel(self->fDriverIndex, self->ui.cb_device->currentText().toUtf8());
  140. }
  141. void DriverSettingsW::slot_updateDeviceInfo()
  142. {
  143. const QString deviceName = self->ui.cb_device->currentText();
  144. const QString oldBufferSize = self->ui.cb_buffersize->currentText();
  145. const QString oldSampleRate = self->ui.cb_samplerate->currentText();
  146. self->ui.cb_buffersize->clear();
  147. self->ui.cb_samplerate->clear();
  148. self->fBufferSizes.clear();
  149. self->fSampleRates.clear();
  150. const EngineDriverDeviceInfo* const driverDeviceInfo = carla_get_engine_driver_device_info(self->fDriverIndex, deviceName.toUtf8());
  151. CARLA_SAFE_ASSERT_RETURN(driverDeviceInfo != nullptr,);
  152. const uint driverDeviceHints = driverDeviceInfo->hints;
  153. fillQUIntListFromUIntArray(self->fBufferSizes, driverDeviceInfo->bufferSizes);
  154. fillQDoubleListFromDoubleArray(self->fSampleRates, driverDeviceInfo->sampleRates);
  155. if (driverDeviceHints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER)
  156. self->ui.cb_triple_buffer->setEnabled(true);
  157. else
  158. self->ui.cb_triple_buffer->setEnabled(false);
  159. if (driverDeviceHints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL)
  160. self->ui.b_panel->setEnabled(true);
  161. else
  162. self->ui.b_panel->setEnabled(false);
  163. if (self->fBufferSizes.size() > 0)
  164. {
  165. for (const uint bsize : self->fBufferSizes)
  166. {
  167. const QString sbsize(QString("%1").arg(bsize));
  168. self->ui.cb_buffersize->addItem(sbsize);
  169. if (oldBufferSize == sbsize)
  170. self->ui.cb_buffersize->setCurrentIndex(self->ui.cb_buffersize->count()-1);
  171. }
  172. }
  173. else
  174. {
  175. self->ui.cb_buffersize->addItem(AUTOMATIC_OPTION);
  176. self->ui.cb_buffersize->setCurrentIndex(0);
  177. }
  178. if (self->fSampleRates.size() > 0)
  179. {
  180. for (const double srate : self->fSampleRates)
  181. {
  182. const QString ssrate(QString("%1").arg(srate));
  183. self->ui.cb_samplerate->addItem(ssrate);
  184. if (oldSampleRate == ssrate)
  185. self->ui.cb_samplerate->setCurrentIndex(self->ui.cb_samplerate->count()-1);
  186. }
  187. }
  188. else
  189. {
  190. self->ui.cb_samplerate->addItem(AUTOMATIC_OPTION);
  191. self->ui.cb_samplerate->setCurrentIndex(0);
  192. }
  193. }
  194. // --------------------------------------------------------------------------------------------------------------------
  195. // Runtime Driver Settings
  196. struct RuntimeDriverSettingsW::PrivateData {
  197. Ui::DriverSettingsW ui;
  198. const CarlaHostHandle hostHandle;
  199. PrivateData(RuntimeDriverSettingsW* const self, const CarlaHostHandle h)
  200. : ui(),
  201. hostHandle(h)
  202. {
  203. ui.setupUi(self);
  204. }
  205. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData)
  206. };
  207. RuntimeDriverSettingsW::RuntimeDriverSettingsW(const CarlaHostHandle hostHandle, QWidget* const parent)
  208. : QDialog(parent),
  209. self(new PrivateData(this, hostHandle))
  210. {
  211. const CarlaRuntimeEngineDriverDeviceInfo* const driverDeviceInfo =
  212. carla_get_runtime_engine_driver_device_info(hostHandle);
  213. QList<uint> bufferSizes;
  214. fillQUIntListFromUIntArray(bufferSizes, driverDeviceInfo->bufferSizes);
  215. QList<double> sampleRates;
  216. fillQDoubleListFromDoubleArray(sampleRates, driverDeviceInfo->sampleRates);
  217. // ----------------------------------------------------------------------------------------------------------------
  218. // Set-up GUI
  219. self->ui.cb_device->clear();
  220. self->ui.cb_buffersize->clear();
  221. self->ui.cb_samplerate->clear();
  222. self->ui.cb_triple_buffer->hide();
  223. self->ui.ico_restart->hide();
  224. self->ui.label_restart->hide();
  225. self->ui.layout_triple_buffer->takeAt(2);
  226. self->ui.layout_triple_buffer->takeAt(1);
  227. self->ui.layout_triple_buffer->takeAt(0);
  228. self->ui.verticalLayout->removeItem(self->ui.layout_triple_buffer);
  229. self->ui.layout_restart->takeAt(3);
  230. self->ui.layout_restart->takeAt(2);
  231. self->ui.layout_restart->takeAt(1);
  232. self->ui.layout_restart->takeAt(0);
  233. self->ui.verticalLayout->removeItem(self->ui.layout_restart);
  234. adjustSize();
  235. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  236. // ----------------------------------------------------------------------------------------------------------------
  237. // Load runtime settings
  238. if (carla_is_engine_running(hostHandle))
  239. {
  240. self->ui.cb_device->addItem(driverDeviceInfo->name);
  241. self->ui.cb_device->setCurrentIndex(0);
  242. self->ui.cb_device->setEnabled(false);
  243. }
  244. else
  245. {
  246. self->ui.cb_device->addItem(driverDeviceInfo->name);
  247. self->ui.cb_device->setCurrentIndex(0);
  248. }
  249. if (bufferSizes.size() > 0)
  250. {
  251. for (const uint bsize : bufferSizes)
  252. {
  253. const QString sbsize(QString("%1").arg(bsize));
  254. self->ui.cb_buffersize->addItem(sbsize);
  255. if (driverDeviceInfo->bufferSize == bsize)
  256. self->ui.cb_buffersize->setCurrentIndex(self->ui.cb_buffersize->count()-1);
  257. }
  258. }
  259. else
  260. {
  261. self->ui.cb_buffersize->addItem(AUTOMATIC_OPTION);
  262. self->ui.cb_buffersize->setCurrentIndex(0);
  263. }
  264. if ((driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE) == 0x0)
  265. self->ui.cb_buffersize->setEnabled(false);
  266. if (sampleRates.size() > 0)
  267. {
  268. for (const double srate : sampleRates)
  269. {
  270. const QString ssrate(QString("%1").arg(srate));
  271. self->ui.cb_samplerate->addItem(ssrate);
  272. if (carla_isEqual(driverDeviceInfo->sampleRate, srate))
  273. self->ui.cb_samplerate->setCurrentIndex(self->ui.cb_samplerate->count()-1);
  274. }
  275. }
  276. else
  277. {
  278. self->ui.cb_samplerate->addItem(AUTOMATIC_OPTION);
  279. self->ui.cb_samplerate->setCurrentIndex(0);
  280. }
  281. if ((driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE) == 0x0)
  282. self->ui.cb_samplerate->setEnabled(false);
  283. if ((driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL) == 0x0)
  284. self->ui.b_panel->setEnabled(false);
  285. // ----------------------------------------------------------------------------------------------------------------
  286. // Set-up connections
  287. connect(self->ui.b_panel, SIGNAL(clicked()), SLOT(slot_showDevicePanel()));
  288. }
  289. RuntimeDriverSettingsW::~RuntimeDriverSettingsW()
  290. {
  291. delete self;
  292. }
  293. void RuntimeDriverSettingsW::getValues(QString& retAudioDevice, uint& retBufferSize, double& retSampleRate)
  294. {
  295. const QString bufferSize = self->ui.cb_buffersize->currentText();
  296. const QString sampleRate = self->ui.cb_samplerate->currentText();
  297. if (bufferSize == AUTOMATIC_OPTION)
  298. retBufferSize = 0;
  299. else
  300. retBufferSize = bufferSize.toUInt();
  301. if (sampleRate == AUTOMATIC_OPTION)
  302. retSampleRate = 0.0;
  303. else
  304. retSampleRate = sampleRate.toDouble();
  305. retAudioDevice = self->ui.cb_buffersize->currentText();
  306. }
  307. void RuntimeDriverSettingsW::slot_showDevicePanel()
  308. {
  309. carla_show_engine_device_control_panel(self->hostHandle);
  310. }
  311. // --------------------------------------------------------------------------------------------------------------------
  312. // Settings Dialog
  313. enum TabIndexes {
  314. TAB_INDEX_MAIN,
  315. TAB_INDEX_CANVAS,
  316. TAB_INDEX_ENGINE,
  317. TAB_INDEX_OSC,
  318. TAB_INDEX_FILEPATHS,
  319. TAB_INDEX_PLUGINPATHS,
  320. TAB_INDEX_WINE,
  321. TAB_INDEX_EXPERIMENTAL,
  322. TAB_INDEX_NONE,
  323. };
  324. enum FilePathIndexes {
  325. FILEPATH_INDEX_AUDIO,
  326. FILEPATH_INDEX_MIDI
  327. };
  328. enum PluginPathIndexes {
  329. PLUGINPATH_INDEX_LADSPA,
  330. PLUGINPATH_INDEX_DSSI,
  331. PLUGINPATH_INDEX_LV2,
  332. PLUGINPATH_INDEX_VST2,
  333. PLUGINPATH_INDEX_VST3,
  334. PLUGINPATH_INDEX_SF2,
  335. PLUGINPATH_INDEX_SFZ,
  336. PLUGINPATH_INDEX_JSFX
  337. };
  338. /*
  339. Single and Multiple client mode is only for JACK,
  340. but we still want to match QComboBox index to backend defines,
  341. so add +2 pos padding if driverName != "JACK".
  342. */
  343. #define PROCESS_MODE_NON_JACK_PADDING 2
  344. struct CarlaSettingsW::PrivateData {
  345. Ui::CarlaSettingsW ui;
  346. CarlaHost& host;
  347. PrivateData(CarlaSettingsW* const self, CarlaHost& h)
  348. : ui(),
  349. host(h)
  350. {
  351. ui.setupUi(self);
  352. }
  353. void loadSettings()
  354. {
  355. {
  356. const QSafeSettings settings;
  357. // --------------------------------------------------------------------------------------------------------
  358. // Main
  359. ui.ch_main_show_logs->setChecked(host.showLogs);
  360. ui.ch_engine_uis_always_on_top->setChecked(host.uisAlwaysOnTop);
  361. ui.le_main_proj_folder->setText(settings.valueString(CARLA_KEY_MAIN_PROJECT_FOLDER,
  362. CARLA_DEFAULT_MAIN_PROJECT_FOLDER));
  363. ui.ch_main_theme_pro->setChecked(settings.valueBool(CARLA_KEY_MAIN_USE_PRO_THEME,
  364. CARLA_DEFAULT_MAIN_USE_PRO_THEME) && ui.group_main_theme->isEnabled());
  365. ui.cb_main_theme_color->setCurrentIndex(ui.cb_main_theme_color->findText(settings.valueString(CARLA_KEY_MAIN_PRO_THEME_COLOR,
  366. CARLA_DEFAULT_MAIN_PRO_THEME_COLOR)));
  367. ui.sb_main_refresh_interval->setValue(settings.valueIntPositive(CARLA_KEY_MAIN_REFRESH_INTERVAL,
  368. CARLA_DEFAULT_MAIN_REFRESH_INTERVAL));
  369. ui.ch_main_confirm_exit->setChecked(settings.valueBool(CARLA_KEY_MAIN_CONFIRM_EXIT,
  370. CARLA_DEFAULT_MAIN_CONFIRM_EXIT));
  371. // --------------------------------------------------------------------------------------------------------
  372. // Canvas
  373. ui.cb_canvas_theme->setCurrentIndex(ui.cb_canvas_theme->findText(settings.valueString(CARLA_KEY_CANVAS_THEME,
  374. CARLA_DEFAULT_CANVAS_THEME)));
  375. ui.cb_canvas_size->setCurrentIndex(ui.cb_canvas_size->findText(settings.valueString(CARLA_KEY_CANVAS_SIZE,
  376. CARLA_DEFAULT_CANVAS_SIZE)));
  377. ui.cb_canvas_bezier_lines->setChecked(settings.valueBool(CARLA_KEY_CANVAS_USE_BEZIER_LINES,
  378. CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES));
  379. ui.cb_canvas_hide_groups->setChecked(settings.valueBool(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS,
  380. CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS));
  381. ui.cb_canvas_auto_select->setChecked(settings.valueBool(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS,
  382. CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS));
  383. ui.cb_canvas_eyecandy->setChecked(settings.valueBool(CARLA_KEY_CANVAS_EYE_CANDY,
  384. CARLA_DEFAULT_CANVAS_EYE_CANDY));
  385. ui.cb_canvas_fancy_eyecandy->setChecked(settings.valueBool(CARLA_KEY_CANVAS_FANCY_EYE_CANDY,
  386. CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY));
  387. ui.cb_canvas_use_opengl->setChecked(settings.valueBool(CARLA_KEY_CANVAS_USE_OPENGL,
  388. CARLA_DEFAULT_CANVAS_USE_OPENGL) && ui.cb_canvas_use_opengl->isEnabled());
  389. ui.cb_canvas_render_aa->setCheckState(settings.valueCheckState(CARLA_KEY_CANVAS_ANTIALIASING,
  390. CARLA_DEFAULT_CANVAS_ANTIALIASING));
  391. ui.cb_canvas_render_hq_aa->setChecked(settings.valueBool(CARLA_KEY_CANVAS_HQ_ANTIALIASING,
  392. CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING) && ui.cb_canvas_render_hq_aa->isEnabled());
  393. ui.cb_canvas_full_repaints->setChecked(settings.valueBool(CARLA_KEY_CANVAS_FULL_REPAINTS,
  394. CARLA_DEFAULT_CANVAS_FULL_REPAINTS));
  395. ui.cb_canvas_inline_displays->setChecked(settings.valueBool(CARLA_KEY_CANVAS_INLINE_DISPLAYS,
  396. CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS));
  397. }
  398. // ------------------------------------------------------------------------------------------------------------
  399. const QSafeSettings settings("falkTX", "Carla2");
  400. // ------------------------------------------------------------------------------------------------------------
  401. // Main
  402. ui.ch_main_experimental->setChecked(host.experimental);
  403. if (! host.experimental)
  404. {
  405. ui.lw_page->hideRow(TAB_INDEX_EXPERIMENTAL);
  406. ui.lw_page->hideRow(TAB_INDEX_WINE);
  407. }
  408. else if (! host.showWineBridges)
  409. {
  410. ui.lw_page->hideRow(TAB_INDEX_WINE);
  411. }
  412. // ------------------------------------------------------------------------------------------------------------
  413. // Engine
  414. QString audioDriver;
  415. if (host.isPlugin)
  416. {
  417. audioDriver = "Plugin";
  418. ui.cb_engine_audio_driver->setCurrentIndex(0);
  419. }
  420. else if (host.audioDriverForced.isNotEmpty())
  421. {
  422. audioDriver = host.audioDriverForced;
  423. ui.cb_engine_audio_driver->setCurrentIndex(0);
  424. }
  425. else
  426. {
  427. audioDriver = settings.valueString(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER);
  428. bool found = false;
  429. for (int i=0; i < ui.cb_engine_audio_driver->count(); ++i)
  430. {
  431. if (ui.cb_engine_audio_driver->itemText(i) == audioDriver)
  432. {
  433. found = true;
  434. ui.cb_engine_audio_driver->setCurrentIndex(i);
  435. break;
  436. }
  437. }
  438. if (! found)
  439. ui.cb_engine_audio_driver->setCurrentIndex(-1);
  440. }
  441. if (audioDriver == "JACK")
  442. ui.sw_engine_process_mode->setCurrentIndex(0);
  443. else
  444. ui.sw_engine_process_mode->setCurrentIndex(1);
  445. ui.tb_engine_driver_config->setEnabled(host.audioDriverForced.isNotEmpty() && ! host.isPlugin);
  446. ui.cb_engine_process_mode_jack->setCurrentIndex(host.nextProcessMode);
  447. if (host.nextProcessMode >= PROCESS_MODE_NON_JACK_PADDING)
  448. ui.cb_engine_process_mode_other->setCurrentIndex(host.nextProcessMode-PROCESS_MODE_NON_JACK_PADDING);
  449. else
  450. ui.cb_engine_process_mode_other->setCurrentIndex(0);
  451. ui.sb_engine_max_params->setValue(static_cast<int>(host.maxParameters));
  452. ui.cb_engine_reset_xruns->setChecked(host.resetXruns);
  453. ui.ch_engine_manage_uis->setChecked(host.manageUIs);
  454. ui.ch_engine_prefer_ui_bridges->setChecked(host.preferUIBridges);
  455. ui.sb_engine_ui_bridges_timeout->setValue(host.uiBridgesTimeout);
  456. ui.ch_engine_force_stereo->setChecked(host.forceStereo || ! ui.ch_engine_force_stereo->isEnabled());
  457. ui.ch_engine_prefer_plugin_bridges->setChecked(host.preferPluginBridges);
  458. ui.ch_exp_export_lv2->setChecked(host.exportLV2);
  459. ui.cb_exp_plugin_bridges->setChecked(host.showPluginBridges);
  460. ui.ch_exp_wine_bridges->setChecked(host.showWineBridges);
  461. // ------------------------------------------------------------------------------------------------------------
  462. // OSC
  463. ui.ch_osc_enable->setChecked(settings.valueBool(CARLA_KEY_OSC_ENABLED,
  464. CARLA_DEFAULT_OSC_ENABLED));
  465. ui.group_osc_tcp_port->setChecked(settings.valueBool(CARLA_KEY_OSC_TCP_PORT_ENABLED,
  466. CARLA_DEFAULT_OSC_TCP_PORT_ENABLED));
  467. ui.group_osc_udp_port->setChecked(settings.valueBool(CARLA_KEY_OSC_UDP_PORT_ENABLED,
  468. CARLA_DEFAULT_OSC_UDP_PORT_ENABLED));
  469. ui.sb_osc_tcp_port_number->setValue(settings.valueIntPositive(CARLA_KEY_OSC_TCP_PORT_NUMBER,
  470. CARLA_DEFAULT_OSC_TCP_PORT_NUMBER));
  471. ui.sb_osc_udp_port_number->setValue(settings.valueIntPositive(CARLA_KEY_OSC_UDP_PORT_NUMBER,
  472. CARLA_DEFAULT_OSC_UDP_PORT_NUMBER));
  473. if (settings.valueBool(CARLA_KEY_OSC_TCP_PORT_RANDOM, CARLA_DEFAULT_OSC_TCP_PORT_RANDOM))
  474. {
  475. ui.rb_osc_tcp_port_specific->setChecked(false);
  476. ui.rb_osc_tcp_port_random->setChecked(true);
  477. }
  478. else
  479. {
  480. ui.rb_osc_tcp_port_random->setChecked(false);
  481. ui.rb_osc_tcp_port_specific->setChecked(true);
  482. }
  483. if (settings.valueBool(CARLA_KEY_OSC_UDP_PORT_RANDOM, CARLA_DEFAULT_OSC_UDP_PORT_RANDOM))
  484. {
  485. ui.rb_osc_udp_port_specific->setChecked(false);
  486. ui.rb_osc_udp_port_random->setChecked(true);
  487. }
  488. else
  489. {
  490. ui.rb_osc_udp_port_random->setChecked(false);
  491. ui.rb_osc_udp_port_specific->setChecked(true);
  492. }
  493. // ------------------------------------------------------------------------------------------------------------
  494. // File Paths
  495. QStringList audioPaths = settings.valueStringList(CARLA_KEY_PATHS_AUDIO, CARLA_DEFAULT_FILE_PATH_AUDIO);
  496. QStringList midiPaths = settings.valueStringList(CARLA_KEY_PATHS_MIDI, CARLA_DEFAULT_FILE_PATH_MIDI);
  497. audioPaths.sort();
  498. midiPaths.sort();
  499. for (const QString& audioPath : audioPaths)
  500. {
  501. if (audioPath.isEmpty()) continue;
  502. ui.lw_files_audio->addItem(audioPath);
  503. }
  504. for (const QString& midiPath : midiPaths)
  505. {
  506. if (midiPath.isEmpty()) continue;
  507. ui.lw_files_midi->addItem(midiPath);
  508. }
  509. // ------------------------------------------------------------------------------------------------------------
  510. // Plugin Paths
  511. QStringList ladspas = settings.valueStringList(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH);
  512. QStringList dssis = settings.valueStringList(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH);
  513. QStringList lv2s = settings.valueStringList(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH);
  514. QStringList vst2s = settings.valueStringList(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH);
  515. QStringList vst3s = settings.valueStringList(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH);
  516. QStringList sf2s = settings.valueStringList(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH);
  517. QStringList sfzs = settings.valueStringList(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH);
  518. QStringList jsfxs = settings.valueStringList(CARLA_KEY_PATHS_JSFX, CARLA_DEFAULT_JSFX_PATH);
  519. ladspas.sort();
  520. dssis.sort();
  521. lv2s.sort();
  522. vst2s.sort();
  523. vst3s.sort();
  524. sf2s.sort();
  525. sfzs.sort();
  526. jsfxs.sort();
  527. for (const QString& ladspa : ladspas)
  528. {
  529. if (ladspa.isEmpty()) continue;
  530. ui.lw_ladspa->addItem(ladspa);
  531. }
  532. for (const QString& dssi : dssis)
  533. {
  534. if (dssi.isEmpty()) continue;
  535. ui.lw_dssi->addItem(dssi);
  536. }
  537. for (const QString& lv2 : lv2s)
  538. {
  539. if (lv2.isEmpty()) continue;
  540. ui.lw_lv2->addItem(lv2);
  541. }
  542. for (const QString& vst2 : vst2s)
  543. {
  544. if (vst2.isEmpty()) continue;
  545. ui.lw_vst->addItem(vst2);
  546. }
  547. for (const QString& vst3 : vst3s)
  548. {
  549. if (vst3.isEmpty()) continue;
  550. ui.lw_vst3->addItem(vst3);
  551. }
  552. for (const QString& sf2 : sf2s)
  553. {
  554. if (sf2.isEmpty()) continue;
  555. ui.lw_sf2->addItem(sf2);
  556. }
  557. for (const QString& sfz : sfzs)
  558. {
  559. if (sfz.isEmpty()) continue;
  560. ui.lw_sfz->addItem(sfz);
  561. }
  562. for (const QString& jsfx : jsfxs)
  563. {
  564. if (jsfx.isEmpty()) continue;
  565. ui.lw_jsfx->addItem(jsfx);
  566. }
  567. // ------------------------------------------------------------------------------------------------------------
  568. // Wine
  569. ui.le_wine_exec->setText(settings.valueString(CARLA_KEY_WINE_EXECUTABLE,
  570. CARLA_DEFAULT_WINE_EXECUTABLE));
  571. ui.cb_wine_prefix_detect->setChecked(settings.valueBool(CARLA_KEY_WINE_AUTO_PREFIX,
  572. CARLA_DEFAULT_WINE_AUTO_PREFIX));
  573. ui.le_wine_prefix_fallback->setText(settings.valueString(CARLA_KEY_WINE_FALLBACK_PREFIX,
  574. CARLA_DEFAULT_WINE_FALLBACK_PREFIX));
  575. ui.group_wine_realtime->setChecked(settings.valueBool(CARLA_KEY_WINE_RT_PRIO_ENABLED,
  576. CARLA_DEFAULT_WINE_RT_PRIO_ENABLED));
  577. ui.sb_wine_base_prio->setValue(settings.valueIntPositive(CARLA_KEY_WINE_BASE_RT_PRIO,
  578. CARLA_DEFAULT_WINE_BASE_RT_PRIO));
  579. ui.sb_wine_server_prio->setValue(settings.valueIntPositive(CARLA_KEY_WINE_SERVER_RT_PRIO,
  580. CARLA_DEFAULT_WINE_SERVER_RT_PRIO));
  581. // ------------------------------------------------------------------------------------------------------------
  582. // Experimental
  583. ui.ch_exp_jack_apps->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_JACK_APPS,
  584. CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS));
  585. ui.ch_exp_export_lv2->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2,
  586. CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT));
  587. ui.ch_exp_load_lib_global->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL,
  588. CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL));
  589. ui.ch_exp_prevent_bad_behaviour->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  590. CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR));
  591. }
  592. void saveSettings()
  593. {
  594. {
  595. QSafeSettings settings;
  596. host.experimental = ui.ch_main_experimental->isChecked();
  597. if (! host.experimental)
  598. resetExperimentalSettings();
  599. // --------------------------------------------------------------------------------------------------------
  600. // Main
  601. settings.setValue(CARLA_KEY_MAIN_PROJECT_FOLDER, ui.le_main_proj_folder->text());
  602. settings.setValue(CARLA_KEY_MAIN_CONFIRM_EXIT, ui.ch_main_confirm_exit->isChecked());
  603. settings.setValue(CARLA_KEY_MAIN_USE_PRO_THEME, ui.ch_main_theme_pro->isChecked());
  604. settings.setValue(CARLA_KEY_MAIN_PRO_THEME_COLOR, ui.cb_main_theme_color->currentText());
  605. settings.setValue(CARLA_KEY_MAIN_REFRESH_INTERVAL, ui.sb_main_refresh_interval->value());
  606. // --------------------------------------------------------------------------------------------------------
  607. // Canvas
  608. settings.setValue(CARLA_KEY_CANVAS_THEME, ui.cb_canvas_theme->currentText());
  609. settings.setValue(CARLA_KEY_CANVAS_SIZE, ui.cb_canvas_size->currentText());
  610. settings.setValue(CARLA_KEY_CANVAS_USE_BEZIER_LINES, ui.cb_canvas_bezier_lines->isChecked());
  611. settings.setValue(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, ui.cb_canvas_hide_groups->isChecked());
  612. settings.setValue(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, ui.cb_canvas_auto_select->isChecked());
  613. settings.setValue(CARLA_KEY_CANVAS_EYE_CANDY, ui.cb_canvas_eyecandy->isChecked());
  614. settings.setValue(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, ui.cb_canvas_fancy_eyecandy->isChecked());
  615. settings.setValue(CARLA_KEY_CANVAS_USE_OPENGL, ui.cb_canvas_use_opengl->isChecked());
  616. settings.setValue(CARLA_KEY_CANVAS_HQ_ANTIALIASING, ui.cb_canvas_render_hq_aa->isChecked());
  617. settings.setValue(CARLA_KEY_CANVAS_ANTIALIASING, ui.cb_canvas_render_aa->checkState()); // 0, 1, 2 match their enum variants
  618. settings.setValue(CARLA_KEY_CANVAS_FULL_REPAINTS, ui.cb_canvas_full_repaints->isChecked());
  619. settings.setValue(CARLA_KEY_CANVAS_INLINE_DISPLAYS, ui.cb_canvas_inline_displays->isChecked());
  620. }
  621. // ------------------------------------------------------------------------------------------------------------
  622. QSafeSettings settings("falkTX", "Carla2");
  623. // ------------------------------------------------------------------------------------------------------------
  624. // Main
  625. settings.setValue(CARLA_KEY_MAIN_EXPERIMENTAL, host.experimental);
  626. // ------------------------------------------------------------------------------------------------------------
  627. // Engine
  628. const QCarlaString audioDriver = ui.cb_engine_audio_driver->currentText();
  629. if (audioDriver.isNotEmpty() && host.audioDriverForced.isEmpty() && ! host.isPlugin)
  630. settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver);
  631. if (! host.processModeForced)
  632. {
  633. // engine sends callback if processMode really changes
  634. if (audioDriver == "JACK")
  635. host.nextProcessMode = static_cast<EngineProcessMode>(ui.cb_engine_process_mode_jack->currentIndex());
  636. else
  637. host.nextProcessMode = static_cast<EngineProcessMode>(ui.cb_engine_process_mode_other->currentIndex() + PROCESS_MODE_NON_JACK_PADDING);
  638. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, host.nextProcessMode);
  639. }
  640. host.exportLV2 = ui.ch_exp_export_lv2->isChecked();
  641. host.forceStereo = ui.ch_engine_force_stereo->isChecked();
  642. host.resetXruns = ui.cb_engine_reset_xruns->isChecked();
  643. host.maxParameters = static_cast<uint>(std::max(0, ui.sb_engine_max_params->value()));
  644. host.manageUIs = ui.ch_engine_manage_uis->isChecked();
  645. host.preferPluginBridges = ui.ch_engine_prefer_plugin_bridges->isChecked();
  646. host.preferUIBridges = ui.ch_engine_prefer_ui_bridges->isChecked();
  647. host.showLogs = ui.ch_main_show_logs->isChecked();
  648. host.showPluginBridges = ui.cb_exp_plugin_bridges->isChecked();
  649. host.showWineBridges = ui.ch_exp_wine_bridges->isChecked();
  650. host.uiBridgesTimeout = ui.sb_engine_ui_bridges_timeout->value();
  651. host.uisAlwaysOnTop = ui.ch_engine_uis_always_on_top->isChecked();
  652. if (ui.ch_engine_force_stereo->isEnabled())
  653. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, host.forceStereo);
  654. settings.setValue(CARLA_KEY_MAIN_SHOW_LOGS, host.showLogs);
  655. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, host.maxParameters);
  656. settings.setValue(CARLA_KEY_ENGINE_RESET_XRUNS, host.resetXruns);
  657. settings.setValue(CARLA_KEY_ENGINE_MANAGE_UIS, host.manageUIs);
  658. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, host.preferPluginBridges);
  659. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, host.preferUIBridges);
  660. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, host.uiBridgesTimeout);
  661. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, host.uisAlwaysOnTop);
  662. settings.setValue(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2, host.exportLV2);
  663. settings.setValue(CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES, host.showPluginBridges);
  664. settings.setValue(CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES, host.showWineBridges);
  665. // ------------------------------------------------------------------------------------------------------------
  666. // OSC
  667. settings.setValue(CARLA_KEY_OSC_ENABLED, ui.ch_osc_enable->isChecked());
  668. settings.setValue(CARLA_KEY_OSC_TCP_PORT_ENABLED, ui.group_osc_tcp_port->isChecked());
  669. settings.setValue(CARLA_KEY_OSC_UDP_PORT_ENABLED, ui.group_osc_udp_port->isChecked());
  670. settings.setValue(CARLA_KEY_OSC_TCP_PORT_RANDOM, ui.rb_osc_tcp_port_random->isChecked());
  671. settings.setValue(CARLA_KEY_OSC_UDP_PORT_RANDOM, ui.rb_osc_udp_port_random->isChecked());
  672. settings.setValue(CARLA_KEY_OSC_TCP_PORT_NUMBER, ui.sb_osc_tcp_port_number->value());
  673. settings.setValue(CARLA_KEY_OSC_UDP_PORT_NUMBER, ui.sb_osc_udp_port_number->value());
  674. // ------------------------------------------------------------------------------------------------------------
  675. // File Paths
  676. QStringList audioPaths;
  677. QStringList midiPaths;
  678. for (int i=0; i < ui.lw_files_audio->count(); ++i)
  679. audioPaths.append(ui.lw_files_audio->item(i)->text());
  680. for (int i=0; i < ui.lw_files_midi->count(); ++i)
  681. midiPaths.append(ui.lw_files_midi->item(i)->text());
  682. /* TODO
  683. host.set_engine_option(ENGINE_OPTION_FILE_PATH, FILE_AUDIO, splitter.join(audioPaths));
  684. host.set_engine_option(ENGINE_OPTION_FILE_PATH, FILE_MIDI, splitter.join(midiPaths));
  685. */
  686. settings.setValue(CARLA_KEY_PATHS_AUDIO, audioPaths);
  687. settings.setValue(CARLA_KEY_PATHS_MIDI, midiPaths);
  688. // ------------------------------------------------------------------------------------------------------------
  689. // Plugin Paths
  690. QStringList ladspas;
  691. QStringList dssis;
  692. QStringList lv2s;
  693. QStringList vst2s;
  694. QStringList vst3s;
  695. QStringList sf2s;
  696. QStringList sfzs;
  697. QStringList jsfxs;
  698. for (int i=0; i < ui.lw_ladspa->count(); ++i)
  699. ladspas.append(ui.lw_ladspa->item(i)->text());
  700. for (int i=0; i < ui.lw_dssi->count(); ++i)
  701. dssis.append(ui.lw_dssi->item(i)->text());
  702. for (int i=0; i < ui.lw_lv2->count(); ++i)
  703. lv2s.append(ui.lw_lv2->item(i)->text());
  704. for (int i=0; i < ui.lw_vst->count(); ++i)
  705. vst2s.append(ui.lw_vst->item(i)->text());
  706. for (int i=0; i < ui.lw_vst3->count(); ++i)
  707. vst3s.append(ui.lw_vst3->item(i)->text());
  708. for (int i=0; i < ui.lw_sf2->count(); ++i)
  709. sf2s.append(ui.lw_sf2->item(i)->text());
  710. for (int i=0; i < ui.lw_sfz->count(); ++i)
  711. sfzs.append(ui.lw_sfz->item(i)->text());
  712. for (int i=0; i < ui.lw_jsfx->count(); ++i)
  713. jsfxs.append(ui.lw_jsfx->item(i)->text());
  714. /* TODO
  715. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas));
  716. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis));
  717. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s));
  718. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST2, splitter.join(vst2s));
  719. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s));
  720. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s));
  721. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs));
  722. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_JSFX, splitter.join(jsfxs));
  723. */
  724. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas);
  725. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis);
  726. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s);
  727. settings.setValue(CARLA_KEY_PATHS_VST2, vst2s);
  728. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s);
  729. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s);
  730. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs);
  731. settings.setValue(CARLA_KEY_PATHS_JSFX, jsfxs);
  732. // ------------------------------------------------------------------------------------------------------------
  733. // Wine
  734. settings.setValue(CARLA_KEY_WINE_EXECUTABLE, ui.le_wine_exec->text());
  735. settings.setValue(CARLA_KEY_WINE_AUTO_PREFIX, ui.cb_wine_prefix_detect->isChecked());
  736. settings.setValue(CARLA_KEY_WINE_FALLBACK_PREFIX, ui.le_wine_prefix_fallback->text());
  737. settings.setValue(CARLA_KEY_WINE_RT_PRIO_ENABLED, ui.group_wine_realtime->isChecked());
  738. settings.setValue(CARLA_KEY_WINE_BASE_RT_PRIO, ui.sb_wine_base_prio->value());
  739. settings.setValue(CARLA_KEY_WINE_SERVER_RT_PRIO, ui.sb_wine_server_prio->value());
  740. // ------------------------------------------------------------------------------------------------------------
  741. // Experimental
  742. settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, ui.ch_exp_jack_apps->isChecked());
  743. settings.setValue(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, ui.ch_exp_load_lib_global->isChecked());
  744. settings.setValue(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, ui.ch_exp_prevent_bad_behaviour->isChecked());
  745. }
  746. void resetSettings()
  747. {
  748. switch (ui.lw_page->currentRow())
  749. {
  750. // ------------------------------------------------------------------------------------------------------------
  751. // Main
  752. case TAB_INDEX_MAIN:
  753. ui.le_main_proj_folder->setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER);
  754. ui.ch_main_theme_pro->setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME && ui.group_main_theme->isEnabled());
  755. ui.cb_main_theme_color->setCurrentIndex(ui.cb_main_theme_color->findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR));
  756. ui.sb_main_refresh_interval->setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL);
  757. ui.ch_main_confirm_exit->setChecked(CARLA_DEFAULT_MAIN_CONFIRM_EXIT);
  758. ui.ch_main_show_logs->setChecked(CARLA_DEFAULT_MAIN_SHOW_LOGS);
  759. break;
  760. // ------------------------------------------------------------------------------------------------------------
  761. // Canvas
  762. case TAB_INDEX_CANVAS:
  763. ui.cb_canvas_theme->setCurrentIndex(ui.cb_canvas_theme->findText(CARLA_DEFAULT_CANVAS_THEME));
  764. ui.cb_canvas_size->setCurrentIndex(ui.cb_canvas_size->findText(CARLA_DEFAULT_CANVAS_SIZE));
  765. ui.cb_canvas_bezier_lines->setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES);
  766. ui.cb_canvas_hide_groups->setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS);
  767. ui.cb_canvas_auto_select->setChecked(CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS);
  768. ui.cb_canvas_eyecandy->setChecked(CARLA_DEFAULT_CANVAS_EYE_CANDY);
  769. ui.cb_canvas_render_aa->setCheckState(Qt::PartiallyChecked); // CARLA_DEFAULT_CANVAS_ANTIALIASING
  770. ui.cb_canvas_full_repaints->setChecked(CARLA_DEFAULT_CANVAS_FULL_REPAINTS);
  771. break;
  772. // ------------------------------------------------------------------------------------------------------------
  773. // Engine
  774. case TAB_INDEX_ENGINE:
  775. if (! host.isPlugin)
  776. ui.cb_engine_audio_driver->setCurrentIndex(0);
  777. if (! host.processModeForced)
  778. {
  779. if (ui.cb_engine_audio_driver->currentText() == "JACK")
  780. {
  781. ui.cb_engine_process_mode_jack->setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE);
  782. ui.sw_engine_process_mode->setCurrentIndex(0); // show all modes
  783. }
  784. else
  785. {
  786. ui.cb_engine_process_mode_other->setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE-PROCESS_MODE_NON_JACK_PADDING);
  787. ui.sw_engine_process_mode->setCurrentIndex(1); // hide single+multi client modes
  788. }
  789. }
  790. ui.sb_engine_max_params->setValue(CARLA_DEFAULT_MAX_PARAMETERS);
  791. ui.cb_engine_reset_xruns->setChecked(CARLA_DEFAULT_RESET_XRUNS);
  792. ui.ch_engine_uis_always_on_top->setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP);
  793. ui.ch_engine_prefer_ui_bridges->setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES);
  794. ui.sb_engine_ui_bridges_timeout->setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT);
  795. ui.ch_engine_manage_uis->setChecked(CARLA_DEFAULT_MANAGE_UIS);
  796. break;
  797. // ------------------------------------------------------------------------------------------------------------
  798. // OSC
  799. case TAB_INDEX_OSC:
  800. ui.ch_osc_enable->setChecked(CARLA_DEFAULT_OSC_ENABLED);
  801. ui.group_osc_tcp_port->setChecked(CARLA_DEFAULT_OSC_TCP_PORT_ENABLED);
  802. ui.group_osc_udp_port->setChecked(CARLA_DEFAULT_OSC_UDP_PORT_ENABLED);
  803. ui.sb_osc_tcp_port_number->setValue(CARLA_DEFAULT_OSC_TCP_PORT_NUMBER);
  804. ui.sb_osc_udp_port_number->setValue(CARLA_DEFAULT_OSC_UDP_PORT_NUMBER);
  805. if (CARLA_DEFAULT_OSC_TCP_PORT_RANDOM)
  806. {
  807. ui.rb_osc_tcp_port_specific->setChecked(false);
  808. ui.rb_osc_tcp_port_random->setChecked(true);
  809. }
  810. else
  811. {
  812. ui.rb_osc_tcp_port_random->setChecked(false);
  813. ui.rb_osc_tcp_port_specific->setChecked(true);
  814. }
  815. if (CARLA_DEFAULT_OSC_UDP_PORT_RANDOM)
  816. {
  817. ui.rb_osc_udp_port_specific->setChecked(false);
  818. ui.rb_osc_udp_port_random->setChecked(true);
  819. }
  820. else
  821. {
  822. ui.rb_osc_udp_port_random->setChecked(false);
  823. ui.rb_osc_udp_port_specific->setChecked(true);
  824. }
  825. break;
  826. // ------------------------------------------------------------------------------------------------------------
  827. // Plugin Paths
  828. case TAB_INDEX_FILEPATHS:
  829. switch (ui.tw_filepaths->currentIndex())
  830. {
  831. case FILEPATH_INDEX_AUDIO:
  832. ui.lw_files_audio->clear();
  833. break;
  834. case FILEPATH_INDEX_MIDI:
  835. ui.lw_files_midi->clear();
  836. break;
  837. }
  838. break;
  839. // ------------------------------------------------------------------------------------------------------------
  840. // Plugin Paths
  841. case TAB_INDEX_PLUGINPATHS:
  842. {
  843. QStringList paths;
  844. switch (ui.tw_paths->currentIndex())
  845. {
  846. case PLUGINPATH_INDEX_LADSPA:
  847. paths = CARLA_DEFAULT_LADSPA_PATH;
  848. paths.sort();
  849. ui.lw_ladspa->clear();
  850. for (const auto& path : paths)
  851. {
  852. if (path.isEmpty())
  853. continue;
  854. ui.lw_ladspa->addItem(path);
  855. }
  856. break;
  857. case PLUGINPATH_INDEX_DSSI:
  858. paths = CARLA_DEFAULT_DSSI_PATH;
  859. paths.sort();
  860. ui.lw_dssi->clear();
  861. for (const auto& path : paths)
  862. {
  863. if (path.isEmpty())
  864. continue;
  865. ui.lw_dssi->addItem(path);
  866. }
  867. break;
  868. case PLUGINPATH_INDEX_LV2:
  869. paths = CARLA_DEFAULT_LV2_PATH;
  870. paths.sort();
  871. ui.lw_lv2->clear();
  872. for (const auto& path : paths)
  873. {
  874. if (path.isEmpty())
  875. continue;
  876. ui.lw_lv2->addItem(path);
  877. }
  878. break;
  879. case PLUGINPATH_INDEX_VST2:
  880. paths = CARLA_DEFAULT_VST2_PATH;
  881. paths.sort();
  882. ui.lw_vst->clear();
  883. for (const auto& path : paths)
  884. {
  885. if (path.isEmpty())
  886. continue;
  887. ui.lw_vst->addItem(path);
  888. }
  889. break;
  890. case PLUGINPATH_INDEX_VST3:
  891. paths = CARLA_DEFAULT_VST3_PATH;
  892. paths.sort();
  893. ui.lw_vst3->clear();
  894. for (const auto& path : paths)
  895. {
  896. if (path.isEmpty())
  897. continue;
  898. ui.lw_vst3->addItem(path);
  899. }
  900. break;
  901. case PLUGINPATH_INDEX_SF2:
  902. paths = CARLA_DEFAULT_SF2_PATH;
  903. paths.sort();
  904. ui.lw_sf2->clear();
  905. for (const auto& path : paths)
  906. {
  907. if (path.isEmpty())
  908. continue;
  909. ui.lw_sf2->addItem(path);
  910. }
  911. break;
  912. case PLUGINPATH_INDEX_SFZ:
  913. paths = CARLA_DEFAULT_SFZ_PATH;
  914. paths.sort();
  915. ui.lw_sfz->clear();
  916. for (const auto& path : paths)
  917. {
  918. if (path.isEmpty())
  919. continue;
  920. ui.lw_sfz->addItem(path);
  921. }
  922. break;
  923. case PLUGINPATH_INDEX_JSFX:
  924. paths = CARLA_DEFAULT_JSFX_PATH;
  925. paths.sort();
  926. ui.lw_jsfx->clear();
  927. for (const auto& path : paths)
  928. {
  929. if (path.isEmpty())
  930. continue;
  931. ui.lw_jsfx->addItem(path);
  932. }
  933. break;
  934. }
  935. break;
  936. }
  937. // ------------------------------------------------------------------------------------------------------------
  938. // Wine
  939. case TAB_INDEX_WINE:
  940. ui.le_wine_exec->setText(CARLA_DEFAULT_WINE_EXECUTABLE);
  941. ui.cb_wine_prefix_detect->setChecked(CARLA_DEFAULT_WINE_AUTO_PREFIX);
  942. ui.le_wine_prefix_fallback->setText(CARLA_DEFAULT_WINE_FALLBACK_PREFIX);
  943. ui.group_wine_realtime->setChecked(CARLA_DEFAULT_WINE_RT_PRIO_ENABLED);
  944. ui.sb_wine_base_prio->setValue(CARLA_DEFAULT_WINE_BASE_RT_PRIO);
  945. ui.sb_wine_server_prio->setValue(CARLA_DEFAULT_WINE_SERVER_RT_PRIO);
  946. break;
  947. // ------------------------------------------------------------------------------------------------------------
  948. // Experimental
  949. case TAB_INDEX_EXPERIMENTAL:
  950. resetExperimentalSettings();
  951. break;
  952. }
  953. }
  954. void resetExperimentalSettings()
  955. {
  956. // Forever experimental
  957. ui.cb_exp_plugin_bridges->setChecked(CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES);
  958. ui.ch_exp_wine_bridges->setChecked(CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES);
  959. ui.ch_exp_jack_apps->setChecked(CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS);
  960. ui.ch_exp_export_lv2->setChecked(CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT);
  961. ui.ch_exp_load_lib_global->setChecked(CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL);
  962. ui.ch_exp_prevent_bad_behaviour->setChecked(CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR);
  963. // Temporary, until stable
  964. ui.cb_canvas_fancy_eyecandy->setChecked(CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY);
  965. ui.cb_canvas_use_opengl->setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and ui.cb_canvas_use_opengl->isEnabled());
  966. ui.cb_canvas_render_hq_aa->setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and ui.cb_canvas_render_hq_aa->isEnabled());
  967. ui.cb_canvas_inline_displays->setChecked(CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS);
  968. ui.ch_engine_force_stereo->setChecked(CARLA_DEFAULT_FORCE_STEREO);
  969. ui.ch_engine_prefer_plugin_bridges->setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES);
  970. }
  971. };
  972. CarlaSettingsW::CarlaSettingsW(QWidget* const parent, CarlaHost& host, const bool hasCanvas, const bool hasCanvasGL)
  973. : QDialog(parent),
  974. self(new PrivateData(this, host))
  975. {
  976. // ----------------------------------------------------------------------------------------------------------------
  977. // Set-up GUI
  978. self->ui.lw_page->setFixedWidth(48 + 6*3 + fontMetricsHorizontalAdvance(self->ui.lw_page->fontMetrics(), " Experimental "));
  979. for (uint i=0; i < carla_get_engine_driver_count(); ++i)
  980. self->ui.cb_engine_audio_driver->addItem(carla_get_engine_driver_name(i));
  981. for (uint i=0; i < Theme::THEME_MAX; ++i)
  982. self->ui.cb_canvas_theme->addItem(getThemeName((Theme::List)i));
  983. #ifdef CARLA_OS_MAC
  984. self->ui.group_main_theme->setEnabled(false);
  985. self->ui.group_main_theme->setVisible(false);
  986. #endif
  987. #ifdef CARLA_OS_Win
  988. if (true)
  989. #else
  990. if (host.isControl)
  991. #endif
  992. {
  993. self->ui.ch_main_show_logs->setEnabled(false);
  994. self->ui.ch_main_show_logs->setVisible(false);
  995. }
  996. if (host.isControl)
  997. {
  998. self->ui.lw_page->hideRow(TAB_INDEX_ENGINE);
  999. self->ui.lw_page->hideRow(TAB_INDEX_FILEPATHS);
  1000. self->ui.lw_page->hideRow(TAB_INDEX_PLUGINPATHS);
  1001. self->ui.ch_exp_export_lv2->hide();
  1002. self->ui.group_experimental_engine->hide();
  1003. }
  1004. else if (! hasCanvas)
  1005. {
  1006. self->ui.lw_page->hideRow(TAB_INDEX_CANVAS);
  1007. }
  1008. else if (! hasCanvasGL)
  1009. {
  1010. self->ui.cb_canvas_use_opengl->setEnabled(false);
  1011. self->ui.cb_canvas_render_hq_aa->setEnabled(false);
  1012. }
  1013. if (host.isPlugin)
  1014. self->ui.cb_engine_audio_driver->setEnabled(false);
  1015. if (host.audioDriverForced.isNotEmpty())
  1016. {
  1017. self->ui.cb_engine_audio_driver->setEnabled(false);
  1018. self->ui.tb_engine_driver_config->setEnabled(false);
  1019. }
  1020. if (host.processModeForced)
  1021. {
  1022. self->ui.cb_engine_process_mode_jack->setEnabled(false);
  1023. self->ui.cb_engine_process_mode_other->setEnabled(false);
  1024. if (host.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
  1025. self->ui.ch_engine_force_stereo->setEnabled(false);
  1026. }
  1027. if (host.isControl || host.isPlugin)
  1028. {
  1029. self->ui.ch_main_confirm_exit->hide();
  1030. self->ui.ch_exp_load_lib_global->hide();
  1031. self->ui.lw_page->hideRow(TAB_INDEX_OSC);
  1032. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1033. }
  1034. #ifndef CARLA_OS_LINUX
  1035. self->ui.ch_exp_wine_bridges->setVisible(false);
  1036. self->ui.ch_exp_jack_apps->setVisible(false);
  1037. self->ui.ch_exp_prevent_bad_behaviour->setVisible(false);
  1038. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1039. #endif
  1040. #ifndef CARLA_OS_MAC
  1041. self->ui.label_engine_ui_bridges_mac_note->setVisible(false);
  1042. #endif
  1043. // FIXME, not implemented yet
  1044. self->ui.ch_engine_uis_always_on_top->hide();
  1045. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  1046. // ----------------------------------------------------------------------------------------------------------------
  1047. // Load settings
  1048. self->loadSettings();
  1049. // ----------------------------------------------------------------------------------------------------------------
  1050. // Set-up connections
  1051. connect(this, SIGNAL(accepted()), SLOT(slot_saveSettings()));
  1052. connect(self->ui.buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(slot_resetSettings()));
  1053. connect(self->ui.b_main_proj_folder_open, SIGNAL(clicked()), SLOT(slot_getAndSetProjectPath()));
  1054. connect(self->ui.cb_engine_audio_driver, SIGNAL(currentIndexChanged(int)), SLOT(slot_engineAudioDriverChanged()));
  1055. connect(self->ui.tb_engine_driver_config, SIGNAL(clicked()), SLOT(slot_showAudioDriverSettings()));
  1056. connect(self->ui.b_paths_add, SIGNAL(clicked()), SLOT(slot_addPluginPath()));
  1057. connect(self->ui.b_paths_remove, SIGNAL(clicked()), SLOT(slot_removePluginPath()));
  1058. connect(self->ui.b_paths_change, SIGNAL(clicked()), SLOT(slot_changePluginPath()));
  1059. connect(self->ui.cb_paths, SIGNAL(currentIndexChanged(int)), SLOT(slot_pluginPathTabChanged(int)));
  1060. connect(self->ui.lw_ladspa, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1061. connect(self->ui.lw_dssi, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1062. connect(self->ui.lw_lv2, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1063. connect(self->ui.lw_vst, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1064. connect(self->ui.lw_vst3, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1065. connect(self->ui.lw_sf2, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1066. connect(self->ui.lw_sfz, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1067. connect(self->ui.lw_jsfx, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1068. connect(self->ui.b_filepaths_add, SIGNAL(clicked()), SLOT(slot_addFilePath()));
  1069. connect(self->ui.b_filepaths_remove, SIGNAL(clicked()), SLOT(slot_removeFilePath()));
  1070. connect(self->ui.b_filepaths_change, SIGNAL(clicked()), SLOT(slot_changeFilePath()));
  1071. connect(self->ui.cb_filepaths, SIGNAL(currentIndexChanged(int)), SLOT(slot_filePathTabChanged(int)));
  1072. connect(self->ui.lw_files_audio, SIGNAL(currentRowChanged(int)), SLOT(slot_filePathRowChanged(int)));
  1073. connect(self->ui.lw_files_midi, SIGNAL(currentRowChanged(int)), SLOT(slot_filePathRowChanged(int)));
  1074. connect(self->ui.ch_main_experimental, SIGNAL(toggled(bool)), SLOT(slot_enableExperimental(bool)));
  1075. connect(self->ui.ch_exp_wine_bridges, SIGNAL(toggled(bool)), SLOT(slot_enableWineBridges(bool)));
  1076. connect(self->ui.cb_exp_plugin_bridges, SIGNAL(toggled(bool)), SLOT(slot_pluginBridgesToggled(bool)));
  1077. connect(self->ui.cb_canvas_eyecandy, SIGNAL(toggled(bool)), SLOT(slot_canvasEyeCandyToggled(bool)));
  1078. connect(self->ui.cb_canvas_fancy_eyecandy, SIGNAL(toggled(bool)), SLOT(slot_canvasFancyEyeCandyToggled(bool)));
  1079. connect(self->ui.cb_canvas_use_opengl, SIGNAL(toggled(bool)), SLOT(slot_canvasOpenGLToggled(bool)));
  1080. // ----------------------------------------------------------------------------------------------------------------
  1081. // Post-connect setup
  1082. self->ui.lw_ladspa->setCurrentRow(0);
  1083. self->ui.lw_dssi->setCurrentRow(0);
  1084. self->ui.lw_lv2->setCurrentRow(0);
  1085. self->ui.lw_vst->setCurrentRow(0);
  1086. self->ui.lw_vst3->setCurrentRow(0);
  1087. self->ui.lw_sf2->setCurrentRow(0);
  1088. self->ui.lw_sfz->setCurrentRow(0);
  1089. self->ui.lw_jsfx->setCurrentRow(0);
  1090. self->ui.lw_files_audio->setCurrentRow(0);
  1091. self->ui.lw_files_midi->setCurrentRow(0);
  1092. self->ui.lw_page->setCurrentCell(0, 0);
  1093. slot_filePathTabChanged(0);
  1094. slot_pluginPathTabChanged(0);
  1095. adjustSize();
  1096. }
  1097. CarlaSettingsW::~CarlaSettingsW()
  1098. {
  1099. delete self;
  1100. }
  1101. // --------------------------------------------------------------------------------------------------------------------
  1102. void CarlaSettingsW::slot_saveSettings()
  1103. {
  1104. self->saveSettings();
  1105. }
  1106. void CarlaSettingsW::slot_resetSettings()
  1107. {
  1108. self->resetSettings();
  1109. }
  1110. // --------------------------------------------------------------------------------------------------------------------
  1111. void CarlaSettingsW::slot_enableExperimental(const bool toggled)
  1112. {
  1113. if (toggled)
  1114. {
  1115. self->ui.lw_page->showRow(TAB_INDEX_EXPERIMENTAL);
  1116. if (self->ui.ch_exp_wine_bridges->isChecked() and not self->host.isControl)
  1117. self->ui.lw_page->showRow(TAB_INDEX_WINE);
  1118. }
  1119. else
  1120. {
  1121. self->ui.lw_page->hideRow(TAB_INDEX_EXPERIMENTAL);
  1122. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1123. }
  1124. }
  1125. void CarlaSettingsW::slot_enableWineBridges(const bool toggled)
  1126. {
  1127. if (toggled && ! self->host.isControl)
  1128. self->ui.lw_page->showRow(TAB_INDEX_WINE);
  1129. else
  1130. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1131. }
  1132. void CarlaSettingsW::slot_pluginBridgesToggled(const bool toggled)
  1133. {
  1134. if (! toggled)
  1135. {
  1136. self->ui.ch_exp_wine_bridges->setChecked(false);
  1137. self->ui.ch_engine_prefer_plugin_bridges->setChecked(false);
  1138. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1139. }
  1140. }
  1141. void CarlaSettingsW::slot_canvasEyeCandyToggled(const bool toggled)
  1142. {
  1143. if (! toggled)
  1144. {
  1145. // disable fancy eyecandy too
  1146. self->ui.cb_canvas_fancy_eyecandy->setChecked(false);
  1147. }
  1148. }
  1149. void CarlaSettingsW::slot_canvasFancyEyeCandyToggled(const bool toggled)
  1150. {
  1151. if (! toggled)
  1152. {
  1153. // make sure normal eyecandy is enabled too
  1154. self->ui.cb_canvas_eyecandy->setChecked(true);
  1155. }
  1156. }
  1157. void CarlaSettingsW::slot_canvasOpenGLToggled(const bool toggled)
  1158. {
  1159. if (! toggled)
  1160. {
  1161. // uncheck GL specific option
  1162. self->ui.cb_canvas_render_hq_aa->setChecked(false);
  1163. }
  1164. }
  1165. // --------------------------------------------------------------------------------------------------------------------
  1166. void CarlaSettingsW::slot_getAndSetProjectPath()
  1167. {
  1168. // FIXME?
  1169. getAndSetPath(this, self->ui.le_main_proj_folder);
  1170. }
  1171. // --------------------------------------------------------------------------------------------------------------------
  1172. void CarlaSettingsW::slot_engineAudioDriverChanged()
  1173. {
  1174. if (self->ui.cb_engine_audio_driver->currentText() == "JACK")
  1175. self->ui.sw_engine_process_mode->setCurrentIndex(0);
  1176. else
  1177. self->ui.sw_engine_process_mode->setCurrentIndex(1);
  1178. }
  1179. void CarlaSettingsW::slot_showAudioDriverSettings()
  1180. {
  1181. const int driverIndex = self->ui.cb_engine_audio_driver->currentIndex();
  1182. const QString driverName = self->ui.cb_engine_audio_driver->currentText();
  1183. CARLA_SAFE_ASSERT_RETURN(driverIndex >= 0,);
  1184. DriverSettingsW(this, static_cast<uint>(driverIndex), driverName).exec();
  1185. }
  1186. // --------------------------------------------------------------------------------------------------------------------
  1187. void CarlaSettingsW::slot_addPluginPath()
  1188. {
  1189. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), "", QFileDialog::ShowDirsOnly);
  1190. if (newPath.isEmpty())
  1191. return;
  1192. switch (self->ui.tw_paths->currentIndex())
  1193. {
  1194. case PLUGINPATH_INDEX_LADSPA:
  1195. self->ui.lw_ladspa->addItem(newPath);
  1196. break;
  1197. case PLUGINPATH_INDEX_DSSI:
  1198. self->ui.lw_dssi->addItem(newPath);
  1199. break;
  1200. case PLUGINPATH_INDEX_LV2:
  1201. self->ui.lw_lv2->addItem(newPath);
  1202. break;
  1203. case PLUGINPATH_INDEX_VST2:
  1204. self->ui.lw_vst->addItem(newPath);
  1205. break;
  1206. case PLUGINPATH_INDEX_VST3:
  1207. self->ui.lw_vst3->addItem(newPath);
  1208. break;
  1209. case PLUGINPATH_INDEX_SF2:
  1210. self->ui.lw_sf2->addItem(newPath);
  1211. break;
  1212. case PLUGINPATH_INDEX_SFZ:
  1213. self->ui.lw_sfz->addItem(newPath);
  1214. break;
  1215. case PLUGINPATH_INDEX_JSFX:
  1216. self->ui.lw_jsfx->addItem(newPath);
  1217. break;
  1218. }
  1219. }
  1220. void CarlaSettingsW::slot_removePluginPath()
  1221. {
  1222. switch (self->ui.tw_paths->currentIndex())
  1223. {
  1224. case PLUGINPATH_INDEX_LADSPA:
  1225. self->ui.lw_ladspa->takeItem(self->ui.lw_ladspa->currentRow());
  1226. break;
  1227. case PLUGINPATH_INDEX_DSSI:
  1228. self->ui.lw_dssi->takeItem(self->ui.lw_dssi->currentRow());
  1229. break;
  1230. case PLUGINPATH_INDEX_LV2:
  1231. self->ui.lw_lv2->takeItem(self->ui.lw_lv2->currentRow());
  1232. break;
  1233. case PLUGINPATH_INDEX_VST2:
  1234. self->ui.lw_vst->takeItem(self->ui.lw_vst->currentRow());
  1235. break;
  1236. case PLUGINPATH_INDEX_VST3:
  1237. self->ui.lw_vst3->takeItem(self->ui.lw_vst3->currentRow());
  1238. break;
  1239. case PLUGINPATH_INDEX_SF2:
  1240. self->ui.lw_sf2->takeItem(self->ui.lw_sf2->currentRow());
  1241. break;
  1242. case PLUGINPATH_INDEX_SFZ:
  1243. self->ui.lw_sfz->takeItem(self->ui.lw_sfz->currentRow());
  1244. break;
  1245. case PLUGINPATH_INDEX_JSFX:
  1246. self->ui.lw_jsfx->takeItem(self->ui.lw_jsfx->currentRow());
  1247. break;
  1248. }
  1249. }
  1250. void CarlaSettingsW::slot_changePluginPath()
  1251. {
  1252. const int curIndex = self->ui.tw_paths->currentIndex();
  1253. QString currentPath;
  1254. switch (curIndex)
  1255. {
  1256. case PLUGINPATH_INDEX_LADSPA:
  1257. currentPath = self->ui.lw_ladspa->currentItem()->text();
  1258. break;
  1259. case PLUGINPATH_INDEX_DSSI:
  1260. currentPath = self->ui.lw_dssi->currentItem()->text();
  1261. break;
  1262. case PLUGINPATH_INDEX_LV2:
  1263. currentPath = self->ui.lw_lv2->currentItem()->text();
  1264. break;
  1265. case PLUGINPATH_INDEX_VST2:
  1266. currentPath = self->ui.lw_vst->currentItem()->text();
  1267. break;
  1268. case PLUGINPATH_INDEX_VST3:
  1269. currentPath = self->ui.lw_vst3->currentItem()->text();
  1270. break;
  1271. case PLUGINPATH_INDEX_SF2:
  1272. currentPath = self->ui.lw_sf2->currentItem()->text();
  1273. break;
  1274. case PLUGINPATH_INDEX_SFZ:
  1275. currentPath = self->ui.lw_sfz->currentItem()->text();
  1276. break;
  1277. case PLUGINPATH_INDEX_JSFX:
  1278. currentPath = self->ui.lw_jsfx->currentItem()->text();
  1279. break;
  1280. }
  1281. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), currentPath, QFileDialog::ShowDirsOnly);
  1282. if (newPath.isEmpty())
  1283. return;
  1284. switch (curIndex)
  1285. {
  1286. case PLUGINPATH_INDEX_LADSPA:
  1287. self->ui.lw_ladspa->currentItem()->setText(newPath);
  1288. break;
  1289. case PLUGINPATH_INDEX_DSSI:
  1290. self->ui.lw_dssi->currentItem()->setText(newPath);
  1291. break;
  1292. case PLUGINPATH_INDEX_LV2:
  1293. self->ui.lw_lv2->currentItem()->setText(newPath);
  1294. break;
  1295. case PLUGINPATH_INDEX_VST2:
  1296. self->ui.lw_vst->currentItem()->setText(newPath);
  1297. break;
  1298. case PLUGINPATH_INDEX_VST3:
  1299. self->ui.lw_vst3->currentItem()->setText(newPath);
  1300. break;
  1301. case PLUGINPATH_INDEX_SF2:
  1302. self->ui.lw_sf2->currentItem()->setText(newPath);
  1303. break;
  1304. case PLUGINPATH_INDEX_SFZ:
  1305. self->ui.lw_sfz->currentItem()->setText(newPath);
  1306. break;
  1307. case PLUGINPATH_INDEX_JSFX:
  1308. self->ui.lw_jsfx->currentItem()->setText(newPath);
  1309. break;
  1310. }
  1311. }
  1312. // --------------------------------------------------------------------------------------------------------------------
  1313. void CarlaSettingsW::slot_pluginPathTabChanged(const int index)
  1314. {
  1315. int row;
  1316. switch (index)
  1317. {
  1318. case PLUGINPATH_INDEX_LADSPA:
  1319. row = self->ui.lw_ladspa->currentRow();
  1320. break;
  1321. case PLUGINPATH_INDEX_DSSI:
  1322. row = self->ui.lw_dssi->currentRow();
  1323. break;
  1324. case PLUGINPATH_INDEX_LV2:
  1325. row = self->ui.lw_lv2->currentRow();
  1326. break;
  1327. case PLUGINPATH_INDEX_VST2:
  1328. row = self->ui.lw_vst->currentRow();
  1329. break;
  1330. case PLUGINPATH_INDEX_VST3:
  1331. row = self->ui.lw_vst3->currentRow();
  1332. break;
  1333. case PLUGINPATH_INDEX_SF2:
  1334. row = self->ui.lw_sf2->currentRow();
  1335. break;
  1336. case PLUGINPATH_INDEX_SFZ:
  1337. row = self->ui.lw_sfz->currentRow();
  1338. break;
  1339. case PLUGINPATH_INDEX_JSFX:
  1340. row = self->ui.lw_jsfx->currentRow();
  1341. break;
  1342. default:
  1343. row = -1;
  1344. break;
  1345. }
  1346. slot_pluginPathRowChanged(row);
  1347. }
  1348. void CarlaSettingsW::slot_pluginPathRowChanged(const int row)
  1349. {
  1350. const bool check = bool(row >= 0);
  1351. self->ui.b_paths_remove->setEnabled(check);
  1352. self->ui.b_paths_change->setEnabled(check);
  1353. }
  1354. // --------------------------------------------------------------------------------------------------------------------
  1355. void CarlaSettingsW::slot_addFilePath()
  1356. {
  1357. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), "", QFileDialog::ShowDirsOnly);
  1358. if (newPath.isEmpty())
  1359. return;
  1360. switch (self->ui.tw_filepaths->currentIndex())
  1361. {
  1362. case FILEPATH_INDEX_AUDIO:
  1363. self->ui.lw_files_audio->addItem(newPath);
  1364. break;
  1365. case FILEPATH_INDEX_MIDI:
  1366. self->ui.lw_files_midi->addItem(newPath);
  1367. break;
  1368. }
  1369. }
  1370. void CarlaSettingsW::slot_removeFilePath()
  1371. {
  1372. switch (self->ui.tw_filepaths->currentIndex())
  1373. {
  1374. case FILEPATH_INDEX_AUDIO:
  1375. self->ui.lw_files_audio->takeItem(self->ui.lw_files_audio->currentRow());
  1376. break;
  1377. case FILEPATH_INDEX_MIDI:
  1378. self->ui.lw_files_midi->takeItem(self->ui.lw_files_midi->currentRow());
  1379. break;
  1380. }
  1381. }
  1382. void CarlaSettingsW::slot_changeFilePath()
  1383. {
  1384. const int curIndex = self->ui.tw_filepaths->currentIndex();
  1385. QString currentPath;
  1386. switch (curIndex)
  1387. {
  1388. case FILEPATH_INDEX_AUDIO:
  1389. currentPath = self->ui.lw_files_audio->currentItem()->text();
  1390. break;
  1391. case FILEPATH_INDEX_MIDI:
  1392. currentPath = self->ui.lw_files_midi->currentItem()->text();
  1393. break;
  1394. }
  1395. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), currentPath, QFileDialog::ShowDirsOnly);
  1396. if (newPath.isEmpty())
  1397. return;
  1398. switch (curIndex)
  1399. {
  1400. case FILEPATH_INDEX_AUDIO:
  1401. self->ui.lw_files_audio->currentItem()->setText(newPath);
  1402. break;
  1403. case FILEPATH_INDEX_MIDI:
  1404. self->ui.lw_files_midi->currentItem()->setText(newPath);
  1405. break;
  1406. }
  1407. }
  1408. // --------------------------------------------------------------------------------------------------------------------
  1409. void CarlaSettingsW::slot_filePathTabChanged(const int index)
  1410. {
  1411. int row;
  1412. switch (index)
  1413. {
  1414. case FILEPATH_INDEX_AUDIO:
  1415. row = self->ui.lw_files_audio->currentRow();
  1416. break;
  1417. case FILEPATH_INDEX_MIDI:
  1418. row = self->ui.lw_files_midi->currentRow();
  1419. break;
  1420. default:
  1421. row = -1;
  1422. break;
  1423. }
  1424. slot_filePathRowChanged(row);
  1425. }
  1426. void CarlaSettingsW::slot_filePathRowChanged(const int row)
  1427. {
  1428. const bool check = bool(row >= 0);
  1429. self->ui.b_filepaths_remove->setEnabled(check);
  1430. self->ui.b_filepaths_change->setEnabled(check);
  1431. }
  1432. // --------------------------------------------------------------------------------------------------------------------