diff --git a/src/back/backlasses.cpp b/src/back/backlasses.cpp index a53c052..2370f08 100644 --- a/src/back/backlasses.cpp +++ b/src/back/backlasses.cpp @@ -140,12 +140,6 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify * } * */ -//todo: not on construct since it expects them to already exist; smells like refactor! -void EndpointSituationCallback::fill(IMMDeviceEnumerator *deviceEnumerator, std::vector playbackDevices, std::vector captureDevices){ - this->deviceEnumerator = deviceEnumerator; - this->playbackDevices = playbackDevices; - this->captureDevices = captureDevices; -} ULONG EndpointSituationCallback::AddRef(){ return InterlockedIncrement(&ref); @@ -685,7 +679,8 @@ Overseer::Overseer() { //: epsc(deviceEnumerator, playbackDevices){ //reloadEndpoints(Flows::FLOW_CAPTURE); //Registering for endpoint information callback - this->epsc.fill(deviceEnumerator, playbackDevices, captureDevices); + //this->epsc.fill(deviceEnumerator, playbackDevices, captureDevices); + //this->epsc.fill(deviceEnumerator); if(FAILED(deviceEnumerator->RegisterEndpointNotificationCallback(((IMMNotificationClient*)&epsc)))) { log_debugcpp("when no enchufas......"); } } diff --git a/src/back/backlasses.h b/src/back/backlasses.h index 8796466..6469c6d 100644 --- a/src/back/backlasses.h +++ b/src/back/backlasses.h @@ -11,9 +11,9 @@ class Session; class Endpoint { public: - Endpoint(IMMDevice* endpoint, uint64_t idx); + Endpoint(IMMDevice* endpoint, uint64_t idx = 0); //todo: how to forward declare delegate constructors? - Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {}; + //Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {}; void reloadEndpointChannels(); uint64_t getIndex(); void setIndex(uint64_t idx); @@ -84,7 +84,7 @@ class EndpointVolumeCallback : public IAudioEndpointVolumeCallback { class EndpointSituationCallback : public IMMNotificationClient { public: - //EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector playbackDevices); + //EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector playbackDevices, std::vector captureDevices); ULONG AddRef(); ULONG Release(); HRESULT QueryInterface(REFIID riid, VOID **ppvInterface); @@ -94,12 +94,11 @@ class EndpointSituationCallback : public IMMNotificationClient { HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState); HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key); - void fill(IMMDeviceEnumerator *deviceEnumerator, std::vector playbackDevices, std::vector captureDevices); private: ULONG ref = 1; - IMMDeviceEnumerator *deviceEnumerator; - std::vector playbackDevices; - std::vector captureDevices; + //IMMDeviceEnumerator *deviceEnumerator; + //std::vector playbackDevices; + //std::vector captureDevices; }; class Overseer { diff --git a/src/qt/qtclasses.cpp b/src/qt/qtclasses.cpp index d6605d2..901fe27 100644 --- a/src/qt/qtclasses.cpp +++ b/src/qt/qtclasses.cpp @@ -285,7 +285,6 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare mainVolumeLabel->setText(QString::number(volume)); log_debugcpp("ENDPOINT SET WITH VOLUME " + std::to_string(volume)); - //tip: would need to be new widget with layout in it //mainMuteLayout = new QGridLayout(); widgetLayout->addWidget(mainLabel, row, 0, 1, 3, Qt::AlignLeft | Qt::AlignVCenter); widgetLayout->addWidget(muteButton, row, 2, Qt::AlignRight | Qt::AlignVCenter); @@ -314,53 +313,28 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare /* * Role ExtendedCheckBoxes setup - */ + */ - uint8_t assignedRoles = eph->getRoles(); - defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setCheckState(assignedRoles == Roles::ROLE_ALL ? Qt::Checked : Qt::Unchecked); - //todo duditas de & - defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setDisabled(assignedRoles == Roles::ROLE_ALL ? true : false); - defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setText(STRING_ROLE_ALL); - - defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE)->setCheckState(assignedRoles & Roles::ROLE_CONSOLE ? Qt::Checked : Qt::Unchecked); - defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE)->setDisabled(assignedRoles & Roles::ROLE_CONSOLE ? true : false); - defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE)->setText(STRING_ROLE_CONSOLE); - - defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA)->setCheckState(assignedRoles & Roles::ROLE_MULTIMEDIA ? Qt::Checked : Qt::Unchecked); - defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA)->setDisabled(assignedRoles & Roles::ROLE_MULTIMEDIA ? true : false); - defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA)->setText(STRING_ROLE_MULTIMEDIA); - - defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS)->setCheckState(assignedRoles & Roles::ROLE_COMMUNICATIONS ? Qt::Checked : Qt::Unchecked); - defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS)->setDisabled(assignedRoles & Roles::ROLE_COMMUNICATIONS ? true : false); - defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS)->setText(STRING_ROLE_COMMUNICATIONS); - - connect(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), &QCheckBox::stateChanged,[this] { - this->eph->setRoles(Roles::ROLE_ALL); - }); - connect(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), &QCheckBox::stateChanged,[this] { - this->eph->setRoles(Roles::ROLE_CONSOLE); - }); - connect(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), &QCheckBox::stateChanged,[this] { - this->eph->setRoles(Roles::ROLE_MULTIMEDIA); - }); - - connect(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), &QCheckBox::stateChanged,[this] { - this->eph->setRoles(Roles::ROLE_COMMUNICATIONS); - }); - defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), - row, 0); - widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), - row, 1); - widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), - row, 2); - widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), - row, 3); + uint8_t assignedRoles = eph->getRoles(); + uint8_t col = 0; + #define checkbox_setup(role, optor) do { \ + defaultRolesCheckBoxes.at(role)->setCheckState(assignedRoles optor role ? Qt::Checked : Qt::Unchecked); \ + defaultRolesCheckBoxes.at(role)->setDisabled(assignedRoles optor role ? true : false); \ + defaultRolesCheckBoxes.at(role)->setText(STRING_##role); \ + connect(defaultRolesCheckBoxes.at(role), &QCheckBox::stateChanged,[this] { \ + this->eph->setRoles(role); \ + }); \ + widgetLayout->addWidget(defaultRolesCheckBoxes.at(role), row, col++); \ + } while(0) + + checkbox_setup(ROLE_ALL, ==); + checkbox_setup(ROLE_CONSOLE, &); + checkbox_setup(ROLE_MULTIMEDIA, &); + checkbox_setup(ROLE_COMMUNICATIONS, &); + #undef checkbox_setup row++; - - /* ----------------------------------------------------------- */ - + /* * EndpointVolume Polling time */