mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-13 13:42:30 +00:00
Work on an input field.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@272 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+34
-6
@@ -24,7 +24,7 @@ Download::Download(DPtr d, Control* c) :
|
||||
m_title(c->get_display().end()),
|
||||
m_window(c->get_display().end()),
|
||||
m_downloadStatus(c->get_display().end()),
|
||||
m_status(c->get_display().end()),
|
||||
m_mainStatus(c->get_display().end()),
|
||||
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings) {
|
||||
@@ -55,7 +55,7 @@ Download::activate() {
|
||||
m_window = m_control->get_display().insert(m_control->get_display().begin(), NULL);
|
||||
m_title = m_control->get_display().insert(m_control->get_display().begin(), new WTitle(m_download->get_download().get_name()));
|
||||
m_downloadStatus = m_control->get_display().insert(m_control->get_display().end(), new WDownloadStatus(m_download));
|
||||
m_status = m_control->get_display().insert(m_control->get_display().end(), new WStatus);
|
||||
m_mainStatus = m_control->get_display().insert(m_control->get_display().end(), new WMainStatus);
|
||||
|
||||
m_control->get_input().push_front(m_bindings);
|
||||
|
||||
@@ -71,14 +71,14 @@ Download::disable() {
|
||||
|
||||
delete *m_title;
|
||||
delete *m_downloadStatus;
|
||||
delete *m_status;
|
||||
delete *m_mainStatus;
|
||||
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_title);
|
||||
m_control->get_display().erase(m_downloadStatus);
|
||||
m_control->get_display().erase(m_status);
|
||||
m_control->get_display().erase(m_mainStatus);
|
||||
|
||||
m_window = m_title = m_downloadStatus = m_status = m_control->get_display().end();
|
||||
m_window = m_title = m_downloadStatus = m_mainStatus = m_control->get_display().end();
|
||||
|
||||
m_control->get_input().erase(m_bindings);
|
||||
}
|
||||
@@ -180,11 +180,32 @@ Download::receive_peer_disconnected(torrent::Peer p) {
|
||||
|
||||
void
|
||||
Download::receive_throttle(int t) {
|
||||
(*m_status)->mark_dirty();
|
||||
(*m_mainStatus)->mark_dirty();
|
||||
|
||||
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_max_uploads(int t) {
|
||||
(*m_downloadStatus)->mark_dirty();
|
||||
|
||||
m_download->get_download().set_uploads_max(std::max(m_download->get_download().get_uploads_max() + t, (uint32_t)2));
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_min_peers(int t) {
|
||||
(*m_downloadStatus)->mark_dirty();
|
||||
|
||||
m_download->get_download().set_peers_min(std::max(m_download->get_download().get_peers_min() + t, (uint32_t)5));
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_max_peers(int t) {
|
||||
(*m_downloadStatus)->mark_dirty();
|
||||
|
||||
m_download->get_download().set_peers_max(std::max(m_download->get_download().get_peers_max() + t, (uint32_t)5));
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_change(Display d) {
|
||||
if (d == m_state)
|
||||
@@ -204,6 +225,13 @@ Download::bind_keys(input::Bindings* b) {
|
||||
(*b)['d'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), 50);
|
||||
(*b)['c'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_throttle), -50);
|
||||
|
||||
(*b)['1'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_uploads), -1);
|
||||
(*b)['2'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_uploads), 1);
|
||||
(*b)['3'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_min_peers), -5);
|
||||
(*b)['4'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_min_peers), 5);
|
||||
(*b)['5'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_peers), -5);
|
||||
(*b)['6'] = sigc::bind(sigc::mem_fun(*this, &Download::receive_max_peers), 5);
|
||||
|
||||
(*b)['t'] = sigc::bind(sigc::mem_fun(m_download->get_download(), &torrent::Download::set_tracker_timeout), 2 * 1000000);
|
||||
|
||||
(*b)[KEY_UP] = sigc::mem_fun(*this, &Download::receive_prev);
|
||||
|
||||
+5
-2
@@ -27,7 +27,7 @@ public:
|
||||
typedef display::WindowPeerInfo WPeerInfo;
|
||||
typedef display::WindowPeerList WPeerList;
|
||||
typedef display::WindowTitle WTitle;
|
||||
typedef display::WindowStatusbar WStatus;
|
||||
typedef display::WindowStatusbar WMainStatus;
|
||||
typedef display::WindowDownloadStatusbar WDownloadStatus;
|
||||
|
||||
typedef core::Download* DPtr;
|
||||
@@ -64,6 +64,9 @@ private:
|
||||
void receive_peer_disconnected(torrent::Peer p);
|
||||
|
||||
void receive_throttle(int t);
|
||||
void receive_max_uploads(int t);
|
||||
void receive_min_peers(int t);
|
||||
void receive_max_peers(int t);
|
||||
void receive_change(Display d);
|
||||
|
||||
void bind_keys(input::Bindings* b);
|
||||
@@ -79,7 +82,7 @@ private:
|
||||
MItr m_title;
|
||||
MItr m_window;
|
||||
MItr m_downloadStatus;
|
||||
MItr m_status;
|
||||
MItr m_mainStatus;
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings* m_bindings;
|
||||
|
||||
+33
-1
@@ -5,9 +5,11 @@
|
||||
#include <sigc++/bind.h>
|
||||
|
||||
#include "input/bindings.h"
|
||||
#include "input/text_input.h"
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_download_list.h"
|
||||
#include "display/window_statusbar.h"
|
||||
#include "display/window_input.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
@@ -22,11 +24,14 @@ DownloadList::DownloadList(core::DownloadList* l, Control* c) :
|
||||
m_list(l),
|
||||
m_focus(l->end()),
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings) {
|
||||
m_bindings(new input::Bindings),
|
||||
m_windowInput(new WInput(new input::TextInput)) {
|
||||
|
||||
m_window = new WList(m_list, &m_focus);
|
||||
|
||||
bind_keys(m_bindings);
|
||||
|
||||
m_windowInput->get_input()->slot_dirty(sigc::mem_fun(*m_windowInput, &WInput::mark_dirty));
|
||||
}
|
||||
|
||||
DownloadList::~DownloadList() {
|
||||
@@ -34,10 +39,14 @@ DownloadList::~DownloadList() {
|
||||
delete m_title;
|
||||
delete m_status;
|
||||
delete m_bindings;
|
||||
|
||||
delete m_windowInput->get_input();
|
||||
delete m_windowInput;
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::activate() {
|
||||
m_control->get_display().push_back(m_windowInput);
|
||||
m_control->get_display().push_back(m_status);
|
||||
m_control->get_display().push_front(m_window);
|
||||
m_control->get_display().push_front(m_title);
|
||||
@@ -46,6 +55,7 @@ DownloadList::activate() {
|
||||
|
||||
void
|
||||
DownloadList::disable() {
|
||||
m_control->get_display().erase(m_windowInput);
|
||||
m_control->get_display().erase(m_title);
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_status);
|
||||
@@ -109,6 +119,27 @@ DownloadList::receive_throttle(int t) {
|
||||
torrent::set(torrent::THROTTLE_ROOT_CONST_RATE, torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) + t * 1024);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_view_input() {
|
||||
m_control->get_input().set_text_input(m_windowInput->get_input());
|
||||
|
||||
m_windowInput->set_focus(true);
|
||||
|
||||
(*m_bindings)['\n'] = sigc::mem_fun(*this, &DownloadList::receive_exit_input);
|
||||
(*m_bindings)[KEY_ENTER] = sigc::mem_fun(*this, &DownloadList::receive_exit_input);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_exit_input() {
|
||||
m_control->get_input().set_text_input();
|
||||
|
||||
m_windowInput->get_input()->clear();
|
||||
m_windowInput->set_focus(false);
|
||||
|
||||
m_bindings->erase('\n');
|
||||
m_bindings->erase(KEY_ENTER);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::bind_keys(input::Bindings* b) {
|
||||
(*b)['a'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_throttle), 1);
|
||||
@@ -122,6 +153,7 @@ DownloadList::bind_keys(input::Bindings* b) {
|
||||
(*b)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
|
||||
(*b)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
|
||||
|
||||
(*b)[KEY_BACKSPACE] = sigc::mem_fun(*this, &DownloadList::receive_view_input);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace display {
|
||||
class WindowTitle;
|
||||
class WindowDownloadList;
|
||||
class WindowStatusbar;
|
||||
class WindowInput;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
typedef display::WindowDownloadList WList;
|
||||
typedef display::WindowTitle WTitle;
|
||||
typedef display::WindowStatusbar WStatus;
|
||||
typedef display::WindowInput WInput;
|
||||
typedef core::DownloadList DList;
|
||||
|
||||
// We own 'window'.
|
||||
@@ -41,6 +43,9 @@ private:
|
||||
|
||||
void receive_throttle(int t);
|
||||
|
||||
void receive_view_input();
|
||||
void receive_exit_input();
|
||||
|
||||
void bind_keys(input::Bindings* b);
|
||||
|
||||
void mark_dirty();
|
||||
@@ -56,6 +61,9 @@ private:
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings* m_bindings;
|
||||
|
||||
// Test
|
||||
WInput* m_windowInput;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user