- Totally redesigned program preferences

- Added some options, the following are already implemented:
  * Start/Stop LSD/NAT-PMP/UPnP
	* Force preallocation of all files
	* Force new torrents status to pause
- Other new features are going to be implemented soon
This commit is contained in:
Christophe Dumez 2007-09-08 17:07:29 +00:00
parent cb8ecb74bf
commit cd70843ee9
17 changed files with 3033 additions and 4673 deletions

View file

@ -33,6 +33,8 @@
- FEATURE: Allow to drag 'n drop urls on the main window
- FEATURE: Improved search engine (multipage support in all plugins)
- FEATURE: Added BTJunkie search engine plugin
- FEATURE: Added an option to force full disk allocation for all torrents
- FEATURE: Added an option to add torrents in paused state
- I18N: Added Hungarian translation
- I18N: Added Brazilian translation
- BUGFIX: Progress of paused torrents is now correct on restart
@ -57,7 +59,7 @@
- BUGFIX: ETA was wrong for torrents with filtered files
- BUGFIX: Fixed drag'n drop on non-KDE systems
- COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little
- COSMETIC: Totally redesigned program preferences
- COSMETIC: Display more logs messages concerning features
- COSMETIC: Improved lists renderers
- COSMETIC: Use a different icon for torrents being checked and for connecting ones

6
TODO
View file

@ -84,7 +84,7 @@ LANGUAGES UPDATED:
- Spanish *BETA5*
- German *BETA6*
- Russian *BETA6*
- Korean *BETA5*
- Korean *BETA6*
- Greek *BETA6*
- Dutch *BETA5*
- Romanian *BETA5*
@ -97,6 +97,9 @@ beta6->beta7 changelog:
- FEATURE: Added zip support in search plugins manager (can put .py & .png inside)
- FEATURE: Redesigned torrent creation dialog
- FEATURE: Allow to set piece size when creating a torrent
- FEATURE: Added an option to force full disk allocation for all torrents
- FEATURE: Added an option to add torrents in paused state
- FEATURE: Allow to disable UPnP/NAT-PMP/LSD
- BUGFIX: In torrent content, it is now easier to filter all torrents using right click menu
- BUGFIX: Updated man page / README / INSTALL
- BUGFIX: Paused torrents could be displayed as connected for a sec after checking
@ -112,3 +115,4 @@ beta6->beta7 changelog:
- BUGFIX: Dropped Qt4.2 support, becomes too difficult to maintain
- BUGFIX: Fixed deprecation warning with latest libtorrent svn
- COSMETIC: Improved some icons
- COSMETIC: Totally redesigned program preferences

View file

@ -314,7 +314,7 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
// Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes();
QSettings settings("qBittorrent", "qBittorrent");
QString previewProgram = settings.value("Options/Misc/PreviewProgram", QString()).toString();
QString previewProgram = settings.value("Preferences/general/MediaPlayer", QString()).toString();
bool has_pause = false, has_start = false, has_preview = false;
foreach(index, selectedIndexes) {
if(index.column() == F_NAME) {

View file

@ -60,7 +60,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), for
setupUi(this);
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION)));
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
systrayIntegration = settings.value(QString::fromUtf8("Options/Misc/Behaviour/SystrayIntegration"), true).toBool();
systrayIntegration = settings.value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
// Create tray icon
if (QSystemTrayIcon::isSystemTrayAvailable()) {
if(systrayIntegration) {
@ -243,7 +243,7 @@ void GUI::finishedTorrent(QTorrentHandle& h) const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool show_msg = true;
QString fileName = h.name();
int useOSD = settings.value(QString::fromUtf8("Options/OSDEnabled"), 1).toInt();
bool useNotificationBalloons = settings.value(QString::fromUtf8("Preferences/General/NotificationBaloons"), true).toBool();
// Add it to finished tab
QString hash = h.hash();
if(QFile::exists(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".finished"))) {
@ -254,7 +254,7 @@ void GUI::finishedTorrent(QTorrentHandle& h) const {
downloadingTorrentTab->setInfoBar(tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName));
downloadingTorrentTab->deleteTorrent(hash);
finishedTorrentTab->addTorrent(hash);
if(show_msg && systrayIntegration && (useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden())))) {
if(show_msg && systrayIntegration && useNotificationBalloons) {
myTrayIcon->showMessage(tr("Download finished"), tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName), QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
}
}
@ -262,8 +262,8 @@ void GUI::finishedTorrent(QTorrentHandle& h) const {
// Notification when disk is full
void GUI::fullDiskError(QTorrentHandle& h) const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
int useOSD = settings.value(QString::fromUtf8("Options/OSDEnabled"), 1).toInt();
if(systrayIntegration && (useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden())))) {
bool useNotificationBalloons = settings.value(QString::fromUtf8("Preferences/General/NotificationBaloons"), true).toBool();
if(systrayIntegration && useNotificationBalloons) {
myTrayIcon->showMessage(tr("I/O Error", "i.e: Input/Output Error"), tr("An error occured when trying to read or write %1. The disk is probably full, download has been paused", "e.g: An error occured when trying to read or write xxx.avi. The disk is probably full, download has been paused").arg(h.name()), QSystemTrayIcon::Critical, TIME_TRAY_BALLOON);
}
// Download will be paused by libtorrent. Updating GUI information accordingly
@ -412,7 +412,7 @@ void GUI::previewFile(QString filePath) {
QStringList params;
params << tmpPath;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString previewProgram = settings.value(QString::fromUtf8("Options/Misc/PreviewProgram"), QString()).toString();
QString previewProgram = settings.value(QString::fromUtf8("Preferences/General/MediaPlayer"), QString()).toString();
previewProcess->start(previewProgram, params, QIODevice::ReadOnly);
}else{
QMessageBox::critical(0, tr("Preview process already running"), tr("There is already another preview process running.\nPlease close the other one first."));
@ -475,13 +475,13 @@ void GUI::on_actionAbout_triggered() {
void GUI::closeEvent(QCloseEvent *e) {
qDebug("Mainwindow received closeEvent");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool goToSystrayOnExit = settings.value(QString::fromUtf8("Options/Misc/Behaviour/GoToSystrayOnExit"), false).toBool();
bool goToSystrayOnExit = settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
if(!force_exit && systrayIntegration && goToSystrayOnExit && !this->isHidden()) {
hide();
e->ignore();
return;
}
if(settings.value(QString::fromUtf8("Options/Misc/Behaviour/ConfirmOnExit"), true).toBool() && downloadingTorrentTab->getNbTorrentsInList()) {
if(settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool() && downloadingTorrentTab->getNbTorrentsInList()) {
show();
if(!isMaximized())
showNormal();
@ -518,7 +518,7 @@ void GUI::on_actionCreate_torrent_triggered() {
// Called when we minimize the program
void GUI::hideEvent(QHideEvent *e) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(systrayIntegration && settings.value(QString::fromUtf8("Options/Misc/Behaviour/GoToSystray"), true).toBool() && !e->spontaneous()) {
if(systrayIntegration && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool() && !e->spontaneous()) {
// Hide window
hide();
}
@ -545,9 +545,9 @@ void GUI::dropEvent(QDropEvent *event) {
// Add file to download list
QString file;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Options/Misc/TorrentAdditionDialog/Enabled"), true).toBool();
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(file, files) {
file = file.trimmed().replace(QString::fromUtf8("file://"), QString::fromUtf8(""));
file = file.trimmed().replace(QString::fromUtf8("file://"), QString::fromUtf8(""), Qt::CaseInsensitive);
qDebug("Dropped file %s on download list", file.toUtf8().data());
if(file.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || file.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || file.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
BTSession->downloadFromUrl(file);
@ -584,16 +584,14 @@ void GUI::dragEnterEvent(QDragEnterEvent *event) {
// Display a dialog to allow user to add
// torrents to download list
void GUI::on_actionOpen_triggered() {
QStringList pathsList;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
// Open File Open Dialog
// Note: it is possible to select more than one file
pathsList = QFileDialog::getOpenFileNames(0,
QStringList pathsList = QFileDialog::getOpenFileNames(0,
tr("Open Torrent Files"), settings.value(QString::fromUtf8("MainWindowLastDir"), QDir::homePath()).toString(),
tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
if(!pathsList.empty()) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Options/Misc/TorrentAdditionDialog/Enabled"), true).toBool();
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
unsigned int listSize = pathsList.size();
for(unsigned int i=0; i<listSize; ++i) {
if(useTorrentAdditionDialog) {
@ -725,7 +723,7 @@ void GUI::on_actionDelete_triggered() {
void GUI::processParams(const QStringList& params) {
QString param;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Options/Misc/TorrentAdditionDialog/Enabled"), true).toBool();
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(param, params) {
param = param.trimmed();
if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
@ -750,7 +748,7 @@ void GUI::addTorrent(QString path) {
void GUI::processScannedFiles(const QStringList& params) {
QString param;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Options/Misc/TorrentAdditionDialog/Enabled"), true).toBool();
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(param, params) {
if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
@ -765,7 +763,7 @@ void GUI::processScannedFiles(const QStringList& params) {
void GUI::processDownloadedFiles(QString path, QString url) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Options/Misc/TorrentAdditionDialog/Enabled"), true).toBool();
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(QString, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, QString)));
@ -784,17 +782,53 @@ void GUI::configureSession(bool deleteOptions) {
proxy_settings proxySettings;
session_settings sessionSettings;
pe_settings encryptionSettings;
// Configure session regarding options
BTSession->setDefaultSavePath(options->getSavePath());
// Downloads
BTSession->preAllocateAllFiles(options->preAllocateAllFiles());
BTSession->startTorrentsInPause(options->addTorrentsInPause());
// Connection
old_listenPort = BTSession->getListenPort();
BTSession->setListeningPortsRange(options->getPorts());
new_listenPort = BTSession->getListenPort();
if(new_listenPort != old_listenPort) {
downloadingTorrentTab->setInfoBar(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort)));
}
if(options->isUPnPEnabled()) {
BTSession->enableUPnP(true);
downloadingTorrentTab->setInfoBar(tr("UPnP support [ON]"), QString::fromUtf8("blue"));
} else {
BTSession->enableUPnP(false);
downloadingTorrentTab->setInfoBar(tr("UPnP support [OFF]"), QString::fromUtf8("blue"));
}
if(options->isNATPMPEnabled()) {
BTSession->enableNATPMP(true);
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [ON]"), QString::fromUtf8("blue"));
} else {
BTSession->enableNATPMP(false);
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [OFF]"), QString::fromUtf8("blue"));
}
// Bittorrent
if(options->isLSDEnabled()) {
BTSession->enableLSD(true);
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery [ON]"), QString::fromUtf8("blue"));
} else {
BTSession->enableLSD(false);
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery support [OFF]"), QString::fromUtf8("blue"));
}
if(options->isDHTEnabled()) {
BTSession->enableDHT(true);
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue"));
// Set DHT Port
BTSession->setDHTPort(new_listenPort);
}else{
BTSession->enableDHT(false);
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
}
// IP Filter
// Configure session regarding options
BTSession->setDefaultSavePath(options->getSavePath());
// Apply max connec limit (-1 if disabled)
BTSession->setMaxConnections(options->getMaxConnec());
limits = options->getLimits();
BTSession->setMaxConnections(options->getMaxConnecs());
limits = options->getGlobalBandwidthLimits();
switch(limits.first) {
case -1: // Download limit disabled
case 0:
@ -812,19 +846,7 @@ void GUI::configureSession(bool deleteOptions) {
BTSession->setUploadRateLimit(limits.second*1024);
}
// Apply ratio (0 if disabled)
BTSession->setGlobalRatio(options->getRatio());
// DHT (Trackerless)
if(options->isDHTEnabled()) {
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(options->getDHTPort()), QString::fromUtf8("blue"));
BTSession->enableDHT();
// Set DHT Port
BTSession->setDHTPort(options->getDHTPort());
}else{
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
BTSession->disableDHT();
}
// UPnP can't be disabled
downloadingTorrentTab->setInfoBar(tr("UPnP support [ON]"), QString::fromUtf8("blue"));
BTSession->setGlobalRatio(options->getDesiredRatio());
// Encryption settings
int encryptionState = options->getEncryptionSetting();
// The most secure, rc4 only so that all streams and encrypted
@ -848,7 +870,7 @@ void GUI::configureSession(bool deleteOptions) {
}
BTSession->applyEncryptionSettings(encryptionSettings);
// PeX
if(!options->isPeXDisabled()) {
if(options->isPeXEnabled()) {
qDebug("Enabling Peer eXchange (PeX)");
downloadingTorrentTab->setInfoBar(tr("PeX support [ON]"), QString::fromUtf8("blue"));
BTSession->enablePeerExchange();
@ -1189,7 +1211,7 @@ void GUI::on_actionOptions_triggered() {
// Is executed each time options are saved
void GUI::OptionsSaved(QString info, bool deleteOptions) {
bool newSystrayIntegration = options->useSystrayIntegration();
bool newSystrayIntegration = options->systrayIntegration();
if(newSystrayIntegration && !systrayIntegration) {
// create the trayicon
createTrayIcon();

View file

@ -157,13 +157,13 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
s->set_upload_rate_limit(-1);
else
s->set_upload_rate_limit(val*1024);
settings.setValue(QString::fromUtf8("Options/Main/UPLimit"), val);
settings.setValue(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), val);
}else{
if(!val)
s->set_download_rate_limit(-1);
else
s->set_download_rate_limit(val*1024);
settings.setValue(QString::fromUtf8("Options/Main/DLLimit"), val);
settings.setValue(QString::fromUtf8("Preferences/Connection/GlobalDLLimit"), val);
}
}
close();

View file

@ -44,17 +44,13 @@
#define MAX_TRACKER_ERRORS 2
// Main constructor
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false){
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false){
// To avoid some exceptions
fs::path::default_name_check(fs::no_check);
// Creating bittorrent session
s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0));
// Set severity level of libtorrent session
s->set_severity_level(alert::info);
// Enable LSD/UPnP/NAT-PMP
s->start_lsd();
s->start_natpmp();
s->start_upnp();
// Enabling metadata plugin
s->add_extension(&create_metadata_plugin);
timerAlerts = new QTimer();
@ -85,6 +81,25 @@ bittorrent::~bittorrent() {
delete s;
}
void bittorrent::preAllocateAllFiles(bool b) {
preAllocateAll = b;
if(b) {
// Reload All Torrents
std::vector<torrent_handle> handles = s->get_torrents();
unsigned int nbHandles = handles.size();
for(unsigned int i=0; i<nbHandles; ++i) {
QTorrentHandle h = handles[i];
if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle");
continue;
}
QString hash = h.hash();
if(has_filtered_files(hash)) continue;
reloadTorrent(h);
}
}
}
void bittorrent::setDownloadLimit(QString hash, long val) {
QTorrentHandle h = getTorrentHandle(hash);
if(h.is_valid())
@ -104,6 +119,10 @@ void bittorrent::handleDownloadFailure(QString url, QString reason) {
emit downloadFromUrlFailure(url, reason);
}
void bittorrent::startTorrentsInPause(bool b) {
addInPause = b;
}
void bittorrent::updateETAs() {
QString hash;
foreach(hash, unfinishedTorrents) {
@ -346,7 +365,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
}
}
// Processing torrents
file = path.trimmed().replace("file://", "");
file = path.trimmed().replace("file://", "", Qt::CaseInsensitive);
if(file.isEmpty()) {
return;
}
@ -409,7 +428,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
}
QString savePath = getSavePath(hash);
// Adding files to bittorrent session
if(has_filtered_files(hash)) {
if(has_filtered_files(hash) || preAllocateAll) {
h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, false, true);
qDebug(" -> Full allocation mode");
}else{
@ -450,7 +469,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
QFile::copy(file, newFile);
}
// Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
if(addInPause || QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
torrentsToPauseAfterChecking << hash;
qDebug("Adding a torrent to the torrentsToPauseAfterChecking list");
}
@ -543,30 +562,53 @@ bool bittorrent::isDHTEnabled() const{
return DHTEnabled;
}
// Enable DHT
void bittorrent::enableDHT() {
if(!DHTEnabled) {
boost::filesystem::ifstream dht_state_file((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toUtf8().data(), std::ios_base::binary);
dht_state_file.unsetf(std::ios_base::skipws);
entry dht_state;
try{
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
}catch (std::exception&) {}
s->start_dht(dht_state);
s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.utorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.bitcomet.com"), 6881));
DHTEnabled = true;
qDebug("DHT enabled");
void bittorrent::enableUPnP(bool b) {
if(b) {
s->start_upnp();
} else {
s->stop_upnp();
}
}
// Disable DHT
void bittorrent::disableDHT() {
if(DHTEnabled) {
DHTEnabled = false;
s->stop_dht();
qDebug("DHT disabled");
void bittorrent::enableNATPMP(bool b) {
if(b) {
s->start_natpmp();
} else {
s->stop_natpmp();
}
}
void bittorrent::enableLSD(bool b) {
if(b) {
s->start_lsd();
} else {
s->stop_lsd();
}
}
// Enable DHT
void bittorrent::enableDHT(bool b) {
if(b) {
if(!DHTEnabled) {
boost::filesystem::ifstream dht_state_file((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toUtf8().data(), std::ios_base::binary);
dht_state_file.unsetf(std::ios_base::skipws);
entry dht_state;
try{
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
}catch (std::exception&) {}
s->start_dht(dht_state);
s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.utorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.bitcomet.com"), 6881));
DHTEnabled = true;
qDebug("DHT enabled");
}
} else {
if(DHTEnabled) {
DHTEnabled = false;
s->stop_dht();
qDebug("DHT disabled");
}
}
}

View file

@ -57,6 +57,8 @@ class bittorrent : public QObject{
QStringList waitingForPause;
QStringList finishedTorrents;
QStringList unfinishedTorrents;
bool preAllocateAll;
bool addInPause;
protected:
QString getSavePath(QString hash);
@ -90,9 +92,8 @@ class bittorrent : public QObject{
void deleteTorrent(QString hash, bool permanent = false);
bool pauseTorrent(QString hash);
bool resumeTorrent(QString hash);
void enableDHT();
void disableDHT();
void saveDHTEntry();
void preAllocateAllFiles(bool b);
void saveFastResumeAndRatioData();
void enableDirectoryScanning(QString scan_dir);
void disableDirectoryScanning();
@ -117,6 +118,7 @@ class bittorrent : public QObject{
void setDHTPort(int dht_port);
void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true);
void setSessionSettings(session_settings sessionSettings);
void startTorrentsInPause(bool b);
void setDefaultSavePath(QString savepath);
void applyEncryptionSettings(pe_settings se);
void loadFilesPriorities(QTorrentHandle& h);
@ -124,6 +126,10 @@ class bittorrent : public QObject{
void setUploadLimit(QString hash, long val);
void setUnfinishedTorrent(QString hash);
void setFinishedTorrent(QString hash);
void enableUPnP(bool b);
void enableNATPMP(bool b);
void enableLSD(bool b);
void enableDHT(bool b);
protected slots:
void scanDirectory();

View file

@ -246,7 +246,7 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) {
// Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString previewProgram = settings.value(QString::fromUtf8("Options/Misc/PreviewProgram"), QString()).toString();
QString previewProgram = settings.value(QString::fromUtf8("Preferences/general/MediaPlayer"), QString()).toString();
bool has_pause = false, has_start = false, has_preview = false;
foreach(index, selectedIndexes) {
if(index.column() == NAME) {

View file

@ -79,17 +79,17 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
foreach(file, files) {
qDebug("dropped %s", file.toUtf8().data());
file = file.replace("file://", "");
if(file.startsWith("http://") || file.startsWith("https://") || file.startsWith("ftp://")) {
if(file.startsWith("http://", Qt::CaseInsensitive) || file.startsWith("https://", Qt::CaseInsensitive) || file.startsWith("ftp://", Qt::CaseInsensitive)) {
downloader->downloadUrl(file);
continue;
}
if(file.endsWith(".py")) {
if(file.endsWith(".py", Qt::CaseInsensitive)) {
QString plugin_name = file.split(QDir::separator()).last();
plugin_name.replace(".py", "");
installPlugin(file, plugin_name);
}
#ifdef HAVE_ZZIP
if(file.endsWith(".zip")) {
if(file.endsWith(".zip", Qt::CaseInsensitive)) {
installZipPlugin(file);
}
#endif
@ -332,7 +332,7 @@ QList<QTreeWidgetItem*> engineSelectDlg::findItemsWithUrl(QString url){
QList<QTreeWidgetItem*> res;
for(int i=0; i<pluginsTree->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = pluginsTree->topLevelItem(i);
if(url.startsWith(item->text(ENGINE_URL)))
if(url.startsWith(item->text(ENGINE_URL), Qt::CaseInsensitive))
res << item;
}
return res;
@ -367,10 +367,10 @@ void engineSelectDlg::installZipPlugin(QString path) {
while(zzip_dir_read(dir, &dirent)) {
/* show info for first file */
QString name(dirent.d_name);
if(name.endsWith(".py")) {
if(name.endsWith(".py", Qt::CaseInsensitive)) {
plugins << name;
} else {
if(name.endsWith(".png")) {
if(name.endsWith(".png", Qt::CaseInsensitive)) {
favicons << name;
}
}
@ -520,14 +520,14 @@ void engineSelectDlg::on_installButton_clicked() {
#endif
QString path;
foreach(path, pathsList) {
if(path.endsWith(".py")) {
if(path.endsWith(".py", Qt::CaseInsensitive)) {
QString plugin_name = path.split(QDir::separator()).last();
plugin_name.replace(".py", "");
plugin_name.replace(".py", "", Qt::CaseInsensitive);
installPlugin(path, plugin_name);
}
#ifdef HAVE_ZZIP
else {
if(path.endsWith(".zip")) {
if(path.endsWith(".zip", Qt::CaseInsensitive)) {
installZipPlugin(path);
}
}
@ -582,7 +582,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateSer
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
qDebug("engineSelectDlg received %s", url.toUtf8().data());
if(url.endsWith("favicon.ico")){
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
// Icon downloaded
QImage fileIcon;
#ifdef HAVE_MAGICK
@ -628,7 +628,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
QFile::remove(filePath);
return;
}
if(url.endsWith(".pyqBT") || url.endsWith(".py")) {
if(url.endsWith(".pyqBT", Qt::CaseInsensitive) || url.endsWith(".py", Qt::CaseInsensitive)) {
QString plugin_name = url.split('/').last();
plugin_name.replace(".py", "");
plugin_name.replace(".pyqBT", "");
@ -637,7 +637,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
return;
}
#ifdef HAVE_ZZIP
if(url.endsWith(".zip")) {
if(url.endsWith(".zip", Qt::CaseInsensitive)) {
installZipPlugin(filePath);
QFile::remove(filePath);
return;
@ -646,7 +646,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
}
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
if(url.endsWith("favicon.ico")){
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
qDebug("Could not download favicon: %s, reason: %s", url.toUtf8().data(), reason.toUtf8().data());
return;
}
@ -660,17 +660,17 @@ void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, update server is temporarily unavailable."));
return;
}
if(url.endsWith(".pyqBT") || url.endsWith(".py")) {
if(url.endsWith(".pyqBT", Qt::CaseInsensitive) || url.endsWith(".py", Qt::CaseInsensitive)) {
// a plugin update download has been failed
QString plugin_name = url.split('/').last();
plugin_name.replace(".pyqBT", "");
plugin_name.replace(".py", "");
plugin_name.replace(".pyqBT", "", Qt::CaseInsensitive);
plugin_name.replace(".py", "", Qt::CaseInsensitive);
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
}
#ifdef HAVE_ZZIP
if(url.endsWith(".zip")) {
if(url.endsWith(".zip", Qt::CaseInsensitive)) {
QString plugin_name = url.split('/').last();
plugin_name.replace(".zip", "");
plugin_name.replace(".zip", "", Qt::CaseInsensitive);
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -44,33 +44,33 @@
#include "GUI.h"
#include "misc.h"
void useStyle(QApplication *app, QString style){
std::cout << "* Style: Using " << style.toStdString() << " style\n";
if(style == QString::fromUtf8("Cleanlooks")){
app->setStyle(new QCleanlooksStyle());
return;
}
if(style == QString::fromUtf8("Motif")){
app->setStyle(new QMotifStyle());
return;
}
if(style == QString::fromUtf8("CDE")){
app->setStyle(new QCDEStyle());
return;
}
void useStyle(QApplication *app, int style){
switch(style) {
case 0:
app->setStyle(new QPlastiqueStyle());
break;
case 1:
app->setStyle(new QCleanlooksStyle());
break;
case 2:
app->setStyle(new QMotifStyle());
break;
case 3:
app->setStyle(new QCDEStyle());
break;
#ifdef Q_WS_MAC
if(style == QString::fromUtf8("MacOS")){
case 4:
app->setStyle(new QMacStyle());
return;
}
break;
#endif
#ifdef Q_WS_WIN
if(style == QString::fromUtf8("WinXP")){
case 4:
app->setStyle(new QWindowsXPStyle());
return;
}
break;
#endif
app->setStyle(new QPlastiqueStyle());
default:
app->setStyle(new QPlastiqueStyle());
}
}
// Main
@ -123,27 +123,15 @@ int main(int argc, char *argv[]){
}
QApplication app(argc, argv);
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString style;
#ifdef Q_WS_WIN
style = settings.value(QString::fromUtf8("Options/Style"), QString::fromUtf8("WinXP")).toString();
#endif
#ifdef Q_WS_MAC
style = settings.value(QString::fromUtf8("Options/Style"), QString::fromUtf8("MacOS")).toString();
#endif
#ifndef Q_WS_WIN
#ifndef Q_WS_MAC
style = settings.value(QString::fromUtf8("Options/Style"), QString::fromUtf8("Plastique")).toString();
#endif
#endif
useStyle(&app, style);
useStyle(&app, settings.value("Preferences/General/Style", 4).toInt());
QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/splash.png")));
splash->show();
// Open options file to read locale
locale = settings.value(QString::fromUtf8("Options/Language/Locale"), QString()).toString();
locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString();
QTranslator translator;
if(locale.isEmpty()){
locale = QLocale::system().name();
settings.setValue(QString::fromUtf8("Options/Language/Locale"), locale);
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
}
if(translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
qDebug("%s locale recognized, using translation.", (const char*)locale.toUtf8());

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -25,10 +25,10 @@
#include "ui_options.h"
#include <libtorrent/ip_filter.hpp>
#define HTTP 0
#define SOCKS5 1
#define HTTP_PW 2
#define SOCKS5_PW 3
#define HTTP 1
#define SOCKS5 2
#define HTTP_PW 3
#define SOCKS5_PW 4
using namespace libtorrent;
@ -51,71 +51,82 @@ class options_imp : public QDialog, private Ui::Dialog{
// Methods
void saveOptions();
void loadOptions();
// Main options
std::pair<unsigned short, unsigned short> getPorts() const;
QPair<int,int> getLimits() const;
float getRatio() const;
int getMaxConnec() const;
// General options
QString getLocale() const;
int getStyle() const;
bool confirmOnExit() const;
bool speedInTitleBar() const;
bool systrayIntegration() const;
bool minimizeToTray() const;
bool closeToTray() const;
bool OSDEnabled() const;
QString getPreviewProgram() const;
// Downloads
QString getSavePath() const;
bool preAllocateAllFiles() const;
bool useAdditionDialog() const;
bool addTorrentsInPause() const;
bool isDirScanEnabled() const;
QString getScanDir() const;
bool isDHTEnabled() const;
int getDHTPort() const;
int getEncryptionSetting() const;
bool isPeXDisabled() const;
// Filter Settings
bool isFilteringEnabled() const;
ip_filter getFilter() const;
// Proxy settings
// Connection options
std::pair<unsigned short, unsigned short> getPorts() const;
bool isUPnPEnabled() const;
bool isNATPMPEnabled() const;
QPair<int,int> getGlobalBandwidthLimits() const;
bool isProxyEnabled() const;
bool isProxyAuthEnabled() const;
QString getProxyIp() const;
unsigned short getProxyPort() const;
QString getProxyUsername() const;
QString getProxyPassword() const;
unsigned short getProxyType() const;
int getProxyType() const;
bool useProxyForTrackers() const;
bool useProxyForPeers() const;
bool useProxyForWebseeds() const;
bool useProxyForDHT() const;
// Language Settings
QString getLocale() const;
// Misc Settings
bool useAdditionDialog() const;
QString getSavePath() const;
bool getGoToSysTrayOnMinimizingWindow() const;
bool getGoToSysTrayOnExitingWindow() const;
bool getConfirmOnExit() const;
QString getPreviewProgram() const;
bool getUseOSDAlways() const;
bool getUseOSDWhenHiddenOnly() const;
QString getStyle() const;
bool useSystrayIntegration() const;
// Bittorrent options
int getMaxConnecs() const;
int getMaxConnecsPerTorrent() const;
int getMaxUploadsPerTorrent() const;
bool isDHTEnabled() const;
bool isPeXEnabled() const;
bool isLSDEnabled() const;
int getEncryptionSetting() const;
float getDesiredRatio() const;
float getDeleteRatio() const;
// IP Filter
bool isFilteringEnabled() const;
ip_filter getFilter() const;
protected slots:
void enableUploadLimit(int checkBoxValue);
void enableDownloadLimit(int checkBoxValue);
void enableDirScan(int checkBoxValue);
void enableProxy(int comboIndex);
void enableProxyAuth(int checkBoxValue);
void enableMaxConnecsLimit(int);
void enableMaxConnecsLimitPerTorrent(int checkBoxValue);
void enableMaxUploadsLimitPerTorrent(int checkBoxValue);
void enableShareRatio(int checkBoxValue);
void enableDeleteRatio(int checkBoxValue);
void enableFilter(int checkBoxValue);
void setStyle(int style);
void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e);
void on_buttonBox_rejected();
void applySettings(QAbstractButton* button);
void on_addFilterRange_clicked();
void on_delFilterRange_clicked();
void on_browse_button_scan_clicked();
void on_browsePreview_clicked();
void on_filterBrowse_clicked();
void disableDownload(int checkBoxValue);
void disableDHTGroup(int checkBoxValue);
void disableMaxConnecLimit(int);
void enableFilter(int checkBoxValue);
void disableUpload(int checkBoxValue);
void disableShareRatio(int checkBoxValue);
void enableProxy(int checkBoxValue);
void enableProxyAuth(int checkBoxValue);
void enableDirScan(int checkBoxValue);
void on_browse_button_clicked();
void on_addFilterRangeButton_clicked();
void on_delFilterRangeButton_clicked();
void on_browseScanDirButton_clicked();
void on_browsePreviewButton_clicked();
void on_browseFilterButton_clicked();
void on_browseSaveDirButton_clicked();
void processFilterFile(QString filePath=QString());
void enableApplyButton();
void checkPortsLogic();
void enableSavePath(int checkBoxValue);
void setStyle(QString style);
void systrayDisabled(int val);
void enableSystrayOptions();
void disableSystrayOptions();
void setSystrayOptionsState(int checkBoxValue);
public slots:
void setLocale(QString locale);

View file

@ -389,8 +389,8 @@ void SearchEngine::updateNova() {
// Error | Stopped by user | Finished normally
void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
QSettings settings("qBittorrent", "qBittorrent");
int useOSD = settings.value("Options/OSDEnabled", 1).toInt();
if(systrayIntegration && (useOSD == 1 || (useOSD == 2 && (isMinimized() || isHidden())))) {
bool useNotificationBalloons = settings.value("Preferences/General/NotificationBaloons", true).toBool();
if(systrayIntegration && useNotificationBalloons) {
myTrayIcon->showMessage(tr("Search Engine"), tr("Search has finished"), QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
}
if(exitcode){

View file

@ -83,6 +83,10 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
savePathTxt->setText(settings.value(QString::fromUtf8("LastDirTorrentAdd"), home+QString::fromUtf8("qBT_dir")).toString());
if(settings.value("Preferences/Downloads/StartInPause", false).toBool()) {
addInPause->setChecked(true);
addInPause->setEnabled(false);
}
}
void showLoad(QString filePath, bool fromScanDir=false, QString from_url=QString::null){