wip: no endpoint, role rework, visual ratio
This commit is contained in:
parent
e42dbaa194
commit
d4db24ed7d
12 changed files with 184 additions and 57 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>assets/selawk.ttf</file>
|
||||
<file>assets/notificationAreaIcon.png</file>
|
||||
<file>assets/style.qss</file>
|
||||
<file>assets/logo.ico</file>
|
||||
|
|
|
|||
BIN
assets/selawk.ttf
Normal file
BIN
assets/selawk.ttf
Normal file
Binary file not shown.
|
|
@ -12,7 +12,7 @@ VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\back\reimpl" "$$
|
|||
|
||||
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp backsessionclasses.cpp contclasses.cpp contsessionclasses.cpp
|
||||
HEADERS += qtclasses.h backlasses.h backsessionclasses.h contclasses.h contsessionclasses.h global.h debug.h backfuncs.h ipolicyconfig.h msinclude.h meterslider.h qtvisuals.h
|
||||
RESOURCES = assets.qrc
|
||||
RESOURCES = assets.qrc
|
||||
RC_ICONS += assets/logo.ico
|
||||
|
||||
#DESTDIR += "build"
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ HRESULT EndpointSituationCallback::QueryInterface(REFIID riid, VOID **ppvInterfa
|
|||
|
||||
HRESULT EndpointSituationCallback::OnDefaultDeviceChanged(EDataFlow flow, ERole role,LPCWSTR pwstrDeviceId) {
|
||||
if (flow == EDataFlow::eCapture) return E_INVALIDARG;
|
||||
if (!pwstrDeviceId) return E_INVALIDARG;
|
||||
|
||||
Roles nRole;
|
||||
switch (role) {
|
||||
|
|
@ -188,7 +189,8 @@ HRESULT EndpointSituationCallback::OnDefaultDeviceChanged(EDataFlow flow, ERole
|
|||
}
|
||||
std::wstring wstringEndpointId = pwstrDeviceId;
|
||||
log_wdebugcpp(L"we got za defol 4 " + wstringEndpointId);
|
||||
osh->changeFrontDefaultsCallback(nRole, wstringEndpointId);
|
||||
osh->roleBucketEntryCallback(nRole, wstringEndpointId);
|
||||
//osh->changeFrontDefaultsCallback(nRole, wstringEndpointId);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
@ -586,6 +588,8 @@ void Overseer::reloadEndpoints(Flows flow) {
|
|||
break;
|
||||
}
|
||||
deviceEnumerator->GetDefaultAudioEndpoint(MSflow, val, &temp);
|
||||
if (!temp) continue;
|
||||
|
||||
LPWSTR id = nullptr;
|
||||
|
||||
if (flow == Flows::FLOW_PLAYBACK) {
|
||||
|
|
|
|||
|
|
@ -290,12 +290,22 @@ NGuid OverseerHandler::getGuid() {
|
|||
return this->os->getGuid();
|
||||
}
|
||||
|
||||
void OverseerHandler::setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults){
|
||||
this->changeFrontDefaults = changeFrontDefaults;
|
||||
/*
|
||||
* void OverseerHandler::setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults){
|
||||
* this->changeFrontDefaults = changeFrontDefaults;
|
||||
* }
|
||||
*
|
||||
* void OverseerHandler::changeFrontDefaultsCallback(Roles role, std::wstring endpointId) {
|
||||
* this->changeFrontDefaults(role, endpointId);
|
||||
* }
|
||||
*/
|
||||
|
||||
void OverseerHandler::roleBucketEntryCallback(Roles role, std::wstring endpointId){
|
||||
this->roleBucketEntry(role, endpointId);
|
||||
}
|
||||
|
||||
void OverseerHandler::changeFrontDefaultsCallback(Roles role, std::wstring endpointId) {
|
||||
this->changeFrontDefaults(role, endpointId);
|
||||
void OverseerHandler::setRoleBucketEntryFunction(std::function<void(Roles, std::wstring)> roleBucketEntry) {
|
||||
this->roleBucketEntry = roleBucketEntry;
|
||||
}
|
||||
|
||||
void OverseerHandler::updateFrontEndpointName(Endpoint* ep) {
|
||||
|
|
|
|||
|
|
@ -99,9 +99,12 @@ public:
|
|||
OverseerHandler();
|
||||
void openControlPanel();
|
||||
|
||||
void setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults);
|
||||
void changeFrontDefaultsCallback(Roles role, std::wstring endpointId);
|
||||
//void setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults);
|
||||
//void changeFrontDefaultsCallback(Roles role, std::wstring endpointId);
|
||||
|
||||
void roleBucketEntryCallback(Roles role, std::wstring endpointId);
|
||||
void setRoleBucketEntryFunction(std::function<void(Roles, std::wstring)> roleBucketEntry);
|
||||
|
||||
void updateFrontEndpointName(Endpoint* ep);
|
||||
//void setReviseEndpointShowingFunction(std::function<void(std::wstring, EndpointState)> reviseEndpointShowing);
|
||||
void reviseEndpointShowing(std::wstring endpointId, EndpointState state);
|
||||
|
|
@ -132,7 +135,8 @@ private:
|
|||
std::function<void(Roles, std::wstring /* endpointid */)> changeFrontDefaults;
|
||||
std::function<void(uint64_t /* epw id */)> removeEndpointWidget;
|
||||
std::function<void(EndpointHandler*)> addEndpointWidget;
|
||||
|
||||
std::function<void(Roles, std::wstring /* endpointid */)> roleBucketEntry;
|
||||
|
||||
/* Session's */
|
||||
std::function<void(float)> changeSessionVolume;
|
||||
//std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#define STRING_ABOUT "About"
|
||||
#define STRING_STARTUP "Run at startup"
|
||||
|
||||
#define STRING_NOENDPOINT "No active endpoints"
|
||||
|
||||
#define LSTRING_UNNAMED_SESSION L"Unnamed session"
|
||||
//INIT BACK
|
||||
|
||||
|
|
|
|||
|
|
@ -245,10 +245,17 @@ void MainWindow::compose() {
|
|||
screenRes.getCoords(&srx1, &sry1, &srx2, &sry2);
|
||||
log_debugcpp("(for Percentage) Screen Res: " + std::to_string(srx1) + " " + std::to_string(srx2)+" " + std::to_string(sry1) + " " + std::to_string(sry2));
|
||||
|
||||
uint64_t windowWidth = (uint64_t)std::abs(screenRes.width()) * this->widthRatio;
|
||||
dpr = screen->devicePixelRatio();
|
||||
log_to_file("dpr: %f \n", dpr);
|
||||
uint64_t windowWidth = ((uint64_t)std::abs(screenRes.width()) * widthRatio) * dpr;
|
||||
uint64_t screenHeight = (uint64_t)std::abs(screenRes.height());
|
||||
log_debugcpp("Window Width: " + std::to_string(windowWidth));
|
||||
|
||||
QFontMetrics fontMetrics = this->fontMetrics();
|
||||
int maxCharWidth = fontMetrics.maxWidth();
|
||||
int charHeight = fontMetrics.height();
|
||||
//QSize QFontMetrics::size(int flags, const QString &text, int tabStops = 0, int *tabArray = nullptr) const
|
||||
|
||||
this->createLayout(new QGridLayout());
|
||||
//scrollArea->verticalScrollBar()->setMinimumWidth(windowWidth * (widthRatio));
|
||||
//scrollArea->verticalScrollBar()->setMaximumWidth(windowWidth * (widthRatio));
|
||||
|
|
@ -259,8 +266,7 @@ void MainWindow::compose() {
|
|||
* this->hide();
|
||||
* this->setAttribute(Qt::WA_DontShowOnScreen, false);
|
||||
*/
|
||||
const qreal dpr = screen->devicePixelRatio();
|
||||
log_to_file("dpr: %f \n", dpr);
|
||||
|
||||
for (auto *epw : ews) {
|
||||
if (!epw) continue;
|
||||
epw->calculateSize(windowWidth, screenHeight);
|
||||
|
|
@ -396,7 +402,7 @@ void SessionWidget::calculateSize(uint64_t width, uint64_t height) {
|
|||
/* og 1080p 120% testing values */
|
||||
this->mainLabel->setMaximumWidth((int)(width * 0.30) /*1/16ish 1080p*/);
|
||||
this->mainLabel->setMinimumWidth((int)(width * 0.30) /*1/16ish 1080p*/);
|
||||
this->mainLabel->setMaximumHeight((int)(height * 0.02));
|
||||
//this->mainLabel->setMaximumHeight((int)(height * 0.02));
|
||||
this->mainLabel->setMinimumHeight((int)(height * 0.02));
|
||||
this->muteButton->setMaximumWidth((int)(width * 0.10) /*1/32th 1080p*/);
|
||||
this->muteButton->setMinimumWidth((int)(width * 0.10) /*1/32th 1080p*/);
|
||||
|
|
@ -410,7 +416,9 @@ void SessionWidget::calculateSize(uint64_t width, uint64_t height) {
|
|||
log_to_file("\tMute btn Maximum width: %d \n", muteButton->maximumWidth());
|
||||
log_to_file("\tMute btn Minimum width: %d \n", muteButton->minimumWidth());
|
||||
log_to_file("\tSlider Minimum width: %d \n", mainSlider->minimumWidth());
|
||||
log_to_file("\tSpacer Minimum width: %d \n\n", widthSpacer->minimumSize().width());
|
||||
log_to_file("\tSlider Maximum width: %d \n", mainSlider->maximumWidth());
|
||||
log_to_file("\tSpacer Minimum width: %d \n", widthSpacer->minimumSize().width());
|
||||
log_to_file("\tSpacer Maximum width: %d \n\n", widthSpacer->maximumSize().width());
|
||||
}
|
||||
|
||||
std::wstring SessionWidget::getName() {
|
||||
|
|
@ -457,8 +465,10 @@ ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidge
|
|||
tmp->setValue((int) volume);
|
||||
tmpLb->setText(QString::number(volume));
|
||||
//tmpLb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
tmp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
tmpLb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
//tmp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
//mainSlider->setFocusPolicy(Qt::StrongFocus);
|
||||
tmpLb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
this->channelSliders.push_back(tmp);
|
||||
this->channelLabels.push_back(tmpLb);
|
||||
widgetLayout->addWidget(tmp, row , col);
|
||||
|
|
@ -505,7 +515,6 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
//todo: sussy
|
||||
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, idx);
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
//setAttribute(Qt::WA_TranslucentBackground);
|
||||
widgetLayout = new QGridLayout(this);
|
||||
//this->setLayout(widgetLayout);
|
||||
log_debugcpp("epw main layout parent: " + std::to_string((intptr_t)(widgetLayout->parent())));
|
||||
|
|
@ -575,6 +584,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
uint32_t epChannelCount = eph->getChannelCount();
|
||||
if(epChannelCount > 1) {
|
||||
cw = new ChannelWidget(epChannelCount, eph, nullptr);
|
||||
cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
//cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
widgetLayout->addWidget(cw, row++, 0, 1, 4 /*colmax*/, Qt::AlignTop);
|
||||
}
|
||||
|
|
@ -672,7 +682,8 @@ void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
|||
for (QWidget *widget : topLevelWidgets) {
|
||||
if (qobject_cast<MainWindow*>(widget)) {
|
||||
double widthRatio = ((MainWindow*)widget)->widthRatio;
|
||||
sw->calculateSize(std::abs(this->screen()->geometry().width()) * widthRatio,
|
||||
double dpr = ((MainWindow*)widget)->dpr;
|
||||
sw->calculateSize((std::abs(this->screen()->geometry().width()) * widthRatio) * dpr,
|
||||
std::abs(this->screen()->geometry().height()));
|
||||
}
|
||||
}
|
||||
|
|
@ -726,6 +737,9 @@ void MainWindow::customEvent(QEvent* ev) {
|
|||
} else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) {
|
||||
ev->setAccepted(true);
|
||||
if (this->isVisible()) this->compose();
|
||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointRoleChange) {
|
||||
ev->setAccepted(true);
|
||||
this->flushRoleChanges();
|
||||
}
|
||||
QMainWindow::customEvent(ev);
|
||||
}
|
||||
|
|
@ -783,14 +797,27 @@ void MainWindow::reorderEndpointWidgetCollection() {
|
|||
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||
/* og 1080p 120% testing values */
|
||||
log_to_file("[EndpointWidget %s sizes]\n", converter.to_bytes(this->getEndpointHandler()->getName()).c_str());
|
||||
log_to_file("Params: {Width: %u Height: %u}\n", width, height);
|
||||
this->mainLabel->setMaximumWidth((int)(width * 0.50) /* 1080p 120%*/);
|
||||
this->mainLabel->setMinimumWidth((int)(width * 0.50) /* 1080p 120%*/);
|
||||
log_to_file("Params: {WWidth: %u SHeight: %u}\n", width, height);
|
||||
//this->setMaximumWidth(width);
|
||||
/*
|
||||
* this->mainLabel->setMaximumWidth((int)(width * 0.50) /\* 1080p 120%*\/);
|
||||
* this->mainLabel->setMinimumWidth((int)(width * 0.50) /\* 1080p 120%*\/);
|
||||
*/
|
||||
this->mainLabel->setMaximumSize((int)(width * 0.50), height /* 1080p 120%*/);
|
||||
this->mainLabel->setMinimumSize((int)(width * 0.50), 1 /* 1080p 120%*/);
|
||||
this->muteButton->setMaximumSize((int)(width * 0.10), height /* 1080p 120%*/);
|
||||
this->mainVolumeLabel->setMaximumSize((int)(width * 0.10), height /* 1080p 120%*/);
|
||||
for (auto roleCheckbox : defaultRolesCheckBoxes) {
|
||||
roleCheckbox.second->setMaximumWidth((int)(width * 0.20) /* 1080p 120%*/);
|
||||
log_to_file("Role %d width: %d \n", roleCheckbox.first, roleCheckbox.second->maximumWidth());
|
||||
}
|
||||
log_to_file("Main label width: %d \n", this->mainLabel->maximumWidth());
|
||||
log_to_file("Mute button width: %d \n", this->muteButton->maximumWidth());
|
||||
log_to_file("Volume label width: %d \n", this->mainVolumeLabel->maximumWidth());
|
||||
|
||||
if (cw) {
|
||||
this->cw->setMinimumSize(QSize(1, (height * 0.06) * (int)((cw->getChannelCount() / 2) + 0.5)));
|
||||
this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, (height * 0.06) * (int)((cw->getChannelCount() / 2) + 0.5)));
|
||||
//this->cw->setMaximumSize(QSize(width, (height * 0.06) * (int)((cw->getChannelCount() / 2) + 0.5)));
|
||||
log_to_file("Channels Maximum size: %d, %d \n", cw->maximumWidth(), cw->maximumHeight());
|
||||
log_to_file("Channels Minimum size: %d, %d \n", cw->minimumWidth(), cw->minimumHeight());
|
||||
}
|
||||
|
|
@ -889,15 +916,23 @@ void MainWindow::createLayout(QGridLayout *newLayout) {
|
|||
widget->setLayout(newLayout);
|
||||
this->widgetLayout = newLayout;
|
||||
|
||||
bool areEndpoints = false;
|
||||
uint64_t i = 0;
|
||||
for (EndpointWidget *epw : ews) {
|
||||
if (!epw) continue;
|
||||
else areEndpoints = true;
|
||||
log_debugcpp("EPWidget positioning");
|
||||
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
|
||||
epw->setIndex(i);
|
||||
this->widgetLayout->addWidget(epw, i++, 0);
|
||||
}
|
||||
widgetLayout->addItem(lastRowSpacer, i, 0);
|
||||
if(areEndpoints)
|
||||
widgetLayout->addItem(lastRowSpacer, i, 0);
|
||||
else {
|
||||
if (noEndpoints) delete noEndpoints;
|
||||
noEndpoints = new QLabel(STRING_NOENDPOINT, this);
|
||||
widgetLayout->addWidget(noEndpoints, i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||
|
|
@ -910,6 +945,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
//setStyleSheet("background: transparent; ");
|
||||
//setStyleSheet("background-color: rgba(255,182,193);");
|
||||
setWindowTitle(STRING_TITLE);
|
||||
/*
|
||||
* Font setup
|
||||
*/
|
||||
int id = QFontDatabase::addApplicationFont(":/assets/selawk.ttf");
|
||||
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
||||
font = QFont(family);
|
||||
font.setKerning(true);
|
||||
font.setPointSize(12);
|
||||
this->setFont(font);
|
||||
//qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
|
||||
|
||||
/*
|
||||
* Registering needed custom events
|
||||
*/
|
||||
|
|
@ -920,9 +966,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
QEvent::registerEventType(CustomQEvent::SessionWidgetObsolete);
|
||||
QEvent::registerEventType(CustomQEvent::SessionWidgetCreated);
|
||||
QEvent::registerEventType(CustomQEvent::RecomposeMainWindow);
|
||||
QEvent::registerEventType(CustomQEvent::EndpointRoleChange);
|
||||
|
||||
/* This spacer provides proper spacing when window vertically > widgets. */
|
||||
lastRowSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
|
||||
ewsUpdateTimer = new QTimer(this);
|
||||
recentlyClosedTimer = new QTimer(this);
|
||||
widget = new QWidget();
|
||||
|
|
@ -945,6 +993,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
* Scroll bar code
|
||||
*/
|
||||
scrollArea = new QScrollArea(this);
|
||||
//widget->setAttribute(Qt::WA_TranslucentBackground);
|
||||
scrollArea->setWidget(widget);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
|
|
@ -959,6 +1008,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
* Menu bar code
|
||||
*/
|
||||
mainMenuBar = new QToolBar(this);
|
||||
/*
|
||||
* QPalette pal;
|
||||
* pal.setColor(QPalette::Window, Qt::transparent);
|
||||
* mainMenuBar->setPalette(pal);
|
||||
*/
|
||||
hw = new HeaderWidget(this);
|
||||
mainMenuBar->addWidget(hw);
|
||||
mainMenuBar->setMovable(false);
|
||||
|
|
@ -993,26 +1047,72 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
this->recentlyClosedTimer->start();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Set of function callback definitons for EndpointSituationCallback
|
||||
*/
|
||||
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
||||
//Sigh... I hope to get this right when librole is done...
|
||||
//todo: STILL BORKED. THEY'RE NOT FORFEITING THEIR OLD POSITION
|
||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||
auto epw = this->ews.at(i);
|
||||
if (!epw) continue;
|
||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
||||
newDef = epw;
|
||||
continue; }
|
||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||
oldDef = epw;
|
||||
continue; }
|
||||
}
|
||||
osh->setRoleBucketEntryFunction([this](Roles role, std::wstring endpointId) {
|
||||
std::pair<Roles, std::wstring> entry = { role, endpointId };
|
||||
this->roleBucketList.push_back(entry);
|
||||
QCoreApplication::instance()->postEvent(this, new QEvent((QEvent::Type)CustomQEvent::EndpointRoleChange),Qt::LowEventPriority);
|
||||
});
|
||||
|
||||
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
||||
if (oldDef && newDef) {
|
||||
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
||||
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<uint64_t>((QEvent::Type)CustomQEvent::EndpointWidgetObsolete, index));
|
||||
});
|
||||
|
||||
osh->setAddEndpointWidgetFunction([this](EndpointHandler* eph) {
|
||||
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<EndpointHandler*>((QEvent::Type)CustomQEvent::EndpointWidgetCreated, eph));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::flushRoleChanges() {
|
||||
std::pair<Roles, std::wstring> change = roleBucketList.back();
|
||||
roleBucketList.pop_back();
|
||||
this->changeFrontDefaults(change.first, change.second);
|
||||
}
|
||||
|
||||
void MainWindow::changeFrontDefaults(Roles role, std::wstring endpointId) {
|
||||
//Sigh... I hope to get this right when librole is done...
|
||||
//todo: STILL BORKED. THEY'RE NOT FORFEITING THEIR OLD POSITION
|
||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||
auto epw = this->ews.at(i);
|
||||
if (!epw) continue;
|
||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
||||
newDef = epw;
|
||||
continue; }
|
||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||
oldDef = epw;
|
||||
continue; }
|
||||
}
|
||||
|
||||
|
||||
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
||||
if (newDef && !oldDef) {
|
||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
newDef->getEndpointHandler()->assignRoles(role);
|
||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
uint8_t newDefIdx = newDef->getIndex();
|
||||
uint8_t newDefRoles = newDef->getEndpointHandler()->getRoles();
|
||||
if (newDefRoles == Roles::ROLE_ALL) {
|
||||
newDef->setIndex(0);
|
||||
this->ews[0] = newDef;
|
||||
if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||
newDef->setIndex(0);
|
||||
this->ews[0] = newDef;
|
||||
} else if (newDefRoles & Roles::ROLE_COMMUNICATIONS) {
|
||||
newDef->setIndex(1);
|
||||
this->ews[1] = newDef;
|
||||
}
|
||||
log_debugcpp("newDef new idx: " + std::to_string(newDef->getIndex()));
|
||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||
}
|
||||
else if (oldDef && newDef) {
|
||||
this->ews.at(oldDef->getIndex()) = nullptr;
|
||||
this->ews.at(newDef->getIndex()) = nullptr;
|
||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
|
|
@ -1023,6 +1123,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
if (newDefRoles == Roles::ROLE_ALL) {
|
||||
newDef->setIndex(0);
|
||||
this->ews[0] = newDef;
|
||||
if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||
|
|
@ -1060,19 +1161,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
}
|
||||
log_debugcpp("oldDef new idx: " + std::to_string(oldDef->getIndex()));
|
||||
oldDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||
}
|
||||
QCoreApplication::instance()->postEvent
|
||||
(this, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||
});
|
||||
|
||||
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
||||
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<uint64_t>((QEvent::Type)CustomQEvent::EndpointWidgetObsolete, index));
|
||||
});
|
||||
|
||||
osh->setAddEndpointWidgetFunction([this](EndpointHandler* eph) {
|
||||
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<EndpointHandler*>((QEvent::Type)CustomQEvent::EndpointWidgetCreated, eph));
|
||||
});
|
||||
|
||||
}
|
||||
QCoreApplication::instance()->postEvent
|
||||
(this, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ enum CustomQEvent {
|
|||
EndpointDefaultChange = 1003,
|
||||
SessionWidgetCreated = 1004,
|
||||
SessionWidgetObsolete = 1005,
|
||||
RecomposeMainWindow = 1006
|
||||
RecomposeMainWindow = 1006,
|
||||
EndpointRoleChange = 1007
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -198,7 +199,11 @@ private slots:
|
|||
|
||||
private:
|
||||
//std::vector<EndpointHandler*> *ephs;
|
||||
void flushRoleChanges();
|
||||
void changeFrontDefaults(Roles role, std::wstring endpointId);
|
||||
|
||||
std::vector<EndpointWidget*> ews;
|
||||
std::vector<std::pair<Roles, std::wstring>> roleBucketList;
|
||||
QWidget *widget;
|
||||
QGridLayout *widgetLayout;
|
||||
|
||||
|
|
@ -209,6 +214,7 @@ private:
|
|||
QTimer *ewsUpdateTimer;
|
||||
static constexpr uint64_t ewsUpdateTimerFrequency = 500;
|
||||
double widthRatio = 0.28;
|
||||
double dpr = 1.0;
|
||||
bool recentlyClosed = false;
|
||||
uint8_t recentlyClosedTimerFrequency = 1000;
|
||||
QTimer *recentlyClosedTimer;
|
||||
|
|
@ -218,6 +224,9 @@ private:
|
|||
QToolBar *mainMenuBar;
|
||||
QScreen *screen;
|
||||
QSpacerItem* lastRowSpacer;
|
||||
QLabel* noEndpoints = nullptr;
|
||||
|
||||
QFont font;
|
||||
friend class EndpointWidget;
|
||||
//public slots:
|
||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include <QPixmapCache>
|
||||
#include <QLatin1Char>
|
||||
#include <QLatin1String>
|
||||
#include <QFontDatabase>
|
||||
//#include <QScrollbarStyleAnimation>
|
||||
//#include <QScrollBar>
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -181,6 +181,8 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
return QRect();
|
||||
|
||||
}
|
||||
|
||||
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option,
|
||||
|
|
|
|||
|
|
@ -46,16 +46,19 @@ int main (int argc, char* argv[]) {
|
|||
* log_debugcpp(a.toStdString());
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
QApplication::setStyle(new MixerStyle(QStyleFactory::create("Fusion")));
|
||||
//QApplication::setFont(font);
|
||||
QPalette palette = QGuiApplication::palette();
|
||||
//todo: ez full apply os accent colorw
|
||||
palette.setColor(QPalette::Active, QPalette::Highlight, QColor(255, 192, 203, 200));//QColor(30,30,30,100));
|
||||
QGuiApplication::setPalette(palette);
|
||||
//Check if running
|
||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||
|
||||
initialize_file_log();
|
||||
atexit(closeDebugFileLog);
|
||||
|
||||
//Check if running
|
||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||
//std::set_terminate(closeDebugFileLog2);
|
||||
if (!isSingleInstanceRunning("Mixer"))
|
||||
startSingleInstanceServer("Mixer");
|
||||
|
|
@ -71,7 +74,7 @@ int main (int argc, char* argv[]) {
|
|||
|
||||
//INIT FRONT
|
||||
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
||||
|
||||
|
||||
MainWindow window = MainWindow();
|
||||
//window.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::MinimumExpanding)
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue