#include "msgmemo.h" #include "italkingwidget.h" #include "ui_msgmemo.h" #include #include #include #include "gotyecpp/gotyemsg.h" #include "gotye/GotyeMessage.h" #include "gotye/GotyeAPI.h" USING_NS_GOTYEAPI; msgMemo::msgMemo(QWidget *parent) : BaseMainWidget(parent), ui(new Ui::msgMemo) { ui->setupUi(this); this->setWindowFlags(Qt::FramelessWindowHint);//去掉标题栏 ui->textEdit->installEventFilter(this); QFile source(":Images/style/style1.html"); source.open(QIODevice::ReadOnly); ui->webView->setHtml(QString::fromUtf8(source.readAll().constData())); source.close(); // this->setStyleSheet("background-color:rgb(200,200,200)"); ui->pushButton_2->hide(); ui->pushButton->hide(); ui->pushButton_expression->hide(); //表情 ui->pushButton_4->hide();//最小化按键 } msgMemo::~msgMemo() { delete ui; } QWebView * msgMemo::getMsgView() { // GotyeMsg::Instance()->setShowMsgWebviwe(ui->webView); return ui->webView; } void msgMemo::on_pushButton_3_clicked() { this->hide(); // this->close(); } void msgMemo::on_pushButton_4_clicked() { this->showMinimized(); // this->hide(); } void msgMemo::on_pushButton_clicked() { ui->tabWidget->setCurrentIndex(0); } void msgMemo::on_pushButton_2_clicked() { ui->tabWidget->setCurrentIndex(1); } void msgMemo::on_msgSeng_clicked() { if( ui->textEdit->toPlainText() == NULL ) { QMessageBox::warning( this , "warning","Message to be sent cannot be empty!" ); return; } // SendMsgShow( ui->textEdit->toPlainText(),Myhead); GotyeMsg::Instance()->sendMessage(ui->textEdit->toPlainText(),GotyeMessageTypeText); ui->textEdit->clear(); ui->textEdit->activateWindow(); ui->textEdit->setFocus(); } bool msgMemo::eventFilter(QObject *obj, QEvent *e) { // Q_ASSERT(obj == inputTextEdit); if (e->type() == QEvent::KeyPress) { QKeyEvent *event = static_cast(e); if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && (event->modifiers() & Qt::ControlModifier)) { ui->textEdit->append("");//换行 // on_pushButton_clicked(); //发送消息的槽 return true; } else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { on_msgSeng_clicked(); //发送消息的槽 return true; } } return false; } void msgMemo::on_pictureSend_clicked() { QFileDialog::Options options; //if (!native->isChecked()) options |= QFileDialog::DontUseNativeDialog; QString selectedFilter,openFilesPath; QStringList files = QFileDialog::getOpenFileNames( this, tr("QFileDialog::getOpenFileNames()"), openFilesPath, tr("Images (*.png *.bmp *.jpg)"), &selectedFilter, options); if (files.count()) { for(int i = 0;i < files.count();i++) { GotyeMsg::Instance()->sendMessage(files[i],GotyeMessageTypeImage); // SendImageShow( files[i],Myhead); } } }