Browse Source

Revamp Torrent creator

adaptive-webui-19844
Chocobo1 9 years ago
parent
commit
6bab30a178
  1. 376
      src/gui/torrentcreatordlg.cpp
  2. 72
      src/gui/torrentcreatordlg.h
  3. 289
      src/gui/torrentcreatordlg.ui

376
src/gui/torrentcreatordlg.cpp

@ -28,254 +28,350 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include "torrentcreatordlg.h"
#include <QCloseEvent>
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QMimeData>
#include <QUrl>
#include "torrentcreatordlg.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/preferences.h"
#include "guiiconprovider.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"
#include "base/bittorrent/torrentcreatorthread.h" #include "base/bittorrent/torrentcreatorthread.h"
#include "base/settingsstorage.h"
#include "base/utils/fs.h"
#include "guiiconprovider.h"
const uint NB_PIECES_MIN = 1200; #include "ui_torrentcreatordlg.h"
const uint NB_PIECES_MAX = 2200;
TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent) namespace
: QDialog(parent)
, m_creatorThread(0)
{ {
setupUi(this); #define SETTINGS_KEY(name) "TorrentCreator/" name
// Icons const QString KEY_DIALOG_SIZE = SETTINGS_KEY("Dimension");
addFile_button->setIcon(GuiIconProvider::instance()->getIcon("document-new"));
addFolder_button->setIcon(GuiIconProvider::instance()->getIcon("folder-new")); const QString KEY_PIECE_SIZE = SETTINGS_KEY("PieceSize");
createButton->setIcon(GuiIconProvider::instance()->getIcon("document-save")); const QString KEY_PRIVATE_TORRENT = SETTINGS_KEY("PrivateTorrent");
cancelButton->setIcon(GuiIconProvider::instance()->getIcon("dialog-cancel")); const QString KEY_START_SEEDING = SETTINGS_KEY("StartSeeding");
const QString KEY_SETTING_IGNORE_RATIO = SETTINGS_KEY("IgnoreRatio");
const QString KEY_LAST_ADD_PATH = SETTINGS_KEY("LastAddPath");
const QString KEY_TRACKER_LIST = SETTINGS_KEY("TrackerList");
const QString KEY_WEB_SEED_LIST = SETTINGS_KEY("WebSeedList");
const QString KEY_COMMENTS = SETTINGS_KEY("Comments");
const QString KEY_LAST_SAVE_PATH = SETTINGS_KEY("LastSavePath");
SettingsStorage *settings() { return SettingsStorage::instance(); }
}
TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent, const QString &defaultPath)
: QDialog(parent)
, m_ui(new Ui::TorrentCreatorDlg)
, m_creatorThread(nullptr)
, m_defaultPath(Utils::Fs::toNativePath(defaultPath))
{
m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
setModal(true); setModal(true);
showProgressBar(false); showProgressBar(false);
loadTrackerList(); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Torrent"));
// Piece sizes
m_pieceSizes << 16 << 32 << 64 << 128 << 256 << 512 << 1024 << 2048 << 4096 << 8192 << 16384; connect(m_ui->addFile_button, SIGNAL(clicked(bool)), SLOT(onAddFileButtonClicked()));
connect(m_ui->addFolder_button, SIGNAL(clicked(bool)), SLOT(onAddFolderButtonClicked()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(onCreateButtonClicked()));
loadSettings(); loadSettings();
show(); show();
} }
TorrentCreatorDlg::~TorrentCreatorDlg() TorrentCreatorDlg::~TorrentCreatorDlg()
{ {
if (m_creatorThread) saveSettings();
// End torrent creation thread
if (m_creatorThread) {
if (m_creatorThread->isRunning()) {
m_creatorThread->abortCreation();
m_creatorThread->terminate();
// Wait for termination
m_creatorThread->wait();
}
delete m_creatorThread; delete m_creatorThread;
} }
void TorrentCreatorDlg::on_addFolder_button_clicked() delete m_ui;
}
void TorrentCreatorDlg::onAddFolderButtonClicked()
{ {
Preferences* const pref = Preferences::instance(); QString oldPath = m_ui->textInputPath->text();
QString lastPath = pref->getCreateTorLastAddPath(); QString path = QFileDialog::getExistingDirectory(this, tr("Select folder"), oldPath);
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), lastPath, QFileDialog::ShowDirsOnly); if (!path.isEmpty())
if (!dir.isEmpty()) { m_ui->textInputPath->setText(Utils::Fs::toNativePath(path));
pref->setCreateTorLastAddPath(dir);
textInputPath->setText(Utils::Fs::toNativePath(dir));
// Update piece size
if (checkAutoPieceSize->isChecked())
updateOptimalPieceSize();
} }
void TorrentCreatorDlg::onAddFileButtonClicked()
{
QString oldPath = m_ui->textInputPath->text();
QString path = QFileDialog::getOpenFileName(this, tr("Select file"), oldPath);
if (!path.isEmpty())
m_ui->textInputPath->setText(Utils::Fs::toNativePath(path));
} }
void TorrentCreatorDlg::on_addFile_button_clicked() int TorrentCreatorDlg::getPieceSize() const
{ {
Preferences* const pref = Preferences::instance(); const int pieceSizes[] = {0, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}; // base unit in KiB
QString lastPath = pref->getCreateTorLastAddPath(); return pieceSizes[m_ui->comboPieceSize->currentIndex()] * 1024;
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), lastPath); }
if (!file.isEmpty()) {
pref->setCreateTorLastAddPath(Utils::Fs::branchPath(file)); void TorrentCreatorDlg::dropEvent(QDropEvent *event)
textInputPath->setText(Utils::Fs::toNativePath(file)); {
// Update piece size event->acceptProposedAction();
if (checkAutoPieceSize->isChecked())
updateOptimalPieceSize(); if (event->mimeData()->hasUrls()) {
// only take the first one
QUrl firstItem = event->mimeData()->urls().first();
QString path = (firstItem.scheme().compare("file", Qt::CaseInsensitive) == 0)
? firstItem.toLocalFile() : firstItem.toString();
m_ui->textInputPath->setText(Utils::Fs::toNativePath(path));
} }
} }
int TorrentCreatorDlg::getPieceSize() const void TorrentCreatorDlg::dragEnterEvent(QDragEnterEvent *event)
{ {
return m_pieceSizes.at(comboPieceSize->currentIndex()) * 1024; if (event->mimeData()->hasFormat("text/plain") || event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
} }
// Main function that create a .torrent file // Main function that create a .torrent file
void TorrentCreatorDlg::on_createButton_clicked() void TorrentCreatorDlg::onCreateButtonClicked()
{ {
QString input = Utils::Fs::fromNativePath(textInputPath->text()).trimmed(); QString input = Utils::Fs::fromNativePath(m_ui->textInputPath->text()).trimmed();
if (input.endsWith("/"))
input.chop(1); // test if readable
if (input.isEmpty()) { QFileInfo fi(input);
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first")); if (!fi.isReadable()) {
QMessageBox::critical(this, tr("Torrent creator failed"), tr("Reason: Path to file/folder is not readable."));
return; return;
} }
QStringList trackers = trackers_list->toPlainText().split("\n"); input = fi.canonicalFilePath();
if (!trackers_list->toPlainText().trimmed().isEmpty())
saveTrackerList();
Preferences* const pref = Preferences::instance(); // get save path
QString lastPath = pref->getCreateTorLastSavePath(); QString lastPath = getLastSavePath();
QString destination = QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), lastPath, tr("Torrent Files (*.torrent)"));
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), lastPath, tr("Torrent Files (*.torrent)"));
if (destination.isEmpty()) if (destination.isEmpty())
return; return;
if (!destination.endsWith(".torrent", Qt::CaseInsensitive))
destination += ".torrent";
setLastSavePath(Utils::Fs::branchPath(destination));
pref->setCreateTorLastSavePath(Utils::Fs::branchPath(destination)); // Disable dialog & set busy cursor
if (!destination.toUpper().endsWith(".TORRENT"))
destination += QString::fromUtf8(".torrent");
// Disable dialog
setInteractionEnabled(false); setInteractionEnabled(false);
showProgressBar(true); showProgressBar(true);
// Set busy cursor
setCursor(QCursor(Qt::WaitCursor)); setCursor(QCursor(Qt::WaitCursor));
// Actually create the torrent
QStringList urlSeeds = URLSeeds_list->toPlainText().split("\n"); QStringList trackers = m_ui->trackers_list->toPlainText().split("\n");
QString comment = txt_comment->toPlainText(); QStringList urlSeeds = m_ui->URLSeeds_list->toPlainText().split("\n");
QString comment = m_ui->txt_comment->toPlainText();
// Create the creator thread // Create the creator thread
m_creatorThread = new BitTorrent::TorrentCreatorThread(this); m_creatorThread = new BitTorrent::TorrentCreatorThread(this);
connect(m_creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString))); connect(m_creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
connect(m_creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString))); connect(m_creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
connect(m_creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int))); connect(m_creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
m_creatorThread->create(input, destination, trackers, urlSeeds, comment, check_private->isChecked(), getPieceSize()); m_creatorThread->create(input, destination, trackers, urlSeeds, comment, m_ui->check_private->isChecked(), getPieceSize());
} }
void TorrentCreatorDlg::handleCreationFailure(QString msg) void TorrentCreatorDlg::handleCreationFailure(const QString &msg)
{ {
// Remove busy cursor // Remove busy cursor
setCursor(QCursor(Qt::ArrowCursor)); setCursor(QCursor(Qt::ArrowCursor));
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg)); QMessageBox::information(this, tr("Torrent creator failed"), tr("Reason: %1").arg(msg));
setInteractionEnabled(true); setInteractionEnabled(true);
showProgressBar(false); showProgressBar(false);
} }
void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path) void TorrentCreatorDlg::handleCreationSuccess(const QString &path, const QString &branchPath)
{ {
// Remove busy cursor // Remove busy cursor
setCursor(QCursor(Qt::ArrowCursor)); setCursor(QCursor(Qt::ArrowCursor));
if (checkStartSeeding->isChecked()) { if (m_ui->checkStartSeeding->isChecked()) {
// Create save path temp data // Create save path temp data
BitTorrent::TorrentInfo t = BitTorrent::TorrentInfo::loadFromFile(Utils::Fs::toNativePath(path)); BitTorrent::TorrentInfo t = BitTorrent::TorrentInfo::loadFromFile(Utils::Fs::toNativePath(path));
if (!t.isValid()) { if (!t.isValid()) {
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list.")); QMessageBox::critical(this, tr("Torrent creator failed"), tr("Reason: Created torrent is invalid. It won't be added to download list."));
return; return;
} }
BitTorrent::AddTorrentParams params; BitTorrent::AddTorrentParams params;
params.savePath = branch_path; params.savePath = branchPath;
params.skipChecking = true; params.skipChecking = true;
params.ignoreShareLimits = checkIgnoreShareLimits->isChecked(); params.ignoreShareLimits = m_ui->checkIgnoreShareLimits->isChecked();
BitTorrent::Session::instance()->addTorrent(t, params); BitTorrent::Session::instance()->addTorrent(t, params);
} }
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully: %1", "%1 is the path of the torrent").arg(Utils::Fs::toNativePath(path))); QMessageBox::information(this, tr("Torrent creator"), QString("%1\n%2").arg(tr("Create torrent success:")).arg(Utils::Fs::toNativePath(path)));
close();
}
void TorrentCreatorDlg::on_cancelButton_clicked()
{
// End torrent creation thread
if (m_creatorThread && m_creatorThread->isRunning()) {
m_creatorThread->abortCreation();
m_creatorThread->terminate();
// Wait for termination
m_creatorThread->wait();
}
// Close the dialog
close(); close();
} }
void TorrentCreatorDlg::updateProgressBar(int progress) void TorrentCreatorDlg::updateProgressBar(int progress)
{ {
progressBar->setValue(progress); m_ui->progressBar->setValue(progress);
} }
void TorrentCreatorDlg::setInteractionEnabled(bool enabled) void TorrentCreatorDlg::setInteractionEnabled(bool enabled)
{ {
textInputPath->setEnabled(enabled); m_ui->textInputPath->setEnabled(enabled);
addFile_button->setEnabled(enabled); m_ui->addFile_button->setEnabled(enabled);
addFolder_button->setEnabled(enabled); m_ui->addFolder_button->setEnabled(enabled);
trackers_list->setEnabled(enabled); m_ui->trackers_list->setEnabled(enabled);
URLSeeds_list->setEnabled(enabled); m_ui->URLSeeds_list->setEnabled(enabled);
txt_comment->setEnabled(enabled); m_ui->txt_comment->setEnabled(enabled);
comboPieceSize->setEnabled(enabled); m_ui->comboPieceSize->setEnabled(enabled);
checkAutoPieceSize->setEnabled(enabled); m_ui->check_private->setEnabled(enabled);
check_private->setEnabled(enabled); m_ui->checkStartSeeding->setEnabled(enabled);
checkStartSeeding->setEnabled(enabled); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
createButton->setEnabled(enabled); m_ui->checkIgnoreShareLimits->setEnabled(enabled && m_ui->checkStartSeeding->isChecked());
checkIgnoreShareLimits->setEnabled(enabled && checkStartSeeding->isChecked());
} }
void TorrentCreatorDlg::showProgressBar(bool show) void TorrentCreatorDlg::showProgressBar(bool show)
{ {
progressLbl->setVisible(show); m_ui->progressLbl->setVisible(show);
progressBar->setVisible(show); m_ui->progressBar->setVisible(show);
}
void TorrentCreatorDlg::saveSettings()
{
setLastAddPath(m_ui->textInputPath->text().trimmed());
setSettingPieceSize(m_ui->comboPieceSize->currentIndex());
setSettingPrivateTorrent(m_ui->check_private->isChecked());
setSettingStartSeeding(m_ui->checkStartSeeding->isChecked());
setSettingIgnoreRatio(m_ui->checkIgnoreShareLimits->isChecked());
setTrackerList(m_ui->trackers_list->toPlainText());
setWebSeedList(m_ui->URLSeeds_list->toPlainText());
setComments(m_ui->txt_comment->toPlainText());
setDialogSize(size());
} }
void TorrentCreatorDlg::on_checkAutoPieceSize_clicked(bool checked) void TorrentCreatorDlg::loadSettings()
{ {
comboPieceSize->setEnabled(!checked); m_ui->textInputPath->setText(!m_defaultPath.isEmpty() ? m_defaultPath : getLastAddPath());
if (checked)
updateOptimalPieceSize(); m_ui->comboPieceSize->setCurrentIndex(getSettingPieceSize());
m_ui->check_private->setChecked(getSettingPrivateTorrent());
m_ui->checkStartSeeding->setChecked(getSettingStartSeeding());
m_ui->checkIgnoreShareLimits->setChecked(getSettingIgnoreRatio());
m_ui->checkIgnoreShareLimits->setEnabled(m_ui->checkStartSeeding->isChecked());
m_ui->trackers_list->setPlainText(getTrackerList());
m_ui->URLSeeds_list->setPlainText(getWebSeedList());
m_ui->txt_comment->setPlainText(getComments());
resize(getDialogSize());
} }
void TorrentCreatorDlg::updateOptimalPieceSize() QSize TorrentCreatorDlg::getDialogSize() const
{ {
qint64 torrentSize = Utils::Fs::computePathSize(textInputPath->text()); return settings()->loadValue(KEY_DIALOG_SIZE, size()).toSize();
qDebug("Torrent size is %lld", torrentSize); }
if (torrentSize < 0)
return; void TorrentCreatorDlg::setDialogSize(const QSize &size)
int i = 0; {
qulonglong nb_pieces = 0; settings()->storeValue(KEY_DIALOG_SIZE, size);
do { }
nb_pieces = (double)torrentSize/(m_pieceSizes.at(i) * 1024.);
qDebug("nb_pieces=%lld with piece_size=%s", nb_pieces, qPrintable(comboPieceSize->itemText(i))); int TorrentCreatorDlg::getSettingPieceSize() const
if (nb_pieces <= NB_PIECES_MIN) { {
if (i > 1) return settings()->loadValue(KEY_PIECE_SIZE).toInt();
--i;
break;
} }
else if (nb_pieces < NB_PIECES_MAX) {
qDebug("Good, nb_pieces=%lld < %d", nb_pieces + 1, NB_PIECES_MAX); void TorrentCreatorDlg::setSettingPieceSize(const int size)
break; {
settings()->storeValue(KEY_PIECE_SIZE, size);
} }
++i;
} while (i < (m_pieceSizes.size() - 1)); bool TorrentCreatorDlg::getSettingPrivateTorrent() const
comboPieceSize->setCurrentIndex(i); {
return settings()->loadValue(KEY_PRIVATE_TORRENT).toBool();
} }
void TorrentCreatorDlg::saveTrackerList() void TorrentCreatorDlg::setSettingPrivateTorrent(const bool b)
{ {
Preferences::instance()->setCreateTorTrackers(trackers_list->toPlainText()); settings()->storeValue(KEY_PRIVATE_TORRENT, b);
} }
void TorrentCreatorDlg::loadTrackerList() bool TorrentCreatorDlg::getSettingStartSeeding() const
{ {
trackers_list->setPlainText(Preferences::instance()->getCreateTorTrackers()); return settings()->loadValue(KEY_START_SEEDING).toBool();
} }
void TorrentCreatorDlg::saveSettings() void TorrentCreatorDlg::setSettingStartSeeding(const bool b)
{ {
Preferences* const pref = Preferences::instance(); settings()->storeValue(KEY_START_SEEDING, b);
pref->setCreateTorGeometry(saveGeometry());
pref->setCreateTorIgnoreRatio(checkIgnoreShareLimits->isChecked());
} }
void TorrentCreatorDlg::loadSettings() bool TorrentCreatorDlg::getSettingIgnoreRatio() const
{ {
const Preferences* const pref = Preferences::instance(); return settings()->loadValue(KEY_SETTING_IGNORE_RATIO).toBool();
restoreGeometry(pref->getCreateTorGeometry());
checkIgnoreShareLimits->setChecked(pref->getCreateTorIgnoreRatio());
} }
void TorrentCreatorDlg::closeEvent(QCloseEvent *event) void TorrentCreatorDlg::setSettingIgnoreRatio(const bool ignore)
{ {
qDebug() << Q_FUNC_INFO; settings()->storeValue(KEY_SETTING_IGNORE_RATIO, ignore);
saveSettings(); }
QDialog::closeEvent(event);
QString TorrentCreatorDlg::getLastAddPath() const
{
return settings()->loadValue(KEY_LAST_ADD_PATH, QDir::homePath()).toString();
}
void TorrentCreatorDlg::setLastAddPath(const QString &path)
{
settings()->storeValue(KEY_LAST_ADD_PATH, path);
}
QString TorrentCreatorDlg::getTrackerList() const
{
return settings()->loadValue(KEY_TRACKER_LIST).toString();
}
void TorrentCreatorDlg::setTrackerList(const QString &list)
{
settings()->storeValue(KEY_TRACKER_LIST, list);
}
QString TorrentCreatorDlg::getWebSeedList() const
{
return settings()->loadValue(KEY_WEB_SEED_LIST).toString();
}
void TorrentCreatorDlg::setWebSeedList(const QString &list)
{
settings()->storeValue(KEY_WEB_SEED_LIST, list);
}
QString TorrentCreatorDlg::getComments() const
{
return settings()->loadValue(KEY_COMMENTS).toString();
}
void TorrentCreatorDlg::setComments(const QString &str)
{
settings()->storeValue(KEY_COMMENTS, str);
}
QString TorrentCreatorDlg::getLastSavePath() const
{
return settings()->loadValue(KEY_LAST_SAVE_PATH, QDir::homePath()).toString();
}
void TorrentCreatorDlg::setLastSavePath(const QString &path)
{
settings()->storeValue(KEY_LAST_SAVE_PATH, path);
} }

72
src/gui/torrentcreatordlg.h

@ -28,52 +28,72 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#ifndef CREATE_TORRENT_IMP_H #ifndef TORRENTCREATORDLG_H
#define CREATE_TORRENT_IMP_H #define TORRENTCREATORDLG_H
#include "ui_torrentcreatordlg.h" #include <QDialog>
namespace Ui
{
class TorrentCreatorDlg;
}
namespace BitTorrent namespace BitTorrent
{ {
class TorrentCreatorThread; class TorrentCreatorThread;
} }
class TorrentCreatorDlg : public QDialog, private Ui::createTorrentDialog class TorrentCreatorDlg: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
TorrentCreatorDlg(QWidget *parent = 0); TorrentCreatorDlg(QWidget *parent = 0, const QString &defaultPath = QString());
~TorrentCreatorDlg(); ~TorrentCreatorDlg();
int getPieceSize() const;
public slots: private slots:
void updateProgressBar(int progress); void updateProgressBar(int progress);
void on_cancelButton_clicked(); void onCreateButtonClicked();
void onAddFileButtonClicked();
protected slots: void onAddFolderButtonClicked();
void on_createButton_clicked(); void handleCreationFailure(const QString &msg);
void on_addFile_button_clicked(); void handleCreationSuccess(const QString &path, const QString &branchPath);
void on_addFolder_button_clicked();
void handleCreationFailure(QString msg);
void handleCreationSuccess(QString path, QString branch_path);
void setInteractionEnabled(bool enabled);
void showProgressBar(bool show);
void on_checkAutoPieceSize_clicked(bool checked);
void updateOptimalPieceSize();
void saveTrackerList();
void loadTrackerList();
protected:
void closeEvent(QCloseEvent *event);
private: private:
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void saveSettings(); void saveSettings();
void loadSettings(); void loadSettings();
int getPieceSize() const;
void showProgressBar(bool show);
void setInteractionEnabled(bool enabled);
private: // settings storage
QSize getDialogSize() const;
void setDialogSize(const QSize &size);
int getSettingPieceSize() const;
void setSettingPieceSize(const int size);
bool getSettingPrivateTorrent() const;
void setSettingPrivateTorrent(const bool b);
bool getSettingStartSeeding() const;
void setSettingStartSeeding(const bool b);
bool getSettingIgnoreRatio() const;
void setSettingIgnoreRatio(const bool ignore);
QString getLastAddPath() const;
void setLastAddPath(const QString &path);
QString getTrackerList() const;
void setTrackerList(const QString &list);
QString getWebSeedList() const;
void setWebSeedList(const QString &list);
QString getComments() const;
void setComments(const QString &str);
QString getLastSavePath() const;
void setLastSavePath(const QString &path);
Ui::TorrentCreatorDlg *m_ui;
BitTorrent::TorrentCreatorThread *m_creatorThread; BitTorrent::TorrentCreatorThread *m_creatorThread;
QList<int> m_pieceSizes; QString m_defaultPath;
}; };
#endif #endif

289
src/gui/torrentcreatordlg.ui

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>createTorrentDialog</class> <class>TorrentCreatorDlg</class>
<widget class="QDialog" name="createTorrentDialog"> <widget class="QDialog" name="TorrentCreatorDlg">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -10,138 +10,85 @@
<height>658</height> <height>658</height>
</rect> </rect>
</property> </property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Torrent Creation Tool</string> <string>Torrent Creator</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="createTorrent_title"> <widget class="QGroupBox" name="groupBox">
<property name="minimumSize"> <property name="title">
<size> <string>Select file/folder to share</string>
<width>0</width>
<height>27</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>27</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Torrent file creation</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_input">
<property name="text">
<string>File or folder to add to the torrent:</string>
</property> </property>
</widget> <layout class="QVBoxLayout" name="verticalLayout_3">
</item>
<item>
<widget class="QLineEdit" name="textInputPath"/>
</item>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="addFile_button"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Add file</string> <string>Path:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="addFolder_button"> <widget class="QLineEdit" name="textInputPath">
<property name="text"> <property name="acceptDrops">
<string>Add folder</string> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item row="0" column="0"> <item>
<widget class="QLabel" name="lbl_announce_url"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="enabled">
<string>Tracker URLs:</string> <bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="urlSeeds_lbl">
<property name="text">
<string>Web seeds urls:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_comment">
<property name="text">
<string>Comment:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget>
</item>
<item row="2" column="1">
<widget class="QTextEdit" name="txt_comment">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="acceptRichText"> <property name="text">
<bool>false</bool> <string>[Drag and drop area]</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item>
<widget class="QTextEdit" name="trackers_list"> <widget class="QPushButton" name="addFile_button">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <string>Select file</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string comment="A tracker tier is a group of trackers, consisting of a main tracker and its mirrors.">You can separate tracker tiers / groups with an empty line.</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item>
<widget class="QTextEdit" name="URLSeeds_list"> <widget class="QPushButton" name="addFolder_button">
<property name="acceptRichText"> <property name="text">
<bool>false</bool> <string>Select folder</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout" name="pieceSizeLayout">
<item> <item>
<widget class="QLabel" name="txtPieceSize"> <widget class="QLabel" name="txtPieceSize">
<property name="text"> <property name="text">
@ -151,15 +98,14 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboPieceSize"> <widget class="QComboBox" name="comboPieceSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>0</number>
</property>
<item>
<property name="text">
<string>Auto</string>
</property> </property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>16 KiB</string> <string>16 KiB</string>
@ -218,17 +164,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkAutoPieceSize"> <spacer name="spacer1">
<property name="text">
<string>Auto</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -245,14 +181,14 @@
<item> <item>
<widget class="QCheckBox" name="check_private"> <widget class="QCheckBox" name="check_private">
<property name="text"> <property name="text">
<string>Private (won't be distributed on DHT network if enabled)</string> <string>Private torrent (Won't distribute on DHT network)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkStartSeeding"> <widget class="QCheckBox" name="checkStartSeeding">
<property name="text"> <property name="text">
<string>Start seeding after creation</string> <string>Start seeding immediately</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
@ -266,66 +202,101 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="progressLbl"> <widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Fields</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QTextEdit" name="trackers_list">
<property name="toolTip">
<string comment="A tracker tier is a group of trackers, consisting of a main tracker and its mirrors.">You can separate tracker tiers / groups with an empty line.</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="urlSeeds_lbl">
<property name="text"> <property name="text">
<string>Progress:</string> <string>Web seed URLs:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QProgressBar" name="progressBar"> <widget class="QTextEdit" name="URLSeeds_list">
<property name="value"> <property name="acceptRichText">
<number>0</number> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="1">
<layout class="QHBoxLayout"> <widget class="QTextEdit" name="txt_comment">
<item> <property name="acceptRichText">
<spacer> <bool>false</bool>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>131</width> <item row="0" column="0">
<height>31</height> <widget class="QLabel" name="lbl_announce_url">
</size> <property name="text">
<string>Tracker URLs:</string>
</property> </property>
</spacer> </widget>
</item> </item>
<item> <item row="2" column="0">
<widget class="QPushButton" name="createButton"> <widget class="QLabel" name="lbl_comment">
<property name="text"> <property name="text">
<string>Create and save...</string> <string>Comments:</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QPushButton" name="cancelButton"> <widget class="QLabel" name="progressLbl">
<property name="text"> <property name="text">
<string>Cancel</string> <string>Progress:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer> <widget class="QProgressBar" name="progressBar"/>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops>
<tabstop>textInputPath</tabstop>
<tabstop>addFile_button</tabstop>
<tabstop>addFolder_button</tabstop>
<tabstop>comboPieceSize</tabstop>
<tabstop>check_private</tabstop>
<tabstop>checkStartSeeding</tabstop>
<tabstop>checkIgnoreShareLimits</tabstop>
<tabstop>trackers_list</tabstop>
<tabstop>URLSeeds_list</tabstop>
<tabstop>txt_comment</tabstop>
</tabstops>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
@ -344,5 +315,21 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>TorrentCreatorDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>635</y>
</hint>
<hint type="destinationlabel">
<x>295</x>
<y>328</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>

Loading…
Cancel
Save