| 2250 | } |
| 2251 | |
| 2252 | void MainWindow::replyFinished(QNetworkReply *reply) { |
| 2253 | reply->deleteLater(); |
| 2254 | if (reply->error()) { |
| 2255 | mUI->mLayoutInformation->deleteLater(); |
| 2256 | qDebug() << "Response: ERROR"; |
| 2257 | return; |
| 2258 | } |
| 2259 | const QString str = reply->readAll(); |
| 2260 | qDebug() << "Response: " << str; |
| 2261 | if (reply->url().fileName() == "version.txt") { |
| 2262 | // TODO: lacks extra version |
| 2263 | QString nameWithVersion = QString("Cppcheck %1").arg(CppCheck::version()); |
| 2264 | // TODO: this should not contain the version |
| 2265 | if (!mCppcheckCfgProductName.isEmpty()) |
| 2266 | nameWithVersion = mCppcheckCfgProductName; |
| 2267 | const int appVersion = getVersion(nameWithVersion); |
| 2268 | const int latestVersion = getVersion(str.trimmed()); |
| 2269 | if (appVersion < latestVersion) { |
| 2270 | if (mSettings->value(SETTINGS_CHECK_VERSION, 0).toInt() != latestVersion) { |
| 2271 | QString install; |
| 2272 | if (isCppcheckPremium()) { |
| 2273 | #ifdef Q_OS_WIN |
| 2274 | const QString url("https://cppchecksolutions.com/cppcheck-premium-installation"); |
| 2275 | #else |
| 2276 | const QString url("https://cppchecksolutions.com/cppcheck-premium-linux-installation"); |
| 2277 | #endif |
| 2278 | install = "<a href=\"" + url + "\">" + tr("Install") + "</a>"; |
| 2279 | } |
| 2280 | mUI->mButtonHideInformation->setVisible(true); |
| 2281 | mUI->mLabelInformation->setVisible(true); |
| 2282 | mUI->mLabelInformation->setText(tr("New version available: %1. %2").arg(str.trimmed()).arg(install)); |
| 2283 | } |
| 2284 | } |
| 2285 | } |
| 2286 | if (!mUI->mLabelInformation->isVisible()) { |
| 2287 | mUI->mLayoutInformation->deleteLater(); |
| 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | void MainWindow::hideInformation() { |
| 2292 | int version = getVersion(mUI->mLabelInformation->text()); |