123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #include "addPic.h"
- #include "ui_addPic.h"
- #include "CAppInfo.h"
- addPic::addPic(int nOrder, QWidget *parent) :
- CBaseWidget(parent),
- ui(new Ui::addPic), m_nOrder(nOrder)
- {
- ui->setupUi(this);
- setStyleSheet(g_appInfoPtr->m_sQssStr);
- if(m_picList == nullptr)
- {
- m_picList = std::make_shared<wPictureList>(g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*10, this);
- connect(m_picList.get(), &wPictureList::picChange, this, [&](){
- QString sFileUrls = m_picList->getFileUrls();
- m_sFileUrls = sFileUrls;
- QStringList fileList;
- if(!sFileUrls.isEmpty())
- {
- fileList = sFileUrls.split(",");
- }
- int nPicWidth = 0;
- if (fileList.count() > 5)
- {
- nPicWidth = g_appInfoPtr->m_fRate * (100+10) * 6;
- ui->btn_addPic->setVisible(false);
- }
- else
- {
- ui->btn_addPic->setVisible(true);
- nPicWidth = g_appInfoPtr->m_fRate * (100+10) * fileList.count();
- }
- int nHeight = m_picList->setUI(0, g_appInfoPtr->m_fRate * 10,
- nPicWidth);
- m_picList->show();
- ui->btn_addPic->setGeometry(m_picList->width(), g_appInfoPtr->m_fRate*10, g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*100);
- emit answerChanged(fileList.count()>0);
- });
- }
- }
- addPic::~addPic()
- {
- delete ui;
- }
- int addPic::setUI(const int nWidth)
- {
- ui->btn_addPic->setGeometry(0, g_appInfoPtr->m_fRate*10, g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*100);
- ui->label_ap_tips->adjustSize();
- ui->label_ap_tips->setGeometry(ui->btn_addPic->x(), ui->btn_addPic->y() + ui->btn_addPic->height() + g_appInfoPtr->m_fRate*6,
- ui->label_ap_tips->width(), ui->label_ap_tips->height());
- setGeometry(0, 0, nWidth, ui->label_ap_tips->y() + ui->label_ap_tips->height() + g_appInfoPtr->m_fRate*10);
- return height();
- }
- int addPic::widgetType()
- {
- return wt_photoAnswer;
- }
- void addPic::on_btn_addPic_clicked()
- {
- if(m_pWxAnswer == nullptr)
- {
- m_pWxAnswer = std::make_shared<wxAnswer>("MULTIPLE_PICTURES", m_nOrder, g_appInfoPtr->m_pAnsBgWidget);
- m_pWxAnswer->setUI(0);
- m_pWxAnswer->setPics(m_sFileUrls);
- connect(m_pWxAnswer.get(), &wxAnswer::exit, this, [&]() {
- m_pWxAnswer.reset();
- });
-
- connect(m_pWxAnswer.get(), &wxAnswer::picConfirm, this, [&](QString sFileUrls){
- m_sFileUrls = sFileUrls;
- m_pWxAnswer.reset();
- if(m_picList == nullptr)
- {
- m_picList = std::make_shared<wPictureList>(g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*10, this);
- }
- m_picList->clearPic();
- QStringList fileList;
- if(!m_sFileUrls.isEmpty())
- {
- fileList = m_sFileUrls.split(",");
- for(QString sFile : fileList)
- {
- m_picList->AddPic(sFile);
- }
- }
- int nPicWidth = 0;
- if (fileList.count() > 5)
- {
- nPicWidth = g_appInfoPtr->m_fRate * (100+10) * 6;
- ui->btn_addPic->setVisible(false);
- }
- else
- {
- nPicWidth = g_appInfoPtr->m_fRate * (100+10) * fileList.count();
- }
- int nHeight = m_picList->setUI(0, g_appInfoPtr->m_fRate * 10,
- nPicWidth);
- m_picList->show();
- ui->btn_addPic->setGeometry(m_picList->width(), g_appInfoPtr->m_fRate*10, g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*100);
- emit answerChanged(fileList.count()>0);
- });
- }
- m_pWxAnswer->show();
- }
- QString addPic::getFileUrl()
- {
- return m_picList->getFileUrls();
- }
- void addPic::setAnswer(QString sAnswer)
- {
- m_sFileUrls = sAnswer;
- m_picList->clearPic();
- QStringList fileList;
- if(!m_sFileUrls.isEmpty())
- {
- fileList = m_sFileUrls.split(",");
- for(QString sFile : fileList)
- {
- m_picList->AddPic(sFile);
- }
- }
- int nPicWidth = 0;
- if (fileList.count() > 5)
- {
- nPicWidth = g_appInfoPtr->m_fRate * (100+10)*6;
- ui->btn_addPic->setVisible(false);
- }
- else
- {
- nPicWidth = g_appInfoPtr->m_fRate * (100+10) * fileList.count();
- }
- int nHeight = m_picList->setUI(0, g_appInfoPtr->m_fRate * 10,
- nPicWidth);
- m_picList->show();
- ui->btn_addPic->setGeometry(m_picList->width(), g_appInfoPtr->m_fRate*10, g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*100);
- }
|