88 lines
2.7 KiB
C++
88 lines
2.7 KiB
C++
|
#include "alarmwidget.h"
|
||
|
|
||
|
AlarmWidget::AlarmWidget(const QString& vehicle, const QString& group, const QString& sensor,
|
||
|
const QString& date, const QString& time, QWidget *parent)
|
||
|
: QWidget(parent)
|
||
|
{
|
||
|
setAttribute(Qt::WA_StyledBackground);
|
||
|
// Устанавливаем обводку для ВСЕГО виджета
|
||
|
setStyleSheet(R"(
|
||
|
QWidget {
|
||
|
border: 1px solid #E5E7EB;
|
||
|
background-color: transparent;
|
||
|
}
|
||
|
)");
|
||
|
|
||
|
// Горизонтальный layout
|
||
|
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||
|
mainLayout->setSpacing(70); // Отступы между элементами
|
||
|
mainLayout->setContentsMargins(25, 5, 25, 5); // Внутренние отступы
|
||
|
setLayout(mainLayout);
|
||
|
|
||
|
// Создаем лейблы
|
||
|
vehicleLabel = createLabel(vehicle, 100, 230);
|
||
|
groupLabel = createLabel(group, 100, 250);
|
||
|
sensorLabel = createLabel(sensor, 100, 250);
|
||
|
dateLabel = createLabel(date, 100, 150);
|
||
|
timeLabel = createLabel(time, 100, 100);
|
||
|
|
||
|
// Добавляем лейблы в layout
|
||
|
mainLayout->addWidget(vehicleLabel);
|
||
|
mainLayout->addWidget(groupLabel);
|
||
|
mainLayout->addWidget(sensorLabel);
|
||
|
mainLayout->addWidget(dateLabel);
|
||
|
mainLayout->addWidget(timeLabel);
|
||
|
|
||
|
// Кнопка "Подробнее"
|
||
|
infoButton = new QPushButton("Подробнее");
|
||
|
infoButton->setFixedHeight(40);
|
||
|
infoButton->setFixedSize(140, 40);
|
||
|
infoButton->setStyleSheet(R"(
|
||
|
QPushButton {
|
||
|
border: 1px solid #13385F;
|
||
|
border-radius: 5px;
|
||
|
color: #13385F;
|
||
|
font-family: Inter;
|
||
|
font-size: 20px;
|
||
|
font-weight: 500;
|
||
|
background-color: white;
|
||
|
}
|
||
|
QPushButton:hover {
|
||
|
background-color: #e0f2f7;
|
||
|
border-color: #1A4A73;
|
||
|
color: #1A4A73;
|
||
|
}
|
||
|
QPushButton:pressed {
|
||
|
background-color: #102E47;
|
||
|
color: white;
|
||
|
border-color: #102E47;
|
||
|
}
|
||
|
)");
|
||
|
|
||
|
// Добавляем кнопку в layout
|
||
|
mainLayout->addWidget(infoButton);
|
||
|
|
||
|
//mainLayout->addStretch();
|
||
|
|
||
|
}
|
||
|
|
||
|
QLabel* AlarmWidget::createLabel(const QString &text, int minSize, int maxSize)
|
||
|
{
|
||
|
QLabel *label = new QLabel(text);
|
||
|
label->setAlignment(Qt::AlignLeft);
|
||
|
label->setWordWrap(true);
|
||
|
label->setMinimumWidth(minSize);
|
||
|
label->setMaximumWidth(maxSize);
|
||
|
label->setFixedHeight(25);
|
||
|
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||
|
label->setStyleSheet(R"(
|
||
|
background: transparent;
|
||
|
font-family: Inter;
|
||
|
font-size: 20px;
|
||
|
font-weight: 400;
|
||
|
color: #13385F;
|
||
|
border: none;
|
||
|
)");
|
||
|
return label;
|
||
|
}
|