initial window scaling
This commit is contained in:
parent
e4732d086b
commit
5229154c45
2 changed files with 70 additions and 23 deletions
|
|
@ -25,15 +25,13 @@ void ExtendedCheckBox::customEvent(QEvent* ev) {
|
||||||
QCheckBox::customEvent(ev);
|
QCheckBox::customEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect MainWindow::setSizePosition(int width, int height) {
|
QRect MainWindow::setSizePosition(QScreen* screen, int width, int height) {
|
||||||
//setGeometry ignores decoration size, theres others for that
|
//setGeometry ignores decoration size, theres others for that
|
||||||
QRect trayIconPos = this->trayIcon->geometry();
|
QRect trayIconPos = this->trayIcon->geometry();
|
||||||
int tix1, tix2, tiy1, tiy2;
|
int tix1, tix2, tiy1, tiy2;
|
||||||
trayIconPos.getCoords(&tix1, &tiy1, &tix2, &tiy2);
|
trayIconPos.getCoords(&tix1, &tiy1, &tix2, &tiy2);
|
||||||
log_debugcpp("Tray Icon Pos: " + std::to_string(tix1) + " " + std::to_string(tix2)+" " + std::to_string(tiy1) + " " + std::to_string(tiy2));
|
log_debugcpp("Tray Icon Pos: " + std::to_string(tix1) + " " + std::to_string(tix2)+" " + std::to_string(tiy1) + " " + std::to_string(tiy2));
|
||||||
|
|
||||||
screen = this->getCurrentScreen();
|
|
||||||
log_debugcpp("Screen: " + screen->model().toStdString() + " " + screen->name().toStdString());
|
|
||||||
this->setScreen(screen);
|
this->setScreen(screen);
|
||||||
|
|
||||||
QRect screenRes = screen->geometry();
|
QRect screenRes = screen->geometry();
|
||||||
|
|
@ -60,15 +58,19 @@ QRect MainWindow::setSizePosition(int width, int height) {
|
||||||
|
|
||||||
switch (pos) {
|
switch (pos) {
|
||||||
case SpawnPos::UP | SpawnPos::RIGHT:
|
case SpawnPos::UP | SpawnPos::RIGHT:
|
||||||
|
this->addToolBar(Qt::BottomToolBarArea, mainMenuBar);
|
||||||
return QRect((arx2 - width), ary1, width, height);
|
return QRect((arx2 - width), ary1, width, height);
|
||||||
break;
|
break;
|
||||||
case SpawnPos::DOWN | SpawnPos::LEFT:
|
case SpawnPos::DOWN | SpawnPos::LEFT:
|
||||||
|
this->addToolBar(Qt::TopToolBarArea, mainMenuBar);
|
||||||
return QRect(arx1, (ary2-height), width, height);
|
return QRect(arx1, (ary2-height), width, height);
|
||||||
break;
|
break;
|
||||||
case SpawnPos::DOWN | SpawnPos::RIGHT:
|
case SpawnPos::DOWN | SpawnPos::RIGHT:
|
||||||
|
this->addToolBar(Qt::TopToolBarArea, mainMenuBar);
|
||||||
return QRect((arx2 - width), (ary2-height), width, height);
|
return QRect((arx2 - width), (ary2-height), width, height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
this->addToolBar(Qt::BottomToolBarArea, mainMenuBar);
|
||||||
return QRect(500, 400, width, height);
|
return QRect(500, 400, width, height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -76,27 +78,49 @@ QRect MainWindow::setSizePosition(int width, int height) {
|
||||||
|
|
||||||
void MainWindow::calculateChildWidgetsSize() {
|
void MainWindow::calculateChildWidgetsSize() {
|
||||||
//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
|
||||||
//TODO: more heights
|
screen = this->getCurrentScreen();
|
||||||
|
log_debugcpp("Screen: " + screen->model().toStdString() + " " + screen->name().toStdString());
|
||||||
|
QRect screenRes = screen->geometry();
|
||||||
|
int srx1, srx2, sry1, sry2;
|
||||||
|
screenRes.getCoords(&srx1, &sry1, &srx2, &sry2);
|
||||||
|
log_debugcpp("(for Percentage) Screen Res: " + std::to_string(srx1) + " " + std::to_string(srx2)+" " + std::to_string(sry1) + " " + std::to_string(sry2));
|
||||||
|
|
||||||
|
width = (uint64_t)std::abs(srx2) * this->widthRatio;
|
||||||
|
log_debugcpp("Window Width: " + std::to_string(width));
|
||||||
|
for (auto *ew : ews) {
|
||||||
|
ew->setWidth(width, widthRatio);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* sessionwidget: mainLabel, mainSlider, muteButton
|
||||||
|
* endpointwidget: mainLabel
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
this->setAttribute(Qt::WA_DontShowOnScreen, true);
|
this->setAttribute(Qt::WA_DontShowOnScreen, true);
|
||||||
this->show();
|
this->show();
|
||||||
this->layout()->invalidate();
|
this->layout()->invalidate();
|
||||||
this->hide();
|
this->hide();
|
||||||
this->setAttribute(Qt::WA_DontShowOnScreen, false);
|
this->setAttribute(Qt::WA_DontShowOnScreen, false);
|
||||||
|
|
||||||
int height = 0, width = 0;
|
int height = 0;
|
||||||
for (auto *epw : this->ews) {
|
for (auto *epw : this->ews) {
|
||||||
height += epw->height();
|
height += epw->height();
|
||||||
//width = (epw->width() > width) ? epw->width() : width;
|
//width = (epw->width() > width) ? epw->width() : width;
|
||||||
}
|
}
|
||||||
width = scrollArea->width();
|
//width = scrollArea->width();
|
||||||
height += mainMenuBar->height();
|
height += mainMenuBar->height();
|
||||||
height += hw->height();
|
height += hw->height();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Establishing initial window size and position
|
* Establishing initial window size and position
|
||||||
*/
|
*/
|
||||||
//TODO: test. hardcode. var.
|
setGeometry(setSizePosition(screen, width, height));
|
||||||
setGeometry(setSizePosition(width, height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QScreen* MainWindow::getCurrentScreen() {
|
QScreen* MainWindow::getCurrentScreen() {
|
||||||
|
|
@ -114,7 +138,7 @@ QScreen* MainWindow::getCurrentScreen() {
|
||||||
return QGuiApplication::primaryScreen();
|
return QGuiApplication::primaryScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent) : QWidget(parent){
|
SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent) : QWidget(parent), widthSpacer(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum){
|
||||||
//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;
|
||||||
|
|
@ -129,12 +153,12 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
||||||
mainLabel = new QLabel(QString::fromStdWString(sh->getName()), this);
|
mainLabel = new QLabel(QString::fromStdWString(sh->getName()), this);
|
||||||
mainSlider = new QSlider(Qt::Horizontal, this);
|
mainSlider = new QSlider(Qt::Horizontal, this);
|
||||||
|
|
||||||
mainLabel->setMaximumWidth(150 /*1/16ish 1080p*/);
|
//mainLabel->setMaximumWidth(150 /*1/16ish 1080p*/);
|
||||||
mainLabel->setMinimumWidth(150 /*1/16ish 1080p*/);
|
//mainLabel->setMinimumWidth(150 /*1/16ish 1080p*/);
|
||||||
mainLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
mainLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
|
||||||
mainSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
mainSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
mainSlider->setMinimumWidth(120 /*1/16 1080p*/);
|
//mainSlider->setMinimumWidth(120 /*1/16 1080p*/);
|
||||||
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
||||||
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||||
mainSlider->setTickInterval(5);
|
mainSlider->setTickInterval(5);
|
||||||
|
|
@ -143,8 +167,8 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
||||||
|
|
||||||
muteButton->setCheckState((sh->getMute() == false ? Qt::Unchecked : Qt::Checked));
|
muteButton->setCheckState((sh->getMute() == false ? Qt::Unchecked : Qt::Checked));
|
||||||
muteButton->setText(sh->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
muteButton->setText(sh->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||||
muteButton->setMaximumWidth(60 /*1/32th 1080p*/);
|
//muteButton->setMaximumWidth(60 /*1/32th 1080p*/);
|
||||||
muteButton->setMinimumWidth(60 /*1/32th 1080p*/);
|
//muteButton->setMinimumWidth(60 /*1/32th 1080p*/);
|
||||||
float volume = sh->getVolume(AudioChannel::CHANNEL_MAIN) * 100;
|
float volume = sh->getVolume(AudioChannel::CHANNEL_MAIN) * 100;
|
||||||
mainSlider->setValue((int)volume);
|
mainSlider->setValue((int)volume);
|
||||||
log_debugcpp("SESSION SET WITH VOLUME " + std::to_string(volume));
|
log_debugcpp("SESSION SET WITH VOLUME " + std::to_string(volume));
|
||||||
|
|
@ -158,7 +182,7 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
||||||
*
|
*
|
||||||
* layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
* layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
*/
|
*/
|
||||||
widgetLayout->addItem(new QSpacerItem(200, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
widgetLayout->addItem(&widthSpacer);
|
||||||
widgetLayout->addWidget(mainLabel, Qt::AlignLeft | Qt::AlignBottom);
|
widgetLayout->addWidget(mainLabel, Qt::AlignLeft | Qt::AlignBottom);
|
||||||
widgetLayout->addWidget(muteButton, Qt::AlignRight | Qt::AlignBottom);
|
widgetLayout->addWidget(muteButton, Qt::AlignRight | Qt::AlignBottom);
|
||||||
widgetLayout->addWidget(mainSlider, Qt::AlignRight | Qt::AlignBottom);
|
widgetLayout->addWidget(mainSlider, Qt::AlignRight | Qt::AlignBottom);
|
||||||
|
|
@ -194,6 +218,16 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
||||||
volumePoller->start(10);
|
volumePoller->start(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionWidget::setWidth(uint64_t width, double widthRatio) {
|
||||||
|
/* og 1080p 120% testing values */
|
||||||
|
this->mainLabel->setMaximumWidth((int)(width * 0.30) /*1/16ish 1080p*/);
|
||||||
|
this->mainLabel->setMinimumWidth((int)(width * 0.30) /*1/16ish 1080p*/);
|
||||||
|
this->muteButton->setMaximumWidth((int)(width * 0.10) /*1/32th 1080p*/);
|
||||||
|
this->muteButton->setMinimumWidth((int)(width * 0.10) /*1/32th 1080p*/);
|
||||||
|
this->mainSlider->setMinimumWidth((int)(width * 0.30) /*1/16 1080p*/);
|
||||||
|
widthSpacer.changeSize((int)width * 0.20, 1, QSizePolicy::Expanding, QSizePolicy::Minimum /*200*/);
|
||||||
|
}
|
||||||
|
|
||||||
void SessionWidget::updateMute(int checked){
|
void SessionWidget::updateMute(int checked){
|
||||||
bool muted = (checked == 2 ? true : false);
|
bool muted = (checked == 2 ? true : false);
|
||||||
this->sh->setMute(osh->getGuid(), muted);
|
this->sh->setMute(osh->getGuid(), muted);
|
||||||
|
|
@ -294,8 +328,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mainLabel->setMaximumWidth(350 /* 1080p 120%*/);
|
//mainLabel->setMaximumWidth(350 /* 1080p 120%*/);
|
||||||
mainLabel->setMinimumWidth(350 /* 1080p 120%*/);
|
//mainLabel->setMinimumWidth(350 /* 1080p 120%*/);
|
||||||
mainLabel->setWordWrap(true);
|
mainLabel->setWordWrap(true);
|
||||||
mainLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
mainLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
||||||
//mainLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
//mainLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
|
@ -316,7 +350,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
log_debugcpp("ENDPOINT SET WITH VOLUME " + std::to_string(volume));
|
log_debugcpp("ENDPOINT SET WITH VOLUME " + std::to_string(volume));
|
||||||
|
|
||||||
//mainMuteLayout = new QGridLayout();
|
//mainMuteLayout = new QGridLayout();
|
||||||
widgetLayout->addWidget(mainLabel, row, 0, 1, 3, Qt::AlignLeft | Qt::AlignVCenter);
|
widgetLayout->addWidget(mainLabel, row, 0, 1, 2, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
widgetLayout->addWidget(muteButton, row, 2, Qt::AlignRight | Qt::AlignVCenter);
|
widgetLayout->addWidget(muteButton, row, 2, Qt::AlignRight | Qt::AlignVCenter);
|
||||||
widgetLayout->addWidget(mainVolumeLabel, row, 3, Qt::AlignRight | Qt::AlignVCenter);
|
widgetLayout->addWidget(mainVolumeLabel, row, 3, Qt::AlignRight | Qt::AlignVCenter);
|
||||||
row++;
|
row++;
|
||||||
|
|
@ -515,6 +549,15 @@ void MainWindow::reorderEndpointWidgetCollection() {
|
||||||
ews.resize(firstNullPosition + 1);
|
ews.resize(firstNullPosition + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EndpointWidget::setWidth(uint64_t width, double widthRatio) {
|
||||||
|
/* og 1080p 120% testing values */
|
||||||
|
this->mainLabel->setMaximumWidth((int)width * 0.35 /* 1080p 120%*/);
|
||||||
|
this->mainLabel->setMinimumWidth((int)width * 0.35 /* 1080p 120%*/);
|
||||||
|
for (auto sw : sessionWidgets){
|
||||||
|
sw->setWidth(width, widthRatio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EndpointWidget::updateMute(int checked){
|
void EndpointWidget::updateMute(int checked){
|
||||||
bool muted = (checked == 2 ? true : false);
|
bool muted = (checked == 2 ? true : false);
|
||||||
this->eph->setMute(osh->getGuid(), muted);
|
this->eph->setMute(osh->getGuid(), muted);
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
||||||
~SessionWidget();
|
~SessionWidget();
|
||||||
|
void setWidth(uint64_t width, double widthRatio);
|
||||||
public slots:
|
public slots:
|
||||||
void updateMainVolume(int newValue);
|
void updateMainVolume(int newValue);
|
||||||
void updateMute(int checked);
|
void updateMute(int checked);
|
||||||
|
|
@ -98,6 +98,8 @@ private:
|
||||||
QCheckBox *muteButton = nullptr;
|
QCheckBox *muteButton = nullptr;
|
||||||
SessionHandler* sh;
|
SessionHandler* sh;
|
||||||
QTimer* volumePoller = nullptr;
|
QTimer* volumePoller = nullptr;
|
||||||
|
|
||||||
|
QSpacerItem widthSpacer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChannelWidget : public QWidget {
|
class ChannelWidget : public QWidget {
|
||||||
|
|
@ -128,7 +130,8 @@ public:
|
||||||
|
|
||||||
void setIndex(uint64_t idx);
|
void setIndex(uint64_t idx);
|
||||||
uint64_t getIndex();
|
uint64_t getIndex();
|
||||||
void setVolume(int channel, float volume);
|
//void setVolume(int channel, float volume);
|
||||||
|
void setWidth(uint64_t width, double widthRatio);
|
||||||
|
|
||||||
~EndpointWidget();
|
~EndpointWidget();
|
||||||
//void updateMainVolume(float newValue);
|
//void updateMainVolume(float newValue);
|
||||||
|
|
@ -203,7 +206,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
void customEvent(QEvent* ev) override;
|
void customEvent(QEvent* ev) override;
|
||||||
QRect setSizePosition(int width, int height);
|
QRect setSizePosition(QScreen* screen, int width, int height);
|
||||||
QScreen* getCurrentScreen();
|
QScreen* getCurrentScreen();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
@ -228,7 +231,8 @@ private:
|
||||||
static constexpr uint64_t ewsUpdateTimerFrequency = 500;
|
static constexpr uint64_t ewsUpdateTimerFrequency = 500;
|
||||||
//TODO: Test
|
//TODO: Test
|
||||||
//TODO: Come back here and check all are parametrized
|
//TODO: Come back here and check all are parametrized
|
||||||
uint64_t windowWidth = 600;
|
double widthRatio = 0.28;
|
||||||
|
uint64_t width;
|
||||||
|
|
||||||
QScrollArea *scrollArea;
|
QScrollArea *scrollArea;
|
||||||
HeaderWidget* hw;
|
HeaderWidget* hw;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue