Blame view

LiveChat/FeiTalk/gui/userinfotip.cpp 1.3 KB
9f17d59e   陈明泉   no message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  #include "userinfotip.h"
  #include "ui_userinfotip.h"
  
  UserInfoTip::UserInfoTip(QWidget *parent) :
      IWidget(parent),
      ui(new Ui::UserInfoTip)
  {
      ui->setupUi(this);
  
      setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint| Qt::Widget);
    //  setFocusPolicy(Qt::StrongFocus);
      ui->labelName->setStyleSheet("color:rgb(0,0,0)");
  }
  
  UserInfoTip::~UserInfoTip()
  {
      delete ui;
  }
  
  void UserInfoTip::resizeEvent(QResizeEvent * event )
  {
     QPainterPath path;
     QRectF rect = QRectF(0,0,width(),height());
     path.addRoundRect(rect,4,4);
     QPolygon polygon= path.toFillPolygon().toPolygon();//获得这个路径上的所有的点
     QRegion region(polygon);//根据这个点构造这个区域
     setMask(region);
  }
  
  
  void UserInfoTip::setHeaderImg(QString img)
  {
      ui->labelHeadImg->setPixmap(QPixmap(img).scaled(160, 140));
      qDebug("CMQ IMG setHeaderImg = %s......\n",img.toLatin1().data());
  }
  
  void UserInfoTip::setName(QString name)
  {
      ui->labelName->setText(name);
  }
  
  void UserInfoTip::setEvaluation(float evaluation_total)
  {
      ui->labelEvaluation->setText(QString("%1").sprintf("%.1f",evaluation_total));
  }
  
  void UserInfoTip::setCallTime(int call_time)
  {
      int hour = call_time/3600;
      int min = (call_time%3600)/60;
  
      ui->labelCallTime->setText(QString("%1h %2min").arg(hour).arg(min));
  }