fixed xekboxes
This commit is contained in:
parent
6744a64fce
commit
60e3178e9a
7 changed files with 74 additions and 54 deletions
|
|
@ -2,14 +2,14 @@ QMAKE_CXXFLAGS += --target=x86_64-w64-mingw32 -g -gcodeview
|
||||||
QMAKE_LFLAGS += --target=x86_64-w64-mingw32 -g -Wl,-pdb= -v
|
QMAKE_LFLAGS += --target=x86_64-w64-mingw32 -g -Wl,-pdb= -v
|
||||||
LIBS += -LC:/capybara/libclang/x86_64-w64-mingw32/lib -lWinmm -lodbc32 -lodbccp32 -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32
|
LIBS += -LC:/capybara/libclang/x86_64-w64-mingw32/lib -lWinmm -lodbc32 -lodbccp32 -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32
|
||||||
#"kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32
|
#"kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32
|
||||||
DEFINES += DEBUG
|
DEFINES += DEBUG QT_LOGGING_TO_CONSOLE=1 WIN32_LEAN_AND_MEAN
|
||||||
CONFIG += debug console
|
CONFIG += debug
|
||||||
|
|
||||||
QT += widgets network
|
QT += widgets network
|
||||||
INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
||||||
HEADERS += qtclasses.h backlasses.h contclasses.h global.h debug.h backfuncs.h ipolicyconfig.h
|
HEADERS += qtclasses.h backlasses.h contclasses.h global.h debug.h backfuncs.h ipolicyconfig.h
|
||||||
RESOURCES = assets.qrc
|
RESOURCES = assets.qrc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ HRESULT EndpointSituationCallback::QueryInterface(REFIID riid, VOID **ppvInterfa
|
||||||
|
|
||||||
HRESULT EndpointSituationCallback::OnDefaultDeviceChanged(EDataFlow flow, ERole role,LPCWSTR pwstrDeviceId) {
|
HRESULT EndpointSituationCallback::OnDefaultDeviceChanged(EDataFlow flow, ERole role,LPCWSTR pwstrDeviceId) {
|
||||||
if (flow == EDataFlow::eCapture) return E_INVALIDARG;
|
if (flow == EDataFlow::eCapture) return E_INVALIDARG;
|
||||||
|
|
||||||
Roles nRole;
|
Roles nRole;
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case ERole::eConsole:
|
case ERole::eConsole:
|
||||||
|
|
@ -126,18 +126,19 @@ HRESULT EndpointSituationCallback::OnDefaultDeviceChanged(EDataFlow flow, ERole
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::wstring wstringEndpointId = pwstrDeviceId;
|
std::wstring wstringEndpointId = pwstrDeviceId;
|
||||||
|
log_wdebugcpp(L"we got za defol 4 " + wstringEndpointId);
|
||||||
osh->changeFrontDefaultsCallback(nRole, wstringEndpointId);
|
osh->changeFrontDefaultsCallback(nRole, wstringEndpointId);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT EndpointSituationCallback::OnDeviceAdded(LPCWSTR pwstrDeviceId) {
|
HRESULT EndpointSituationCallback::OnDeviceAdded(LPCWSTR pwstrDeviceId) {
|
||||||
log_wdebugcpp(L"ayo we eventing za adin" << pwstrDeviceId);
|
log_wdebugcpp(L"ayo we eventing za adin " + std::wstring(pwstrDeviceId));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT EndpointSituationCallback::OnDeviceRemoved(LPCWSTR pwstrDeviceId) {
|
HRESULT EndpointSituationCallback::OnDeviceRemoved(LPCWSTR pwstrDeviceId) {
|
||||||
log_wdebugcpp(L"ayo we eventing za rmovin" << pwstrDeviceId);
|
log_wdebugcpp(L"ayo we eventing za rmovin " + std::wstring(pwstrDeviceId));
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,13 +160,15 @@ HRESULT EndpointSituationCallback::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, D
|
||||||
|
|
||||||
HRESULT EndpointSituationCallback::OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) {
|
HRESULT EndpointSituationCallback::OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) {
|
||||||
|
|
||||||
log_debugcpp(" -->Changed device property " <<
|
/*
|
||||||
key.fmtid.Data1 << key.fmtid.Data2 << key.fmtid.Data3 << "\n" <<
|
* log_debugcpp(" -->Changed device property " +
|
||||||
key.fmtid.Data4[0]<< key.fmtid.Data4[1]<< "\n"<<
|
* key.fmtid.Data1 + key.fmtid.Data2 + key.fmtid.Data3 + "\n" +
|
||||||
key.fmtid.Data4[2]<< key.fmtid.Data4[3] << "\n"<<
|
* key.fmtid.Data4[0]+ key.fmtid.Data4[1]+ "\n"+
|
||||||
key.fmtid.Data4[4]<< key.fmtid.Data4[5] << "\n"<<
|
* key.fmtid.Data4[2]+ key.fmtid.Data4[3] + "\n"+
|
||||||
key.fmtid.Data4[6]<< key.fmtid.Data4[7]<< "\n"<<
|
* key.fmtid.Data4[4]+ key.fmtid.Data4[5] + "\n"+
|
||||||
" pid " << key.pid);
|
* key.fmtid.Data4[6]+ key.fmtid.Data4[7]+ "\n"+
|
||||||
|
* " pid " + key.pid);
|
||||||
|
*/
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +275,7 @@ void Endpoint::removeVolumeCallback(EndpointVolumeCallback *epc){
|
||||||
endpointVolume->UnregisterControlChangeNotify((IAudioEndpointVolumeCallback*)epc);
|
endpointVolume->UnregisterControlChangeNotify((IAudioEndpointVolumeCallback*)epc);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Endpoint::getRoles(){
|
Roles Endpoint::getRoles(){
|
||||||
return this->endpointRoles;
|
return this->endpointRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,13 +346,13 @@ void Endpoint::setRoles(Roles role){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Endpoint::assignRoles(uint8_t role){
|
void Endpoint::assignRoles(Roles role){
|
||||||
uint8_t roles = endpointRoles | role;
|
Roles roles = (Roles)(endpointRoles | role);
|
||||||
this->endpointRoles = roles;
|
this->endpointRoles = roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Endpoint::removeRoles(uint8_t role){
|
void Endpoint::removeRoles(Roles role){
|
||||||
uint8_t roles = endpointRoles ^ role;
|
Roles roles = (Roles)(endpointRoles ^ role);
|
||||||
this->endpointRoles = roles;
|
this->endpointRoles = roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,6 +364,7 @@ Endpoint::~Endpoint(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overseer::initCOMLibrary() {
|
void Overseer::initCOMLibrary() {
|
||||||
|
OutputDebugStringW(L"EPWidget creation\n");
|
||||||
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) {
|
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) {
|
||||||
log_debugcpp("si"); };
|
log_debugcpp("si"); };
|
||||||
|
|
||||||
|
|
@ -405,7 +409,7 @@ void Overseer::reloadEndpoints() {
|
||||||
Endpoint *endpoint = new Endpoint(temp, i);
|
Endpoint *endpoint = new Endpoint(temp, i);
|
||||||
//endpoint->setIndex(i);
|
//endpoint->setIndex(i);
|
||||||
this->playbackDevices.push_back(endpoint);
|
this->playbackDevices.push_back(endpoint);
|
||||||
//TODO: le porblemx std::cout << "ola" << std::endl;
|
//TODO: le porblemx std::cout + "ola" + std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceCollection->Release();
|
deviceCollection->Release();
|
||||||
|
|
@ -435,8 +439,8 @@ void Overseer::reloadEndpoints() {
|
||||||
temp->GetId(&id);
|
temp->GetId(&id);
|
||||||
int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0);
|
int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0);
|
||||||
if (comparison - 2 == 0) {
|
if (comparison - 2 == 0) {
|
||||||
log_wdebugcpp("ola defaul de " << i << " es " << id);
|
log_wdebugcpp(L"ola defaul de " + std::to_wstring(i) + L" es " + id);
|
||||||
playbackDevices.at(j)->assignRoles((1 << i));
|
playbackDevices.at(j)->assignRoles((Roles)(1 << i));
|
||||||
}
|
}
|
||||||
//uint8_t debg = playbackDevices.at(j)->getRoles();
|
//uint8_t debg = playbackDevices.at(j)->getRoles();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#define _WIN32_WINNT 0x0A00
|
#define _WIN32_WINNT 0x0A00
|
||||||
#include <sdkddkver.h>
|
#include <sdkddkver.h>
|
||||||
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <initguid.h>
|
#include <initguid.h>
|
||||||
#include <Propidl.h>
|
#include <Propidl.h>
|
||||||
#include <functiondiscoverykeys_devpkey.h>
|
#include <functiondiscoverykeys_devpkey.h>
|
||||||
|
//#include <debugapi.h>
|
||||||
|
|
||||||
#include <endpointvolume.h>
|
#include <endpointvolume.h>
|
||||||
#include <audiopolicy.h>
|
#include <audiopolicy.h>
|
||||||
|
|
@ -41,10 +42,10 @@ class Endpoint {
|
||||||
bool getMute();
|
bool getMute();
|
||||||
void setState(uint8_t state);
|
void setState(uint8_t state);
|
||||||
size_t getState();
|
size_t getState();
|
||||||
uint8_t getRoles();
|
Roles getRoles();
|
||||||
void setRoles(Roles role);
|
void setRoles(Roles role);
|
||||||
void assignRoles(uint8_t role);
|
void assignRoles(Roles role);
|
||||||
void removeRoles(uint8_t role);
|
void removeRoles(Roles role);
|
||||||
std::wstring getId();
|
std::wstring getId();
|
||||||
std::wstring getName();
|
std::wstring getName();
|
||||||
void setVolumeCallback(EndpointVolumeCallback *epc);
|
void setVolumeCallback(EndpointVolumeCallback *epc);
|
||||||
|
|
@ -59,7 +60,7 @@ class Endpoint {
|
||||||
std::wstring friendlyName;
|
std::wstring friendlyName;
|
||||||
std::wstring endpointId;
|
std::wstring endpointId;
|
||||||
unsigned long endpointState;
|
unsigned long endpointState;
|
||||||
uint8_t endpointRoles = 0;
|
Roles endpointRoles = (Roles)0;
|
||||||
uint64_t idx;
|
uint64_t idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,11 @@ void EndpointHandler::setRoles(Roles newRole){
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointHandler::assignRoles(Roles newRole){
|
void EndpointHandler::assignRoles(Roles newRole){
|
||||||
ep->assignRoles((uint8_t)newRole);
|
ep->assignRoles(newRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointHandler::removeRoles(Roles newRole){
|
void EndpointHandler::removeRoles(Roles newRole){
|
||||||
ep->removeRoles((uint8_t)newRole);
|
ep->removeRoles(newRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndpointHandler::~EndpointHandler() {
|
EndpointHandler::~EndpointHandler() {
|
||||||
|
|
@ -136,17 +136,17 @@ uint64_t OverseerHandler::getPlaybackEndpointsCount(){
|
||||||
|
|
||||||
void OverseerHandler::reloadEndpointHandlers(){
|
void OverseerHandler::reloadEndpointHandlers(){
|
||||||
//std::vector<EndpointHandler*>* ephs = new std::vector<EndpointHandler*>;
|
//std::vector<EndpointHandler*>* ephs = new std::vector<EndpointHandler*>;
|
||||||
log_debugcpp(" VSize: " << this->getPlaybackEndpointsCount());
|
log_debugcpp(" VSize: " + std::to_string(this->getPlaybackEndpointsCount()));
|
||||||
|
|
||||||
for(uint64_t i = 0; i < this->getPlaybackEndpointsCount(); i++){
|
for(uint64_t i = 0; i < this->getPlaybackEndpointsCount(); i++){
|
||||||
log_debugcpp("Creating handler " << i);
|
log_debugcpp("Creating handler " + std::to_string(i));
|
||||||
|
|
||||||
if(i < (this->endpointHandlers.size()) &&
|
if(i < (this->endpointHandlers.size()) &&
|
||||||
this->endpointHandlers.at(i) != nullptr)
|
this->endpointHandlers.at(i) != nullptr)
|
||||||
delete endpointHandlers.at(i);
|
delete endpointHandlers.at(i);
|
||||||
|
|
||||||
EndpointHandler* eph = new EndpointHandler(i);
|
EndpointHandler* eph = new EndpointHandler(i);
|
||||||
log_debugcpp("Created handler " << i << ", adding to vector. " << " VSize: " << this->getPlaybackEndpointsCount());
|
log_debugcpp("Created handler " + std::to_string(i) + ", adding to vector. " + " VSize: " + std::to_string(this->getPlaybackEndpointsCount()));
|
||||||
|
|
||||||
if (i >= this->endpointHandlers.size())
|
if (i >= this->endpointHandlers.size())
|
||||||
endpointHandlers.push_back(eph);
|
endpointHandlers.push_back(eph);
|
||||||
|
|
|
||||||
19
src/debug.h
19
src/debug.h
|
|
@ -7,7 +7,7 @@ std::bitset<Y> varToBitset(T info) {
|
||||||
std::bitset<Y> content(info);
|
std::bitset<Y> content(info);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
#ifndef _WIN32
|
||||||
#define log_debugcpp(str) do { \
|
#define log_debugcpp(str) do { \
|
||||||
std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
@ -15,6 +15,21 @@ std::bitset<Y> varToBitset(T info) {
|
||||||
#define log_wdebugcpp(str) do { \
|
#define log_wdebugcpp(str) do { \
|
||||||
std::wcout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
std::wcout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <debugapi.h>
|
||||||
|
#define WIDE2(x) L##x
|
||||||
|
#define WIDE1(x) WIDE2(x)
|
||||||
|
#define WFILE WIDE1(__FILE__)
|
||||||
|
#define log_debugcpp(str) { \
|
||||||
|
OutputDebugStringA(std::string("[DEBUG] (" + std::string(__FILE__) + ":" + std::to_string(__LINE__) + "): " + std::string(str) + "\n").c_str()); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define log_wdebugcpp(str) do { \
|
||||||
|
OutputDebugStringW(std::wstring(L"[DEBUG] (" + std::wstring(WFILE) + L":" + std::to_wstring(__LINE__) + L"): " + std::wstring(str) +L"\n").c_str()); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define print_as_binary(len, type, info) varToBitset<len, type>(info)
|
#define print_as_binary(len, type, info) varToBitset<len, type>(info)
|
||||||
|
|
||||||
|
|
@ -30,5 +45,3 @@ std::bitset<Y> varToBitset(T info) {
|
||||||
/* typedef void (EndpointWidget::*epwChannelVolumeFunc)(uint32_t channel, float newValue); */
|
/* typedef void (EndpointWidget::*epwChannelVolumeFunc)(uint32_t channel, float newValue); */
|
||||||
/* typedef void (EndpointWidget::*epwToggleFrontFunc)(bool active); */
|
/* typedef void (EndpointWidget::*epwToggleFrontFunc)(bool active); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ EndpointWidgetEvent::EndpointWidgetEvent(QEvent::Type type, int idx) : QEvent(ty
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExtendedCheckBox::event(QEvent* ev) {
|
void ExtendedCheckBox::customEvent(QEvent* ev) {
|
||||||
if (ev->type() == QEvent::User) {
|
QEvent::Type tipo = ev->type();
|
||||||
|
if (ev->type() == (QEvent::Type)CustomQEvent::EndpointDefaultChange) {
|
||||||
//todo: still prone to bugs; whack-a-mole to come
|
//todo: still prone to bugs; whack-a-mole to come
|
||||||
|
ev->setAccepted(true);
|
||||||
this->blockSignals(true);
|
this->blockSignals(true);
|
||||||
if (this->isEnabled()) {
|
if (this->isEnabled()) {
|
||||||
this->setCheckState(Qt::Checked);
|
this->setCheckState(Qt::Checked);
|
||||||
|
|
@ -16,10 +18,10 @@ bool ExtendedCheckBox::event(QEvent* ev) {
|
||||||
this->setCheckState(Qt::Unchecked);
|
this->setCheckState(Qt::Unchecked);
|
||||||
}
|
}
|
||||||
this->blockSignals(false);
|
this->blockSignals(false);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
// Make sure the rest of events are handled
|
// Make sure the rest of events are handled
|
||||||
return QCheckBox::event(ev);
|
QCheckBox::customEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||||
|
|
@ -29,7 +31,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ACTIVE, idx);
|
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ACTIVE, idx);
|
||||||
layout = new QGridLayout(this);
|
layout = new QGridLayout(this);
|
||||||
//this->setLayout(layout);
|
//this->setLayout(layout);
|
||||||
log_debugcpp("epw main layout parent: "<< layout->parent());
|
log_debugcpp("epw main layout parent: " + std::to_string((intptr_t)(layout->parent())));
|
||||||
if (parent == nullptr) { log_debugcpp("owo?"); }
|
if (parent == nullptr) { log_debugcpp("owo?"); }
|
||||||
|
|
||||||
defaultRolesCheckBoxes = {
|
defaultRolesCheckBoxes = {
|
||||||
|
|
@ -64,7 +66,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||||
float volume = eph->getVolume(AudioChannel::CHANNEL_MAIN) * 100;
|
float volume = eph->getVolume(AudioChannel::CHANNEL_MAIN) * 100;
|
||||||
mainSlider->setValue((int)volume);
|
mainSlider->setValue((int)volume);
|
||||||
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
log_debugcpp("ENDPOINT SET WITH VOLUME " + std::to_string(volume));
|
||||||
|
|
||||||
//tip: would need to be new widget with layout in it
|
//tip: would need to be new widget with layout in it
|
||||||
//mainMuteLayout = new QGridLayout();
|
//mainMuteLayout = new QGridLayout();
|
||||||
|
|
@ -183,11 +185,12 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
|
|
||||||
void MainWindow::customEvent(QEvent* ev) {
|
void MainWindow::customEvent(QEvent* ev) {
|
||||||
if (ev->type() == CustomQEvent::EndpointWidgetObsolete) {
|
if (ev->type() == CustomQEvent::EndpointWidgetObsolete) {
|
||||||
|
ev->setAccepted(true);
|
||||||
this->removeEndpointWidget((EndpointWidgetEvent*)ev);
|
this->removeEndpointWidget((EndpointWidgetEvent*)ev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Make sure the rest of events are handled
|
// Make sure the rest of events are handled
|
||||||
return QMainWindow::customEvent(ev);
|
QMainWindow::customEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::removeEndpointWidget(EndpointWidgetEvent* ev){
|
void MainWindow::removeEndpointWidget(EndpointWidgetEvent* ev){
|
||||||
|
|
@ -272,6 +275,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
* Registering needed custom events
|
* Registering needed custom events
|
||||||
*/
|
*/
|
||||||
QEvent::registerEventType(CustomQEvent::EndpointWidgetObsolete);
|
QEvent::registerEventType(CustomQEvent::EndpointWidgetObsolete);
|
||||||
|
QEvent::registerEventType(CustomQEvent::EndpointDefaultChange);
|
||||||
|
|
||||||
widget = new QWidget();
|
widget = new QWidget();
|
||||||
layout = new QGridLayout();
|
layout = new QGridLayout();
|
||||||
|
|
@ -279,9 +283,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
trayIconMenu = new QMenu();
|
trayIconMenu = new QMenu();
|
||||||
trayIconMenuQuit = new QAction(STRING_QUIT);
|
trayIconMenuQuit = new QAction(STRING_QUIT);
|
||||||
|
|
||||||
changeDefaultCheckboxEnablement = new QEvent(QEvent::User);
|
|
||||||
changeDefaultCheckboxEnablement->setAccepted(true);
|
|
||||||
|
|
||||||
widget->setLayout(layout);
|
widget->setLayout(layout);
|
||||||
setCentralWidget(widget);
|
setCentralWidget(widget);
|
||||||
//layout->addWidget(pintas, 0, 0);
|
//layout->addWidget(pintas, 0, 0);
|
||||||
|
|
@ -317,13 +318,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
||||||
epw->getEndpointHandler()->assignRoles(role);
|
epw->getEndpointHandler()->assignRoles(role);
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
||||||
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(role), changeDefaultCheckboxEnablement);
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
//epw->defaultRolesCheckBoxes.at(role)->postEnableChange();
|
//epw->defaultRolesCheckBoxes.at(role)->postEnableChange();
|
||||||
/*
|
/*
|
||||||
* And were you THE default?
|
* And were you THE default?
|
||||||
*/
|
*/
|
||||||
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
||||||
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL), changeDefaultCheckboxEnablement);
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Are you the dethroned king?
|
* Are you the dethroned king?
|
||||||
|
|
@ -333,14 +334,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
* And were you THE default up until now?
|
* And were you THE default up until now?
|
||||||
*/
|
*/
|
||||||
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
||||||
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL), changeDefaultCheckboxEnablement);
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
}
|
}
|
||||||
|
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
||||||
//Same as before. ini-san will come...
|
//Same as before. ini-san will come...
|
||||||
epw->getEndpointHandler()->removeRoles(role);
|
epw->getEndpointHandler()->removeRoles(role);
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
||||||
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(role), changeDefaultCheckboxEnablement);
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -348,7 +349,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
|
|
||||||
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
||||||
EndpointWidgetEvent* removeObsoleteEndpointWidget = new EndpointWidgetEvent((QEvent::Type)CustomQEvent::EndpointWidgetObsolete, index);
|
EndpointWidgetEvent* removeObsoleteEndpointWidget = new EndpointWidgetEvent((QEvent::Type)CustomQEvent::EndpointWidgetObsolete, index);
|
||||||
removeObsoleteEndpointWidget->setAccepted(true);
|
|
||||||
QCoreApplication::instance()->postEvent(this, removeObsoleteEndpointWidget);
|
QCoreApplication::instance()->postEvent(this, removeObsoleteEndpointWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
*/
|
*/
|
||||||
enum CustomQEvent {
|
enum CustomQEvent {
|
||||||
EndpointWidgetObsolete = 1001,
|
EndpointWidgetObsolete = 1001,
|
||||||
|
EndpointDefaultChange = 1002,
|
||||||
};
|
};
|
||||||
|
|
||||||
class EndpointWidgetEvent : public QEvent {
|
class EndpointWidgetEvent : public QEvent {
|
||||||
|
|
@ -69,18 +70,20 @@ public:
|
||||||
//Q_DECLARE_METATYPE(EndpointWidgetEvent)
|
//Q_DECLARE_METATYPE(EndpointWidgetEvent)
|
||||||
|
|
||||||
class ExtendedCheckBox : public QCheckBox {
|
class ExtendedCheckBox : public QCheckBox {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
void customEvent(QEvent* ev) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//c++11: this inherits all parent's constructors unconditionally
|
//c++11: this inherits all parent's constructors unconditionally
|
||||||
using QCheckBox::QCheckBox;
|
using QCheckBox::QCheckBox;
|
||||||
//alternative being calling parent ctor directly after declaring child ctor:
|
//alternative being calling parent ctor directly after declaring child ctor:
|
||||||
//B(int x) : A(x) { }
|
//B(int x) : A(x) { }
|
||||||
bool event(QEvent* ev) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class EndpointWidget : public QWidget {
|
class EndpointWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
|
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
|
||||||
|
|
@ -153,8 +156,7 @@ private:
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
QMenu *trayIconMenu;
|
QMenu *trayIconMenu;
|
||||||
QAction *trayIconMenuQuit;
|
QAction *trayIconMenuQuit;
|
||||||
QEvent* changeDefaultCheckboxEnablement;
|
|
||||||
|
|
||||||
//public slots:
|
//public slots:
|
||||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue