mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 03:28:41 -07:00
Improvements on the behavior of the program updater(closes #1282):
1. Check for updates every hour 2. Don't check again for this session if the user chose to ignore the new version 3. Display a message if the user checked for updates via the menu item and there isn't one 4. Remove dead code
This commit is contained in:
parent
7428c2c0b1
commit
b7f84dabf5
4 changed files with 25 additions and 80 deletions
|
@ -49,8 +49,8 @@ const QString FILE_EXT = "EXE";
|
|||
|
||||
using namespace libtorrent;
|
||||
|
||||
ProgramUpdater::ProgramUpdater(QObject *parent) :
|
||||
QObject(parent)
|
||||
ProgramUpdater::ProgramUpdater(QObject *parent, bool invokedByUser) :
|
||||
QObject(parent), m_invokedByUser(invokedByUser)
|
||||
{
|
||||
mp_manager = new QNetworkAccessManager(this);
|
||||
Preferences pref;
|
||||
|
@ -140,7 +140,7 @@ void ProgramUpdater::rssDownloadFinished(QNetworkReply *reply)
|
|||
}
|
||||
}
|
||||
}
|
||||
emit updateCheckFinished(!m_updateUrl.isEmpty(), new_version);
|
||||
emit updateCheckFinished(!m_updateUrl.isEmpty(), new_version, m_invokedByUser);
|
||||
// Clean up
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
@ -150,50 +150,8 @@ void ProgramUpdater::updateProgram()
|
|||
Q_ASSERT(!m_updateUrl.isEmpty());
|
||||
QDesktopServices::openUrl(m_updateUrl);
|
||||
return;
|
||||
/*connect(mp_manager, SIGNAL(finished(QNetworkReply*)),
|
||||
this, SLOT(saveUpdate(QNetworkReply*)));
|
||||
// Send the request
|
||||
mp_manager->get(QNetworkRequest(QUrl(m_updateUrl)));*/
|
||||
}
|
||||
|
||||
/*void ProgramUpdater::saveUpdate(QNetworkReply *reply)
|
||||
{
|
||||
// Disconnect SIGNAL/SLOT
|
||||
disconnect(mp_manager, 0, this, 0);
|
||||
// Process the download
|
||||
if (!reply->error()) {
|
||||
// Save the file
|
||||
const QString installer_path = QDir::temp().absoluteFilePath("qbittorrent_update."+FILE_EXT.toLower());
|
||||
QFile update_installer(installer_path);
|
||||
if (update_installer.exists()) {
|
||||
update_installer.remove();
|
||||
}
|
||||
if (update_installer.open(QIODevice::WriteOnly)) {
|
||||
update_installer.write(reply->readAll());
|
||||
reply->close();
|
||||
update_installer.close();
|
||||
// Install the update
|
||||
installUpdate(installer_path);
|
||||
} else {
|
||||
emit updateInstallFinished(tr("Could not create the file %1").arg(installer_path));
|
||||
}
|
||||
} else {
|
||||
emit updateInstallFinished(tr("Failed to download the update at %1", "%1 is an URL").arg(m_updateUrl));
|
||||
}
|
||||
reply->deleteLater();
|
||||
deleteLater();
|
||||
}*/
|
||||
|
||||
/*void ProgramUpdater::installUpdate(QString update_path)
|
||||
{
|
||||
qDebug("Installing the update at %s...", qPrintable(update_path));
|
||||
#ifdef Q_WS_WIN
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///")+update_path, QUrl::TolerantMode));
|
||||
#else
|
||||
QDesktopServices::openUrl(QUrl(QString("file://")+update_path, QUrl::TolerantMode));
|
||||
#endif
|
||||
}*/
|
||||
|
||||
// title on Windows: /qbittorrent-win32/qbittorrent-2.4.7/qbittorrent_2.4.7_setup.exe
|
||||
// title on Mac: /qbittorrent-mac/qbittorrent-2.4.4/qbittorrent-2.4.4.dmg
|
||||
QString ProgramUpdater::extractVersionNumber(const QString& title) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue