| 613 | } |
| 614 | |
| 615 | void |
| 616 | IDE::versionCheckFinished(void) { |
| 617 | if (versionCheckReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()==200) { |
| 618 | QString currentVersion = versionCheckReply->readAll(); |
| 619 | |
| 620 | QRegularExpression versionRegExp("([1-9][0-9]*)\\.([0-9]+)\\.([0-9]+)"); |
| 621 | |
| 622 | int curVersionMajor = 0; |
| 623 | int curVersionMinor = 0; |
| 624 | int curVersionPatch = 0; |
| 625 | bool ok = true; |
| 626 | QRegularExpressionMatch curVersionMatch = versionRegExp.match(currentVersion); |
| 627 | if (curVersionMatch.hasMatch()) { |
| 628 | curVersionMajor = curVersionMatch.captured(1).toInt(&ok); |
| 629 | if (ok) |
| 630 | curVersionMinor = curVersionMatch.captured(2).toInt(&ok); |
| 631 | if (ok) |
| 632 | curVersionPatch = curVersionMatch.captured(3).toInt(&ok); |
| 633 | } |
| 634 | |
| 635 | int appVersionMajor = 0; |
| 636 | int appVersionMinor = 0; |
| 637 | int appVersionPatch = 0; |
| 638 | QRegularExpressionMatch appVersionMatch = versionRegExp.match(applicationVersion()); |
| 639 | if (ok && appVersionMatch.hasMatch()) { |
| 640 | appVersionMajor = appVersionMatch.captured(1).toInt(&ok); |
| 641 | if (ok) |
| 642 | appVersionMinor = appVersionMatch.captured(2).toInt(&ok); |
| 643 | if (ok) |
| 644 | appVersionPatch = appVersionMatch.captured(3).toInt(&ok); |
| 645 | } |
| 646 | |
| 647 | bool needUpdate = ok && (curVersionMajor > appVersionMajor || |
| 648 | (curVersionMajor==appVersionMajor && |
| 649 | (curVersionMinor > appVersionMinor || |
| 650 | (curVersionMinor==appVersionMinor && |
| 651 | curVersionPatch > appVersionPatch)))); |
| 652 | |
| 653 | if (needUpdate) { |
| 654 | int button = QMessageBox::information(nullptr,"Update available", |
| 655 | "Version "+currentVersion+" of MiniZinc is now available. " |
| 656 | "You are currently using version "+applicationVersion()+ |
| 657 | ".\nDo you want to open the MiniZinc web site?", |
| 658 | QMessageBox::Cancel|QMessageBox::Ok,QMessageBox::Ok); |
| 659 | if (button==QMessageBox::Ok) { |
| 660 | QDesktopServices::openUrl(QUrl("http://www.minizinc.org/")); |
| 661 | } |
| 662 | } |
| 663 | QSettings settings; |
| 664 | settings.beginGroup("ide"); |
| 665 | settings.setValue("lastCheck21",QDate::currentDate().toString()); |
| 666 | settings.endGroup(); |
| 667 | stats.resetCounts(); |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | QString IDE::appDir(void) const { |
| 672 | #ifdef Q_OS_MAC |
nothing calls this directly
no test coverage detected