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.

carla_settings.cpp 66KB

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