1 #include "input_mapping_dialog.h"
3 #include "ui_input_mapping.h"
9 InputMappingDialog::InputMappingDialog()
10 : ui(new Ui::InputMappingDialog)
14 //connect(ui->button_box, &QDialogButtonBox::accepted, [this]{ this->close(); });
15 vector<string> card_names = global_mixer->get_audio_mixer()->get_names();
16 fill_ui_from_mapping(global_mixer->get_audio_mixer()->get_input_mapping(), card_names);
19 void InputMappingDialog::fill_ui_from_mapping(const InputMapping &mapping, const vector<string> &card_names)
21 ui->table->verticalHeader()->hide();
22 ui->table->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
23 ui->table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
24 ui->table->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
25 ui->table->horizontalHeader()->setSectionsClickable(false);
27 ui->table->setRowCount(mapping.inputs.size());
28 for (unsigned row = 0; row < mapping.inputs.size(); ++row) {
29 // TODO: Mark as some sort of header (by means of background color, probably).
30 QString name(QString::fromStdString(mapping.inputs[row].name));
31 ui->table->setItem(row, 0, new QTableWidgetItem(name));
34 QComboBox *card_combo = new QComboBox;
35 card_combo->addItem(QString("(none) "));
36 for (const string &name : card_names) {
37 card_combo->addItem(QString::fromStdString(name + " "));
39 switch (mapping.inputs[row].input_source_type) {
40 case InputSourceType::SILENCE:
41 card_combo->setCurrentIndex(0);
43 case InputSourceType::CAPTURE_CARD:
44 card_combo->setCurrentIndex(mapping.inputs[row].input_source_index + 1);
49 ui->table->setCellWidget(row, 1, card_combo);
51 // Left and right channel.
52 fill_channel_ui_from_mapping(row, mapping.inputs[row]);
56 void InputMappingDialog::fill_channel_ui_from_mapping(unsigned row, const InputMapping::Input &input)
58 for (unsigned channel = 0; channel < 2; ++channel) {
59 QComboBox *channel_combo = new QComboBox;
60 channel_combo->addItem(QString("(none)"));
61 if (input.input_source_type == InputSourceType::CAPTURE_CARD) {
62 for (unsigned source = 0; source < 8; ++source) { // TODO: Ask the card about number of channels, and names.
64 snprintf(buf, sizeof(buf), "Channel %u ", source + 1);
65 channel_combo->addItem(QString(buf));
68 channel_combo->setCurrentIndex(input.source_channel[channel] + 1);
69 ui->table->setCellWidget(row, 2 + channel, channel_combo);