📄 msgscreen.cpp
字号:
/* Demo program for iksemel external sockets.** Copyright (C) 2004 Darrell Karbott (djk2005@users.sf.net)** This code is free software; you can redistribute it and/or** modify it under the terms of the GNU Public Licence (GPL) version 2** See http://www.gnu.org/ for further details of the GPL.*/#include "MsgScreen.h"#include <qlabel.h>#include <qpushbutton.h>#include <qlayout.h>// Stringsconst char* LABEL_TOJID = "To Jid:";const char* LABEL_MSG = "Msg:";const char* LABEL_TITLE = "CIksDemo Jabber Demo [QT UI]";const char* LABEL_START_MSG = "Press [Connect] to start.";MsgScreen::MsgScreen(QWidget* parent) : QWidget(parent){ setCaption(LABEL_TITLE); // Divide area in two QVBoxLayout* layout = new QVBoxLayout(this, 5); // Stack pairs of widgets vertically in top part QVBoxLayout* top = new QVBoxLayout(layout, 5); QGridLayout* textFields = new QGridLayout(top, 2, 2); QLabel* lblToJid = new QLabel(LABEL_TOJID, this); textFields->addWidget(lblToJid, 0, 0); txtToJid_ = new QLineEdit(this); textFields->addWidget(txtToJid_, 0, 1); QLabel* lblMsg = new QLabel(LABEL_MSG, this); textFields->addWidget(lblMsg, 1, 0); txtMsg_ = new QLineEdit(this); textFields->addWidget(txtMsg_, 1, 1);// // first// QHBoxLayout* firstRow = new QHBoxLayout(top, 5);// QLabel* lblToJid = new QLabel(LABEL_TOJID, this);// firstRow->addWidget(lblToJid);// firstRow->addSpacing(5);// txtToJid_ = new QLineEdit(this);// firstRow->addWidget(txtToJid_);// // second// QHBoxLayout* secondRow = new QHBoxLayout(top, 5);// QLabel* lblMsg = new QLabel(LABEL_MSG, this);// secondRow->addWidget(lblMsg);// secondRow->addSpacing(5);// txtMsg_ = new QLineEdit(this);// secondRow->addWidget(txtMsg_); // Third QHBoxLayout* thirdRow = new QHBoxLayout(top, 5); thirdRow->addStretch(); QPushButton* send = new QPushButton("&Send", this); connect( send, SIGNAL(clicked()), this, SLOT(onSend())); thirdRow->addWidget(send); QPushButton* connectBut = new QPushButton("&Connect", this); connect( connectBut, SIGNAL(clicked()), this, SLOT(onConnect())); thirdRow->addWidget(connectBut); QPushButton* disconnect = new QPushButton("&Disconnect", this); connect( disconnect, SIGNAL(clicked()), this, SLOT(onDisconnect())); thirdRow->addWidget(disconnect); // Put read only display QTextEdit in bottom txtDisplay_ = new QTextEdit(this); txtDisplay_->setReadOnly(true); layout->addWidget(txtDisplay_); display(LABEL_START_MSG);}void MsgScreen::display(const char* line){ txtDisplay_->append(line);}void MsgScreen::setToJid(const char* to){ txtToJid_->setText(to);}void MsgScreen::onSend(){ QString to = txtToJid_->text().stripWhiteSpace(); QString msg = txtMsg_->text().stripWhiteSpace(); emit sendMsg(to, msg);}void MsgScreen::onConnect(){ emit connect_();}void MsgScreen::onDisconnect(){ emit disconnect();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -