enable/disable/add/remove groundwork done
This commit is contained in:
parent
a6a052f348
commit
04da76c021
4 changed files with 66 additions and 58 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "qtclasses.h"
|
||||
|
||||
|
||||
|
||||
bool ExtendedCheckBox::event(QEvent* ev) {
|
||||
if (ev->type() == QEvent::User) {
|
||||
this->blockSignals(true);
|
||||
|
|
@ -20,26 +21,27 @@ bool ExtendedCheckBox::event(QEvent* ev) {
|
|||
|
||||
|
||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
||||
this->idx = idx;
|
||||
this->eph = eph;
|
||||
layout = new QGridLayout();
|
||||
this->setLayout(layout);
|
||||
log_debugcpp("olaW");
|
||||
layout = new QGridLayout(this);
|
||||
//this->setLayout(layout);
|
||||
log_debugcpp("epw main layout parent: "<< layout->parent());
|
||||
if (parent == nullptr) { log_debugcpp("owo?"); }
|
||||
|
||||
defaultRolesCheckBoxes = {
|
||||
{Roles::ROLE_ALL, new ExtendedCheckBox()},
|
||||
{Roles::ROLE_CONSOLE, new ExtendedCheckBox()},
|
||||
{Roles::ROLE_MULTIMEDIA, new ExtendedCheckBox()},
|
||||
{Roles::ROLE_COMMUNICATIONS, new ExtendedCheckBox()}
|
||||
{Roles::ROLE_ALL, new ExtendedCheckBox(this)},
|
||||
{Roles::ROLE_CONSOLE, new ExtendedCheckBox(this)},
|
||||
{Roles::ROLE_MULTIMEDIA, new ExtendedCheckBox(this)},
|
||||
{Roles::ROLE_COMMUNICATIONS, new ExtendedCheckBox(this)}
|
||||
};
|
||||
|
||||
/*
|
||||
* Mute, main slider and label setup
|
||||
*/
|
||||
muteButton = new QCheckBox();
|
||||
mainLabel = new QLabel(QString::fromStdWString(eph->getName()));
|
||||
mainSlider = new QSlider(Qt::Horizontal);
|
||||
muteButton = new QCheckBox(this);
|
||||
mainLabel = new QLabel(QString::fromStdWString(eph->getName()), this);
|
||||
mainSlider = new QSlider(Qt::Horizontal, this);
|
||||
|
||||
if (this->eph->getState() != EndpointState::ENDPOINT_ACTIVE) {
|
||||
layout->addWidget(mainLabel, 0, 0);
|
||||
|
|
@ -48,6 +50,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
}
|
||||
|
||||
//muteButton->setStyleSheet("background-color: #A3C1DA; color: red");
|
||||
mainSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
||||
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
mainSlider->setTickInterval(5);
|
||||
|
|
@ -60,12 +63,11 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
mainSlider->setValue((int)volume);
|
||||
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
||||
|
||||
//todo: parent
|
||||
mainMuteLayout = new QGridLayout();
|
||||
layout->addLayout(mainMuteLayout, 0, 0, 2, 1, Qt::AlignLeft | Qt::AlignBottom);
|
||||
mainMuteLayout->addWidget(mainLabel, 0, 0);
|
||||
mainMuteLayout->addWidget(muteButton, 0, 1);
|
||||
layout->addWidget(mainSlider, 0, 2, 1, 2, Qt::AlignLeft | Qt::AlignBottom);
|
||||
//tip: would need to be new widget with layout in it
|
||||
//mainMuteLayout = new QGridLayout();
|
||||
layout->addWidget(mainLabel, 0, 0, Qt::AlignLeft | Qt::AlignBottom);
|
||||
layout->addWidget(muteButton, 0, 1, Qt::AlignLeft | Qt::AlignBottom);
|
||||
layout->addWidget(mainSlider, 0, 2, 1, 2);
|
||||
|
||||
//TODO:0 = mute and muted, change volume = unmuted are client side tricks = 2 callbacks, one for volume, one for mute state. Implement as an user selectable option?
|
||||
connect<void(QSlider::*)(int), void(EndpointWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&EndpointWidget::updateMainVolume);
|
||||
|
|
@ -78,6 +80,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
for(uint32_t i = 0; i < eph->getChannelCount(); i++){
|
||||
QSlider* tmp = new QSlider(Qt::Horizontal);
|
||||
QLabel* tmpLb = new QLabel("");
|
||||
tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
tmp->setTickInterval(5);
|
||||
tmp->setSingleStep(1);
|
||||
tmp->setRange(0,100);
|
||||
|
|
@ -87,8 +90,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
tmpLb->setText(QString::number(volume));
|
||||
this->channelSliders.push_back(tmp);
|
||||
this->channelLabels.push_back(tmpLb);
|
||||
layout->addWidget(tmp, 2, i, 1, 2, Qt::AlignLeft | Qt::AlignTop);
|
||||
layout->addWidget(tmpLb, 3, i, 1, 2, Qt::AlignLeft | Qt::AlignTop);
|
||||
layout->addWidget(tmp, 2, i);
|
||||
layout->addWidget(tmpLb, 3, i);
|
||||
//TODO: check if there's a need to prevent deadlocks; probably this will eventually turn into its own func
|
||||
//this causes channel bar desync when back -> front. blocksignals below fix it. huh.
|
||||
connect(tmp, &QSlider::valueChanged, [this, i](int newValue){
|
||||
|
|
@ -329,16 +332,18 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
|||
|
||||
void MainWindow::reloadEndpointWidgets() {
|
||||
size_t i = 0;
|
||||
for (; i < (osh->getEndpointHandlers().size()); i++) {
|
||||
log_debugcpp("EPWidget creation");
|
||||
osh->getEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
|
||||
EndpointWidget *epw = new EndpointWidget(i, osh->getEndpointHandlers().at(i), widget);
|
||||
//TODO: ALWAYS PUSH BACK??? PSZ CHANGE DIS WHEN IMPLEMENTING DYN ENDPOINT DET
|
||||
ews.push_back(epw);
|
||||
layout->addWidget(epw, i, 0);
|
||||
|
||||
for (size_t epwIndex = 0; i < (osh->getEndpointHandlers().size()); i++) {
|
||||
if (osh->getEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){
|
||||
log_debugcpp("EPWidget creation");
|
||||
osh->getEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
|
||||
EndpointWidget *epw = new EndpointWidget(epwIndex, osh->getEndpointHandlers().at(i), widget);
|
||||
epwIndex++;
|
||||
//TODO: ALWAYS PUSH BACK??? PSZ CHANGE DIS WHEN IMPLEMENTING DYN ENDPOINT DET
|
||||
ews.push_back(epw);
|
||||
layout->addWidget(epw, i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//todo:: tas aqui tirao, no me gustas y probablemente yo a ti tampoco
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue