Commit 861d0106 authored by Alexandre Lision's avatar Alexandre Lision

videoprefs: reload sizes and framerate

catch signals of current device changed and repopulate the lists

Tuleap: #369
Change-Id: I8052e53d53388a5dd122be6cabba8faf65efd031
parent 859d98f7
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
@interface VideoPrefsVC () @interface VideoPrefsVC ()
@property (assign) IBOutlet NSView *previewView; @property (assign) IBOutlet NSView* previewView;
@property (assign) IBOutlet NSPopUpButton *videoDevicesList; @property (assign) IBOutlet NSPopUpButton* videoDevicesList;
@property (assign) IBOutlet NSPopUpButton *sizesList; @property (assign) IBOutlet NSPopUpButton* sizesList;
@property (assign) IBOutlet NSPopUpButton *ratesList; @property (assign) IBOutlet NSPopUpButton* ratesList;
@property BOOL shouldHandlePreview; @property BOOL shouldHandlePreview;
...@@ -55,38 +55,55 @@ QMetaObject::Connection previewStopped; ...@@ -55,38 +55,55 @@ QMetaObject::Connection previewStopped;
{ {
[super loadView]; [super loadView];
// Make sure models are loaded
Video::ConfigurationProxy::deviceModel().rowCount(); Video::ConfigurationProxy::deviceModel().rowCount();
Video::ConfigurationProxy::resolutionModel().rowCount(); Video::ConfigurationProxy::resolutionModel().rowCount();
Video::ConfigurationProxy::rateModel().rowCount(); Video::ConfigurationProxy::rateModel().rowCount();
// Prepopulate values
QModelIndex qDeviceIdx = Video::ConfigurationProxy::deviceSelectionModel().currentIndex(); QModelIndex qDeviceIdx = Video::ConfigurationProxy::deviceSelectionModel().currentIndex();
qDeviceIdx = Video::ConfigurationProxy::deviceSelectionModel().currentIndex();
[videoDevicesList addItemWithTitle:Video::ConfigurationProxy::deviceModel().data(qDeviceIdx, Qt::DisplayRole).toString().toNSString()]; [videoDevicesList addItemWithTitle:Video::ConfigurationProxy::deviceModel().data(qDeviceIdx, Qt::DisplayRole).toString().toNSString()];
QModelIndex qSizeIdx = Video::ConfigurationProxy::resolutionSelectionModel().currentIndex(); QModelIndex qSizeIdx = Video::ConfigurationProxy::resolutionSelectionModel().currentIndex();
[sizesList addItemWithTitle:Video::ConfigurationProxy::resolutionModel().data(qSizeIdx, Qt::DisplayRole).toString().toNSString()]; [sizesList addItemWithTitle:Video::ConfigurationProxy::resolutionModel().data(qSizeIdx, Qt::DisplayRole).toString().toNSString()];
if(qobject_cast<QAbstractProxyModel*>(&Video::ConfigurationProxy::resolutionModel())) {
QObject::connect(qobject_cast<QAbstractProxyModel*>(&Video::ConfigurationProxy::resolutionModel()),
&QAbstractProxyModel::modelReset,
[=]() {
NSLog(@"resolution Source model changed!!!");
});
}
QModelIndex qRate = Video::ConfigurationProxy::rateSelectionModel().currentIndex(); QModelIndex qRate = Video::ConfigurationProxy::rateSelectionModel().currentIndex();
[ratesList addItemWithTitle:Video::ConfigurationProxy::rateModel().data(qDeviceIdx, Qt::DisplayRole).toString().toNSString()]; [ratesList addItemWithTitle:Video::ConfigurationProxy::rateModel().data(qDeviceIdx, Qt::DisplayRole).toString().toNSString()];
if(qobject_cast<QAbstractProxyModel*>(&Video::ConfigurationProxy::rateModel())) { // connect to model reset (device may have changed) and selection changed signals
QObject::connect(qobject_cast<QAbstractProxyModel*>(&Video::ConfigurationProxy::rateModel()), QObject::connect(qobject_cast<QAbstractProxyModel*>(&Video::ConfigurationProxy::resolutionModel()),
&QAbstractProxyModel::modelReset, &QAbstractProxyModel::modelReset,
[=]() { [=]() {
NSLog(@"rates Source model changed!!!"); [sizesList removeAllItems];
}); });
} QObject::connect(&Video::ConfigurationProxy::resolutionSelectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if (!current.isValid()) {
return;
}
[sizesList removeAllItems];
[sizesList addItemWithTitle:Video::ConfigurationProxy::resolutionSelectionModel().currentIndex().data(Qt::DisplayRole).toString().toNSString()];
});
QObject::connect(qobject_cast<QAbstractProxyModel*>(&Video::ConfigurationProxy::rateModel()),
&QAbstractProxyModel::modelReset,
[=]() {
[ratesList removeAllItems];
});
QObject::connect(&Video::ConfigurationProxy::rateSelectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if (!current.isValid()) {
return;
}
[ratesList removeAllItems];
[ratesList addItemWithTitle:Video::ConfigurationProxy::rateSelectionModel().currentIndex().data(Qt::DisplayRole).toString().toNSString()];
});
[previewView setWantsLayer:YES]; [previewView setWantsLayer:YES];
[previewView setLayer:[CALayer layer]]; [previewView setLayer:[CALayer layer]];
...@@ -207,20 +224,24 @@ QMetaObject::Connection previewStopped; ...@@ -207,20 +224,24 @@ QMetaObject::Connection previewStopped;
{ {
QModelIndex qIdx; QModelIndex qIdx;
if(self.videoDevicesList.menu == menu) { if(self.videoDevicesList.menu == menu) {
qIdx = Video::ConfigurationProxy::deviceModel().index(index, 0); qIdx = Video::ConfigurationProxy::deviceModel().index(index, 0);
[item setTitle:Video::ConfigurationProxy::deviceModel().data(qIdx, Qt::DisplayRole).toString().toNSString()]; [item setTitle:Video::ConfigurationProxy::deviceModel().data(qIdx, Qt::DisplayRole).toString().toNSString()];
if (qIdx == Video::ConfigurationProxy::deviceSelectionModel().currentIndex()) {
[videoDevicesList selectItem:item];
}
} else if(self.sizesList.menu == menu) { } else if(self.sizesList.menu == menu) {
qIdx = Video::ConfigurationProxy::resolutionModel().index(index, 0); qIdx = Video::ConfigurationProxy::resolutionModel().index(index, 0);
[item setTitle:Video::ConfigurationProxy::resolutionModel().data(qIdx, Qt::DisplayRole).toString().toNSString()]; [item setTitle:Video::ConfigurationProxy::resolutionModel().data(qIdx, Qt::DisplayRole).toString().toNSString()];
if (qIdx == Video::ConfigurationProxy::resolutionSelectionModel().currentIndex()) {
[sizesList selectItem:item];
}
} else if(self.ratesList.menu == menu) { } else if(self.ratesList.menu == menu) {
qIdx = Video::ConfigurationProxy::rateModel().index(index, 0); qIdx = Video::ConfigurationProxy::rateModel().index(index, 0);
[item setTitle:Video::ConfigurationProxy::rateModel().data(qIdx, Qt::DisplayRole).toString().toNSString()]; [item setTitle:Video::ConfigurationProxy::rateModel().data(qIdx, Qt::DisplayRole).toString().toNSString()];
if (qIdx == Video::ConfigurationProxy::rateSelectionModel().currentIndex()) {
[ratesList selectItem:item];
}
} }
return YES; return YES;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment