yangjingjing 5 年之前
父節點
當前提交
c8aa635d29
共有 6 個文件被更改,包括 44 次插入33 次删除
  1. 3 3
      ImageEdit.cpp
  2. 18 16
      MainPaintScene.cpp
  3. 2 2
      imagecropperdemo.cpp
  4. 9 6
      reporting.cpp
  5. 6 3
      reporting.ui
  6. 6 3
      ui_reporting.h

+ 3 - 3
ImageEdit.cpp

@@ -192,9 +192,9 @@ void ImageEdit::on_pbt_Green_clicked()
 void ImageEdit::imageSave()
 {
     QString filename1 = QFileDialog::getSaveFileName(this,tr("保存图片"),"",tr("Images (*.jpg)")); //选择路径
-    //    QPixmap pixmap(_mainPaintScene->sceneRect().width(),1378);
-    QPixmap pixmap(_mainPaintScene->sceneRect().width(),_mainPaintScene->sceneRect().height());
-    //    QPixmap fitpixmap = pixmap.scaled(1083, 1378, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 饱满填充
+        QPixmap pixmap(_mainPaintScene->sceneRect().width(),1378);
+//    QPixmap pixmap(_mainPaintScene->sceneRect().width(),_mainPaintScene->sceneRect().height());
+//    QPixmap fitpixmap = pixmap.scaled(1083, 1378, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 饱满填充
     pixmap.fill(Qt::white);
     qDebug()<<_mainPaintScene->sceneRect().width()<<_mainPaintScene->sceneRect().height();
     qDebug()<<_mainPaintScene->width()<<_mainPaintScene->height();

+ 18 - 16
MainPaintScene.cpp

@@ -50,24 +50,26 @@ void MainPaintScene::SetBackGroundImage(QString path)
     this->clear();
     //this->addRect(0,0,initWidth,initHeight,QPen(Qt::green),QBrush(Qt::red));
     QPixmap pixmap =QPixmap::fromImage(QImage(path));
-    double dpiX = QApplication::desktop()->physicalDpiX();
-    double dpiY = QApplication::desktop()->physicalDpiY();
-    int physicalX=(int)(dpiX*5.5/2.54+0.5f);
-    int physicalY=(int)(dpiY*7/2.54+0.5f);
-    QPixmap fitpixmap = pixmap.scaled(physicalX, physicalY, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 饱满填充
-//    QPixmap fitpixmap = pixmap.scaled(1083, 1378, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 饱满填充
+//    double dpiX = QApplication::desktop()->physicalDpiX();
+//    double dpiY = QApplication::desktop()->physicalDpiY();
+//    int physicalX=(int)(dpiX*5.5/2.54+0.5f);
+//    int physicalY=(int)(dpiY*7/2.54+0.5f);
+//    QPixmap fitpixmap = pixmap.scaled(physicalX, physicalY, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 饱满填充
+        QPixmap fitpixmap = pixmap.scaled(1083, 1378, Qt::KeepAspectRatio, Qt::SmoothTransformation);  // 饱满填充
     QGraphicsPixmapItem* _backGroundItem= this->addPixmap(fitpixmap);
 
-    //    if(pixmap.width()>pixmap.height())
-    //    {
-    //        //匹配宽度
-    //        _backGroundItem->setScale( initWidth/pixmap.width() );
-    //    }
-    //    else//匹配高度
-    //    {
-    //        _backGroundItem->setScale( initHeight /pixmap.height() );
-    //    }
-    _backGroundItem->setPos(0,0);
+//            if(pixmap.width()>pixmap.height())
+//            {
+//                //匹配宽度
+//                _backGroundItem->setScale( initWidth/pixmap.width() );
+//            }
+//            else//匹配高度
+//            {
+//                _backGroundItem->setScale( initHeight /pixmap.height() );
+//            }
+
+
+    _backGroundItem->setPos(392,0);
 
 }
 

+ 2 - 2
imagecropperdemo.cpp

@@ -476,9 +476,9 @@ void ImageCropperDemo::onSaveCroppedImage() {
     QString filename = QFileDialog::getSaveFileName(this, "保存图片", "", "picture (*.png)");
     if (!filename.isNull()) {
         if (imgCropperLabel->getCroppedImage().save(filename, "PNG"))
-            QMessageBox::information(this, "Prompt", "保存成功!", QMessageBox::Ok);
+            QMessageBox::information(this, "提示", "保存成功!", QMessageBox::Ok);
         else
-            QMessageBox::information(this, "Error", "保存失败!", QMessageBox::Ok);
+            QMessageBox::information(this, "错误", "保存失败!", QMessageBox::Ok);
     }
 }
 

+ 9 - 6
reporting.cpp

@@ -77,7 +77,7 @@ void Reporting::fileSave(){
     // 获取所有的工作文档
     QAxObject * documents = word->querySubObject("Documents");
     // 以文件testTemplate.dot为模版新建一个文档,注意这里的路径为绝对路径
-    QDir dir(".");
+//    QDir dir(".");
     documents->dynamicCall("Add(QString)",templatePath);
     // 获取当前激活的文档
     QAxObject *document=word->querySubObject("ActiveDocument");
@@ -331,6 +331,7 @@ void Reporting::fileSave(){
     document->dynamicCall("SaveAs (const QString&)", outFileName);
     document->dynamicCall("Close (boolean)", true);  //关闭文本窗口
     word->dynamicCall("Quit(void)");  //退出word
+
     QMessageBox::information(this, tr("消息"),tr("报告生成成功!"),QMessageBox::Ok);
     //    delete bookmark_text;
     delete document;
@@ -352,7 +353,7 @@ void Reporting::on_zp1Button_clicked()
     fileDialog->setFileMode(QFileDialog::ExistingFiles);
     //设置视图模式
     fileDialog->setViewMode(QFileDialog::Detail);
-    ui->zp1Edit->setText(QString(fileDialog->getOpenFileName()));
+    ui->zp1Edit->setText(QString(QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("Images (*.png *.xpm *.jpg)"))));
 }
 
 void Reporting::on_zp2Button_clicked()
@@ -369,7 +370,7 @@ void Reporting::on_zp2Button_clicked()
     fileDialog->setFileMode(QFileDialog::ExistingFiles);
     //设置视图模式
     fileDialog->setViewMode(QFileDialog::Detail);
-    ui->zp2Edit->setText(QString(fileDialog->getOpenFileName()));
+    ui->zp2Edit->setText(QString(QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("Images (*.png *.xpm *.jpg)"))));
 }
 
 void Reporting::on_pushButton_3_clicked()
@@ -386,7 +387,7 @@ void Reporting::on_pushButton_3_clicked()
     fileDialog->setFileMode(QFileDialog::ExistingFiles);
     //设置视图模式
     fileDialog->setViewMode(QFileDialog::Detail);
-    ui->zp3Edit->setText(QString(fileDialog->getOpenFileName()));
+    ui->zp3Edit->setText(QString(QString(QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("Images (*.png *.xpm *.jpg)")))));
 }
 
 void Reporting::on_zp4Button_clicked()
@@ -403,7 +404,7 @@ void Reporting::on_zp4Button_clicked()
     fileDialog->setFileMode(QFileDialog::ExistingFiles);
     //设置视图模式
     fileDialog->setViewMode(QFileDialog::Detail);
-    ui->zp4Edit->setText(QString(fileDialog->getOpenFileName()));
+    ui->zp4Edit->setText(QString(QString(QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("Images (*.png *.xpm *.jpg)")))));
 }
 
 void Reporting::openAction()
@@ -420,5 +421,7 @@ void Reporting::openAction()
     fileDialog->setFileMode(QFileDialog::ExistingFiles);
     //设置视图模式
     fileDialog->setViewMode(QFileDialog::Detail);
-    templatePath=QString(fileDialog->getOpenFileName());
+    templatePath=QString(QString(QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("dot(*.dot)"))));
+    if(templatePath!=nullptr)
+     QMessageBox::information(this, tr("消息"),tr("模板加载成功!"),QMessageBox::Ok);
 }

+ 6 - 3
reporting.ui

@@ -840,10 +840,10 @@
      <normaloff>:/new/prefix1/images/save.png</normaloff>:/new/prefix1/images/save.png</iconset>
    </property>
    <property name="text">
-    <string>保存</string>
+    <string>生成报告</string>
    </property>
    <property name="toolTip">
-    <string>保存</string>
+    <string>生成报告</string>
    </property>
   </action>
   <action name="openAction">
@@ -852,7 +852,10 @@
      <normaloff>:/new/prefix1/images/open.ico</normaloff>:/new/prefix1/images/open.ico</iconset>
    </property>
    <property name="text">
-    <string>打开模板</string>
+    <string>加载模板</string>
+   </property>
+   <property name="toolTip">
+    <string>加载模板</string>
    </property>
   </action>
  </widget>

+ 6 - 3
ui_reporting.h

@@ -326,11 +326,14 @@ public:
     void retranslateUi(QWidget *Reporting)
     {
         Reporting->setWindowTitle(QApplication::translate("Reporting", "Form", nullptr));
-        saveAction->setText(QApplication::translate("Reporting", "\344\277\235\345\255\230", nullptr));
+        saveAction->setText(QApplication::translate("Reporting", "\347\224\237\346\210\220\346\212\245\345\221\212", nullptr));
 #ifndef QT_NO_TOOLTIP
-        saveAction->setToolTip(QApplication::translate("Reporting", "\344\277\235\345\255\230", nullptr));
+        saveAction->setToolTip(QApplication::translate("Reporting", "\347\224\237\346\210\220\346\212\245\345\221\212", nullptr));
+#endif // QT_NO_TOOLTIP
+        openAction->setText(QApplication::translate("Reporting", "\345\212\240\350\275\275\346\250\241\346\235\277", nullptr));
+#ifndef QT_NO_TOOLTIP
+        openAction->setToolTip(QApplication::translate("Reporting", "\345\212\240\350\275\275\346\250\241\346\235\277", nullptr));
 #endif // QT_NO_TOOLTIP
-        openAction->setText(QApplication::translate("Reporting", "\346\211\223\345\274\200\346\250\241\346\235\277", nullptr));
         label->setText(QApplication::translate("Reporting", "\347\211\251\350\257\201\351\211\264\345\256\232\344\271\246", nullptr));
         label_2->setText(QApplication::translate("Reporting", "\350\213\217\345\205\254\345\247\221\347\211\251\351\211\264\357\274\210\347\227\225\346\243\200\357\274\211\345\255\227", nullptr));
         label_3->setText(QApplication::translate("Reporting", "\345\217\267", nullptr));