resultdiagram saving and E-mail sending
authorOmistaja <esal@ubuntu.ubuntu-domain>
Tue, 11 May 2010 15:11:52 +0000 (18:11 +0300)
committerOmistaja <esal@ubuntu.ubuntu-domain>
Tue, 11 May 2010 15:11:52 +0000 (18:11 +0300)
Client/resultdialog.cpp
Client/resultdialog.h
Client/resultdialog.ui

index a5f5d32..1f75c6e 100644 (file)
@@ -14,6 +14,8 @@
 #include <QPainter>
 #include <QPicture>
 #include <QDebug>
+#include <QDesktopServices>
+#include <QUrl>
 
 const int DIAGRAM_WIDTH = 400;
 const int DIAGRAM_HEIGHT = 300;
@@ -114,7 +116,15 @@ void ResultDialog::changeEvent(QEvent *e)
 void ResultDialog::paintEvent(QPaintEvent *)
 {
     setHeaders();
-    QPainter painter(this);
+    //Create Pixmap, where image will be draw
+    QPixmap image(ui->scrollArea->width(), ui->scrollArea->height()/*DIAGRAM_WIDTH+100, DIAGRAM_HEIGHT+70*/);
+       
+    //Create painter and give paramemeter where image will be draw
+    QPainter painter(&image);
+    painter.setPen(Qt::white);
+    painter.setBrush(Qt::white);
+    painter.drawRect(QRect(0, 0, ui->scrollArea->width(), ui->scrollArea->height()/*DIAGRAM_WIDTH+100, DIAGRAM_HEIGHT+70*/));
+    
 
     painter.setRenderHint(QPainter::Antialiasing, true);
     painter.setPen(QPen((Qt::gray),2));
@@ -126,7 +136,7 @@ void ResultDialog::paintEvent(QPaintEvent *)
 
     fontForResult.setPixelSize(50);
     painter.setFont(fontForResult);
-    painter.drawText(diagramStemStart.x() + 50, diagramStemStart.y() - 150, resultString);
+    painter.drawText(diagramStemStart.x() + 30, diagramStemStart.y() - 150, resultString);
     painter.setFont(font);
 
     painter.setPen(QPen((Qt::darkCyan),2));
@@ -198,6 +208,18 @@ void ResultDialog::paintEvent(QPaintEvent *)
     {
         painter.drawPolyline(points, pointsToShow);
     }
+    //Save image in file acceleration.png
+    image.save("acceleration.png", 0, -1);
+
+    //Create label
+    QLabel *imageLabel = new QLabel(this);
+    
+    //Set image pixmap to label
+    imageLabel->setPixmap(image);
+    
+    //Set image label to scrollArea
+    ui->scrollArea->setWidget(imageLabel);
+
 }
 
 /**
@@ -798,4 +820,12 @@ void ResultDialog::killHelpDialog()
         helpAccelerationDialog = NULL;
     }
 }
+/**
+  * This slot function opens E-mail application with attachment file
+  * (acceleration.png). Image of resultdialog
+  */
 
+void ResultDialog::on_pushButtonEMail_clicked()
+{
+    QDesktopServices::openUrl(QUrl("mailto:name@domain.com?Subject=Acceleration Result&Body=Hi, Here are my acceleration result!&Attachment=acceleration.png"));
+}
index 752b790..21b9ff9 100644 (file)
@@ -57,6 +57,7 @@ private:
     QString resultString;
 
 private slots:
+    void on_pushButtonEMail_clicked();
     void on_pushButtonInfo_clicked();
     void on_pushButtonNew_clicked();
     void on_pushButtonSend_clicked();
index 974628a..4431c71 100644 (file)
@@ -70,7 +70,7 @@
     <rect>
      <x>510</x>
      <y>280</y>
-     <width>131</width>
+     <width>81</width>
      <height>71</height>
     </rect>
    </property>
   <widget class="QPushButton" name="pushButtonNew">
    <property name="geometry">
     <rect>
-     <x>660</x>
+     <x>710</x>
      <y>280</y>
-     <width>131</width>
+     <width>81</width>
      <height>71</height>
     </rect>
    </property>
     <string/>
    </property>
    <property name="icon">
-    <iconset resource="graphics.qrc">
+    <iconset>
      <normaloff>:/new/prefix1/Graphics/info.png</normaloff>:/new/prefix1/Graphics/info.png</iconset>
    </property>
    <property name="iconSize">
     </size>
    </property>
   </widget>
+  <widget class="QScrollArea" name="scrollArea">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>501</width>
+     <height>381</height>
+    </rect>
+   </property>
+   <property name="verticalScrollBarPolicy">
+    <enum>Qt::ScrollBarAlwaysOff</enum>
+   </property>
+   <property name="horizontalScrollBarPolicy">
+    <enum>Qt::ScrollBarAlwaysOff</enum>
+   </property>
+   <property name="widgetResizable">
+    <bool>true</bool>
+   </property>
+   <widget class="QWidget" name="scrollAreaWidgetContents">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>0</y>
+      <width>499</width>
+      <height>379</height>
+     </rect>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QPushButton" name="pushButtonEMail">
+   <property name="geometry">
+    <rect>
+     <x>610</x>
+     <y>280</y>
+     <width>81</width>
+     <height>71</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Send E-mail</string>
+   </property>
+  </widget>
  </widget>
- <resources>
-  <include location="graphics.qrc"/>
- </resources>
+ <resources/>
  <connections/>
 </ui>