Changeset 20015b41e7 in tspsg
- Timestamp:
- Apr 27, 2010, 9:12:55 AM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 5d401f2c50
- Parents:
- ca3d2a30fa
- git-author:
- Oleksii Serdiuk <contacts@…> (04/27/10 09:12:55)
- git-committer:
- Oleksii Serdiuk <contacts@…> (06/29/12 19:41:31)
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/defaults.h
rca3d2a30fa r20015b41e7 67 67 //! Default for "Show solution graph" 68 68 #define DEF_SHOW_GRAPH true 69 /*! 70 * \def DEF_GRAPH_IMAGE_FORMAT 71 * \brief Default for "Save solution graph as" 72 */ 73 #if !defined(NOSVG) && (QT_VERSION >= 0x040500) 74 #define DEF_GRAPH_IMAGE_FORMAT "svg" 75 #else 76 #define DEF_GRAPH_IMAGE_FORMAT "png" 77 #endif // NOSVG && QT_VERSION >= 0x040500 69 78 //! Default for "Show solution steps' matrices for every solution step" 70 79 #define DEF_SHOW_MATRIX true -
src/globals.h
rca3d2a30fa r20015b41e7 32 32 #include <QtCore> 33 33 #include <QtGui> 34 #include <QtSvg> 34 #if !defined(NOSVG) && (QT_VERSION >= 0x040500) 35 #include <QtSvg> 36 #endif // NOSVG && QT_VERSION >= 0x040500 35 37 36 38 // Version info -
src/main.cpp
rca3d2a30fa r20015b41e7 33 33 #endif 34 34 35 #ifdef STATIC_BUILD36 Q_IMPORT_PLUGIN(qjpeg)37 Q_IMPORT_PLUGIN(qsvg)38 #endif35 //#ifdef STATIC_BUILD 36 // Q_IMPORT_PLUGIN(qjpeg) 37 // Q_IMPORT_PLUGIN(qtiff) 38 //#endif 39 39 40 40 int main(int argc, char *argv[]) … … 47 47 app.setOrganizationName("Oleksii \"Lёppa\" Serdiuk"); 48 48 app.setOrganizationDomain("oleksii.name"); 49 app.setApplicationName("TSPSG ");49 app.setApplicationName("TSPSG: TSP Solver and Generator"); 50 50 app.setApplicationVersion(BUILD_VERSION); 51 51 -
src/mainwindow.cpp
rca3d2a30fa r20015b41e7 226 226 } 227 227 QFileInfo fi(selectedFile); 228 QString format = settings->value("Output/GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT).toString(); 229 #if !defined(NOSVG) && (QT_VERSION >= 0x040500) 230 if (!QImageWriter::supportedImageFormats().contains(format.toAscii()) && (format != "svg")) { 231 #else // NOSVG && QT_VERSION >= 0x040500 232 if (!QImageWriter::supportedImageFormats().contains(format.toAscii())) { 233 #endif // NOSVG && QT_VERSION >= 0x040500 234 format = DEF_GRAPH_IMAGE_FORMAT; 235 settings->remove("Output/GraphImageFormat"); 236 } 228 237 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"))); 238 img = fi.completeBaseName() + "." + format; 239 html.replace(QRegExp("<img\\s+src=\"tspsg://graph.pic\""), QString("<img src=\"%1\" width=\"%2\" height=\"%3\" alt=\"%4\"").arg(img).arg(graph.width() + 2).arg(graph.height() + 2).arg(tr("Solution Graph"))); 240 231 241 // Saving solution text as HTML 232 242 QTextStream ts(&file); … … 234 244 ts << html; 235 245 file.close(); 236 // Saving solution graph as SVG 246 247 // Saving solution graph as SVG or PNG (depending on settings and SVG support) 248 #if !defined(NOSVG) && (QT_VERSION >= 0x040500) 249 if (format == "svg") { 237 250 QSvgGenerator svg; 238 svg.setFileName(fi.path() + "/" + img); 239 svg.setTitle(tr("Solution Graph")); 251 svg.setSize(QSize(graph.width(), graph.height())); 252 svg.setResolution(graph.logicalDpiX()); 253 svg.setFileName(fi.path() + "/" + img); 254 svg.setTitle(tr("Solution Graph")); 255 svg.setDescription(tr("Generated with %1").arg(QApplication::applicationName())); 240 256 QPainter p; 241 p.begin(&svg); 242 graph.play(&p); 243 p.end(); 257 p.begin(&svg); 258 p.drawPicture(1, 1, graph); 259 p.end(); 260 } else { 261 #endif // NOSVG && QT_VERSION >= 0x040500 262 QImage i(graph.width() + 2, graph.height() + 2, QImage::Format_ARGB32); 263 i.fill(0x00FFFFFF); 264 QPainter p; 265 p.begin(&i); 266 p.drawPicture(1, 1, graph); 267 p.end(); 268 QImageWriter pic(fi.path() + "/" + img); 269 if (pic.supportsOption(QImageIOHandler::Description)) { 270 pic.setText("Title", "Solution Graph"); 271 pic.setText("Software", QApplication::applicationName()); 272 } 273 if (format == "png") 274 pic.setQuality(5); 275 else if (format == "jpeg") 276 pic.setQuality(80); 277 if (!pic.write(i)) { 278 QApplication::restoreOverrideCursor(); 279 QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution graph.\nError: %1").arg(pic.errorString())); 280 return; 281 } 282 #if !defined(NOSVG) && (QT_VERSION >= 0x040500) 283 } 284 #endif // NOSVG && QT_VERSION >= 0x040500 244 285 245 286 // Qt < 4.5 has no QTextDocumentWriter class … … 351 392 title += QString("<b>TSPSG<br>TSP Solver and Generator</b><br>"); 352 393 #else 353 title += QString("<b> TSPSG: TSP Solver and Generator</b><br>");394 title += QString("<b>%1</b><br>").arg(QApplication::applicationName()); 354 395 #endif // HANDHELD 355 396 title += QString("%1: <b>%2</b><br>").arg(tr("Version"), QApplication::applicationVersion()); … … 536 577 pic.begin(&graph); 537 578 pic.setRenderHint(QPainter::Antialiasing); 579 pic.setFont(settings->value("Output/Font", QFont(DEF_FONT_FAMILY, 9)).value<QFont>()); 580 pic.setBrush(QBrush(QColor(Qt::white))); 581 pic.setBackgroundMode(Qt::OpaqueMode); 538 582 } 539 583 … … 805 849 pic.setFont(font); 806 850 } 807 pic.setBackgroundMode(Qt::OpaqueMode);808 851 if (step->price != INFINITY) { 809 852 pic.drawText(QRectF(x - r, y - r, r * 2, r * 2), Qt::AlignCenter, isInteger(step->price) ? QString("\n%1").arg(step->price) : QString("\n%1").arg(step->price, 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt())); … … 811 854 pic.drawText(QRectF(x - r, y - r, r * 2, r * 2), Qt::AlignCenter, "\n"INFSTR); 812 855 } 813 pic.setBackgroundMode(Qt::TransparentMode);814 856 } else { 815 857 pic.drawText(QRectF(x - r, y - r, r * 2, r * 2), Qt::AlignCenter, tr("Root")); -
src/settingsdialog.cpp
rca3d2a30fa r20015b41e7 195 195 settings->beginGroup("Output"); 196 196 cbShowGraph->setChecked(settings->value("ShowGraph", DEF_SHOW_GRAPH).toBool()); 197 198 #if !defined(NOSVG) && (QT_VERSION >= 0x040500) 199 comboGraphImageFormat->addItem("svg"); 200 #endif // NOSVG && QT_VERSION >= 0x040500 201 // We create a whitelist of formats, supported by the most popular web browsers according to 202 // http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support 203 // + TIFF format (there are plugins to support it). 204 QStringList whitelist; 205 whitelist << "bmp" << "jpeg" << "png" << "tiff" << "xbm"; 206 foreach (QByteArray format, QImageWriter::supportedImageFormats()) { 207 if (whitelist.contains(format)) 208 comboGraphImageFormat->addItem(format); 209 } 210 comboGraphImageFormat->model()->sort(0); 211 comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(settings->value("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT).toString(), Qt::MatchFixedString)); 212 if (comboGraphImageFormat->currentIndex() < 0) 213 comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(DEF_GRAPH_IMAGE_FORMAT, Qt::MatchFixedString)); 214 labelGraphImageFormat->setEnabled(cbShowGraph->isChecked()); 215 comboGraphImageFormat->setEnabled(cbShowGraph->isChecked()); 216 197 217 cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool()); 198 218 cbCitiesLimit->setEnabled(cbShowMatrix->isChecked()); … … 252 272 settings->setValue("SettingsReset", true); 253 273 QDialog::accept(); 254 QMessageBox::information(this , tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now."));274 QMessageBox::information(this->parentWidget(), tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now.")); 255 275 return; 256 276 } else … … 282 302 settings->beginGroup("Output"); 283 303 settings->setValue("ShowGraph", cbShowGraph->isChecked()); 304 if (cbShowGraph->isChecked()) { 305 if (comboGraphImageFormat->currentIndex() >= 0) 306 settings->setValue("GraphImageFormat", comboGraphImageFormat->currentText()); 307 else 308 settings->setValue("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT); 309 } 284 310 settings->setValue("ShowMatrix", cbShowMatrix->isChecked()); 285 311 settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked()); -
tspsg.pro
rca3d2a30fa r20015b41e7 11 11 ###################################################################### 12 12 13 QT += svg 13 !nosvg { 14 QT += svg 15 } else { 16 DEFINES += NOSVG 17 } 14 18 15 19 TEMPLATE = app … … 49 53 include($$join(PRL, "/")) 50 54 contains(QMAKE_PRL_CONFIG, static) { 51 # We "embed" SVG and JPEG support on static build 52 QTPLUGIN += qjpeg qsvg 55 # We "embed" JPEG and TIFF support on static build 53 56 DEFINES += STATIC_BUILD 57 # QTPLUGIN += qjpeg qtiff 54 58 } 55 59 … … 76 80 77 81 # Installation and deployment 78 # Common rules 79 l10n.files = l10n/*.qm 80 #share.files = 81 docs.files = COPYING README.txt 82 INSTALLS += target l10n share docs 83 84 # For *nix: 85 # - executable goes to /usr/bin 86 # - COPYING and README go to /usr/share/TSPSG 87 # - translations go to /usr/share/TSPSG/l10n 88 # - docs go to /usr/share/doc/TSPSG-x.x.x 89 unix:!symbian { 90 PREFIX = /usr 91 CONFIG(release, debug|release) { 92 DEFINES += PATH_L10N=\\\"$$PREFIX/share/TSPSG/l10n\\\" 93 DEFINES += PATH_DOCS=\\\"$$PREFIX/share/TSPSG/docs\\\" 94 } 95 96 target.path = $$PREFIX/bin 97 share.path = $$PREFIX/share/TSPSG 98 l10n.path = $$PREFIX/share/TSPSG/l10n 99 docs.path = $$PREFIX/share/doc/TSPSG-$$VERSION 100 apps.files = resources/tspsg.desktop 101 apps.path = $$PREFIX/share/applications/ 102 icon.files = resources/tspsg.png 103 icon.path = $$PREFIX/share/pixmaps 104 INSTALLS += apps icon 105 } 106 107 # TODO: MacOSX 108 109 # For win32: everything goes to "%PROGRAMFILES%\TSPSG" and subfolders. 110 win32 { 111 PREFIX = "$$(PROGRAMFILES)" 112 113 share.files = $$[QT_INSTALL_BINS]/QtCore$${D}4.dll \ 114 $$[QT_INSTALL_BINS]/QtGui$${D}4.dll 115 $$[QT_INSTALL_BINS]/QtSvg$${D}4.dll 116 l10n.files += $$[QT_INSTALL_TRANSLATIONS]/*.qm 117 win32-g++ { 118 share.files += $$[QT_INSTALL_BINS]/mingwm10.dll \ 119 $$[QT_INSTALL_BINS]/libgcc_s_dw2-1.dll 120 } 121 imageformats.files = $$[QT_INSTALL_PLUGINS]/imageformats/qsvg$${D}4.dll \ 122 $$[QT_INSTALL_PLUGINS]/imageformats/qjpeg$${D}4.dll 123 imageformats.path = $$PREFIX/TSPSG/imageformats 124 INSTALLS += imageformats 125 } 126 127 # For wince: we are deploying to \Program Files\TSPSG. 128 wince { 129 PREFIX = "\Program Files" 130 share.sources = $$share.files 131 l10n.sources = $$l10n.files \ 132 $$[QT_INSTALL_TRANSLATIONS]/*.qm 133 docs.sources = $$docs.files 134 135 DEPLOYMENT += target share l10n docs 136 DEPLOYMENT_PLUGIN += qjpeg qsvg 137 } 138 139 # win32 and wince common 140 win* { 141 target.path = $$PREFIX/TSPSG 142 share.path = $$PREFIX/TSPSG 143 l10n.path = $$PREFIX/TSPSG/l10n 144 docs.path = $$PREFIX/TSPSG 145 146 RC_FILE = resources/tspsg.rc 147 } 148 149 # Symbian 150 symbian { 151 # qmake for Symbian (as of Qt 4.6.2) has a bug: file masks doesn't work, so we need to specify all files manually 152 share.sources = $$share.files 153 l10n.sources = $$[QT_INSTALL_TRANSLATIONS]/qt_ru.qm \ 154 $$[QT_INSTALL_TRANSLATIONS]/qt_uk.qm \ 155 l10n/tspsg_en.qm l10n/tspsg_ru.qm l10n/tspsg_uk.qm 156 l10n.path = l10n 157 docs.sources = $$docs.files 158 docs.pkg_prerules = \ 159 "\"README.txt\" - \"\", FILETEXT, TEXTCONTINUE" \ 160 "\"COPYING\" - \"\", FILETEXT, TEXTEXIT" 161 DEPLOYMENT += share l10n docs 162 DEPLOYMENT_PLUGIN += qjpeg qsvg 163 164 ICON = resources/tspsg.svg 165 166 appinfo = \ 167 "$$LITERAL_HASH{\"TSPSG\"},(0xEb9dce0e),$$BUILD_VERSION_MAJOR,$$BUILD_VERSION_MINOR,$$BUILD_RELEASE" 168 vendorinfo = \ 169 "%{\"l-homes.org\"}" \ 170 ":\"l-homes.org\"" 171 default_deployment.pkg_prerules = appinfo vendorinfo 172 DEPLOYMENT.installer_header = "$${LITERAL_HASH}{\"TSPSG Installer\"},(0xA000D7CE),1,0,0" 173 } 82 include(install.pri) -
ui/settingsdialog.ui
rca3d2a30fa r20015b41e7 12 12 </property> 13 13 <widget class="QWidget" name="bgGrey" native="true"> 14 <property name="geometry"> 15 <rect> 16 <x>0</x> 17 <y>0</y> 18 <width>197</width> 19 <height>37</height> 20 </rect> 21 </property> 14 22 <property name="sizePolicy"> 15 23 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> … … 93 101 </widget> 94 102 <widget class="QWidget" name="bgWhite" native="true"> 103 <property name="geometry"> 104 <rect> 105 <x>0</x> 106 <y>0</y> 107 <width>226</width> 108 <height>253</height> 109 </rect> 110 </property> 95 111 <property name="autoFillBackground"> 96 112 <bool>true</bool> … … 165 181 <property name="text"> 166 182 <string>Fractional accuracy:</string> 183 </property> 184 <property name="buddy"> 185 <cstring>spinFractionalAccuracy</cstring> 167 186 </property> 168 187 </widget> … … 302 321 </item> 303 322 <item> 304 <widget class="QCheckBox" name="cbShowMatrix"> 305 <property name="cursor"> 306 <cursorShape>PointingHandCursor</cursorShape> 307 </property> 308 <property name="statusTip"> 309 <string>Show solution steps' matrices for every solution step</string> 310 </property> 311 <property name="text"> 312 <string>Show solution steps' matrices</string> 313 </property> 314 </widget> 315 </item> 316 <item> 317 <layout class="QHBoxLayout" name="layoutCititesLimit"> 323 <layout class="QHBoxLayout" name="_10"> 318 324 <property name="spacing"> 319 <number> 0</number>320 </property> 321 <item> 322 <spacer name="spacer_ 3">325 <number>5</number> 326 </property> 327 <item> 328 <spacer name="spacer_7"> 323 329 <property name="orientation"> 324 330 <enum>Qt::Horizontal</enum> … … 336 342 </item> 337 343 <item> 344 <widget class="QLabel" name="labelGraphImageFormat"> 345 <property name="text"> 346 <string>Save solution graph as</string> 347 </property> 348 <property name="buddy"> 349 <cstring>comboGraphImageFormat</cstring> 350 </property> 351 </widget> 352 </item> 353 <item> 354 <widget class="QComboBox" name="comboGraphImageFormat"> 355 <property name="cursor"> 356 <cursorShape>PointingHandCursor</cursorShape> 357 </property> 358 <property name="statusTip"> 359 <string>What image format to use for graph when saving solution as HTML</string> 360 </property> 361 </widget> 362 </item> 363 <item> 364 <spacer name="horizontalSpacer"> 365 <property name="orientation"> 366 <enum>Qt::Horizontal</enum> 367 </property> 368 <property name="sizeHint" stdset="0"> 369 <size> 370 <width>0</width> 371 <height>0</height> 372 </size> 373 </property> 374 </spacer> 375 </item> 376 </layout> 377 </item> 378 <item> 379 <widget class="QCheckBox" name="cbShowMatrix"> 380 <property name="cursor"> 381 <cursorShape>PointingHandCursor</cursorShape> 382 </property> 383 <property name="statusTip"> 384 <string>Show solution steps' matrices for every solution step</string> 385 </property> 386 <property name="text"> 387 <string>Show solution steps' matrices</string> 388 </property> 389 </widget> 390 </item> 391 <item> 392 <layout class="QHBoxLayout" name="_12"> 393 <property name="spacing"> 394 <number>0</number> 395 </property> 396 <item> 397 <spacer name="spacer_3"> 398 <property name="orientation"> 399 <enum>Qt::Horizontal</enum> 400 </property> 401 <property name="sizeType"> 402 <enum>QSizePolicy::Fixed</enum> 403 </property> 404 <property name="sizeHint" stdset="0"> 405 <size> 406 <width>10</width> 407 <height>0</height> 408 </size> 409 </property> 410 </spacer> 411 </item> 412 <item> 338 413 <widget class="QCheckBox" name="cbCitiesLimit"> 339 414 <property name="cursor"> … … 350 425 <item> 351 426 <widget class="QSpinBox" name="spinCitiesLimit"> 427 <property name="cursor"> 428 <cursorShape>PointingHandCursor</cursorShape> 429 </property> 352 430 <property name="statusTip"> 353 431 <string>Maximum number of cities to show solution steps' matrices</string> … … 512 590 <hints> 513 591 <hint type="sourcelabel"> 514 <x> 80</x>515 <y>1 50</y>592 <x>91</x> 593 <y>107</y> 516 594 </hint> 517 595 <hint type="destinationlabel"> 518 <x> 91</x>519 <y>1 75</y>596 <x>113</x> 597 <y>132</y> 520 598 </hint> 521 599 </hints> … … 528 606 <hints> 529 607 <hint type="sourcelabel"> 530 <x> 80</x>531 <y>1 50</y>608 <x>91</x> 609 <y>107</y> 532 610 </hint> 533 611 <hint type="destinationlabel"> 534 <x> 91</x>535 <y>1 75</y>612 <x>113</x> 613 <y>132</y> 536 614 </hint> 537 615 </hints> … … 544 622 <hints> 545 623 <hint type="sourcelabel"> 546 <x> 91</x>547 <y>1 75</y>624 <x>113</x> 625 <y>132</y> 548 626 </hint> 549 627 <hint type="destinationlabel"> 550 <x>184</x> 551 <y>174</y> 628 <x>183</x> 629 <y>134</y> 630 </hint> 631 </hints> 632 </connection> 633 <connection> 634 <sender>cbShowGraph</sender> 635 <signal>toggled(bool)</signal> 636 <receiver>labelGraphImageFormat</receiver> 637 <slot>setEnabled(bool)</slot> 638 <hints> 639 <hint type="sourcelabel"> 640 <x>113</x> 641 <y>48</y> 642 </hint> 643 <hint type="destinationlabel"> 644 <x>72</x> 645 <y>73</y> 646 </hint> 647 </hints> 648 </connection> 649 <connection> 650 <sender>cbShowGraph</sender> 651 <signal>toggled(bool)</signal> 652 <receiver>comboGraphImageFormat</receiver> 653 <slot>setEnabled(bool)</slot> 654 <hints> 655 <hint type="sourcelabel"> 656 <x>113</x> 657 <y>48</y> 658 </hint> 659 <hint type="destinationlabel"> 660 <x>149</x> 661 <y>73</y> 552 662 </hint> 553 663 </hints>
Note: See TracChangeset
for help on using the changeset viewer.