|
|
@ -58,7 +58,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : |
|
|
|
m_contentDelegate(0), |
|
|
|
m_contentDelegate(0), |
|
|
|
m_isMagnet(false), |
|
|
|
m_isMagnet(false), |
|
|
|
m_hasMetadata(false), |
|
|
|
m_hasMetadata(false), |
|
|
|
m_hasRenamedFile(false) |
|
|
|
m_hasRenamedFile(false), |
|
|
|
|
|
|
|
m_oldIndex(0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
setAttribute(Qt::WA_DeleteOnClose); |
|
|
@ -69,9 +70,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : |
|
|
|
ui->start_torrent_cb->setChecked(!pref->addTorrentsInPause()); |
|
|
|
ui->start_torrent_cb->setChecked(!pref->addTorrentsInPause()); |
|
|
|
ui->save_path_combo->addItem(fsutils::toNativePath(pref->getSavePath()), pref->getSavePath()); |
|
|
|
ui->save_path_combo->addItem(fsutils::toNativePath(pref->getSavePath()), pref->getSavePath()); |
|
|
|
loadSavePathHistory(); |
|
|
|
loadSavePathHistory(); |
|
|
|
ui->save_path_combo->insertSeparator(ui->save_path_combo->count()); |
|
|
|
|
|
|
|
ui->save_path_combo->addItem(tr("Other...", "Other save path...")); |
|
|
|
|
|
|
|
connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); |
|
|
|
connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); |
|
|
|
|
|
|
|
connect(ui->browse_button, SIGNAL(clicked()), SLOT(browseButton_clicked())); |
|
|
|
ui->default_save_path_cb->setVisible(false); // Default path is selected by default
|
|
|
|
ui->default_save_path_cb->setVisible(false); // Default path is selected by default
|
|
|
|
|
|
|
|
|
|
|
|
// Load labels
|
|
|
|
// Load labels
|
|
|
@ -316,13 +316,20 @@ void AddNewTorrentDialog::updateDiskSpaceLabel() { |
|
|
|
|
|
|
|
|
|
|
|
void AddNewTorrentDialog::onSavePathChanged(int index) |
|
|
|
void AddNewTorrentDialog::onSavePathChanged(int index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static int old_index = 0; |
|
|
|
// Toggle default save path setting checkbox visibility
|
|
|
|
Preferences* const pref = Preferences::instance(); |
|
|
|
ui->default_save_path_cb->setChecked(false); |
|
|
|
|
|
|
|
ui->default_save_path_cb->setVisible(QDir(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString()) != QDir(Preferences::instance()->getSavePath())); |
|
|
|
|
|
|
|
relayout(); |
|
|
|
|
|
|
|
|
|
|
|
if (index == (ui->save_path_combo->count() - 1)) { |
|
|
|
// Remember index
|
|
|
|
|
|
|
|
m_oldIndex = index; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddNewTorrentDialog::browseButton_clicked() |
|
|
|
|
|
|
|
{ |
|
|
|
disconnect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSavePathChanged(int))); |
|
|
|
disconnect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSavePathChanged(int))); |
|
|
|
// User is asking for a new save path
|
|
|
|
// User is asking for a new save path
|
|
|
|
QString cur_save_path = ui->save_path_combo->itemText(old_index); |
|
|
|
QString cur_save_path = ui->save_path_combo->itemText(m_oldIndex); |
|
|
|
QString new_path, old_filename, new_filename; |
|
|
|
QString new_path, old_filename, new_filename; |
|
|
|
|
|
|
|
|
|
|
|
if (m_torrentInfo && m_torrentInfo->num_files() == 1) { |
|
|
|
if (m_torrentInfo && m_torrentInfo->num_files() == 1) { |
|
|
@ -356,18 +363,14 @@ void AddNewTorrentDialog::onSavePathChanged(int index) |
|
|
|
m_filesPath[0] = new_filename; |
|
|
|
m_filesPath[0] = new_filename; |
|
|
|
updateFileNameInSavePaths(new_filename); |
|
|
|
updateFileNameInSavePaths(new_filename); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onSavePathChanged(0); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Restore index
|
|
|
|
// Restore index
|
|
|
|
ui->save_path_combo->setCurrentIndex(old_index); |
|
|
|
ui->save_path_combo->setCurrentIndex(m_oldIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); |
|
|
|
connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); |
|
|
|
} |
|
|
|
|
|
|
|
// Toggle default save path setting checkbox visibility
|
|
|
|
|
|
|
|
ui->default_save_path_cb->setChecked(false); |
|
|
|
|
|
|
|
ui->default_save_path_cb->setVisible(QDir(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString()) != pref->getSavePath()); |
|
|
|
|
|
|
|
relayout(); |
|
|
|
|
|
|
|
// Remember index
|
|
|
|
|
|
|
|
old_index = ui->save_path_combo->currentIndex(); |
|
|
|
|
|
|
|
updateDiskSpaceLabel(); |
|
|
|
updateDiskSpaceLabel(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|