wip: detected width bug (channels)
This commit is contained in:
parent
46224d331c
commit
2115cdf508
5 changed files with 63 additions and 31 deletions
|
|
@ -78,10 +78,12 @@ QRect MainWindow::setSizePosition(QScreen* screen, int width, int height) {
|
|||
}
|
||||
|
||||
void MainWindow::compose() {
|
||||
//todo: invalidate layout when adding sessions with window open
|
||||
//We need dynamically added child widgets to expand so that we know their height
|
||||
/*
|
||||
* Setting correct widget widths and heights
|
||||
*/
|
||||
log_to_file_simple("[Compose]\n");
|
||||
screen = this->getCurrentScreen();
|
||||
log_debugcpp("Screen: " + screen->model().toStdString() + " " + screen->name().toStdString());
|
||||
|
||||
|
|
@ -160,7 +162,9 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
|||
widgetLayout = new QHBoxLayout(this);
|
||||
//widgetLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
widgetLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||
widgetLayout->setContentsMargins(0, 10, 0, 10);
|
||||
int left = 0, top = 0, right = 0, bottom = 0;
|
||||
widgetLayout->getContentsMargins(&left, &top, &right, &bottom);
|
||||
widgetLayout->setContentsMargins(0, top, 0, bottom);
|
||||
|
||||
muteButton = new QCheckBox(this);
|
||||
mainLabel = new QLabel(QString::fromStdWString(sh->getName()), this);
|
||||
|
|
@ -236,7 +240,19 @@ void SessionWidget::calculateSize(uint64_t width, uint64_t height) {
|
|||
this->muteButton->setMinimumWidth((int)(width * 0.10) /*1/32th 1080p*/);
|
||||
//this->muteButton->setMinimumWidth((int)(width * 0.10) /*1/16 1080p*/);
|
||||
this->mainSlider->setMinimumWidth((int)(width * 0.30) /*1/16 1080p*/);
|
||||
widthSpacer->changeSize((int)width * 0.20, 1, QSizePolicy::Expanding, QSizePolicy::Minimum /*200*/);
|
||||
widthSpacer->changeSize((int)(width * 0.20), 1, QSizePolicy::Expanding, QSizePolicy::Minimum /*200*/);
|
||||
|
||||
log_to_file("\t[Session %s sizes]\n", converter.to_bytes(this->getName()).c_str());
|
||||
log_to_file("\tMain label Maximum size: %d, %d \n", mainLabel->maximumWidth(), mainLabel->maximumHeight());
|
||||
log_to_file("\tMain label Minimum size: %d, %d \n", mainLabel->minimumWidth(), mainLabel->minimumHeight());
|
||||
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());
|
||||
}
|
||||
|
||||
std::wstring SessionWidget::getName() {
|
||||
return sh->getName();
|
||||
}
|
||||
|
||||
void SessionWidget::updateMute(int checked){
|
||||
|
|
@ -257,6 +273,7 @@ SessionWidget::~SessionWidget() {
|
|||
ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||
this->eph = eph;
|
||||
this->channelCount = channelCount;
|
||||
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||
widgetLayout = new QGridLayout(this);
|
||||
float volume = 100;
|
||||
int left = 0, top = 0, right = 0, bottom = 0;
|
||||
|
|
@ -267,31 +284,30 @@ ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidge
|
|||
* Channel sliders setup
|
||||
*/
|
||||
//uint32_t epChannelCount = eph->getChannelCount();
|
||||
for(uint32_t i = 0; i < channelCount && channelCount > 1; i++){
|
||||
for(uint64_t channel = 0, col = 0, row = 0; channel < channelCount && channelCount > 1; channel++){
|
||||
QSlider* tmp = new QSlider(Qt::Horizontal);
|
||||
QLabel* tmpLb = new QLabel("");
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
//tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
tmp->setTickInterval(5);
|
||||
tmp->setSingleStep(1);
|
||||
tmp->setRange(0,100);
|
||||
|
||||
volume = eph->getVolume(i) * 100;
|
||||
volume = eph->getVolume(channel) * 100;
|
||||
tmp->setValue((int) volume);
|
||||
tmpLb->setText(QString::number(volume));
|
||||
//tmpLb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
tmp->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
tmpLb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
tmp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
tmpLb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
this->channelSliders.push_back(tmp);
|
||||
this->channelLabels.push_back(tmpLb);
|
||||
widgetLayout->addWidget(tmp, 0, i);
|
||||
widgetLayout->addWidget(tmpLb, 1, i);
|
||||
widgetLayout->addWidget(tmp, row , col);
|
||||
widgetLayout->addWidget(tmpLb, row + 1, col++);
|
||||
if(channel % 2 != 0) { row += 2; col = 0; }
|
||||
|
||||
//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){
|
||||
this->eph->setVolume(osh->getGuid(), i, newValue);
|
||||
this->channelLabels.at(i)->setText(QString::number(newValue));
|
||||
connect(tmp, &QSlider::valueChanged, [this, channel](int newValue){
|
||||
this->eph->setVolume(osh->getGuid(), channel, newValue);
|
||||
this->channelLabels.at(channel)->setText(QString::number(newValue));
|
||||
});
|
||||
}
|
||||
this->setLayout(widgetLayout);
|
||||
|
|
@ -314,6 +330,10 @@ void ChannelWidget::updateChannel(int channel) {
|
|||
this->channelSliders.at(channel)->blockSignals(false);
|
||||
}
|
||||
|
||||
uint32_t ChannelWidget::getChannelCount() const {
|
||||
return channelCount;
|
||||
}
|
||||
|
||||
EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t idx) : QWidget(parent) {
|
||||
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
||||
row = 0;
|
||||
|
|
@ -392,7 +412,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
|
||||
uint32_t epChannelCount = eph->getChannelCount();
|
||||
if(epChannelCount > 1) {
|
||||
cw = new ChannelWidget(epChannelCount, eph, this);
|
||||
cw = new ChannelWidget(epChannelCount, eph, nullptr);
|
||||
//cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
widgetLayout->addWidget(cw, row++, 0, 1, 4 /*colmax*/, Qt::AlignTop);
|
||||
}
|
||||
|
|
@ -583,12 +603,17 @@ void MainWindow::reorderEndpointWidgetCollection() {
|
|||
|
||||
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||
/* og 1080p 120% testing values */
|
||||
this->mainLabel->setMaximumWidth((int)width * 0.50 /* 1080p 120%*/);
|
||||
this->mainLabel->setMinimumWidth((int)width * 0.50 /* 1080p 120%*/);
|
||||
|
||||
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("Main label width: %d \n", this->mainLabel->maximumWidth());
|
||||
|
||||
if (cw) {
|
||||
this->cw->setMinimumSize(QSize(1, height * 0.06));
|
||||
this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, height * 0.06));
|
||||
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)));
|
||||
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());
|
||||
}
|
||||
for (auto sw : sessionWidgets){
|
||||
if (sw) sw->calculateSize(width, height);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue