wip: ini parse baseline

This commit is contained in:
Hane 2024-12-03 21:13:42 +01:00
commit 8e07b1efdd
9 changed files with 356 additions and 27 deletions

View file

@ -296,7 +296,7 @@ void MainWindow::compose() {
this->mainMenuBar->setMaximumWidth((int)windowWidth);
for (auto *epw : ews) {
if (!epw) continue;
epw->updateChannelsVisibility();
epw->calculateSize(windowWidth - scrollArea->verticalScrollBar()->sizeHint().width()
- widgetLayout->contentsMargins().left()
, screenHeight);
@ -605,8 +605,12 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
if(epChannelCount > 1) {
cw = new ChannelWidget(epChannelCount, eph, nullptr);
cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
//cw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
widgetLayout->addWidget(cw, row++, 0, 1, 4 /*colmax*/, Qt::AlignTop);
cw->setVisible(false);
char* const channelSettings = set->getValue("show_channels");
if(channelSettings && !(strcmp(channelSettings, "true"))){
cw->setVisible(true);
}
}
/*
@ -889,6 +893,13 @@ void EndpointWidget::updateMainVolume(int newValue){
* }
*/
void EndpointWidget::updateChannelsVisibility() {
char* const channelSettings = set->getValue("show_channels");
if(channelSettings && !(strcmp(channelSettings, "true"))){
cw->setVisible(true);
} else cw->setVisible(false);
}
EndpointHandler* EndpointWidget::getEndpointHandler(){
return this->eph;
}
@ -915,19 +926,36 @@ std::map<Roles, ExtendedCheckBox*> EndpointWidget::getDefaultRolesWidgets() {
HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
widgetLayout = new QGridLayout(this);
QString text = "&" STRING_ABOUT;
about = new QPushButton(text, this);
QString text; //= "&" STRING_ABOUT;
//about = new QPushButton(text, this);
#ifdef WIN32
text = "&" STRING_CP;
openCP = new QPushButton(text, this);
connect(openCP, &QPushButton::clicked, [](){ osh->openControlPanel(); });
text = "&" STRING_STARTUP;
startup = new QPushButton(text, this);
text = "&" STRING_CHANNELS;
channels = new QCheckBox(text, this);
char* const channelSettings = set->getValue("show_channels");
if(channelSettings && !(strcmp(channelSettings, "true"))){
channels->setChecked(true);
}
connect(channels, &QCheckBox::stateChanged, [this, parent](){
set->setValue("show_channels", channels->isChecked(), sizeof("show_channels"));
if(parent)
QCoreApplication::instance()->postEvent
(parent, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
});
widgetLayout->addWidget(openCP , 0, 0);
widgetLayout->addWidget(startup, 0, 1);
text = "&" STRING_STARTUP;
startup = new QCheckBox(text, this);
//connect(openCP, &QPushButton::clicked, [](){ osh->openControlPanel(); });
widgetLayout->addWidget(openCP , 0, 0, 2, 2);
widgetLayout->addWidget(channels, 0, 2, 1, 2);
widgetLayout->addWidget(startup , 1, 2, 1, 2);
#endif
widgetLayout->addWidget(about , 0, 2);
//widgetLayout->addWidget(about , 0, 2);
this->setLayout(widgetLayout);
}
@ -1034,19 +1062,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
* Menu bar code
*/
mainMenuBar = new QToolBar(this);
/*
* QPalette pal;
* pal.setColor(QPalette::Window, Qt::transparent);
* mainMenuBar->setPalette(pal);
*/
hw = new HeaderWidget(this);
mainMenuBar->addWidget(hw);
mainMenuBar->setMovable(false);
this->addToolBar(Qt::BottomToolBarArea, mainMenuBar);
reloadEndpointWidgets();
//scrollArea->setMinimumWidth(ews.at(0)->minimumWidth());
log_debugcpp(std::to_string(scrollArea->minimumWidth()));
/*
* Tray Icon code