void SessionTimesWidget::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape) on_closeButton_clicked(); QWidget::keyPressEvent(event); }
void BookmarksWindow::setupConnections() { connect(addButton,SIGNAL(clicked()),this, SLOT(on_addButton_clicked())); connect(addBookmarkWindow, SIGNAL(addBookmark(Bookmark *)), this, SLOT(addBookmarkItem(Bookmark *))); connect(removeButton,SIGNAL(clicked()),this, SLOT(on_removeButton_clicked())); connect(closeButton,SIGNAL(clicked()),this,SLOT(on_closeButton_clicked())); connect(loadButton,SIGNAL(clicked()),this,SLOT(on_loadButton_clicked())); connect(saveButton,SIGNAL(clicked()),this,SLOT(on_saveButton_clicked())); connect(openButton,SIGNAL(clicked()),this,SLOT(on_openButton_clicked())); }
ChatWindow::ChatWindow(QListWidgetItem *item, MainWindow *parent): QMainWindow(parent), username(CommonElements::getInstance()->getUsername()), item(item), friendName(item->text().left(item->text().size() - 4)), friendHead(new QLabel(this)), friendnameLabel(new QLabel(this)), messageEdit(new QTextEdit(this)), sendEdit(new QTextEdit(this)), sendButton(new QPushButton(this)), picButton(new QPushButton(this)), expressButton(new QPushButton(this)), filButton(new QPushButton(this)), closeButton(new CloseButton(this)), minButton(new MiniumButton(this)), trueImage(new QCheckBox(this)), manager(0), recmanager(0), filemanager(0), dmanager(0), pressed(false), expDialog(0) { this->setWindowFlags(Qt::FramelessWindowHint/* | Qt::Tool*/ | Qt::X11BypassWindowManagerHint); this->setMinimumSize(800, 600); this->setMaximumSize(800, 600); QLinearGradient linearGradient(QPoint(0, 0), QPoint(0, 600)); linearGradient.setColorAt(0, QColor(133, 218, 223)); linearGradient.setColorAt(1, QColor(255, 255, 255)); QPalette palette; palette.setBrush(QPalette::Background, QBrush(linearGradient)); this->setPalette(palette); QFont font; font.setPointSize(16); this->setWindowTitle(this->friendName); this->sendButton->setText("发送"); this->trueImage->setText("显示原图"); this->trueImage->setChecked(false); this->messageEdit->setReadOnly(true); this->friendHead->setGeometry(60, 32, 48, 48); this->friendnameLabel->setGeometry(120,32, 200, 48); this->messageEdit->setGeometry(50, 85, 700, 285); this->sendEdit->setGeometry(50, 420, 700, 120); this->sendButton->setGeometry(710, 550, 60, 30); this->picButton->setGeometry(90, 380, 30, 30); this->expressButton->setGeometry(50, 380, 30, 30); this->filButton->setGeometry(130, 380, 30, 30); this->closeButton->setGeometry(770, 0, 30, 30); this->minButton->setGeometry(740, 0, 30, 30); this->trueImage->setGeometry(170, 380, 80, 30); QImage head(":/images/photo"); head.scaled(48, 48, Qt::KeepAspectRatio); this->friendHead->setScaledContents(true); this->friendHead->setPixmap(QPixmap::fromImage(head)); this->friendnameLabel->setText(this->friendName); this->friendnameLabel->setFont(font); font.setPointSize(10); this->messageEdit->setFont(font); this->expressButton->setStyleSheet("QPushButton{border-image:url(:/images/expression);}" "QPushButton:hover{border-image:url(:/images/expression_1);}" "QPushButton:pressed{border-image:url(:/images/expression_2);}"); this->picButton->setStyleSheet("QPushButton{border-image:url(:/images/pic_0);}" "QPushButton:hover{border-image:url(:/images/pic_1);}" "QPushButton:pressed{border-image:url(:/images/pic_2);}"); this->filButton->setStyleSheet("QPushButton{border-image:url(:/images/file);}" "QPushButton:hover{border-image:url(:/images/file_1);}" "QPushButton:pressed{border-image:url(:/images/file_2);}"); connect(this->sendButton, SIGNAL(clicked()), this, SLOT(on_sendButton_clicked())); connect(this->picButton, SIGNAL(clicked()), this, SLOT(on_picButton_clicked())); connect(this->closeButton, SIGNAL(clicked()), this, SLOT(on_closeButton_clicked())); connect(this->minButton, SIGNAL(clicked()), this, SLOT(on_minButton_clicked())); connect(this->expressButton, SIGNAL(clicked()), this, SLOT(on_expressButton_clicked())); connect(this->filButton, SIGNAL(clicked()), this, SLOT(on_filButton_clicked())); expMap.insert("huaji", "(#滑稽)"); expMap.insert("dahan", "(#大汗)"); expMap.insert("fennu", "(#愤怒)"); expMap.insert("guaiqiao", "(#乖巧)"); expMap.insert("hecha", "(#喝茶)"); expMap.insert("kaixin", "(#开心)"); expMap.insert("penshui", "(#喷水)"); expMap.insert("weixiao", "(#微笑)"); expMap.insert("yinxian", "(#阴险)"); dPath = QDir::currentPath() + "/headImages/head_" + this->friendName + ".png"; updateFriendHead(); Database *db = Database::getInstance(""); db->loadMessage(this, this->friendName); }