void PaintChatWindow::on_haveUpdate(){ std::cerr<<"PaintChatWindow::on_haveUpdate()"<<std::endl; if(chatType == ChatWidget::CHATTYPE_PRIVATE) { updateImage(); } if(chatType == ChatWidget::CHATTYPE_LOBBY) { QImage i = ui->paintWidget->getImage(); QPainter p(&i); p.setPen(Qt::black); p.setBrush(Qt::NoBrush); p.drawRect(0, 0, 302, 102); ui->paintWidget->setImage(i); QImage img = ui->paintWidget->getImage().copy(1, 1, 301, 101); std::string html = imgToHtmlString(img); ui->progressBar->setValue((html.size()*100)/MAX_LOBBY_MSG_SIZE); if(html.size()>MAX_LOBBY_MSG_SIZE) { ui->progressBar->setValue(100); } } }
void PaintChatWindow::on_haveUpdate(){ std::cerr<<"PaintChatWindow::on_haveUpdate()"<<std::endl; if(chatType == ChatWidget::CHATTYPE_PRIVATE) { updateImage(); } if(chatType == ChatWidget::CHATTYPE_LOBBY) { QImage i = ui->paintWidget->getImage(); // QPainter p(&i); // p.setPen(Qt::black); // p.setBrush(Qt::NoBrush); // p.drawRect(0, 0, 302, 102); // ui->paintWidget->setImage(i); QImage img = ui->paintWidget->getImage(); std::string html; bool scaled = imgToHtmlString(html, img, MAX_LOBBY_MSG_SIZE); ui->progressBar->setValue((html.size()*100)/MAX_LOBBY_MSG_SIZE); if(html.size()>MAX_LOBBY_MSG_SIZE) { ui->progressBar->setValue(100); } ui->lblImageSize->setText(QString("Image size: %1 bytes").arg(html.size())); ui->lblWarning->setVisible(scaled); } }
void PaintChatWindow::on_pushButtonSend_clicked() { std::string html; if(chatType == ChatWidget::CHATTYPE_PRIVATE) { imgToHtmlString(html, ui->paintWidget->getImage()); } if(chatType == ChatWidget::CHATTYPE_LOBBY) { QImage img = ui->paintWidget->getImage(); imgToHtmlString(html, img, MAX_LOBBY_MSG_SIZE); } rsMsgs->sendChat(ChatId(chatId), html); // chatWidget->addChatMsg(false, QString::fromStdString(rsPeers->getPeerName(rsPeers->getOwnId())), // QDateTime::currentDateTime(), QDateTime::currentDateTime(), // QString::fromStdString(html), ChatWidget::MSGTYPE_NORMAL ); }
void PaintChatWindow::on_pushButtonSend_clicked() { std::string html; if(chatType == ChatWidget::CHATTYPE_PRIVATE) { html = imgToHtmlString(ui->paintWidget->getImage()); } if(chatType == ChatWidget::CHATTYPE_LOBBY) { QImage img = ui->paintWidget->getImage().copy(1, 1, 301, 101); html = imgToHtmlString(img); if(html.size() > MAX_LOBBY_MSG_SIZE) { QMessageBox msgBox; msgBox.setText(tr("The image is to big to send it in a Chatlobby. Try to remove Details. The Progressbar below the image shows you the image size.")); msgBox.exec(); return; } } rsMsgs->sendPrivateChat(peerId, std::wstring(html.begin(), html.end())); chatWidget->addChatMsg(false, QString::fromStdString(rsPeers->getPeerName(rsPeers->getOwnId())), QDateTime::currentDateTime(), QDateTime::currentDateTime(), QString::fromStdString(html), ChatWidget::MSGTYPE_NORMAL ); }