fix: 单元测试更新

Description: 单元测试更新,当前覆盖率67%

Log: 单元测试更新,当前覆盖率67%
Change-Id: I2b56f415c9d98f8efe40c507edd7f23f18c6e36a
This commit is contained in:
liuminghang
2021-06-28 14:38:59 +08:00
parent 10093812cc
commit cb69768a9f
3 changed files with 77 additions and 42 deletions

View File

@ -132,43 +132,24 @@ void ImageView::RotateImage(const int &index)
}
void ImageView::savecurrentPic()
{
QString filename = QFileDialog::getSaveFileName(this, tr("Save Image"), "", tr("Images (*.png *.bmp *.jpg)")); //选择路径
image().save(filename);
}
void ImageView::savecurrentPicAs()
{
QFileDialog fileDialog;
QString fileName = fileDialog.getSaveFileName(this, tr("Open File"), "/home", tr("png"));
if (fileName == "") {
return;
}
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(this, tr("error"), tr("open file error"));
return;
} else {
image().save(fileName, "png");
}
}
void ImageView::openImage(QImage *img)
{
if (!img->isNull() && scene()) {
QPixmap pic = QPixmap::fromImage(*img);
if (!pic.isNull()) {
scene()->clear();
m_pixmapItem = new QGraphicsPixmapItem(pic);
m_pixmapItem->setTransformationMode(Qt::SmoothTransformation);
QRectF rect = m_pixmapItem->boundingRect();
setSceneRect(rect);
scene()->addItem(m_pixmapItem);
fitWindow();
}
}
}
//void ImageView::openImage(QImage *img)
//{
// if (!img->isNull() && scene()) {
// QPixmap pic = QPixmap::fromImage(*img);
// if (!pic.isNull()) {
// scene()->clear();
// m_pixmapItem = new QGraphicsPixmapItem(pic);
// m_pixmapItem->setTransformationMode(Qt::SmoothTransformation);
// QRectF rect = m_pixmapItem->boundingRect();
// setSceneRect(rect);
// scene()->addItem(m_pixmapItem);
// fitWindow();
// }
// }
//}
qreal ImageView::imageRelativeScale() const
{

View File

@ -42,12 +42,8 @@ public slots:
void fitImage();
//旋转图片感觉index角度-为左,+为右
void RotateImage(const int &index);
//保存图片
void savecurrentPic();
//另存为
void savecurrentPicAs();
//打开该图片
void openImage(QImage *img);
// //打开该图片
// void openImage(QImage *img);
//窗口大小改变事件
void resizeEvent(QResizeEvent *event) override;