AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::AddNewTorrentDialog) , m_contentModel(0) , m_contentDelegate(0) , m_hasMetadata(false) , m_oldIndex(0) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); ui->lblMetaLoading->setVisible(false); ui->progMetaLoading->setVisible(false); auto session = BitTorrent::Session::instance(); ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused()); (session->isASMDisabledByDefault() ? ui->simpleModeRadioButton : ui->advancedModeRadioButton)->setChecked(true); populateSavePathComboBox(); connect(ui->savePathComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); connect(ui->browseButton, SIGNAL(clicked()), SLOT(browseButton_clicked())); ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); // Load categories QStringList categories = session->categories(); std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive); QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString(); if (!defaultCategory.isEmpty()) ui->categoryComboBox->addItem(defaultCategory); ui->categoryComboBox->addItem(""); foreach (const QString &category, categories) if (category != defaultCategory) ui->categoryComboBox->addItem(category); ui->categoryComboBox->model()->sort(0); ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder); loadState(); // Signal / slots connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool))); connect(ui->doNotDeleteTorrentCheckBox, SIGNAL(clicked(bool)), SLOT(doNotDeleteTorrentClicked(bool))); editHotkey = new QShortcut(QKeySequence("F2"), ui->contentTreeView, 0, 0, Qt::WidgetShortcut); connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile())); connect(ui->contentTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile())); ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus(); }
AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::AddNewTorrentDialog) , m_contentModel(0) , m_contentDelegate(0) , m_hasMetadata(false) , m_oldIndex(0) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); ui->lblMetaLoading->setVisible(false); ui->progMetaLoading->setVisible(false); Preferences* const pref = Preferences::instance(); ui->start_torrent_cb->setChecked(!pref->addTorrentsInPause()); ui->save_path_combo->addItem(Utils::Fs::toNativePath(pref->getSavePath()), pref->getSavePath()); loadSavePathHistory(); 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 // Load labels const QStringList customLabels = pref->getTorrentLabels(); const QString defaultLabel = pref->getDefaultLabel(); if (!defaultLabel.isEmpty()) ui->label_combo->addItem(defaultLabel); ui->label_combo->addItem(""); foreach (const QString& label, customLabels) if (label != defaultLabel) ui->label_combo->addItem(label); ui->label_combo->model()->sort(0); ui->content_tree->header()->setSortIndicator(0, Qt::AscendingOrder); loadState(); // Signal / slots connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool))); editHotkey = new QShortcut(QKeySequence("F2"), ui->content_tree, 0, 0, Qt::WidgetShortcut); connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile())); connect(ui->content_tree, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile())); ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus(); }