wip: detected width bug (channels)
This commit is contained in:
parent
46224d331c
commit
2115cdf508
5 changed files with 63 additions and 31 deletions
16
src/debug.h
16
src/debug.h
|
|
@ -3,17 +3,19 @@
|
|||
#if defined (QT_DEBUG) || defined (DEBUG) || defined (_DEBUG)
|
||||
|
||||
#ifdef INIT_FILELOG
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
|
||||
FILE* fileLog;
|
||||
errno_t lfResult;
|
||||
bool writable = false;
|
||||
|
||||
bool initializeFileLogging() {
|
||||
void inline initializeFileLogging() {
|
||||
lfResult = fopen_s(&fileLog, "log.txt", "w");
|
||||
if (!lfResult) return true;
|
||||
else return false;
|
||||
if (!lfResult) writable = true;
|
||||
else writable = false;
|
||||
}
|
||||
|
||||
#else
|
||||
extern std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter;
|
||||
extern errno_t lfResult;
|
||||
extern FILE* fileLog;
|
||||
extern bool writable;
|
||||
|
|
@ -53,10 +55,13 @@ std::bitset<Y> varToBitset(T info) {
|
|||
|
||||
#endif
|
||||
|
||||
#define log_to_file(fmt, cnt) do { \
|
||||
|
||||
#define log_to_file_simple(fmt) log_to_file(fmt, "")
|
||||
#define log_to_file(fmt, cnt...) do { \
|
||||
if(writable) fprintf_s(fileLog, fmt, cnt); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define print_as_binary(len, type, info) varToBitset<len, type>(info)
|
||||
|
||||
#define close_file_log_buffer() do { \
|
||||
|
|
@ -67,7 +72,8 @@ std::bitset<Y> varToBitset(T info) {
|
|||
#define log_debugcpp(str)
|
||||
#define log_wdebugcpp(str)
|
||||
#define print_as_binary(len, type, info)
|
||||
#define log_to_file(fmt, cnt)
|
||||
#define log_to_file_simple(fmt)
|
||||
#define log_to_file(fmt, cnt...)
|
||||
#define initialize_file_log() false
|
||||
#define close_file_log_buffer()
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <codecvt>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <bitset>
|
||||
#include <climits>
|
||||
#include <locale>
|
||||
|
||||
#include "debug.h"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@ public:
|
|||
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
||||
~SessionWidget();
|
||||
void calculateSize(uint64_t width, uint64_t height);
|
||||
std::wstring getName();
|
||||
|
||||
public slots:
|
||||
void updateMainVolume(int newValue);
|
||||
void updateMute(int checked);
|
||||
|
|
@ -111,6 +113,7 @@ public:
|
|||
//QSize minimumSizeHint() const override;
|
||||
//void setMinimum(QSize minimum);
|
||||
void updateChannel(int channel);
|
||||
uint32_t getChannelCount() const;
|
||||
|
||||
private:
|
||||
const double roundingFactor = 0.005;
|
||||
|
|
|
|||
|
|
@ -47,10 +47,7 @@ int main (int argc, char* argv[]) {
|
|||
//QApplication::setStyle("windowsvista");
|
||||
//Check if running
|
||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||
writable = initialize_file_log();
|
||||
log_to_file("%d hola", 3);
|
||||
//int bro = fprintf_s(fileLog, "hola\n");
|
||||
//bro = fprintf(fileLog, "hola");
|
||||
initialize_file_log();
|
||||
atexit(closeDebugFileLog);
|
||||
//std::set_terminate(closeDebugFileLog2);
|
||||
if (!isSingleInstanceRunning("Mixer"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue