| 1 | |
| 2 | /* |
| 3 | Copyright (C) 2008, 2009 Andres Cabrera |
| 4 | [email protected] |
| 5 | |
| 6 | This file is part of CsoundQt. |
| 7 | |
| 8 | CsoundQt is free software; you can redistribute it |
| 9 | and/or modify it under the terms of the GNU Lesser General Public |
| 10 | License as published by the Free Software Foundation; either |
| 11 | version 2.1 of the License, or (at your option) any later version. |
| 12 | |
| 13 | CsoundQt is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU Lesser General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU Lesser General Public |
| 19 | License along with Csound; if not, write to the Free Software |
| 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 21 | 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <QDir> |
| 25 | //#include <QOperatingSystemVersion> // not present before Qt 5.9 |
| 26 | #include <QSysInfo> |
| 27 | |
| 28 | #include "qutecsound.h" |
| 29 | #include "configdialog.h" |
| 30 | #include "options.h" |
| 31 | #include "types.h" |
| 32 | #include "configlists.h" |
| 33 | |
| 34 | |
| 35 | typedef QPair<QString, QString> QStringPair; |
| 36 | |
| 37 | #ifdef QCS_RTMIDI |
| 38 | #include "RtMidi.h" |
| 39 | #endif |
| 40 | |
| 41 | ConfigDialog::ConfigDialog(CsoundQt *parent, Options *options, ConfigLists *configlists) |
| 42 | : QDialog(parent), m_parent(parent), m_options(options), m_configlists(configlists) |
| 43 | { |
| 44 | setupUi(this); |
| 45 | // don't expand over screen, leave some room for panels |
| 46 | setMaximumSize(QApplication::desktop()->width() * 0.9, |
| 47 | QApplication::desktop()->height() * 0.9); |
| 48 | |
| 49 | m_configlists->refreshModules(); |
| 50 | |
| 51 | if(m_configlists->rtAudioNames.size() == 1) { |
| 52 | QMessageBox::warning(this, tr("No Audio Modules"), |
| 53 | tr("No real-time audio modules were found.\n" |
| 54 | "Make sure OPCODE6DIR64 is set properly in your system" |
| 55 | "or the configuration dialog.")); |
| 56 | } |
| 57 | QHash<QString, QString> audioModNames; |
| 58 | audioModNames["pa_cb"] = "portaudio (callback)"; |
| 59 | audioModNames["pa_bl"] = "portaudio (blocking)"; |
| 60 | audioModNames["auhal"] = "coreaudio (auhal)"; |
| 61 | |
| 62 | QHash<QString, int> audioPriorities; |
| 63 | audioPriorities["jack"] = 0; |
| 64 | audioPriorities["pa_cb"] = 1; |
| 65 | audioPriorities["auhal"] = 2; |
| 66 | std::sort(m_configlists->rtAudioNames.begin(), |
| 67 | m_configlists->rtAudioNames.end(), |
| 68 | [&audioPriorities](const QString &mod1, const QString &mod2) { |
| 69 | return audioPriorities.value(mod1, 10) < audioPriorities.value(mod2, 10); |
| 70 | }); |
| 71 | |
| 72 | if(m_configlists->rtAudioNames.contains("jack")) { |
| 73 | if(!m_configlists->isJackRunning()) { |
| 74 | audioModNames["jack"] = "jack (not running)"; |
| 75 | JackNameLineEdit->setEnabled(false); |
| 76 | } |
| 77 | } else { |
| 78 | if(RtUseOptionsCheckBox->checkState() == Qt::Checked) |
| 79 | JackNameLineEdit->setEnabled(false); |
| 80 | } |
| 81 | foreach (QString item, m_configlists->fileTypeLongNames) { |
| 82 | FileTypeComboBox->addItem(item); |
| 83 | } |
| 84 | foreach (QString item, m_configlists->fileFormatNames) { |
| 85 | FileFormatComboBox->addItem(item); |
| 86 | } |
| 87 | foreach (QString item, m_configlists->rtAudioNames) { |
| 88 | if (audioModNames.contains(item)) { |
| 89 | RtModuleComboBox->addItem(audioModNames[item], item); |
| 90 | } else { |
| 91 | RtModuleComboBox->addItem(item, item); |
| 92 | } |
| 93 | } |
| 94 | foreach (QString item, m_configlists->rtMidiNames) { |
| 95 | RtMidiModuleComboBox->addItem(item, item); |
| 96 | } |
| 97 | for (int i = 0; i < m_configlists->languages.size(); i++) { |
| 98 | languageComboBox->addItem(m_configlists->languages[i], |
| 99 | QVariant(m_configlists->languageCodes[i])); |
| 100 | } |
| 101 | midiInterfaceComboBox->clear(); |
| 102 | midiOutInterfaceComboBox->clear(); |
| 103 | |
| 104 | #ifdef QCS_RTMIDI |
| 105 | try { |
| 106 | RtMidiIn midiin((RtMidi::Api) m_options->rtMidiApi); // later: should be possible also with other APIs UNIX_JACK etc |
| 107 | for (int i = 0; i < (int) midiin.getPortCount(); i++) { |
| 108 | midiInterfaceComboBox->addItem(QString::fromStdString(midiin.getPortName(i)), QVariant(i)); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | #ifdef QCS_OLD_RTMIDI |
| 113 | catch (RtError &error) { |
| 114 | #else |
| 115 | catch (RtMidiError &error) { |
| 116 | #endif |
| 117 | // Handle the exception here |
| 118 | error.printMessage(); |
| 119 | } |
| 120 | try { |
| 121 | RtMidiOut midiout((RtMidi::Api) m_options->rtMidiApi); |
| 122 | for (int i = 0; i < (int) midiout.getPortCount(); i++) { |
| 123 | midiOutInterfaceComboBox->addItem(QString::fromStdString(midiout.getPortName(i)), QVariant(i)); |
| 124 | } |
| 125 | } |
| 126 | #ifdef QCS_OLD_RTMIDI |
| 127 | catch (RtError &error) { |
| 128 | #else |
| 129 | catch (RtMidiError &error) { |
| 130 | #endif |
| 131 | // Handle the exception here |
| 132 | error.printMessage(); |
| 133 | } |
| 134 | #else |
| 135 | midiInterfaceComboBox->addItem(tr("No RtMidi support")); |
| 136 | #endif |
| 137 | |
| 138 | midiInterfaceComboBox->addItem(QString(tr("None", "No MIDI In interface")), QVariant(9999)); |
| 139 | //match interface by nameby name, not by index |
| 140 | int ifIndex = midiInterfaceComboBox->findText(m_options->midiInterfaceName); |
| 141 | if (ifIndex>=0) { |
| 142 | midiInterfaceComboBox->setCurrentIndex(ifIndex); |
| 143 | } else { |
| 144 | qDebug()<< m_options->midiInterfaceName << "not found. Setting MIDI In to None"; |
| 145 | // set to none if not found |
| 146 | midiInterfaceComboBox->setCurrentIndex(midiInterfaceComboBox->findData(9999)); |
| 147 | } |
| 148 | midiOutInterfaceComboBox->addItem(QString(tr(" None", "No MIDI Out interface")), QVariant(9999)); |
| 149 | |
| 150 | ifIndex = midiOutInterfaceComboBox->findText(m_options->midiOutInterfaceName); |
| 151 | if (ifIndex>=0) { |
| 152 | midiOutInterfaceComboBox->setCurrentIndex(ifIndex); |
| 153 | } else { |
| 154 | qDebug()<< m_options->midiOutInterfaceName << " not found. Setting MIDI Out to None"; |
| 155 | midiOutInterfaceComboBox->setCurrentIndex(midiOutInterfaceComboBox->findData(9999)); |
| 156 | } |
| 157 | |
| 158 | themeComboBox->setCurrentIndex(themeComboBox->findText(m_options->theme)); |
| 159 | fontComboBox->setCurrentIndex(fontComboBox->findText(m_options->font) ); |
| 160 | fontSizeComboBox->setCurrentIndex(fontSizeComboBox->findText(QString::number((int) m_options->fontPointSize))); |
| 161 | lineNumbersCheckBox->setChecked(m_options->showLineNumberArea); |
| 162 | |
| 163 | lineEndingComboBox->setCurrentIndex(m_options->lineEnding); |
| 164 | consoleFontComboBox->setCurrentIndex(consoleFontComboBox->findText(m_options->consoleFont) ); |
| 165 | consoleFontSizeComboBox->setCurrentIndex(consoleFontSizeComboBox->findText(QString::number((int) m_options->consoleFontPointSize))); |
| 166 | QPixmap pixmap(64,64); |
| 167 | pixmap.fill(m_options->consoleFontColor); |
| 168 | consoleFontColorPushButton->setIcon(pixmap); |
| 169 | QPalette palette(m_options->consoleFontColor); |
| 170 | consoleFontColorPushButton->setPalette(palette); |
| 171 | |
| 172 | pixmap.fill(m_options->consoleBgColor); |
| 173 | consoleBgColorPushButton->setIcon(pixmap); |
| 174 | palette = QPalette(m_options->consoleBgColor); |
| 175 | consoleBgColorPushButton->setPalette(palette); |
| 176 | |
| 177 | pixmap.fill(m_options->editorBgColor); |
| 178 | // editorBgColorButton->setIcon(pixmap); |
| 179 | palette = QPalette(m_options->editorBgColor); |
| 180 | // editorBgColorButton->setPalette(palette); |
| 181 | |
| 182 | tabWidthSpinBox->setValue(m_options->tabWidth); |
| 183 | tabIndentCheckBox->setChecked(m_options->tabIndents); |
| 184 | highlightingThemeComboBox->setCurrentText(m_options->highlightingTheme); |
| 185 | autoplayCheckBox->setChecked(m_options->autoPlay); |
| 186 | autoJoinCheckBox->setChecked(m_options->autoJoin); |
| 187 | menusDepthSpinBox->setValue(m_options->menuDepth); |
| 188 | saveChangesCheckBox->setChecked(m_options->saveChanges); |
| 189 | askIfTemporaryCheckBox->setChecked(m_options->askIfTemporary); |
| 190 | rememberFileCheckBox->setChecked(m_options->rememberFile); |
| 191 | saveWidgetsCheckBox->setChecked(m_options->saveWidgets); |
| 192 | widgetsIndependentCheckBox->setChecked(m_options->widgetsIndependent); |
| 193 | iconTextCheckBox->setChecked(m_options->iconText); |
| 194 | toolbarCheckBox->setChecked(m_options->showToolbar); |
| 195 | lockToolbarCheckBox->setChecked(m_options->lockToolbar); |
| 196 | toolbarIconSizeSpinBox->setValue(m_options->toolbarIconSize); |
| 197 | wrapLinesCheckBox->setChecked(m_options->wrapLines); |
| 198 | autoCompleteCheckBox->setChecked(m_options->autoComplete); |
| 199 | autoCompleteDelaySpinBox->setValue(m_options->autoCompleteDelay); |
| 200 | |
| 201 | autoParameterModeCheckBox->setChecked(m_options->autoParameterMode); |
| 202 | widgetsCheckBox->setChecked(m_options->enableWidgets); |
| 203 | midiCcToCurrentPageOnlyCheckBox->setChecked(m_options->midiCcToCurrentPageOnly); |
| 204 | showWidgetsOnRunCheckBox->setChecked(m_options->showWidgetsOnRun); |
| 205 | showTooltipsCheckBox->setChecked(m_options->showTooltips); |
| 206 | graphUpdateRateSpinBox->setValue(m_options->graphUpdateRate); |
| 207 | enableFLTKCheckBox->setChecked(m_options->enableFLTK); |
| 208 | terminalFLTKCheckBox->setChecked(m_options->terminalFLTK); |
| 209 | terminalFLTKCheckBox->setEnabled(m_options->enableFLTK); |
| 210 | oldFormatCheckBox->setChecked(m_options->oldFormat); |
| 211 | openPropertiesCheckBox->setChecked(m_options->openProperties); |
| 212 | fontScalingSpinBox->setValue(m_options->fontScaling); |
| 213 | fontOffsetSpinBox->setValue(m_options->fontOffset); |
| 214 | tabShortcutActiveCheckBox->setChecked(m_options->tabShortcutActive); |
| 215 | highlightScoreCheckBox->setChecked(m_options->highlightScore); |
| 216 | |
| 217 | if (m_options->useAPI) |
| 218 | ApiRadioButton->setChecked(true); |
| 219 | else |
| 220 | ExternalRadioButton->setChecked(true); |
| 221 | |
| 222 | noMessagesCheckBox->setChecked(m_options->noMessages); |
| 223 | noBufferCheckBox->setChecked(m_options->noBuffer); |
| 224 | noPythonCheckBox->setChecked(m_options->noPython); |
| 225 | noEventsCheckBox->setChecked(m_options->noEvents); |
| 226 | |
| 227 | // threadCheckBox->setChecked(m_options->thread); |
| 228 | // threadCheckBox->setEnabled(ApiRadioButton->isChecked()); |
| 229 | keyRepeatCheckBox->setChecked(m_options->keyRepeat); |
| 230 | debugLiveEventsCheckBox->setChecked(m_options->debugLiveEvents); |
| 231 | int bufferIndex = consoleBufferComboBox->findText(QString::number(m_options->consoleBufferSize)); |
| 232 | if (bufferIndex < 0) { |
| 233 | bufferIndex = consoleBufferComboBox->count() - 1; |
| 234 | } |
| 235 | consoleBufferComboBox->setCurrentIndex(bufferIndex); |
| 236 | |
| 237 | checkSyntaxBeforeRunCheckBox->setChecked(m_options->checkSyntaxBeforeRun); |
| 238 | |
| 239 | BufferSizeLineEdit->setText(QString::number(m_options->bufferSize)); |
| 240 | BufferSizeCheckBox->setChecked(m_options->bufferSizeActive); |
| 241 | BufferSizeLineEdit->setEnabled(m_options->bufferSizeActive); |
| 242 | HwBufferSizeLineEdit->setText(QString::number(m_options->HwBufferSize)); |
| 243 | HwBufferSizeCheckBox->setChecked(m_options->HwBufferSizeActive); |
| 244 | HwBufferSizeLineEdit->setEnabled(m_options->HwBufferSizeActive); |
| 245 | // DitherCheckBox->setChecked(m_options->dither); |
| 246 | // newParserCheckBox->setChecked(m_options->newParser); |
| 247 | multicoreCheckBox->setChecked(m_options->multicore); |
| 248 | numThreadsSpinBox->setValue(m_options->numThreads); |
| 249 | AdditionalFlagsCheckBox->setChecked(m_options->additionalFlagsActive); |
| 250 | AdditionalFlagsLineEdit->setText(m_options->additionalFlags); |
| 251 | AdditionalFlagsLineEdit->setEnabled(m_options->additionalFlagsActive); |
| 252 | FileUseOptionsCheckBox->setChecked(m_options->fileUseOptions); |
| 253 | FileOverrideCheckBox->setChecked(m_options->fileOverrideOptions); |
| 254 | AskFilenameCheckBox->setChecked(m_options->fileAskFilename); |
| 255 | FilePlayFinishedCheckBox->setChecked(m_options->filePlayFinished); |
| 256 | FileTypeComboBox->setCurrentIndex(m_options->fileFileType); |
| 257 | FileFormatComboBox->setCurrentIndex(m_options->fileSampleFormat); |
| 258 | InputFilenameCheckBox->setChecked(m_options->fileInputFilenameActive); |
| 259 | InputFilenameLineEdit->setText(m_options->fileInputFilename); |
| 260 | InputFilenameLineEdit->setEnabled(m_options->fileInputFilenameActive); |
| 261 | OutputFilenameCheckBox->setChecked(m_options->fileOutputFilenameActive); |
| 262 | OutputFilenameLineEdit->setText(m_options->fileOutputFilename); |
| 263 | OutputFilenameLineEdit->setEnabled(m_options->fileOutputFilenameActive); |
| 264 | RtUseOptionsCheckBox->setChecked(m_options->rtUseOptions); |
| 265 | RtOverrideCheckBox->setChecked(m_options->rtOverrideOptions); |
| 266 | int index = RtModuleComboBox->findData(m_options->rtAudioModule); |
| 267 | if (index < 0 || index >= RtModuleComboBox->count()) { |
| 268 | index = 0; |
| 269 | } |
| 270 | RtModuleComboBox->setCurrentIndex(index); |
| 271 | connect(RtModuleComboBox, SIGNAL(currentIndexChanged(int)), |
| 272 | this, SLOT(onRtModuleComboBoxChanged(int)) ); |
| 273 | |
| 274 | RtInputLineEdit->setText(m_options->rtInputDevice); |
| 275 | RtOutputLineEdit->setText(m_options->rtOutputDevice); |
| 276 | // useSystemSamplerateCheckBox->setChecked(m_options->useSystemSamplerate); |
| 277 | |
| 278 | if(m_options->useSystemSamplerate) { |
| 279 | if(RtModuleComboBox->currentText() == "pulse") { |
| 280 | // pulseaudio backend has no system sample rate, so we default to the orchestra |
| 281 | samplerateComboBox->setCurrentText("Orchestra"); |
| 282 | } else { |
| 283 | samplerateComboBox->setCurrentText("System"); |
| 284 | } |
| 285 | } else if (m_options->samplerate == 0) { |
| 286 | samplerateComboBox->setCurrentText("Orchestra"); |
| 287 | } else { |
| 288 | samplerateComboBox->setCurrentText(QString::number(m_options->samplerate)); |
| 289 | } |
| 290 | |
| 291 | numChannelsCheckBox->setChecked(m_options->overrideNumChannels); |
| 292 | numChannelsSpinBox->setValue(m_options->numChannels); |
| 293 | numChannelsSpinBox->setMinimum(1); |
| 294 | numChannelsSpinBox->setMaximum(64); |
| 295 | |
| 296 | numInputChannelsSpinBox->setValue(m_options->numInputChannels); |
| 297 | numInputChannelsSpinBox->setMinimum(1); |
| 298 | numInputChannelsSpinBox->setMaximum(64); |
| 299 | |
| 300 | realtimeCheckBox->setChecked(m_options->realtimeFlag); |
| 301 | sampleAccurateCheckBox->setChecked(m_options->sampleAccurateFlag); |
| 302 | |
| 303 | //limiter |
| 304 | bool limiterAvailable = csoundGetVersion()>=6160; |
| 305 | limiterCheckBox->setEnabled(limiterAvailable); |
| 306 | limiterSpinBox->setEnabled(limiterAvailable); |
| 307 | if (limiterAvailable) { |
| 308 | limiterCheckBox->setChecked(m_options->useLimiter); |
| 309 | limiterSpinBox->setValue(m_options->limitValue); |
| 310 | } |
| 311 | |
| 312 | JackNameLineEdit->setText(m_options->rtJackName); |
| 313 | RtMidiModuleComboBox->setCurrentIndex(RtMidiModuleComboBox->findData(m_options->rtMidiModule)); |
| 314 | RtMidiInputLineEdit->setText(m_options->rtMidiInputDevice); |
| 315 | RtMidiOutputLineEdit->setText(m_options->rtMidiOutputDevice); |
| 316 | csoundMidiCheckBox->setChecked(m_options->useCsoundMidi); |
| 317 | simultaneousCheckBox->setChecked(m_options->simultaneousRun); |
| 318 | |
| 319 | sampleFormatComboBox->setCurrentIndex(m_options->sampleFormat); |
| 320 | debugPortSpinBox->setValue(m_options->debugPort); |
| 321 | |
| 322 | CsdocdirLineEdit->setText(m_options->csdocdir); |
| 323 | OpcodedirCheckBox->setChecked(m_options->opcodedirActive); |
| 324 | OpcodedirLineEdit->setText(m_options->opcodedir); |
| 325 | Opcodedir64CheckBox->setChecked(m_options->opcodedir64Active); |
| 326 | Opcodedir64LineEdit->setText(m_options->opcodedir64); |
| 327 | Opcode6dir64CheckBox->setChecked(m_options->opcode6dir64Active); |
| 328 | Opcode6dir64LineEdit->setText(m_options->opcode6dir64); |
| 329 | SadirCheckBox->setChecked(m_options->sadirActive); |
| 330 | SadirLineEdit->setText(m_options->sadir); |
| 331 | SsdirCheckBox->setChecked(m_options->ssdirActive); |
| 332 | SsdirLineEdit->setText(m_options->ssdir); |
| 333 | SfdirCheckBox->setChecked(m_options->sfdirActive); |
| 334 | SfdirLineEdit->setText(m_options->sfdir); |
| 335 | rawWaveCheckBox->setChecked(m_options->rawWaveActive); |
| 336 | rawWaveLineEdit->setText(m_options->rawWave); |
| 337 | IncdirCheckBox->setChecked(m_options->incdirActive); |
| 338 | IncdirLineEdit->setText(m_options->incdir); |
| 339 | // defaultCsdCheckBox->setChecked(m_options->defaultCsdActive); |
| 340 | // defaultCsdLineEdit->setText(m_options->defaultCsd); |
| 341 | // defaultCsdLineEdit->setEnabled(m_options->defaultCsdActive); |
| 342 | favoriteLineEdit->setText(m_options->favoriteDir); |
| 343 | examplePathlineEdit->setText(m_options->examplePath); |
| 344 | pythonDirLineEdit->setText(m_options->pythonDir); |
| 345 | pythonExecutableLineEdit->setText(m_options->pythonExecutable); |
| 346 | csoundExecutableLineEdit->setText(m_options->csoundExecutable); |
| 347 | logFileLineEdit->setText(m_options->logFile); |
| 348 | sdkLineEdit->setText(m_options->sdkDir); |
| 349 | templateLineEdit->setText(m_options->templateDir); |
| 350 | |
| 351 | TerminalLineEdit->setText(m_options->terminal); |
| 352 | browserLineEdit->setText(m_options->browser); |
| 353 | dotLineEdit->setText(m_options->dot); |
| 354 | WaveEditorLineEdit->setText(m_options->waveeditor); |
| 355 | WavePlayerLineEdit->setText(m_options->waveplayer); |
| 356 | pdfViewerLineEdit->setText(m_options->pdfviewer); |
| 357 | languageComboBox->setCurrentIndex(m_options->language); |
| 358 | |
| 359 | templateTextEdit->setPlainText(m_options->csdTemplate); |
| 360 | |
| 361 | connect(inputFilenameToolButton, SIGNAL(clicked()), this, SLOT(browseInputFilename())); |
| 362 | connect(outputFilenameToolButton, SIGNAL(clicked()), this, SLOT(browseOutputFilename())); |
| 363 | connect(csdocdirToolButton, SIGNAL(clicked()), this, SLOT(browseCsdocdir())); |
| 364 | connect(opcodedirToolButton, SIGNAL(clicked()), this, SLOT(browseOpcodedir())); |
| 365 | connect(opcodedir64ToolButton, SIGNAL(clicked()), this, SLOT(browseOpcodedir64())); |
| 366 | connect(opcode6dir64ToolButton, SIGNAL(clicked()), this, SLOT(browseOpcode6dir64())); // was commented out - why? |
| 367 | connect(sadirToolButton, SIGNAL(clicked()), this, SLOT(browseSadir())); |
| 368 | connect(ssdirToolButton, SIGNAL(clicked()), this, SLOT(browseSsdir())); |
| 369 | connect(sfdirToolButton, SIGNAL(clicked()), this, SLOT(browseSfdir())); |
| 370 | connect(incdirToolButton, SIGNAL(clicked()), this, SLOT(browseIncdir())); |
| 371 | connect(rawWaveToolButton, SIGNAL(clicked()), this, SLOT(browseRawWaveDir())); |
| 372 | // connect(defaultCsdToolButton, SIGNAL(clicked()), this, SLOT(browseDefaultCsd())); |
| 373 | connect(favoriteToolButton, SIGNAL(clicked()), this, SLOT(browseFavorite())); |
| 374 | connect(examplePathToolButton, SIGNAL(clicked()), this, SLOT(browseExamplePath()) ); |
| 375 | connect(terminalToolButton, SIGNAL(clicked()), this, SLOT(browseTerminal())); |
| 376 | connect(browserToolButton, SIGNAL(clicked()), this, SLOT(browseBrowser())); |
| 377 | connect(dotToolButton, SIGNAL(clicked()), this, SLOT(browseDot())); |
| 378 | connect(waveEditorToolButton, SIGNAL(clicked()), this, SLOT(browseWaveEditor())); |
| 379 | connect(wavePlayerToolButton, SIGNAL(clicked()), this, SLOT(browseWavePlayer())); |
| 380 | connect(pdfViewerToolButton, SIGNAL(clicked()), this, SLOT(browsePdfViewer())); |
| 381 | connect(pythonDirToolButton, SIGNAL(clicked()), this, SLOT(browsePythonDir())); |
| 382 | connect(logFileToolButton, SIGNAL(clicked()), this, SLOT(browseLogFile())); |
| 383 | connect(sdkToolButton, SIGNAL(clicked()), this, SLOT(browseSdkDir())); |
| 384 | connect(templateToolButton, SIGNAL(clicked()), this, SLOT(browseTemplateDir())); |
| 385 | |
| 386 | // connect(this, SIGNAL(changeFont()), parent, SLOT(changeFont())); |
| 387 | connect(audioInputToolButton, SIGNAL(released()), this, SLOT(selectAudioInput())); |
| 388 | connect(audioOutputToolButton, SIGNAL(released()), this, SLOT(selectAudioOutput())); |
| 389 | connect(midiInputToolButton, SIGNAL(released()), this, SLOT(selectMidiInput())); |
| 390 | connect(midiOutputToolButton, SIGNAL(released()), this, SLOT(selectMidiOutput())); |
| 391 | connect(consoleFontColorPushButton, SIGNAL(released()), this, SLOT(selectTextColor())); |
| 392 | connect(consoleBgColorPushButton, SIGNAL(released()), this, SLOT(selectBgColor())); |
| 393 | // connect(editorBgColorButton, SIGNAL(released()), this, SLOT(selectEditorBgColor())); |
| 394 | |
| 395 | connect(clearTemplatePushButton,SIGNAL(released()), this, SLOT(clearTemplate())); |
| 396 | connect(defaultTemplatePushButton,SIGNAL(released()), this, SLOT(defaultTemplate())); |
| 397 | |
| 398 | // connect(OpcodedirCheckBox, SIGNAL(toggled(bool)), this, SLOT(warnOpcodeDir(bool))); |
| 399 | // connect(Opcodedir64CheckBox, SIGNAL(toggled(bool)), this, SLOT(warnOpcodeDir(bool))); |
| 400 | // connect(Opcode6dir64CheckBox, SIGNAL(toggled(bool)), this, SLOT(uDir(bool))); |
| 401 | |
| 402 | connect(csoundExecutableToolButton,SIGNAL(clicked()),this, SLOT(browseCsoundExecutable())); |
| 403 | connect(pythonExecutableToolButton,SIGNAL(clicked()),this, SLOT(browsePythonExecutable())); |
| 404 | |
| 405 | connect(testAudioSetupButton, SIGNAL(released()), this, SLOT(testAudioSetup())); |
| 406 | // connect(envirRecommendButton, SIGNAL(clicked()), this, SLOT(recommendEnvironmentSettings())); |
| 407 | |
| 408 | //connect(RtMidiModuleComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(checkRtMidiModule(QString)) ); |
| 409 | |
| 410 | |
| 411 | #ifndef QCS_PYTHONQT |
| 412 | pythonDirLineEdit->setEnabled(false); |
| 413 | pythonDirToolButton->setEnabled(false); |
| 414 | noPythonCheckBox->setEnabled(false); |
| 415 | noPythonCheckBox->setChecked(false); |
| 416 | #endif |
| 417 | |
| 418 | m_selectedOutputDeviceIndex = -1; |
| 419 | } |
| 420 | |
| 421 | ConfigDialog::~ConfigDialog() |
| 422 | { |
| 423 | } |
| 424 | |
| 425 | void ConfigDialog::onRtModuleComboBoxChanged(int index) { |
| 426 | // Todo: remember the settings for each backend in a hash table, and set it to the last |
| 427 | // known value when changed back. Otherwise set it to the default adc/dac |
| 428 | auto currentText = this->RtModuleComboBox->currentText(); |
| 429 | //auto currentOperatingSystem = QOperatingSystemVersion::current(); |
| 430 | //qDebug() << "module: " << currentText << "Op.system type is: " << QSysInfo::productType() ; |
| 431 | if(currentText == "null") { |
| 432 | RtInputLineEdit->setText(""); |
| 433 | RtOutputLineEdit->setText(""); |
| 434 | } else if (currentText == "jack") { |
| 435 | #ifdef Q_OS_LINUX |
| 436 | RtInputLineEdit->setText("adc:system:capture_"); |
| 437 | RtOutputLineEdit->setText("dac:system:playback_"); |
| 438 | #else |
| 439 | RtInputLineEdit->setText("adc"); |
| 440 | RtOutputLineEdit->setText("dac"); |
| 441 | #endif |
| 442 | } else if (currentText == "pulse") { |
| 443 | RtInputLineEdit->setText("adc"); |
| 444 | RtOutputLineEdit->setText("dac"); |
| 445 | if(m_options->useSystemSamplerate || this->samplerateComboBox->currentText() == "System") { |
| 446 | this->samplerateComboBox->setCurrentText("Orchestra"); |
| 447 | m_options->useSystemSamplerate = false; |
| 448 | m_options->samplerate = 0; |
| 449 | } |
| 450 | } else if (currentText.startsWith("portaudio") && QSysInfo::productType()=="osx" ) { // on newer Mac's the internal microphone has 1 channel and that causes problems for portaudio. Disable input by default |
| 451 | qDebug() << "Set audio input to none for portaudio on MacOS"; |
| 452 | RtInputLineEdit->setText(""); |
| 453 | RtOutputLineEdit->setText("dac"); |
| 454 | } else { |
| 455 | RtInputLineEdit->setText("adc"); |
| 456 | RtOutputLineEdit->setText("dac"); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | int ConfigDialog::currentTab() |
| 461 | { |
| 462 | return editorTabWidget->currentIndex(); |
| 463 | } |
| 464 | |
| 465 | void ConfigDialog::warnOpcodeDir(bool on) |
| 466 | { |
| 467 | if (on) { |
| 468 | QMessageBox::warning(this, "CsoundQt", |
| 469 | tr("Please note that OPCODEDIR and OPCODEDIR64 will overwrite current settings so you will need to restart CsoundQt to return to default.") |
| 470 | ); |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | void ConfigDialog::setCurrentTab(int index) |
| 475 | { |
| 476 | if (index >= 0 && index < 4) { |
| 477 | editorTabWidget->setCurrentIndex(index); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | void ConfigDialog::accept() |
| 482 | { |
| 483 | m_options->theme = themeComboBox->currentText(); |
| 484 | m_options->font = fontComboBox->currentText(); |
| 485 | m_options->fontPointSize = fontSizeComboBox->currentText().toDouble(); |
| 486 | m_options->showLineNumberArea = lineNumbersCheckBox->isChecked(); |
| 487 | m_options->lineEnding = lineEndingComboBox->currentIndex(); |
| 488 | m_options->consoleFont = consoleFontComboBox->currentText(); |
| 489 | m_options->consoleFontPointSize = consoleFontSizeComboBox->currentText().toDouble(); |
| 490 | m_options->tabWidth = tabWidthSpinBox->value(); |
| 491 | m_options->tabIndents = tabIndentCheckBox->isChecked(); |
| 492 | m_options->highlightingTheme = highlightingThemeComboBox->currentText(); |
| 493 | m_options->colorVariables = m_options->highlightingTheme != "none"; |
| 494 | m_options->autoPlay = autoplayCheckBox->isChecked(); |
| 495 | m_options->autoJoin = autoJoinCheckBox->isChecked(); |
| 496 | m_options->menuDepth = menusDepthSpinBox->value(); |
| 497 | m_options->saveChanges = saveChangesCheckBox->isChecked(); |
| 498 | m_options->askIfTemporary = askIfTemporaryCheckBox->isChecked(); |
| 499 | m_options->widgetsIndependent = widgetsIndependentCheckBox->isChecked(); |
| 500 | m_options->rememberFile = rememberFileCheckBox->isChecked(); |
| 501 | m_options->saveWidgets = saveWidgetsCheckBox->isChecked(); |
| 502 | m_options->iconText = iconTextCheckBox->isChecked(); |
| 503 | m_options->showToolbar = toolbarCheckBox->isChecked(); |
| 504 | m_options->lockToolbar = lockToolbarCheckBox->isChecked(); |
| 505 | m_options->toolbarIconSize = toolbarIconSizeSpinBox->value(); |
| 506 | m_options->wrapLines = wrapLinesCheckBox->isChecked(); |
| 507 | m_options->autoComplete = autoCompleteCheckBox->isChecked(); |
| 508 | m_options->autoCompleteDelay = autoCompleteDelaySpinBox->value(); |
| 509 | m_options->autoParameterMode = autoParameterModeCheckBox->isChecked(); |
| 510 | m_options->enableWidgets = widgetsCheckBox->isChecked(); |
| 511 | m_options->midiCcToCurrentPageOnly = midiCcToCurrentPageOnlyCheckBox->isChecked(); |
| 512 | m_options->showWidgetsOnRun = showWidgetsOnRunCheckBox->isChecked(); |
| 513 | m_options->showTooltips = showTooltipsCheckBox->isChecked(); |
| 514 | m_options->enableFLTK = enableFLTKCheckBox->isChecked(); |
| 515 | m_options->terminalFLTK = terminalFLTKCheckBox->isChecked(); |
| 516 | m_options->oldFormat = oldFormatCheckBox->isChecked(); |
| 517 | m_options->openProperties = openPropertiesCheckBox->isChecked(); |
| 518 | m_options->fontScaling = fontScalingSpinBox->value(); |
| 519 | m_options->fontOffset = fontOffsetSpinBox->value(); |
| 520 | m_options->graphUpdateRate = graphUpdateRateSpinBox->value(); |
| 521 | m_options->debugPort = debugPortSpinBox->value(); |
| 522 | m_options->tabShortcutActive = tabShortcutActiveCheckBox->isChecked(); |
| 523 | m_options->useAPI = ApiRadioButton->isChecked(); |
| 524 | // m_options->thread = threadCheckBox->isChecked(); |
| 525 | m_options->keyRepeat = keyRepeatCheckBox->isChecked(); |
| 526 | m_options->debugLiveEvents = debugLiveEventsCheckBox->isChecked(); |
| 527 | m_options->consoleBufferSize = consoleBufferComboBox->itemText(consoleBufferComboBox->currentIndex()).toInt(); |
| 528 | m_options->midiInterface = midiInterfaceComboBox->itemData(midiInterfaceComboBox->currentIndex()).toInt(); // actually not necessary to store thta any more but for any case... |
| 529 | m_options->midiInterfaceName = midiInterfaceComboBox->currentText(); |
| 530 | m_options->midiOutInterface = midiOutInterfaceComboBox->itemData(midiOutInterfaceComboBox->currentIndex()).toInt(); |
| 531 | m_options->midiOutInterfaceName = midiOutInterfaceComboBox->currentText(); |
| 532 | m_options->noMessages = noMessagesCheckBox->isChecked(); |
| 533 | m_options->noBuffer = noBufferCheckBox->isChecked(); |
| 534 | m_options->noPython = noPythonCheckBox->isChecked(); |
| 535 | m_options->noEvents = noEventsCheckBox->isChecked(); |
| 536 | if (m_options->consoleBufferSize < 0) |
| 537 | m_options->consoleBufferSize = 0; |
| 538 | m_options->bufferSize = BufferSizeLineEdit->text().toInt(); |
| 539 | m_options->bufferSizeActive = BufferSizeCheckBox->isChecked(); |
| 540 | m_options->HwBufferSize = HwBufferSizeLineEdit->text().toInt(); |
| 541 | m_options->HwBufferSizeActive = HwBufferSizeCheckBox->isChecked(); |
| 542 | // m_options->dither = DitherCheckBox->isChecked(); |
| 543 | m_options->realtimeFlag = realtimeCheckBox->isChecked(); // this was empty after = ? |
| 544 | // m_options->newParser = newParserCheckBox->isChecked() ? 1 : 0; |
| 545 | m_options->useLimiter = limiterCheckBox->isEnabled() && limiterCheckBox->isChecked(); |
| 546 | m_options->limitValue = limiterSpinBox->value(); |
| 547 | m_options->multicore = multicoreCheckBox->isChecked(); |
| 548 | m_options->numThreads = numThreadsSpinBox->value(); |
| 549 | m_options->additionalFlags = AdditionalFlagsLineEdit->text(); |
| 550 | m_options->additionalFlagsActive = AdditionalFlagsCheckBox->isChecked(); |
| 551 | m_options->fileUseOptions = FileUseOptionsCheckBox->isChecked(); |
| 552 | m_options->fileOverrideOptions = FileOverrideCheckBox->isChecked(); |
| 553 | m_options->fileAskFilename = AskFilenameCheckBox->isChecked(); |
| 554 | m_options->filePlayFinished = FilePlayFinishedCheckBox->isChecked(); |
| 555 | m_options->fileFileType = FileTypeComboBox->currentIndex(); |
| 556 | m_options->fileSampleFormat = FileFormatComboBox->currentIndex(); |
| 557 | m_options->fileInputFilenameActive = InputFilenameCheckBox->isChecked(); |
| 558 | m_options->fileInputFilename = InputFilenameLineEdit->text(); |
| 559 | m_options->fileOutputFilenameActive = OutputFilenameCheckBox->isChecked(); |
| 560 | m_options->fileOutputFilename = OutputFilenameLineEdit->text(); |
| 561 | m_options->rtUseOptions = RtUseOptionsCheckBox->isChecked(); |
| 562 | m_options->rtOverrideOptions = RtOverrideCheckBox->isChecked(); |
| 563 | m_options->rtAudioModule = RtModuleComboBox->itemData( |
| 564 | RtModuleComboBox->currentIndex()).toString(); |
| 565 | m_options->rtInputDevice = RtInputLineEdit->text(); |
| 566 | m_options->rtOutputDevice = RtOutputLineEdit->text(); |
| 567 | m_options->rtJackName = JackNameLineEdit->text(); |
| 568 | // m_options->useSystemSamplerate = useSystemSamplerateCheckBox->isChecked(); |
| 569 | auto srmenu = samplerateComboBox->currentText(); |
| 570 | if(srmenu == "System") { |
| 571 | m_options->useSystemSamplerate = true; |
| 572 | m_options->samplerate = 0; |
| 573 | } else if (srmenu == "Orchestra") { |
| 574 | m_options->useSystemSamplerate = false; |
| 575 | m_options->samplerate = 0; |
| 576 | } else { |
| 577 | m_options->useSystemSamplerate = false; |
| 578 | m_options->samplerate = srmenu.toInt(); |
| 579 | } |
| 580 | m_options->overrideNumChannels = numChannelsCheckBox->isChecked(); |
| 581 | m_options->numChannels = numChannelsSpinBox->value(); |
| 582 | |
| 583 | m_options->numInputChannels = numInputChannelsSpinBox->value(); |
| 584 | m_options->realtimeFlag = realtimeCheckBox->isChecked(); |
| 585 | m_options->sampleAccurateFlag = sampleAccurateCheckBox->isChecked(); |
| 586 | |
| 587 | |
| 588 | m_options->rtMidiModule = RtMidiModuleComboBox->currentText(); |
| 589 | m_options->rtMidiInputDevice = RtMidiInputLineEdit->text(); |
| 590 | m_options->rtMidiOutputDevice = RtMidiOutputLineEdit->text(); |
| 591 | m_options->useCsoundMidi = csoundMidiCheckBox->isChecked(); |
| 592 | m_options->simultaneousRun = simultaneousCheckBox->isChecked(); |
| 593 | |
| 594 | m_options->sampleFormat = sampleFormatComboBox->currentIndex(); |
| 595 | |
| 596 | m_options->csdocdir = CsdocdirLineEdit->text(); |
| 597 | m_options->opcodedirActive = OpcodedirCheckBox->isChecked(); |
| 598 | m_options->opcodedir = OpcodedirLineEdit->text(); |
| 599 | m_options->opcodedir64Active = Opcodedir64CheckBox->isChecked(); |
| 600 | m_options->opcodedir64 = Opcodedir64LineEdit->text(); |
| 601 | m_options->opcode6dir64Active = Opcode6dir64CheckBox->isChecked(); |
| 602 | m_options->opcode6dir64 = Opcode6dir64LineEdit->text(); |
| 603 | m_options->sadirActive = SadirCheckBox->isChecked(); |
| 604 | m_options->sadir = SadirLineEdit->text(); |
| 605 | m_options->ssdirActive = SsdirCheckBox->isChecked(); |
| 606 | m_options->ssdir = SsdirLineEdit->text(); |
| 607 | m_options->sfdirActive = SfdirCheckBox->isChecked(); |
| 608 | m_options->sfdir = SfdirLineEdit->text(); |
| 609 | m_options->incdirActive = IncdirCheckBox->isChecked(); |
| 610 | m_options->incdir = IncdirLineEdit->text(); |
| 611 | m_options->rawWaveActive = rawWaveCheckBox->isChecked(); |
| 612 | m_options->rawWave = rawWaveLineEdit->text(); |
| 613 | // m_options->defaultCsdActive = defaultCsdCheckBox->isChecked(); |
| 614 | // m_options->defaultCsd = defaultCsdLineEdit->text(); |
| 615 | m_options->favoriteDir = favoriteLineEdit->text(); |
| 616 | m_options->examplePath = examplePathlineEdit->text(); |
| 617 | m_options->pythonDir = pythonDirLineEdit->text(); |
| 618 | m_options->pythonExecutable = pythonExecutableLineEdit->text(); |
| 619 | m_options->csoundExecutable = csoundExecutableLineEdit->text(); |
| 620 | m_options->logFile = logFileLineEdit->text(); |
| 621 | m_options->sdkDir = sdkLineEdit->text(); |
| 622 | m_options->templateDir = templateLineEdit->text(); |
| 623 | |
| 624 | m_options->terminal = TerminalLineEdit->text(); |
| 625 | m_options->browser = browserLineEdit->text(); |
| 626 | m_options->dot = dotLineEdit->text(); |
| 627 | m_options->waveeditor = WaveEditorLineEdit->text(); |
| 628 | m_options->waveplayer = WavePlayerLineEdit->text(); |
| 629 | m_options->pdfviewer = pdfViewerLineEdit->text(); |
| 630 | m_options->language = languageComboBox->currentIndex(); |
| 631 | |
| 632 | m_options->csdTemplate = templateTextEdit->toPlainText(); |
| 633 | m_options->checkSyntaxBeforeRun = checkSyntaxBeforeRunCheckBox->isChecked(); |
| 634 | m_options->highlightScore = highlightScoreCheckBox->isChecked(); |
| 635 | |
| 636 | // emit(changeFont()); |
| 637 | QDialog::accept(); |
| 638 | } |
| 639 | |
| 640 | void ConfigDialog::browseInputFilename() |
| 641 | { |
| 642 | browseSaveFile(m_options->fileInputFilename); |
| 643 | InputFilenameLineEdit->setText(m_options->fileInputFilename); |
| 644 | } |
| 645 | |
| 646 | void ConfigDialog::browseOutputFilename() |
| 647 | { |
| 648 | browseSaveFile(m_options->fileOutputFilename); |
| 649 | OutputFilenameLineEdit->setText(m_options->fileOutputFilename); |
| 650 | } |
| 651 | |
| 652 | void ConfigDialog::browseCsdocdir() |
| 653 | { |
| 654 | browseDir(m_options->csdocdir); |
| 655 | CsdocdirLineEdit->setText(m_options->csdocdir); |
| 656 | } |
| 657 | |
| 658 | void ConfigDialog::browseOpcodedir() |
| 659 | { |
| 660 | browseDir(m_options->opcodedir); |
| 661 | OpcodedirLineEdit->setText(m_options->opcodedir); |
| 662 | } |
| 663 | |
| 664 | void ConfigDialog::browseOpcodedir64() |
| 665 | { |
| 666 | browseDir(m_options->opcodedir64); |
| 667 | Opcodedir64LineEdit->setText(m_options->opcodedir64); |
| 668 | } |
| 669 | |
| 670 | void ConfigDialog::browseOpcode6dir64() |
| 671 | { |
| 672 | browseDir(m_options->opcode6dir64); |
| 673 | Opcode6dir64LineEdit->setText(m_options->opcode6dir64); |
| 674 | } |
| 675 | |
| 676 | void ConfigDialog::browseSadir() |
| 677 | { |
| 678 | browseDir(m_options->sadir); |
| 679 | SadirLineEdit->setText(m_options->sadir); |
| 680 | } |
| 681 | |
| 682 | void ConfigDialog::browseSsdir() |
| 683 | { |
| 684 | browseDir(m_options->ssdir); |
| 685 | SsdirLineEdit->setText(m_options->ssdir); |
| 686 | } |
| 687 | |
| 688 | void ConfigDialog::browseSfdir() |
| 689 | { |
| 690 | browseDir(m_options->sfdir); |
| 691 | SfdirLineEdit->setText(m_options->sfdir); |
| 692 | } |
| 693 | |
| 694 | void ConfigDialog::browseIncdir() |
| 695 | { |
| 696 | browseDir(m_options->incdir); |
| 697 | IncdirLineEdit->setText(m_options->incdir); |
| 698 | } |
| 699 | |
| 700 | void ConfigDialog::browseRawWaveDir() |
| 701 | { |
| 702 | browseDir(m_options->rawWave); |
| 703 | rawWaveLineEdit->setText(m_options->rawWave); |
| 704 | } |
| 705 | |
| 706 | void ConfigDialog::browseCsoundExecutable() |
| 707 | { |
| 708 | browseFile(m_options->csoundExecutable); |
| 709 | csoundExecutableLineEdit->setText(m_options->csoundExecutable); |
| 710 | } |
| 711 | |
| 712 | void ConfigDialog::browsePythonExecutable() |
| 713 | { |
| 714 | browseFile(m_options->pythonExecutable); |
| 715 | pythonExecutableLineEdit->setText(m_options->pythonExecutable); |
| 716 | } |
| 717 | |
| 718 | |
| 719 | //void ConfigDialog::browseDefaultCsd() |
| 720 | //{ |
| 721 | // browseFile(m_options->defaultCsd); |
| 722 | // if (!m_options->defaultCsd.endsWith(".csd")) { |
| 723 | // QMessageBox::warning(this, tr("CsoundQt"), |
| 724 | // tr("Only files with extension .csd are accepted")); |
| 725 | // return; |
| 726 | // } |
| 727 | // defaultCsdLineEdit->setText(m_options->defaultCsd); |
| 728 | //} |
| 729 | |
| 730 | void ConfigDialog::browseFavorite() |
| 731 | { |
| 732 | browseDir(m_options->favoriteDir); |
| 733 | favoriteLineEdit->setText(m_options->favoriteDir); |
| 734 | } |
| 735 | |
| 736 | void ConfigDialog::browseExamplePath() |
| 737 | { |
| 738 | browseDir(m_options->examplePath); |
| 739 | examplePathlineEdit->setText(m_options->examplePath); |
| 740 | } |
| 741 | |
| 742 | void ConfigDialog::browseTerminal() |
| 743 | { |
| 744 | browseFile(m_options->terminal); |
| 745 | TerminalLineEdit->setText(m_options->terminal); |
| 746 | } |
| 747 | |
| 748 | void ConfigDialog::browseBrowser() |
| 749 | { |
| 750 | browseFile(m_options->browser); |
| 751 | browserLineEdit->setText(m_options->browser); |
| 752 | } |
| 753 | |
| 754 | void ConfigDialog::browseDot() |
| 755 | { |
| 756 | browseFile(m_options->dot); |
| 757 | dotLineEdit->setText(m_options->dot); |
| 758 | } |
| 759 | |
| 760 | void ConfigDialog::browseWaveEditor() |
| 761 | { |
| 762 | browseFile(m_options->waveeditor); |
| 763 | WaveEditorLineEdit->setText(m_options->waveeditor); |
| 764 | } |
| 765 | |
| 766 | void ConfigDialog::browseWavePlayer() |
| 767 | { |
| 768 | browseFile(m_options->waveplayer); |
| 769 | WavePlayerLineEdit->setText(m_options->waveplayer); |
| 770 | } |
| 771 | |
| 772 | void ConfigDialog::browsePdfViewer() |
| 773 | { |
| 774 | browseFile(m_options->pdfviewer); |
| 775 | pdfViewerLineEdit->setText(m_options->pdfviewer); |
| 776 | } |
| 777 | |
| 778 | void ConfigDialog::browsePythonDir() |
| 779 | { |
| 780 | browseDir(m_options->pythonDir); |
| 781 | pythonDirLineEdit->setText(m_options->pythonDir); |
| 782 | } |
| 783 | |
| 784 | void ConfigDialog::browseLogFile() |
| 785 | { |
| 786 | browseSaveFile(m_options->logFile); |
| 787 | logFileLineEdit->setText(m_options->logFile); |
| 788 | } |
| 789 | |
| 790 | void ConfigDialog::browseSdkDir() |
| 791 | { |
| 792 | browseDir(m_options->sdkDir); |
| 793 | sdkLineEdit->setText(m_options->sdkDir); |
| 794 | } |
| 795 | |
| 796 | void ConfigDialog::browseTemplateDir() |
| 797 | { |
| 798 | browseDir(m_options->templateDir); |
| 799 | templateLineEdit->setText(m_options->templateDir); |
| 800 | } |
| 801 | |
| 802 | void ConfigDialog::selectAudioInput() |
| 803 | { |
| 804 | QList<QStringPair> deviceList = m_configlists->getAudioInputDevices( |
| 805 | RtModuleComboBox->itemData(RtModuleComboBox->currentIndex()).toString()); |
| 806 | // QMenu menu(this); |
| 807 | QMenu menu(audioInputToolButton); |
| 808 | QVector<QAction*> actions; |
| 809 | |
| 810 | QString module = RtModuleComboBox->currentText(); |
| 811 | if(module == "jack") { |
| 812 | deviceList.prepend(QStringPair("adc", "adc")); |
| 813 | deviceList.prepend(QStringPair("Do Not Autoconnect", "adc:null")); |
| 814 | deviceList.prepend(QStringPair("System Inputs", "adc:system:capture_")); |
| 815 | } else { |
| 816 | deviceList.prepend(QStringPair("Default", "adc")); |
| 817 | } |
| 818 | |
| 819 | deviceList.prepend(QStringPair("No Input", "")); |
| 820 | |
| 821 | auto currentSelection = RtInputLineEdit->text(); |
| 822 | for (int i = 0; i < deviceList.size(); i++) { |
| 823 | auto option = !deviceList[i].second.isEmpty() ? |
| 824 | deviceList[i].first + " (" + deviceList[i].second + ")": |
| 825 | deviceList[i].first; |
| 826 | if(currentSelection == deviceList[i].second) |
| 827 | option.prepend("> "); |
| 828 | auto action = menu.addAction(option); |
| 829 | actions.append(action); |
| 830 | } |
| 831 | |
| 832 | auto pos = audioInputToolButton->mapToGlobal(QPoint(0, audioInputToolButton->height())); |
| 833 | int index = actions.indexOf(menu.exec(pos)); |
| 834 | if (index >= 0) |
| 835 | RtInputLineEdit->setText(deviceList[index].second); |
| 836 | } |
| 837 | |
| 838 | void ConfigDialog::selectAudioOutput() |
| 839 | { |
| 840 | QList<QStringPair> deviceList = m_configlists->getAudioOutputDevices( |
| 841 | RtModuleComboBox->itemData(RtModuleComboBox->currentIndex()).toString()); |
| 842 | QMenu menu(this); |
| 843 | QVector<QAction*> actions; |
| 844 | |
| 845 | |
| 846 | QString module = RtModuleComboBox->currentText(); |
| 847 | if(module == "jack") { |
| 848 | deviceList.prepend(QStringPair("dac", "dac")); |
| 849 | deviceList.prepend(QStringPair("Do Not Autoconnect", "dac:null")); |
| 850 | deviceList.prepend(QStringPair("System Outputs", "dac:system:playback_")); |
| 851 | } else { |
| 852 | deviceList.prepend(QStringPair("Default", "dac")); |
| 853 | } |
| 854 | |
| 855 | deviceList.append(QStringPair("No Output", "")); |
| 856 | auto currentSelection = RtOutputLineEdit->text(); |
| 857 | |
| 858 | for (int i = 0; i < deviceList.size(); i++) { |
| 859 | auto option = !deviceList[i].second.isEmpty() ? |
| 860 | deviceList[i].first + " (" + deviceList[i].second + ")" : |
| 861 | deviceList[i].first; |
| 862 | if(currentSelection == deviceList[i].second) |
| 863 | option.prepend("> "); |
| 864 | auto action = menu.addAction(option); |
| 865 | actions.append(action); |
| 866 | } |
| 867 | |
| 868 | auto pos = audioOutputToolButton->mapToGlobal(QPoint(0, audioOutputToolButton->height())); |
| 869 | int index = actions.indexOf(menu.exec(pos)); |
| 870 | if (index >= 0) { |
| 871 | RtOutputLineEdit->setText(deviceList[index].second); |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | void ConfigDialog::selectMidiInput() |
| 876 | { |
| 877 | QString module = RtMidiModuleComboBox->currentText(); |
| 878 | QHash<QString, QString> deviceList = m_configlists->getMidiInputDevices(module); |
| 879 | |
| 880 | QMenu menu(this); |
| 881 | |
| 882 | if (module == "jack") { |
| 883 | deviceList.insert("jack", "jack"); // just to create client in jack |
| 884 | } |
| 885 | |
| 886 | deviceList.insert("Disabled", ""); |
| 887 | |
| 888 | if (module == "portmidi") { |
| 889 | deviceList.insert("all", "a"); |
| 890 | } |
| 891 | |
| 892 | QHashIterator<QString, QString> i(deviceList); |
| 893 | while (i.hasNext()) { |
| 894 | i.next(); |
| 895 | QAction* action = menu.addAction(i.key() + " (" + i.value() +")"); |
| 896 | action->setData(i.value()); |
| 897 | } |
| 898 | |
| 899 | QPoint pos = midiInputToolButton->mapToGlobal(QPoint(0, midiInputToolButton->height())); |
| 900 | QAction *selected = menu.exec(pos); |
| 901 | |
| 902 | if (selected) { |
| 903 | RtMidiInputLineEdit->setText(selected->data().toString()); |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | void ConfigDialog::selectMidiOutput() |
| 908 | { |
| 909 | QString module = RtMidiModuleComboBox->currentText(); |
| 910 | QList<QStringPair> deviceList = m_configlists->getMidiOutputDevices(module); |
| 911 | QMenu menu(this); |
| 912 | QVector<QAction*> actions; |
| 913 | |
| 914 | QStringPair device; |
| 915 | |
| 916 | if (module == "jack") { |
| 917 | // since getMidiInputDevices does not return jack clients yet and empty |
| 918 | // parametery may crash csound |
| 919 | deviceList.prepend(QStringPair("jack", "jack")); |
| 920 | } |
| 921 | |
| 922 | deviceList.append(QStringPair("Disabled", "")); |
| 923 | |
| 924 | for (int i = 0; i < deviceList.size(); i++) { |
| 925 | QAction* action = menu.addAction(deviceList[i].first + " (" + deviceList[i].second +")"); |
| 926 | actions.append(action); |
| 927 | } |
| 928 | |
| 929 | QPoint pos = midiOutputToolButton->mapToGlobal(QPoint(0, midiOutputToolButton->height())); |
| 930 | int index = actions.indexOf(menu.exec(pos)); |
| 931 | // int index = actions.indexOf(menu.exec(this->mapToGlobal(pos))); |
| 932 | if (index >= 0) |
| 933 | RtMidiOutputLineEdit->setText(deviceList[index].second); |
| 934 | } |
| 935 | |
| 936 | void ConfigDialog::browseFile(QString &destination) |
| 937 | { |
| 938 | QString file = QFileDialog::getOpenFileName(this,tr("Select File"),destination); |
| 939 | if (file!="") |
| 940 | destination = file; |
| 941 | } |
| 942 | |
| 943 | void ConfigDialog::browseSaveFile(QString &destination) |
| 944 | { |
| 945 | QString file = QFileDialog::getSaveFileName(this,tr("Select File"),destination); |
| 946 | if (file!="") |
| 947 | destination = file; |
| 948 | } |
| 949 | |
| 950 | void ConfigDialog::browseDir(QString &destination) |
| 951 | { |
| 952 | QString dir = QFileDialog::getExistingDirectory(this,tr("Select Directory"),destination); |
| 953 | if (dir!="") |
| 954 | destination = dir; |
| 955 | } |
| 956 | |
| 957 | |
| 958 | void ConfigDialog::selectTextColor() |
| 959 | { |
| 960 | QColor color = QColorDialog::getColor(m_options->consoleFontColor, this); |
| 961 | if (color.isValid()) { |
| 962 | m_options->consoleFontColor = color; |
| 963 | QPixmap pixmap (64,64); |
| 964 | pixmap.fill(m_options->consoleFontColor); |
| 965 | consoleFontColorPushButton->setIcon(pixmap); |
| 966 | QPalette palette(m_options->consoleFontColor); |
| 967 | consoleFontColorPushButton->setPalette(palette); |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | void ConfigDialog::selectBgColor() |
| 972 | { |
| 973 | QColor color = QColorDialog::getColor(m_options->consoleBgColor, this); |
| 974 | if (color.isValid()) { |
| 975 | m_options->consoleBgColor = color; |
| 976 | QPixmap pixmap (64,64); |
| 977 | pixmap.fill(m_options->consoleBgColor); |
| 978 | consoleBgColorPushButton->setIcon(pixmap); |
| 979 | QPalette palette(m_options->consoleBgColor); |
| 980 | consoleBgColorPushButton->setPalette(palette); |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | |
| 985 | void ConfigDialog::selectEditorBgColor() |
| 986 | { |
| 987 | QColor color = QColorDialog::getColor(m_options->editorBgColor, this); |
| 988 | if (color.isValid()) { |
| 989 | m_options->editorBgColor = color; |
| 990 | QPixmap pixmap (64,64); |
| 991 | pixmap.fill(m_options->editorBgColor); |
| 992 | // editorBgColorButton->setIcon(pixmap); |
| 993 | QPalette palette(m_options->editorBgColor); |
| 994 | // editorBgColorButton->setPalette(palette); |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | |
| 999 | void ConfigDialog::clearTemplate() |
| 1000 | { |
| 1001 | templateTextEdit->clear(); |
| 1002 | } |
| 1003 | |
| 1004 | void ConfigDialog::defaultTemplate() |
| 1005 | { |
| 1006 | QString defaultText = QCS_DEFAULT_TEMPLATE; |
| 1007 | templateTextEdit->setPlainText(defaultText ); |
| 1008 | } |
| 1009 | |
| 1010 | void ConfigDialog::on_csoundMidiCheckBox_toggled(bool checked) |
| 1011 | { |
| 1012 | if (checked) { // close internal rtmidi |
| 1013 | midiInterfaceComboBox->setEnabled(false); |
| 1014 | midiOutInterfaceComboBox->setEnabled(false); |
| 1015 | qDebug()<<Q_FUNC_INFO<<" closing internal rtmidi now."; |
| 1016 | emit disableInternalRtMidi(); |
| 1017 | } else { |
| 1018 | midiInterfaceComboBox->setEnabled(true); |
| 1019 | midiOutInterfaceComboBox->setEnabled(true); |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | void ConfigDialog::checkRtMidiModule(QString module) |
| 1024 | { |
| 1025 | if (module=="jack") { // && there is no lists; but now not connected. later: remove this function! |
| 1026 | qDebug()<<Q_FUNC_INFO<<"Setting dummy input and output for jack midi"; |
| 1027 | RtMidiInputLineEdit->setText("dummy"); |
| 1028 | RtMidiOutputLineEdit->setText("dummy"); |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | bool backendSupportsSystemSamplerate(QString module) { |
| 1033 | if(module == "jack" || |
| 1034 | module == "auhal") |
| 1035 | return true; |
| 1036 | return false; |
| 1037 | } |
| 1038 | |
| 1039 | void ConfigDialog::testAudioSetup() { |
| 1040 | // here we only accept to close the dialog. The actual functionality |
| 1041 | // is called from CsoundQt::configure, where the testAudioSetupButton |
| 1042 | // is connected to CsoundQt::testAudioSetup |
| 1043 | // This is done like this because CsoundQt creates this dialog |
| 1044 | // each time and holds no reference to it. |
| 1045 | this->accept(); |
| 1046 | } |
| 1047 | |
| 1048 | void ConfigDialog::recommendEnvironmentSettings() { |
| 1049 | #ifdef Q_OS_UNIX |
| 1050 | QString default_opcodes64 = "/usr/local/lib/csound/plugins64-6.0:"; |
| 1051 | #endif |
| 1052 | #ifdef Q_OS_WIN |
| 1053 | // What's the default plugin folder in win? |
| 1054 | QString default_opcodes64 = ""; |
| 1055 | #endif |
| 1056 | auto home = qgetenv("HOME"); |
| 1057 | auto dataLocationApp = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)[0]; |
| 1058 | auto dataLocation = QDir(dataLocationApp); |
| 1059 | dataLocation.cdUp(); |
| 1060 | if(this->Opcode6dir64LineEdit->text().isEmpty()) { |
| 1061 | auto opcdirenv = qgetenv("OPCODE6DIR64"); |
| 1062 | if(!opcdirenv.isEmpty()) { |
| 1063 | // if the user already set OPCODE6DIR64 then leave it as is. This is probably |
| 1064 | // an expert user |
| 1065 | QDEBUG << "$OPCODE6DIR64 is already set to " << opcdirenv; |
| 1066 | this->Opcode6dir64LineEdit->setText(opcdirenv); |
| 1067 | this->Opcode6dir64CheckBox->setChecked(false); |
| 1068 | } else { |
| 1069 | // We set OPCODE6DIR64 to the default + a user writable location |
| 1070 | auto opcdirstr = dataLocation.path() + "/csound6/plugins64"; |
| 1071 | auto opcdir = QDir(opcdirstr); |
| 1072 | if(!opcdir.exists()) { |
| 1073 | opcdir.mkpath("."); |
| 1074 | } |
| 1075 | if(!default_opcodes64.isEmpty()) |
| 1076 | opcdirstr = default_opcodes64 + opcdirstr; |
| 1077 | this->Opcode6dir64LineEdit->setText(opcdirstr); |
| 1078 | this->Opcode6dir64CheckBox->setChecked(true); |
| 1079 | } |
| 1080 | } |
| 1081 | if(this->IncdirLineEdit->text().isEmpty()) { |
| 1082 | auto incdirenv = qgetenv("INCDIR"); |
| 1083 | if(!incdirenv.isEmpty()) { |
| 1084 | // if the user already set it, then leave it as is. This is probably |
| 1085 | // an expert user |
| 1086 | QDEBUG << "$INCDIR is already set to " << incdirenv; |
| 1087 | this->IncdirLineEdit->setText(incdirenv); |
| 1088 | this->IncdirCheckBox->setChecked(false); |
| 1089 | } else { |
| 1090 | // propose an include folder parallel to the plugins folder |
| 1091 | auto incdirstr = dataLocation.path() + "/csound6/udos"; |
| 1092 | auto incdir = QDir(incdirstr); |
| 1093 | if(!incdir.exists()) { |
| 1094 | incdir.mkpath("."); |
| 1095 | } |
| 1096 | this->IncdirLineEdit->setText(incdirstr); |
| 1097 | this->IncdirCheckBox->setChecked(true); |
| 1098 | } |
| 1099 | } |
| 1100 | } |