dynamic height + width 1st commit
This commit is contained in:
parent
8d1a0d190b
commit
90286b6853
3 changed files with 97 additions and 118 deletions
|
|
@ -25,7 +25,7 @@ void ExtendedCheckBox::customEvent(QEvent* ev) {
|
||||||
QCheckBox::customEvent(ev);
|
QCheckBox::customEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect MainWindow::setSizePosition() {
|
QRect MainWindow::setSizePosition(int width, int height) {
|
||||||
//setGeometry ignores decoration size xdddd
|
//setGeometry ignores decoration size xdddd
|
||||||
QRect trayIconPos = this->trayIcon->geometry();
|
QRect trayIconPos = this->trayIcon->geometry();
|
||||||
int tix1, tix2, tiy1, tiy2;
|
int tix1, tix2, tiy1, tiy2;
|
||||||
|
|
@ -45,29 +45,51 @@ QRect MainWindow::setSizePosition() {
|
||||||
|
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case SpawnPos::UP | SpawnPos::RIGHT:
|
case SpawnPos::UP | SpawnPos::RIGHT:
|
||||||
return QRect((arx2 - windowWidth), ary1, windowWidth, 440);
|
return QRect((arx2 - width), ary1, width, height);
|
||||||
break;
|
break;
|
||||||
case SpawnPos::DOWN | SpawnPos::LEFT:
|
case SpawnPos::DOWN | SpawnPos::LEFT:
|
||||||
return QRect(arx1, (ary2-440), windowWidth, 440);
|
return QRect(arx1, (ary2-height), width, height);
|
||||||
break;
|
break;
|
||||||
case SpawnPos::DOWN | SpawnPos::RIGHT:
|
case SpawnPos::DOWN | SpawnPos::RIGHT:
|
||||||
return QRect((arx2 - windowWidth), (ary2-440), windowWidth, 440);
|
return QRect((arx2 - width), (ary2-height), windowWidth, height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return QRect(500, 400, windowWidth, 440);
|
return QRect(500, 400, width, height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::calculateChildWidgetsSize() {
|
||||||
|
//We need dynamically added child widgets to expand so that we know their height
|
||||||
|
//TODO: MenuBar height
|
||||||
|
this->setAttribute(Qt::WA_DontShowOnScreen, true);
|
||||||
|
this->show();
|
||||||
|
this->layout()->invalidate();
|
||||||
|
this->hide();
|
||||||
|
this->setAttribute(Qt::WA_DontShowOnScreen, false);
|
||||||
|
|
||||||
|
int height = 0, width = 0;
|
||||||
|
for (auto *epw : this->ews) {
|
||||||
|
height += epw->height();
|
||||||
|
width = (epw->width() > width) ? epw->width() : width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Establishing initial window size and position
|
||||||
|
*/
|
||||||
|
//TODO: test. hardcode. var.
|
||||||
|
setGeometry(setSizePosition(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent) : QWidget(parent){
|
SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent) : 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
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
this->sh = sh;
|
this->sh = sh;
|
||||||
|
|
||||||
layout = new QHBoxLayout(this);
|
widgetLayout = new QHBoxLayout(this);
|
||||||
//layout->setSizeConstraint(QLayout::SetFixedSize);
|
//widgetLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
widgetLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
//layout->setMaximumSize(minimumSize());
|
//widgetLayout->setMaximumSize(minimumSize());
|
||||||
//this->setLayout(
|
//this->setLayout(
|
||||||
|
|
||||||
muteButton = new QCheckBox(this);
|
muteButton = new QCheckBox(this);
|
||||||
|
|
@ -103,12 +125,12 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
||||||
*
|
*
|
||||||
* layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
* layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
*/
|
*/
|
||||||
layout->addItem(new QSpacerItem(200, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
widgetLayout->addItem(new QSpacerItem(200, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||||
layout->addWidget(mainLabel, Qt::AlignLeft | Qt::AlignBottom);
|
widgetLayout->addWidget(mainLabel, Qt::AlignLeft | Qt::AlignBottom);
|
||||||
layout->addWidget(muteButton, Qt::AlignRight | Qt::AlignBottom);
|
widgetLayout->addWidget(muteButton, Qt::AlignRight | Qt::AlignBottom);
|
||||||
layout->addWidget(mainSlider, Qt::AlignRight | Qt::AlignBottom);
|
widgetLayout->addWidget(mainSlider, Qt::AlignRight | Qt::AlignBottom);
|
||||||
|
|
||||||
//layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
//widgetLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
|
|
||||||
//TODO:0 = mute and muted, change volume = unmuted are client side tricks = 2 callbacks, one for volume, one for mute state. Implement as an user selectable option?
|
//TODO:0 = mute and muted, change volume = unmuted are client side tricks = 2 callbacks, one for volume, one for mute state. Implement as an user selectable option?
|
||||||
connect<void(QSlider::*)(int), void(SessionWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&SessionWidget::updateMainVolume);
|
connect<void(QSlider::*)(int), void(SessionWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&SessionWidget::updateMainVolume);
|
||||||
|
|
@ -157,7 +179,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;
|
||||||
layout = new QGridLayout(this);
|
widgetLayout = new QGridLayout(this);
|
||||||
float volume = 100;
|
float volume = 100;
|
||||||
/*
|
/*
|
||||||
* Channel sliders setup
|
* Channel sliders setup
|
||||||
|
|
@ -176,8 +198,8 @@ ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidge
|
||||||
tmpLb->setText(QString::number(volume));
|
tmpLb->setText(QString::number(volume));
|
||||||
this->channelSliders.push_back(tmp);
|
this->channelSliders.push_back(tmp);
|
||||||
this->channelLabels.push_back(tmpLb);
|
this->channelLabels.push_back(tmpLb);
|
||||||
layout->addWidget(tmp, 0, i);
|
widgetLayout->addWidget(tmp, 0, i);
|
||||||
layout->addWidget(tmpLb, 1, i);
|
widgetLayout->addWidget(tmpLb, 1, i);
|
||||||
|
|
||||||
//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.
|
||||||
|
|
@ -186,7 +208,7 @@ ChannelWidget::ChannelWidget(uint32_t channelCount, EndpointHandler* eph, QWidge
|
||||||
this->channelLabels.at(i)->setText(QString::number(newValue));
|
this->channelLabels.at(i)->setText(QString::number(newValue));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this->setLayout(layout);
|
this->setLayout(widgetLayout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,9 +228,9 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, idx);
|
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, idx);
|
||||||
|
|
||||||
//setAttribute(Qt::WA_TranslucentBackground);
|
//setAttribute(Qt::WA_TranslucentBackground);
|
||||||
layout = new QGridLayout(this);
|
widgetLayout = new QGridLayout(this);
|
||||||
//this->setLayout(layout);
|
//this->setLayout(widgetLayout);
|
||||||
log_debugcpp("epw main layout parent: " + std::to_string((intptr_t)(layout->parent())));
|
log_debugcpp("epw main layout parent: " + std::to_string((intptr_t)(widgetLayout->parent())));
|
||||||
if (parent == nullptr) { log_debugcpp("ayooooo?"); }
|
if (parent == nullptr) { log_debugcpp("ayooooo?"); }
|
||||||
|
|
||||||
defaultRolesCheckBoxes = {
|
defaultRolesCheckBoxes = {
|
||||||
|
|
@ -226,8 +248,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
mainSlider = new QSlider(Qt::Horizontal, this);
|
mainSlider = new QSlider(Qt::Horizontal, this);
|
||||||
|
|
||||||
if (this->eph->getState() != EndpointState::ENDPOINT_ACTIVE) {
|
if (this->eph->getState() != EndpointState::ENDPOINT_ACTIVE) {
|
||||||
layout->addWidget(mainLabel, row, 0);
|
widgetLayout->addWidget(mainLabel, row, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
widgetLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,10 +273,10 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
|
|
||||||
//tip: would need to be new widget with layout in it
|
//tip: would need to be new widget with layout in it
|
||||||
//mainMuteLayout = new QGridLayout();
|
//mainMuteLayout = new QGridLayout();
|
||||||
layout->addWidget(mainLabel, row, 0, Qt::AlignLeft | Qt::AlignVCenter);
|
widgetLayout->addWidget(mainLabel, row, 0, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
layout->addWidget(muteButton, row, 1, Qt::AlignLeft | Qt::AlignVCenter);
|
widgetLayout->addWidget(muteButton, row, 1, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
layout->addWidget(mainSlider, row, 2, 1, 2, Qt::AlignLeft | Qt::AlignVCenter);
|
widgetLayout->addWidget(mainSlider, row, 2, 1, 2, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
widgetLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
//int debug2 = this->minimumWidth();
|
//int debug2 = this->minimumWidth();
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
|
@ -270,7 +292,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
uint32_t epChannelCount = eph->getChannelCount();
|
uint32_t epChannelCount = eph->getChannelCount();
|
||||||
if(epChannelCount) {
|
if(epChannelCount) {
|
||||||
cw = new ChannelWidget(epChannelCount, eph, this);
|
cw = new ChannelWidget(epChannelCount, eph, this);
|
||||||
layout->addWidget(cw, row++, 0, 1, 4 /*colmax*/);
|
widgetLayout->addWidget(cw, row++, 0, 1, 4 /*colmax*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -309,10 +331,10 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
this->eph->setRoles(Roles::ROLE_COMMUNICATIONS);
|
this->eph->setRoles(Roles::ROLE_COMMUNICATIONS);
|
||||||
});
|
});
|
||||||
|
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), row, 0);
|
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), row, 0);
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), row, 1);
|
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), row, 1);
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), row, 2);
|
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), row, 2);
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), row, 3);
|
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), row, 3);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
/* ----------------------------------------------------------- */
|
/* ----------------------------------------------------------- */
|
||||||
|
|
@ -347,7 +369,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
/* First SessionWidget batch */
|
/* First SessionWidget batch */
|
||||||
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
||||||
SessionWidget* sessionWidget = new SessionWidget(i, eph->getSessionHandlers().at(i), this);
|
SessionWidget* sessionWidget = new SessionWidget(i, eph->getSessionHandlers().at(i), this);
|
||||||
layout->addWidget(sessionWidget, row, 0, 1, 4);
|
widgetLayout->addWidget(sessionWidget, row, 0, 1, 4);
|
||||||
row++;
|
row++;
|
||||||
sessionWidgets.push_back(sessionWidget);
|
sessionWidgets.push_back(sessionWidget);
|
||||||
eph->getSessionHandlers().at(i)->setFrontIndex(i);
|
eph->getSessionHandlers().at(i)->setFrontIndex(i);
|
||||||
|
|
@ -363,10 +385,10 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
});
|
});
|
||||||
|
|
||||||
//todo parent?
|
//todo parent?
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
widgetLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 4, 0);
|
widgetLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 4, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 6, 0);
|
widgetLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 6, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 6, 1);
|
widgetLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 6, 1);
|
||||||
log_debugcpp("ENDPOINT_WIDGETED");
|
log_debugcpp("ENDPOINT_WIDGETED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -374,7 +396,7 @@ void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
||||||
uint64_t index = this->sessionWidgets.size();
|
uint64_t index = this->sessionWidgets.size();
|
||||||
SessionWidget* sw = new SessionWidget(index, ev->payload, this);
|
SessionWidget* sw = new SessionWidget(index, ev->payload, this);
|
||||||
ev->payload->setFrontIndex(index);
|
ev->payload->setFrontIndex(index);
|
||||||
this->layout->addWidget(sw, row, 0, 1, 4);
|
this->widgetLayout->addWidget(sw, row, 0, 1, 4);
|
||||||
row++;
|
row++;
|
||||||
sessionWidgets.push_back(sw);
|
sessionWidgets.push_back(sw);
|
||||||
return;
|
return;
|
||||||
|
|
@ -383,7 +405,7 @@ void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
||||||
void EndpointWidget::removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
void EndpointWidget::removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
||||||
uint64_t i = ev->payload->getFrontIndex();
|
uint64_t i = ev->payload->getFrontIndex();
|
||||||
this->sessionWidgets.at(i)->setParent(nullptr);
|
this->sessionWidgets.at(i)->setParent(nullptr);
|
||||||
this->layout->removeWidget(sessionWidgets.at(i));
|
this->widgetLayout->removeWidget(sessionWidgets.at(i));
|
||||||
delete sessionWidgets.at(i);
|
delete sessionWidgets.at(i);
|
||||||
sessionWidgets.at(i) = nullptr;
|
sessionWidgets.at(i) = nullptr;
|
||||||
ev->payload->setFrontIndex(INT_MAX);
|
ev->payload->setFrontIndex(INT_MAX);
|
||||||
|
|
@ -423,7 +445,7 @@ void MainWindow::customEvent(QEvent* ev) {
|
||||||
void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
||||||
uint64_t i = ev->payload;
|
uint64_t i = ev->payload;
|
||||||
this->ews.at(i)->setParent(nullptr);
|
this->ews.at(i)->setParent(nullptr);
|
||||||
this->layout->removeWidget(ews.at(i));
|
this->widgetLayout->removeWidget(ews.at(i));
|
||||||
//uint64_t saisu = ews.size();
|
//uint64_t saisu = ews.size();
|
||||||
//delete ews.at(index);
|
//delete ews.at(index);
|
||||||
delete ews.at(i);
|
delete ews.at(i);
|
||||||
|
|
@ -434,7 +456,7 @@ void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
||||||
|
|
||||||
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
||||||
EndpointWidget* epw = new EndpointWidget(this->ews.size(), ev->payload, widget);
|
EndpointWidget* epw = new EndpointWidget(this->ews.size(), ev->payload, widget);
|
||||||
this->layout->addWidget(epw);
|
this->widgetLayout->addWidget(epw);
|
||||||
ews.push_back(epw);
|
ews.push_back(epw);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -533,7 +555,7 @@ std::map<Roles, ExtendedCheckBox*> EndpointWidget::getDefaultRolesWidgets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
||||||
layout = new QGridLayout(this);
|
widgetLayout = new QGridLayout(this);
|
||||||
|
|
||||||
QString text = "&" STRING_ABOUT;
|
QString text = "&" STRING_ABOUT;
|
||||||
about = new QPushButton(text, this);
|
about = new QPushButton(text, this);
|
||||||
|
|
@ -544,18 +566,18 @@ HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
||||||
text = "&" STRING_STARTUP;
|
text = "&" STRING_STARTUP;
|
||||||
startup = new QPushButton(text, this);
|
startup = new QPushButton(text, this);
|
||||||
|
|
||||||
layout->addWidget(openCP , 0, 0);
|
widgetLayout->addWidget(openCP , 0, 0);
|
||||||
layout->addWidget(startup, 0, 1);
|
widgetLayout->addWidget(startup, 0, 1);
|
||||||
#endif
|
#endif
|
||||||
layout->addWidget(about , 0, 2);
|
widgetLayout->addWidget(about , 0, 2);
|
||||||
this->setLayout(layout);
|
this->setLayout(widgetLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
// setWindowState(Qt::WindowFullScreen);
|
//setWindowState(Qt::WindowFullScreen);
|
||||||
// setCentralWidget(centralWidget);
|
//setCentralWidget(centralWidget);
|
||||||
//todo: ratio
|
//todo: ratio
|
||||||
resize(windowWidth, 440);
|
//resize(windowWidth, 440);
|
||||||
setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint);
|
setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
setWindowTitle(STRING_TITLE);
|
setWindowTitle(STRING_TITLE);
|
||||||
|
|
@ -577,7 +599,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
//setAttribute(Qt::WA_TranslucentBackground, true);
|
//setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
ewsUpdateTimer = new QTimer(this);
|
ewsUpdateTimer = new QTimer(this);
|
||||||
widget = new QWidget();
|
widget = new QWidget();
|
||||||
layout = new QGridLayout();
|
widgetLayout = new QGridLayout();
|
||||||
trayIcon = new QSystemTrayIcon();
|
trayIcon = new QSystemTrayIcon();
|
||||||
trayIconMenu = new QMenu();
|
trayIconMenu = new QMenu();
|
||||||
trayIconMenuQuit = new QAction(STRING_QUIT);
|
trayIconMenuQuit = new QAction(STRING_QUIT);
|
||||||
|
|
@ -587,7 +609,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
ewsUpdateTimer->setInterval(ewsUpdateTimerFrequency);
|
ewsUpdateTimer->setInterval(ewsUpdateTimerFrequency);
|
||||||
connect(ewsUpdateTimer, &QTimer::timeout, this, &MainWindow::reorderEndpointWidgetCollection);
|
connect(ewsUpdateTimer, &QTimer::timeout, this, &MainWindow::reorderEndpointWidgetCollection);
|
||||||
//widget->setMinimumSize(QSize(300,300));
|
//widget->setMinimumSize(QSize(300,300));
|
||||||
widget->setLayout(layout);
|
widget->setLayout(widgetLayout);
|
||||||
/*
|
/*
|
||||||
* Scroll bar code
|
* Scroll bar code
|
||||||
*/
|
*/
|
||||||
|
|
@ -595,6 +617,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
scrollArea->setWidget(widget);
|
scrollArea->setWidget(widget);
|
||||||
scrollArea->setWidgetResizable(true);
|
scrollArea->setWidgetResizable(true);
|
||||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
|
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
scrollArea->setStyleSheet("QScrollBar:vertical { width: 4px; }");
|
||||||
scrollArea->setMinimumWidth(500);
|
scrollArea->setMinimumWidth(500);
|
||||||
setCentralWidget(scrollArea);
|
setCentralWidget(scrollArea);
|
||||||
|
|
||||||
|
|
@ -608,12 +632,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
this->setMenuBar(mainMenuBar);
|
this->setMenuBar(mainMenuBar);
|
||||||
|
|
||||||
//setCentralWidget(widget);
|
//setCentralWidget(widget);
|
||||||
//layout->addWidget(pintas, 0, 0);
|
//widgetLayout->addWidget(pintas, 0, 0);
|
||||||
|
|
||||||
reloadEndpointWidgets();
|
reloadEndpointWidgets();
|
||||||
scrollArea->setMinimumWidth(ews.at(0)->minimumWidth());
|
//scrollArea->setMinimumWidth(ews.at(0)->minimumWidth());
|
||||||
log_debugcpp(std::to_string(scrollArea->minimumWidth()));
|
log_debugcpp(std::to_string(scrollArea->minimumWidth()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tray Icon code
|
* Tray Icon code
|
||||||
*/
|
*/
|
||||||
|
|
@ -631,12 +655,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
trayIcon->setToolTip(STRING_TITLE);
|
trayIcon->setToolTip(STRING_TITLE);
|
||||||
trayIcon->setContextMenu(trayIconMenu);
|
trayIcon->setContextMenu(trayIconMenu);
|
||||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
|
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
|
||||||
|
|
||||||
/*
|
|
||||||
* Establishing initial window size and position
|
|
||||||
*/
|
|
||||||
//TODO: test. hardcode. var.
|
|
||||||
setGeometry(setSizePosition());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set of function callback definitons for EndpointSituationCallback
|
* Set of function callback definitons for EndpointSituationCallback
|
||||||
|
|
@ -695,15 +713,16 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
if (trayIcon->isVisible()) {
|
if (trayIcon->isVisible()) {
|
||||||
//todo: would be nice to show this to 1st time users; ini-san will come...
|
//todo: would be nice to show this to 1st time users; ini-san will come...
|
||||||
//this->trayIcon->showMessage("ini file calling","tratarte como un gilipollas la primera vez", QSystemTrayIcon::Information);
|
//this->trayIcon->showMessage("ini file calling","tratarte como un gilipollas la primera vez", QSystemTrayIcon::Information);
|
||||||
hide();
|
|
||||||
event->ignore();
|
hide();
|
||||||
|
event->ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
this->setGeometry(this->setSizePosition());
|
this->calculateChildWidgetsSize();
|
||||||
this->showNormal();
|
this->showNormal();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -721,10 +740,10 @@ void MainWindow::reloadEndpointWidgets() {
|
||||||
epwIndex++;
|
epwIndex++;
|
||||||
//alfinal estoes solopara inicializarlmao
|
//alfinal estoes solopara inicializarlmao
|
||||||
ews.push_back(epw);
|
ews.push_back(epw);
|
||||||
layout->addWidget(epw, i, 0);
|
widgetLayout->addWidget(epw, i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//todo:: tas aqui tirao, no me gustas y probablemente yo a ti tampoco
|
//todo:: tas aqui tirao, no me gustas y probablemente yo a ti tampoco
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
|
widgetLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
//#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
//#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
@ -38,31 +38,6 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "contclasses.h"
|
#include "contclasses.h"
|
||||||
//class EndpointHandler;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* class ToggleButton : public QAbstractButton {
|
|
||||||
* Q_OBJECT
|
|
||||||
*
|
|
||||||
* public:
|
|
||||||
* ToggleButton(QWidget *parent = nullptr);
|
|
||||||
* void checkStateSet();
|
|
||||||
* bool hitButton(const QPoint &pos) const;
|
|
||||||
* void nextCheckState();
|
|
||||||
* void changeEvent(QEvent *e) override;
|
|
||||||
* bool event(QEvent *e) override;
|
|
||||||
* void focusInEvent(QFocusEvent *e) override;
|
|
||||||
* void focusOutEvent(QFocusEvent *e) override;
|
|
||||||
* void keyPressEvent(QKeyEvent *e) override;
|
|
||||||
* void keyReleaseEvent(QKeyEvent *e) override;
|
|
||||||
* void mouseMoveEvent(QMouseEvent *e) override;
|
|
||||||
* void mousePressEvent(QMouseEvent *e) override;
|
|
||||||
* void mouseReleaseEvent(QMouseEvent *e) override;
|
|
||||||
* void paintEvent(QPaintEvent *e) override = 0;
|
|
||||||
* void timerEvent(QTimerEvent *e) override;
|
|
||||||
* ToggleButton(QWidget *parent = nullptr);
|
|
||||||
* };
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum SpawnPos {
|
enum SpawnPos {
|
||||||
LEFT = (1 << 1),
|
LEFT = (1 << 1),
|
||||||
|
|
@ -117,8 +92,7 @@ private:
|
||||||
QLabel *mainLabel = nullptr;
|
QLabel *mainLabel = nullptr;
|
||||||
QSlider *mainSlider = nullptr;
|
QSlider *mainSlider = nullptr;
|
||||||
uint64_t idx;
|
uint64_t idx;
|
||||||
//QGridLayout *layout = nullptr;
|
QHBoxLayout *widgetLayout = nullptr;
|
||||||
QHBoxLayout *layout = nullptr;
|
|
||||||
QCheckBox *muteButton = nullptr;
|
QCheckBox *muteButton = nullptr;
|
||||||
SessionHandler* sh;
|
SessionHandler* sh;
|
||||||
QTimer* volumePoller = nullptr;
|
QTimer* volumePoller = nullptr;
|
||||||
|
|
@ -137,7 +111,7 @@ private:
|
||||||
uint32_t channelCount;
|
uint32_t channelCount;
|
||||||
std::vector<QSlider*> channelSliders;
|
std::vector<QSlider*> channelSliders;
|
||||||
std::vector<QLabel*> channelLabels;
|
std::vector<QLabel*> channelLabels;
|
||||||
QGridLayout *layout;
|
QGridLayout *widgetLayout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -181,7 +155,7 @@ private:
|
||||||
QSlider *mainSlider = nullptr;
|
QSlider *mainSlider = nullptr;
|
||||||
std::vector<QSlider*> channelSliders;
|
std::vector<QSlider*> channelSliders;
|
||||||
std::vector<QLabel*> channelLabels;
|
std::vector<QLabel*> channelLabels;
|
||||||
QGridLayout *layout = nullptr;
|
QGridLayout *widgetLayout = nullptr;
|
||||||
QGridLayout *mainMuteLayout = nullptr;
|
QGridLayout *mainMuteLayout = nullptr;
|
||||||
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
||||||
|
|
||||||
|
|
@ -205,25 +179,8 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
HeaderWidget(QWidget *parent = nullptr);
|
HeaderWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//~HeaderWidget();
|
|
||||||
//void updateMainVolume(float newValue);
|
|
||||||
//void updateVolume(uint32_t channel, float newValue);
|
|
||||||
//void updateMute(bool muted);
|
|
||||||
|
|
||||||
//void populateEndpointWidget(EndpointHandler *eph);
|
|
||||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
|
||||||
|
|
||||||
//public slots:
|
|
||||||
|
|
||||||
//protected:
|
|
||||||
//void customEvent(QEvent* ev) override;
|
|
||||||
|
|
||||||
//private slots:
|
|
||||||
//void addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev);
|
|
||||||
//void removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGridLayout *layout;
|
QGridLayout *widgetLayout;
|
||||||
QPushButton *about;
|
QPushButton *about;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
QPushButton *openCP;
|
QPushButton *openCP;
|
||||||
|
|
@ -238,11 +195,12 @@ class MainWindow : public QMainWindow {
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
void reloadEndpointWidgets();
|
void reloadEndpointWidgets();
|
||||||
|
void calculateChildWidgetsSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
void customEvent(QEvent* ev) override;
|
void customEvent(QEvent* ev) override;
|
||||||
QRect setSizePosition();
|
QRect setSizePosition(int width, int height);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
|
|
@ -256,7 +214,7 @@ private:
|
||||||
//std::vector<EndpointHandler*> *ephs;
|
//std::vector<EndpointHandler*> *ephs;
|
||||||
std::vector<EndpointWidget*> ews;
|
std::vector<EndpointWidget*> ews;
|
||||||
QWidget *widget;
|
QWidget *widget;
|
||||||
QGridLayout *layout;
|
QGridLayout *widgetLayout;
|
||||||
|
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
QMenu *trayIconMenu;
|
QMenu *trayIconMenu;
|
||||||
|
|
@ -283,4 +241,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
//#endif
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,10 @@ int main (int argc, char* argv[]) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//app->setStyleSheet(styleSheet);
|
//app->setStyleSheet(styleSheet);
|
||||||
//window.setMinimumSize(100, 100);
|
window.calculateChildWidgetsSize();
|
||||||
|
#ifdef DEBUG
|
||||||
window.show();
|
window.show();
|
||||||
|
#endif
|
||||||
return app->exec();
|
return app->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue