📄 composer.cpp
字号:
// Protected by the GNU General Public License#include "composer.h"Composer::Composer(QWidget *parent, QString toPre, QString bodyPre) : QMainWindow(parent){ resize(240,300); setCaption(tr("Compose Message")); QToolBar *toolbar = new QToolBar(this); setToolBarsMovable(false); addToolBar(toolbar); sendSMS = new QAction(tr("Send SMS"), QIconSet(QPixmap("send.png")), 0, 0, this); sendSMS->addTo(toolbar); connect(sendSMS, SIGNAL(activated()), this, SLOT(sendMessage())); QAction *abortButton = new QAction(tr("Stop"), QIconSet(QPixmap("stop.png")), 0, 0, this); abortButton->setEnabled(false); abortButton->addTo(toolbar); QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); QGridLayout *layout = new QGridLayout(centralWidget); layout->addWidget(new QLabel(tr("To:"),centralWidget),0,0); to = new QComboBox(centralWidget); to->setEditable(true); layout->addWidget(to,0,1); message = new QMultiLineEdit(centralWidget); message->setText(bodyPre); layout->addMultiCellWidget(message,3,3,0,1); getStuff(); this->toPre = toPre;};void Composer::getStuff(){ }void Composer::setStatusText(const QString &msg){ //Global::statusMessage(msg);}void Composer::sendMessage(){ if (to->currentText().isEmpty()) { QMessageBox::information(this, tr("Missing Parameter"), tr("You have to specify\na recipient!"), tr("Ok")); return; } QString home = getenv( "HOME" ); QDir d(home + "/.smsbox/dir/outbox/"); QStringList contents = d.entryList("*", QDir::Files, QDir::Name); int num = 1; for (QStringList::Iterator i = contents.begin(); i != contents.end(); i++) { if ((*i).toInt() >= num) num = (*i).toInt() + 1; } QString location = "/.smsbox/dir/outbox/%1"; QFile f(home + location.arg(num)); if (f.open(IO_WriteOnly|IO_Append)) { f.writeBlock("--\n", qstrlen("--\n")); QTextStream t(&f); t << "Originating address:" + to->currentText() << "\n"; t << "User data:" + message->text() << "\n"; } f.close(); sendSMS->setEnabled(false); setStatusText(tr("Looking up SMS server")); SendSMS *sendsms = new SendSMS(to->currentText(), message->text()); connect(sendsms, SIGNAL(destroyed()), this, SLOT(enableSend())); connect(sendsms, SIGNAL(errorOccourred(int)), this, SLOT(sendError(int)));}void Composer::sendError(int error){ if (error == SendSMS::ErrUnknownResponse) { QMessageBox::warning(this, tr("Error"), tr("An unknown error occoured."), tr("Ok")); sendSMS->setEnabled(true); }}void Composer::enableSend(){ sendSMS->setEnabled(true);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -