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.

1720 lines
67KB

  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. };
  337. /*
  338. Single and Multiple client mode is only for JACK,
  339. but we still want to match QComboBox index to backend defines,
  340. so add +2 pos padding if driverName != "JACK".
  341. */
  342. #define PROCESS_MODE_NON_JACK_PADDING 2
  343. struct CarlaSettingsW::PrivateData {
  344. Ui::CarlaSettingsW ui;
  345. CarlaHost& host;
  346. PrivateData(CarlaSettingsW* const self, CarlaHost& h)
  347. : ui(),
  348. host(h)
  349. {
  350. ui.setupUi(self);
  351. }
  352. void loadSettings()
  353. {
  354. {
  355. const QSafeSettings settings;
  356. // --------------------------------------------------------------------------------------------------------
  357. // Main
  358. ui.ch_main_show_logs->setChecked(host.showLogs);
  359. ui.ch_engine_uis_always_on_top->setChecked(host.uisAlwaysOnTop);
  360. ui.le_main_proj_folder->setText(settings.valueString(CARLA_KEY_MAIN_PROJECT_FOLDER,
  361. CARLA_DEFAULT_MAIN_PROJECT_FOLDER));
  362. ui.ch_main_theme_pro->setChecked(settings.valueBool(CARLA_KEY_MAIN_USE_PRO_THEME,
  363. CARLA_DEFAULT_MAIN_USE_PRO_THEME) && ui.group_main_theme->isEnabled());
  364. ui.cb_main_theme_color->setCurrentIndex(ui.cb_main_theme_color->findText(settings.valueString(CARLA_KEY_MAIN_PRO_THEME_COLOR,
  365. CARLA_DEFAULT_MAIN_PRO_THEME_COLOR)));
  366. ui.sb_main_refresh_interval->setValue(settings.valueIntPositive(CARLA_KEY_MAIN_REFRESH_INTERVAL,
  367. CARLA_DEFAULT_MAIN_REFRESH_INTERVAL));
  368. ui.ch_main_confirm_exit->setChecked(settings.valueBool(CARLA_KEY_MAIN_CONFIRM_EXIT,
  369. CARLA_DEFAULT_MAIN_CONFIRM_EXIT));
  370. // --------------------------------------------------------------------------------------------------------
  371. // Canvas
  372. ui.cb_canvas_theme->setCurrentIndex(ui.cb_canvas_theme->findText(settings.valueString(CARLA_KEY_CANVAS_THEME,
  373. CARLA_DEFAULT_CANVAS_THEME)));
  374. ui.cb_canvas_size->setCurrentIndex(ui.cb_canvas_size->findText(settings.valueString(CARLA_KEY_CANVAS_SIZE,
  375. CARLA_DEFAULT_CANVAS_SIZE)));
  376. ui.cb_canvas_bezier_lines->setChecked(settings.valueBool(CARLA_KEY_CANVAS_USE_BEZIER_LINES,
  377. CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES));
  378. ui.cb_canvas_hide_groups->setChecked(settings.valueBool(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS,
  379. CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS));
  380. ui.cb_canvas_auto_select->setChecked(settings.valueBool(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS,
  381. CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS));
  382. ui.cb_canvas_eyecandy->setChecked(settings.valueBool(CARLA_KEY_CANVAS_EYE_CANDY,
  383. CARLA_DEFAULT_CANVAS_EYE_CANDY));
  384. ui.cb_canvas_fancy_eyecandy->setChecked(settings.valueBool(CARLA_KEY_CANVAS_FANCY_EYE_CANDY,
  385. CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY));
  386. ui.cb_canvas_use_opengl->setChecked(settings.valueBool(CARLA_KEY_CANVAS_USE_OPENGL,
  387. CARLA_DEFAULT_CANVAS_USE_OPENGL) && ui.cb_canvas_use_opengl->isEnabled());
  388. ui.cb_canvas_render_aa->setCheckState(settings.valueCheckState(CARLA_KEY_CANVAS_ANTIALIASING,
  389. CARLA_DEFAULT_CANVAS_ANTIALIASING));
  390. ui.cb_canvas_render_hq_aa->setChecked(settings.valueBool(CARLA_KEY_CANVAS_HQ_ANTIALIASING,
  391. CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING) && ui.cb_canvas_render_hq_aa->isEnabled());
  392. ui.cb_canvas_full_repaints->setChecked(settings.valueBool(CARLA_KEY_CANVAS_FULL_REPAINTS,
  393. CARLA_DEFAULT_CANVAS_FULL_REPAINTS));
  394. ui.cb_canvas_inline_displays->setChecked(settings.valueBool(CARLA_KEY_CANVAS_INLINE_DISPLAYS,
  395. CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS));
  396. }
  397. // ------------------------------------------------------------------------------------------------------------
  398. const QSafeSettings settings("falkTX", "Carla2");
  399. // ------------------------------------------------------------------------------------------------------------
  400. // Main
  401. ui.ch_main_experimental->setChecked(host.experimental);
  402. if (! host.experimental)
  403. {
  404. ui.lw_page->hideRow(TAB_INDEX_EXPERIMENTAL);
  405. ui.lw_page->hideRow(TAB_INDEX_WINE);
  406. }
  407. else if (! host.showWineBridges)
  408. {
  409. ui.lw_page->hideRow(TAB_INDEX_WINE);
  410. }
  411. // ------------------------------------------------------------------------------------------------------------
  412. // Engine
  413. QString audioDriver;
  414. if (host.isPlugin)
  415. {
  416. audioDriver = "Plugin";
  417. ui.cb_engine_audio_driver->setCurrentIndex(0);
  418. }
  419. else if (host.audioDriverForced.isNotEmpty())
  420. {
  421. audioDriver = host.audioDriverForced;
  422. ui.cb_engine_audio_driver->setCurrentIndex(0);
  423. }
  424. else
  425. {
  426. audioDriver = settings.valueString(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER);
  427. bool found = false;
  428. for (int i=0; i < ui.cb_engine_audio_driver->count(); ++i)
  429. {
  430. if (ui.cb_engine_audio_driver->itemText(i) == audioDriver)
  431. {
  432. found = true;
  433. ui.cb_engine_audio_driver->setCurrentIndex(i);
  434. break;
  435. }
  436. }
  437. if (! found)
  438. ui.cb_engine_audio_driver->setCurrentIndex(-1);
  439. }
  440. if (audioDriver == "JACK")
  441. ui.sw_engine_process_mode->setCurrentIndex(0);
  442. else
  443. ui.sw_engine_process_mode->setCurrentIndex(1);
  444. ui.tb_engine_driver_config->setEnabled(host.audioDriverForced.isNotEmpty() && ! host.isPlugin);
  445. ui.cb_engine_process_mode_jack->setCurrentIndex(host.nextProcessMode);
  446. if (host.nextProcessMode >= PROCESS_MODE_NON_JACK_PADDING)
  447. ui.cb_engine_process_mode_other->setCurrentIndex(host.nextProcessMode-PROCESS_MODE_NON_JACK_PADDING);
  448. else
  449. ui.cb_engine_process_mode_other->setCurrentIndex(0);
  450. ui.sb_engine_max_params->setValue(static_cast<int>(host.maxParameters));
  451. ui.cb_engine_reset_xruns->setChecked(host.resetXruns);
  452. ui.ch_engine_manage_uis->setChecked(host.manageUIs);
  453. ui.ch_engine_prefer_ui_bridges->setChecked(host.preferUIBridges);
  454. ui.sb_engine_ui_bridges_timeout->setValue(host.uiBridgesTimeout);
  455. ui.ch_engine_force_stereo->setChecked(host.forceStereo || ! ui.ch_engine_force_stereo->isEnabled());
  456. ui.ch_engine_prefer_plugin_bridges->setChecked(host.preferPluginBridges);
  457. ui.ch_exp_export_lv2->setChecked(host.exportLV2);
  458. ui.cb_exp_plugin_bridges->setChecked(host.showPluginBridges);
  459. ui.ch_exp_wine_bridges->setChecked(host.showWineBridges);
  460. // ------------------------------------------------------------------------------------------------------------
  461. // OSC
  462. ui.ch_osc_enable->setChecked(settings.valueBool(CARLA_KEY_OSC_ENABLED,
  463. CARLA_DEFAULT_OSC_ENABLED));
  464. ui.group_osc_tcp_port->setChecked(settings.valueBool(CARLA_KEY_OSC_TCP_PORT_ENABLED,
  465. CARLA_DEFAULT_OSC_TCP_PORT_ENABLED));
  466. ui.group_osc_udp_port->setChecked(settings.valueBool(CARLA_KEY_OSC_UDP_PORT_ENABLED,
  467. CARLA_DEFAULT_OSC_UDP_PORT_ENABLED));
  468. ui.sb_osc_tcp_port_number->setValue(settings.valueIntPositive(CARLA_KEY_OSC_TCP_PORT_NUMBER,
  469. CARLA_DEFAULT_OSC_TCP_PORT_NUMBER));
  470. ui.sb_osc_udp_port_number->setValue(settings.valueIntPositive(CARLA_KEY_OSC_UDP_PORT_NUMBER,
  471. CARLA_DEFAULT_OSC_UDP_PORT_NUMBER));
  472. if (settings.valueBool(CARLA_KEY_OSC_TCP_PORT_RANDOM, CARLA_DEFAULT_OSC_TCP_PORT_RANDOM))
  473. {
  474. ui.rb_osc_tcp_port_specific->setChecked(false);
  475. ui.rb_osc_tcp_port_random->setChecked(true);
  476. }
  477. else
  478. {
  479. ui.rb_osc_tcp_port_random->setChecked(false);
  480. ui.rb_osc_tcp_port_specific->setChecked(true);
  481. }
  482. if (settings.valueBool(CARLA_KEY_OSC_UDP_PORT_RANDOM, CARLA_DEFAULT_OSC_UDP_PORT_RANDOM))
  483. {
  484. ui.rb_osc_udp_port_specific->setChecked(false);
  485. ui.rb_osc_udp_port_random->setChecked(true);
  486. }
  487. else
  488. {
  489. ui.rb_osc_udp_port_random->setChecked(false);
  490. ui.rb_osc_udp_port_specific->setChecked(true);
  491. }
  492. // ------------------------------------------------------------------------------------------------------------
  493. // File Paths
  494. QStringList audioPaths = settings.valueStringList(CARLA_KEY_PATHS_AUDIO, CARLA_DEFAULT_FILE_PATH_AUDIO);
  495. QStringList midiPaths = settings.valueStringList(CARLA_KEY_PATHS_MIDI, CARLA_DEFAULT_FILE_PATH_MIDI);
  496. audioPaths.sort();
  497. midiPaths.sort();
  498. for (const QString& audioPath : audioPaths)
  499. {
  500. if (audioPath.isEmpty()) continue;
  501. ui.lw_files_audio->addItem(audioPath);
  502. }
  503. for (const QString& midiPath : midiPaths)
  504. {
  505. if (midiPath.isEmpty()) continue;
  506. ui.lw_files_midi->addItem(midiPath);
  507. }
  508. // ------------------------------------------------------------------------------------------------------------
  509. // Plugin Paths
  510. QStringList ladspas = settings.valueStringList(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH);
  511. QStringList dssis = settings.valueStringList(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH);
  512. QStringList lv2s = settings.valueStringList(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH);
  513. QStringList vst2s = settings.valueStringList(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH);
  514. QStringList vst3s = settings.valueStringList(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH);
  515. QStringList sf2s = settings.valueStringList(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH);
  516. QStringList sfzs = settings.valueStringList(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH);
  517. ladspas.sort();
  518. dssis.sort();
  519. lv2s.sort();
  520. vst2s.sort();
  521. vst3s.sort();
  522. sf2s.sort();
  523. sfzs.sort();
  524. for (const QString& ladspa : ladspas)
  525. {
  526. if (ladspa.isEmpty()) continue;
  527. ui.lw_ladspa->addItem(ladspa);
  528. }
  529. for (const QString& dssi : dssis)
  530. {
  531. if (dssi.isEmpty()) continue;
  532. ui.lw_dssi->addItem(dssi);
  533. }
  534. for (const QString& lv2 : lv2s)
  535. {
  536. if (lv2.isEmpty()) continue;
  537. ui.lw_lv2->addItem(lv2);
  538. }
  539. for (const QString& vst2 : vst2s)
  540. {
  541. if (vst2.isEmpty()) continue;
  542. ui.lw_vst->addItem(vst2);
  543. }
  544. for (const QString& vst3 : vst3s)
  545. {
  546. if (vst3.isEmpty()) continue;
  547. ui.lw_vst3->addItem(vst3);
  548. }
  549. for (const QString& sf2 : sf2s)
  550. {
  551. if (sf2.isEmpty()) continue;
  552. ui.lw_sf2->addItem(sf2);
  553. }
  554. for (const QString& sfz : sfzs)
  555. {
  556. if (sfz.isEmpty()) continue;
  557. ui.lw_sfz->addItem(sfz);
  558. }
  559. // ------------------------------------------------------------------------------------------------------------
  560. // Wine
  561. ui.le_wine_exec->setText(settings.valueString(CARLA_KEY_WINE_EXECUTABLE,
  562. CARLA_DEFAULT_WINE_EXECUTABLE));
  563. ui.cb_wine_prefix_detect->setChecked(settings.valueBool(CARLA_KEY_WINE_AUTO_PREFIX,
  564. CARLA_DEFAULT_WINE_AUTO_PREFIX));
  565. ui.le_wine_prefix_fallback->setText(settings.valueString(CARLA_KEY_WINE_FALLBACK_PREFIX,
  566. CARLA_DEFAULT_WINE_FALLBACK_PREFIX));
  567. ui.group_wine_realtime->setChecked(settings.valueBool(CARLA_KEY_WINE_RT_PRIO_ENABLED,
  568. CARLA_DEFAULT_WINE_RT_PRIO_ENABLED));
  569. ui.sb_wine_base_prio->setValue(settings.valueIntPositive(CARLA_KEY_WINE_BASE_RT_PRIO,
  570. CARLA_DEFAULT_WINE_BASE_RT_PRIO));
  571. ui.sb_wine_server_prio->setValue(settings.valueIntPositive(CARLA_KEY_WINE_SERVER_RT_PRIO,
  572. CARLA_DEFAULT_WINE_SERVER_RT_PRIO));
  573. // ------------------------------------------------------------------------------------------------------------
  574. // Experimental
  575. ui.ch_exp_jack_apps->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_JACK_APPS,
  576. CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS));
  577. ui.ch_exp_export_lv2->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2,
  578. CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT));
  579. ui.ch_exp_load_lib_global->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL,
  580. CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL));
  581. ui.ch_exp_prevent_bad_behaviour->setChecked(settings.valueBool(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR,
  582. CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR));
  583. }
  584. void saveSettings()
  585. {
  586. {
  587. QSafeSettings settings;
  588. host.experimental = ui.ch_main_experimental->isChecked();
  589. if (! host.experimental)
  590. resetExperimentalSettings();
  591. // --------------------------------------------------------------------------------------------------------
  592. // Main
  593. settings.setValue(CARLA_KEY_MAIN_PROJECT_FOLDER, ui.le_main_proj_folder->text());
  594. settings.setValue(CARLA_KEY_MAIN_CONFIRM_EXIT, ui.ch_main_confirm_exit->isChecked());
  595. settings.setValue(CARLA_KEY_MAIN_USE_PRO_THEME, ui.ch_main_theme_pro->isChecked());
  596. settings.setValue(CARLA_KEY_MAIN_PRO_THEME_COLOR, ui.cb_main_theme_color->currentText());
  597. settings.setValue(CARLA_KEY_MAIN_REFRESH_INTERVAL, ui.sb_main_refresh_interval->value());
  598. // --------------------------------------------------------------------------------------------------------
  599. // Canvas
  600. settings.setValue(CARLA_KEY_CANVAS_THEME, ui.cb_canvas_theme->currentText());
  601. settings.setValue(CARLA_KEY_CANVAS_SIZE, ui.cb_canvas_size->currentText());
  602. settings.setValue(CARLA_KEY_CANVAS_USE_BEZIER_LINES, ui.cb_canvas_bezier_lines->isChecked());
  603. settings.setValue(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, ui.cb_canvas_hide_groups->isChecked());
  604. settings.setValue(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, ui.cb_canvas_auto_select->isChecked());
  605. settings.setValue(CARLA_KEY_CANVAS_EYE_CANDY, ui.cb_canvas_eyecandy->isChecked());
  606. settings.setValue(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, ui.cb_canvas_fancy_eyecandy->isChecked());
  607. settings.setValue(CARLA_KEY_CANVAS_USE_OPENGL, ui.cb_canvas_use_opengl->isChecked());
  608. settings.setValue(CARLA_KEY_CANVAS_HQ_ANTIALIASING, ui.cb_canvas_render_hq_aa->isChecked());
  609. settings.setValue(CARLA_KEY_CANVAS_ANTIALIASING, ui.cb_canvas_render_aa->checkState()); // 0, 1, 2 match their enum variants
  610. settings.setValue(CARLA_KEY_CANVAS_FULL_REPAINTS, ui.cb_canvas_full_repaints->isChecked());
  611. settings.setValue(CARLA_KEY_CANVAS_INLINE_DISPLAYS, ui.cb_canvas_inline_displays->isChecked());
  612. }
  613. // ------------------------------------------------------------------------------------------------------------
  614. QSafeSettings settings("falkTX", "Carla2");
  615. // ------------------------------------------------------------------------------------------------------------
  616. // Main
  617. settings.setValue(CARLA_KEY_MAIN_EXPERIMENTAL, host.experimental);
  618. // ------------------------------------------------------------------------------------------------------------
  619. // Engine
  620. const QCarlaString audioDriver = ui.cb_engine_audio_driver->currentText();
  621. if (audioDriver.isNotEmpty() && host.audioDriverForced.isEmpty() && ! host.isPlugin)
  622. settings.setValue(CARLA_KEY_ENGINE_AUDIO_DRIVER, audioDriver);
  623. if (! host.processModeForced)
  624. {
  625. // engine sends callback if processMode really changes
  626. if (audioDriver == "JACK")
  627. host.nextProcessMode = static_cast<EngineProcessMode>(ui.cb_engine_process_mode_jack->currentIndex());
  628. else
  629. host.nextProcessMode = static_cast<EngineProcessMode>(ui.cb_engine_process_mode_other->currentIndex() + PROCESS_MODE_NON_JACK_PADDING);
  630. settings.setValue(CARLA_KEY_ENGINE_PROCESS_MODE, host.nextProcessMode);
  631. }
  632. host.exportLV2 = ui.ch_exp_export_lv2->isChecked();
  633. host.forceStereo = ui.ch_engine_force_stereo->isChecked();
  634. host.resetXruns = ui.cb_engine_reset_xruns->isChecked();
  635. host.maxParameters = static_cast<uint>(std::max(0, ui.sb_engine_max_params->value()));
  636. host.manageUIs = ui.ch_engine_manage_uis->isChecked();
  637. host.preferPluginBridges = ui.ch_engine_prefer_plugin_bridges->isChecked();
  638. host.preferUIBridges = ui.ch_engine_prefer_ui_bridges->isChecked();
  639. host.showLogs = ui.ch_main_show_logs->isChecked();
  640. host.showPluginBridges = ui.cb_exp_plugin_bridges->isChecked();
  641. host.showWineBridges = ui.ch_exp_wine_bridges->isChecked();
  642. host.uiBridgesTimeout = ui.sb_engine_ui_bridges_timeout->value();
  643. host.uisAlwaysOnTop = ui.ch_engine_uis_always_on_top->isChecked();
  644. if (ui.ch_engine_force_stereo->isEnabled())
  645. settings.setValue(CARLA_KEY_ENGINE_FORCE_STEREO, host.forceStereo);
  646. settings.setValue(CARLA_KEY_MAIN_SHOW_LOGS, host.showLogs);
  647. settings.setValue(CARLA_KEY_ENGINE_MAX_PARAMETERS, host.maxParameters);
  648. settings.setValue(CARLA_KEY_ENGINE_RESET_XRUNS, host.resetXruns);
  649. settings.setValue(CARLA_KEY_ENGINE_MANAGE_UIS, host.manageUIs);
  650. settings.setValue(CARLA_KEY_ENGINE_PREFER_PLUGIN_BRIDGES, host.preferPluginBridges);
  651. settings.setValue(CARLA_KEY_ENGINE_PREFER_UI_BRIDGES, host.preferUIBridges);
  652. settings.setValue(CARLA_KEY_ENGINE_UI_BRIDGES_TIMEOUT, host.uiBridgesTimeout);
  653. settings.setValue(CARLA_KEY_ENGINE_UIS_ALWAYS_ON_TOP, host.uisAlwaysOnTop);
  654. settings.setValue(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2, host.exportLV2);
  655. settings.setValue(CARLA_KEY_EXPERIMENTAL_PLUGIN_BRIDGES, host.showPluginBridges);
  656. settings.setValue(CARLA_KEY_EXPERIMENTAL_WINE_BRIDGES, host.showWineBridges);
  657. // ------------------------------------------------------------------------------------------------------------
  658. // OSC
  659. settings.setValue(CARLA_KEY_OSC_ENABLED, ui.ch_osc_enable->isChecked());
  660. settings.setValue(CARLA_KEY_OSC_TCP_PORT_ENABLED, ui.group_osc_tcp_port->isChecked());
  661. settings.setValue(CARLA_KEY_OSC_UDP_PORT_ENABLED, ui.group_osc_udp_port->isChecked());
  662. settings.setValue(CARLA_KEY_OSC_TCP_PORT_RANDOM, ui.rb_osc_tcp_port_random->isChecked());
  663. settings.setValue(CARLA_KEY_OSC_UDP_PORT_RANDOM, ui.rb_osc_udp_port_random->isChecked());
  664. settings.setValue(CARLA_KEY_OSC_TCP_PORT_NUMBER, ui.sb_osc_tcp_port_number->value());
  665. settings.setValue(CARLA_KEY_OSC_UDP_PORT_NUMBER, ui.sb_osc_udp_port_number->value());
  666. // ------------------------------------------------------------------------------------------------------------
  667. // File Paths
  668. QStringList audioPaths;
  669. QStringList midiPaths;
  670. for (int i=0; i < ui.lw_files_audio->count(); ++i)
  671. audioPaths.append(ui.lw_files_audio->item(i)->text());
  672. for (int i=0; i < ui.lw_files_midi->count(); ++i)
  673. midiPaths.append(ui.lw_files_midi->item(i)->text());
  674. /* TODO
  675. host.set_engine_option(ENGINE_OPTION_FILE_PATH, FILE_AUDIO, splitter.join(audioPaths));
  676. host.set_engine_option(ENGINE_OPTION_FILE_PATH, FILE_MIDI, splitter.join(midiPaths));
  677. */
  678. settings.setValue(CARLA_KEY_PATHS_AUDIO, audioPaths);
  679. settings.setValue(CARLA_KEY_PATHS_MIDI, midiPaths);
  680. // ------------------------------------------------------------------------------------------------------------
  681. // Plugin Paths
  682. QStringList ladspas;
  683. QStringList dssis;
  684. QStringList lv2s;
  685. QStringList vst2s;
  686. QStringList vst3s;
  687. QStringList sf2s;
  688. QStringList sfzs;
  689. for (int i=0; i < ui.lw_ladspa->count(); ++i)
  690. ladspas.append(ui.lw_ladspa->item(i)->text());
  691. for (int i=0; i < ui.lw_dssi->count(); ++i)
  692. dssis.append(ui.lw_dssi->item(i)->text());
  693. for (int i=0; i < ui.lw_lv2->count(); ++i)
  694. lv2s.append(ui.lw_lv2->item(i)->text());
  695. for (int i=0; i < ui.lw_vst->count(); ++i)
  696. vst2s.append(ui.lw_vst->item(i)->text());
  697. for (int i=0; i < ui.lw_vst3->count(); ++i)
  698. vst3s.append(ui.lw_vst3->item(i)->text());
  699. for (int i=0; i < ui.lw_sf2->count(); ++i)
  700. sf2s.append(ui.lw_sf2->item(i)->text());
  701. for (int i=0; i < ui.lw_sfz->count(); ++i)
  702. sfzs.append(ui.lw_sfz->item(i)->text());
  703. /* TODO
  704. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LADSPA, splitter.join(ladspas));
  705. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_DSSI, splitter.join(dssis));
  706. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_LV2, splitter.join(lv2s));
  707. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST2, splitter.join(vst2s));
  708. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_VST3, splitter.join(vst3s));
  709. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SF2, splitter.join(sf2s));
  710. host.set_engine_option(ENGINE_OPTION_PLUGIN_PATH, PLUGIN_SFZ, splitter.join(sfzs));
  711. */
  712. settings.setValue(CARLA_KEY_PATHS_LADSPA, ladspas);
  713. settings.setValue(CARLA_KEY_PATHS_DSSI, dssis);
  714. settings.setValue(CARLA_KEY_PATHS_LV2, lv2s);
  715. settings.setValue(CARLA_KEY_PATHS_VST2, vst2s);
  716. settings.setValue(CARLA_KEY_PATHS_VST3, vst3s);
  717. settings.setValue(CARLA_KEY_PATHS_SF2, sf2s);
  718. settings.setValue(CARLA_KEY_PATHS_SFZ, sfzs);
  719. // ------------------------------------------------------------------------------------------------------------
  720. // Wine
  721. settings.setValue(CARLA_KEY_WINE_EXECUTABLE, ui.le_wine_exec->text());
  722. settings.setValue(CARLA_KEY_WINE_AUTO_PREFIX, ui.cb_wine_prefix_detect->isChecked());
  723. settings.setValue(CARLA_KEY_WINE_FALLBACK_PREFIX, ui.le_wine_prefix_fallback->text());
  724. settings.setValue(CARLA_KEY_WINE_RT_PRIO_ENABLED, ui.group_wine_realtime->isChecked());
  725. settings.setValue(CARLA_KEY_WINE_BASE_RT_PRIO, ui.sb_wine_base_prio->value());
  726. settings.setValue(CARLA_KEY_WINE_SERVER_RT_PRIO, ui.sb_wine_server_prio->value());
  727. // ------------------------------------------------------------------------------------------------------------
  728. // Experimental
  729. settings.setValue(CARLA_KEY_EXPERIMENTAL_JACK_APPS, ui.ch_exp_jack_apps->isChecked());
  730. settings.setValue(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, ui.ch_exp_load_lib_global->isChecked());
  731. settings.setValue(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, ui.ch_exp_prevent_bad_behaviour->isChecked());
  732. }
  733. void resetSettings()
  734. {
  735. switch (ui.lw_page->currentRow())
  736. {
  737. // ------------------------------------------------------------------------------------------------------------
  738. // Main
  739. case TAB_INDEX_MAIN:
  740. ui.le_main_proj_folder->setText(CARLA_DEFAULT_MAIN_PROJECT_FOLDER);
  741. ui.ch_main_theme_pro->setChecked(CARLA_DEFAULT_MAIN_USE_PRO_THEME && ui.group_main_theme->isEnabled());
  742. ui.cb_main_theme_color->setCurrentIndex(ui.cb_main_theme_color->findText(CARLA_DEFAULT_MAIN_PRO_THEME_COLOR));
  743. ui.sb_main_refresh_interval->setValue(CARLA_DEFAULT_MAIN_REFRESH_INTERVAL);
  744. ui.ch_main_confirm_exit->setChecked(CARLA_DEFAULT_MAIN_CONFIRM_EXIT);
  745. ui.ch_main_show_logs->setChecked(CARLA_DEFAULT_MAIN_SHOW_LOGS);
  746. break;
  747. // ------------------------------------------------------------------------------------------------------------
  748. // Canvas
  749. case TAB_INDEX_CANVAS:
  750. ui.cb_canvas_theme->setCurrentIndex(ui.cb_canvas_theme->findText(CARLA_DEFAULT_CANVAS_THEME));
  751. ui.cb_canvas_size->setCurrentIndex(ui.cb_canvas_size->findText(CARLA_DEFAULT_CANVAS_SIZE));
  752. ui.cb_canvas_bezier_lines->setChecked(CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES);
  753. ui.cb_canvas_hide_groups->setChecked(CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS);
  754. ui.cb_canvas_auto_select->setChecked(CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS);
  755. ui.cb_canvas_eyecandy->setChecked(CARLA_DEFAULT_CANVAS_EYE_CANDY);
  756. ui.cb_canvas_render_aa->setCheckState(Qt::PartiallyChecked); // CARLA_DEFAULT_CANVAS_ANTIALIASING
  757. ui.cb_canvas_full_repaints->setChecked(CARLA_DEFAULT_CANVAS_FULL_REPAINTS);
  758. break;
  759. // ------------------------------------------------------------------------------------------------------------
  760. // Engine
  761. case TAB_INDEX_ENGINE:
  762. if (! host.isPlugin)
  763. ui.cb_engine_audio_driver->setCurrentIndex(0);
  764. if (! host.processModeForced)
  765. {
  766. if (ui.cb_engine_audio_driver->currentText() == "JACK")
  767. {
  768. ui.cb_engine_process_mode_jack->setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE);
  769. ui.sw_engine_process_mode->setCurrentIndex(0); // show all modes
  770. }
  771. else
  772. {
  773. ui.cb_engine_process_mode_other->setCurrentIndex(CARLA_DEFAULT_PROCESS_MODE-PROCESS_MODE_NON_JACK_PADDING);
  774. ui.sw_engine_process_mode->setCurrentIndex(1); // hide single+multi client modes
  775. }
  776. }
  777. ui.sb_engine_max_params->setValue(CARLA_DEFAULT_MAX_PARAMETERS);
  778. ui.cb_engine_reset_xruns->setChecked(CARLA_DEFAULT_RESET_XRUNS);
  779. ui.ch_engine_uis_always_on_top->setChecked(CARLA_DEFAULT_UIS_ALWAYS_ON_TOP);
  780. ui.ch_engine_prefer_ui_bridges->setChecked(CARLA_DEFAULT_PREFER_UI_BRIDGES);
  781. ui.sb_engine_ui_bridges_timeout->setValue(CARLA_DEFAULT_UI_BRIDGES_TIMEOUT);
  782. ui.ch_engine_manage_uis->setChecked(CARLA_DEFAULT_MANAGE_UIS);
  783. break;
  784. // ------------------------------------------------------------------------------------------------------------
  785. // OSC
  786. case TAB_INDEX_OSC:
  787. ui.ch_osc_enable->setChecked(CARLA_DEFAULT_OSC_ENABLED);
  788. ui.group_osc_tcp_port->setChecked(CARLA_DEFAULT_OSC_TCP_PORT_ENABLED);
  789. ui.group_osc_udp_port->setChecked(CARLA_DEFAULT_OSC_UDP_PORT_ENABLED);
  790. ui.sb_osc_tcp_port_number->setValue(CARLA_DEFAULT_OSC_TCP_PORT_NUMBER);
  791. ui.sb_osc_udp_port_number->setValue(CARLA_DEFAULT_OSC_UDP_PORT_NUMBER);
  792. if (CARLA_DEFAULT_OSC_TCP_PORT_RANDOM)
  793. {
  794. ui.rb_osc_tcp_port_specific->setChecked(false);
  795. ui.rb_osc_tcp_port_random->setChecked(true);
  796. }
  797. else
  798. {
  799. ui.rb_osc_tcp_port_random->setChecked(false);
  800. ui.rb_osc_tcp_port_specific->setChecked(true);
  801. }
  802. if (CARLA_DEFAULT_OSC_UDP_PORT_RANDOM)
  803. {
  804. ui.rb_osc_udp_port_specific->setChecked(false);
  805. ui.rb_osc_udp_port_random->setChecked(true);
  806. }
  807. else
  808. {
  809. ui.rb_osc_udp_port_random->setChecked(false);
  810. ui.rb_osc_udp_port_specific->setChecked(true);
  811. }
  812. break;
  813. // ------------------------------------------------------------------------------------------------------------
  814. // Plugin Paths
  815. case TAB_INDEX_FILEPATHS:
  816. switch (ui.tw_filepaths->currentIndex())
  817. {
  818. case FILEPATH_INDEX_AUDIO:
  819. ui.lw_files_audio->clear();
  820. break;
  821. case FILEPATH_INDEX_MIDI:
  822. ui.lw_files_midi->clear();
  823. break;
  824. }
  825. break;
  826. // ------------------------------------------------------------------------------------------------------------
  827. // Plugin Paths
  828. case TAB_INDEX_PLUGINPATHS:
  829. {
  830. QStringList paths;
  831. switch (ui.tw_paths->currentIndex())
  832. {
  833. case PLUGINPATH_INDEX_LADSPA:
  834. paths = CARLA_DEFAULT_LADSPA_PATH;
  835. paths.sort();
  836. ui.lw_ladspa->clear();
  837. for (const auto& path : paths)
  838. {
  839. if (path.isEmpty())
  840. continue;
  841. ui.lw_ladspa->addItem(path);
  842. }
  843. break;
  844. case PLUGINPATH_INDEX_DSSI:
  845. paths = CARLA_DEFAULT_DSSI_PATH;
  846. paths.sort();
  847. ui.lw_dssi->clear();
  848. for (const auto& path : paths)
  849. {
  850. if (path.isEmpty())
  851. continue;
  852. ui.lw_dssi->addItem(path);
  853. }
  854. break;
  855. case PLUGINPATH_INDEX_LV2:
  856. paths = CARLA_DEFAULT_LV2_PATH;
  857. paths.sort();
  858. ui.lw_lv2->clear();
  859. for (const auto& path : paths)
  860. {
  861. if (path.isEmpty())
  862. continue;
  863. ui.lw_lv2->addItem(path);
  864. }
  865. break;
  866. case PLUGINPATH_INDEX_VST2:
  867. paths = CARLA_DEFAULT_VST2_PATH;
  868. paths.sort();
  869. ui.lw_vst->clear();
  870. for (const auto& path : paths)
  871. {
  872. if (path.isEmpty())
  873. continue;
  874. ui.lw_vst->addItem(path);
  875. }
  876. break;
  877. case PLUGINPATH_INDEX_VST3:
  878. paths = CARLA_DEFAULT_VST3_PATH;
  879. paths.sort();
  880. ui.lw_vst3->clear();
  881. for (const auto& path : paths)
  882. {
  883. if (path.isEmpty())
  884. continue;
  885. ui.lw_vst3->addItem(path);
  886. }
  887. break;
  888. case PLUGINPATH_INDEX_SF2:
  889. paths = CARLA_DEFAULT_SF2_PATH;
  890. paths.sort();
  891. ui.lw_sf2->clear();
  892. for (const auto& path : paths)
  893. {
  894. if (path.isEmpty())
  895. continue;
  896. ui.lw_sf2->addItem(path);
  897. }
  898. break;
  899. case PLUGINPATH_INDEX_SFZ:
  900. paths = CARLA_DEFAULT_SFZ_PATH;
  901. paths.sort();
  902. ui.lw_sfz->clear();
  903. for (const auto& path : paths)
  904. {
  905. if (path.isEmpty())
  906. continue;
  907. ui.lw_sfz->addItem(path);
  908. }
  909. break;
  910. }
  911. break;
  912. }
  913. // ------------------------------------------------------------------------------------------------------------
  914. // Wine
  915. case TAB_INDEX_WINE:
  916. ui.le_wine_exec->setText(CARLA_DEFAULT_WINE_EXECUTABLE);
  917. ui.cb_wine_prefix_detect->setChecked(CARLA_DEFAULT_WINE_AUTO_PREFIX);
  918. ui.le_wine_prefix_fallback->setText(CARLA_DEFAULT_WINE_FALLBACK_PREFIX);
  919. ui.group_wine_realtime->setChecked(CARLA_DEFAULT_WINE_RT_PRIO_ENABLED);
  920. ui.sb_wine_base_prio->setValue(CARLA_DEFAULT_WINE_BASE_RT_PRIO);
  921. ui.sb_wine_server_prio->setValue(CARLA_DEFAULT_WINE_SERVER_RT_PRIO);
  922. break;
  923. // ------------------------------------------------------------------------------------------------------------
  924. // Experimental
  925. case TAB_INDEX_EXPERIMENTAL:
  926. resetExperimentalSettings();
  927. break;
  928. }
  929. }
  930. void resetExperimentalSettings()
  931. {
  932. // Forever experimental
  933. ui.cb_exp_plugin_bridges->setChecked(CARLA_DEFAULT_EXPERIMENTAL_PLUGIN_BRIDGES);
  934. ui.ch_exp_wine_bridges->setChecked(CARLA_DEFAULT_EXPERIMENTAL_WINE_BRIDGES);
  935. ui.ch_exp_jack_apps->setChecked(CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS);
  936. ui.ch_exp_export_lv2->setChecked(CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT);
  937. ui.ch_exp_load_lib_global->setChecked(CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL);
  938. ui.ch_exp_prevent_bad_behaviour->setChecked(CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR);
  939. // Temporary, until stable
  940. ui.cb_canvas_fancy_eyecandy->setChecked(CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY);
  941. ui.cb_canvas_use_opengl->setChecked(CARLA_DEFAULT_CANVAS_USE_OPENGL and ui.cb_canvas_use_opengl->isEnabled());
  942. ui.cb_canvas_render_hq_aa->setChecked(CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING and ui.cb_canvas_render_hq_aa->isEnabled());
  943. ui.cb_canvas_inline_displays->setChecked(CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS);
  944. ui.ch_engine_force_stereo->setChecked(CARLA_DEFAULT_FORCE_STEREO);
  945. ui.ch_engine_prefer_plugin_bridges->setChecked(CARLA_DEFAULT_PREFER_PLUGIN_BRIDGES);
  946. }
  947. };
  948. CarlaSettingsW::CarlaSettingsW(QWidget* const parent, CarlaHost& host, const bool hasCanvas, const bool hasCanvasGL)
  949. : QDialog(parent),
  950. self(new PrivateData(this, host))
  951. {
  952. // ----------------------------------------------------------------------------------------------------------------
  953. // Set-up GUI
  954. self->ui.lw_page->setFixedWidth(48 + 6*3 + fontMetricsHorizontalAdvance(self->ui.lw_page->fontMetrics(), " Experimental "));
  955. for (uint i=0; i < carla_get_engine_driver_count(); ++i)
  956. self->ui.cb_engine_audio_driver->addItem(carla_get_engine_driver_name(i));
  957. for (uint i=0; i < Theme::THEME_MAX; ++i)
  958. self->ui.cb_canvas_theme->addItem(getThemeName((Theme::List)i));
  959. #ifdef CARLA_OS_MAC
  960. self->ui.group_main_theme->setEnabled(false);
  961. self->ui.group_main_theme->setVisible(false);
  962. #endif
  963. #ifdef CARLA_OS_Win
  964. if (true)
  965. #else
  966. if (host.isControl)
  967. #endif
  968. {
  969. self->ui.ch_main_show_logs->setEnabled(false);
  970. self->ui.ch_main_show_logs->setVisible(false);
  971. }
  972. if (host.isControl)
  973. {
  974. self->ui.lw_page->hideRow(TAB_INDEX_ENGINE);
  975. self->ui.lw_page->hideRow(TAB_INDEX_FILEPATHS);
  976. self->ui.lw_page->hideRow(TAB_INDEX_PLUGINPATHS);
  977. self->ui.ch_exp_export_lv2->hide();
  978. self->ui.group_experimental_engine->hide();
  979. }
  980. else if (! hasCanvas)
  981. {
  982. self->ui.lw_page->hideRow(TAB_INDEX_CANVAS);
  983. }
  984. else if (! hasCanvasGL)
  985. {
  986. self->ui.cb_canvas_use_opengl->setEnabled(false);
  987. self->ui.cb_canvas_render_hq_aa->setEnabled(false);
  988. }
  989. if (host.isPlugin)
  990. self->ui.cb_engine_audio_driver->setEnabled(false);
  991. if (host.audioDriverForced.isNotEmpty())
  992. {
  993. self->ui.cb_engine_audio_driver->setEnabled(false);
  994. self->ui.tb_engine_driver_config->setEnabled(false);
  995. }
  996. if (host.processModeForced)
  997. {
  998. self->ui.cb_engine_process_mode_jack->setEnabled(false);
  999. self->ui.cb_engine_process_mode_other->setEnabled(false);
  1000. if (host.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK)
  1001. self->ui.ch_engine_force_stereo->setEnabled(false);
  1002. }
  1003. if (host.isControl || host.isPlugin)
  1004. {
  1005. self->ui.ch_main_confirm_exit->hide();
  1006. self->ui.ch_exp_load_lib_global->hide();
  1007. self->ui.lw_page->hideRow(TAB_INDEX_OSC);
  1008. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1009. }
  1010. #ifndef CARLA_OS_LINUX
  1011. self->ui.ch_exp_wine_bridges->setVisible(false);
  1012. self->ui.ch_exp_jack_apps->setVisible(false);
  1013. self->ui.ch_exp_prevent_bad_behaviour->setVisible(false);
  1014. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1015. #endif
  1016. #ifndef CARLA_OS_MAC
  1017. self->ui.label_engine_ui_bridges_mac_note->setVisible(false);
  1018. #endif
  1019. // FIXME, not implemented yet
  1020. self->ui.ch_engine_uis_always_on_top->hide();
  1021. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  1022. // ----------------------------------------------------------------------------------------------------------------
  1023. // Load settings
  1024. self->loadSettings();
  1025. // ----------------------------------------------------------------------------------------------------------------
  1026. // Set-up connections
  1027. connect(this, SIGNAL(accepted()), SLOT(slot_saveSettings()));
  1028. connect(self->ui.buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(slot_resetSettings()));
  1029. connect(self->ui.b_main_proj_folder_open, SIGNAL(clicked()), SLOT(slot_getAndSetProjectPath()));
  1030. connect(self->ui.cb_engine_audio_driver, SIGNAL(currentIndexChanged(int)), SLOT(slot_engineAudioDriverChanged()));
  1031. connect(self->ui.tb_engine_driver_config, SIGNAL(clicked()), SLOT(slot_showAudioDriverSettings()));
  1032. connect(self->ui.b_paths_add, SIGNAL(clicked()), SLOT(slot_addPluginPath()));
  1033. connect(self->ui.b_paths_remove, SIGNAL(clicked()), SLOT(slot_removePluginPath()));
  1034. connect(self->ui.b_paths_change, SIGNAL(clicked()), SLOT(slot_changePluginPath()));
  1035. connect(self->ui.cb_paths, SIGNAL(currentIndexChanged(int)), SLOT(slot_pluginPathTabChanged(int)));
  1036. connect(self->ui.lw_ladspa, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1037. connect(self->ui.lw_dssi, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1038. connect(self->ui.lw_lv2, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1039. connect(self->ui.lw_vst, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1040. connect(self->ui.lw_vst3, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1041. connect(self->ui.lw_sf2, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1042. connect(self->ui.lw_sfz, SIGNAL(currentRowChanged(int)), SLOT(slot_pluginPathRowChanged(int)));
  1043. connect(self->ui.b_filepaths_add, SIGNAL(clicked()), SLOT(slot_addFilePath()));
  1044. connect(self->ui.b_filepaths_remove, SIGNAL(clicked()), SLOT(slot_removeFilePath()));
  1045. connect(self->ui.b_filepaths_change, SIGNAL(clicked()), SLOT(slot_changeFilePath()));
  1046. connect(self->ui.cb_filepaths, SIGNAL(currentIndexChanged(int)), SLOT(slot_filePathTabChanged(int)));
  1047. connect(self->ui.lw_files_audio, SIGNAL(currentRowChanged(int)), SLOT(slot_filePathRowChanged(int)));
  1048. connect(self->ui.lw_files_midi, SIGNAL(currentRowChanged(int)), SLOT(slot_filePathRowChanged(int)));
  1049. connect(self->ui.ch_main_experimental, SIGNAL(toggled(bool)), SLOT(slot_enableExperimental(bool)));
  1050. connect(self->ui.ch_exp_wine_bridges, SIGNAL(toggled(bool)), SLOT(slot_enableWineBridges(bool)));
  1051. connect(self->ui.cb_exp_plugin_bridges, SIGNAL(toggled(bool)), SLOT(slot_pluginBridgesToggled(bool)));
  1052. connect(self->ui.cb_canvas_eyecandy, SIGNAL(toggled(bool)), SLOT(slot_canvasEyeCandyToggled(bool)));
  1053. connect(self->ui.cb_canvas_fancy_eyecandy, SIGNAL(toggled(bool)), SLOT(slot_canvasFancyEyeCandyToggled(bool)));
  1054. connect(self->ui.cb_canvas_use_opengl, SIGNAL(toggled(bool)), SLOT(slot_canvasOpenGLToggled(bool)));
  1055. // ----------------------------------------------------------------------------------------------------------------
  1056. // Post-connect setup
  1057. self->ui.lw_ladspa->setCurrentRow(0);
  1058. self->ui.lw_dssi->setCurrentRow(0);
  1059. self->ui.lw_lv2->setCurrentRow(0);
  1060. self->ui.lw_vst->setCurrentRow(0);
  1061. self->ui.lw_vst3->setCurrentRow(0);
  1062. self->ui.lw_sf2->setCurrentRow(0);
  1063. self->ui.lw_sfz->setCurrentRow(0);
  1064. self->ui.lw_files_audio->setCurrentRow(0);
  1065. self->ui.lw_files_midi->setCurrentRow(0);
  1066. self->ui.lw_page->setCurrentCell(0, 0);
  1067. slot_filePathTabChanged(0);
  1068. slot_pluginPathTabChanged(0);
  1069. adjustSize();
  1070. }
  1071. CarlaSettingsW::~CarlaSettingsW()
  1072. {
  1073. delete self;
  1074. }
  1075. // --------------------------------------------------------------------------------------------------------------------
  1076. void CarlaSettingsW::slot_saveSettings()
  1077. {
  1078. self->saveSettings();
  1079. }
  1080. void CarlaSettingsW::slot_resetSettings()
  1081. {
  1082. self->resetSettings();
  1083. }
  1084. // --------------------------------------------------------------------------------------------------------------------
  1085. void CarlaSettingsW::slot_enableExperimental(const bool toggled)
  1086. {
  1087. if (toggled)
  1088. {
  1089. self->ui.lw_page->showRow(TAB_INDEX_EXPERIMENTAL);
  1090. if (self->ui.ch_exp_wine_bridges->isChecked() and not self->host.isControl)
  1091. self->ui.lw_page->showRow(TAB_INDEX_WINE);
  1092. }
  1093. else
  1094. {
  1095. self->ui.lw_page->hideRow(TAB_INDEX_EXPERIMENTAL);
  1096. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1097. }
  1098. }
  1099. void CarlaSettingsW::slot_enableWineBridges(const bool toggled)
  1100. {
  1101. if (toggled && ! self->host.isControl)
  1102. self->ui.lw_page->showRow(TAB_INDEX_WINE);
  1103. else
  1104. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1105. }
  1106. void CarlaSettingsW::slot_pluginBridgesToggled(const bool toggled)
  1107. {
  1108. if (! toggled)
  1109. {
  1110. self->ui.ch_exp_wine_bridges->setChecked(false);
  1111. self->ui.ch_engine_prefer_plugin_bridges->setChecked(false);
  1112. self->ui.lw_page->hideRow(TAB_INDEX_WINE);
  1113. }
  1114. }
  1115. void CarlaSettingsW::slot_canvasEyeCandyToggled(const bool toggled)
  1116. {
  1117. if (! toggled)
  1118. {
  1119. // disable fancy eyecandy too
  1120. self->ui.cb_canvas_fancy_eyecandy->setChecked(false);
  1121. }
  1122. }
  1123. void CarlaSettingsW::slot_canvasFancyEyeCandyToggled(const bool toggled)
  1124. {
  1125. if (! toggled)
  1126. {
  1127. // make sure normal eyecandy is enabled too
  1128. self->ui.cb_canvas_eyecandy->setChecked(true);
  1129. }
  1130. }
  1131. void CarlaSettingsW::slot_canvasOpenGLToggled(const bool toggled)
  1132. {
  1133. if (! toggled)
  1134. {
  1135. // uncheck GL specific option
  1136. self->ui.cb_canvas_render_hq_aa->setChecked(false);
  1137. }
  1138. }
  1139. // --------------------------------------------------------------------------------------------------------------------
  1140. void CarlaSettingsW::slot_getAndSetProjectPath()
  1141. {
  1142. // FIXME?
  1143. getAndSetPath(this, self->ui.le_main_proj_folder);
  1144. }
  1145. // --------------------------------------------------------------------------------------------------------------------
  1146. void CarlaSettingsW::slot_engineAudioDriverChanged()
  1147. {
  1148. if (self->ui.cb_engine_audio_driver->currentText() == "JACK")
  1149. self->ui.sw_engine_process_mode->setCurrentIndex(0);
  1150. else
  1151. self->ui.sw_engine_process_mode->setCurrentIndex(1);
  1152. }
  1153. void CarlaSettingsW::slot_showAudioDriverSettings()
  1154. {
  1155. const int driverIndex = self->ui.cb_engine_audio_driver->currentIndex();
  1156. const QString driverName = self->ui.cb_engine_audio_driver->currentText();
  1157. CARLA_SAFE_ASSERT_RETURN(driverIndex >= 0,);
  1158. DriverSettingsW(this, static_cast<uint>(driverIndex), driverName).exec();
  1159. }
  1160. // --------------------------------------------------------------------------------------------------------------------
  1161. void CarlaSettingsW::slot_addPluginPath()
  1162. {
  1163. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), "", QFileDialog::ShowDirsOnly);
  1164. if (newPath.isEmpty())
  1165. return;
  1166. switch (self->ui.tw_paths->currentIndex())
  1167. {
  1168. case PLUGINPATH_INDEX_LADSPA:
  1169. self->ui.lw_ladspa->addItem(newPath);
  1170. break;
  1171. case PLUGINPATH_INDEX_DSSI:
  1172. self->ui.lw_dssi->addItem(newPath);
  1173. break;
  1174. case PLUGINPATH_INDEX_LV2:
  1175. self->ui.lw_lv2->addItem(newPath);
  1176. break;
  1177. case PLUGINPATH_INDEX_VST2:
  1178. self->ui.lw_vst->addItem(newPath);
  1179. break;
  1180. case PLUGINPATH_INDEX_VST3:
  1181. self->ui.lw_vst3->addItem(newPath);
  1182. break;
  1183. case PLUGINPATH_INDEX_SF2:
  1184. self->ui.lw_sf2->addItem(newPath);
  1185. break;
  1186. case PLUGINPATH_INDEX_SFZ:
  1187. self->ui.lw_sfz->addItem(newPath);
  1188. break;
  1189. }
  1190. }
  1191. void CarlaSettingsW::slot_removePluginPath()
  1192. {
  1193. switch (self->ui.tw_paths->currentIndex())
  1194. {
  1195. case PLUGINPATH_INDEX_LADSPA:
  1196. self->ui.lw_ladspa->takeItem(self->ui.lw_ladspa->currentRow());
  1197. break;
  1198. case PLUGINPATH_INDEX_DSSI:
  1199. self->ui.lw_dssi->takeItem(self->ui.lw_dssi->currentRow());
  1200. break;
  1201. case PLUGINPATH_INDEX_LV2:
  1202. self->ui.lw_lv2->takeItem(self->ui.lw_lv2->currentRow());
  1203. break;
  1204. case PLUGINPATH_INDEX_VST2:
  1205. self->ui.lw_vst->takeItem(self->ui.lw_vst->currentRow());
  1206. break;
  1207. case PLUGINPATH_INDEX_VST3:
  1208. self->ui.lw_vst3->takeItem(self->ui.lw_vst3->currentRow());
  1209. break;
  1210. case PLUGINPATH_INDEX_SF2:
  1211. self->ui.lw_sf2->takeItem(self->ui.lw_sf2->currentRow());
  1212. break;
  1213. case PLUGINPATH_INDEX_SFZ:
  1214. self->ui.lw_sfz->takeItem(self->ui.lw_sfz->currentRow());
  1215. break;
  1216. }
  1217. }
  1218. void CarlaSettingsW::slot_changePluginPath()
  1219. {
  1220. const int curIndex = self->ui.tw_paths->currentIndex();
  1221. QString currentPath;
  1222. switch (curIndex)
  1223. {
  1224. case PLUGINPATH_INDEX_LADSPA:
  1225. currentPath = self->ui.lw_ladspa->currentItem()->text();
  1226. break;
  1227. case PLUGINPATH_INDEX_DSSI:
  1228. currentPath = self->ui.lw_dssi->currentItem()->text();
  1229. break;
  1230. case PLUGINPATH_INDEX_LV2:
  1231. currentPath = self->ui.lw_lv2->currentItem()->text();
  1232. break;
  1233. case PLUGINPATH_INDEX_VST2:
  1234. currentPath = self->ui.lw_vst->currentItem()->text();
  1235. break;
  1236. case PLUGINPATH_INDEX_VST3:
  1237. currentPath = self->ui.lw_vst3->currentItem()->text();
  1238. break;
  1239. case PLUGINPATH_INDEX_SF2:
  1240. currentPath = self->ui.lw_sf2->currentItem()->text();
  1241. break;
  1242. case PLUGINPATH_INDEX_SFZ:
  1243. currentPath = self->ui.lw_sfz->currentItem()->text();
  1244. break;
  1245. }
  1246. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), currentPath, QFileDialog::ShowDirsOnly);
  1247. if (newPath.isEmpty())
  1248. return;
  1249. switch (curIndex)
  1250. {
  1251. case PLUGINPATH_INDEX_LADSPA:
  1252. self->ui.lw_ladspa->currentItem()->setText(newPath);
  1253. break;
  1254. case PLUGINPATH_INDEX_DSSI:
  1255. self->ui.lw_dssi->currentItem()->setText(newPath);
  1256. break;
  1257. case PLUGINPATH_INDEX_LV2:
  1258. self->ui.lw_lv2->currentItem()->setText(newPath);
  1259. break;
  1260. case PLUGINPATH_INDEX_VST2:
  1261. self->ui.lw_vst->currentItem()->setText(newPath);
  1262. break;
  1263. case PLUGINPATH_INDEX_VST3:
  1264. self->ui.lw_vst3->currentItem()->setText(newPath);
  1265. break;
  1266. case PLUGINPATH_INDEX_SF2:
  1267. self->ui.lw_sf2->currentItem()->setText(newPath);
  1268. break;
  1269. case PLUGINPATH_INDEX_SFZ:
  1270. self->ui.lw_sfz->currentItem()->setText(newPath);
  1271. break;
  1272. }
  1273. }
  1274. // --------------------------------------------------------------------------------------------------------------------
  1275. void CarlaSettingsW::slot_pluginPathTabChanged(const int index)
  1276. {
  1277. int row;
  1278. switch (index)
  1279. {
  1280. case PLUGINPATH_INDEX_LADSPA:
  1281. row = self->ui.lw_ladspa->currentRow();
  1282. break;
  1283. case PLUGINPATH_INDEX_DSSI:
  1284. row = self->ui.lw_dssi->currentRow();
  1285. break;
  1286. case PLUGINPATH_INDEX_LV2:
  1287. row = self->ui.lw_lv2->currentRow();
  1288. break;
  1289. case PLUGINPATH_INDEX_VST2:
  1290. row = self->ui.lw_vst->currentRow();
  1291. break;
  1292. case PLUGINPATH_INDEX_VST3:
  1293. row = self->ui.lw_vst3->currentRow();
  1294. break;
  1295. case PLUGINPATH_INDEX_SF2:
  1296. row = self->ui.lw_sf2->currentRow();
  1297. break;
  1298. case PLUGINPATH_INDEX_SFZ:
  1299. row = self->ui.lw_sfz->currentRow();
  1300. break;
  1301. default:
  1302. row = -1;
  1303. break;
  1304. }
  1305. slot_pluginPathRowChanged(row);
  1306. }
  1307. void CarlaSettingsW::slot_pluginPathRowChanged(const int row)
  1308. {
  1309. const bool check = bool(row >= 0);
  1310. self->ui.b_paths_remove->setEnabled(check);
  1311. self->ui.b_paths_change->setEnabled(check);
  1312. }
  1313. // --------------------------------------------------------------------------------------------------------------------
  1314. void CarlaSettingsW::slot_addFilePath()
  1315. {
  1316. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), "", QFileDialog::ShowDirsOnly);
  1317. if (newPath.isEmpty())
  1318. return;
  1319. switch (self->ui.tw_filepaths->currentIndex())
  1320. {
  1321. case FILEPATH_INDEX_AUDIO:
  1322. self->ui.lw_files_audio->addItem(newPath);
  1323. break;
  1324. case FILEPATH_INDEX_MIDI:
  1325. self->ui.lw_files_midi->addItem(newPath);
  1326. break;
  1327. }
  1328. }
  1329. void CarlaSettingsW::slot_removeFilePath()
  1330. {
  1331. switch (self->ui.tw_filepaths->currentIndex())
  1332. {
  1333. case FILEPATH_INDEX_AUDIO:
  1334. self->ui.lw_files_audio->takeItem(self->ui.lw_files_audio->currentRow());
  1335. break;
  1336. case FILEPATH_INDEX_MIDI:
  1337. self->ui.lw_files_midi->takeItem(self->ui.lw_files_midi->currentRow());
  1338. break;
  1339. }
  1340. }
  1341. void CarlaSettingsW::slot_changeFilePath()
  1342. {
  1343. const int curIndex = self->ui.tw_filepaths->currentIndex();
  1344. QString currentPath;
  1345. switch (curIndex)
  1346. {
  1347. case FILEPATH_INDEX_AUDIO:
  1348. currentPath = self->ui.lw_files_audio->currentItem()->text();
  1349. break;
  1350. case FILEPATH_INDEX_MIDI:
  1351. currentPath = self->ui.lw_files_midi->currentItem()->text();
  1352. break;
  1353. }
  1354. const QString newPath = QFileDialog::getExistingDirectory(this, tr("Add Path"), currentPath, QFileDialog::ShowDirsOnly);
  1355. if (newPath.isEmpty())
  1356. return;
  1357. switch (curIndex)
  1358. {
  1359. case FILEPATH_INDEX_AUDIO:
  1360. self->ui.lw_files_audio->currentItem()->setText(newPath);
  1361. break;
  1362. case FILEPATH_INDEX_MIDI:
  1363. self->ui.lw_files_midi->currentItem()->setText(newPath);
  1364. break;
  1365. }
  1366. }
  1367. // --------------------------------------------------------------------------------------------------------------------
  1368. void CarlaSettingsW::slot_filePathTabChanged(const int index)
  1369. {
  1370. int row;
  1371. switch (index)
  1372. {
  1373. case FILEPATH_INDEX_AUDIO:
  1374. row = self->ui.lw_files_audio->currentRow();
  1375. break;
  1376. case FILEPATH_INDEX_MIDI:
  1377. row = self->ui.lw_files_midi->currentRow();
  1378. break;
  1379. default:
  1380. row = -1;
  1381. break;
  1382. }
  1383. slot_filePathRowChanged(row);
  1384. }
  1385. void CarlaSettingsW::slot_filePathRowChanged(const int row)
  1386. {
  1387. const bool check = bool(row >= 0);
  1388. self->ui.b_filepaths_remove->setEnabled(check);
  1389. self->ui.b_filepaths_change->setEnabled(check);
  1390. }
  1391. // --------------------------------------------------------------------------------------------------------------------