mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
filetransfer: corrected pause/resume behaviour
This commit is contained in:
parent
6440ef8310
commit
6c5cd7c010
8
core.cpp
8
core.cpp
|
@ -393,6 +393,14 @@ void Core::onFileControlCallback(Tox* tox, int32_t friendnumber, uint8_t receive
|
||||||
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_FINISHED, nullptr, 0);
|
tox_file_send_control(tox, file->friendId, 1, file->fileNum, TOX_FILECONTROL_FINISHED, nullptr, 0);
|
||||||
removeFileFromQueue((bool)receive_send, file->friendId, file->fileNum);
|
removeFileFromQueue((bool)receive_send, file->friendId, file->fileNum);
|
||||||
}
|
}
|
||||||
|
else if (receive_send == 0 && control_type == TOX_FILECONTROL_ACCEPT)
|
||||||
|
{
|
||||||
|
emit static_cast<Core*>(core)->fileTransferRemotePausedUnpaused(*file, false);
|
||||||
|
}
|
||||||
|
else if ((receive_send == 0 || receive_send == 1) && control_type == TOX_FILECONTROL_PAUSE)
|
||||||
|
{
|
||||||
|
emit static_cast<Core*>(core)->fileTransferRemotePausedUnpaused(*file, true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << QString("Core: File control callback, receive_send=%1, control_type=%2")
|
qDebug() << QString("Core: File control callback, receive_send=%1, control_type=%2")
|
||||||
|
|
1
core.h
1
core.h
|
@ -146,6 +146,7 @@ signals:
|
||||||
void fileDownloadFinished(const QString& path);
|
void fileDownloadFinished(const QString& path);
|
||||||
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
|
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 fileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
|
||||||
|
void fileTransferRemotePausedUnpaused(ToxFile file, bool paused);
|
||||||
|
|
||||||
void avInvite(int friendId, int callIndex, bool video);
|
void avInvite(int friendId, int callIndex, bool video);
|
||||||
void avStart(int friendId, int callIndex, bool video);
|
void avStart(int friendId, int callIndex, bool video);
|
||||||
|
|
|
@ -30,6 +30,7 @@ FileTransferInstance::FileTransferInstance(ToxFile File)
|
||||||
{
|
{
|
||||||
id = Idconter++;
|
id = Idconter++;
|
||||||
state = tsPending;
|
state = tsPending;
|
||||||
|
remotePaused = false;
|
||||||
|
|
||||||
filename = File.fileName;
|
filename = File.fileName;
|
||||||
size = getHumanReadableSize(File.filesize);
|
size = getHumanReadableSize(File.filesize);
|
||||||
|
@ -61,7 +62,7 @@ void FileTransferInstance::onFileTransferInfo(int FriendId, int FileNum, int64_t
|
||||||
if (FileNum != fileNum || FriendId != friendId || Direction != direction)
|
if (FileNum != fileNum || FriendId != friendId || Direction != direction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
state = tsProcessing;
|
// state = tsProcessing;
|
||||||
QDateTime newtime = QDateTime::currentDateTime();
|
QDateTime newtime = QDateTime::currentDateTime();
|
||||||
int timediff = lastUpdate.secsTo(newtime);
|
int timediff = lastUpdate.secsTo(newtime);
|
||||||
if (timediff <= 0)
|
if (timediff <= 0)
|
||||||
|
@ -121,6 +122,37 @@ void FileTransferInstance::onFileTransferFinished(ToxFile File)
|
||||||
emit stateUpdated();
|
emit stateUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileTransferInstance::onFileTransferAccepted(ToxFile File)
|
||||||
|
{
|
||||||
|
if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
remotePaused = false;
|
||||||
|
state = tsProcessing;
|
||||||
|
|
||||||
|
emit stateUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileTransferInstance::onFileTransferRemotePausedUnpaused(ToxFile File, bool paused)
|
||||||
|
{
|
||||||
|
if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
remotePaused = paused;
|
||||||
|
|
||||||
|
emit stateUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileTransferInstance::onFileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection Direction)
|
||||||
|
{
|
||||||
|
if (FileNum != fileNum || FriendId != friendId || Direction != direction)
|
||||||
|
return;
|
||||||
|
|
||||||
|
state = tsPaused;
|
||||||
|
|
||||||
|
emit stateUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
void FileTransferInstance::cancelTransfer()
|
void FileTransferInstance::cancelTransfer()
|
||||||
{
|
{
|
||||||
Core::getInstance()->cancelFileSend(friendId, fileNum);
|
Core::getInstance()->cancelFileSend(friendId, fileNum);
|
||||||
|
@ -181,19 +213,33 @@ void FileTransferInstance::acceptRecvRequest()
|
||||||
|
|
||||||
void FileTransferInstance::pauseResumeRecv()
|
void FileTransferInstance::pauseResumeRecv()
|
||||||
{
|
{
|
||||||
|
if (!(state == tsProcessing || state == tsPaused))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (remotePaused)
|
||||||
|
return;
|
||||||
|
|
||||||
Core::getInstance()->pauseResumeFileRecv(friendId, fileNum);
|
Core::getInstance()->pauseResumeFileRecv(friendId, fileNum);
|
||||||
if (state == tsProcessing)
|
// if (state == tsProcessing)
|
||||||
state = tsPaused;
|
// state = tsPaused;
|
||||||
else state = tsProcessing;
|
// else state = tsProcessing;
|
||||||
|
|
||||||
emit stateUpdated();
|
emit stateUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTransferInstance::pauseResumeSend()
|
void FileTransferInstance::pauseResumeSend()
|
||||||
{
|
{
|
||||||
|
if (!(state == tsProcessing || state == tsPaused))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (remotePaused)
|
||||||
|
return;
|
||||||
|
|
||||||
Core::getInstance()->pauseResumeFileSend(friendId, fileNum);
|
Core::getInstance()->pauseResumeFileSend(friendId, fileNum);
|
||||||
if (state == tsProcessing)
|
// if (state == tsProcessing)
|
||||||
state = tsPaused;
|
// state = tsPaused;
|
||||||
else state = tsProcessing;
|
// else state = tsProcessing;
|
||||||
|
|
||||||
emit stateUpdated();
|
emit stateUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +266,15 @@ QString FileTransferInstance::getHtmlImage()
|
||||||
else if (state == tsPaused)
|
else if (state == tsPaused)
|
||||||
rightBtnImg = QImage(":/ui/fileTransferInstance/resumeFileButton.png");
|
rightBtnImg = QImage(":/ui/fileTransferInstance/resumeFileButton.png");
|
||||||
else
|
else
|
||||||
rightBtnImg = QImage(":/ui/fileTransferInstance/acceptFileButton.png");
|
{
|
||||||
|
if (direction == ToxFile::SENDING)
|
||||||
|
rightBtnImg = QImage(":/ui/fileTransferInstance/pauseGreyFileButton.png");
|
||||||
|
else
|
||||||
|
rightBtnImg = QImage(":/ui/fileTransferInstance/acceptFileButton.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remotePaused)
|
||||||
|
rightBtnImg = QImage(":/ui/fileTransferInstance/pauseGreyFileButton.png");
|
||||||
|
|
||||||
res = draw2ButtonsForm("silver", leftBtnImg, rightBtnImg);
|
res = draw2ButtonsForm("silver", leftBtnImg, rightBtnImg);
|
||||||
} else if (state == tsCanceled)
|
} else if (state == tsCanceled)
|
||||||
|
|
|
@ -40,6 +40,9 @@ public slots:
|
||||||
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction);
|
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction);
|
||||||
void onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction);
|
void onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction);
|
||||||
void onFileTransferFinished(ToxFile File);
|
void onFileTransferFinished(ToxFile File);
|
||||||
|
void onFileTransferAccepted(ToxFile File);
|
||||||
|
void onFileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection Direction);
|
||||||
|
void onFileTransferRemotePausedUnpaused(ToxFile File, bool paused);
|
||||||
void pressFromHtml(QString);
|
void pressFromHtml(QString);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -65,6 +68,7 @@ private:
|
||||||
uint id;
|
uint id;
|
||||||
|
|
||||||
TransfState state;
|
TransfState state;
|
||||||
|
bool remotePaused;
|
||||||
QImage pic;
|
QImage pic;
|
||||||
QString filename, size, speed, eta;
|
QString filename, size, speed, eta;
|
||||||
QDateTime lastUpdate;
|
QDateTime lastUpdate;
|
||||||
|
|
1
res.qrc
1
res.qrc
|
@ -127,6 +127,7 @@
|
||||||
<file>ui/volButton/volButton.css</file>
|
<file>ui/volButton/volButton.css</file>
|
||||||
<file>ui/fileTransferInstance/acceptFileButton.png</file>
|
<file>ui/fileTransferInstance/acceptFileButton.png</file>
|
||||||
<file>ui/fileTransferInstance/pauseFileButton.png</file>
|
<file>ui/fileTransferInstance/pauseFileButton.png</file>
|
||||||
|
<file>ui/fileTransferInstance/pauseGreyFileButton.png</file>
|
||||||
<file>ui/fileTransferInstance/resumeFileButton.png</file>
|
<file>ui/fileTransferInstance/resumeFileButton.png</file>
|
||||||
<file>ui/fileTransferInstance/stopFileButton.png</file>
|
<file>ui/fileTransferInstance/stopFileButton.png</file>
|
||||||
<file>ui/fileTransferInstance/emptyLGreenFileButton.png</file>
|
<file>ui/fileTransferInstance/emptyLGreenFileButton.png</file>
|
||||||
|
|
BIN
ui/fileTransferInstance/pauseGreyFileButton.png
Normal file
BIN
ui/fileTransferInstance/pauseGreyFileButton.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 B |
Binary file not shown.
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 403 B |
|
@ -108,6 +108,9 @@ void ChatForm::startFileSend(ToxFile file)
|
||||||
connect(Core::getInstance(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
|
connect(Core::getInstance(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
|
||||||
connect(Core::getInstance(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
|
connect(Core::getInstance(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
|
||||||
connect(Core::getInstance(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished);
|
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)));
|
||||||
|
|
||||||
QString name = Widget::getInstance()->getUsername();
|
QString name = Widget::getInstance()->getUsername();
|
||||||
if (name == previousName)
|
if (name == previousName)
|
||||||
|
@ -128,6 +131,9 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
||||||
connect(Core::getInstance(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
|
connect(Core::getInstance(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
|
||||||
connect(Core::getInstance(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
|
connect(Core::getInstance(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
|
||||||
connect(Core::getInstance(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished);
|
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)));
|
||||||
|
|
||||||
Widget* w = Widget::getInstance();
|
Widget* w = Widget::getInstance();
|
||||||
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())
|
if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user