mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 07:09:21 +00:00
Alot of UI work, resize fixed.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@253 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
noinst_LIBRARIES = libsub_ui.a
|
||||
|
||||
libsub_ui_a_SOURCES = \
|
||||
control.h \
|
||||
download.cc \
|
||||
download.h \
|
||||
download_list.cc \
|
||||
download_list.h
|
||||
|
||||
INCLUDES = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "input/bindings.h"
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_peer_list.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
Download::Download(DPtr d, Control* c) :
|
||||
m_download(d),
|
||||
m_title(new WTitle(d->get_download().get_name())),
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings) {
|
||||
|
||||
m_window = new WPeerList(&m_peers);
|
||||
m_window->slot_chunks_total(sigc::mem_fun(m_download->get_download(), &torrent::Download::get_chunks_total));
|
||||
|
||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &Download::receive_prev);
|
||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &Download::receive_next);
|
||||
|
||||
m_download->get_download().peer_list(m_peers);
|
||||
|
||||
m_connPeerConnected = m_download->get_download().signal_peer_connected(sigc::mem_fun(*this, &Download::receive_peer_connected));
|
||||
m_connPeerDisconnected = m_download->get_download().signal_peer_disconnected(sigc::mem_fun(*this, &Download::receive_peer_disconnected));
|
||||
}
|
||||
|
||||
Download::~Download() {
|
||||
m_connPeerConnected.disconnect();
|
||||
m_connPeerDisconnected.disconnect();
|
||||
|
||||
delete m_window;
|
||||
delete m_title;
|
||||
delete m_bindings;
|
||||
}
|
||||
|
||||
void
|
||||
Download::activate() {
|
||||
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
|
||||
Download::disable() {
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_display().erase(m_title);
|
||||
m_control->get_input().erase(m_bindings);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_next() {
|
||||
if (m_window->get_focus() == m_window->get_list().end())
|
||||
m_window->set_focus(m_window->get_list().begin());
|
||||
else
|
||||
m_window->set_focus(++m_window->get_focus());
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_prev() {
|
||||
if (m_window->get_focus() == m_window->get_list().begin())
|
||||
m_window->set_focus(m_window->get_list().end());
|
||||
else
|
||||
m_window->set_focus(--m_window->get_focus());
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_peer_connected(torrent::Peer p) {
|
||||
m_peers.push_back(p);
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_peer_disconnected(torrent::Peer p) {
|
||||
PList::iterator itr = std::find(m_peers.begin(), m_peers.end(), p);
|
||||
|
||||
if (itr == m_peers.end())
|
||||
throw std::logic_error("Download::receive_peer_disconnected(...) received a peer we don't have in our list");
|
||||
|
||||
if (itr == m_window->get_focus())
|
||||
m_window->set_focus(m_peers.erase(itr));
|
||||
else
|
||||
m_peers.erase(itr);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef RTORRENT_UI_DOWNLOAD_H
|
||||
#define RTORRENT_UI_DOWNLOAD_H
|
||||
|
||||
#include <list>
|
||||
#include <torrent/peer.h>
|
||||
#include <sigc++/connection.h>
|
||||
|
||||
#include "core/download_list.h"
|
||||
|
||||
namespace display {
|
||||
class WindowTitle;
|
||||
class WindowPeerList;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Control;
|
||||
|
||||
class Download {
|
||||
public:
|
||||
typedef display::WindowPeerList WPeerList;
|
||||
typedef display::WindowTitle WTitle;
|
||||
typedef core::DownloadList::iterator DPtr;
|
||||
typedef std::list<torrent::Peer> PList;
|
||||
|
||||
// We own 'window'.
|
||||
Download(DPtr d, Control* c);
|
||||
~Download();
|
||||
|
||||
WPeerList& get_window() { return *m_window; }
|
||||
input::Bindings& get_bindings() { return *m_bindings; }
|
||||
|
||||
void activate();
|
||||
void disable();
|
||||
|
||||
private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_peer_connected(torrent::Peer p);
|
||||
void receive_peer_disconnected(torrent::Peer p);
|
||||
|
||||
DPtr m_download;
|
||||
PList m_peers;
|
||||
|
||||
WPeerList* m_window;
|
||||
WTitle* m_title;
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings* m_bindings;
|
||||
|
||||
sigc::connection m_connPeerConnected;
|
||||
sigc::connection m_connPeerDisconnected;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <torrent/torrent.h>
|
||||
|
||||
#include "input/bindings.h"
|
||||
#include "display/window_title.h"
|
||||
#include "display/window_download_list.h"
|
||||
|
||||
#include "control.h"
|
||||
#include "download.h"
|
||||
#include "download_list.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
DownloadList::DownloadList(core::DownloadList* l, Control* c) :
|
||||
m_window(new WList(l)),
|
||||
m_title(new WTitle("rtorrent " VERSION " - " + torrent::get(torrent::LIBRARY_NAME))),
|
||||
m_download(NULL),
|
||||
m_control(c),
|
||||
m_bindings(new input::Bindings) {
|
||||
|
||||
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
|
||||
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
|
||||
(*m_bindings)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
|
||||
}
|
||||
|
||||
DownloadList::~DownloadList() {
|
||||
delete m_window;
|
||||
delete m_title;
|
||||
delete m_bindings;
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::activate() {
|
||||
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_title);
|
||||
m_control->get_display().erase(m_window);
|
||||
m_control->get_input().erase(m_bindings);
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_next() {
|
||||
if (m_window->get_focus() == m_window->get_list().end())
|
||||
m_window->set_focus(m_window->get_list().begin());
|
||||
else
|
||||
m_window->set_focus(++m_window->get_focus());
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_prev() {
|
||||
if (m_window->get_focus() == m_window->get_list().begin())
|
||||
m_window->set_focus(m_window->get_list().end());
|
||||
else
|
||||
m_window->set_focus(--m_window->get_focus());
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_view_download() {
|
||||
if (m_window->get_focus() == m_window->get_list().end())
|
||||
return;
|
||||
|
||||
disable();
|
||||
|
||||
m_download = new Download(m_window->get_focus(), m_control);
|
||||
|
||||
m_download->get_bindings()[KEY_LEFT] = sigc::mem_fun(*this, &DownloadList::receive_exit_download);
|
||||
m_download->activate();
|
||||
|
||||
m_control->get_display().adjust_layout();
|
||||
}
|
||||
|
||||
void
|
||||
DownloadList::receive_exit_download() {
|
||||
if (m_download == NULL)
|
||||
throw std::logic_error("DownloadList::receive_exit_download() called but m_download == NULL");
|
||||
|
||||
m_download->disable();
|
||||
delete m_download;
|
||||
m_download = NULL;
|
||||
|
||||
activate();
|
||||
|
||||
m_control->get_display().adjust_layout();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef RTORRENT_UI_DOWNLOAD_LIST_H
|
||||
#define RTORRENT_UI_DOWNLOAD_LIST_H
|
||||
|
||||
namespace display {
|
||||
class WindowTitle;
|
||||
class WindowDownloadList;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Control;
|
||||
class Download;
|
||||
|
||||
class DownloadList {
|
||||
public:
|
||||
typedef display::WindowDownloadList WList;
|
||||
typedef display::WindowTitle WTitle;
|
||||
|
||||
// We own 'window'.
|
||||
DownloadList(core::DownloadList* l, Control* c);
|
||||
~DownloadList();
|
||||
|
||||
WList& get_window() { return *m_window; }
|
||||
input::Bindings& get_bindings() { return *m_bindings; }
|
||||
|
||||
void activate();
|
||||
void disable();
|
||||
|
||||
private:
|
||||
void receive_next();
|
||||
void receive_prev();
|
||||
|
||||
void receive_view_download();
|
||||
void receive_exit_download();
|
||||
|
||||
WList* m_window;
|
||||
WTitle* m_title;
|
||||
|
||||
Download* m_download;
|
||||
|
||||
Control* m_control;
|
||||
input::Bindings* m_bindings;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user