| 
									
										
										
										
											2016-05-04 17:07:26 +02:00
										 |  |  | #include <gui/audiodialog.h>
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include <QTreeWidgetItem>
 | 
					
						
							| 
									
										
										
										
											2016-05-04 17:07:26 +02:00
										 |  |  | #include "ui_audiodialog.h"
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #include "audio/audiodeviceinfo.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-04 17:07:26 +02:00
										 |  |  | AudioDialog::AudioDialog(AudioDeviceInfo* audioDeviceInfo, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	QDialog(parent), | 
					
						
							| 
									
										
										
										
											2016-05-04 17:07:26 +02:00
										 |  |  | 	ui(new Ui::AudioDialog), | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	m_audioDeviceInfo(audioDeviceInfo) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ui->setupUi(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const AudioDeviceInfo::Devices& devices = audioDeviceInfo->getDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QTreeWidgetItem* api; | 
					
						
							|  |  |  | 	QStringList sl; | 
					
						
							|  |  |  | 	sl.append(tr("Default (use first suitable device)")); | 
					
						
							|  |  |  | 	api = new QTreeWidgetItem(ui->audioTree, sl, ATDefault); | 
					
						
							|  |  |  | 	api->setFirstColumnSpanned(true); | 
					
						
							|  |  |  | 	for(AudioDeviceInfo::Devices::const_iterator it = devices.begin(); it != devices.end(); ++it) { | 
					
						
							|  |  |  | 		int apiIndex; | 
					
						
							|  |  |  | 		sl.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for(apiIndex = 0; apiIndex < ui->audioTree->topLevelItemCount(); ++apiIndex) { | 
					
						
							|  |  |  | 			if(ui->audioTree->topLevelItem(apiIndex)->text(0) == it->api) | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if(apiIndex >= ui->audioTree->topLevelItemCount()) { | 
					
						
							|  |  |  | 			sl.append(it->api); | 
					
						
							|  |  |  | 			api = new QTreeWidgetItem(ui->audioTree, sl, ATInterface); | 
					
						
							|  |  |  | 			api->setExpanded(true); | 
					
						
							|  |  |  | 			api->setFirstColumnSpanned(true); | 
					
						
							|  |  |  | 			sl.clear(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			api = ui->audioTree->topLevelItem(apiIndex); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		sl.append(it->name); | 
					
						
							|  |  |  | 		new QTreeWidgetItem(api, sl, ATDevice); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if(ui->audioTree->currentItem() == NULL) | 
					
						
							|  |  |  | 		ui->audioTree->setCurrentItem(ui->audioTree->topLevelItem(0)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ui->tabWidget->setCurrentIndex(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-04 17:07:26 +02:00
										 |  |  | AudioDialog::~AudioDialog() | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-04 17:07:26 +02:00
										 |  |  | void AudioDialog::accept() | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	QDialog::accept(); | 
					
						
							|  |  |  | } |