123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #include "clNoticePopWidget.h"
- #include "ui_clNoticePopWidget.h"
- #include "CAppInfo.h"
- #include <QGraphicsDropShadowEffect>
- clNoticePopWidget::clNoticePopWidget(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::clNoticePopWidget)
- {
- ui->setupUi(this);
- setStyleSheet(g_appInfoPtr->m_sQssStr);
- }
- clNoticePopWidget::~clNoticePopWidget()
- {
- delete ui;
- }
- void clNoticePopWidget::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
- {
- setGeometry(nLeft, nTop, nWidth, nHeight);
- ui->widget_npw_BG->setGeometry(g_appInfoPtr->m_fRate*5, g_appInfoPtr->m_fRate*5, width()-g_appInfoPtr->m_fRate*10, height()-g_appInfoPtr->m_fRate*10);
- ui->label_noticeIcon->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*24,
- g_appInfoPtr->m_fRate*16, g_appInfoPtr->m_fRate*12);
- ui->label_noticeTitle->adjustSize();
- ui->label_noticeTitle->setGeometry(ui->label_noticeIcon->x() + ui->label_noticeIcon->width() + g_appInfoPtr->m_fRate*8,
- ui->label_noticeIcon->y() + (ui->label_noticeIcon->height() - ui->label_noticeTitle->height())/2,
- ui->label_noticeTitle->width(), ui->label_noticeTitle->height());
- ui->txtb_noticeContent->setGeometry(ui->label_noticeIcon->x(), ui->label_noticeTitle->y() + ui->label_noticeTitle->height() + g_appInfoPtr->m_fRate*10,
- g_appInfoPtr->m_fRate*260, g_appInfoPtr->m_fRate*60);
- ui->btn_detail->setGeometry(ui->widget_npw_BG->width() - g_appInfoPtr->m_fRate*(20 + 80),
- ui->widget_npw_BG->height() - g_appInfoPtr->m_fRate*(20 + 30),
- g_appInfoPtr->m_fRate*80, g_appInfoPtr->m_fRate*30);
- ui->btn_ignore->setGeometry(ui->btn_detail->x() - g_appInfoPtr->m_fRate*10 - ui->btn_detail->width(), ui->btn_detail->y(),
- ui->btn_detail->width(), ui->btn_detail->height());
- QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
- effect->setOffset(g_appInfoPtr->m_fRate*4,g_appInfoPtr->m_fRate*4);
- effect->setColor(QColor(0,0,0,30));
- effect->setBlurRadius(g_appInfoPtr->m_fRate*16);
- ui->widget_npw_BG->setGraphicsEffect(effect);
- }
- void clNoticePopWidget::addNotice(const CNoticeInfo ni)
- {
- std::vector<CNoticeInfo>::iterator it =
- std::find_if(vIgnoreNL.begin(), vIgnoreNL.end(), [&ni](const CNoticeInfo &temp) {
- return temp.nId == ni.nId;
- });
- if (it != vIgnoreNL.end())
- {
- return;
- }
- vNL.push_back(ni);
- if (vNL.size() == 1)
- {
- showNotice(ni);
- }
- }
- void clNoticePopWidget::setNoticeRead(__int64 nId)
- {
- std::vector<CNoticeInfo>::iterator it =
- std::find_if(vNL.begin(), vNL.end(), [&nId](const CNoticeInfo &temp) {
- return temp.nId == nId;
- });
- if (it != vNL.end())
- {
- vNL.erase(it);
- if (vNL.size() <= 0)
- {
- hide();
- }
- else
- {
- showNotice(*vNL.begin());
- }
-
- }
- }
- void clNoticePopWidget::showNotice(const CNoticeInfo ni)
- {
- if (ni.bHasRecalled)
- {
- ui->label_noticeTitle->setText(QString::fromLocal8Bit("发送者已撤回消息:%1").arg(ni.sTitle));
- ui->label_noticeTitle->adjustSize();
- ui->txtb_noticeContent->insertPlainText(QString::fromLocal8Bit("该消息已经被发送者撤回。"));
- }
- else
- {
- ui->label_noticeTitle->setText(ni.sTitle);
- ui->label_noticeTitle->adjustSize();
- ui->txtb_noticeContent->insertHtml(ni.sContent);
- }
-
- }
- int clNoticePopWidget::noticeCount()
- {
- return vNL.size();
- }
- void clNoticePopWidget::on_btn_detail_clicked()
- {
- emit showNoticeDetail(vNL.begin()->nId);
- on_btn_ignore_clicked();
- }
- void clNoticePopWidget::on_btn_ignore_clicked()
- {
- vIgnoreNL.push_back(*vNL.begin());
- vNL.erase(vNL.begin());
- if(vNL.size() <= 0)
- {
- hide();
- }
- }
|