Skip to content

Commit

Permalink
Merge pull request #1073 from vktr/feature/add-seed-mode-flag
Browse files Browse the repository at this point in the history
Add 'Seed mode' flag to 'Add torrent' dialog
  • Loading branch information
vktr committed Dec 20, 2020
2 parents 72c28c2 + 91ec63e commit 593af87
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
"tier": "Tier",
"some_torrents_already_in_session": "Some of the torrents are already added and will be skipped",
"all_torrents_already_in_session": "All torrents are already added and will be skipped",
"seed_mode": "Seed mode",
"connections": "Connections",
"view_help": "View &Help"
}
14 changes: 14 additions & 0 deletions src/picotorrent/ui/dialogs/addtorrentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ AddTorrentDialog::AddTorrentDialog(wxWindow* parent, wxWindowID id, lt::add_torr
m_torrentLabel = new wxBitmapComboBox(optionsSizer->GetStaticBox(), ptID_LABEL_COMBO, "", wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
m_sequentialDownload = new wxCheckBox(optionsSizer->GetStaticBox(), ptID_SEQUENTIAL_DOWNLOAD, i18n("sequential_download"));
m_startTorrent = new wxCheckBox(optionsSizer->GetStaticBox(), ptID_START_TORRENT, i18n("start_torrent"));
m_seedMode = new wxCheckBox(optionsSizer->GetStaticBox(), ptID_SEED_MODE, i18n("seed_mode"));

auto optionsGrid = new wxFlexGridSizer(2, FromDIP(7), FromDIP(10));
optionsGrid->AddGrowableCol(1, 1);
Expand All @@ -63,6 +64,7 @@ AddTorrentDialog::AddTorrentDialog(wxWindow* parent, wxWindowID id, lt::add_torr
auto flagsGrid = new wxFlexGridSizer(2, FromDIP(7), FromDIP(10));
flagsGrid->Add(m_sequentialDownload, 1, wxALL);
flagsGrid->Add(m_startTorrent, 1, wxALL);
flagsGrid->Add(m_seedMode, 1, wxALL);

optionsGrid->AddSpacer(1);
optionsGrid->Add(flagsGrid, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, FromDIP(3));
Expand Down Expand Up @@ -292,6 +294,15 @@ AddTorrentDialog::AddTorrentDialog(wxWindow* parent, wxWindowID id, lt::add_torr
},
ptID_START_TORRENT);

this->Bind(
wxEVT_CHECKBOX,
[this](wxCommandEvent&)
{
if (m_seedMode->IsChecked()) { m_params.flags |= lt::torrent_flags::seed_mode; }
else { m_params.flags &= ~lt::torrent_flags::seed_mode; }
},
ptID_SEED_MODE);

this->Bind(wxEVT_BUTTON, &AddTorrentDialog::OnAddTracker, this, ptID_TRACKERS_ADD);
this->Bind(wxEVT_BUTTON, &AddTorrentDialog::OnRemoveTracker, this, ptID_TRACKERS_REMOVE);
this->Bind(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, &AddTorrentDialog::ShowFileContextMenu, this, ptID_FILE_LIST);
Expand Down Expand Up @@ -421,6 +432,9 @@ void AddTorrentDialog::Load()

m_startTorrent->SetValue(!isPaused);

m_seedMode->SetValue(
(m_params.flags & lt::torrent_flags::seed_mode) == lt::torrent_flags::seed_mode);

if (m_params.ti)
{
// Files
Expand Down
2 changes: 2 additions & 0 deletions src/picotorrent/ui/dialogs/addtorrentdialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace Dialogs
ptID_FILE_LIST,
ptID_SEQUENTIAL_DOWNLOAD,
ptID_START_TORRENT,
ptID_SEED_MODE,
ptID_TRACKERS_ADD,
ptID_TRACKERS_REMOVE,
ptID_OK,
Expand Down Expand Up @@ -100,6 +101,7 @@ namespace Dialogs
wxDataViewCtrl* m_filesView;
wxCheckBox* m_sequentialDownload;
wxCheckBox* m_startTorrent;
wxCheckBox* m_seedMode;
wxListView* m_peers;
wxListView* m_trackers;
wxButton* m_addTracker;
Expand Down

0 comments on commit 593af87

Please sign in to comment.