1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

hooked up filetransferwidget

This commit is contained in:
krepa098 2014-11-17 16:05:14 +01:00
parent 1cf9fe3474
commit 27cb075dbb
12 changed files with 396 additions and 152 deletions

View File

@ -94,7 +94,14 @@
<file>translations/fr.qm</file>
<file>translations/ru.qm</file>
<file>ui/fileTransferWidget/fileTransferWidget.css</file>
<file>ui/fileTransferInstance/red.css</file>
<file>ui/fileTransferInstance/green.css</file>
<file>ui/fileTransferInstance/grey.css</file>
<file>ui/fileTransferInstance/yellow.css</file>
<file>ui/fileTransferInstance/background_red.png</file>
<file>ui/fileTransferInstance/background_yellow.png</file>
<file>ui/fileTransferInstance/background_green.png</file>
<file>ui/fileTransferInstance/background_grey.png</file>
<file>ui/fileTransferInstance/pause_2x.png</file>
<file>ui/fileTransferInstance/no_2x.png</file>
<file>ui/fileTransferInstance/yes_2x.png</file>

View File

@ -18,6 +18,7 @@
#include "ui_filetransferwidget.h"
#include "src/core.h"
#include "src/misc/style.h"
#include <QMouseEvent>
#include <QDebug>
@ -26,15 +27,28 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
: QWidget(parent)
, ui(new Ui::FileTransferWidget)
, fileInfo(file)
, lastTick(QTime::currentTime())
{
ui->setupUi(this);
ui->filenameLabel->setText(file.fileName);
ui->progressBar->setValue(0);
ui->fileSizeLabel->setText(getHumanReadableSize(file.filesize));
ui->progressLabel->setText("0%");
ui->etaLabel->setText("--:--");
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css"));
Style::repolish(this);
connect(Core::getInstance(), &Core::fileTransferInfo, this, &FileTransferWidget::onFileTransferInfo);
connect(Core::getInstance(), &Core::fileTransferAccepted, this, &FileTransferWidget::onFileTransferAccepted);
connect(Core::getInstance(), &Core::fileTransferCancelled, this, &FileTransferWidget::onFileTransferCancelled);
connect(Core::getInstance(), &Core::fileTransferPaused, this, &FileTransferWidget::onFileTransferPaused);
connect(Core::getInstance(), &Core::fileTransferFinished, this, &FileTransferWidget::onFileTransferFinished);
setFixedHeight(100);
setupButtons();
setFixedHeight(85);
}
FileTransferWidget::~FileTransferWidget()
@ -42,12 +56,176 @@ FileTransferWidget::~FileTransferWidget()
delete ui;
}
void FileTransferWidget::onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction)
void FileTransferWidget::onFileTransferInfo(ToxFile file)
{
if(FileNum != fileInfo.fileNum)
if(fileInfo != file)
return;
fileInfo = file;
// update progress
qreal progress = static_cast<qreal>(Filesize)/static_cast<qreal>(BytesSent);
qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize);
ui->progressBar->setValue(static_cast<int>(progress * 100.0));
// eta, speed
QTime now = QTime::currentTime();
qreal deltaSecs = lastTick.msecsTo(now) / 1000.0;
if(deltaSecs >= 1.0)
{
qint64 deltaBytes = file.bytesSent - lastBytesSent;
qint64 bytesPerSec = static_cast<int>(static_cast<qreal>(deltaBytes) / deltaSecs);
if(bytesPerSec > 0)
{
QTime toGo(0,0,file.filesize / bytesPerSec);
ui->etaLabel->setText(toGo.toString("mm:ss"));
}
else
{
ui->etaLabel->setText("--:--");
}
ui->progressLabel->setText(getHumanReadableSize(bytesPerSec) + "/s");
lastTick = now;
lastBytesSent = file.bytesSent;
}
setupButtons();
repaint();
}
void FileTransferWidget::onFileTransferAccepted(ToxFile file)
{
if(fileInfo != file)
return;
fileInfo = file;
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/yellow.css"));
Style::repolish(this);
setupButtons();
}
void FileTransferWidget::onFileTransferCancelled(ToxFile file)
{
if(fileInfo != file)
return;
fileInfo = file;
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/red.css"));
Style::repolish(this);
setupButtons();
hideWidgets();
disconnect(Core::getInstance());
}
void FileTransferWidget::onFileTransferPaused(ToxFile file)
{
if(fileInfo != file)
return;
fileInfo = file;
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css"));
Style::repolish(this);
setupButtons();
}
void FileTransferWidget::onFileTransferFinished(ToxFile file)
{
if(fileInfo != file)
return;
fileInfo = file;
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/green.css"));
Style::repolish(this);
setupButtons();
hideWidgets();
disconnect(Core::getInstance());
}
QString FileTransferWidget::getHumanReadableSize(qint64 size)
{
static const char* suffix[] = {"B","kiB","MiB","GiB","TiB"};
int exp = 0;
if (size > 0)
exp = std::min( (int) (log(size) / log(1024)), (int) (sizeof(suffix) / sizeof(suffix[0]) - 1));
return QString().setNum(size / pow(1024, exp),'f',2).append(suffix[exp]);
}
void FileTransferWidget::hideWidgets()
{
ui->buttonWidget->hide();
ui->progressBar->hide();
ui->progressLabel->hide();
ui->etaLabel->hide();
}
void FileTransferWidget::setupButtons()
{
switch(fileInfo.status)
{
case ToxFile::TRANSMITTING:
ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/no_2x.png"));
ui->topButton->setObjectName("cancel");
ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/pause_2x.png"));
ui->bottomButton->setObjectName("pause");
break;
case ToxFile::PAUSED:
ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/no_2x.png"));
ui->topButton->setObjectName("cancel");
ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/arrow_white_2x.png"));
ui->bottomButton->setObjectName("resume");
break;
case ToxFile::STOPPED:
case ToxFile::BROKEN: //TODO: ?
break;
}
}
void FileTransferWidget::handleButton(QPushButton *btn)
{
if(fileInfo.direction == ToxFile::SENDING)
{
if(btn->objectName() == "cancel")
Core::getInstance()->cancelFileSend(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
}
else
{
if(btn->objectName() == "cancel")
Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
}
}
void FileTransferWidget::on_topButton_clicked()
{
handleButton(ui->topButton);
}
void FileTransferWidget::on_bottomButton_clicked()
{
handleButton(ui->bottomButton);
}

View File

@ -18,6 +18,7 @@
#define FILETRANSFERWIDGET_H
#include <QWidget>
#include <QTime>
#include "../chatlinecontent.h"
#include "../../corestructs.h"
@ -25,6 +26,8 @@ namespace Ui {
class FileTransferWidget;
}
class QPushButton;
class FileTransferWidget : public QWidget
{
Q_OBJECT
@ -34,11 +37,27 @@ public:
virtual ~FileTransferWidget();
protected slots:
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
void onFileTransferInfo(ToxFile file);
void onFileTransferAccepted(ToxFile file);
void onFileTransferCancelled(ToxFile file);
void onFileTransferPaused(ToxFile file);
void onFileTransferFinished(ToxFile file);
protected:
QString getHumanReadableSize(qint64 size);
void hideWidgets();
void setupButtons();
void handleButton(QPushButton* btn);
private slots:
void on_topButton_clicked();
void on_bottomButton_clicked();
private:
Ui::FileTransferWidget *ui;
ToxFile fileInfo;
QTime lastTick;
qint64 lastBytesSent = 0;
};

View File

@ -6,35 +6,29 @@
<rect>
<x>0</x>
<y>0</y>
<width>619</width>
<height>86</height>
<width>544</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color:transparent;</string>
<string notr="true">#FileTransferWidget {
background-color:transparent;
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QFrame" name="frame_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame {
border-image: url(:/ui/fileTransferInstance/background_red.png);
border-left:25;padding-top:-30;
border-top:28;
border-right:25; padding-right:-28;
border-bottom:28;padding-bottom:-30;
color:white;
}
QPushButton {
margin:0;
}</string>
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -45,70 +39,89 @@ QPushButton {
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="filenameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Filename</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>10Mb</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>24%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="progressLabel">
<property name="text">
<string>ETA:10:10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="statusWidget" native="true">
<layout class="QHBoxLayout" name="_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="fileSizeLabel">
<property name="text">
<string>10Mb</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="progressLabel">
<property name="text">
<string>24%</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="etaLabel">
<property name="text">
<string>ETA:10:10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>14</height>
<height>10</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QProgressBar {
border: 2px solid black;
border-radius: 0px;
color: white;
background-color:white;
}
QProgressBar::chunk {
background-color: black;
width: 20px;
}</string>
<string notr="true"/>
</property>
<property name="value">
<number>24</number>
@ -140,64 +153,78 @@ QProgressBar::chunk {
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res.qrc">
<normaloff>:/ui/fileTransferInstance/pause_2x.png</normaloff>:/ui/fileTransferInstance/pause_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>25</width>
<height>28</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res.qrc">
<normaloff>:/ui/fileTransferInstance/arrow_white_2x.png</normaloff>:/ui/fileTransferInstance/arrow_white_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>25</width>
<height>28</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="buttonWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="topButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res.qrc">
<normaloff>:/ui/fileTransferInstance/pause_2x.png</normaloff>:/ui/fileTransferInstance/pause_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>25</width>
<height>28</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>92</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="bottomButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../res.qrc">
<normaloff>:/ui/fileTransferInstance/arrow_white_2x.png</normaloff>:/ui/fileTransferInstance/arrow_white_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>25</width>
<height>28</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>

View File

@ -567,7 +567,7 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
qDebug() << QString("Core::onFileControlCallback: Transfer of file %1 cancelled by friend %2")
.arg(file->fileNum).arg(file->friendId);
file->status = ToxFile::STOPPED;
emit static_cast<Core*>(core)->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
emit static_cast<Core*>(core)->fileTransferCancelled(*file);
// Wait for sendAllFileData to return before deleting the ToxFile, we MUST ensure this or we'll use after free
if (file->sendTimer)
{
@ -594,7 +594,7 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
qDebug() << QString("Core::onFileControlCallback: Transfer of file %1 cancelled by friend %2")
.arg(file->fileNum).arg(file->friendId);
file->status = ToxFile::STOPPED;
emit static_cast<Core*>(core)->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::RECEIVING);
emit static_cast<Core*>(core)->fileTransferCancelled(*file);
removeFileFromQueue((bool)receive_send, file->friendId, file->fileNum);
}
else if (receive_send == 0 && control_type == TOX_FILECONTROL_FINISHED)
@ -669,8 +669,7 @@ void Core::onFileDataCallback(Tox*, int32_t friendnumber, uint8_t filenumber, co
file->file->write((char*)data,length);
file->bytesSent += length;
//qDebug() << QString("Core::onFileDataCallback: received %1/%2 bytes").arg(file->bytesSent).arg(file->filesize);
emit static_cast<Core*>(core)->fileTransferInfo(file->friendId, file->fileNum,
file->filesize, file->bytesSent, ToxFile::RECEIVING);
emit static_cast<Core*>(core)->fileTransferInfo(*file);
}
void Core::onAvatarInfoCallback(Tox*, int32_t friendnumber, uint8_t format,
@ -852,7 +851,7 @@ void Core::pauseResumeFileSend(int friendId, int fileNum)
if (file->status == ToxFile::TRANSMITTING)
{
file->status = ToxFile::PAUSED;
emit fileTransferPaused(file->friendId, file->fileNum, ToxFile::SENDING);
emit fileTransferPaused(*file);
tox_file_send_control(tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_PAUSE, nullptr, 0);
}
else if (file->status == ToxFile::PAUSED)
@ -884,7 +883,7 @@ void Core::pauseResumeFileRecv(int friendId, int fileNum)
if (file->status == ToxFile::TRANSMITTING)
{
file->status = ToxFile::PAUSED;
emit fileTransferPaused(file->friendId, file->fileNum, ToxFile::RECEIVING);
emit fileTransferPaused(*file);
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_PAUSE, nullptr, 0);
}
else if (file->status == ToxFile::PAUSED)
@ -914,7 +913,7 @@ void Core::cancelFileSend(int friendId, int fileNum)
return;
}
file->status = ToxFile::STOPPED;
emit fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
emit fileTransferCancelled(*file);
tox_file_send_control(tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0);
while (file->sendTimer) QThread::msleep(1); // Wait until sendAllFileData returns before deleting
removeFileFromQueue(true, friendId, fileNum);
@ -937,7 +936,7 @@ void Core::cancelFileRecv(int friendId, int fileNum)
return;
}
file->status = ToxFile::STOPPED;
emit fileTransferCancelled(file->friendId, file->fileNum, ToxFile::RECEIVING);
emit fileTransferCancelled(*file);
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0);
removeFileFromQueue(true, friendId, fileNum);
}
@ -959,7 +958,7 @@ void Core::rejectFileRecvRequest(int friendId, int fileNum)
return;
}
file->status = ToxFile::STOPPED;
emit fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
emit fileTransferCancelled(*file);
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0);
removeFileFromQueue(false, friendId, fileNum);
}
@ -1557,14 +1556,14 @@ void Core::sendAllFileData(Core *core, ToxFile* file)
file->sendTimer = nullptr;
return;
}
emit core->fileTransferInfo(file->friendId, file->fileNum, file->filesize, file->bytesSent, ToxFile::SENDING);
emit core->fileTransferInfo(*file);
// qApp->processEvents();
long long chunkSize = tox_file_data_size(core->tox, file->friendId);
if (chunkSize == -1)
{
qWarning("Core::fileHeartbeat: Error getting preffered chunk size, aborting file send");
file->status = ToxFile::STOPPED;
emit core->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
emit core->fileTransferCancelled(*file);
tox_file_send_control(core->tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0);
removeFileFromQueue(true, file->friendId, file->fileNum);
return;
@ -1579,7 +1578,7 @@ void Core::sendAllFileData(Core *core, ToxFile* file)
qWarning() << QString("Core::sendAllFileData: Error reading from file: %1").arg(file->file->errorString());
delete[] data;
file->status = ToxFile::STOPPED;
emit core->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
emit core->fileTransferCancelled(*file);
tox_file_send_control(core->tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0);
removeFileFromQueue(true, file->friendId, file->fileNum);
return;
@ -1589,7 +1588,7 @@ void Core::sendAllFileData(Core *core, ToxFile* file)
qWarning() << QString("Core::sendAllFileData: Nothing to read from file: %1").arg(file->file->errorString());
delete[] data;
file->status = ToxFile::STOPPED;
emit core->fileTransferCancelled(file->friendId, file->fileNum, ToxFile::SENDING);
emit core->fileTransferCancelled(*file);
tox_file_send_control(core->tox, file->friendId, 0, file->fileNum, TOX_FILECONTROL_KILL, nullptr, 0);
removeFileFromQueue(true, file->friendId, file->fileNum);
return;

View File

@ -173,12 +173,12 @@ signals:
void fileSendStarted(ToxFile file);
void fileReceiveRequested(ToxFile file);
void fileTransferAccepted(ToxFile file);
void fileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferCancelled(ToxFile file);
void fileTransferFinished(ToxFile file);
void fileUploadFinished(const QString& path);
void fileDownloadFinished(const QString& path);
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
void fileTransferPaused(ToxFile file);
void fileTransferInfo(ToxFile file);
void fileTransferRemotePausedUnpaused(ToxFile file, bool paused);
void fileTransferBrokenUnbroken(ToxFile file, bool broken);

View File

@ -12,6 +12,16 @@ ToxFile::ToxFile(int FileNum, int FriendId, QByteArray FileName, QString FilePat
{
}
bool ToxFile::operator==(const ToxFile &other) const
{
return fileNum == other.fileNum && friendId && other.friendId;
}
bool ToxFile::operator!=(const ToxFile &other) const
{
return !(*this == other);
}
void ToxFile::setFilePath(QString path)
{
filePath=path;

View File

@ -57,6 +57,10 @@ struct ToxFile
ToxFile()=default;
ToxFile(int FileNum, int FriendId, QByteArray FileName, QString FilePath, FileDirection Direction);
~ToxFile(){}
bool operator==(const ToxFile& other) const;
bool operator!=(const ToxFile& other) const;
void setFilePath(QString path);
bool open(bool write);
@ -65,8 +69,8 @@ struct ToxFile
QByteArray fileName;
QString filePath;
QFile* file;
long long bytesSent;
long long filesize;
qint64 bytesSent;
qint64 filesize;
FileStatus status;
FileDirection direction;
QTimer* sendTimer;

View File

@ -197,13 +197,13 @@ void ChatForm::onFileRecvRequest(ToxFile file)
FileTransferInstance* fileTrans = new FileTransferInstance(file);
ftransWidgets.insert(fileTrans->getId(), fileTrans);
connect(Core::getInstance(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
connect(Core::getInstance(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
connect(Core::getInstance(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished);
connect(Core::getInstance(), SIGNAL(fileTransferAccepted(ToxFile)), fileTrans, SLOT(onFileTransferAccepted(ToxFile)));
connect(Core::getInstance(), SIGNAL(fileTransferPaused(int,int,ToxFile::FileDirection)), fileTrans, SLOT(onFileTransferPaused(int,int,ToxFile::FileDirection)));
connect(Core::getInstance(), SIGNAL(fileTransferRemotePausedUnpaused(ToxFile,bool)), fileTrans, SLOT(onFileTransferRemotePausedUnpaused(ToxFile,bool)));
connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool)));
// connect(Core::getInstance(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
// connect(Core::getInstance(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
// connect(Core::getInstance(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished);
// connect(Core::getInstance(), SIGNAL(fileTransferAccepted(ToxFile)), fileTrans, SLOT(onFileTransferAccepted(ToxFile)));
// connect(Core::getInstance(), SIGNAL(fileTransferPaused(int,int,ToxFile::FileDirection)), fileTrans, SLOT(onFileTransferPaused(int,int,ToxFile::FileDirection)));
// connect(Core::getInstance(), SIGNAL(fileTransferRemotePausedUnpaused(ToxFile,bool)), fileTrans, SLOT(onFileTransferRemotePausedUnpaused(ToxFile,bool)));
// connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool)));
Widget* w = Widget::getInstance();
if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B