From e3e9461901d6cd510ca42afda1dbc01f9ec1c573 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 3 Jun 2010 20:56:54 +0000 Subject: [PATCH] Display paths with '\' separator on Win32 --- 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 b84ca9099..98060615c 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1532,6 +1532,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 45b802026..8950dda5b 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"; @@ -389,9 +389,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()); @@ -401,7 +409,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 @@ -487,7 +499,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(); @@ -606,7 +622,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); @@ -615,7 +635,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()); @@ -632,6 +656,9 @@ void options_imp::loadOptions(){ } else { // enable checkExportDir->setChecked(true); +#ifdef Q_WS_WIN + strValue = strValue.replace("/", "\\"); +#endif textExportDir->setText(strValue); enableTorrentExport(checkExportDir->isChecked()); } @@ -1020,16 +1047,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()); } @@ -1425,6 +1448,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); } } @@ -1439,6 +1465,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); } } @@ -1454,6 +1483,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); } } @@ -1468,6 +1500,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 1612358f1..0b185d356 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -211,6 +211,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); } } @@ -229,6 +232,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()); @@ -743,7 +749,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 bac1f5169..c5dfeba1f 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -92,7 +92,11 @@ public: // Remember columns width readSettings(); //torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch); - savePathTxt->setText(Preferences::getSavePath()); + QString display_path = Preferences::getSavePath(); +#ifdef Q_WS_WIN + display_path = display_path.replace("/", "\\"); +#endif + savePathTxt->setText(display_path); if(Preferences::addTorrentsInPause()) { addInPause->setChecked(true); //addInPause->setEnabled(false); @@ -400,7 +404,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()); @@ -408,6 +416,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); } } @@ -431,7 +442,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())){