refactoring if-else, busy cursor while waiting for pdftops, error msg box added
--HG-- branch : develop
This commit is contained in:
parent
c1191c4e9d
commit
2b7570e886
|
@ -205,35 +205,37 @@ void TableWindow::saveScene()
|
||||||
tableScene->clearSelection(); // Selections would also render to the file, so need delete them
|
tableScene->clearSelection(); // Selections would also render to the file, so need delete them
|
||||||
shadowPaper->setVisible(false);
|
shadowPaper->setVisible(false);
|
||||||
QFileInfo fi( name );
|
QFileInfo fi( name );
|
||||||
if (fi.suffix() == "svg")
|
QStringList suffix;
|
||||||
{
|
suffix << "svg" << "png" << "pdf" << "eps" << "ps";
|
||||||
|
switch (suffix.indexOf(fi.suffix())) {
|
||||||
|
case 0:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
SvgFile(name);
|
SvgFile(name);
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
}
|
break;
|
||||||
else if (fi.suffix() == "png")
|
case 1:
|
||||||
{
|
|
||||||
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
||||||
PngFile(name);
|
PngFile(name);
|
||||||
paper->setPen(QPen(Qt::black, widthMainLine));
|
paper->setPen(QPen(Qt::black, widthMainLine));
|
||||||
}
|
break;
|
||||||
else if (fi.suffix() == "pdf")
|
case 2:
|
||||||
{
|
|
||||||
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
||||||
PdfFile(name);
|
PdfFile(name);
|
||||||
paper->setPen(QPen(Qt::black, widthMainLine));
|
paper->setPen(QPen(Qt::black, widthMainLine));
|
||||||
}
|
break;
|
||||||
else if (fi.suffix() == "eps")
|
case 3:
|
||||||
{
|
|
||||||
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
||||||
EpsFile(name);
|
EpsFile(name);
|
||||||
paper->setPen(QPen(Qt::black, widthMainLine));
|
paper->setPen(QPen(Qt::black, widthMainLine));
|
||||||
}
|
break;
|
||||||
else if (fi.suffix() == "ps")
|
case 4:
|
||||||
{
|
|
||||||
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
|
||||||
PsFile(name);
|
PsFile(name);
|
||||||
paper->setPen(QPen(Qt::black, widthMainLine));
|
paper->setPen(QPen(Qt::black, widthMainLine));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qWarning() << "Bad file suffix in TableWindow::saveScene().";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
brush->setColor( QColor( Qt::gray ) );
|
brush->setColor( QColor( Qt::gray ) );
|
||||||
brush->setStyle( Qt::SolidPattern );
|
brush->setStyle( Qt::SolidPattern );
|
||||||
|
@ -492,9 +494,24 @@ void TableWindow::EpsFile(const QString &name) const
|
||||||
#endif
|
#endif
|
||||||
params << "-eps" << tmp.fileName() << name;
|
params << "-eps" << tmp.fileName() << name;
|
||||||
|
|
||||||
proc.start(program,params);
|
#ifndef QT_NO_CURSOR
|
||||||
proc.waitForFinished();
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
#endif
|
||||||
|
proc.start(program, params);
|
||||||
|
proc.waitForFinished(15000);
|
||||||
|
#ifndef QT_NO_CURSOR
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
#endif
|
||||||
qDebug() << proc.errorString();
|
qDebug() << proc.errorString();
|
||||||
|
|
||||||
|
QFile F(name);
|
||||||
|
if(!F.exists())
|
||||||
|
{
|
||||||
|
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
|
||||||
|
"Creating file '"+name+"' failed!",
|
||||||
|
QMessageBox::Ok | QMessageBox::Default);
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,8 +532,23 @@ void TableWindow::PsFile(const QString &name) const
|
||||||
#endif
|
#endif
|
||||||
params << tmp.fileName() << name;
|
params << tmp.fileName() << name;
|
||||||
|
|
||||||
proc.start(program,params);
|
#ifndef QT_NO_CURSOR
|
||||||
proc.waitForFinished();
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
#endif
|
||||||
|
proc.start(program, params);
|
||||||
|
proc.waitForFinished(15000);
|
||||||
|
#ifndef QT_NO_CURSOR
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
#endif
|
||||||
qDebug() << proc.errorString();
|
qDebug() << proc.errorString();
|
||||||
|
|
||||||
|
QFile F(name);
|
||||||
|
if(!F.exists())
|
||||||
|
{
|
||||||
|
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
|
||||||
|
"Creating file '"+name+"' failed!",
|
||||||
|
QMessageBox::Ok | QMessageBox::Default);
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user