114 lines
4.4 KiB
C++
114 lines
4.4 KiB
C++
#include "qtclasses.h"
|
|
|
|
|
|
EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
|
this->eph = eph;
|
|
layout = new QGridLayout();
|
|
this->setLayout(layout);
|
|
log_debugcpp("olaW");
|
|
if (parent == nullptr) { log_debugcpp("owo?"); }
|
|
|
|
muteButton = new QPushButton();
|
|
mainLabel = new QLabel(eph->getName());
|
|
leftChannelLabel = new QLabel("88");
|
|
rightChannelLabel = new QLabel("77");
|
|
mainSlider = new QSlider(Qt::Horizontal);
|
|
leftChannelSlider = new QSlider(Qt::Horizontal);
|
|
rightChannelSlider = new QSlider(Qt::Horizontal);
|
|
|
|
muteButton->setStyleSheet("background-color: #A3C1DA; color: red");
|
|
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
|
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
|
mainSlider->setTickInterval(5);
|
|
mainSlider->setSingleStep(1);
|
|
mainSlider->setRange(0,100);
|
|
leftChannelSlider->setTickInterval(5);
|
|
leftChannelSlider->setSingleStep(1);
|
|
leftChannelSlider->setRange(0,100);
|
|
rightChannelSlider->setTickInterval(5);
|
|
rightChannelSlider->setSingleStep(1);
|
|
rightChannelSlider->setRange(0,100);
|
|
|
|
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
|
float volume = eph->getVolume(ENDPOINT_MASTER_VOLUME) * 100;
|
|
mainSlider->setValue((int)volume);
|
|
volume = eph->getVolume(ENDPOINT_LEFT_CHANNEL_VOLUME) * 100;
|
|
leftChannelSlider->setValue((int)volume);
|
|
leftChannelLabel->setText(QString::number(volume));
|
|
volume = eph->getVolume(ENDPOINT_RIGHT_CHANNEL_VOLUME) * 100;
|
|
rightChannelSlider->setValue((int)volume);
|
|
rightChannelLabel->setText(QString::number(volume));
|
|
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
|
|
|
mainMuteLayout = new QGridLayout();
|
|
layout->addLayout(mainMuteLayout, 0, 0);
|
|
mainMuteLayout->addWidget(mainLabel, 0, 0);
|
|
mainMuteLayout->addWidget(muteButton, 0, 1);
|
|
layout->addWidget(mainSlider, 0, 1);
|
|
layout->addWidget(leftChannelSlider, 1, 0);
|
|
layout->addWidget(leftChannelLabel, 2, 0);
|
|
layout->addWidget(rightChannelSlider, 1, 1);
|
|
layout->addWidget(rightChannelLabel, 2, 1);
|
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 0);
|
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 1);
|
|
|
|
/*
|
|
* connect(mainSlider, &QSlider::valueChanged, eph, &EndpointHandler::setValue);
|
|
*/
|
|
connect(mainSlider, &QSlider::valueChanged, [this](int newValue){this->eph->setValue(ENDPOINT_MASTER_VOLUME, newValue); });
|
|
connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
|
|
connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
|
|
connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
|
log_debugcpp("ENDPOINT_WIDGETED");
|
|
}
|
|
|
|
|
|
MainWindow::MainWindow(std::vector<EndpointHandler*> *ephs, QWidget *parent) : QMainWindow(parent) {
|
|
// setWindowState(Qt::WindowFullScreen);
|
|
// setCentralWidget(centralWidget);
|
|
widget = new QWidget();
|
|
layout = new QGridLayout();
|
|
|
|
widget->setLayout(layout);
|
|
setCentralWidget(widget);
|
|
//layout->addWidget(pintas, 0, 0);
|
|
|
|
setWindowTitle("slidea resbala nu c");
|
|
|
|
/*s
|
|
* setEndpointHandlers(ephs);
|
|
*/
|
|
unsigned int i = 0;
|
|
for (; i < ephs->size(); i++) {
|
|
log_debugcpp("EPWidget creation");
|
|
EndpointWidget *epw = new EndpointWidget(ephs->at(i), widget);
|
|
ews.push_back(epw);
|
|
layout->addWidget(epw, i, 0);
|
|
}
|
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
|
|
}
|
|
|
|
/*
|
|
* void MainWindow::setEndpointHandlers(std::vector<EndpointHandler*> *ephs){
|
|
* this->ephs = ephs;
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
* void MainWindow::setPlotButton() {
|
|
* button = new QPushButton("push"),
|
|
* button->setCheckable(true);
|
|
* connect(button, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)))
|
|
* QHBoxLayout *plotsLayout = new QHBoxLayout;
|
|
* plotsLayout->setSpacing(10);
|
|
* plotsLayout->addWidget(funPlot);
|
|
* QHBoxLayout *buttonsLayout = new QHBoxLayout ;
|
|
* buttonsLayout->addWidget(button);
|
|
* QVBoxLayout *widgetLayout = new QVBoxLayout;
|
|
* widgetLayout->addLayout(plotsLayout);
|
|
* widgetLayout->addLayout(buttonsLayout);
|
|
* setLayout(widgetLayout);
|
|
* ...
|
|
*/
|
|
|