Changeset 108 in tspsg-svn
- Timestamp:
- Apr 25, 2010, 10:09:26 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/globals.h
r107 r108 32 32 #include <QtCore> 33 33 #include <QtGui> 34 #include <QtSvg> 34 35 35 36 // Version info -
trunk/src/main.cpp
r99 r108 34 34 35 35 #ifdef STATIC_BUILD 36 //Q_IMPORT_PLUGIN(qjpeg)37 //Q_IMPORT_PLUGIN(qsvg)36 Q_IMPORT_PLUGIN(qjpeg) 37 Q_IMPORT_PLUGIN(qsvg) 38 38 #endif 39 39 -
trunk/src/mainwindow.cpp
r107 r108 218 218 } 219 219 #endif 220 if (selectedFile.endsWith(".htm", Qt::CaseInsensitive) || selectedFile.endsWith(".html", Qt::CaseInsensitive)) { 221 QFile file(selectedFile); 222 if (!file.open(QFile::WriteOnly)) { 223 QApplication::restoreOverrideCursor(); 224 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(file.errorString())); 225 return; 226 } 227 QFileInfo fi(selectedFile); 228 QString html = solutionText->document()->toHtml("UTF-8"), 229 img = fi.completeBaseName() + ".svg"; 230 html.replace(QRegExp("<img\\s+src=\"tspsg://graph.pic\""), QString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"%4\"").arg(img).arg(graph.width() + 1).arg(graph.height() + 1).arg(tr("Solution Graph"))); 231 // Saving solution text as HTML 232 QTextStream ts(&file); 233 ts.setCodec(QTextCodec::codecForName("UTF-8")); 234 ts << html; 235 file.close(); 236 // Saving solution graph as SVG 237 QSvgGenerator svg; 238 svg.setFileName(fi.path() + "/" + img); 239 svg.setTitle(tr("Solution Graph")); 240 QPainter p; 241 p.begin(&svg); 242 graph.play(&p); 243 p.end(); 244 245 // Qt < 4.5 has no QTextDocumentWriter class 220 246 #if QT_VERSION >= 0x040500 247 } else { 221 248 QTextDocumentWriter dw(selectedFile); 222 if (!(selectedFile.endsWith(".htm",Qt::CaseInsensitive) || selectedFile.endsWith(".html",Qt::CaseInsensitive) || selectedFile.endsWith(".odt",Qt::CaseInsensitive) || selectedFile.endsWith(".txt",Qt::CaseInsensitive))) 223 dw.setFormat("plaintext"); 224 if (!dw.write(solutionText->document())) 225 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(dw.device()->errorString())); 226 #else // QT_VERSION >= 0x040500 227 // Qt < 4.5 has no QTextDocumentWriter class 228 QFile file(selectedFile); 229 if (!file.open(QFile::WriteOnly)) { 230 QApplication::restoreOverrideCursor(); 231 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(file->errorString())); 232 return; 233 } 234 QTextStream ts(&file); 235 ts.setCodec(QTextCodec::codecForName("UTF-8")); 236 ts << solutionText->document()->toHtml("UTF-8"); 237 file.close(); 249 if (!selectedFile.endsWith(".odt",Qt::CaseInsensitive)) 250 dw.setFormat("plaintext"); 251 if (!dw.write(solutionText->document())) 252 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(dw.device()->errorString())); 238 253 #endif // QT_VERSION >= 0x040500 254 } 239 255 QApplication::restoreOverrideCursor(); 240 256 } -
trunk/tspsg.pro
r104 r108 11 11 ###################################################################### 12 12 13 #QT += svg13 QT += svg 14 14 15 15 TEMPLATE = app … … 50 50 contains(QMAKE_PRL_CONFIG, static) { 51 51 # We "embed" SVG and JPEG support on static build 52 #QTPLUGIN += qjpeg qsvg52 QTPLUGIN += qjpeg qsvg 53 53 DEFINES += STATIC_BUILD 54 54 } … … 113 113 share.files = $$[QT_INSTALL_BINS]/QtCore$${D}4.dll \ 114 114 $$[QT_INSTALL_BINS]/QtGui$${D}4.dll 115 #$$[QT_INSTALL_BINS]/QtSvg$${D}4.dll115 $$[QT_INSTALL_BINS]/QtSvg$${D}4.dll 116 116 l10n.files += $$[QT_INSTALL_TRANSLATIONS]/*.qm 117 117 win32-g++ { … … 134 134 135 135 DEPLOYMENT += target share l10n docs 136 #DEPLOYMENT_PLUGIN += qjpeg qsvg136 DEPLOYMENT_PLUGIN += qjpeg qsvg 137 137 } 138 138 … … 160 160 "\"COPYING\" - \"\", FILETEXT, TEXTEXIT" 161 161 DEPLOYMENT += share l10n docs 162 #DEPLOYMENT_PLUGIN += qjpeg qsvg162 DEPLOYMENT_PLUGIN += qjpeg qsvg 163 163 164 164 ICON = resources/tspsg.svg
Note: See TracChangeset
for help on using the changeset viewer.