1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef CARDBOARD_H
- #define CARDBOARD_H
- #include <QDeclarativeItem>
- #include <QGraphicsScene>
- #include <QEvent>
- #include <QMessageService>
- #include <QMessage>
- #include <QDeclarativeView>
- #include <QFile>
- QTM_USE_NAMESPACE
- class CardBoard : public QDeclarativeItem {
- Q_OBJECT
- QDeclarativeView *view;
- public:
- CardBoard(QDeclarativeView *view) : QDeclarativeItem() {
- this->view = view;
- }
- CardBoard() : QDeclarativeItem() {
- this->view = view;
- }
- Q_INVOKABLE void sendMms() {
- QMessageService *pMessageManager = new QMessageService(this);
- QMessage message;
- message.setType(QMessage::Mms);
- message.setBody("Foo");
- QStringList images;
- images << "qrc:/images/1245944_74222603_854.jpg";
- message.appendAttachments(images);
- pMessageManager->compose(message);
- }
- Q_INVOKABLE void sendEmail() {
- QMessageService *pMessageManager = new QMessageService(this);
- QMessage message;
- message.setType(QMessage::Email);
- //message.setSubject("auto test");
- //message.setTo(QMessageAddress(QMessageAddress::Email, "swinkels@o2.pl"));
- QStringList *images = new QStringList();
- images->append("/home/user/MyDocs/Pictures/eCard_email.jpg");
- message.appendAttachments(*images);
- pMessageManager->compose(message);
- //pMessageManager->send(message);
- }
- Q_INVOKABLE bool fileExists(QString fileName) {
- QString fullName = "/home/user/MyDocs/Pictures/" + fileName;
- return QFile::exists(fullName);
- }
- Q_INVOKABLE bool saveJPG(QString fileName) {
- QPixmap pixmap = QPixmap::grabWidget(view);
- if (pixmap.isNull())
- qDebug() << "save pixmap is null";
- else
- qDebug() << "pixmap size:" << pixmap.width() << " x " << pixmap.height();
- QImage image = pixmap.toImage();
- QImage image32 = image.convertToFormat(QImage::Format_RGB32);
- QString fullName = "/home/user/MyDocs/Pictures/" + fileName;
- bool val = image32.save(fullName, "JPG", 80);
- if (val == false)
- qDebug() << "saving failed: " << fullName;
- else
- qDebug() << "saving OK: " << fullName;
- return val;
- }
- };
- #endif // CARDBOARD_H
|