mic back/cont & plug/unplug done; devicead/rem to go
This commit is contained in:
parent
44ccde6ac8
commit
6f8455c63d
5 changed files with 129 additions and 46 deletions
|
|
@ -85,7 +85,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
/*
|
||||
* Channel sliders setup
|
||||
*/
|
||||
for(uint32_t i = 0; i < eph->getChannelCount(); i++){
|
||||
uint32_t epChannelCount = eph->getChannelCount();
|
||||
for(uint32_t i = 0; i < epChannelCount && epChannelCount > 1; i++){
|
||||
QSlider* tmp = new QSlider(Qt::Horizontal);
|
||||
QLabel* tmpLb = new QLabel("");
|
||||
tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
|
@ -163,7 +164,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
mainSlider->setValue((int)((eph->getCallbackInfo()->mainVolume + roundingFactor) * 100));
|
||||
muteButton->setCheckState((eph->getCallbackInfo()->muted == false ? Qt::Unchecked : Qt::Checked));
|
||||
muteButton->setText(eph->getCallbackInfo()->muted ? STRING_UNMUTE : STRING_MUTE);
|
||||
for(uint32_t i = 0; i < eph->getCallbackInfo()->channels; i++){
|
||||
for(uint32_t i = 0; i < eph->getCallbackInfo()->channels && eph->getChannelCount() > 1; i++){
|
||||
this->channelSliders.at(i)->blockSignals(true);
|
||||
this->channelSliders.at(i)->setValue((int)((eph->getCallbackInfo()->channelVolumes[i] + roundingFactor) * 100));
|
||||
this->channelLabels.at(i)->setText(QString::number((int)((eph->getCallbackInfo()->channelVolumes[i] + roundingFactor) * 100)));
|
||||
|
|
@ -210,15 +211,20 @@ void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
|
|||
uint64_t i = ev->payload;
|
||||
this->ews.at(i)->setParent(nullptr);
|
||||
this->layout->removeWidget(ews.at(i));
|
||||
uint64_t saisu = ews.size();
|
||||
//uint64_t saisu = ews.size();
|
||||
//delete ews.at(index);
|
||||
delete ews.at(i);
|
||||
while ((i + 1) < ews.size()) {
|
||||
ews.at(i) = ews.at(i + 1);
|
||||
ews.at(i)->setIndex(i);
|
||||
i++;
|
||||
}
|
||||
ews.pop_back();
|
||||
ews.at(i) = nullptr;
|
||||
this->ewsUpdateTimer->start();
|
||||
|
||||
/*
|
||||
* while ((i + 1) < ews.size()) {
|
||||
* ews.at(i) = ews.at(i + 1);
|
||||
* ews.at(i)->setIndex(i);
|
||||
* i++;
|
||||
* }
|
||||
* ews.pop_back();
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -229,6 +235,34 @@ void MainWindow::addEndpointWidget(EndpointWidgetEvent<EndpointHandler*>* ev){
|
|||
return;
|
||||
}
|
||||
|
||||
void MainWindow::reorderEndpointWidgetCollection() {
|
||||
size_t firstNullPosition = 0;
|
||||
size_t ewsSize = ews.size();
|
||||
bool breakSorting = false;
|
||||
|
||||
//todo: is all of gui really atomic by definition? im afraid of cutting through amazing add momentos, but I think I did my homework. Must check back.
|
||||
for (size_t i = 0; i < ewsSize; i++) {
|
||||
if (ews.at(i) == nullptr) {
|
||||
for (size_t j = (i + 1); j < ewsSize; j++) {
|
||||
|
||||
if (ews.at(j) != nullptr) {
|
||||
ews.at(i) = ews.at(j);
|
||||
ews.at(i)->setIndex(i);
|
||||
ews.at(j) = nullptr;
|
||||
break;
|
||||
}
|
||||
if (j == ewsSize - 1) {
|
||||
firstNullPosition = i;
|
||||
breakSorting = true;
|
||||
}
|
||||
|
||||
}
|
||||
if (breakSorting) break;
|
||||
}
|
||||
}
|
||||
ews.resize(firstNullPosition + 1);
|
||||
}
|
||||
|
||||
void EndpointWidget::updateMute(int checked){
|
||||
bool muted = (checked == 2 ? true : false);
|
||||
this->eph->setMute(osh->getGuid(), muted);
|
||||
|
|
@ -304,13 +338,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
QEvent::registerEventType(CustomQEvent::EndpointWidgetObsolete);
|
||||
QEvent::registerEventType(CustomQEvent::EndpointWidgetCreated);
|
||||
QEvent::registerEventType(CustomQEvent::EndpointDefaultChange);
|
||||
|
||||
|
||||
ewsUpdateTimer = new QTimer(this);
|
||||
widget = new QWidget();
|
||||
layout = new QGridLayout();
|
||||
trayIcon = new QSystemTrayIcon();
|
||||
trayIconMenu = new QMenu();
|
||||
trayIconMenuQuit = new QAction(STRING_QUIT);
|
||||
|
||||
ewsUpdateTimer->setSingleShot(true);
|
||||
ewsUpdateTimer->setInterval(ewsUpdateTimerFrequency);
|
||||
connect(ewsUpdateTimer, &QTimer::timeout, this, &MainWindow::reorderEndpointWidgetCollection);
|
||||
widget->setLayout(layout);
|
||||
setCentralWidget(widget);
|
||||
//layout->addWidget(pintas, 0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue