wip: customize scroll bar

This commit is contained in:
Hane 2024-05-30 22:36:35 +02:00
commit 313a26c8e3
3 changed files with 448 additions and 48 deletions

View file

@ -250,6 +250,8 @@ void MainWindow::compose() {
log_debugcpp("Window Width: " + std::to_string(windowWidth));
this->createLayout(new QGridLayout());
//scrollArea->verticalScrollBar()->setMinimumWidth(windowWidth * (widthRatio));
//scrollArea->verticalScrollBar()->setMaximumWidth(windowWidth * (widthRatio));
/*
* this->setAttribute(Qt::WA_DontShowOnScreen, true);
* this->show();
@ -257,10 +259,11 @@ void MainWindow::compose() {
* this->hide();
* this->setAttribute(Qt::WA_DontShowOnScreen, false);
*/
const qreal dpr = screen->devicePixelRatio();
log_to_file("dpr: %f \n", dpr);
for (auto *epw : ews) {
if (!epw) continue;
epw->calculateSize(windowWidth, screenHeight);
epw->calculateSize(windowWidth * dpr,screenHeight * screen->devicePixelRatio());
log_debugcpp("epw loop");
log_debugcpp("epw roles: " + print_as_binary((epw->getEndpointHandler()->getRoles())));
//std::bitset<sizeof(uint8_t)> content =
@ -277,8 +280,8 @@ void MainWindow::compose() {
if (!ews[i]) continue;
ews[i]->layout()->getContentsMargins(&left, &top, &right, &bottom);
windowHeight += ews[i]->sizeHint().height();
windowHeight += top;
windowHeight += bottom;
windowHeight += top * 3;
//windowHeight += bottom;
log_debugcpp("windowHeight loop: " + std::to_string(windowHeight));
}
windowHeight += mainMenuBar->sizeHint().height();
@ -941,13 +944,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
scrollArea = new QScrollArea(this);
scrollArea->setWidget(widget);
scrollArea->setWidgetResizable(true);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setContentsMargins(QMargins(0, 0, 0, 0));
//scrollArea->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
//scrollArea->verticalScrollBar()->setSingleStep(1);
//custom style = no qss
//scrollArea->setStyleSheet("QScrollBar:vertical { width: 4px; }");
//scrollArea->setMinimumWidth(500);
setCentralWidget(scrollArea);
/*