mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Hide/show input and status bar depending on whetever input has focus.
Added removal of downloads. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@283 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -15,7 +15,6 @@ DownloadList::insert(std::istream* str) {
|
||||
torrent::Download d = torrent::download_create(str);
|
||||
|
||||
iterator itr = Base::insert(end(), Download());
|
||||
|
||||
itr->set_download(d);
|
||||
|
||||
return itr;
|
||||
@@ -26,7 +25,6 @@ DownloadList::erase(iterator itr) {
|
||||
itr->release_download();
|
||||
|
||||
torrent::download_remove(itr->get_hash());
|
||||
|
||||
Base::erase(itr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <istream>
|
||||
@@ -37,6 +38,17 @@ Manager::insert(const std::string& uri) {
|
||||
create_http(uri);
|
||||
}
|
||||
|
||||
void
|
||||
Manager::erase(DownloadList::iterator itr) {
|
||||
if (itr->get_download().is_active())
|
||||
throw std::logic_error("core::Manager::erase(...) called on an active download");
|
||||
|
||||
if (itr->get_download().is_open())
|
||||
itr->close();
|
||||
|
||||
m_downloadList.erase(itr);
|
||||
}
|
||||
|
||||
void
|
||||
Manager::start(Download* d) {
|
||||
if (d->get_download().is_active())
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
void cleanup();
|
||||
|
||||
void insert(const std::string& uri);
|
||||
void erase(DownloadList::iterator itr);
|
||||
|
||||
void start(Download* d);
|
||||
void stop(Download* d);
|
||||
|
||||
+10
-9
@@ -1,15 +1,15 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "text_input.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace input {
|
||||
|
||||
bool
|
||||
TextInput::pressed(int key) {
|
||||
std::stringstream str;
|
||||
//std::stringstream str;
|
||||
|
||||
if (m_alt) {
|
||||
m_alt = false;
|
||||
@@ -32,6 +32,7 @@ TextInput::pressed(int key) {
|
||||
|
||||
} else {
|
||||
switch (key) {
|
||||
case 0x08:
|
||||
case KEY_BACKSPACE:
|
||||
if (m_pos != 0)
|
||||
Base::erase(--m_pos, 1);
|
||||
@@ -64,19 +65,19 @@ TextInput::pressed(int key) {
|
||||
break;
|
||||
|
||||
default:
|
||||
//return false;
|
||||
return false;
|
||||
|
||||
// Testcode.
|
||||
if (key == KEY_ENTER || key == '\n')
|
||||
return false;
|
||||
// if (key == KEY_ENTER || key == '\n')
|
||||
// return false;
|
||||
|
||||
str << "\\x" << std::hex << key;
|
||||
// str << "\\x" << std::hex << key;
|
||||
|
||||
Base::insert(m_pos, str.str());
|
||||
// Base::insert(m_pos, str.str());
|
||||
|
||||
m_pos += str.str().length();
|
||||
// m_pos += str.str().length();
|
||||
|
||||
return true;
|
||||
// return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-8
@@ -46,18 +46,21 @@ set_shutdown() {
|
||||
|
||||
void
|
||||
do_shutdown(ui::Control* c) {
|
||||
if (is_shutting_down)
|
||||
// Be quick about it...
|
||||
return;
|
||||
if (!is_shutting_down) {
|
||||
is_shutting_down = true;
|
||||
|
||||
is_shutting_down = true;
|
||||
torrent::listen_close();
|
||||
|
||||
torrent::listen_close();
|
||||
std::for_each(c->get_core().get_download_list().begin(), c->get_core().get_download_list().end(),
|
||||
std::mem_fun_ref(&core::Download::stop));
|
||||
|
||||
// TODO: Set display to a safe mode.
|
||||
} else {
|
||||
// Close all torrents, this will stop all tracker connections and cause
|
||||
// a quick shutdown.
|
||||
std::for_each(c->get_core().get_download_list().begin(), c->get_core().get_download_list().end(),
|
||||
std::mem_fun_ref(&core::Download::close));
|
||||
|
||||
std::for_each(c->get_core().get_download_list().begin(), c->get_core().get_download_list().end(),
|
||||
std::mem_fun_ref(&core::Download::stop));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+31
-15
@@ -20,17 +20,17 @@ namespace ui {
|
||||
DownloadList::DownloadList(Control* c) :
|
||||
m_title(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
|
||||
m_status(new WStatus),
|
||||
m_textInput(new WInput(new input::TextInput)),
|
||||
m_download(NULL),
|
||||
m_focus(c->get_core().get_download_list().end()),
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings),
|
||||
m_windowInput(new WInput(new input::TextInput)) {
|
||||
m_bindings(new input::Bindings) {
|
||||
|
||||
m_window = new WList(&m_control->get_core().get_download_list(), &m_focus);
|
||||
|
||||
bind_keys(m_bindings);
|
||||
|
||||
m_windowInput->get_input()->slot_dirty(sigc::mem_fun(*m_windowInput, &WInput::mark_dirty));
|
||||
m_textInput->get_input()->slot_dirty(sigc::mem_fun(*m_textInput, &WInput::mark_dirty));
|
||||
}
|
||||
|
||||
DownloadList::~DownloadList() {
|
||||
@@ -39,26 +39,31 @@ DownloadList::~DownloadList() {
|
||||
delete m_status;
|
||||
delete m_bindings;
|
||||
|
||||
delete m_windowInput->get_input();
|
||||
delete m_windowInput;
|
||||
delete m_textInput->get_input();
|
||||
delete m_textInput;
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::activate() {
|
||||
m_control->get_display().push_back(m_windowInput);
|
||||
m_control->get_input().push_front(m_bindings);
|
||||
|
||||
m_control->get_display().push_back(m_status);
|
||||
m_control->get_display().push_front(m_window);
|
||||
m_control->get_display().push_front(m_title);
|
||||
m_control->get_input().push_front(m_bindings);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::disable() {
|
||||
m_control->get_display().erase(m_windowInput);
|
||||
if (m_textInput->get_focus()) {
|
||||
m_textInput->get_input()->clear();
|
||||
receive_exit_input();
|
||||
}
|
||||
|
||||
m_control->get_input().erase(m_bindings);
|
||||
|
||||
m_control->get_display().erase(m_title);
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_status);
|
||||
m_control->get_input().erase(m_bindings);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -101,7 +106,10 @@ DownloadList::receive_stop_download() {
|
||||
if (m_focus == m_control->get_core().get_download_list().end())
|
||||
return;
|
||||
|
||||
m_control->get_core().stop(&*m_focus);
|
||||
if (m_focus->get_download().is_active())
|
||||
m_control->get_core().stop(&*m_focus);
|
||||
else
|
||||
m_control->get_core().erase(m_focus);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -136,9 +144,13 @@ DownloadList::receive_exit_download() {
|
||||
|
||||
void
|
||||
DownloadList::receive_view_input() {
|
||||
m_control->get_input().set_text_input(m_windowInput->get_input());
|
||||
m_control->get_display().erase(m_status);
|
||||
m_control->get_display().push_back(m_textInput);
|
||||
m_control->get_display().adjust_layout();
|
||||
|
||||
m_windowInput->set_focus(true);
|
||||
m_control->get_input().set_text_input(m_textInput->get_input());
|
||||
|
||||
m_textInput->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);
|
||||
@@ -146,12 +158,16 @@ DownloadList::receive_view_input() {
|
||||
|
||||
void
|
||||
DownloadList::receive_exit_input() {
|
||||
m_control->get_display().erase(m_textInput);
|
||||
m_control->get_display().push_back(m_status);
|
||||
m_control->get_display().adjust_layout();
|
||||
|
||||
m_control->get_input().set_text_input();
|
||||
|
||||
m_slotOpenUri(m_windowInput->get_input()->str());
|
||||
m_slotOpenUri(m_textInput->get_input()->str());
|
||||
|
||||
m_windowInput->get_input()->clear();
|
||||
m_windowInput->set_focus(false);
|
||||
m_textInput->get_input()->clear();
|
||||
m_textInput->set_focus(false);
|
||||
|
||||
m_bindings->erase('\n');
|
||||
m_bindings->erase(KEY_ENTER);
|
||||
|
||||
@@ -62,6 +62,7 @@ private:
|
||||
WList* m_window;
|
||||
WTitle* m_title;
|
||||
WStatus* m_status;
|
||||
WInput* m_textInput;
|
||||
|
||||
Download* m_download;
|
||||
|
||||
@@ -72,9 +73,6 @@ private:
|
||||
input::Bindings* m_bindings;
|
||||
|
||||
SlotOpenUri m_slotOpenUri;
|
||||
|
||||
// Test
|
||||
WInput* m_windowInput;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user