Use palette colors for resizable panel stylesheets. (#6782)

Took 7 minutes

Took 5 seconds

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-04-07 15:57:03 +02:00 committed by GitHub
parent 335022c4aa
commit 635fae101d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,7 +20,6 @@ ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWid
frame = new QFrame(this); frame = new QFrame(this);
frame->setFrameShape(QFrame::Box); frame->setFrameShape(QFrame::Box);
frame->setLineWidth(2); frame->setLineWidth(2);
frame->setStyleSheet("border: none;");
auto *frameLayout = new QVBoxLayout(frame); auto *frameLayout = new QVBoxLayout(frame);
frameLayout->setContentsMargins(0, 0, 0, 0); frameLayout->setContentsMargins(0, 0, 0, 0);
@ -30,15 +29,13 @@ ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWid
frameLayout->addWidget(analyticsPanel); frameLayout->addWidget(analyticsPanel);
dropIndicator = new QFrame(frame); dropIndicator = new QFrame(frame);
dropIndicator->setStyleSheet("background-color: #3daee9;");
dropIndicator->setFixedHeight(3); dropIndicator->setFixedHeight(3);
dropIndicator->hide(); // hidden by default dropIndicator->hide(); // hidden by default
dropIndicator->raise(); // make sure it's above children dropIndicator->raise(); // make sure it's above children
selectionOverlay = new QFrame(frame); selectionOverlay = new QFrame(frame);
selectionOverlay->setStyleSheet("background-color: rgba(61,174,233,50);"); // semi-transparent blue selectionOverlay->hide(); // hidden by default
selectionOverlay->hide(); // hidden by default selectionOverlay->raise(); // make sure it is above children
selectionOverlay->raise(); // make sure it is above children
selectionOverlay->setAttribute(Qt::WA_TransparentForMouseEvents); selectionOverlay->setAttribute(Qt::WA_TransparentForMouseEvents);
// Bottom bar with drag button and resize handle // Bottom bar with drag button and resize handle
@ -51,24 +48,41 @@ ResizablePanel::ResizablePanel(const QString &_typeId, AbstractAnalyticsPanelWid
dragButton = new QPushButton("", bottomBar); dragButton = new QPushButton("", bottomBar);
dragButton->setFixedSize(40, 8); dragButton->setFixedSize(40, 8);
dragButton->setCursor(Qt::OpenHandCursor); dragButton->setCursor(Qt::OpenHandCursor);
dragButton->setStyleSheet("QPushButton { "
"background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #4a4a4a, stop:1 #3a3a3a); "
"border: none; color: #888; font-size: 10px; }"
"QPushButton:hover { background: #5a5a5a; }");
bottomLayout->addWidget(dragButton); bottomLayout->addWidget(dragButton);
// Resize handle fills the rest // Resize handle fills the rest
resizeHandle = new QWidget(bottomBar); resizeHandle = new QWidget(bottomBar);
resizeHandle->setFixedHeight(8); resizeHandle->setFixedHeight(8);
resizeHandle->setCursor(Qt::SizeVerCursor); resizeHandle->setCursor(Qt::SizeVerCursor);
resizeHandle->setStyleSheet("background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
"stop:0 #3a3a3a, stop:1 #2a2a2a);");
bottomLayout->addWidget(resizeHandle, 1); bottomLayout->addWidget(resizeHandle, 1);
frameLayout->addWidget(bottomBar); frameLayout->addWidget(bottomBar);
mainLayout->addWidget(frame); mainLayout->addWidget(frame);
const QPalette &pal = QApplication::palette();
QColor mid = pal.color(QPalette::Mid);
QColor dark = pal.color(QPalette::Dark);
QColor midLight = pal.color(QPalette::Midlight);
QColor shadow = pal.color(QPalette::Shadow);
QColor placeholderText = pal.color(QPalette::PlaceholderText);
frame->setStyleSheet("QFrame { border: none; }");
dropIndicator->setStyleSheet("QFrame { background-color: #3daee9; }");
selectionOverlay->setStyleSheet("QFrame { background-color: rgba(61,174,233,50); }");
dragButton->setStyleSheet(QString("QPushButton { "
"background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 %1, stop:1 %2); "
"border: none; color: %3; font-size: 10px; }"
"QPushButton:hover { background: %4; }")
.arg(mid.name(), dark.name(), placeholderText.name(), midLight.name()));
resizeHandle->setStyleSheet(QString("QWidget { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
"stop:0 %1, stop:1 %2); }")
.arg(dark.name(), shadow.name()));
// Set size policy // Set size policy
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);