modify dialog frame
This commit is contained in:
parent
8eb83d9cbf
commit
e9c4516f0f
@ -76,6 +76,8 @@ void RecourceHelper::ChangeSkin(const QString& skin) {
|
|||||||
if (file.open(QFile::ReadOnly | QFile::Text)) {
|
if (file.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
QString qss = stream.readAll();
|
QString qss = stream.readAll();
|
||||||
|
qss += "\nDialogTitleBar{border-top-left-radius:10px;border-top-right-radius:10px;}\n";
|
||||||
|
qss += "QWidget#DialogContainer{border-radius:10px;background: palette(window);}\n";
|
||||||
qApp->setStyleSheet(qss);
|
qApp->setStyleSheet(qss);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,11 @@ FrameTitleBar{
|
|||||||
border-top-right-radius:10px;
|
border-top-right-radius:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget#DialogContainer {
|
||||||
|
border-radius:10px;
|
||||||
|
background: #212F3C;
|
||||||
|
}
|
||||||
|
|
||||||
QFrame>QLabel#sys_icon {
|
QFrame>QLabel#sys_icon {
|
||||||
max-width:24px;
|
max-width:24px;
|
||||||
min-width:24px;
|
min-width:24px;
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
#include "FrameTitleBar.h"
|
#include "FrameTitleBar.h"
|
||||||
#include "FramelessDelegate.h"
|
#include "FramelessDelegate.h"
|
||||||
@ -50,12 +52,36 @@ bool Dialog::nativeEvent(const QByteArray& eventType, void* message, qintptr* re
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::paintEvent(QPaintEvent* event) {
|
void Dialog::paintEvent(QPaintEvent* event) {
|
||||||
QStyleOption opt;
|
Q_UNUSED(event);
|
||||||
opt.initFrom(this);
|
this->setAutoFillBackground(false);
|
||||||
|
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
p.fillRect(rect(), Qt::transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::InitFrame() {
|
void Dialog::InitFrame() {
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
if (ui_ && ui_->verticalLayout && ui_->titleBar && ui_->mianWidget) {
|
||||||
|
ui_->verticalLayout->setContentsMargins(12, 12, 12, 12);
|
||||||
|
|
||||||
|
QWidget* container = new QWidget(this);
|
||||||
|
container->setObjectName("DialogContainer");
|
||||||
|
container->setAutoFillBackground(true);
|
||||||
|
container->setAttribute(Qt::WA_StyledBackground, true);
|
||||||
|
QVBoxLayout* containerLayout = new QVBoxLayout(container);
|
||||||
|
containerLayout->setSpacing(0);
|
||||||
|
containerLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
ui_->verticalLayout->removeWidget(ui_->titleBar);
|
||||||
|
ui_->verticalLayout->removeWidget(ui_->mianWidget);
|
||||||
|
containerLayout->addWidget(ui_->titleBar);
|
||||||
|
containerLayout->addWidget(ui_->mianWidget);
|
||||||
|
ui_->verticalLayout->addWidget(container);
|
||||||
|
|
||||||
|
auto *shadow = new QGraphicsDropShadowEffect(this);
|
||||||
|
shadow->setBlurRadius(24);
|
||||||
|
shadow->setColor(QColor(0, 0, 0, 100));
|
||||||
|
shadow->setOffset(0, 8);
|
||||||
|
container->setGraphicsEffect(shadow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user