Commit 51bd4179 authored by Cristian Greco's avatar Cristian Greco

Imported Upstream version 3.1.10

parent a4112ddf
......@@ -43,7 +43,7 @@ before_install:
install:
- if [[ "$lt_source" == "from_dist" ]]; then sudo apt-get -qq install libtorrent-rasterbar-dev; fi
- if [[ "$lt_source" == "from_svn" ]]; then cd .. && svn co http://libtorrent.googlecode.com/svn/branches/RC_0_16 ./libtorrent && (cd libtorrent && ./autotool.sh && ./configure $ltconf && sudo make install) && sudo ldconfig /usr/local/lib && cd $TRAVIS_BUILD_DIR ; fi
- if [[ "$lt_source" == "from_svn" ]]; then cd .. && svn co svn://svn.code.sf.net/p/libtorrent/code/branches/RC_0_16 ./libtorrent && (cd libtorrent && ./autotool.sh && ./configure $ltconf && sudo make install) && sudo ldconfig /usr/local/lib && cd $TRAVIS_BUILD_DIR ; fi
script:
- qt-qconf
......
* Sun Sep 21 2014 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v3.1.10
- FEATURE: Allow disabling of OS cache. This will prevent RAM increases on Windows when seeding many files. Closes #1699. (sledgehammer999)
- FEATURE: Add 'Completed' column. Closes #1241. (sledgehammer999)
- FEATURE: Added 'Ratio Limit' column. Closes #936. (sledgehammer999)
- FEATURE: Add 'Open' and 'Open Containing Folder' entries in the content's right-click menu. Closes #1143. (sledgehammer999)
- FEATURE: Don't listen on IPv6 address by default. Prevents network connectivity problems. Closes #1880. (sledgehammer999)
- FEATURE: Added 'Shutdown now' button in shutdown confirmation dialog. Closes #969. (sledgehammer999)
- FEATURE: Add peer port column to PeerListWidget. Closes #1650. (Ivanov Juriy)
- COSMETIC: Fix weird ratio values when torrent was imported or downloaded history was lost due to crash. (sledgehammer999)
- COSMETIC: Use 'μTP' instead of 'uTP'. (sledgehammer999)
- COSMETIC: Show the loaded torrents in the transferlist when qBT is launched with a torrent/magnet and the AddNewTorrentDialog is showing. Closes #1564. (sledgehammer999)
- COSMETIC: Don't mix finished/unifinished torrents when sorting by ETA. Closes #1688. (sledgehammer999)
- COSMETIC: Sort finished torrents by completed date when sorting by queue number. (sledgehammer999)
- COSMETIC: Right align numerical values in the transfer list. Partially revert 51a9a9aab. Closes #1903. (sledgehammer999)
- COSMETIC: Don't display the Search Engine tab by default. (sledgehammer999)
- WINDOWS: Correctly associate torrents and magnet links with qBittorrent under non-admin accounts. Closes #291 #527 #579 #614 #964. (glassez, sledgehammer999)
- WINDOWS: Check for python before creating the search engine tab. Prevents the creation of python specific files in the user's PC if no python is found. Closes #1370. (sledgehammer999)
- WINDOWS: Don't create keys in the registry if python isn't found. Closes #1370. (sledgehammer999)
- WINDOWS: Can now correctly detect 64bit and 32bit python installations on 64bit Windows. Closes #1148 #445 #795 #1708. (sledgehammer999)
- WINDOWS: Search first in PATH for python. Closes #956. (sledgehammer999)
- OSX: Enable system tray in MACOSX (Nick Korotysh).
- OSX: Fix headless (nox) build. (sledgehammer999)
- WEBUI: Correctly save/load settings and other improvements (glassez)
- WEBUI: Removed broken 'Report a bug' iframe. Closes #1343 (Benjamin Hutchins)
- WEBUI: Removed broken 'Documentation'. Improves fix for #1343 (Benjamin Hutchins)
- WEBUI: Removed essentially useless 'Visit website' iframe and changed it to a regular link. Improves fix for #1343 (Benjamin Hutchins)
- BUGFIX: Fix RSS feed icon. The tmp file gets deleted in the feed destructor. Closes #1639 (sledgehammer999)
- BUGFIX: fix issue #1674: AddNewTorrentDialog is shown again and again even if checkbox "dont ask me again" is set (Ivan Sorokin)
- BUGFIX: Don't show availability bar for magnet links (Ivan Sorokin)
- BUGFIX: Fix crash when the selected torrent disappears from the transfer list. Closes #1661 (sledgehammer999)
- BUGFIX: Fix tracker announcing problem(hit-and-run) when many torrents are being active. Closes #1571 (sledgehammer999)
- BUGFIX: Count magnet links in the 'downloading' filter and make them prevent system inhibition. Closes #1558 (sledgehammer999)
- BUGFIX: Pick up updated plugins. Closes #1745. (sledgehammer999)
- BUGFIX: Bring mainwindow in front when notification is clicked and other windows are in front. (sledgehammer999)
- BUGFIX: Speedup torrent moving (Ivan Sorokin)
- BUGFIX: Fix bug when moving a torrent before the previous move is completed (Ivan Sorokin)
- BUGFIX: Add option to hibernate computer in Auto-Shutdown menu (Bruno Barbieri)
- BUGFIX: Fix column resizing issues (Bryan Roscoe)
- BUGFIX: Fix possible crashes. Closes #1814. (sledgehammer999)
- BUGFIX: Limit max cache to 1800MiB for 32bits compiled binaries and to 4GiB for other. Closes #1698. (sledgehammer999)
- BUGFIX: Don't localize double numbers in the webui. Closes #1525. (sledgehammer999)
- BUGFIX: Don't shrink transferlist rows when scrolling horizontally. Closes #1613. (sledgehammer999)
- BUGFIX: When qBT is launched with a magnet don't show it in the transferlist while the metadata are being loaded in the background. (sledgehammer999)
- BUGFIX: Show disk space while retrieving metadata. Closes #1693. (sledgehammer999)
- BUGFIX: Don't disable DHT/LSD/UPnP in the GUI when anonymous mode is enabled. (sledgehammer999)
- BUGFIX: Possible fix for crash in RSS code. Closes #1901. (sledgehammer999)
- BUGFIX: Fixed SMTP emailing code (Ivanov Juriy, sledgehammer999)
- BUGFIX: Don't display the context menu in 'Content' and 'HTTP Sources' buttons when no torrent is selected. It prevents crashes. Closes #1906, #1900. (sledgehammer999)
- BUGFIX: Don't translate file extensions. Closes #1907. (sledgehammer999)
- BUGFIX: Fix available disk space label on single file torrents. (sledgehammer999)
- BUGFIX: Show stalled downloads that are uploading under the 'Active' filter. Closes #1654." (sledgehammer999)
- BUGFIX: fix import torrent with "Keep incomplete torrents in:" enabled (lojack5)
- BUGFIX: Send a spoofed user agent for the search engines(fixes some of them) (Martin Janco)
- BUGFIX: Support URLs that redirect to magnet links (Gelmir)
- BUGFIX: Consider queued items before deciding to 'auto-shutdown on downloads completion'. Closes #1942. (sledgehammer999)
* Tue Apr 29 2014 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v3.1.9.2
- OTHER: The v3.1.9.1 Windows build was broken
......
qBittorrent - A BitTorrent client in Qt4
qBittorrent - A BitTorrent client in Qt
------------------------------------------
Description:
[![Build Status](https://travis-ci.org/qbittorrent/qBittorrent.png?branch=v3_1_x)](https://travis-ci.org/qbittorrent/qBittorrent)
********************************
qBittorrent is a bittorrent client programmed in C++ / Qt4 that uses
libtorrent (sometimes called rblibtorrent) by Arvid Norberg.
###Description:
qBittorrent is a bittorrent client programmed in C++ / Qt that uses
libtorrent (sometimes called libtorrent-rasterbar) by Arvid Norberg.
It aims to be a good alternative to all other bittorrent clients
out there. qBittorrent is fast, stable and provides unicode
......@@ -13,13 +14,14 @@ support as well as many features.
This product includes GeoLite data created by MaxMind, available from
http://maxmind.com/
Installation:
********************************
### Installation:
For installation, follow the instructions from INSTALL file, but simple:
```
./configure
make && make install
qbittorrent
```
will install and execute qBittorrent hopefully without any problem.
......@@ -32,9 +34,9 @@ http://wiki.qbittorrent.org
Please report any bug (or feature request) to:
http://bugs.qbittorrent.org
You can also meet me (chris-qBT) on IRC:
#qbittorrent on irc.freenode.net
You can also meet me (sledgehammer_999) on IRC:
`#qbittorrent on irc.freenode.net`
------------------------------------------
Christophe Dumez <chris@qbittorrent.org>
sledgehammer999 <sledgehammer999@qbittorrent.org>
......@@ -46,7 +46,6 @@
#include <QFile>
#include <QUrl>
#include <QMenu>
#include <QTimer>
#include <QFileDialog>
#include <libtorrent/version.hpp>
......@@ -62,6 +61,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
m_hasRenamedFile(false)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
ui->lblMetaLoading->setVisible(false);
ui->progMetaLoading->setVisible(false);
......@@ -125,18 +125,22 @@ void AddNewTorrentDialog::saveState()
settings.setValue("expanded", ui->adv_button->isChecked());
}
void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url)
void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url, QWidget *parent)
{
AddNewTorrentDialog dlg;
if (dlg.loadTorrent(torrent_path, from_url))
dlg.exec();
AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent);
if (dlg->loadTorrent(torrent_path, from_url))
dlg->open();
else
delete dlg;
}
void AddNewTorrentDialog::showMagnet(const QString& link)
void AddNewTorrentDialog::showMagnet(const QString& link, QWidget *parent)
{
AddNewTorrentDialog dlg;
if (dlg.loadMagnet(link))
dlg.exec();
AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent);
if (dlg->loadMagnet(link))
dlg->open();
else
delete dlg;
}
void AddNewTorrentDialog::showEvent(QShowEvent *event) {
......@@ -154,7 +158,7 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show)
if (show) {
ui->adv_button->setText(QString::fromUtf8("▲"));
ui->settings_group->setVisible(true);
ui->info_group->setVisible(m_hasMetadata);
ui->info_group->setVisible(true);
if (m_hasMetadata && (m_torrentInfo->num_files() > 1)) {
ui->content_tree->setVisible(true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
......@@ -231,7 +235,7 @@ bool AddNewTorrentDialog::loadMagnet(const QString &magnet_uri)
setWindowTitle(torrent_name.isEmpty() ? tr("Magnet link") : torrent_name);
QIniSettings settings;
showAdvancedSettings(settings.value("AddNewTorrentDialog/expanded").toBool());
setupTreeview();
// Set dialog position
setdialogPosition();
......@@ -284,24 +288,28 @@ void AddNewTorrentDialog::updateFileNameInSavePaths(const QString &new_filename)
}
}
void AddNewTorrentDialog::updateDiskSpaceLabel()
{
Q_ASSERT(m_hasMetadata);
void AddNewTorrentDialog::updateDiskSpaceLabel() {
// Determine torrent size
qulonglong torrent_size = 0;
if (m_contentModel) {
const std::vector<int> priorities = m_contentModel->model()->getFilesPriorities();
Q_ASSERT(priorities.size() == (uint) m_torrentInfo->num_files());
for (uint i=0; i<priorities.size(); ++i) {
if (priorities[i] > 0)
torrent_size += m_torrentInfo->file_at(i).size;
if (m_hasMetadata) {
if (m_contentModel) {
const std::vector<int> priorities = m_contentModel->model()->getFilesPriorities();
Q_ASSERT(priorities.size() == (uint) m_torrentInfo->num_files());
for (uint i=0; i<priorities.size(); ++i) {
if (priorities[i] > 0)
torrent_size += m_torrentInfo->file_at(i).size;
}
} else {
torrent_size = m_torrentInfo->total_size();
}
} else {
torrent_size = m_torrentInfo->total_size();
}
QString size_string = misc::friendlyUnit(torrent_size);
QString size_string = torrent_size ? misc::friendlyUnit(torrent_size) : QString(tr("Not Available", "This size is unavailable."));
size_string += " (";
size_string += tr("Disk space: %1").arg(misc::friendlyUnit(fsutils::freeDiskSpaceOnPath(ui->save_path_combo->currentText())));
size_string += tr("Disk space: %1").arg(misc::friendlyUnit(fsutils::freeDiskSpaceOnPath(
ui->save_path_combo->itemData(
ui->save_path_combo->currentIndex()).toString())));
size_string += ")";
ui->size_lbl->setText(size_string);
}
......@@ -360,8 +368,7 @@ void AddNewTorrentDialog::onSavePathChanged(int index)
relayout();
// Remember index
old_index = ui->save_path_combo->currentIndex();
if (m_hasMetadata)
updateDiskSpaceLabel();
updateDiskSpaceLabel();
}
void AddNewTorrentDialog::relayout()
......@@ -379,6 +386,8 @@ void AddNewTorrentDialog::renameSelectedFile()
if (selectedIndexes.size() != 1)
return;
const QModelIndex &index = selectedIndexes.first();
if (!index.isValid())
return;
// Ask for new name
bool ok;
const QString new_name_last = AutoExpandableDialog::getText(this, tr("Rename the file"),
......@@ -627,57 +636,63 @@ void AddNewTorrentDialog::setMetadataProgressIndicator(bool visibleIndicator, co
}
void AddNewTorrentDialog::setupTreeview() {
// Set dialog title
setWindowTitle(misc::toQStringU(m_torrentInfo->name()));
if (!m_hasMetadata) {
ui->comment_lbl->setText(tr("Not Available", "This comment is unavailable"));
ui->date_lbl->setText(tr("Not Available", "This date is unavailable"));
}
else {
// Set dialog title
setWindowTitle(misc::toQStringU(m_torrentInfo->name()));
// Set torrent information
QString comment = misc::toQString(m_torrentInfo->comment());
ui->comment_lbl->setText(comment.replace('\n', ' '));
ui->date_lbl->setText(m_torrentInfo->creation_date() ? misc::toQString(*m_torrentInfo->creation_date()) : tr("Not available"));
updateDiskSpaceLabel();
// Set torrent information
QString comment = misc::toQString(m_torrentInfo->comment());
ui->comment_lbl->setText(comment.replace('\n', ' '));
ui->date_lbl->setText(m_torrentInfo->creation_date() ? misc::toQString(*m_torrentInfo->creation_date()) : tr("Not available"));
file_storage fs = m_torrentInfo->files();
file_storage fs = m_torrentInfo->files();
// Populate m_filesList
// Populate m_filesList
for (int i = 0; i < m_torrentInfo->num_files(); ++i) {
#if LIBTORRENT_VERSION_NUM >= 1600
m_filesPath << misc::toQStringU(fs.file_path(m_torrentInfo->file_at(i)));
#else
m_filesPath << misc::toQStringU(m_torrentInfo->file_at(i).path.string());
#endif
}
}
// Prepare content tree
if (fs.num_files() > 1) {
m_contentModel = new TorrentContentFilterModel(this);
connect(m_contentModel->model(), SIGNAL(filteredFilesChanged()), SLOT(updateDiskSpaceLabel()));
ui->content_tree->setModel(m_contentModel);
ui->content_tree->hideColumn(PROGRESS);
m_contentDelegate = new PropListDelegate();
ui->content_tree->setItemDelegate(m_contentDelegate);
connect(ui->content_tree, SIGNAL(clicked(const QModelIndex&)), ui->content_tree, SLOT(edit(const QModelIndex&)));
connect(ui->content_tree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContentTreeMenu(const QPoint&)));
// List files in torrent
m_contentModel->model()->setupModelData(*m_torrentInfo);
if (!m_headerState.isEmpty())
ui->content_tree->header()->restoreState(m_headerState);
// Expand root folder
ui->content_tree->setExpanded(m_contentModel->index(0, 0), true);
} else {
// Update save paths (append file name to them)
// Prepare content tree
if (fs.num_files() > 1) {
m_contentModel = new TorrentContentFilterModel(this);
connect(m_contentModel->model(), SIGNAL(filteredFilesChanged()), SLOT(updateDiskSpaceLabel()));
ui->content_tree->setModel(m_contentModel);
ui->content_tree->hideColumn(PROGRESS);
m_contentDelegate = new PropListDelegate();
ui->content_tree->setItemDelegate(m_contentDelegate);
connect(ui->content_tree, SIGNAL(clicked(const QModelIndex&)), ui->content_tree, SLOT(edit(const QModelIndex&)));
connect(ui->content_tree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContentTreeMenu(const QPoint&)));
// List files in torrent
m_contentModel->model()->setupModelData(*m_torrentInfo);
if (!m_headerState.isEmpty())
ui->content_tree->header()->restoreState(m_headerState);
// Expand root folder
ui->content_tree->setExpanded(m_contentModel->index(0, 0), true);
} else {
// Update save paths (append file name to them)
#if LIBTORRENT_VERSION_NUM >= 1600
QString single_file_relpath = misc::toQStringU(fs.file_path(m_torrentInfo->file_at(0)));
#else
QString single_file_relpath = misc::toQStringU(m_torrentInfo->file_at(0).path.string());
#endif
for (int i=0; i<ui->save_path_combo->count()-1; ++i) {
for (int i=0; i<ui->save_path_combo->count()-1; ++i) {
ui->save_path_combo->setItemText(i, fsutils::toDisplayPath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
}
}
}
QIniSettings settings;
updateDiskSpaceLabel();
showAdvancedSettings(settings.value("AddNewTorrentDialog/expanded").toBool());
// Set dialog position
setdialogPosition();
......
......@@ -53,8 +53,8 @@ class AddNewTorrentDialog : public QDialog
public:
~AddNewTorrentDialog();
static void showTorrent(const QString& torrent_path, const QString& from_url = QString());
static void showMagnet(const QString& torrent_link);
static void showTorrent(const QString& torrent_path, const QString& from_url, QWidget *parent = 0);
static void showMagnet(const QString& torrent_link, QWidget *parent = 0);
protected:
void showEvent(QShowEvent *event);
......
......@@ -122,6 +122,14 @@ void DownloadThread::processDlFinished(QNetworkReply* reply) {
newUrl = reply->url().resolved(newUrl);
const QString newUrlString = newUrl.toString();
qDebug("Redirecting from %s to %s", qPrintable(url), qPrintable(newUrlString));
// Redirect to magnet workaround
if (newUrlString.startsWith("magnet:", Qt::CaseInsensitive)) {
qDebug("Magnet redirect detected.");
reply->abort();
emit magnetRedirect(newUrlString, url);
reply->deleteLater();
return;
}
m_redirectMapping.insert(newUrlString, url);
// redirecting with first cookies
downloadUrl(newUrlString, m_networkManager.cookieJar()->cookiesForUrl(url));
......
......@@ -54,6 +54,7 @@ public:
signals:
void downloadFinished(const QString &url, const QString &file_path);
void downloadFailure(const QString &url, const QString &reason);
void magnetRedirect(const QString &url_new, const QString &url_old);
private slots:
void processDlFinished(QNetworkReply* reply);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -45,7 +45,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.1.9.2</string>
<string>3.1.10</string>
<key>CFBundleSignature</key>
<string>qBit</string>
<key>CFBundleExecutable</key>
......@@ -59,7 +59,7 @@
<key>NSAppleScriptEnabled</key>
<string>YES</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2006-2013 The qBittorrent project</string>
<string>Copyright © 2006-2014 The qBittorrent project</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
......
......@@ -187,7 +187,7 @@ void sigabrtHandler(int) {
// Main
int main(int argc, char *argv[]) {
#ifdef Q_OS_MACX
#if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
if ( QSysInfo::MacintoshVersion > QSysInfo::MV_10_8 )
{
// fix Mac OS X 10.9 (mavericks) font issue
......
......@@ -85,6 +85,9 @@ void qt_mac_set_dock_menu(QMenu *menu);
#include "programupdater.h"
#endif
#include "powermanagement.h"
#ifdef Q_OS_WIN
#include "downloadthread.h"
#endif
using namespace libtorrent;
......@@ -98,7 +101,11 @@ using namespace libtorrent;
*****************************************************/
// Constructor
MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMainWindow(parent), m_posInitialized(false), force_exit(false) {
MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMainWindow(parent), m_posInitialized(false), force_exit(false)
#ifdef Q_OS_WIN
, has_python(false)
#endif
{
setupUi(this);
Preferences pref;
......@@ -249,9 +256,10 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
actionRSS_Reader->setChecked(RssSettings().isRSSEnabled());
actionSearch_engine->setChecked(pref.isSearchEnabled());
actionExecution_Logs->setChecked(pref.isExecutionLogEnabled());
displaySearchTab(actionSearch_engine->isChecked());
displayRSSTab(actionRSS_Reader->isChecked());
on_actionExecution_Logs_triggered(actionExecution_Logs->isChecked());
if (actionSearch_engine->isChecked())
QTimer::singleShot(0, this, SLOT(on_actionSearch_engine_triggered()));
// Auto shutdown actions
QActionGroup * autoShutdownGroup = new QActionGroup(this);
......@@ -260,12 +268,15 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
autoShutdownGroup->addAction(actionAutoExit_qBittorrent);
autoShutdownGroup->addAction(actionAutoShutdown_system);
autoShutdownGroup->addAction(actionAutoSuspend_system);
autoShutdownGroup->addAction(actionAutoHibernate_system);
#if !defined(Q_WS_X11) || defined(QT_DBUS_LIB)
actionAutoShutdown_system->setChecked(pref.shutdownWhenDownloadsComplete());
actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete());
actionAutoHibernate_system->setChecked(pref.hibernateWhenDownloadsComplete());
#else
actionAutoShutdown_system->setDisabled(true);
actionAutoSuspend_system->setDisabled(true);
actionAutoHibernate_system->setDisabled(true);
#endif
actionAutoExit_qBittorrent->setChecked(pref.shutdownqBTWhenDownloadsComplete());
......@@ -447,6 +458,7 @@ void MainWindow::displayRSSTab(bool enable) {
}
void MainWindow::displaySearchTab(bool enable) {
Preferences().setSearchEnabled(enable);
if (enable) {
// RSS tab
if (!searchEngine) {
......@@ -526,12 +538,12 @@ void MainWindow::balloonClicked() {
return;
}
show();
if (isMinimized()) {
if (isMinimized())
showNormal();
}
raise();
activateWindow();
}
raise();
activateWindow();
}
// called when a torrent has finished
......@@ -898,13 +910,13 @@ void MainWindow::dropEvent(QDropEvent *event) {
}
if (file.startsWith("magnet:", Qt::CaseInsensitive)) {
if (useTorrentAdditionDialog)
AddNewTorrentDialog::showMagnet(file);
AddNewTorrentDialog::showMagnet(file, this);
else
QBtSession::instance()->addMagnetUri(file);
} else {
// Local file
if (useTorrentAdditionDialog)
AddNewTorrentDialog::showTorrent(file);
AddNewTorrentDialog::showTorrent(file, QString(), this);
else
QBtSession::instance()->addTorrent(file);
}
......@@ -938,11 +950,10 @@ void MainWindow::on_actionOpen_triggered() {
tr("Open Torrent Files"), settings.value(QString::fromUtf8("MainWindowLastDir"), QDir::homePath()).toString(),
tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
if (!pathsList.empty()) {
const bool useTorrentAdditionDialog = pref.useAdditionDialog();
const uint listSize = pathsList.size();
for (uint i=0; i<listSize; ++i) {
if (useTorrentAdditionDialog)
AddNewTorrentDialog::showTorrent(pathsList.at(i));
if (pref.useAdditionDialog())
AddNewTorrentDialog::showTorrent(pathsList.at(i), QString(), this);
else
QBtSession::instance()->addTorrent(pathsList.at(i));
}
......@@ -985,12 +996,12 @@ void MainWindow::processParams(const QStringList& params) {
}
if (param.startsWith("magnet:", Qt::CaseInsensitive)) {
if (useTorrentAdditionDialog)
AddNewTorrentDialog::showMagnet(param);
AddNewTorrentDialog::showMagnet(param, this);
else
QBtSession::instance()->addMagnetUri(param);
} else {
if (useTorrentAdditionDialog)
AddNewTorrentDialog::showTorrent(param);
AddNewTorrentDialog::showTorrent(param, QString(), this);
else
QBtSession::instance()->addTorrent(param);
}
......@@ -1005,7 +1016,7 @@ void MainWindow::addTorrent(QString path) {
void MainWindow::processDownloadedFiles(QString path, QString url) {
Preferences pref;
if (pref.useAdditionDialog())
AddNewTorrentDialog::showTorrent(path, url);
AddNewTorrentDialog::showTorrent(path, url, this);
else
QBtSession::instance()->addTorrent(path, false, url);
}
......@@ -1013,7 +1024,7 @@ void MainWindow::processDownloadedFiles(QString path, QString url) {
void MainWindow::processNewMagnetLink(const QString& link) {
Preferences pref;
if (pref.useAdditionDialog())
AddNewTorrentDialog::showMagnet(link);
AddNewTorrentDialog::showMagnet(link, this);
else
QBtSession::instance()->addMagnetUri(link);
}
......@@ -1208,7 +1219,7 @@ void MainWindow::downloadFromURLList(const QStringList& url_list) {
}
if (url.startsWith("magnet:", Qt::CaseInsensitive)) {
if (useTorrentAdditionDialog)
AddNewTorrentDialog::showMagnet(url);
AddNewTorrentDialog::showMagnet(url, this);
else
QBtSession::instance()->addMagnetUri(url);
}
......@@ -1327,7 +1338,34 @@ void MainWindow::on_actionRSS_Reader_triggered() {
}
void MainWindow::on_actionSearch_engine_triggered() {
Preferences().setSearchEnabled(actionSearch_engine->isChecked());
#ifdef Q_OS_WIN
if (!has_python && actionSearch_engine->isChecked()) {
bool res = false;
// Check if python is already in PATH
if (misc::pythonVersion())
res = true;
else
res = addPythonPathToEnv();
if (res)
has_python = true;
else if (QMessageBox::question(this, tr("Missing Python Interpreter"),
tr("Python 2.x is required to use the search engine but it does not seem to be installed.\nDo you want to install it now?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
// Download and Install Python
installPython();
actionSearch_engine->setChecked(false);
Preferences().setSearchEnabled(false);
return;
}
else {
actionSearch_engine->setChecked(false);
Preferences().setSearchEnabled(false);
return;
}
}
#endif
displaySearchTab(actionSearch_engine->isChecked());
}
......@@ -1422,6 +1460,11 @@ void MainWindow::on_actionAutoSuspend_system_toggled(bool enabled)
Preferences().setSuspendWhenDownloadsComplete(enabled);
}
void MainWindow::on_actionAutoHibernate_system_toggled(bool enabled) {
qDebug() << Q_FUNC_INFO << enabled;
Preferences().setHibernateWhenDownloadsComplete(enabled);
}
void MainWindow::on_actionAutoShutdown_system_toggled(bool enabled)
{
qDebug() << Q_FUNC_INFO << enabled;
......@@ -1472,3 +1515,64 @@ void MainWindow::checkProgramUpdate() {
updater->checkForUpdates();
}
#endif
#ifdef Q_OS_WIN
bool MainWindow::addPythonPathToEnv() {
if (has_python)
return true;
QString python_path = Preferences::getPythonPath();
if (!python_path.isEmpty()) {
// Add it to PATH envvar
QString path_envar = QString::fromLocal8Bit(qgetenv("PATH").constData());
if (path_envar.isNull()) {
path_envar = "";
}
path_envar = python_path+";"+path_envar;
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
qputenv("PATH", path_envar.toLocal8Bit());
return true;
}
return false;
}
void MainWindow::installPython() {
setCursor(QCursor(Qt::WaitCursor));
// Download python
DownloadThread *pydownloader = new DownloadThread(this);
connect(pydownloader, SIGNAL(downloadFinished(QString,QString)), this, SLOT(pythonDownloadSuccess(QString,QString)));
connect(pydownloader, SIGNAL(downloadFailure(QString,QString)), this, SLOT(pythonDownloadFailure(QString,QString)));
pydownloader->downloadUrl("http://python.org/ftp/python/2.7.3/python-2.7.3.msi");
}
void MainWindow::pythonDownloadSuccess(QString url, QString file_path) {
setCursor(QCursor(Qt::ArrowCursor));