|
@@ -12,30 +12,47 @@
|
|
|
#include <QLabel>
|
|
|
#include <QApplication>
|
|
|
#include <QPixmap>
|
|
|
+#include <QResizeEvent>
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
-UserView::UserView(QWidget *parent) : QWidget(parent)
|
|
|
+UserView::UserView(QWidget *parent) : QWidget(parent) { }
|
|
|
+
|
|
|
+void UserView::showEvent(QShowEvent *event)
|
|
|
{
|
|
|
- initilaize();
|
|
|
- initLayout();
|
|
|
- connectSignalsAndSlots();
|
|
|
+ QWidget::showEvent(event);
|
|
|
+ init();
|
|
|
refresh();
|
|
|
}
|
|
|
|
|
|
-void UserView::paintEvent(QPaintEvent *event)
|
|
|
+void UserView::resizeEvent(QResizeEvent *event)
|
|
|
+{
|
|
|
+ QWidget::resizeEvent(event);
|
|
|
+ init();
|
|
|
+ m_bgLabel->resize(event->size());
|
|
|
+ m_bgLabel->setPixmap(pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
|
|
+}
|
|
|
+
|
|
|
+void UserView::init()
|
|
|
{
|
|
|
- QWidget::paintEvent(event);
|
|
|
- QPainter painter(this);
|
|
|
- QPixmap pixmap(":/resource/background/1.jpg");
|
|
|
- painter.drawPixmap(0, 0,
|
|
|
- pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
|
|
+ if (m_initilized == true) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ initilaize();
|
|
|
+ initLayout();
|
|
|
+ connectSignalsAndSlots();
|
|
|
+
|
|
|
+ m_initilized = true;
|
|
|
}
|
|
|
|
|
|
void UserView::initilaize()
|
|
|
{
|
|
|
m_vBoxLayout = new QVBoxLayout(this);
|
|
|
|
|
|
+ m_bgLabel = new QLabel(this);
|
|
|
+ pixmap = QPixmap(":/resource/background/1.jpg");
|
|
|
+
|
|
|
m_iconLabel = new QLabel(this);
|
|
|
m_iconLabel->setFixedSize(QSize(50, 50));
|
|
|
m_iconLabel->setScaledContents(true);
|
|
@@ -94,9 +111,9 @@ void UserView::connectSignalsAndSlots()
|
|
|
|
|
|
void UserView::refresh()
|
|
|
{
|
|
|
- m_accValueLabel->setText("admin");
|
|
|
- m_idValueLabel->setText("100001");
|
|
|
- m_typeValueLabel->setText("超级管理员");
|
|
|
+ m_accValueLabel->setText(QFUser::currentUser()->userName);
|
|
|
+ m_idValueLabel->setText(QFUser::currentUser()->userNo);
|
|
|
+ m_typeValueLabel->setText(QFUser::currentUser()->roleName());
|
|
|
}
|
|
|
|
|
|
void UserView::slotLogout()
|