|
@@ -1,8 +1,23 @@
|
|
|
#include "UserView.h"
|
|
|
|
|
|
+#include <Widgets/Button.h>
|
|
|
+#include <QFDIcon.h>
|
|
|
+
|
|
|
+#include <QBoxLayout>
|
|
|
+#include <QGridLayout>
|
|
|
+#include <QLabel>
|
|
|
+#include <QApplication>
|
|
|
+#include <QPixmap>
|
|
|
+
|
|
|
#include <QPainter>
|
|
|
|
|
|
-UserView::UserView(QWidget *parent) : QWidget(parent) { }
|
|
|
+UserView::UserView(QWidget *parent) : QWidget(parent)
|
|
|
+{
|
|
|
+ initilaize();
|
|
|
+ initLayout();
|
|
|
+ connectSignalsAndSlots();
|
|
|
+ refresh();
|
|
|
+}
|
|
|
|
|
|
void UserView::paintEvent(QPaintEvent *event)
|
|
|
{
|
|
@@ -12,3 +27,75 @@ void UserView::paintEvent(QPaintEvent *event)
|
|
|
painter.drawPixmap(0, 0,
|
|
|
pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
|
|
}
|
|
|
+
|
|
|
+void UserView::initilaize()
|
|
|
+{
|
|
|
+ m_vBoxLayout = new QVBoxLayout(this);
|
|
|
+
|
|
|
+ m_iconLabel = new QLabel(this);
|
|
|
+ m_iconLabel->setFixedSize(QSize(50, 50));
|
|
|
+ m_iconLabel->setScaledContents(true);
|
|
|
+ QPixmap pixmap = QPixmap(":/resource/logo.png");
|
|
|
+ pixmap.scaled(m_iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
|
+ m_iconLabel->setPixmap(pixmap);
|
|
|
+
|
|
|
+ m_gridLayout = new QGridLayout();
|
|
|
+
|
|
|
+ m_accNameLabel = new QLabel("用户名:", this);
|
|
|
+ m_accValueLabel = new QLabel(this);
|
|
|
+
|
|
|
+ m_idNameLabel = new QLabel("账号id:", this);
|
|
|
+ m_idValueLabel = new QLabel(this);
|
|
|
+ m_typeNameLabel = new QLabel("账号类型:", this);
|
|
|
+ m_typeValueLabel = new QLabel(this);
|
|
|
+
|
|
|
+ m_hBoxLayout = new QHBoxLayout();
|
|
|
+ m_confirmButton = new PushButton("退出", NEWFLICON(QFDIcon, Logout), this);
|
|
|
+
|
|
|
+ setStyleSheet("QLabel {font-size: 14px;font:Normal;font-family: 'Microsoft YaHei UI';}");
|
|
|
+}
|
|
|
+
|
|
|
+void UserView::initLayout()
|
|
|
+{
|
|
|
+ m_vBoxLayout->setContentsMargins(20, 20, 20, 20);
|
|
|
+
|
|
|
+ m_vBoxLayout->addStretch(1);
|
|
|
+
|
|
|
+ m_vBoxLayout->addWidget(m_iconLabel, 0, Qt::AlignHCenter);
|
|
|
+ m_vBoxLayout->addSpacing(50);
|
|
|
+
|
|
|
+ m_vBoxLayout->addLayout(m_gridLayout);
|
|
|
+ m_gridLayout->setAlignment(Qt::AlignHCenter);
|
|
|
+
|
|
|
+ m_gridLayout->addWidget(m_accNameLabel, 0, 0, 1, 1, Qt::AlignRight);
|
|
|
+ m_gridLayout->addWidget(m_accValueLabel, 0, 1, 1, 1, Qt::AlignLeft);
|
|
|
+
|
|
|
+ m_gridLayout->addWidget(m_idNameLabel, 1, 0, 1, 1, Qt::AlignRight);
|
|
|
+ m_gridLayout->addWidget(m_idValueLabel, 1, 1, 1, 1, Qt::AlignLeft);
|
|
|
+
|
|
|
+ m_gridLayout->addWidget(m_typeNameLabel, 2, 0, 1, 1, Qt::AlignRight);
|
|
|
+ m_gridLayout->addWidget(m_typeValueLabel, 2, 1, 1, 1, Qt::AlignLeft);
|
|
|
+
|
|
|
+ m_vBoxLayout->addStretch(2);
|
|
|
+
|
|
|
+ m_vBoxLayout->addLayout(m_hBoxLayout);
|
|
|
+ m_hBoxLayout->setAlignment(Qt::AlignRight);
|
|
|
+ m_hBoxLayout->addWidget(m_confirmButton);
|
|
|
+}
|
|
|
+
|
|
|
+void UserView::connectSignalsAndSlots()
|
|
|
+{
|
|
|
+ connect(m_confirmButton, &PushButton::clicked, this, &UserView::slotLogout);
|
|
|
+}
|
|
|
+
|
|
|
+void UserView::refresh()
|
|
|
+{
|
|
|
+ m_accValueLabel->setText("admin");
|
|
|
+ m_idValueLabel->setText("100001");
|
|
|
+ m_typeValueLabel->setText("超级管理员");
|
|
|
+}
|
|
|
+
|
|
|
+void UserView::slotLogout()
|
|
|
+{
|
|
|
+ emit signalLogout();
|
|
|
+}
|