Debian Codegraph @

BambooTracker/gui/configuration_dialog.cpp

raw
1 /*
2 * Copyright (C) 2018-2023 Rerrah
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
11 * conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #include "configuration_dialog.hpp"
27 #include "ui_configuration_dialog.h"
28 #include <algorithm>
29 #include <functional>
30 #include <QPushButton>
31 #include <QMenu>
32 #include <QMessageBox>
33 #include <QFont>
34 #include <QColorDialog>
35 #include <QFileDialog>
36 #include <QApplication>
37 #include <QListWidgetItem>
38 #include <QTreeWidgetItem>
39 #include <QToolButton>
40 #include <QHBoxLayout>
41 #include <QSignalBlocker>
42 #include <QList>
43 #include "chip/opna.hpp"
44 #include "audio/audio_stream.hpp"
45 #include "midi/midi.hpp"
46 #include "jamming.hpp"
47 #include "gui/slider_style.hpp"
48 #include "gui/fm_envelope_set_edit_dialog.hpp"
49 #include "gui/note_name_manager.hpp"
50 #include "gui/gui_utils.hpp"
51
52 namespace
53 {
54 inline Qt::CheckState toCheckState(bool enabled)
55 {
56 return enabled ? Qt::Checked : Qt::Unchecked;
57 }
58
59 inline bool fromCheckState(Qt::CheckState state)
60 {
61 return (state == Qt::Checked) ? true : false;
62 }
63
64 struct NotationSystemAttribute
65 {
66 const QString name;
67 const char* dispName;
68 const NoteNotationSystem ev;
69 };
70
71 const NotationSystemAttribute NOTATION_SYSS[] = {
72 { "English", QT_TRANSLATE_NOOP("NotationSystem", "English"), NoteNotationSystem::ENGLISH },
73 { "German", QT_TRANSLATE_NOOP("NotationSystem", "German"), NoteNotationSystem::GERMAN }
74 };
75 }
76
77 ConfigurationDialog::ConfigurationDialog(std::weak_ptr<Configuration> config, std::weak_ptr<ColorPalette> palette,
78 std::weak_ptr<const AudioStream> stream, QWidget *parent)
79 : QDialog(parent),
80 ui(new Ui::ConfigurationDialog),
81 config_(config),
82 refPalette_(palette),
83 stream_(stream)
84 {
85 ui->setupUi(this);
86
87 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
88 QObject::connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
89 this, [&] {
90 on_ConfigurationDialog_accepted();
91 emit applyPressed();
92 });
93
94 std::shared_ptr<Configuration> configLocked = config.lock();
95 // General //
96 // General settings
97 auto glfunc = [&](int i, bool enabled, QString desc) {
98 QListWidgetItem* item = ui->generalSettingsListWidget->item(i);
99 item->setCheckState(toCheckState(enabled));
100 item->setData(Qt::UserRole, desc);
101 };
102 glfunc(0, configLocked->getWarpCursor(),
103 tr("Wrap the cursor around the edges of the pattern editor."));
104 glfunc(1, configLocked->getWarpAcrossOrders(),
105 tr("Move to the previous or next order when reaching the top or bottom in the pattern editor."));
106 glfunc(2, configLocked->getShowRowNumberInHex(),
107 tr("Display row numbers and the playback position on the status bar in hexadecimal."));
108 glfunc(3, configLocked->getShowPreviousNextOrders(),
109 tr("Preview the previous and next orders in the pattern editor."));
110 glfunc(4, configLocked->getBackupModules(),
111 tr("Create a backup copy of the existing file when saving a module."));
112 glfunc(5, configLocked->getDontSelectOnDoubleClick(),
113 tr("Don't select the whole track when double-clicking in the pattern editor."));
114 glfunc(6, configLocked->getReverseFMVolumeOrder(),
115 tr("Reverse the order of FM volume so that 00 is the quietest in the pattern editor."));
116 glfunc(7, configLocked->getMoveCursorToRight(),
117 tr("Automatically move the cursor right after entering effects in the pattern editor."));
118 glfunc(8, configLocked->getRetrieveChannelState(),
119 tr("Reconstruct the current channel's state from previous orders upon playing."));
120 glfunc(9, configLocked->getEnableTranslation(),
121 tr("Translate to your language from the next launch. See readme to check supported languages."));
122 glfunc(10, configLocked->getShowFMDetuneAsSigned(),
123 tr("Display FM detune values as signed numbers in the FM envelope editor."));
124 glfunc(11, configLocked->getFill00ToEffectValue(),
125 tr("Automatically fill 00 to the effect value column upon entering an effect ID."));
126 glfunc(12, configLocked->getMoveCursorByHorizontalScroll(),
127 tr("Move the cursor with the horizontal scroll bar in the order list and the pattern editor."));
128 glfunc(13, configLocked->getOverwriteUnusedUneditedPropety(),
129 tr("Overwrite unused and unedited instrument properties when creating new properties. "
130 "If disabled, override unused properties regardless of editing."));
131 glfunc(14, configLocked->getWriteOnlyUsedSamples(),
132 tr("Only send samples used by instruments to the ADPCM memory. "
133 "It is recommended to turn this off if you change ADPCM samples frequently due to the high cost of rewriting.."));
134 glfunc(15, configLocked->getReflectInstrumentNumberChange(),
135 tr("Automatically update the instrument number in patterns when an instrument's number is changed."));
136 glfunc(16, configLocked->getFixJammingVolume(),
137 tr("Set maximum volume during jam mode. When unchecked, the volume is changed by the volume spinbox."));
138 glfunc(17, configLocked->getMuteHiddenTracks(),
139 tr("Automatically mute tracks when they are hidden."));
140 glfunc(18, configLocked->getRestoreTrackVisibility(),
141 tr("Restore the previous track visibility on startup."));
142 glfunc(19, configLocked->getOverflowPaste(),
143 tr("Move pasted pattern data outside the rows of the current frame to subsequent frames."));
144
145 // Edit settings
146 ui->pageJumpLengthSpinBox->setValue(static_cast<int>(configLocked->getPageJumpLength()));
147
148 // Wave view
149 ui->waveViewRateSpinBox->setValue(configLocked->getWaveViewFrameRate());
150
151 // Note names
152 {
153 QSignalBlocker blocker(ui->noteNameComboBox);
154 for (const auto& attrib : NOTATION_SYSS) {
155 ui->noteNameComboBox->addItem(QCoreApplication::translate("NotationSystem", attrib.dispName));
156 if (attrib.ev == configLocked->getNotationSystem()) {
157 ui->noteNameComboBox->setCurrentIndex(ui->noteNameComboBox->count() - 1);
158 }
159 }
160 }
161
162 // Keys
163 ui->shortcutsTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
164 ui->shortcutsTreeWidget->header()->setSectionResizeMode(1, QHeaderView::Fixed);
165 struct ActionPair
166 {
167 Configuration::ShortcutAction action;
168 QString text;
169 };
170 const ActionPair shortcutsActions[] = {
171 { Configuration::ShortcutAction::KeyOff, tr("Key release") },
172 { Configuration::ShortcutAction::KeyCut, tr("Key cut") },
173 { Configuration::ShortcutAction::OctaveUp, tr("Octave up") },
174 { Configuration::ShortcutAction::OctaveDown, tr("Octave down") },
175 { Configuration::ShortcutAction::EchoBuffer, tr("Echo buffer") },
176 { Configuration::ShortcutAction::PlayAndStop, tr("Play and stop") },
177 { Configuration::ShortcutAction::Play, tr("Play") },
178 { Configuration::ShortcutAction::PlayFromStart, tr("Play from start") },
179 { Configuration::ShortcutAction::PlayPattern, tr("Play pattern") },
180 { Configuration::ShortcutAction::PlayFromCursor, tr("Play from cursor") },
181 { Configuration::ShortcutAction::PlayFromMarker, tr("Play from marker") },
182 { Configuration::ShortcutAction::PlayStep, tr("Play step") },
183 { Configuration::ShortcutAction::Stop, tr("Stop") },
184 { Configuration::ShortcutAction::FocusOnPattern, tr("Focus on pattern editor") },
185 { Configuration::ShortcutAction::FocusOnOrder, tr("Focus on order list") },
186 { Configuration::ShortcutAction::FocusOnInstrument, tr("Focus on instrument list") },
187 { Configuration::ShortcutAction::ToggleEditJam, tr("Toggle edit/jam mode") },
188 { Configuration::ShortcutAction::SetMarker, tr("Set marker") },
189 { Configuration::ShortcutAction::PasteMix, tr("Paste and mix") },
190 { Configuration::ShortcutAction::PasteOverwrite, tr("Paste and overwrite") },
191 { Configuration::ShortcutAction::PasteInsert, tr("Paste and insert") },
192 { Configuration::ShortcutAction::SelectAll, tr("Select all") },
193 { Configuration::ShortcutAction::Deselect, tr("Deselect") },
194 { Configuration::ShortcutAction::SelectRow, tr("Select row") },
195 { Configuration::ShortcutAction::SelectColumn, tr("Select column") },
196 { Configuration::ShortcutAction::SelectPattern, tr("Select pattern") },
197 { Configuration::ShortcutAction::SelectOrder, tr("Select order") },
198 { Configuration::ShortcutAction::GoToStep, tr("Go to step") },
199 { Configuration::ShortcutAction::ToggleTrack, tr("Toggle track") },
200 { Configuration::ShortcutAction::SoloTrack, tr("Solo track") },
201 { Configuration::ShortcutAction::Interpolate, tr("Interpolate") },
202 { Configuration::ShortcutAction::Reverse, tr("Reverse") },
203 { Configuration::ShortcutAction::GoToPrevOrder, tr("Go to previous order") },
204 { Configuration::ShortcutAction::GoToNextOrder, tr("Go to next order") },
205 { Configuration::ShortcutAction::ToggleBookmark, tr("Toggle bookmark") },
206 { Configuration::ShortcutAction::PrevBookmark, tr("Previous bookmark") },
207 { Configuration::ShortcutAction::NextBookmark, tr("Next bookmark") },
208 { Configuration::ShortcutAction::DecreaseNote, tr("Transpose down one semitone") },
209 { Configuration::ShortcutAction::IncreaseNote, tr("Transpose up one semitone") },
210 { Configuration::ShortcutAction::DecreaseOctave, tr("Transpose down one octave") },
211 { Configuration::ShortcutAction::IncreaseOctave, tr("Transpose up one octave") },
212 { Configuration::ShortcutAction::PrevInstrument, tr("Previous instrument") },
213 { Configuration::ShortcutAction::NextInstrument, tr("Next instrument") },
214 { Configuration::ShortcutAction::MaskInstrument, tr("Mask instrument") },
215 { Configuration::ShortcutAction::MaskVolume, tr("Mask volume") },
216 { Configuration::ShortcutAction::EditInstrument, tr("Edit instrument") },
217 { Configuration::ShortcutAction::FollowMode, tr("Follow mode") },
218 { Configuration::ShortcutAction::DuplicateOrder, tr("Duplicate order") },
219 { Configuration::ShortcutAction::ClonePatterns, tr("Clone patterns") },
220 { Configuration::ShortcutAction::CloneOrder, tr("Clone order") },
221 { Configuration::ShortcutAction::ReplaceInstrument, tr("Replace instrument") },
222 { Configuration::ShortcutAction::ExpandPattern, tr("Expand pattern") },
223 { Configuration::ShortcutAction::ShrinkPattern, tr("Shrink pattern") },
224 { Configuration::ShortcutAction::FineDecreaseValues, tr("Fine decrease values") },
225 { Configuration::ShortcutAction::FineIncreaseValues, tr("Fine increase values") },
226 { Configuration::ShortcutAction::CoarseDecreaseValues, tr("Coarse decrease values") },
227 { Configuration::ShortcutAction::CoarseIncreaseValuse, tr("Coarse increase valuse") },
228 { Configuration::ShortcutAction::ExpandEffect, tr("Expand effect column") },
229 { Configuration::ShortcutAction::ShrinkEffect, tr("Shrink effect column") },
230 { Configuration::ShortcutAction::PrevHighlighted, tr("Previous highlighted step") },
231 { Configuration::ShortcutAction::NextHighlighted, tr("Next highlighted step") },
232 { Configuration::ShortcutAction::IncreasePatternSize, tr("Increase pattern size") },
233 { Configuration::ShortcutAction::DecreasePatternSize, tr("Decrease pattern size") },
234 { Configuration::ShortcutAction::IncreaseEditStep, tr("Increase edit step") },
235 { Configuration::ShortcutAction::DecreaseEditStep, tr("Decrease edit step") },
236 { Configuration::ShortcutAction::DisplayEffectList, tr("Display effect list") },
237 { Configuration::ShortcutAction::PreviousSong, tr("Previous song") },
238 { Configuration::ShortcutAction::NextSong, tr("Next song") },
239 { Configuration::ShortcutAction::JamVolumeUp, tr("Jam volume up") },
240 { Configuration::ShortcutAction::JamVolumeDown, tr("Jam volume down") }
241 };
242 std::unordered_map<Configuration::ShortcutAction, std::string> shortcuts = configLocked->getShortcuts();
243 for (const auto& pair : shortcutsActions) {
244 int row = ui->shortcutsTreeWidget->topLevelItemCount();
245 auto item = new QTreeWidgetItem();
246 item->setText(0, pair.text);
247 ui->shortcutsTreeWidget->insertTopLevelItem(row, item);
248 auto widget = new QWidget();
249 widget->setLayout(new QHBoxLayout());
250 auto seq = new QKeySequenceEdit(gui_utils::utf8ToQString(shortcuts.at(pair.action)));
251 shortcutsMap_[pair.action] = seq;
252 auto button = new QToolButton();
253 button->setIcon(QIcon(":/icon/remove_inst"));
254 QObject::connect(button, &QToolButton::clicked, seq, &QKeySequenceEdit::clear);
255 auto layout = widget->layout();
256 layout->setSpacing(0);
257 layout->setContentsMargins(0, 0, 0, 0);
258 layout->addWidget(seq);
259 layout->addWidget(button);
260 ui->shortcutsTreeWidget->setItemWidget(item, 1, widget);
261 }
262
263 ui->keyboardTypeComboBox->setCurrentIndex(static_cast<int>(configLocked->getNoteEntryLayout()));
264 customLayoutKeysMap_ = {
265 { JamKey::LowC, ui->lowCEdit },
266 { JamKey::LowCS, ui->lowCSEdit },
267 { JamKey::LowD, ui->lowDEdit },
268 { JamKey::LowDS, ui->lowDSEdit },
269 { JamKey::LowE, ui->lowEEdit },
270 { JamKey::LowF, ui->lowFEdit },
271 { JamKey::LowFS, ui->lowFSEdit },
272 { JamKey::LowG, ui->lowGEdit },
273 { JamKey::LowGS, ui->lowGSEdit },
274 { JamKey::LowA, ui->lowAEdit },
275 { JamKey::LowAS, ui->lowASEdit },
276 { JamKey::LowB, ui->lowBEdit },
277 { JamKey::LowC2, ui->lowHighCEdit },
278 { JamKey::LowCS2, ui->lowHighCSEdit },
279 { JamKey::LowD2, ui->lowHighDEdit },
280
281 { JamKey::HighC, ui->highCEdit },
282 { JamKey::HighCS, ui->highCSEdit },
283 { JamKey::HighD, ui->highDEdit },
284 { JamKey::HighDS, ui->highDSEdit },
285 { JamKey::HighE, ui->highEEdit },
286 { JamKey::HighF, ui->highFEdit },
287 { JamKey::HighFS, ui->highFSEdit },
288 { JamKey::HighG, ui->highGEdit },
289 { JamKey::HighGS, ui->highGSEdit },
290 { JamKey::HighA, ui->highAEdit },
291 { JamKey::HighAS, ui->highASEdit },
292 { JamKey::HighB, ui->highBEdit },
293 { JamKey::HighC2, ui->highHighCEdit },
294 { JamKey::HighCS2, ui->highHighCSEdit },
295 { JamKey::HighD2, ui->highHighDEdit }
296 };
297 for (const auto& pair : configLocked->getCustomLayoutKeys()) {
298 customLayoutKeysMap_.at(pair.second)->setKeySequence(QKeySequence(gui_utils::utf8ToQString(pair.first)));
299 }
300 updateNoteNames();
301
302 // Sound //
303 ui->emulatorComboBox->addItem("MAME YM2608", static_cast<int>(chip::OpnaEmulator::Mame));
304 ui->emulatorComboBox->addItem("Nuked OPN-Mod", static_cast<int>(chip::OpnaEmulator::Nuked));
305 ui->emulatorComboBox->addItem("ymfm", static_cast<int>(chip::OpnaEmulator::Ymfm));
306 ui->emulatorComboBox->setCurrentIndex(ui->emulatorComboBox->findData(configLocked->getEmulator()));
307
308 ui->zeroWaitWriteCheckBox->setChecked(configLocked->getImmediateWriteModeEnabled());
309
310 {
311 QSignalBlocker blocker(ui->audioApiComboBox);
312 int sndApiRow = -1;
313 int defSndApiRow = 0;
314 for (auto& name : stream.lock()->getAvailableBackends()) {
315 ui->audioApiComboBox->addItem(name);
316 if (name == QString::fromStdString(configLocked->getSoundAPI()))
317 sndApiRow = ui->audioApiComboBox->count() - 1;
318 if (name == stream.lock()->getCurrentBackend())
319 defSndApiRow = sndApiRow = ui->audioApiComboBox->count() - 1;
320 }
321 ui->audioApiComboBox->setCurrentIndex((sndApiRow == -1) ? defSndApiRow : sndApiRow);
322 }
323 on_audioApiComboBox_currentIndexChanged(ui->audioApiComboBox->currentText());
324
325 ui->realChipComboBox->addItem(tr("None"), static_cast<int>(RealChipInterfaceType::NONE));
326 #ifdef USE_REAL_CHIP
327 ui->realChipComboBox->addItem("SCCI", static_cast<int>(RealChipInterfaceType::SCCI));
328 ui->realChipComboBox->addItem("C86CTL", static_cast<int>(RealChipInterfaceType::C86CTL));
329 #endif
330 switch (configLocked->getRealChipInterface()) {
331 default: // Fall through
332 case RealChipInterfaceType::NONE: ui->realChipComboBox->setCurrentIndex(0); break;
333 case RealChipInterfaceType::SCCI: ui->realChipComboBox->setCurrentIndex(1); break;
334 case RealChipInterfaceType::C86CTL: ui->realChipComboBox->setCurrentIndex(2); break;
335 }
336
337 {
338 QSignalBlocker blocker1(ui->midiInputDeviceComboBox), blocker2(ui->midiApiComboBox);
339 MidiInterface& midiIntf = MidiInterface::getInstance();
340 int midiApiRow = -1;
341 int defMidiApiRow = 0;
342 for (auto& name : midiIntf.getAvailableApis()) {
343 ui->midiApiComboBox->addItem(gui_utils::utf8ToQString(name));
344 if (name == configLocked->getMidiAPI())
345 midiApiRow = ui->midiApiComboBox->count() - 1;
346 if (name == midiIntf.currentApiName())
347 defMidiApiRow = midiApiRow = ui->midiApiComboBox->count() - 1;
348 }
349 ui->midiApiComboBox->setCurrentIndex((midiApiRow == -1) ? defMidiApiRow : midiApiRow);
350 }
351 onMidiApiChanged(ui->midiApiComboBox->currentText(), false);
352 ui->midiInputGroupBox->setChecked(configLocked->getMidiEnabled());
353
354 constexpr uint32_t SAMPLE_RATES[] = { 8000, 16000, 22050, 32000, 44100, 48000, 55466, 96000, 192000, 249600 };
355 constexpr size_t N_SAMPLE_RATES = sizeof(SAMPLE_RATES) / sizeof(SAMPLE_RATES[0]);
356 for (auto rate : SAMPLE_RATES) {
357 ui->sampleRateComboBox->addItem(QString("%1Hz").arg(rate), rate);
358 }
359 ui->sampleRateComboBox->setCurrentIndex(0);
360 for (size_t i = 0; i < N_SAMPLE_RATES; ++i) {
361 if (SAMPLE_RATES[i] == configLocked->getSampleRate()) {
362 ui->sampleRateComboBox->setCurrentIndex(i);
363 }
364 }
365
366 ui->resamplerComboBox->addItem(QString("Linear (%1)").arg(tr("old, deprecated")), static_cast<int>(chip::ResamplerType::Linear));
367 ui->resamplerComboBox->addItem("blip_buf", static_cast<int>(chip::ResamplerType::BlipBuf));
368 ui->resamplerComboBox->addItem(QString("blip_buf (%1)").arg(tr("fast")), static_cast<int>(chip::ResamplerType::FastBlipBuf));
369 for (int i = 0; i < ui->resamplerComboBox->count(); ++i) {
370 if (static_cast<chip::ResamplerType>(ui->resamplerComboBox->itemData(i).toInt()) == configLocked->getResamplerType()) {
371 ui->resamplerComboBox->setCurrentIndex(i);
372 break;
373 }
374 }
375
376 ui->bufferLengthHorizontalSlider->setStyle(SliderStyle::instance());
377 QObject::connect(ui->bufferLengthHorizontalSlider, &QSlider::valueChanged,
378 this, [&](int value) {
379 ui->bufferLengthLabel->setText(QString::number(value) + "ms");
380 });
381 ui->bufferLengthHorizontalSlider->setValue(static_cast<int>(configLocked->getBufferLength()));
382
383 // Mixer //
384 ui->masterMixerSlider->setText(tr("Master"));
385 ui->masterMixerSlider->setSuffix("%");
386 ui->masterMixerSlider->setMaximum(200);
387 ui->masterMixerSlider->setMinimum(0);
388 ui->masterMixerSlider->setTickPosition(QSlider::TicksBothSides);
389 ui->masterMixerSlider->setTickInterval(20);
390 ui->masterMixerSlider->setValue(configLocked->getMixerVolumeMaster());
391
392 ui->fmMixerSlider->setText("FM");
393 ui->fmMixerSlider->setSuffix("dB");
394 ui->fmMixerSlider->setMaximum(120);
395 ui->fmMixerSlider->setMinimum(-120);
396 ui->fmMixerSlider->setValueRate(0.1);
397 ui->fmMixerSlider->setSign(true);
398 ui->fmMixerSlider->setTickPosition(QSlider::TicksBothSides);
399 ui->fmMixerSlider->setTickInterval(20);
400 ui->fmMixerSlider->setValue(static_cast<int>(configLocked->getMixerVolumeFM() * 10));
401
402 ui->ssgMixerSlider->setText("SSG");
403 ui->ssgMixerSlider->setSuffix("dB");
404 ui->ssgMixerSlider->setMaximum(120);
405 ui->ssgMixerSlider->setMinimum(-120);
406 ui->ssgMixerSlider->setValueRate(0.1);
407 ui->ssgMixerSlider->setSign(true);
408 ui->ssgMixerSlider->setTickPosition(QSlider::TicksBothSides);
409 ui->ssgMixerSlider->setTickInterval(20);
410 ui->ssgMixerSlider->setValue(static_cast<int>(configLocked->getMixerVolumeSSG() * 10));
411
412 // Formats //
413 fmEnvelopeTexts_ = configLocked->getFMEnvelopeTexts();
414 updateEnvelopeSetUi();
415
416 // Appearance //
417 ui->colorsTreeWidget->setColumnWidth(0, 250);
418 updateColorTreeFrom(palette.lock().get());
419
420 auto deserializeFont = [](const std::string& fontStr) {
421 QFont font;
422 font.fromString(gui_utils::utf8ToQString(fontStr));
423 return font;
424 };
425 ui->ptnHdFontInfoWidget->setFontInfo(deserializeFont(configLocked->getPatternEditorHeaderFont()));
426 ui->ptnRowFontInfoWidget->setFontInfo(deserializeFont(configLocked->getPatternEditorRowsFont()));
427 ui->odrHdFontInfoWidget->setFontInfo(deserializeFont(configLocked->getOrderListHeaderFont()));
428 ui->odrRowFontInfoWidget->setFontInfo(deserializeFont(configLocked->getOrderListRowsFont()));
429 }
430
431 ConfigurationDialog::~ConfigurationDialog()
432 {
433 delete ui;
434 }
435
436 void ConfigurationDialog::on_ConfigurationDialog_accepted()
437 {
438 std::shared_ptr<Configuration> configLocked = config_.lock();
439 // General //
440 // General settings
441 configLocked->setWarpCursor(fromCheckState(ui->generalSettingsListWidget->item(0)->checkState()));
442 configLocked->setWarpAcrossOrders(fromCheckState(ui->generalSettingsListWidget->item(1)->checkState()));
443 configLocked->setShowRowNumberInHex(fromCheckState(ui->generalSettingsListWidget->item(2)->checkState()));
444 configLocked->setShowPreviousNextOrders(fromCheckState(ui->generalSettingsListWidget->item(3)->checkState()));
445 configLocked->setBackupModules(fromCheckState(ui->generalSettingsListWidget->item(4)->checkState()));
446 configLocked->setDontSelectOnDoubleClick(fromCheckState(ui->generalSettingsListWidget->item(5)->checkState()));
447 configLocked->setReverseFMVolumeOrder(fromCheckState(ui->generalSettingsListWidget->item(6)->checkState()));
448 configLocked->setMoveCursorToRight(fromCheckState(ui->generalSettingsListWidget->item(7)->checkState()));
449 configLocked->setRetrieveChannelState(fromCheckState(ui->generalSettingsListWidget->item(8)->checkState()));
450 configLocked->setEnableTranslation(fromCheckState(ui->generalSettingsListWidget->item(9)->checkState()));
451 configLocked->setShowFMDetuneAsSigned(fromCheckState(ui->generalSettingsListWidget->item(10)->checkState()));
452 configLocked->setFill00ToEffectValue(fromCheckState(ui->generalSettingsListWidget->item(11)->checkState()));
453 configLocked->setMoveCursorByHorizontalScroll(fromCheckState(ui->generalSettingsListWidget->item(12)->checkState()));
454 configLocked->setOverwriteUnusedUneditedPropety(fromCheckState(ui->generalSettingsListWidget->item(13)->checkState()));
455 configLocked->setWriteOnlyUsedSamples(fromCheckState(ui->generalSettingsListWidget->item(14)->checkState()));
456 configLocked->setReflectInstrumentNumberChange(fromCheckState(ui->generalSettingsListWidget->item(15)->checkState()));
457 configLocked->setFixJammingVolume(fromCheckState(ui->generalSettingsListWidget->item(16)->checkState()));
458 configLocked->setMuteHiddenTracks(fromCheckState(ui->generalSettingsListWidget->item(17)->checkState()));
459 configLocked->setRestoreTrackVisibility(fromCheckState(ui->generalSettingsListWidget->item(18)->checkState()));
460 configLocked->setOverflowPaste(fromCheckState(ui->generalSettingsListWidget->item(19)->checkState()));
461
462 // Edit settings
463 configLocked->setPageJumpLength(static_cast<size_t>(ui->pageJumpLengthSpinBox->value()));
464
465 // Wave view
466 configLocked->setWaveViewFrameRate(ui->waveViewRateSpinBox->value());
467
468 // Note names
469 configLocked->setNotationSystem(NOTATION_SYSS[ui->noteNameComboBox->currentIndex()].ev);
470
471 // Keys
472 std::unordered_map<Configuration::ShortcutAction, std::string> shortcuts;
473 for (const auto& pair: shortcutsMap_) {
474 shortcuts[pair.first] = pair.second->keySequence().toString().toStdString();
475 }
476 configLocked->setShortcuts(shortcuts);
477
478 configLocked->setNoteEntryLayout(static_cast<Configuration::KeyboardLayout>(ui->keyboardTypeComboBox->currentIndex()));
479 std::unordered_map<std::string, JamKey> customLayoutNewKeys;
480 for (const auto& pair : customLayoutKeysMap_) {
481 customLayoutNewKeys[pair.second->keySequence().toString().toStdString()] = pair.first;
482 }
483 configLocked->setCustomLayoutKeys(customLayoutNewKeys);
484
485 // Sound //
486 int emu = ui->emulatorComboBox->currentData().toInt();
487 bool changedEmu = false;
488 if (emu != configLocked->getEmulator()) {
489 configLocked->setEmulator(emu);
490 changedEmu = true;
491 }
492
493 configLocked->setImmediateWriteModeEnabled(ui->zeroWaitWriteCheckBox->isChecked());
494
495 configLocked->setSoundDevice(ui->audioDeviceComboBox->currentText().toUtf8().toStdString());
496 configLocked->setSoundAPI(ui->audioApiComboBox->currentText().toUtf8().toStdString());
497 configLocked->setRealChipInterface(static_cast<RealChipInterfaceType>(
498 ui->realChipComboBox->currentData(Qt::UserRole).toInt()));
499 configLocked->setMidiEnabled(ui->midiInputGroupBox->isChecked());
500 configLocked->setMidiAPI(ui->midiApiComboBox->currentText().toUtf8().toStdString());
501 configLocked->setMidiInputPort(ui->midiInputDeviceComboBox->currentData().toString().toUtf8().toStdString());
502 configLocked->setSampleRate(ui->sampleRateComboBox->currentData(Qt::UserRole).toUInt());
503 configLocked->setResamplerType(static_cast<chip::ResamplerType>(ui->resamplerComboBox->currentData().toInt()));
504 configLocked->setBufferLength(static_cast<size_t>(ui->bufferLengthHorizontalSlider->value()));
505
506 // Mixer //
507 configLocked->setMixerVolumeMaster(ui->masterMixerSlider->value());
508 configLocked->setMixerVolumeFM(ui->fmMixerSlider->value() * 0.1);
509 configLocked->setMixerVolumeSSG(ui->ssgMixerSlider->value() * 0.1);
510
511 // Formats //
512 std::sort(fmEnvelopeTexts_.begin(), fmEnvelopeTexts_.end(),
513 [](const FMEnvelopeText& a, const FMEnvelopeText& b) -> bool { return (a.name < b.name); });
514 configLocked->setFMEnvelopeTexts(fmEnvelopeTexts_);
515
516 // Appearance //
517 setPaletteFromColorTree(refPalette_.lock().get());
518 configLocked->setPatternEditorHeaderFont(ui->ptnHdFontInfoWidget->getFontInfo().toString().toStdString());
519 configLocked->setPatternEditorRowsFont(ui->ptnRowFontInfoWidget->getFontInfo().toString().toStdString());
520 configLocked->setOrderListHeaderFont(ui->odrHdFontInfoWidget->getFontInfo().toString().toStdString());
521 configLocked->setOrderListRowsFont(ui->odrRowFontInfoWidget->getFontInfo().toString().toStdString());
522
523 if (changedEmu) {
524 QMessageBox::information(this, tr("Configuration"), tr("The change of emulator will be effective after restarting the program."));
525 }
526 }
527
528 /***** General *****/
529 void ConfigurationDialog::on_generalSettingsListWidget_itemSelectionChanged()
530 {
531 QString text("");
532 if (QListWidgetItem* item = ui->generalSettingsListWidget->currentItem()) {
533 text = item->data(Qt::UserRole).toString();
534 }
535 ui->descPlainTextEdit->setPlainText(tr("Description: %1").arg(text));
536 }
537
538 void ConfigurationDialog::on_noteNameComboBox_currentIndexChanged(int index)
539 {
540 // Change notation system temporary
541 NoteNameManager& man = NoteNameManager::getManager();
542 man.setNotationSystem(NOTATION_SYSS[index].ev);
543 updateNoteNames();
544
545 // Restore global notation system
546 for (const auto& attrib : NOTATION_SYSS) {
547 if (attrib.ev == config_.lock()->getNotationSystem()) {
548 man.setNotationSystem(attrib.ev);
549 return;
550 }
551 }
552 }
553
554 /***** Mixer *****/
555 void ConfigurationDialog::on_mixerResetPushButton_clicked()
556 {
557 ui->fmMixerSlider->setValue(0);
558 ui->ssgMixerSlider->setValue(0);
559 }
560
561 /***** Sound *****/
562 void ConfigurationDialog::on_audioApiComboBox_currentIndexChanged(const QString &arg1)
563 {
564 ui->audioDeviceComboBox->clear();
565 std::vector<QString> devices = stream_.lock()->getAvailableDevices(arg1);
566 if (devices.empty()) {
567 ui->audioDeviceComboBox->setEnabled(false);
568 return;
569 }
570 else {
571 ui->audioDeviceComboBox->setEnabled(true);
572 }
573 int devRow = -1;
574 int defDevRow = 0;
575 for (auto& name : devices) {
576 ui->audioDeviceComboBox->addItem(name);
577 if (name == gui_utils::utf8ToQString(config_.lock()->getSoundDevice()))
578 devRow = ui->audioDeviceComboBox->count() - 1;
579 if (name == stream_.lock()->getDefaultOutputDevice(arg1))
580 defDevRow = ui->audioDeviceComboBox->count() - 1;
581 }
582 ui->audioDeviceComboBox->setCurrentIndex((devRow == -1) ? defDevRow : devRow);
583 }
584
585 void ConfigurationDialog::on_midiApiComboBox_currentIndexChanged(const QString &arg1)
586 {
587 onMidiApiChanged(arg1);
588 }
589
590 void ConfigurationDialog::onMidiApiChanged(const QString &arg1, bool hasInitialized)
591 {
592 ui->midiInputDeviceComboBox->clear();
593
594 MidiInterface &intf = MidiInterface::getInstance();
595 std::vector<std::string> ports;
596 bool vport;
597 std::string apiName = arg1.toStdString();
598 if (intf.currentApiName() == apiName) {
599 ports = intf.getRealInputPorts();
600 vport = intf.supportsVirtualPort();
601 }
602 else {
603 ports = intf.getRealInputPorts(apiName);
604 vport = intf.supportsVirtualPort(apiName);
605 }
606
607 int devRow = -1;
608 if (vport) {
609 ui->midiInputDeviceComboBox->addItem(tr("Virtual port"), QString());
610 }
611 else if (ports.empty()) {
612 ui->midiInputDeviceComboBox->setEnabled(false);
613 return;
614 }
615 if (hasInitialized) // To reflect unchecked groupbox when displaying the dialog for the first time
616 ui->midiInputDeviceComboBox->setEnabled(true);
617 for (auto& portName : ports) {
618 auto name = QString::fromStdString(portName);
619 ui->midiInputDeviceComboBox->addItem(name, name);
620 if (portName == config_.lock()->getMidiInputPort())
621 devRow = ui->midiInputDeviceComboBox->count() - 1;
622 }
623 ui->midiInputDeviceComboBox->setCurrentIndex((devRow == -1) ? 0 : devRow);
624 }
625
626 /*****Formats *****/
627 void ConfigurationDialog::on_addEnvelopeSetPushButton_clicked()
628 {
629 auto name = tr("Set %1").arg(fmEnvelopeTexts_.size() + 1);
630 fmEnvelopeTexts_.push_back({ name.toUtf8().toStdString(), std::vector<FMEnvelopeTextType>() });
631 updateEnvelopeSetUi();
632 for (int i = ui->envelopeTypeListWidget->count() - 1; i >= 0; --i) {
633 if (ui->envelopeTypeListWidget->item(i)->text() == name) {
634 ui->envelopeTypeListWidget->setCurrentRow(i);
635 break;
636 }
637 }
638 }
639
640 void ConfigurationDialog::on_removeEnvelopeSetpushButton_clicked()
641 {
642 fmEnvelopeTexts_.erase(fmEnvelopeTexts_.begin() + ui->envelopeTypeListWidget->currentRow());
643 updateEnvelopeSetUi();
644 }
645
646 void ConfigurationDialog::on_editEnvelopeSetPushButton_clicked()
647 {
648 size_t row = static_cast<size_t>(ui->envelopeTypeListWidget->currentRow());
649 FMEnvelopeSetEditDialog dialog(fmEnvelopeTexts_.at(row).texts, this);
650 dialog.setWindowTitle(dialog.windowTitle() + ": " + ui->envelopeSetNameLineEdit->text());
651 if (dialog.exec() == QDialog::Accepted) {
652 fmEnvelopeTexts_.at(row).texts = dialog.getSet();
653 }
654 }
655
656 void ConfigurationDialog::on_envelopeSetNameLineEdit_textChanged(const QString &arg1)
657 {
658 fmEnvelopeTexts_.at(static_cast<size_t>(ui->envelopeTypeListWidget->currentRow())).name = arg1.toStdString();
659 ui->envelopeTypeListWidget->currentItem()->setText(arg1);
660 }
661
662 void ConfigurationDialog::on_envelopeTypeListWidget_currentRowChanged(int currentRow)
663 {
664 if (currentRow == -1) {
665 ui->editEnvelopeSetPushButton->setEnabled(false);
666 ui->removeEnvelopeSetpushButton->setEnabled(false);
667 ui->envelopeSetNameLineEdit->setEnabled(false);
668 }
669 else {
670 ui->editEnvelopeSetPushButton->setEnabled(true);
671 ui->removeEnvelopeSetpushButton->setEnabled(true);
672 ui->envelopeSetNameLineEdit->setEnabled(true);
673 ui->envelopeSetNameLineEdit->setText(ui->envelopeTypeListWidget->item(currentRow)->text());
674 }
675 }
676
677 void ConfigurationDialog::updateEnvelopeSetUi()
678 {
679 std::sort(fmEnvelopeTexts_.begin(), fmEnvelopeTexts_.end(),
680 [](const FMEnvelopeText& a, const FMEnvelopeText& b) -> bool { return (a.name < b.name); });
681
682 ui->envelopeTypeListWidget->clear();
683 for (auto& texts : fmEnvelopeTexts_)
684 ui->envelopeTypeListWidget->addItem(gui_utils::utf8ToQString(texts.name));
685 }
686
687 /***** Keys *****/
688 void ConfigurationDialog::on_keyboardTypeComboBox_currentIndexChanged(int)
689 {
690 bool enableCustomLayoutInterface = ui->keyboardTypeComboBox->currentIndex() == 0;
691 ui->lowHighKeysTabWidget->setEnabled(enableCustomLayoutInterface);
692 ui->customLayoutResetButton->setEnabled(enableCustomLayoutInterface);
693 }
694
695 void ConfigurationDialog::on_customLayoutResetButton_clicked()
696 {
697 std::unordered_map<std::string, JamKey> QWERTYLayoutMapping = config_.lock()->mappingLayouts.at (Configuration::KeyboardLayout::QWERTY);
698 std::unordered_map<std::string, JamKey>::const_iterator QWERTYLayoutMappingIterator = QWERTYLayoutMapping.begin();
699 while (QWERTYLayoutMappingIterator != QWERTYLayoutMapping.end()) {
700 customLayoutKeysMap_.at(QWERTYLayoutMappingIterator->second)->setKeySequence(QKeySequence(QString::fromStdString(QWERTYLayoutMappingIterator->first)));
701 QWERTYLayoutMappingIterator++;
702 }
703 }
704
705 void ConfigurationDialog::addShortcutItem(QString action, std::string shortcut)
706 {
707 int row = ui->shortcutsTreeWidget->topLevelItemCount();
708 auto titem = new QTreeWidgetItem();
709 titem->setText(0, action);
710 ui->shortcutsTreeWidget->insertTopLevelItem(row, titem);
711 ui->shortcutsTreeWidget->setItemWidget(titem, 1, new QKeySequenceEdit(gui_utils::utf8ToQString(shortcut)));
712 }
713
714 std::string ConfigurationDialog::getShortcutString(int row) const
715 {
716 return qobject_cast<QKeySequenceEdit*>(
717 ui->shortcutsTreeWidget->itemWidget(ui->shortcutsTreeWidget->topLevelItem(row), 1)
718 )->keySequence().toString().toStdString();
719 }
720
721 void ConfigurationDialog::updateNoteNames()
722 {
723 const NoteNameManager& man = NoteNameManager::getManager();
724 ui->lowCLabel->setText(man.getNoteName(0));
725 ui->lowCSLabel->setText(man.getNoteName(1));
726 ui->lowDLabel->setText(man.getNoteName(2));
727 ui->lowDSLabel->setText(man.getNoteName(3));
728 ui->lowELabel->setText(man.getNoteName(4));
729 ui->lowFLabel->setText(man.getNoteName(5));
730 ui->lowFSLabel->setText(man.getNoteName(6));
731 ui->lowGLabel->setText(man.getNoteName(7));
732 ui->lowGSLabel->setText(man.getNoteName(8));
733 ui->lowALabel->setText(man.getNoteName(9));
734 ui->lowASLabel->setText(man.getNoteName(10));
735 ui->lowBLabel->setText(man.getNoteName(11));
736 ui->lowHighCLabel->setText(man.getNoteName(0));
737 ui->lowHighCSLabel->setText(man.getNoteName(1));
738 ui->lowHighDLabel->setText(man.getNoteName(2));
739 ui->highCLabel->setText(man.getNoteName(0));
740 ui->highCSLabel->setText(man.getNoteName(1));
741 ui->highDLabel->setText(man.getNoteName(2));
742 ui->highDSLabel->setText(man.getNoteName(3));
743 ui->highELabel->setText(man.getNoteName(4));
744 ui->highFLabel->setText(man.getNoteName(5));
745 ui->highFSLabel->setText(man.getNoteName(6));
746 ui->highGLabel->setText(man.getNoteName(7));
747 ui->highGSLabel->setText(man.getNoteName(8));
748 ui->highALabel->setText(man.getNoteName(9));
749 ui->highASLabel->setText(man.getNoteName(10));
750 ui->highBLabel->setText(man.getNoteName(11));
751 ui->highHighCLabel->setText(man.getNoteName(0));
752 ui->highHighCSLabel->setText(man.getNoteName(1));
753 ui->highHighDLabel->setText(man.getNoteName(2));
754 }
755
756 /***** Appearance *****/
757 void ConfigurationDialog::on_colorEditPushButton_clicked()
758 {
759 QTreeWidgetItem* item = ui->colorsTreeWidget->currentItem();
760 if (item == nullptr || item->parent() == nullptr) return;
761 QColorDialog dialog(item->data(1, Qt::BackgroundRole).value<QColor>(), this);
762 dialog.setOption(QColorDialog::ShowAlphaChannel);
763 if (dialog.exec() == QDialog::Accepted)
764 item->setData(1, Qt::BackgroundRole, dialog.currentColor());
765 }
766
767 void ConfigurationDialog::on_colorLoadPushButton_clicked()
768 {
769 QString file = QFileDialog::getOpenFileName(this, tr("Open color scheme"),
770 QApplication::applicationDirPath() + "/skins",
771 tr("ini file (*.ini)") + ";;" + tr("All files (*)"), nullptr
772 #if defined(Q_OS_LINUX) || (defined(Q_OS_BSD4) && !defined(Q_OS_DARWIN))
773 , QFileDialog::DontUseNativeDialog
774 #endif
775 );
776 if (file.isNull()) return;
777
778 ColorPalette palette;
779 if (io::loadPalette(file, &palette)) {
780 updateColorTreeFrom(&palette);
781 }
782 else {
783 QMessageBox::critical(this, tr("Error"), tr("An unknown error occurred while loading the color scheme."));
784 }
785 }
786
787 void ConfigurationDialog::on_colorSavePushButton_clicked()
788 {
789 QString file = QFileDialog::getSaveFileName(this, tr("Save color scheme"),
790 QApplication::applicationDirPath() + "/skins",
791 tr("ini file (*.ini)") + ";;" + tr("All files (*)"), nullptr
792 #if defined(Q_OS_LINUX) || (defined(Q_OS_BSD4) && !defined(Q_OS_DARWIN))
793 , QFileDialog::DontUseNativeDialog
794 #endif
795 );
796 if (file.isNull()) return;
797 if (!file.endsWith(".ini")) file += ".ini"; // For linux
798
799 ColorPalette palette;
800 setPaletteFromColorTree(&palette);
801 if (!io::savePalette(file, &palette))
802 QMessageBox::critical(this, tr("Error"), tr("Failed to save the color scheme."));
803 }
804
805 void ConfigurationDialog::updateColorTreeFrom(const ColorPalette* const palette)
806 {
807 QTreeWidgetItem* ptnColors = ui->colorsTreeWidget->topLevelItem(0);
808 ptnColors->child(0)->setData(1, Qt::BackgroundRole, palette->ptnDefTextColor);
809 ptnColors->child(1)->setData(1, Qt::BackgroundRole, palette->ptnDefStepColor);
810 ptnColors->child(2)->setData(1, Qt::BackgroundRole, palette->ptnHl1StepColor);
811 ptnColors->child(3)->setData(1, Qt::BackgroundRole, palette->ptnHl2StepColor);
812 ptnColors->child(4)->setData(1, Qt::BackgroundRole, palette->ptnCurTextColor);
813 ptnColors->child(5)->setData(1, Qt::BackgroundRole, palette->ptnCurStepColor);
814 ptnColors->child(6)->setData(1, Qt::BackgroundRole, palette->ptnCurEditStepColor);
815 ptnColors->child(7)->setData(1, Qt::BackgroundRole, palette->ptnCurCellColor);
816 ptnColors->child(8)->setData(1, Qt::BackgroundRole, palette->ptnPlayStepColor);
817 ptnColors->child(9)->setData(1, Qt::BackgroundRole, palette->ptnSelCellColor);
818 ptnColors->child(10)->setData(1, Qt::BackgroundRole, palette->ptnHovCellColor);
819 ptnColors->child(11)->setData(1, Qt::BackgroundRole, palette->ptnDefStepNumColor);
820 ptnColors->child(12)->setData(1, Qt::BackgroundRole, palette->ptnHl1StepNumColor);
821 ptnColors->child(13)->setData(1, Qt::BackgroundRole, palette->ptnHl2StepNumColor);
822 ptnColors->child(14)->setData(1, Qt::BackgroundRole, palette->ptnNoteColor);
823 ptnColors->child(15)->setData(1, Qt::BackgroundRole, palette->ptnInstColor);
824 ptnColors->child(16)->setData(1, Qt::BackgroundRole, palette->ptnVolColor);
825 ptnColors->child(17)->setData(1, Qt::BackgroundRole, palette->ptnEffColor);
826 ptnColors->child(18)->setData(1, Qt::BackgroundRole, palette->ptnErrorColor);
827 ptnColors->child(19)->setData(1, Qt::BackgroundRole, palette->ptnHeaderTextColor);
828 ptnColors->child(20)->setData(1, Qt::BackgroundRole, palette->ptnHeaderRowColor);
829 ptnColors->child(21)->setData(1, Qt::BackgroundRole, palette->ptnMaskColor);
830 ptnColors->child(22)->setData(1, Qt::BackgroundRole, palette->ptnBorderColor);
831 ptnColors->child(23)->setData(1, Qt::BackgroundRole, palette->ptnHeaderBorderColor);
832 ptnColors->child(24)->setData(1, Qt::BackgroundRole, palette->ptnMuteColor);
833 ptnColors->child(25)->setData(1, Qt::BackgroundRole, palette->ptnUnmuteColor);
834 ptnColors->child(26)->setData(1, Qt::BackgroundRole, palette->ptnBackColor);
835 ptnColors->child(27)->setData(1, Qt::BackgroundRole, palette->ptnMarkerColor);
836 ptnColors->child(28)->setData(1, Qt::BackgroundRole, palette->ptnUnfocusedShadowColor);
837
838 QTreeWidgetItem* odrColors = ui->colorsTreeWidget->topLevelItem(1);
839 odrColors->child(0)->setData(1, Qt::BackgroundRole, palette->odrDefTextColor);
840 odrColors->child(1)->setData(1, Qt::BackgroundRole, palette->odrDefRowColor);
841 odrColors->child(2)->setData(1, Qt::BackgroundRole, palette->odrCurTextColor);
842 odrColors->child(3)->setData(1, Qt::BackgroundRole, palette->odrCurRowColor);
843 odrColors->child(4)->setData(1, Qt::BackgroundRole, palette->odrCurEditRowColor);
844 odrColors->child(5)->setData(1, Qt::BackgroundRole, palette->odrCurCellColor);
845 odrColors->child(6)->setData(1, Qt::BackgroundRole, palette->odrPlayRowColor);
846 odrColors->child(7)->setData(1, Qt::BackgroundRole, palette->odrSelCellColor);
847 odrColors->child(8)->setData(1, Qt::BackgroundRole, palette->odrHovCellColor);
848 odrColors->child(9)->setData(1, Qt::BackgroundRole, palette->odrRowNumColor);
849 odrColors->child(10)->setData(1, Qt::BackgroundRole, palette->odrHeaderTextColor);
850 odrColors->child(11)->setData(1, Qt::BackgroundRole, palette->odrHeaderRowColor);
851 odrColors->child(12)->setData(1, Qt::BackgroundRole, palette->odrBorderColor);
852 odrColors->child(13)->setData(1, Qt::BackgroundRole, palette->odrHeaderBorderColor);
853 odrColors->child(14)->setData(1, Qt::BackgroundRole, palette->odrBackColor);
854 odrColors->child(15)->setData(1, Qt::BackgroundRole, palette->odrUnfocusedShadowColor);
855
856 QTreeWidgetItem* ilistColors = ui->colorsTreeWidget->topLevelItem(2);
857 ilistColors->child(0)->setData(1, Qt::BackgroundRole, palette->ilistTextColor);
858 ilistColors->child(1)->setData(1, Qt::BackgroundRole, palette->ilistBackColor);
859 ilistColors->child(2)->setData(1, Qt::BackgroundRole, palette->ilistSelBackColor);
860 ilistColors->child(3)->setData(1, Qt::BackgroundRole, palette->ilistHovBackColor);
861 ilistColors->child(4)->setData(1, Qt::BackgroundRole, palette->ilistHovSelBackColor);
862
863 QTreeWidgetItem* wavColors = ui->colorsTreeWidget->topLevelItem(3);
864 wavColors->child(0)->setData(1, Qt::BackgroundRole, palette->wavBackColor);
865 wavColors->child(1)->setData(1, Qt::BackgroundRole, palette->wavDrawColor);
866 }
867
868 void ConfigurationDialog::setPaletteFromColorTree(ColorPalette* const palette)
869 {
870 QTreeWidgetItem* ptnColors = ui->colorsTreeWidget->topLevelItem(0);
871 palette->ptnDefTextColor = ptnColors->child(0)->data(1, Qt::BackgroundRole).value<QColor>();
872 palette->ptnDefStepColor = ptnColors->child(1)->data(1, Qt::BackgroundRole).value<QColor>();
873 palette->ptnHl1StepColor = ptnColors->child(2)->data(1, Qt::BackgroundRole).value<QColor>();
874 palette->ptnHl2StepColor = ptnColors->child(3)->data(1, Qt::BackgroundRole).value<QColor>();
875 palette->ptnCurTextColor = ptnColors->child(4)->data(1, Qt::BackgroundRole).value<QColor>();
876 palette->ptnCurStepColor = ptnColors->child(5)->data(1, Qt::BackgroundRole).value<QColor>();
877 palette->ptnCurEditStepColor = ptnColors->child(6)->data(1, Qt::BackgroundRole).value<QColor>();
878 palette->ptnCurCellColor = ptnColors->child(7)->data(1, Qt::BackgroundRole).value<QColor>();
879 palette->ptnPlayStepColor = ptnColors->child(8)->data(1, Qt::BackgroundRole).value<QColor>();
880 palette->ptnSelCellColor = ptnColors->child(9)->data(1, Qt::BackgroundRole).value<QColor>();
881 palette->ptnHovCellColor = ptnColors->child(10)->data(1, Qt::BackgroundRole).value<QColor>();
882 palette->ptnDefStepNumColor = ptnColors->child(11)->data(1, Qt::BackgroundRole).value<QColor>();
883 palette->ptnHl1StepNumColor = ptnColors->child(12)->data(1, Qt::BackgroundRole).value<QColor>();
884 palette->ptnHl2StepNumColor = ptnColors->child(13)->data(1, Qt::BackgroundRole).value<QColor>();
885 palette->ptnNoteColor = ptnColors->child(14)->data(1, Qt::BackgroundRole).value<QColor>();
886 palette->ptnInstColor = ptnColors->child(15)->data(1, Qt::BackgroundRole).value<QColor>();
887 palette->ptnVolColor = ptnColors->child(16)->data(1, Qt::BackgroundRole).value<QColor>();
888 palette->ptnEffColor = ptnColors->child(17)->data(1, Qt::BackgroundRole).value<QColor>();
889 palette->ptnErrorColor = ptnColors->child(18)->data(1, Qt::BackgroundRole).value<QColor>();
890 palette->ptnHeaderTextColor = ptnColors->child(19)->data(1, Qt::BackgroundRole).value<QColor>();
891 palette->ptnHeaderRowColor = ptnColors->child(20)->data(1, Qt::BackgroundRole).value<QColor>();
892 palette->ptnMaskColor = ptnColors->child(21)->data(1, Qt::BackgroundRole).value<QColor>();
893 palette->ptnBorderColor = ptnColors->child(22)->data(1, Qt::BackgroundRole).value<QColor>();
894 palette->ptnHeaderBorderColor = ptnColors->child(23)->data(1, Qt::BackgroundRole).value<QColor>();
895 palette->ptnMuteColor = ptnColors->child(24)->data(1, Qt::BackgroundRole).value<QColor>();
896 palette->ptnUnmuteColor = ptnColors->child(25)->data(1, Qt::BackgroundRole).value<QColor>();
897 palette->ptnBackColor = ptnColors->child(26)->data(1, Qt::BackgroundRole).value<QColor>();
898 palette->ptnMarkerColor = ptnColors->child(27)->data(1, Qt::BackgroundRole).value<QColor>();
899 palette->ptnUnfocusedShadowColor = ptnColors->child(28)->data(1, Qt::BackgroundRole).value<QColor>();
900
901 QTreeWidgetItem* odrColors = ui->colorsTreeWidget->topLevelItem(1);
902 palette->odrDefTextColor = odrColors->child(0)->data(1, Qt::BackgroundRole).value<QColor>();
903 palette->odrDefRowColor = odrColors->child(1)->data(1, Qt::BackgroundRole).value<QColor>();
904 palette->odrCurTextColor = odrColors->child(2)->data(1, Qt::BackgroundRole).value<QColor>();
905 palette->odrCurRowColor = odrColors->child(3)->data(1, Qt::BackgroundRole).value<QColor>();
906 palette->odrCurEditRowColor = odrColors->child(4)->data(1, Qt::BackgroundRole).value<QColor>();
907 palette->odrCurCellColor = odrColors->child(5)->data(1, Qt::BackgroundRole).value<QColor>();
908 palette->odrPlayRowColor = odrColors->child(6)->data(1, Qt::BackgroundRole).value<QColor>();
909 palette->odrSelCellColor = odrColors->child(7)->data(1, Qt::BackgroundRole).value<QColor>();
910 palette->odrHovCellColor = odrColors->child(8)->data(1, Qt::BackgroundRole).value<QColor>();
911 palette->odrRowNumColor = odrColors->child(9)->data(1, Qt::BackgroundRole).value<QColor>();
912 palette->odrHeaderTextColor = odrColors->child(10)->data(1, Qt::BackgroundRole).value<QColor>();
913 palette->odrHeaderRowColor = odrColors->child(11)->data(1, Qt::BackgroundRole).value<QColor>();
914 palette->odrBorderColor = odrColors->child(12)->data(1, Qt::BackgroundRole).value<QColor>();
915 palette->odrHeaderBorderColor = odrColors->child(13)->data(1, Qt::BackgroundRole).value<QColor>();
916 palette->odrBackColor = odrColors->child(14)->data(1, Qt::BackgroundRole).value<QColor>();
917 palette->odrUnfocusedShadowColor = odrColors->child(15)->data(1, Qt::BackgroundRole).value<QColor>();
918
919 QTreeWidgetItem* ilistColors = ui->colorsTreeWidget->topLevelItem(2);
920 palette->ilistTextColor = ilistColors->child(0)->data(1, Qt::BackgroundRole).value<QColor>();
921 palette->ilistBackColor = ilistColors->child(1)->data(1, Qt::BackgroundRole).value<QColor>();
922 palette->ilistSelBackColor = ilistColors->child(2)->data(1, Qt::BackgroundRole).value<QColor>();
923 palette->ilistHovBackColor = ilistColors->child(3)->data(1, Qt::BackgroundRole).value<QColor>();
924 palette->ilistHovSelBackColor = ilistColors->child(4)->data(1, Qt::BackgroundRole).value<QColor>();
925
926 QTreeWidgetItem* wavColors = ui->colorsTreeWidget->topLevelItem(3);
927 palette->wavBackColor = wavColors->child(0)->data(1, Qt::BackgroundRole).value<QColor>();
928 palette->wavDrawColor = wavColors->child(1)->data(1, Qt::BackgroundRole).value<QColor>();
929 }