mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
- FEATURE: Display free disk space in torrent addition dialog
- Added some disambiguation for translators
This commit is contained in:
parent
c8e8306e0a
commit
6fcf25af52
5 changed files with 576 additions and 465 deletions
|
@ -1,5 +1,6 @@
|
||||||
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.5.0
|
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.5.0
|
||||||
- FEATURE: Added Magnet URI support
|
- FEATURE: Added Magnet URI support
|
||||||
|
- FEATURE: Display free disk space in torrent addition dialog
|
||||||
- BUGFIX: torrent resume code rewrited
|
- BUGFIX: torrent resume code rewrited
|
||||||
|
|
||||||
* Thu Aug 13 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.4.0
|
* Thu Aug 13 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.4.0
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>addTorrentDialog</class>
|
<class>addTorrentDialog</class>
|
||||||
<widget class="QDialog" name="addTorrentDialog">
|
<widget class="QDialog" name="addTorrentDialog">
|
||||||
|
@ -6,13 +7,13 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>511</width>
|
<width>511</width>
|
||||||
<height>441</height>
|
<height>461</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Torrent addition dialog</string>
|
<string>Torrent addition dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="fileNameLbl">
|
<widget class="QLabel" name="fileNameLbl">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -45,16 +46,7 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
<property name="margin">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -69,6 +61,75 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Torrent size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_torrent_size">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Free disk space:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lbl_disk_space">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unknown</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_space_msg">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="torrentContentLbl">
|
<widget class="QLabel" name="torrentContentLbl">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -102,7 +163,7 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
@ -129,7 +190,7 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
@ -142,7 +203,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkIncrementalDL">
|
<widget class="QCheckBox" name="checkIncrementalDL">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Download in correct order (slower but good for previewing)</string>
|
<string>Download in sequential order (slower but good for previewing)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -158,16 +219,7 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin" >
|
<property name="margin">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin" >
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin" >
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -175,7 +227,7 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
@ -202,7 +254,7 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
|
|
22
src/misc.h
22
src/misc.h
|
@ -42,6 +42,10 @@
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
#include <sys/vfs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
@ -92,6 +96,24 @@ public:
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned long long freeDiskSpaceOnPath(QString path) {
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
|
unsigned long long available;
|
||||||
|
struct statfs stats;
|
||||||
|
int ret = statfs ((path+"/.").toUtf8().data(), &stats) ;
|
||||||
|
if(ret == 0) {
|
||||||
|
available = ((unsigned long long)stats.f_bavail) *
|
||||||
|
((unsigned long long)stats.f_bsize) ;
|
||||||
|
return available;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||||
// use Binary prefix standards from IEC 60027-2
|
// use Binary prefix standards from IEC 60027-2
|
||||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||||
|
|
|
@ -465,7 +465,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string comment="qBittorrent will watch a directory and automatically download torrents present in it">Transfer lists double-click</string>
|
<string comment="Action executed when doucle-clicking on an item in transfer (download/upload) list">Transfer lists double-click action</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -64,6 +64,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
QStandardItemModel *PropListModel;
|
QStandardItemModel *PropListModel;
|
||||||
PropListDelegate *PropDelegate;
|
PropListDelegate *PropDelegate;
|
||||||
unsigned int nbFiles;
|
unsigned int nbFiles;
|
||||||
|
boost::intrusive_ptr<torrent_info> t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
torrentAdditionDialog(QWidget *parent, bittorrent* _BTSession) : QDialog(parent) {
|
torrentAdditionDialog(QWidget *parent, bittorrent* _BTSession) : QDialog(parent) {
|
||||||
|
@ -116,7 +117,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
this->filePath = filePath;
|
this->filePath = filePath;
|
||||||
this->from_url = from_url;
|
this->from_url = from_url;
|
||||||
// Getting torrent file informations
|
// Getting torrent file informations
|
||||||
boost::intrusive_ptr<torrent_info> t;
|
|
||||||
try {
|
try {
|
||||||
t = new torrent_info(filePath.toLocal8Bit().data());
|
t = new torrent_info(filePath.toLocal8Bit().data());
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
|
@ -147,7 +147,8 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
addFilesToTree(arb->getRoot(), PropListModel->invisibleRootItem());
|
addFilesToTree(arb->getRoot(), PropListModel->invisibleRootItem());
|
||||||
delete arb;
|
delete arb;
|
||||||
connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
||||||
torrentContentList->expandAll();
|
//torrentContentList->expandAll();
|
||||||
|
updateDiskSpaceLabels();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,6 +257,40 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
// Reconnect the signal/slot on item edition so that we
|
// Reconnect the signal/slot on item edition so that we
|
||||||
// get future updates
|
// get future updates
|
||||||
connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
|
||||||
|
// Update disk space labels
|
||||||
|
updateDiskSpaceLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateDiskSpaceLabels() {
|
||||||
|
unsigned long long available = misc::freeDiskSpaceOnPath(savePathTxt->text());
|
||||||
|
if (available > 0) {
|
||||||
|
lbl_disk_space->setText(misc::friendlyUnit(available));
|
||||||
|
} else {
|
||||||
|
lbl_disk_space->setText(tr("Unknown"));
|
||||||
|
}
|
||||||
|
// Determine torrent size
|
||||||
|
unsigned long long torrent_size = 0;
|
||||||
|
int nbFiles = t->num_files();
|
||||||
|
int *priorities = new int[nbFiles];
|
||||||
|
getPriorities(PropListModel->invisibleRootItem(), priorities);
|
||||||
|
for(int i=0; i<nbFiles; ++i) {
|
||||||
|
if(priorities[i] > 0)
|
||||||
|
torrent_size += t->file_at(i).size;
|
||||||
|
}
|
||||||
|
lbl_torrent_size->setText(misc::friendlyUnit(torrent_size));
|
||||||
|
// Check if free space is sufficient
|
||||||
|
if(available > 0) {
|
||||||
|
if(available > torrent_size) {
|
||||||
|
// Space is sufficient
|
||||||
|
label_space_msg->setText(tr("(%1 left after torrent download)", "e.g. (100MiB left after torrent download)").arg(misc::friendlyUnit(available-torrent_size)));
|
||||||
|
} else {
|
||||||
|
// Space is unsufficient
|
||||||
|
label_space_msg->setText("<font color=\"red\">"+tr("(%1 more are required to download)", "e.g. (100MiB more are required to download)").arg(misc::friendlyUnit(torrent_size-available))+"</font>");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Available disk space is unknown
|
||||||
|
label_space_msg->setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_browseButton_clicked(){
|
void on_browseButton_clicked(){
|
||||||
|
@ -268,6 +303,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
}
|
}
|
||||||
if(!dir.isNull()){
|
if(!dir.isNull()){
|
||||||
savePathTxt->setText(dir);
|
savePathTxt->setText(dir);
|
||||||
|
updateDiskSpaceLabels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue