|
|
#include "marketing.h"
|
|
|
#include "choose.h"
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
#include <QPushButton>
|
|
|
#include <QPixmap>
|
|
|
#include <QResizeEvent>
|
|
|
|
|
|
marketing::marketing(QWidget *parent, choose *choosePage) :
|
|
|
QWidget(parent),
|
|
|
choosePage(choosePage)
|
|
|
{
|
|
|
// 设置窗口大小
|
|
|
resize(600, 420);
|
|
|
setMinimumSize(600, 420);
|
|
|
setMaximumSize(600, 420);
|
|
|
|
|
|
// 垂直布局
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
layout->setSpacing(0);
|
|
|
|
|
|
// 背景图片
|
|
|
imageLabel = new QLabel(this);
|
|
|
originalPixmap.load(":/marketing.jpg");
|
|
|
if (!originalPixmap.isNull()) {
|
|
|
imageLabel->setPixmap(originalPixmap.scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
|
|
} else {
|
|
|
imageLabel->setText("图片加载失败");
|
|
|
imageLabel->setAlignment(Qt::AlignCenter);
|
|
|
}
|
|
|
imageLabel->setScaledContents(true);
|
|
|
imageLabel->setAlignment(Qt::AlignCenter);
|
|
|
layout->addWidget(imageLabel);
|
|
|
setLayout(layout);
|
|
|
|
|
|
// 公告文本框
|
|
|
announcementEdit = new QTextEdit(this);
|
|
|
announcementEdit->setText("停车场公告:\n"
|
|
|
"1. 请规范停放,车身完全入位,勿占消防通道、应急出口及他人专属车位。\n"
|
|
|
"2. 勿在车内存放现金、首饰等贵重物品,锁车后确认门窗是否关好。\n"
|
|
|
"3. 场内禁鸣笛、限速5km/h,儿童与宠物需成人全程看护。\n"
|
|
|
"4. 若遇车辆剐蹭、设备故障,联系管理员(电话:88888888)协助处理。\n"
|
|
|
"5. 遇暴雨、大风等恶劣天气,建议选择地下停车场或空旷且安全区域,避免车辆受损。\n"
|
|
|
"感谢您的理解与配合,祝您出行平安!");
|
|
|
announcementEdit->setFixedSize(420, 250);
|
|
|
announcementEdit->setStyleSheet(
|
|
|
"QTextEdit {"
|
|
|
" font: 12px '微软雅黑';"
|
|
|
" padding: 10px;"
|
|
|
" background: rgba(255, 255, 255, 0);" // 背景透明
|
|
|
" color: #000000;" // 文字颜色
|
|
|
" border: none;" // 边框透明
|
|
|
" border-radius: 10px;" // 圆角可选
|
|
|
"}"
|
|
|
"QTextEdit:focus {"
|
|
|
" outline: none;" // 聚焦时去掉蓝框
|
|
|
" border: none;" // 聚焦时边框也透明
|
|
|
"}"
|
|
|
);
|
|
|
|
|
|
announcementEdit->raise();
|
|
|
|
|
|
// 发布按钮
|
|
|
sendButton = new QPushButton("发布", this);
|
|
|
sendButton->setFixedSize(80, 40);
|
|
|
sendButton->setStyleSheet(
|
|
|
"QPushButton {"
|
|
|
" background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
|
|
" stop:0 #a0d8ef, stop:1 #70b8d6);"
|
|
|
" color: white;"
|
|
|
" font: bold 16px '微软雅黑';"
|
|
|
" border-radius: 10px;"
|
|
|
"}"
|
|
|
"QPushButton:hover {"
|
|
|
" background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
|
|
" stop:0 #70b8d6, stop:1 #a0d8ef);"
|
|
|
"}"
|
|
|
);
|
|
|
sendButton->raise();
|
|
|
|
|
|
// 返回按钮
|
|
|
backButton = new QPushButton("返回", this);
|
|
|
backButton->setFixedSize(70, 35);
|
|
|
backButton->setStyleSheet(
|
|
|
"QPushButton {"
|
|
|
" background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
|
|
" stop:0 #cdebb0, stop:1 #a8d88c);"
|
|
|
" color: white;"
|
|
|
" font: bold 15px '微软雅黑';"
|
|
|
" border-radius: 8px;"
|
|
|
"}"
|
|
|
"QPushButton:hover {"
|
|
|
" background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
|
|
" stop:0 #a8d88c, stop:1 #cdebb0);"
|
|
|
"}"
|
|
|
);
|
|
|
backButton->raise();
|
|
|
|
|
|
// 发布按钮点击
|
|
|
connect(sendButton, &QPushButton::clicked, this, [=]() {
|
|
|
if (choosePage && !announcementEdit->toPlainText().isEmpty()) {
|
|
|
choosePage->setAnnouncementText(announcementEdit->toPlainText());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 返回按钮点击
|
|
|
connect(backButton, &QPushButton::clicked, this, [=]() {
|
|
|
if (choosePage) {
|
|
|
choosePage->show();
|
|
|
this->hide();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
void marketing::resizeEvent(QResizeEvent *event)
|
|
|
{
|
|
|
QWidget::resizeEvent(event);
|
|
|
|
|
|
// 背景图片自适应
|
|
|
if (!originalPixmap.isNull()) {
|
|
|
imageLabel->setPixmap(originalPixmap.scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
|
|
}
|
|
|
|
|
|
// 文本框偏移
|
|
|
int textboxX = (width() - announcementEdit->width()) / 2 - 10;
|
|
|
int textboxY = (height() - announcementEdit->height()) / 2 - 20;
|
|
|
announcementEdit->move(textboxX, textboxY);
|
|
|
|
|
|
// 发布按钮左下方
|
|
|
sendButton->move(
|
|
|
textboxX - sendButton->width() + 370, // x 坐标
|
|
|
textboxY + announcementEdit->height() - sendButton->height()/2 - 20 // y 坐标往上偏移 20
|
|
|
);
|
|
|
|
|
|
// 返回按钮左上角
|
|
|
backButton->move(15, 15);
|
|
|
}
|
|
|
|
|
|
marketing::~marketing()
|
|
|
{
|
|
|
// QWidget 自动释放子控件,无需 delete
|
|
|
}
|