#include "BootWidget.h" #include "BootGlobal.h" #include "ui_BootWidget.h" #include #include BootWidget::BootWidget(QWidget *parent) : QWidget(parent),mSplitter(NULL),mListEvtLog(NULL) { setWindowIcon(QIcon(":/res/FavIcon.ico")); setMinimumSize(1920, 1080); SetFullMode(); Init(); } BootWidget::~BootWidget() { } void BootWidget::SetFullMode() { setWindowFlags(Qt::Window | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); /* setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint|Qt::Tool |Qt::X11BypassWindowManagerHint); */ //setParent(nullptr); QList listScreens = QGuiApplication::screens(); //多显示器 QRect rect = listScreens.at(0)->geometry(); const int desktopWidth = rect.width(); const int desktopHeight = rect.height(); setMinimumSize(desktopWidth, desktopHeight); } void BootWidget::Demo_FulfillLog() { for(int i=1; i<=20; ++i) { QString str = QString(QStringLiteral("我是第%1串字符串")).arg(i); QBaseListWidgetItem* item = new QErrorListWidgetItem(str); // 为啥子类不能直接调用父类的接口?? item->AppentToWidget(mListEvtLog); } } void BootWidget::Demo_FulfillFatalMsg() { for(int i=1; i<1024; ++i) { QString str = QString(QStringLiteral("我是第%1串字符串")).arg(i); QBaseListWidgetItem* item = new QTipListWidgetItem(str); item->AppentToWidget(mListImportantTip); } } void BootWidget::Init() { QFont font; font.setFamily(QStringLiteral("微软雅黑")); //font.setPointSize(12); this->setFont(font); /* mSplitter = new QSplitter(Qt::Horizontal, this); mListEvtLog = new QListWidget(this); mListImportantTip = new QListWidget(this); auto *rightWidget = new QWidget(mSplitter); auto *layoutColumn = new QVBoxLayout(rightWidget); layoutColumn->addWidget(mListImportantTip); mSplitter->addWidget(mListEvtLog); mSplitter->addWidget(rightWidget); mSplitter->setStretchFactor(0, 80); mSplitter->setStretchFactor(1, 20); mSplitter->setAutoFillBackground(true); //mSplitter->setHandleWidth(0); QVBoxLayout *centerLayout = new QVBoxLayout(this); centerLayout->addWidget(mSplitter); this->setLayout(centerLayout); */ auto *layoutCenter = new QHBoxLayout(this); auto *layoutLeft = new QVBoxLayout(this); auto *layoutRight = new QVBoxLayout(this); auto *layoutRightArea = new QVBoxLayout(this); SlimLayout(layoutCenter); SlimLayout(layoutLeft); SlimLayout(layoutRight); SlimLayout(layoutRightArea); layoutRight->addLayout(layoutRightArea); mListEvtLog = new QLeftInfoListWidget(this); layoutLeft->addWidget(mListEvtLog); Demo_FulfillLog(); // LOGO mLogoLabel = new QLabel(this); QPixmap logoPixmap(GetLogoPicPath()); if(false) { const int labelWidth = mLogoLabel->width(); const int labelHeight = mLogoLabel->height(); //logoPixmap = logoPixmap.scaled(labelWidth, labelHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); logoPixmap = logoPixmap.scaled(labelWidth, labelHeight, Qt::KeepAspectRatio); } else { //const int pixWidth = logoPixmap.width(); //const int pixlHeight = logoPixmap.height(); //mLogoLabel->resize(pixWidth, pixlHeight); } mLogoLabel->setAlignment(Qt::AlignCenter); mLogoLabel->setPixmap(logoPixmap); //mLogoLabel->setScaledContents(true); SetWidgetBackgroundColor(mLogoLabel, GetRightBackgoundColor()); // TerminalInfo QLabel* terminalLabel = new QLabel(this); terminalLabel->setText("7715012020 CMB.LIB V1.2.3.4"); terminalLabel->setAlignment(Qt::AlignCenter); SetWidgetBackgroundColor(terminalLabel, GetRightBackgoundColor()); // Entity boot information QLabel* entityBootLabel = new QLabel(this); //equals: entityBootLabel->setText(QString::fromLocal8Bit(("11/55 个模块启动成功"))); entityBootLabel->setText(QStringLiteral("11/55 个模块启动成功")); entityBootLabel->setAlignment(Qt::AlignCenter); QFont fontLabel; fontLabel.setBold(true); fontLabel.setPointSize(12); entityBootLabel->setFont(fontLabel); //entityBootLabel->setStyleSheet("font-size:40px;font-style:blod"); SetWidgetBackgroundColor(entityBootLabel, GetRightBackgoundColor()); // no effect. //entityBootLabel->setContentsMargins(0,1000,0,1000); entityBootLabel->setMargin(10); layoutRightArea->addWidget(mLogoLabel); layoutRightArea->addWidget(terminalLabel); layoutRightArea->addWidget(entityBootLabel); mListImportantTip = new QRightInfoListWidget(this); layoutRightArea->addWidget(mListImportantTip); /* mTextEidtFatalMsg = new QPlainTextEdit(this); mTextEidtFatalMsg->setReadOnly(true); mTextEidtFatalMsg->setMaximumBlockCount(1024); mTextEidtFatalMsg->setBackgroundVisible(false); layoutRightArea->addWidget(mTextEidtFatalMsg); */ Demo_FulfillFatalMsg(); layoutCenter->addLayout(layoutLeft); layoutCenter->addLayout(layoutRight); layoutCenter->setStretch(0, 80); layoutCenter->setStretch(1, 20); this->setLayout(layoutCenter); } void BootWidget::paintEvent(QPaintEvent *event) { /* QPixmap logoPixmap(GetLogoPicPath()); const int pixWidth = logoPixmap.width(); const int pixlHeight = logoPixmap.height(); const int labelWidth = mLogoLabel->width(); const int newLabelHeight = labelWidth / (pixWidth / pixlHeight); mLogoLabel->resize(labelWidth, newLabelHeight); */ }