mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-10 04:11:16 +00:00
- Fixed error messages display when loading a corrupted torrent file
This commit is contained in:
parent
9b7b5b200b
commit
b93ac6f9af
16
src/GUI.cpp
16
src/GUI.cpp
@ -269,6 +269,7 @@ GUI::~GUI(){
|
|||||||
|
|
||||||
// Update Info Bar information
|
// Update Info Bar information
|
||||||
void GUI::setInfoBar(const QString& info, const QString& color){
|
void GUI::setInfoBar(const QString& info, const QString& color){
|
||||||
|
qDebug("setInfoBar called");
|
||||||
static unsigned short nbLines = 0;
|
static unsigned short nbLines = 0;
|
||||||
++nbLines;
|
++nbLines;
|
||||||
// Check log size, clear it if too big
|
// Check log size, clear it if too big
|
||||||
@ -1058,9 +1059,10 @@ void GUI::dropEvent(QDropEvent *event){
|
|||||||
QString file;
|
QString file;
|
||||||
foreach(file, files){
|
foreach(file, files){
|
||||||
if(options->useAdditionDialog()){
|
if(options->useAdditionDialog()){
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, file.trimmed().replace("file://", ""));
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||||||
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
||||||
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
||||||
|
dialog->showLoad(file.trimmed().replace("file://", ""));
|
||||||
}else{
|
}else{
|
||||||
addTorrent(file.trimmed().replace("file://", ""));
|
addTorrent(file.trimmed().replace("file://", ""));
|
||||||
}
|
}
|
||||||
@ -1101,9 +1103,10 @@ void GUI::askForTorrents(){
|
|||||||
if(!pathsList.empty()){
|
if(!pathsList.empty()){
|
||||||
for(int i=0; i<pathsList.size(); ++i){
|
for(int i=0; i<pathsList.size(); ++i){
|
||||||
if(options->useAdditionDialog()){
|
if(options->useAdditionDialog()){
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, pathsList.at(i));
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||||||
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
||||||
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
||||||
|
dialog->showLoad(pathsList.at(i));
|
||||||
}else{
|
}else{
|
||||||
addTorrent(pathsList.at(i));
|
addTorrent(pathsList.at(i));
|
||||||
}
|
}
|
||||||
@ -1134,9 +1137,10 @@ void GUI::scanDirectory(){
|
|||||||
}
|
}
|
||||||
foreach(file, to_add){
|
foreach(file, to_add){
|
||||||
if(options->useAdditionDialog()){
|
if(options->useAdditionDialog()){
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, file, true);
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||||||
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
||||||
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
||||||
|
dialog->showLoad(file, true);
|
||||||
}else{
|
}else{
|
||||||
addTorrent(file, true);
|
addTorrent(file, true);
|
||||||
}
|
}
|
||||||
@ -1603,9 +1607,10 @@ void GUI::processParams(const QStringList& params){
|
|||||||
downloadFromUrl(param);
|
downloadFromUrl(param);
|
||||||
}else{
|
}else{
|
||||||
if(options->useAdditionDialog()){
|
if(options->useAdditionDialog()){
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, param);
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||||||
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
||||||
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
||||||
|
dialog->showLoad(param);
|
||||||
}else{
|
}else{
|
||||||
addTorrent(param);
|
addTorrent(param);
|
||||||
}
|
}
|
||||||
@ -2397,9 +2402,10 @@ void GUI::processDownloadedFile(QString url, QString file_path, int return_code,
|
|||||||
}
|
}
|
||||||
// Add file to torrent download list
|
// Add file to torrent download list
|
||||||
if(options->useAdditionDialog()){
|
if(options->useAdditionDialog()){
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, file_path, false, url);
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||||||
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
|
||||||
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
|
||||||
|
dialog->showLoad(file_path, false, url);
|
||||||
}else{
|
}else{
|
||||||
addTorrent(file_path, false, url);
|
addTorrent(file_path, false, url);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,10 @@ using namespace libtorrent;
|
|||||||
class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void setInfoBarGUI(const QString& info, const QString& color);
|
||||||
|
void torrentAddition(const QString& filePath, bool fromScanDir, const QString& from_url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QString filePath;
|
QString filePath;
|
||||||
@ -51,7 +55,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
QString from_url;
|
QString from_url;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
torrentAdditionDialog(QWidget *parent, QString filePath, bool fromScanDir=false, QString from_url=QString::null) : QDialog(parent), filePath(filePath), fromScanDir(fromScanDir), from_url(from_url){
|
torrentAdditionDialog(QWidget *parent) : QDialog(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
actionSelect->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
|
actionSelect->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/add.png")));
|
||||||
@ -64,6 +68,12 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
home += QDir::separator();
|
home += QDir::separator();
|
||||||
}
|
}
|
||||||
savePathTxt->setText(home+"qBT_dir");
|
savePathTxt->setText(home+"qBT_dir");
|
||||||
|
}
|
||||||
|
|
||||||
|
void showLoad(QString filePath, bool fromScanDir=false, QString from_url=QString::null){
|
||||||
|
this->filePath = filePath;
|
||||||
|
this->fromScanDir = fromScanDir;
|
||||||
|
this->from_url = from_url;
|
||||||
std::ifstream in((const char*)filePath.toUtf8(), std::ios_base::binary);
|
std::ifstream in((const char*)filePath.toUtf8(), std::ios_base::binary);
|
||||||
in.unsetf(std::ios_base::skipws);
|
in.unsetf(std::ios_base::skipws);
|
||||||
try{
|
try{
|
||||||
@ -91,7 +101,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
}else{
|
}else{
|
||||||
emit setInfoBarGUI(tr("Unable to decode torrent file:")+" '"+filePath+"'", "red");
|
emit setInfoBarGUI(tr("Unable to decode torrent file:")+" '"+filePath+"'", "red");
|
||||||
}
|
}
|
||||||
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."),"red");
|
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."), "red");
|
||||||
if(fromScanDir){
|
if(fromScanDir){
|
||||||
// Remove .corrupt file in case it already exists
|
// Remove .corrupt file in case it already exists
|
||||||
QFile::remove(filePath+".corrupt");
|
QFile::remove(filePath+".corrupt");
|
||||||
@ -108,7 +118,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
}else{
|
}else{
|
||||||
emit setInfoBarGUI(tr("Unable to decode torrent file:")+" '"+filePath+"'", "red");
|
emit setInfoBarGUI(tr("Unable to decode torrent file:")+" '"+filePath+"'", "red");
|
||||||
}
|
}
|
||||||
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."),"red");
|
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."), "red");
|
||||||
if(fromScanDir){
|
if(fromScanDir){
|
||||||
// Remove .corrupt file in case it already exists
|
// Remove .corrupt file in case it already exists
|
||||||
QFile::remove(filePath+".corrupt");
|
QFile::remove(filePath+".corrupt");
|
||||||
@ -258,10 +268,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
emit torrentAddition(filePath, fromScanDir, from_url);
|
emit torrentAddition(filePath, fromScanDir, from_url);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
|
||||||
void setInfoBarGUI(const QString& message, const QString& color);
|
|
||||||
void torrentAddition(const QString& filePath, bool fromScanDir, const QString& from_url);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user