📄 viewsms.cpp
字号:
// Protected by the GNU General Public License#include "viewsms.h"ViewSMS::ViewSMS(SMS sms, QString name, QWidget *parent) : QMainWindow(parent){ resize(240,300); setCaption(tr("SMS by ") + "ViewSMS"); //showMaximized(); QToolBar *toolbar = new QToolBar(this); setToolBarsMovable(false); addToolBar(toolbar); toolbar->show(); QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); QAction *reply = new QAction(tr("Reply"), QIconSet(QPixmap("reply.png")), 0, 0, this); connect(reply, SIGNAL(activated()), this, SLOT(reply())); QAction *forward = new QAction(tr("Forward"), QIconSet(QPixmap("forward.png")), 0, 0, this); connect(forward, SIGNAL(activated()), this, SLOT(forward())); QAction *deleteSMS = new QAction(tr("Delete sms"), QIconSet(QPixmap("delete.png")), 0, 0, this); connect(deleteSMS, SIGNAL(activated()), this, SLOT(deleteSMS())); QAction *back = new QAction(tr("Back"), QIconSet(QPixmap("back.png")), 0, 0, this); connect(back, SIGNAL(activated()), this, SLOT(close())); reply->addTo(toolbar); forward->addTo(toolbar); deleteSMS->addTo(toolbar); back->addTo(toolbar); QGridLayout *layout = new QGridLayout(centralWidget); viewText = "<html><body><b>From:</b> " + sms.from() + "<hr><pre>" + sms.body() + "</pre></body></html>"; smsView = new QTextBrowser(centralWidget); smsView->setText( viewText ); layout->addWidget(smsView,0,0); cout << viewText << endl; this->name = name; this->from = sms.from(); this->body = sms.body(); } void ViewSMS::deleteSMS(){ if (QMessageBox::information(this, tr("Sure?"), tr("Do you really want to\ndelete this sms?"), tr("Yes"), tr("No"))) return; QString home = getenv( "HOME" ); QFile f(home + "/.smsbox/dir/inbox/" + name); f.remove(); emit smsDeleted(); close();}void ViewSMS::reply(){ QString replyBody = tr("You wrote:\n"); QTextStream t(body, IO_ReadOnly); while (!t.atEnd()) { replyBody += "> " + t.readLine() + "\n"; } Composer *composer = new Composer(0, from, replyBody); composer->showMaximized(); composer->show();}void ViewSMS::forward(){ QString forwardBody = tr("Begin of the forwarded message:\n\n") + body; Composer *composer = new Composer(0, 0, forwardBody); composer->showMaximized(); composer->show();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -