提交 3c1488bc 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add a auto mkpath method

Signed-off-by: 丁劲犇's avatargoldenhawking <goldenhawking@163.com>
上级 fd56a8f3
......@@ -406,12 +406,27 @@ void osm_frame_widget::on_pushButton_saveToFile_clicked()
{
QSettings settings(QCoreApplication::applicationFilePath()+".ini",QSettings::IniFormat);
QString strLastSaveImgDir = settings.value("history/last_save_img_dir","./").toString();
QString newfm = QFileDialog::getSaveFileName(this,tr("save to image"),strLastSaveImgDir,
QString strDefaultFilename = "Image_" +
QDateTime::currentDateTime()
.toString("yyyyMMddHHmmss") +".png";
QFileDialog dlg_save(this,tr("save to image"),strLastSaveImgDir,
"Images (*.png *.bmp *.jpg);;All files(*.*)"
);
if (newfm.size()>2)
dlg_save.setFileMode(QFileDialog::AnyFile);
dlg_save.setAcceptMode(QFileDialog::AcceptSave);
dlg_save.selectFile(strDefaultFilename);
if (dlg_save.exec()==QDialog::Accepted)
{
if (true == ui->widget_mainMap->saveToImage(newfm))
settings.setValue("history/last_save_img_dir",newfm);
QStringList fms = dlg_save.selectedFiles();
foreach (QString newfm, fms)
{
if (true == ui->widget_mainMap->saveToImage(newfm))
{
QFileInfo info(newfm);
settings.setValue("history/last_save_img_dir",info.absolutePath());
}
}
}
}
......@@ -7,11 +7,9 @@
#include <QVariant>
#include <QMap>
#define OSMLayerInterface_iid "org.goldenhawkingStudio.OSMViewer_iid.LayerInterface"
#define QTVOSM_DEBUG(MSG) qDebug()<<"QTVOSM Debug>"<< MSG <<"\n\t"<<__FUNCTION__<<":"<<__FILE__<<__LINE__
#define QTVOSM_WARNING(MSG) qWarning()<<"QTVOSM Debug>"<< MSG <<"\n\t"<<__FUNCTION__<<":"<<__FILE__<<__LINE__
#define QTVOSM_FATAL(MSG) qFatal()<<"QTVOSM Debug>"<< MSG <<"\n\t"<<__FUNCTION__<<":"<<__FILE__<<__LINE__
class osm_frame_widget;
class qtaxviewer_planetosm;
class qtwidget_planetosm;
......
......@@ -5,6 +5,8 @@
#include <QDebug>
#include <math.h>
#include <QPixmap>
#include <QFileInfo>
#include <QDir>
#include "layer_interface.h"
namespace QTVOSM{
tilesviewer::tilesviewer(QWidget *parent) :
......@@ -986,6 +988,9 @@ namespace QTVOSM{
bool tilesviewer::saveToImage(const QString & strFm)
{
QFileInfo info(strFm);
QDir dir;
dir.mkpath(info.absolutePath());
QPixmap m = this->grab();
return m.save(strFm);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册