- Moved everything to trunk to create a stable branch

This commit is contained in:
Christophe Dumez 2006-09-30 16:02:39 +00:00
commit 969a02b93e
200 changed files with 46382 additions and 0 deletions

162
src/DLListDelegate.h Normal file
View file

@ -0,0 +1,162 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef DLLISTDELEGATE_H
#define DLLISTDELEGATE_H
#include <QAbstractItemDelegate>
#include <QModelIndex>
#include <QPainter>
#include <QStyleOptionProgressBarV2>
#include <QProgressBar>
#include <QApplication>
#include "misc.h"
// Defines for download list list columns
#define NAME 0
#define SIZE 1
#define PROGRESS 2
#define DLSPEED 3
#define UPSPEED 4
#define STATUS 5
#define ETA 6
class DLListDelegate: public QAbstractItemDelegate {
Q_OBJECT
public:
DLListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
~DLListDelegate(){}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
QStyleOptionViewItem opt = option;
char tmp[MAX_CHAR_TMP];
// set text color
QVariant value = index.data(Qt::TextColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
}
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (option.state & QStyle::State_Selected){
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
}else{
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
// draw the background color
if(index.column() != PROGRESS){
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
cg = QPalette::Inactive;
}
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
}else{
value = index.data(Qt::BackgroundColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
}
}
}
switch(index.column()){
case SIZE:
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
break;
case ETA:
painter->drawText(option.rect, Qt::AlignCenter, misc::userFriendlyDuration(index.data().toLongLong()));
break;
case UPSPEED:
case DLSPEED:{
float speed = index.data().toDouble();
snprintf(tmp, MAX_CHAR_TMP, "%.1f", speed/1024.);
painter->drawText(option.rect, Qt::AlignCenter, QString(tmp)+" "+tr("KiB/s"));
break;
}
case PROGRESS:{
QStyleOptionProgressBarV2 newopt;
float progress;
progress = index.data().toDouble()*100.;
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
newopt.rect = opt.rect;
newopt.text = QString(tmp)+"%";
newopt.progress = (int)progress;
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = false;
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
painter);
//We prefer to display text manually to control color/font/boldness
if (option.state & QStyle::State_Selected){
opt.palette.setColor(QPalette::Text, QColor("grey"));
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
}
case NAME:{
// decoration
value = index.data(Qt::DecorationRole);
QPixmap pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);
QRect pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
if (pixmapRect.isValid()){
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
painter->drawPixmap(p, pixmap);
}
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, index.data().toString());
break;
}
default:
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
}
}
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
QVariant value = index.data(Qt::FontRole);
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
QFontMetrics fontMetrics(fnt);
const QString text = index.data(Qt::DisplayRole).toString();
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
return textRect.size();
}
// QWidget* createEditor(QWidget * parent, const QStyleOptionViewItem& /*option*/, const QModelIndex & index) const{
// if(index.column() == PROGRESS){
// QProgressBar *progressBar = new QProgressBar(parent);
// progressBar->setRange(0,100);
// progressBar->installEventFilter(const_cast<DLListDelegate*>(this));
// return progressBar;
// }
// return 0;
// }
// void setEditorData(QWidget *editor, const QModelIndex &index) const{
// QProgressBar *progressBar = static_cast<QProgressBar*>(editor);
// float progress = index.data().toDouble();
// progressBar->setValue((int)(progress*100.));
// }
// void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & index) const{
// if(index.column() == PROGRESS){
// editor->setGeometry(option.rect);
// }
// }
};
#endif

2192
src/GUI.cpp Normal file

File diff suppressed because it is too large Load diff

195
src/GUI.h Normal file
View file

@ -0,0 +1,195 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef GUI_H
#define GUI_H
#include <QMainWindow>
#include <QMap>
#include <QProcess>
#include <QTcpServer>
#include <QTcpSocket>
#include <libtorrent/entry.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/session.hpp>
#include <libtorrent/fingerprint.hpp>
#include <libtorrent/session_settings.hpp>
#include <libtorrent/identify_client.hpp>
#include <libtorrent/alert_types.hpp>
#include "ui_MainWindow.h"
#include "options_imp.h"
#include "about_imp.h"
#include "OSD.h"
#include "previewSelect.h"
#include "trackerLogin.h"
class createtorrent;
class QTimer;
class TrayIcon;
class DLListDelegate;
class SearchListDelegate;
class downloadThread;
class downloadFromURL;
using namespace libtorrent;
namespace fs = boost::filesystem;
class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
private:
// Bittorrent
session *s;
std::pair<unsigned short, unsigned short> listenPorts;
QMap<QString, torrent_handle> handles;
QTimer *checkConnect;
QTimer *timerScan;
QMap<QString, QStringList> trackerErrors;
trackerLogin *tracker_login;
QList<QPair<torrent_handle,std::string> > unauthenticated_trackers;
downloadThread *downloader;
downloadFromURL *downloadFromURLDialog;
bool DHTEnabled;
// GUI related
options_imp *options;
createtorrent *createWindow;
QTimer *refresher;
TrayIcon *myTrayIcon;
QMenu *myTrayIconMenu;
about *aboutdlg;
QStandardItemModel *DLListModel;
DLListDelegate *DLDelegate;
QStandardItemModel *SearchListModel;
SearchListDelegate *SearchDelegate;
QStringList supported_preview_extensions;
// Preview
previewSelect *previewSelection;
QProcess *previewProcess;
// Search related
QMap<QString, QString> searchResultsUrls;
QProcess *searchProcess;
bool search_stopped;
bool no_search_results;
QByteArray search_result_line_truncated;
unsigned long nb_search_results;
OSD *OSDWindow;
QTcpServer *tcpServer;
QTcpSocket *clientConnection;
protected slots:
// GUI related slots
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void centerWindow();
void toggleVisibility();
void showAbout();
void setInfoBar(const QString& info, const QString& color="black");
void updateDlList();
void showCreateWindow();
void clearLog();
void AnotherInstanceConnected();
void readParamsInFile();
void saveCheckedSearchEngines(int) const;
void saveColWidthDLList() const;
void saveColWidthSearchList() const;
void loadCheckedSearchEngines();
bool loadColWidthDLList();
bool loadColWidthSearchList();
void saveWindowSize() const;
void loadWindowSize();
void sortDownloadList(int index);
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
void sortSearchList(int index);
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
void sortSearchListString(int index, Qt::SortOrder sortOrder);
void displayDLListMenu(const QPoint& pos);
void selectGivenRow(const QModelIndex& index);
void togglePausedState(const QModelIndex& index);
void displayInfoBarMenu(const QPoint& pos);
void displayGUIMenu(const QPoint& pos);
void previewFileSelection();
void previewFile(const QString& filePath);
void cleanTempPreviewFile(int, QProcess::ExitStatus);
// Torrent actions
void showProperties(const QModelIndex &index);
void propertiesSelection();
void addTorrents(const QStringList& pathsList, bool fromScanDir = false, const QString& from_url = QString());
void pauseAll();
void startAll();
void pauseSelection();
void startSelection();
void askForTorrents();
void deleteAll();
void deleteSelection();
void resumeUnfinished();
void saveFastResumeData() const;
void checkConnectionStatus();
void scanDirectory();
void setGlobalRatio(float ratio);
void configureSession();
void ProcessParams(const QStringList& params);
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
void processDownloadedFile(QString url, QString file_path, int return_code, QString errorBuffer);
void downloadFromURLList(const QStringList& url_list);
// Search slots
void on_search_button_clicked();
void on_stop_search_button_clicked();
void on_clear_button_clicked();
void on_download_button_clicked();
void on_update_nova_button_clicked();
void appendSearchResult(const QString& line);
void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput();
void searchStarted();
void downloadSelectedItem(const QModelIndex& index);
// Utils slots
void setRowColor(int row, const QString& color, bool inDLList=true);
// Options slots
void showOptions() const;
void OptionsSaved(const QString& info);
// HTTP slots
void downloadFromUrl(const QString& url);
void askForTorrentUrl();
public slots:
void setLocale(QString locale);
protected:
void closeEvent(QCloseEvent *);
void hideEvent(QHideEvent *);
public:
// Construct / Destruct
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI();
// Methods
int getRowFromName(const QString& name) const;
float getNovaVersion(const QString& novaPath) const;
QByteArray getNovaChangelog(const QString& novaPath) const;
void updateNova() const;
bool isFilePreviewPossible(const torrent_handle& h) const;
};
#endif

BIN
src/Icons/button_cancel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/Icons/button_ok.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/Icons/encrypted.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

BIN
src/Icons/filter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

BIN
src/Icons/flags/china.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

BIN
src/Icons/flags/france.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
src/Icons/flags/germany.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

BIN
src/Icons/flags/greece.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

BIN
src/Icons/flags/italy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

BIN
src/Icons/flags/poland.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

BIN
src/Icons/flags/romania.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
src/Icons/flags/russia.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/Icons/flags/spain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

BIN
src/Icons/flags/sweden.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

BIN
src/Icons/flags/turkey.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

BIN
src/Icons/flags/ukraine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

BIN
src/Icons/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/Icons/locale.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/Icons/log.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

BIN
src/Icons/proxy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,26 @@
[Desktop Entry]
Categories=Qt;Application;Network;P2P
Comment=V0.6.0
Encoding=UTF-8
Exec=qbittorrent
GenericName=Bittorrent client
GenericName[fr]=Client Bittorrent
GenericName[nl]=Bittorrent client
GenericName[es]=Cliente Bittorrent
GenericName[sv]=Bittorrent-klient
GenericName[tr]=Bittorrent istemcisi
GenericName[de]=Bittorren Client
GenericName[pl]=Klient Bittorrent
GenericName[zh]=Bittorrent
GenericName[ko]=
GenericName[el]=Τορεντ πελάτης
GenericName[bg]=Торент клиент
GenericName[uk]=Bittorrent-клієнт
GenericName[ru]=клиент Bittorrent
Icon=qbittorrent
MimeType=application/x-bittorrent
Name=qBittorrent
Name[ko]=
Terminal=false
Type=Application

BIN
src/Icons/qbittorrent16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 965 B

BIN
src/Icons/qbittorrent22.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

BIN
src/Icons/qbittorrent32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
src/Icons/skin/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

BIN
src/Icons/skin/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

BIN
src/Icons/skin/exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
src/Icons/skin/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/Icons/skin/new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/Icons/skin/open.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
src/Icons/skin/pause.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/Icons/skin/paused.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

BIN
src/Icons/skin/play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/Icons/skin/play_all.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/Icons/skin/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/Icons/skin/remove.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

BIN
src/Icons/skin/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/Icons/skin/seeding.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

BIN
src/Icons/skin/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/Icons/skin/stalled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

BIN
src/Icons/skin/url.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
src/Icons/smile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

BIN
src/Icons/splash.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
src/Icons/stare.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
src/Icons/style.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/Icons/systemtray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/Icons/unhappy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

BIN
src/Icons/wizard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

930
src/MainWindow.ui Normal file
View file

@ -0,0 +1,930 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>849</width>
<height>526</height>
</rect>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle" >
<string/>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTabWidget" name="tabs" >
<property name="tabPosition" >
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<string>Transfers</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QWidget" name="widget" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lbl_DLSpeed" >
<property name="text" >
<string>Total DL Speed:</string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="LCD_DownSpeed" >
<property name="autoFillBackground" >
<bool>true</bool>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<property name="smallDecimalPoint" >
<bool>false</bool>
</property>
<property name="numDigits" >
<number>6</number>
</property>
<property name="segmentStyle" >
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0" >
<double>0</double>
</property>
<property name="intValue" stdset="0" >
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="unitDL" >
<property name="text" >
<string>KiB/s</string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Session ratio: </string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="LCD_Ratio" >
<property name="autoFillBackground" >
<bool>true</bool>
</property>
<property name="numDigits" >
<number>4</number>
</property>
<property name="segmentStyle" >
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0" >
<double>1</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_ratio_icon" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lbl_UPSpeed" >
<property name="text" >
<string>Total UP Speed:</string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="LCD_UpSpeed" >
<property name="autoFillBackground" >
<bool>true</bool>
</property>
<property name="smallDecimalPoint" >
<bool>false</bool>
</property>
<property name="numDigits" >
<number>6</number>
</property>
<property name="segmentStyle" >
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0" >
<double>0</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="unitUP" >
<property name="text" >
<string>KiB/s</string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="downloadList" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="autoScroll" >
<bool>true</bool>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="indentation" >
<number>1</number>
</property>
<property name="itemsExpandable" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="layoutWidget_3" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="info_icon" >
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_info" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Log:</string>
</property>
<property name="alignment" >
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>661</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="infoBar" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>123</height>
</size>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2" >
<attribute name="title" >
<string>Search</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="groupEngines" >
<property name="minimumSize" >
<size>
<width>131</width>
<height>132</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>125</width>
<height>132</height>
</size>
</property>
<property name="title" >
<string>Search Engines</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="mininova" >
<property name="text" >
<string/>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="piratebay" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="reactor" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="isohunt" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="btjunkie" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="meganova" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="search_lbl" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Search Pattern:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="search_pattern" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="search_button" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>29</height>
</size>
</property>
<property name="text" >
<string>Search</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stop_search_button" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>29</height>
</size>
</property>
<property name="text" >
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="status_lbl" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="search_status" >
<property name="minimumSize" >
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>35</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>true</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Stopped</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="results_lbl" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Results:</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>721</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="resultsBrowser" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="autoScroll" >
<bool>true</bool>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="indentation" >
<number>1</number>
</property>
<property name="itemsExpandable" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="download_button" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Download</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clear_button" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Clear</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>601</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="update_nova_button" >
<property name="text" >
<string>Update search plugin</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>849</width>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menu_Help" >
<property name="title" >
<string>&amp;Help</string>
</property>
<addaction name="actionAbout" />
</widget>
<widget class="QMenu" name="menu_Options" >
<property name="title" >
<string>&amp;Options</string>
</property>
<addaction name="actionOptions" />
</widget>
<widget class="QMenu" name="menu_Edit" >
<property name="title" >
<string>&amp;Edit</string>
</property>
<addaction name="actionStart_All" />
<addaction name="actionPause_All" />
<addaction name="separator" />
<addaction name="actionStart" />
<addaction name="actionPause" />
<addaction name="separator" />
<addaction name="actionTorrent_Properties" />
<addaction name="separator" />
<addaction name="actionDelete" />
<addaction name="actionDelete_All" />
</widget>
<widget class="QMenu" name="menu_File" >
<property name="title" >
<string>&amp;File</string>
</property>
<addaction name="actionOpen" />
<addaction name="actionDownload_from_URL" />
<addaction name="actionCreate_torrent" />
<addaction name="actionExit" />
</widget>
<addaction name="menu_File" />
<addaction name="menu_Edit" />
<addaction name="menu_Options" />
<addaction name="menu_Help" />
</widget>
<widget class="QStatusBar" name="statusbar" />
<widget class="QToolBar" name="toolBar" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="movable" >
<bool>false</bool>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<attribute name="toolBarArea" >
<number>4</number>
</attribute>
<addaction name="actionOpen" />
<addaction name="actionDownload_from_URL" />
<addaction name="separator" />
<addaction name="actionDelete" />
<addaction name="actionDelete_All" />
<addaction name="separator" />
<addaction name="actionTorrent_Properties" />
<addaction name="separator" />
<addaction name="actionStart" />
<addaction name="actionPause" />
<addaction name="separator" />
<addaction name="actionStart_All" />
<addaction name="actionPause_All" />
<addaction name="separator" />
<addaction name="actionOptions" />
<addaction name="actionExit" />
<addaction name="separator" />
<addaction name="actionConnexion_Status" />
</widget>
<action name="actionOpen" >
<property name="text" >
<string>Open</string>
</property>
</action>
<action name="actionExit" >
<property name="text" >
<string>Exit</string>
</property>
</action>
<action name="actionOptions" >
<property name="text" >
<string>Preferences</string>
</property>
</action>
<action name="actionAbout" >
<property name="text" >
<string>About</string>
</property>
</action>
<action name="actionStart" >
<property name="text" >
<string>Start</string>
</property>
</action>
<action name="actionPause" >
<property name="text" >
<string>Pause</string>
</property>
</action>
<action name="actionDelete" >
<property name="text" >
<string>Delete</string>
</property>
</action>
<action name="actionPause_All" >
<property name="text" >
<string>Pause All</string>
</property>
</action>
<action name="actionStart_All" >
<property name="text" >
<string>Start All</string>
</property>
</action>
<action name="actionDocumentation" >
<property name="text" >
<string>Documentation</string>
</property>
</action>
<action name="actionConnexion_Status" >
<property name="text" >
<string>Connection Status</string>
</property>
</action>
<action name="actionDelete_All" >
<property name="text" >
<string>Delete All</string>
</property>
</action>
<action name="actionTorrent_Properties" >
<property name="text" >
<string>Torrent Properties</string>
</property>
</action>
<action name="actionDownload_from_URL" >
<property name="text" >
<string>Download from URL</string>
</property>
</action>
<action name="actionCreate_torrent" >
<property name="text" >
<string>Create torrent</string>
</property>
</action>
<action name="actionPreview_file" >
<property name="text" >
<string>Preview file</string>
</property>
</action>
<action name="actionClearLog" >
<property name="text" >
<string>Clear log</string>
</property>
</action>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>search_pattern</sender>
<signal>returnPressed()</signal>
<receiver>search_button</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel" >
<x>405</x>
<y>125</y>
</hint>
<hint type="destinationlabel" >
<x>543</x>
<y>123</y>
</hint>
</hints>
</connection>
</connections>
</ui>

65
src/OSD.cpp Normal file
View file

@ -0,0 +1,65 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#include <QPixmap>
#include "OSD.h"
OSD::OSD(QWidget *parent) : QDialog(parent){
// Hide OSD Timer
hideOSDTimer = new QTimer(this);
hideOSDTimer->setSingleShot(true);
connect(hideOSDTimer, SIGNAL(timeout()), this, SLOT(hide()));
// Window settings
setWindowFlags(Qt::SplashScreen);
setPalette(QPalette(QColor("darkBlue")));
hboxLayout = new QHBoxLayout(this);
icon = new QLabel(this);
icon->setPixmap(QPixmap(":/Icons/qbittorrent16.png"));
icon->adjustSize();
msg = new QLabel(this);
msg->setPalette(QPalette(QColor(88, 75, 255, 200)));
icon->setPalette(QPalette(QColor(88, 75, 255, 200)));
msg->setAutoFillBackground(true);
icon->setAutoFillBackground(true);
hboxLayout->addWidget(icon);
hboxLayout->addWidget(msg);
hboxLayout->setSpacing(0);
hboxLayout->setMargin(1);
}
OSD::~OSD(){
delete hideOSDTimer;
delete icon;
delete msg;
delete hboxLayout;
}
void OSD::display(const QString& message){
if(hideOSDTimer->isActive()){
hideOSDTimer->stop();
hide();
}
msg->setText("<font color='white'><b>"+message+"</b></font>");
msg->adjustSize();
adjustSize();
show();
hideOSDTimer->start(3000);
}

47
src/OSD.h Normal file
View file

@ -0,0 +1,47 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef OSD_H
#define OSD_H
#include <QDialog>
#include <QLabel>
#include <QHBoxLayout>
#include <QTimer>
class OSD : public QDialog {
Q_OBJECT
private:
QTimer *hideOSDTimer;
QHBoxLayout *hboxLayout;
QLabel *icon;
QLabel *msg;
public:
OSD(QWidget *parent=0);
~OSD();
public slots:
void display(const QString& message);
};
#endif

115
src/PreviewListDelegate.h Normal file
View file

@ -0,0 +1,115 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef PREVIEWLISTDELEGATE_H
#define PREVIEWLISTDELEGATE_H
#include <QItemDelegate>
#include <QStyleOptionProgressBarV2>
#include <QModelIndex>
#include <QPainter>
#include <QProgressBar>
#include <QApplication>
#include "misc.h"
// Defines for properties list columns
#define NAME 0
#define SIZE 1
#define PROGRESS 2
class PreviewListDelegate: public QAbstractItemDelegate {
Q_OBJECT
public:
PreviewListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
~PreviewListDelegate(){}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
QItemDelegate delegate;
QStyleOptionViewItem opt = option;
QStyleOptionProgressBarV2 newopt;
char tmp[MAX_CHAR_TMP];
float progress;
// set text color
QVariant value = index.data(Qt::TextColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
}
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (option.state & QStyle::State_Selected){
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
}else{
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
// draw the background color
if(index.column() != PROGRESS){
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
cg = QPalette::Inactive;
}
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
}else{
value = index.data(Qt::BackgroundColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
}
}
}
switch(index.column()){
case SIZE:
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
break;
case NAME:
painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
break;
case PROGRESS:
progress = index.data().toDouble()*100.;
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
newopt.rect = opt.rect;
newopt.text = QString(tmp)+"%";
newopt.progress = (int)progress;
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = false;
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
painter);
//We prefer to display text manually to control color/font/boldness
if (option.state & QStyle::State_Selected){
opt.palette.setColor(QPalette::Text, QColor("grey"));
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
default:
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
}
}
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
QItemDelegate delegate;
return delegate.sizeHint(option, index);
}
};
#endif

126
src/PropListDelegate.h Normal file
View file

@ -0,0 +1,126 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef PROPLISTDELEGATE_H
#define PROPLISTDELEGATE_H
#include <QAbstractItemDelegate>
#include <QStyleOptionProgressBarV2>
#include <QModelIndex>
#include <QPainter>
#include <QProgressBar>
#include <QApplication>
#include "misc.h"
// Defines for properties list columns
#define NAME 0
#define SIZE 1
#define PROGRESS 2
#define SELECTED 3
class PropListDelegate: public QAbstractItemDelegate {
Q_OBJECT
public:
PropListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
~PropListDelegate(){}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
QStyleOptionViewItem opt = option;
char tmp[MAX_CHAR_TMP];
// set text color
QVariant value = index.data(Qt::TextColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
}
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (option.state & QStyle::State_Selected){
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
}else{
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
// draw the background color
if(index.column() != PROGRESS){
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
cg = QPalette::Inactive;
}
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
}else{
value = index.data(Qt::BackgroundColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
}
}
}
switch(index.column()){
case SIZE:
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
break;
case NAME:
painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
break;
case PROGRESS:{
QStyleOptionProgressBarV2 newopt;
float progress = index.data().toDouble()*100.;
snprintf(tmp, MAX_CHAR_TMP, "%.1f", progress);
newopt.rect = opt.rect;
newopt.text = QString(tmp)+"%";
newopt.progress = (int)progress;
newopt.maximum = 100;
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = false;
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt,
painter);
//We prefer to display text manually to control color/font/boldness
if (option.state & QStyle::State_Selected){
opt.palette.setColor(QPalette::Text, QColor("grey"));
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
}
case SELECTED:
if(index.data().toBool()){
painter->drawText(option.rect, Qt::AlignCenter, tr("True"));
}else{
painter->drawText(option.rect, Qt::AlignCenter, tr("False"));
}
break;
default:
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
}
}
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
QVariant value = index.data(Qt::FontRole);
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
QFontMetrics fontMetrics(fnt);
const QString text = index.data(Qt::DisplayRole).toString();
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
return textRect.size();
}
};
#endif

95
src/SearchListDelegate.h Normal file
View file

@ -0,0 +1,95 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef SEARCHLISTDELEGATE_H
#define SEARCHLISTDELEGATE_H
#include <QAbstractItemDelegate>
#include <QStyleOptionProgressBarV2>
#include <QModelIndex>
#include <QPainter>
#include <QProgressBar>
#include "misc.h"
// Defines for search results list columns
#define NAME 0
#define SIZE 1
#define SEEDERS 2
#define LEECHERS 3
#define ENGINE 4
class SearchListDelegate: public QAbstractItemDelegate {
Q_OBJECT
public:
SearchListDelegate(QObject *parent=0) : QAbstractItemDelegate(parent){}
~SearchListDelegate(){}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{
QStyleOptionViewItem opt = option;
// set text color
QVariant value = index.data(Qt::TextColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
}
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (option.state & QStyle::State_Selected){
painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
}else{
painter->setPen(opt.palette.color(cg, QPalette::Text));
}
// draw the background color
if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
cg = QPalette::Inactive;
}
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
}else{
value = index.data(Qt::BackgroundColorRole);
if (value.isValid() && qvariant_cast<QColor>(value).isValid()){
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
}
}
switch(index.column()){
case SIZE:
painter->drawText(option.rect, Qt::AlignCenter, misc::friendlyUnit(index.data().toLongLong()));
break;
case NAME:
painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
break;
default:
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
}
}
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{
QVariant value = index.data(Qt::FontRole);
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
QFontMetrics fontMetrics(fnt);
const QString text = index.data(Qt::DisplayRole).toString();
QRect textRect = QRect(0, 0, 0, fontMetrics.lineSpacing() * (text.count(QLatin1Char('\n')) + 1));
return textRect.size();
}
};
#endif

427
src/about.ui Normal file
View file

@ -0,0 +1,427 @@
<ui version="4.0" >
<author>Christophe Dumez</author>
<comment></comment>
<exportmacro></exportmacro>
<class>AboutDlg</class>
<widget class="QDialog" name="AboutDlg" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>320</height>
</rect>
</property>
<property name="windowTitle" >
<string>About qBittorrent</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="logo" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lb_name" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>&lt;h3>&lt;b>qBittorrent&lt;/b>&lt;/h3></string>
</property>
<property name="textFormat" >
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tw_tabs" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab2" >
<attribute name="title" >
<string>About</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QWidget" name="widget1" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lb_about" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>A bittorrent client using Qt4 and libtorrent, programmed in C++.&lt;br>
&lt;br>
Copyright © 2006 by Christophe Dumez&lt;br>
&lt;br> &lt;u>Home Page:&lt;/u> &lt;i>http://www.qbittorrent.org&lt;/i>&lt;br></string>
</property>
<property name="textFormat" >
<enum>Qt::RichText</enum>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab3" >
<attribute name="title" >
<string>Author</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QFrame" name="te_authors" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QSplitter" name="splitter" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="widget" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_3" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Country:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_birthday" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Birthday:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_occupation" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Occupation:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>E-mail:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>true</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Home page:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Christophe Dumez</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>France</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11" >
<property name="text" >
<string>03/05/1985</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10" >
<property name="text" >
<string>Student in computer science</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>chris@qbittorrent.org</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>http://www.dchris.eu</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab4" >
<attribute name="title" >
<string>Thanks To</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTextBrowser" name="te_thanks" />
</item>
</layout>
</widget>
<widget class="QWidget" name="tab5" >
<attribute name="title" >
<string>Translation</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTextBrowser" name="te_translation" />
</item>
</layout>
</widget>
<widget class="QWidget" name="tab1" >
<attribute name="title" >
<string>License</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTextBrowser" name="te_license" />
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

405
src/about_imp.h Normal file
View file

@ -0,0 +1,405 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef ABOUT_H
#define ABOUT_H
#include "ui_about.h"
#define VERSION "v0.7.0rc2"
class about : public QDialog, private Ui::AboutDlg{
Q_OBJECT
public:
about(QWidget *parent = 0): QDialog(parent){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Set icons
logo->setPixmap(QPixmap(QString::fromUtf8(":/Icons/yinyang32.png")));
//Title
lb_name->setText("<b><h1>"+tr("qBittorrent ")+VERSION"</h1></b>");
// Thanks
te_thanks->append("<ul><li>I would like to thank sourceforge.net for hosting qBittorrent project.</li>");
te_thanks->append("<li>I also want to thank Jeffery Fernandez (jeffery@qbittorrent.org), project consultant, webdevelopper and RPM packager, for his help.</li>");
te_thanks->append("<li>I am gratefull to Peter Koeleman (peter@qbittorrent.org) and Johnny Mast (rave@qbittorrent.org) who helped me port qBittorrent to Windows.</li>");
te_thanks->append("<li>Thanks a lot to our graphist Mateusz Toboła (tobejodok@qbittorrent.org) for his great work.</li></ul>");
// Translation
te_translation->append(tr("I would like to thank the following people who volunteered to translate qBittorrent:")+"<br>");
te_translation->append(QString::fromUtf8(
"<i>- <u>Bulgarian:</u> Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)<br>\
- <u>Catalan:</u> Gekko Dam Beer (gekko04@users.sourceforge.net)<br>\
- <u>Chinese (Simplified):</u> Chen Wuyang (wuyang@gmail.com)<br>\
- <u>Chinese (Traditional):</u> Jeff Chen (jeff.cn.chen@gmail.com)<br>\
- <u>Dutch:</u> Luke Niesink (luke@lukeniesink.net)<br>\
- <u>German:</u> Niels Hoffmann (zentralmaschine@users.sourceforge.net)<br>\
- <u>Greek:</u> Tsvetan Bankov (emerge_life@users.sourceforge.net)<br>\
- <u>Italian:</u> Maffo (maffo999@users.sourceforge.net)<br>\
- <u>Korean:</u> Jin Woo Sin (jin828sin@users.sourceforge.net)<br>\
- <u>Polish:</u> Adam Babol (a-b@users.sourceforge.net)<br>\
- <u>Portuguese:</u> Bruno Nunes (brunopatriarca@users.sourceforge.net)<br>\
- <u>Romanian:</u> Obada Denis (obadadenis@users.sourceforge.net)<br>\
- <u>Russian:</u> Nick Khazov (m2k3d0n at users.sourceforge.net)</i><br>\
- <u>Slovak:</u> helix84</i><br>\
- <u>Spanish:</u> Vicente Raul Plata Fonseca (silverxnt@users.sourceforge.net)</i><br>\
- <u>Swedish:</u> Daniel Nylander (po@danielnylander.se)</i><br>\
- <u>Turkish:</u> Erdem Bingöl (erdem84@gmail.com)</i><br>\
- <u>Ukrainian:</u> Andrey Shpachenko (masterfix@users.sourceforge.net)</i><br><br>"));
te_translation->append(tr("Please contact me if you would like to translate qBittorrent to your own language."));
// License
te_license->append("<center><b>GNU GENERAL PUBLIC LICENSE</b></center><br>\
<center>Version 2, June 1991</center><br>\
Copyright (C) 1989, 1991 Free Software Foundation, Inc.<br>\
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br>\
Everyone is permitted to copy and distribute verbatim copies<br>\
of this license document, but changing it is not allowed.<br>\
<br>\
<center><b>Preamble</b></center><br>\
The licenses for most software are designed to take away your<br>\
freedom to share and change it. By contrast, the GNU General Public<br>\
License is intended to guarantee your freedom to share and change free<br>\
software--to make sure the software is free for all its users. This<br>\
General Public License applies to most of the Free Software<br>\
Foundation's software and to any other program whose authors commit to<br>\
using it. (Some other Free Software Foundation software is covered by<br>\
the GNU Library General Public License instead.) You can apply it to<br>\
your programs, too.<br>\
<br>\
When we speak of free software, we are referring to freedom, not<br>\
price. Our General Public Licenses are designed to make sure that you<br>\
have the freedom to distribute copies of free software (and charge for<br>\
this service if you wish), that you receive source code or can get it<br>\
if you want it, that you can change the software or use pieces of it<br>\
in new free programs; and that you know you can do these things.<br>\
<br>\
To protect your rights, we need to make restrictions that forbid<br>\
anyone to deny you these rights or to ask you to surrender the rights.<br>\
These restrictions translate to certain responsibilities for you if you<br>\
distribute copies of the software, or if you modify it.<br>\
<br>\
For example, if you distribute copies of such a program, whether<br>\
gratis or for a fee, you must give the recipients all the rights that<br>\
you have. You must make sure that they, too, receive or can get the<br>\
source code. And you must show them these terms so they know their<br>\
rights.<br>\
<br>\
We protect your rights with two steps: (1) copyright the software, and<br>\
(2) offer you this license which gives you legal permission to copy,<br>\
distribute and/or modify the software.<br>\
<br>\
Also, for each author's protection and ours, we want to make certain<br>\
that everyone understands that there is no warranty for this free<br>\
software. If the software is modified by someone else and passed on, we<br>\
want its recipients to know that what they have is not the original, so<br>\
that any problems introduced by others will not reflect on the original<br>\
authors' reputations.<br>\
<br>\
Finally, any free program is threatened constantly by software<br>\
patents. We wish to avoid the danger that redistributors of a free<br>\
program will individually obtain patent licenses, in effect making the<br>\
program proprietary. To prevent this, we have made it clear that any<br>\
patent must be licensed for everyone's free use or not licensed at all.<br>\
<br>\
The precise terms and conditions for copying, distribution and<br>\
modification follow.<br>\
<br>\
<center><b>GNU GENERAL PUBLIC LICENSE</b></center><br>\
<center><b>TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</b></center><br>\
0. This License applies to any program or other work which contains<br>\
a notice placed by the copyright holder saying it may be distributed<br>\
under the terms of this General Public License. The 'Program', below,<br>\
refers to any such program or work, and a 'work based on the Program'<br>\
means either the Program or any derivative work under copyright law:<br>\
that is to say, a work containing the Program or a portion of it,<br>\
either verbatim or with modifications and/or translated into another<br>\
language. (Hereinafter, translation is included without limitation in<br>\
the term 'modification'.) Each licensee is addressed as 'you'.<br>\
<br>\
Activities other than copying, distribution and modification are not<br>\
covered by this License; they are outside its scope. The act of<br>\
running the Program is not restricted, and the output from the Program<br>\
is covered only if its contents constitute a work based on the<br>\
Program (independent of having been made by running the Program).<br>\
Whether that is true depends on what the Program does.<br>\
<br>\
1. You may copy and distribute verbatim copies of the Program's<br>\
source code as you receive it, in any medium, provided that you<br>\
conspicuously and appropriately publish on each copy an appropriate<br>\
copyright notice and disclaimer of warranty; keep intact all the<br>\
notices that refer to this License and to the absence of any warranty;<br>\
and give any other recipients of the Program a copy of this License<br>\
along with the Program.<br>\
<br>\
You may charge a fee for the physical act of transferring a copy, and<br>\
you may at your option offer warranty protection in exchange for a fee.<br>\
<br>\
2. You may modify your copy or copies of the Program or any portion<br>\
of it, thus forming a work based on the Program, and copy and<br>\
distribute such modifications or work under the terms of Section 1<br>\
above, provided that you also meet all of these conditions:<br>\
<br>\
a) You must cause the modified files to carry prominent notices<br>\
stating that you changed the files and the date of any change.<br>\
<br>\
b) You must cause any work that you distribute or publish, that in<br>\
whole or in part contains or is derived from the Program or any<br>\
part thereof, to be licensed as a whole at no charge to all third<br>\
parties under the terms of this License.<br>\
<br>\
c) If the modified program normally reads commands interactively<br>\
when run, you must cause it, when started running for such<br>\
interactive use in the most ordinary way, to print or display an<br>\
announcement including an appropriate copyright notice and a<br>\
notice that there is no warranty (or else, saying that you provide<br>\
a warranty) and that users may redistribute the program under<br>\
these conditions, and telling the user how to view a copy of this<br>\
License. (Exception: if the Program itself is interactive but<br>\
does not normally print such an announcement, your work based on<br>\
the Program is not required to print an announcement.)<br>\
<br>\
These requirements apply to the modified work as a whole. If<br>\
identifiable sections of that work are not derived from the Program,<br>\
and can be reasonably considered independent and separate works in<br>\
themselves, then this License, and its terms, do not apply to those<br>\
sections when you distribute them as separate works. But when you<br>\
distribute the same sections as part of a whole which is a work based<br>\
on the Program, the distribution of the whole must be on the terms of<br>\
this License, whose permissions for other licensees extend to the<br>\
entire whole, and thus to each and every part regardless of who wrote it.<br>\
<br>\
Thus, it is not the intent of this section to claim rights or contest<br>\
your rights to work written entirely by you; rather, the intent is to<br>\
exercise the right to control the distribution of derivative or<br>\
collective works based on the Program.<br>\
<br>\
In addition, mere aggregation of another work not based on the Program<br>\
with the Program (or with a work based on the Program) on a volume of<br>\
a storage or distribution medium does not bring the other work under<br>\
the scope of this License.<br>\
<br>\
3. You may copy and distribute the Program (or a work based on it,<br>\
under Section 2) in object code or executable form under the terms of<br>\
Sections 1 and 2 above provided that you also do one of the following:<br>\
<br>\
a) Accompany it with the complete corresponding machine-readable<br>\
source code, which must be distributed under the terms of Sections<br>\
1 and 2 above on a medium customarily used for software interchange; or,<br>\
<br>\
b) Accompany it with a written offer, valid for at least three<br>\
years, to give any third party, for a charge no more than your<br>\
cost of physically performing source distribution, a complete<br>\
machine-readable copy of the corresponding source code, to be<br>\
distributed under the terms of Sections 1 and 2 above on a medium<br>\
customarily used for software interchange; or,<br>\
<br>\
c) Accompany it with the information you received as to the offer<br>\
to distribute corresponding source code. (This alternative is<br>\
allowed only for noncommercial distribution and only if you<br>\
received the program in object code or executable form with such<br>\
an offer, in accord with Subsection b above.)<br>\
<br>\
The source code for a work means the preferred form of the work for<br>\
making modifications to it. For an executable work, complete source<br>\
code means all the source code for all modules it contains, plus any<br>\
associated interface definition files, plus the scripts used to<br>\
control compilation and installation of the executable. However, as a<br>\
special exception, the source code distributed need not include<br>\
anything that is normally distributed (in either source or binary<br>\
form) with the major components (compiler, kernel, and so on) of the<br>\
operating system on which the executable runs, unless that component<br>\
itself accompanies the executable.<br>\
<br>\
If distribution of executable or object code is made by offering<br>\
access to copy from a designated place, then offering equivalent<br>\
access to copy the source code from the same place counts as<br>\
distribution of the source code, even though third parties are not<br>\
compelled to copy the source along with the object code.<br>\
<br>\
4. You may not copy, modify, sublicense, or distribute the Program<br>\
except as expressly provided under this License. Any attempt<br>\
otherwise to copy, modify, sublicense or distribute the Program is<br>\
void, and will automatically terminate your rights under this License.<br>\
However, parties who have received copies, or rights, from you under<br>\
this License will not have their licenses terminated so long as such<br>\
parties remain in full compliance.<br>\
<br>\
5. You are not required to accept this License, since you have not<br>\
signed it. However, nothing else grants you permission to modify or<br>\
distribute the Program or its derivative works. These actions are<br>\
prohibited by law if you do not accept this License. Therefore, by<br>\
modifying or distributing the Program (or any work based on the<br>\
Program), you indicate your acceptance of this License to do so, and<br>\
all its terms and conditions for copying, distributing or modifying<br>\
the Program or works based on it.<br>\
<br>\
6. Each time you redistribute the Program (or any work based on the<br>\
Program), the recipient automatically receives a license from the<br>\
original licensor to copy, distribute or modify the Program subject to<br>\
these terms and conditions. You may not impose any further<br>\
restrictions on the recipients' exercise of the rights granted herein.<br>\
You are not responsible for enforcing compliance by third parties to<br>\
this License.<br>\
<br>\
7. If, as a consequence of a court judgment or allegation of patent<br>\
infringement or for any other reason (not limited to patent issues),<br>\
conditions are imposed on you (whether by court order, agreement or<br>\
otherwise) that contradict the conditions of this License, they do not<br>\
excuse you from the conditions of this License. If you cannot<br>\
distribute so as to satisfy simultaneously your obligations under this<br>\
License and any other pertinent obligations, then as a consequence you<br>\
may not distribute the Program at all. For example, if a patent<br>\
license would not permit royalty-free redistribution of the Program by<br>\
all those who receive copies directly or indirectly through you, then<br>\
the only way you could satisfy both it and this License would be to<br>\
refrain entirely from distribution of the Program.<br>\
<br>\
If any portion of this section is held invalid or unenforceable under<br>\
any particular circumstance, the balance of the section is intended to<br>\
apply and the section as a whole is intended to apply in other<br>\
circumstances.<br>\
<br>\
It is not the purpose of this section to induce you to infringe any<br>\
patents or other property right claims or to contest validity of any<br>\
such claims; this section has the sole purpose of protecting the<br>\
integrity of the free software distribution system, which is<br>\
implemented by public license practices. Many people have made<br>\
generous contributions to the wide range of software distributed<br>\
through that system in reliance on consistent application of that<br>\
system; it is up to the author/donor to decide if he or she is willing<br>\
to distribute software through any other system and a licensee cannot<br>\
impose that choice.<br>\
<br>\
This section is intended to make thoroughly clear what is believed to<br>\
be a consequence of the rest of this License.<br>\
<br>\
8. If the distribution and/or use of the Program is restricted in<br>\
certain countries either by patents or by copyrighted interfaces, the<br>\
original copyright holder who places the Program under this License<br>\
may add an explicit geographical distribution limitation excluding<br>\
those countries, so that distribution is permitted only in or among<br>\
countries not thus excluded. In such case, this License incorporates<br>\
the limitation as if written in the body of this License.<br>\
<br>\
9. The Free Software Foundation may publish revised and/or new versions<br>\
of the General Public License from time to time. Such new versions will<br>\
be similar in spirit to the present version, but may differ in detail to<br>\
address new problems or concerns.<br>\
<br>\
Each version is given a distinguishing version number. If the Program<br>\
specifies a version number of this License which applies to it and 'any<br>\
later version', you have the option of following the terms and conditions<br>\
either of that version or of any later version published by the Free<br>\
Software Foundation. If the Program does not specify a version number of<br>\
this License, you may choose any version ever published by the Free Software<br>\
Foundation.<br>\
<br>\
10. If you wish to incorporate parts of the Program into other free<br>\
programs whose distribution conditions are different, write to the author<br>\
to ask for permission. For software which is copyrighted by the Free<br>\
Software Foundation, write to the Free Software Foundation; we sometimes<br>\
make exceptions for this. Our decision will be guided by the two goals<br>\
of preserving the free status of all derivatives of our free software and<br>\
of promoting the sharing and reuse of software generally.<br>\
<br>\
<center><b>NO WARRANTY</b></center><br>\
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY<br>\
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN<br>\
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES<br>\
PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED<br>\
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF<br>\
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS<br>\
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE<br>\
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,<br>\
REPAIR OR CORRECTION.<br>\
<br>\
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING<br>\
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR<br>\
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,<br>\
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING<br>\
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED<br>\
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY<br>\
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER<br>\
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE<br>\
POSSIBILITY OF SUCH DAMAGES.<br>\
<br>\
<center><b>END OF TERMS AND CONDITIONS</b></center><br>\
<center>How to Apply These Terms to Your New Programs</center><br>\
If you develop a new program, and you want it to be of the greatest<br>\
possible use to the public, the best way to achieve this is to make it<br>\
free software which everyone can redistribute and change under these terms.<br>\
<br>\
To do so, attach the following notices to the program. It is safest<br>\
to attach them to the start of each source file to most effectively<br>\
convey the exclusion of warranty; and each file should have at least<br>\
the 'copyright' line and a pointer to where the full notice is found.<br>\
<br>\
<one line to give the program's name and a brief idea of what it does.><br>\
Copyright (C) <year> <name of author><br>\
<br>\
This program is free software; you can redistribute it and/or modify<br>\
it under the terms of the GNU General Public License as published by<br>\
the Free Software Foundation; either version 2 of the License, or<br>\
(at your option) any later version.<br>\
<br>\
This program is distributed in the hope that it will be useful,<br>\
but WITHOUT ANY WARRANTY; without even the implied warranty of<br>\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>\
GNU General Public License for more details.<br>\
<br>\
You should have received a copy of the GNU General Public License<br>\
along with this program; if not, write to the Free Software<br>\
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br>\
<br>\
<br>\
Also add information on how to contact you by electronic and paper mail.<br>\
<br>\
If the program is interactive, make it output a short notice like this<br>\
when it starts in an interactive mode:<br>\
<br>\
Gnomovision version 69, Copyright (C) year name of author<br>\
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.<br>\
This is free software, and you are welcome to redistribute it<br>\
under certain conditions; type `show c' for details.<br>\
<br>\
The hypothetical commands `show w' and `show c' should show the appropriate<br>\
parts of the General Public License. Of course, the commands you use may<br>\
be called something other than `show w' and `show c'; they could even be<br>\
mouse-clicks or menu items--whatever suits your program.<br>\
<br>\
You should also get your employer (if you work as a programmer) or your<br>\
school, if any, to sign a 'copyright disclaimer' for the program, if<br>\
necessary. Here is a sample; alter the names:<br>\
<br>\
Yoyodyne, Inc., hereby disclaims all copyright interest in the program<br>\
`Gnomovision' (which makes passes at compilers) written by James Hacker.<br>\
<br>\
'signature of Ty Coon', 1 April 1989<br>\
Ty Coon, President of Vice<br>\
<br>\
This General Public License does not permit incorporating your program into<br>\
proprietary programs. If your program is a subroutine library, you may<br>\
consider it more useful to permit linking proprietary applications with the<br>\
library. If this is what you want to do, use the GNU Library General<br>\
Public License instead of this License.<br>");
show();
}
};
#endif

275
src/createtorrent.ui Normal file
View file

@ -0,0 +1,275 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>createTorrentDialog</class>
<widget class="QDialog" name="createTorrentDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>307</height>
</rect>
</property>
<property name="windowTitle" >
<string>Torrent Creation Tool</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="createTorrent_title" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>27</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>27</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Create Torrent file</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lbl_destination" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text" >
<string>&lt;center>Destination torrent file:&lt;/center></string>
</property>
<property name="buddy" >
<cstring>txt_destination</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_input" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text" >
<string>&lt;center>Input file or directory:&lt;/center></string>
</property>
<property name="buddy" >
<cstring>txt_input</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_announce_url" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
<property name="text" >
<string>&lt;center>Announce url:&lt;br>(One per line)&lt;/center></string>
</property>
<property name="buddy" >
<cstring></cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_comment" >
<property name="text" >
<string>&lt;center>Comment:&lt;/center></string>
</property>
<property name="buddy" >
<cstring>txt_comment</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="txt_destination" />
</item>
<item>
<widget class="QToolButton" name="browse_destination" >
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="txt_input" />
</item>
<item>
<widget class="QCheckBox" name="checkDirectory" >
<property name="text" >
<string>Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="browse_input" >
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="txt_announce" />
</item>
<item>
<widget class="QTextEdit" name="txt_comment" >
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="createButton" >
<property name="text" >
<string>Create</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>createTorrentDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>355</x>
<y>275</y>
</hint>
<hint type="destinationlabel" >
<x>179</x>
<y>282</y>
</hint>
</hints>
</connection>
</connections>
</ui>

136
src/createtorrent_imp.cpp Normal file
View file

@ -0,0 +1,136 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#include <QFileDialog>
#include <QMessageBox>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/file.hpp"
#include "libtorrent/storage.hpp"
#include "libtorrent/hasher.hpp"
#include "createtorrent_imp.h"
using namespace libtorrent;
using namespace boost::filesystem;
createtorrent::createtorrent(QWidget *parent): QDialog(parent){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
show();
}
void createtorrent::on_browse_destination_clicked(){
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), QDir::homePath(), tr("Torrent Files")+" (*.torrent)");
if(!destination.isEmpty()){
txt_destination->setText(destination);
}
}
void createtorrent::on_browse_input_clicked(){
// Can't use QFileDialog static functions for this because
// user can select a file or a directory
QFileDialog *fd = new QFileDialog(this, tr("Select input directory or file"), QDir::homePath());
if(checkDirectory->isChecked()){
fd->setFileMode(QFileDialog::DirectoryOnly);
}else{
fd->setFileMode(QFileDialog::ExistingFile);
}
QStringList fileNames;
if (fd->exec()){
fileNames = fd->selectedFiles();
txt_input->setText(fileNames.first());
}
}
// Subfunction to add files to a torrent_info structure
// Written by Arvid Norberg (libtorrent Author)
void add_files(torrent_info& t, path const& p, path const& l){
path f(p / l);
if (is_directory(f)){
for (directory_iterator i(f), end; i != end; ++i)
add_files(t, p, l / i->leaf());
}else{
t.add_file(l, file_size(f));
}
}
// Main function that create a .torrent file
void createtorrent::on_createButton_clicked(){
QString destination = txt_destination->text();
if(destination.isEmpty()){
QMessageBox::critical(0, tr("No destination path set"), tr("Please type a destination path first"));
return;
}
QString input = txt_input->text();
if(input.isEmpty()){
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
return;
}
if(!QFile::exists(input)){
QMessageBox::critical(0, tr("Input path does not exist"), tr("Please type a correct input path first"));
return;
}
char const* creator_str = "qBittorrent";
int piece_size = 256 * 1024;
try {
torrent_info t;
path full_path = complete(path(input.toStdString().c_str()));
ofstream out(complete(path(destination.toStdString().c_str())), std::ios_base::binary);
add_files(t, full_path.branch_path(), full_path.leaf());
t.set_piece_size(piece_size);
storage st(t, full_path.branch_path());
QStringList trackers = txt_announce->toPlainText().split('\n');
for(int i=0; i<trackers.size(); ++i){
t.add_tracker(trackers.at(i).toStdString().c_str());
}
// calculate the hash for all pieces
int num = t.num_pieces();
std::vector<char> buf(piece_size);
for (int i = 0; i < num; ++i)
{
st.read(&buf[0], i, 0, t.piece_size(i));
hasher h(&buf[0], t.piece_size(i));
t.set_hash(i, h.final());
}
// Set qBittorrent as creator and add user comment to
// torrent_info structure
t.set_creator(creator_str);
t.set_comment(txt_comment->toPlainText().toStdString().c_str());
// create the torrent and print it to out
entry e = t.create_torrent();
libtorrent::bencode(std::ostream_iterator<char>(out), e);
}
catch (std::exception& e){
std::cerr << e.what() << "\n";
}
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+destination);
hide();
}

40
src/createtorrent_imp.h Normal file
View file

@ -0,0 +1,40 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef CREATE_TORRENT_IMP_H
#define CREATE_TORRENT_IMP_H
#include <QDialog>
#include "ui_createtorrent.h"
class createtorrent : public QDialog, private Ui::createTorrentDialog{
Q_OBJECT
public:
createtorrent(QWidget *parent = 0);
protected slots:
void on_browse_destination_clicked();
void on_browse_input_clicked();
void on_createButton_clicked();
};
#endif

BIN
src/doc/qbittorrent.1.gz Normal file

Binary file not shown.

158
src/downloadFromURL.ui Normal file
View file

@ -0,0 +1,158 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>downloadFromURL</class>
<widget class="QDialog" name="downloadFromURL" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>220</height>
</rect>
</property>
<property name="windowTitle" >
<string>Download from urls</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="icon_lbl" >
<property name="minimumSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="downloadURL_lbl" >
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Download Torrents from URLs</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textUrls" >
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_infos" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>17</height>
</size>
</property>
<property name="font" >
<font>
<family>Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<italic>true</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="text" >
<string>Only one URL per line</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="downloadButton" >
<property name="text" >
<string>Download</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

76
src/downloadFromURLImp.h Normal file
View file

@ -0,0 +1,76 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef DOWNLOADFROMURL_H
#define DOWNLOADFROMURL_H
#include <QDialog>
#include <QMessageBox>
#include <QString>
#include <QRegExp>
#include <QStringList>
#include "ui_downloadFromURL.h"
class downloadFromURL : public QDialog, private Ui::downloadFromURL{
Q_OBJECT
public:
downloadFromURL(QWidget *parent): QDialog(parent){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
icon_lbl->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/url.png")));
connect(this, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), parent, SLOT(downloadFromURLList(const QStringList&)));
show();
}
~downloadFromURL(){}
signals:
void urlsReadyToBeDownloaded(const QStringList& torrent_urls);
public slots:
void on_downloadButton_clicked(){
QString urls = textUrls->toPlainText();
QStringList url_list = urls.split("\n");
QString url;
QStringList url_list_cleaned;
foreach(url, url_list){
url = url.trimmed();
if(!url.isEmpty()){
if(url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0){
url_list_cleaned << url;
}
}
}
if(!url_list_cleaned.size()){
QMessageBox::critical(0, tr("No URL entered"), tr("Please type at least one URL."));
return;
}
emit urlsReadyToBeDownloaded(url_list_cleaned);
close();
}
void on_cancelButton_clicked(){
close();
}
};
#endif

119
src/downloadThread.h Normal file
View file

@ -0,0 +1,119 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contact : chris@qbittorrent.org
*/
#ifndef DOWNLOADTHREAD_H
#define DOWNLOADTHREAD_H
#include <QThread>
#include <QFile>
#include <QTemporaryFile>
#include <QMutex>
#include <QMutexLocker>
#include <QWaitCondition>
#include <curl/curl.h>
#include <iostream>
#include "misc.h"
class downloadThread : public QThread {
Q_OBJECT
private:
QStringList url_list;
QMutex mutex;
QWaitCondition condition;
signals:
void downloadFinished(QString url, QString file_path, int return_code, QString errorBuffer);
public:
downloadThread(QObject* parent) : QThread(parent){}
void downloadUrl(const QString& url){
mutex.lock();
url_list << url;
mutex.unlock();
if(!isRunning()){
start();
}
}
void run(){
forever{
mutex.lock();
if(url_list.size() != 0){
QString url = url_list.takeFirst();
mutex.unlock();
CURL *curl;
std::string filePath;
int return_code;
// XXX: Trick to get a unique filename
QTemporaryFile *tmpfile = new QTemporaryFile;
if (tmpfile->open()) {
filePath = tmpfile->fileName().toStdString();
}
delete tmpfile;
FILE *file = fopen(filePath.c_str(), "w");
if(!file){
std::cout << "Error: could not open temporary file...\n";
return;
}
// Initilization required by libcurl
curl = curl_easy_init();
if(!curl){
std::cout << "Error: Failed to init curl...\n";
fclose(file);
return;
}
// Set url to download
curl_easy_setopt(curl, CURLOPT_URL, (void*) url.toStdString().c_str());
// Define our callback to get called when there's data to be written
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
// Set destination file
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
// Some SSL mambo jambo
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
// We want error message:
char errorBuffer[CURL_ERROR_SIZE];
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
if(return_code){
std::cout << "Error: failed to set error buffer in curl\n";
fclose(file);
QFile::remove(filePath.c_str());
return;
}
// Perform Download
return_code = curl_easy_perform(curl);
// Cleanup
curl_easy_cleanup(curl);
// Close tmp file
fclose(file);
emit downloadFinished(url, QString(filePath.c_str()), return_code, QString(errorBuffer));
}else{
mutex.unlock();
break;
}
}
}
};
#endif

67
src/icons.qrc Normal file
View file

@ -0,0 +1,67 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>Icons/home.png</file>
<file>Icons/log.png</file>
<file>Icons/style.png</file>
<file>Icons/wizard.png</file>
<file>Icons/button_cancel.png</file>
<file>Icons/smile.png</file>
<file>Icons/qbittorrent16.png</file>
<file>Icons/stare.png</file>
<file>Icons/filter.png</file>
<file>Icons/encrypted.png</file>
<file>Icons/locale.png</file>
<file>Icons/proxy.png</file>
<file>Icons/systemtray.png</file>
<file>Icons/button_ok.png</file>
<file>Icons/unhappy.png</file>
<file>Icons/qbittorrent22.png</file>
<file>Icons/splash.jpg</file>
<file>Icons/qbittorrent32.png</file>
<file>Icons/skin/url.png</file>
<file>Icons/skin/pause_all.png</file>
<file>Icons/skin/play_all.png</file>
<file>Icons/skin/remove.png</file>
<file>Icons/skin/settings.png</file>
<file>Icons/skin/open.png</file>
<file>Icons/skin/disconnected.png</file>
<file>Icons/skin/delete.png</file>
<file>Icons/skin/connected.png</file>
<file>Icons/skin/play.png</file>
<file>Icons/skin/properties.png</file>
<file>Icons/skin/downloading.png</file>
<file>Icons/skin/search.png</file>
<file>Icons/skin/exit.png</file>
<file>Icons/skin/pause.png</file>
<file>Icons/skin/firewalled.png</file>
<file>Icons/skin/seeding.png</file>
<file>Icons/skin/paused.png</file>
<file>Icons/skin/connecting.png</file>
<file>Icons/skin/add.png</file>
<file>Icons/skin/stalled.png</file>
<file>Icons/skin/new.png</file>
<file>Icons/skin/delete_all.png</file>
<file>Icons/skin/info.png</file>
<file>Icons/skin/preview.png</file>
<file>Icons/flags/netherlands.png</file>
<file>Icons/flags/china.png</file>
<file>Icons/flags/bulgaria.png</file>
<file>Icons/flags/china_hong_kong.png</file>
<file>Icons/flags/france.png</file>
<file>Icons/flags/germany.png</file>
<file>Icons/flags/greece.png</file>
<file>Icons/flags/south_korea.png</file>
<file>Icons/flags/poland.png</file>
<file>Icons/flags/portugal.png</file>
<file>Icons/flags/slovakia.png</file>
<file>Icons/flags/sweden.png</file>
<file>Icons/flags/turkey.png</file>
<file>Icons/flags/italy.png</file>
<file>Icons/flags/united_kingdom.png</file>
<file>Icons/flags/romania.png</file>
<file>Icons/flags/russia.png</file>
<file>Icons/flags/spain.png</file>
<file>Icons/flags/ukraine.png</file>
<file>Icons/flags/spain_catalunya.png</file>
</qresource>
</RCC>

24
src/lang.qrc Normal file
View file

@ -0,0 +1,24 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>lang/qbittorrent_fr.qm</file>
<file>lang/qbittorrent_zh.qm</file>
<file>lang/qbittorrent_en.qm</file>
<file>lang/qbittorrent_es.qm</file>
<file>lang/qbittorrent_pl.qm</file>
<file>lang/qbittorrent_ko.qm</file>
<file>lang/qbittorrent_de.qm</file>
<file>lang/qbittorrent_ru.qm</file>
<file>lang/qbittorrent_ca.qm</file>
<file>lang/qbittorrent_nl.qm</file>
<file>lang/qbittorrent_uk.qm</file>
<file>lang/qbittorrent_tr.qm</file>
<file>lang/qbittorrent_sv.qm</file>
<file>lang/qbittorrent_el.qm</file>
<file>lang/qbittorrent_bg.qm</file>
<file>lang/qbittorrent_sk.qm</file>
<file>lang/qbittorrent_ro.qm</file>
<file>lang/qbittorrent_it.qm</file>
<file>lang/qbittorrent_zh_HK.qm</file>
<file>lang/qbittorrent_pt.qm</file>
</qresource>
</RCC>

BIN
src/lang/qbittorrent_bg.qm Normal file

Binary file not shown.

1624
src/lang/qbittorrent_bg.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_ca.qm Normal file

Binary file not shown.

1672
src/lang/qbittorrent_ca.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_de.qm Normal file

Binary file not shown.

1621
src/lang/qbittorrent_de.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_el.qm Normal file

Binary file not shown.

1664
src/lang/qbittorrent_el.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_en.qm Normal file

Binary file not shown.

1273
src/lang/qbittorrent_en.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_es.qm Normal file

Binary file not shown.

1645
src/lang/qbittorrent_es.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_fr.qm Normal file

Binary file not shown.

1753
src/lang/qbittorrent_fr.ts Normal file

File diff suppressed because it is too large Load diff

BIN
src/lang/qbittorrent_it.qm Normal file

Binary file not shown.

1485
src/lang/qbittorrent_it.ts Normal file

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more