From b719bfaecbf7c64063a8062e3d06a93bd4f7af03 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 3 Jun 2010 21:08:28 +0000 Subject: [PATCH] Merge Win32 fixes from stable branch --- src/bittorrent.cpp | 3 ++ src/createtorrent_imp.cpp | 12 +++++-- src/options_imp.cpp | 71 +++++++++++++++++++++++++++++---------- src/propertieswidget.cpp | 12 ++++++- src/torrentadditiondlg.h | 21 ++++++++++-- 5 files changed, 95 insertions(+), 24 deletions(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index f5087e00a..17879aee0 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1538,6 +1538,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { if(consoleMessages.size() > 100) { consoleMessages.removeFirst(); } +#ifdef Q_WS_WIN + msg = msg.replace("/", "\\"); +#endif consoleMessages.append(QString::fromUtf8("")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8(" - ") + msg + QString::fromUtf8("")); #endif emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg); diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index 5a11b7831..e8cc5a5a8 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -80,14 +80,22 @@ createtorrent::~createtorrent() { void createtorrent::on_addFolder_button_clicked(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), QDir::homePath(), QFileDialog::ShowDirsOnly); - if(!dir.isEmpty()) + if(!dir.isEmpty()) { +#ifdef Q_WS_WIN + dir = dir.replace("/", "\\"); +#endif textInputPath->setText(dir); + } } void createtorrent::on_addFile_button_clicked(){ QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), QDir::homePath()); - if(!file.isEmpty()) + if(!file.isEmpty()) { +#ifdef Q_WS_WIN + file = file.replace("/", "\\"); +#endif textInputPath->setText(file); + } } void createtorrent::on_removeTracker_button_clicked() { diff --git a/src/options_imp.cpp b/src/options_imp.cpp index e9bd56291..d8f6dd7a1 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -90,7 +90,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ locales << "nl_NL"; comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/spain.png"))), QString::fromUtf8("Español")); locales << "es_ES"; - comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/spain_catalunya.png"))), QString::fromUtf8("Català")); + comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/spain_catalunya.png"))), QString::fromUtf8("Catal ")); locales << "ca_ES"; comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/portugal.png"))), QString::fromUtf8("Português")); locales << "pt_PT"; @@ -110,7 +110,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ locales << "ro_RO"; comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/turkey.png"))), QString::fromUtf8("Türkçe")); locales << "tr_TR"; -comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/saoudi_arabia.png"))), QString::fromUtf8("عربي")); + comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/saoudi_arabia.png"))), QString::fromUtf8("عربي")); locales << "ar_SA"; comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/greece.png"))), QString::fromUtf8("Ελληνικά")); locales << "el_GR"; @@ -126,7 +126,7 @@ comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/saoudi_arabia.png"))) locales << "bg_BG"; comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/ukraine.png"))), QString::fromUtf8("Українська")); locales << "uk_UA"; - comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/russia.png"))), QString::fromUtf8("Русский")); + comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/russia.png"))), QString::fromUtf8(" усский")); locales << "ru_RU"; comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/japan.png"))), QString::fromUtf8("日本語")); locales << "ja_JP"; @@ -391,9 +391,17 @@ void options_imp::saveOptions(){ settings.endGroup(); // Downloads preferences settings.beginGroup("Downloads"); - settings.setValue(QString::fromUtf8("SavePath"), getSavePath()); + QString save_path = getSavePath(); +#ifdef Q_WS_WIN + save_path = save_path.replace("\\", "/"); +#endif + settings.setValue(QString::fromUtf8("SavePath"), save_path); settings.setValue(QString::fromUtf8("TempPathEnabled"), isTempPathEnabled()); - settings.setValue(QString::fromUtf8("TempPath"), getTempPath()); + QString temp_path = getTempPath(); +#ifdef Q_WS_WIN + temp_path = temp_path.replace("\\", "/"); +#endif + settings.setValue(QString::fromUtf8("TempPath"), temp_path); settings.setValue(QString::fromUtf8("AppendLabel"), checkAppendLabel->isChecked()); #ifdef LIBTORRENT_0_15 settings.setValue(QString::fromUtf8("UseIncompleteExtension"), checkAppendqB->isChecked()); @@ -403,7 +411,11 @@ void options_imp::saveOptions(){ settings.setValue(QString::fromUtf8("StartInPause"), addTorrentsInPause()); ScanFoldersModel::instance()->makePersistent(settings); addedScanDirs.clear(); - Preferences::setExportDir(getExportDir()); + QString export_dir = getExportDir(); +#ifdef Q_WS_WIN + export_dir = export_dir.replace("\\", "/"); +#endif + Preferences::setExportDir(export_dir); settings.setValue(QString::fromUtf8("DblClOnTorDl"), getActionOnDblClOnTorrentDl()); settings.setValue(QString::fromUtf8("DblClOnTorFn"), getActionOnDblClOnTorrentFn()); // End Downloads preferences @@ -489,7 +501,11 @@ void options_imp::saveOptions(){ settings.beginGroup("IPFilter"); settings.setValue(QString::fromUtf8("Enabled"), isFilteringEnabled()); if(isFilteringEnabled()){ - settings.setValue(QString::fromUtf8("File"), textFilterPath->text()); + QString filter_path = textFilterPath->text(); +#ifdef Q_WS_WIN + filter_path = filter_path.replace("\\", "/"); +#endif + settings.setValue(QString::fromUtf8("File"), filter_path); } // End IPFilter preferences settings.endGroup(); @@ -609,7 +625,11 @@ void options_imp::loadOptions(){ } // End General preferences // Downloads preferences - textSavePath->setText(Preferences::getSavePath()); + QString save_path = Preferences::getSavePath(); +#ifdef Q_WS_WIN + save_path = save_path.replace("/", "\\"); +#endif + textSavePath->setText(save_path); if(Preferences::isTempPathEnabled()) { // enable checkTempFolder->setChecked(true); @@ -618,7 +638,11 @@ void options_imp::loadOptions(){ checkTempFolder->setChecked(false); enableTempPathInput(checkTempFolder->isChecked()); } - textTempPath->setText(Preferences::getTempPath()); + QString temp_path = Preferences::getTempPath(); +#ifdef Q_WS_WIN + temp_path = temp_path.replace("/", "\\"); +#endif + textTempPath->setText(temp_path); checkAppendLabel->setChecked(Preferences::appendTorrentLabel()); #ifdef LIBTORRENT_0_15 checkAppendqB->setChecked(Preferences::useIncompleteFilesExtension()); @@ -635,6 +659,9 @@ void options_imp::loadOptions(){ } else { // enable checkExportDir->setChecked(true); +#ifdef Q_WS_WIN + strValue = strValue.replace("/", "\\"); +#endif textExportDir->setText(strValue); enableTorrentExport(checkExportDir->isChecked()); } @@ -1023,16 +1050,12 @@ float options_imp::getDeleteRatio() const{ // Return Save Path QString options_imp::getSavePath() const{ -#ifdef Q_WS_WIN - QString home = QDir::rootPath(); -#else - QString home = QDir::homePath(); -#endif - if(home[home.length()-1] != QDir::separator()){ - home += QDir::separator(); - } if(textSavePath->text().trimmed().isEmpty()){ - textSavePath->setText(home+QString::fromUtf8("qBT_dir")); + QString save_path = Preferences::getSavePath(); +#ifdef Q_WS_WIN + save_path = save_path.replace("/", "\\"); +#endif + textSavePath->setText(save_path); } return misc::expandPath(textSavePath->text()); } @@ -1428,6 +1451,9 @@ void options_imp::on_browseExportDirButton_clicked() { dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), QDir::homePath()); } if(!dir.isNull()){ +#ifdef Q_WS_WIN + dir = dir.replace("/", "\\"); +#endif textExportDir->setText(dir); } } @@ -1442,6 +1468,9 @@ void options_imp::on_browseFilterButton_clicked() { ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)")); } if(!ipfilter.isNull()){ +#ifdef Q_WS_WIN + ipfilter = ipfilter.replace("/", "\\"); +#endif textFilterPath->setText(ipfilter); } } @@ -1457,6 +1486,9 @@ void options_imp::on_browseSaveDirButton_clicked(){ dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath()); } if(!dir.isNull()){ +#ifdef Q_WS_WIN + dir = dir.replace("/", "\\"); +#endif textSavePath->setText(dir); } } @@ -1471,6 +1503,9 @@ void options_imp::on_browseTempDirButton_clicked(){ dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath()); } if(!dir.isNull()){ +#ifdef Q_WS_WIN + dir = dir.replace("/", "\\"); +#endif textTempPath->setText(dir); } } diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index ea16980c0..89a3b659e 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -212,6 +212,9 @@ void PropertiesWidget::updateSavePath(QTorrentHandle& _h) { QString p = TorrentPersistentData::getSavePath(h.hash()); if(p.isEmpty()) p = h.save_path(); +#ifdef Q_WS_WIN + p = p.replace("/", "\\"); +#endif save_path->setText(p); } } @@ -236,6 +239,9 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { QString p = TorrentPersistentData::getSavePath(h.hash()); if(p.isEmpty()) p = h.save_path(); +#ifdef Q_WS_WIN + p = p.replace("/", "\\"); +#endif save_path->setText(p); // Creation date lbl_creationDate->setText(h.creation_date()); @@ -752,7 +758,11 @@ void PropertiesWidget::renameSelectedFile() { if(!BTSession->useTemporaryFolder() || h.is_seed()) h.move_storage(savePath.absolutePath()); // Update save_path in dialog - save_path->setText(savePath.absolutePath()); + QString display_path = savePath.absolutePath(); +#ifdef Q_WS_WIN + display_path = display_path.replace("/", "\\"); +#endif + save_path->setText(display_path); } } diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index d6006b94d..cf831a002 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -99,7 +99,11 @@ public: //torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch); defaultSavePath = Preferences::getSavePath(); appendLabelToSavePath = Preferences::appendTorrentLabel(); - savePathTxt->setText(defaultSavePath); + QString display_path = defaultSavePath; +#ifdef Q_WS_WIN + display_path = display_path.replace("/", "\\"); +#endif + savePathTxt->setText(display_path); if(Preferences::addTorrentsInPause()) { addInPause->setChecked(true); //addInPause->setEnabled(false); @@ -421,7 +425,11 @@ public slots: void on_browseButton_clicked(){ QString dir; - const QString &save_path = misc::expandPath(savePathTxt->text()); + QString save_path = savePathTxt->text(); +#ifdef Q_WS_WIN + save_path = save_path.replace("\\", "/"); +#endif + save_path = misc::expandPath(save_path); const QDir &saveDir(save_path); if(!save_path.isEmpty() && saveDir.exists()){ dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath()); @@ -429,6 +437,9 @@ public slots: dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath()); } if(!dir.isNull()){ +#ifdef Q_WS_WIN + dir = dir.replace("/", "\\"); +#endif savePathTxt->setText(dir); } } @@ -452,7 +463,11 @@ public slots: QMessageBox::critical(0, tr("Empty save path"), tr("Please enter a save path")); return; } - QDir savePath(misc::expandPath(savePathTxt->text())); + QString save_path = savePathTxt->text(); +#ifdef Q_WS_WIN + save_path = save_path.replace("\\", "/"); +#endif + QDir savePath(misc::expandPath(save_path)); // Check if savePath exists if(!savePath.exists()){ if(!savePath.mkpath(savePath.path())){