Compare commits
2 commits
4756a00156
...
2115cdf508
| Author | SHA1 | Date | |
|---|---|---|---|
| 2115cdf508 | |||
| 46224d331c |
5 changed files with 111 additions and 25 deletions
41
src/debug.h
41
src/debug.h
|
|
@ -2,6 +2,28 @@
|
||||||
|
|
||||||
#if defined (QT_DEBUG) || defined (DEBUG) || defined (_DEBUG)
|
#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;
|
||||||
|
|
||||||
|
void inline initializeFileLogging() {
|
||||||
|
lfResult = fopen_s(&fileLog, "log.txt", "w");
|
||||||
|
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;
|
||||||
|
extern bool initializeFileLogging();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define initialize_file_log() initializeFileLogging()
|
||||||
|
|
||||||
template<size_t Y, typename T>
|
template<size_t Y, typename T>
|
||||||
std::bitset<Y> varToBitset(T info) {
|
std::bitset<Y> varToBitset(T info) {
|
||||||
std::bitset<Y> content(info);
|
std::bitset<Y> content(info);
|
||||||
|
|
@ -15,6 +37,7 @@ 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
|
#else
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
@ -29,19 +52,35 @@ std::bitset<Y> varToBitset(T info) {
|
||||||
#define log_wdebugcpp(str) do { \
|
#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()); \
|
OutputDebugStringW(std::wstring(L"[DEBUG] (" + std::wstring(WFILE) + L":" + std::to_wstring(__LINE__) + L"): " + std::wstring(str) +L"\n").c_str()); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#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 print_as_binary(len, type, info) varToBitset<len, type>(info)
|
||||||
|
|
||||||
|
#define close_file_log_buffer() do { \
|
||||||
|
fclose(fileLog); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define log_debugcpp(str)
|
#define log_debugcpp(str)
|
||||||
#define log_wdebugcpp(str)
|
#define log_wdebugcpp(str)
|
||||||
#define print_as_binary(len, type, info)
|
#define print_as_binary(len, type, info)
|
||||||
|
#define log_to_file_simple(fmt)
|
||||||
|
#define log_to_file(fmt, cnt...)
|
||||||
|
#define initialize_file_log() false
|
||||||
|
#define close_file_log_buffer()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Here as a quick reference, in case smthn similar is needed again */
|
/* Here as a quick reference, in case smthn similar is needed again */
|
||||||
/* typedef void (EndpointWidget::*epwMuteFunc)(bool muted); */
|
/* typedef void (EndpointWidget::*epwMuteFunc)(bool muted); */
|
||||||
/* typedef void (EndpointWidget::*epwMainVolumeFunc)(float newValue); */
|
/* Typedef void (EndpointWidget::*epwMainVolumeFunc)(float newValue); */
|
||||||
/* 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); */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define __STDC_WANT_LIB_EXT1__ 1
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <codecvt>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <climits>
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,12 @@ QRect MainWindow::setSizePosition(QScreen* screen, int width, int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::compose() {
|
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
|
//We need dynamically added child widgets to expand so that we know their height
|
||||||
/*
|
/*
|
||||||
* Setting correct widget widths and heights
|
* Setting correct widget widths and heights
|
||||||
*/
|
*/
|
||||||
|
log_to_file_simple("[Compose]\n");
|
||||||
screen = this->getCurrentScreen();
|
screen = this->getCurrentScreen();
|
||||||
log_debugcpp("Screen: " + screen->model().toStdString() + " " + screen->name().toStdString());
|
log_debugcpp("Screen: " + screen->model().toStdString() + " " + screen->name().toStdString());
|
||||||
|
|
||||||
|
|
@ -106,9 +108,9 @@ void MainWindow::compose() {
|
||||||
log_debugcpp("epw loop");
|
log_debugcpp("epw loop");
|
||||||
log_debugcpp("epw roles: " + std::to_string(epw->getEndpointHandler()->getRoles()));
|
log_debugcpp("epw roles: " + std::to_string(epw->getEndpointHandler()->getRoles()));
|
||||||
//std::bitset<sizeof(uint8_t)> content =
|
//std::bitset<sizeof(uint8_t)> content =
|
||||||
print_as_binary(8, uint8_t, (epw->getEndpointHandler()->getRoles()));
|
//print_as_binary(8, uint8_t, (epw->getEndpointHandler()->getRoles()));
|
||||||
//log_debugcpp(content);
|
//log_debugcpp(content);
|
||||||
varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles());
|
//varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -160,7 +162,9 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
||||||
widgetLayout = new QHBoxLayout(this);
|
widgetLayout = new QHBoxLayout(this);
|
||||||
//widgetLayout->setSizeConstraint(QLayout::SetFixedSize);
|
//widgetLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
widgetLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
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);
|
muteButton = new QCheckBox(this);
|
||||||
mainLabel = new QLabel(QString::fromStdWString(sh->getName()), 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/32th 1080p*/);
|
||||||
//this->muteButton->setMinimumWidth((int)(width * 0.10) /*1/16 1080p*/);
|
//this->muteButton->setMinimumWidth((int)(width * 0.10) /*1/16 1080p*/);
|
||||||
this->mainSlider->setMinimumWidth((int)(width * 0.30) /*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){
|
void SessionWidget::updateMute(int checked){
|
||||||
|
|
@ -257,6 +273,7 @@ SessionWidget::~SessionWidget() {
|
||||||
ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||||
this->eph = eph;
|
this->eph = eph;
|
||||||
this->channelCount = channelCount;
|
this->channelCount = channelCount;
|
||||||
|
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||||
widgetLayout = new QGridLayout(this);
|
widgetLayout = new QGridLayout(this);
|
||||||
float volume = 100;
|
float volume = 100;
|
||||||
int left = 0, top = 0, right = 0, bottom = 0;
|
int left = 0, top = 0, right = 0, bottom = 0;
|
||||||
|
|
@ -267,31 +284,30 @@ ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidge
|
||||||
* Channel sliders setup
|
* Channel sliders setup
|
||||||
*/
|
*/
|
||||||
//uint32_t epChannelCount = eph->getChannelCount();
|
//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);
|
QSlider* tmp = new QSlider(Qt::Horizontal);
|
||||||
QLabel* tmpLb = new QLabel("");
|
QLabel* tmpLb = new QLabel("");
|
||||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
|
||||||
//tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
||||||
tmp->setTickInterval(5);
|
tmp->setTickInterval(5);
|
||||||
tmp->setSingleStep(1);
|
tmp->setSingleStep(1);
|
||||||
tmp->setRange(0,100);
|
tmp->setRange(0,100);
|
||||||
|
|
||||||
volume = eph->getVolume(i) * 100;
|
volume = eph->getVolume(channel) * 100;
|
||||||
tmp->setValue((int) volume);
|
tmp->setValue((int) volume);
|
||||||
tmpLb->setText(QString::number(volume));
|
tmpLb->setText(QString::number(volume));
|
||||||
//tmpLb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
//tmpLb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
tmp->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
tmp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
tmpLb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
tmpLb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
this->channelSliders.push_back(tmp);
|
this->channelSliders.push_back(tmp);
|
||||||
this->channelLabels.push_back(tmpLb);
|
this->channelLabels.push_back(tmpLb);
|
||||||
widgetLayout->addWidget(tmp, 0, i);
|
widgetLayout->addWidget(tmp, row , col);
|
||||||
widgetLayout->addWidget(tmpLb, 1, i);
|
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
|
//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.
|
//this causes channel bar desync when back -> front. blocksignals below fix it. huh.
|
||||||
connect(tmp, &QSlider::valueChanged, [this, i](int newValue){
|
connect(tmp, &QSlider::valueChanged, [this, channel](int newValue){
|
||||||
this->eph->setVolume(osh->getGuid(), i, newValue);
|
this->eph->setVolume(osh->getGuid(), channel, newValue);
|
||||||
this->channelLabels.at(i)->setText(QString::number(newValue));
|
this->channelLabels.at(channel)->setText(QString::number(newValue));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this->setLayout(widgetLayout);
|
this->setLayout(widgetLayout);
|
||||||
|
|
@ -314,6 +330,10 @@ void ChannelWidget::updateChannel(int channel) {
|
||||||
this->channelSliders.at(channel)->blockSignals(false);
|
this->channelSliders.at(channel)->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ChannelWidget::getChannelCount() const {
|
||||||
|
return channelCount;
|
||||||
|
}
|
||||||
|
|
||||||
EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t idx) : QWidget(parent) {
|
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
|
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
||||||
row = 0;
|
row = 0;
|
||||||
|
|
@ -392,7 +412,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
||||||
|
|
||||||
uint32_t epChannelCount = eph->getChannelCount();
|
uint32_t epChannelCount = eph->getChannelCount();
|
||||||
if(epChannelCount > 1) {
|
if(epChannelCount > 1) {
|
||||||
cw = new ChannelWidget(epChannelCount, eph, this);
|
cw = new ChannelWidget(epChannelCount, eph, nullptr);
|
||||||
//cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
//cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
widgetLayout->addWidget(cw, row++, 0, 1, 4 /*colmax*/, Qt::AlignTop);
|
widgetLayout->addWidget(cw, row++, 0, 1, 4 /*colmax*/, Qt::AlignTop);
|
||||||
}
|
}
|
||||||
|
|
@ -583,11 +603,17 @@ void MainWindow::reorderEndpointWidgetCollection() {
|
||||||
|
|
||||||
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
|
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||||
/* og 1080p 120% testing values */
|
/* og 1080p 120% testing values */
|
||||||
this->mainLabel->setMaximumWidth((int)width * 0.50 /* 1080p 120%*/);
|
log_to_file("[EndpointWidget %s sizes]\n", converter.to_bytes(this->getEndpointHandler()->getName()).c_str());
|
||||||
this->mainLabel->setMinimumWidth((int)width * 0.50 /* 1080p 120%*/);
|
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) {
|
if (cw) {
|
||||||
this->cw->setMinimumSize(QSize(1, 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));
|
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){
|
for (auto sw : sessionWidgets){
|
||||||
if (sw) sw->calculateSize(width, height);
|
if (sw) sw->calculateSize(width, height);
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ public:
|
||||||
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
||||||
~SessionWidget();
|
~SessionWidget();
|
||||||
void calculateSize(uint64_t width, uint64_t height);
|
void calculateSize(uint64_t width, uint64_t height);
|
||||||
|
std::wstring getName();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateMainVolume(int newValue);
|
void updateMainVolume(int newValue);
|
||||||
void updateMute(int checked);
|
void updateMute(int checked);
|
||||||
|
|
@ -111,6 +113,7 @@ public:
|
||||||
//QSize minimumSizeHint() const override;
|
//QSize minimumSizeHint() const override;
|
||||||
//void setMinimum(QSize minimum);
|
//void setMinimum(QSize minimum);
|
||||||
void updateChannel(int channel);
|
void updateChannel(int channel);
|
||||||
|
uint32_t getChannelCount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double roundingFactor = 0.005;
|
const double roundingFactor = 0.005;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
//#include "contclasses.h"
|
//#include "contclasses.h"
|
||||||
|
#define INIT_FILELOG
|
||||||
#include "qtclasses.h"
|
#include "qtclasses.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
|
|
@ -31,10 +32,24 @@ QLocalServer* startSingleInstanceServer(QString appName) {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void closeDebugFileLog() {
|
||||||
|
close_file_log_buffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set_terminate
|
||||||
|
* void closeDebugFileLog2() {
|
||||||
|
* close_file_log_buffer();
|
||||||
|
* abort();
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
int main (int argc, char* argv[]) {
|
int main (int argc, char* argv[]) {
|
||||||
//QApplication::setStyle("windowsvista");
|
//QApplication::setStyle("windowsvista");
|
||||||
//Check if running
|
//Check if running
|
||||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||||
|
initialize_file_log();
|
||||||
|
atexit(closeDebugFileLog);
|
||||||
|
//std::set_terminate(closeDebugFileLog2);
|
||||||
if (!isSingleInstanceRunning("Mixer"))
|
if (!isSingleInstanceRunning("Mixer"))
|
||||||
startSingleInstanceServer("Mixer");
|
startSingleInstanceServer("Mixer");
|
||||||
else exit(0);
|
else exit(0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue