mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
filetransferwidget: first steps
This commit is contained in:
parent
4ca45fd4f9
commit
1cf9fe3474
5
res.qrc
5
res.qrc
|
@ -94,6 +94,11 @@
|
|||
<file>translations/fr.qm</file>
|
||||
<file>translations/ru.qm</file>
|
||||
<file>ui/fileTransferWidget/fileTransferWidget.css</file>
|
||||
<file>ui/fileTransferInstance/background_red.png</file>
|
||||
<file>ui/fileTransferInstance/pause_2x.png</file>
|
||||
<file>ui/fileTransferInstance/no_2x.png</file>
|
||||
<file>ui/fileTransferInstance/yes_2x.png</file>
|
||||
<file>ui/fileTransferInstance/arrow_white_2x.png</file>
|
||||
<file>ui/statusButton/dot_away.png</file>
|
||||
<file>ui/statusButton/dot_busy.png</file>
|
||||
<file>ui/statusButton/dot_idle.png</file>
|
||||
|
|
|
@ -103,6 +103,17 @@ ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& time
|
|||
return line;
|
||||
}
|
||||
|
||||
ChatMessage *ChatLog::addFileTransferMessage(const QString &sender, const ToxFile &file, const QDateTime& timestamp, bool self)
|
||||
{
|
||||
ChatMessage* line = new ChatMessage(scene, QString());
|
||||
line->addColumn(new Text(sender, self ? Style::getFont(Style::MediumBold) : Style::getFont(Style::Medium), true), ColumnFormat(75.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right));
|
||||
line->addColumn(new ChatLineContentProxy(new FileTransferWidget(0, file)), ColumnFormat(1.0, ColumnFormat::VariableSize));
|
||||
line->addColumn(new Text(timestamp.toString("hh:mm")), ColumnFormat(50.0, ColumnFormat::FixedSize, 1, ColumnFormat::Right));
|
||||
|
||||
insertChatline(line);
|
||||
return line;
|
||||
}
|
||||
|
||||
void ChatLog::clearSelection()
|
||||
{
|
||||
if(selStartRow >= 0)
|
||||
|
|
|
@ -24,6 +24,7 @@ class QGraphicsScene;
|
|||
class ChatLine;
|
||||
class ChatLineContent;
|
||||
class ChatMessage;
|
||||
class ToxFile;
|
||||
|
||||
class ChatLog : public QGraphicsView
|
||||
{
|
||||
|
@ -36,6 +37,7 @@ public:
|
|||
ChatMessage* addChatMessage(const QString& sender, const QString& msg, bool self);
|
||||
|
||||
ChatMessage* addSystemMessage(const QString& msg, const QDateTime& timestamp);
|
||||
ChatMessage* addFileTransferMessage(const QString& sender, const ToxFile& file, const QDateTime ×tamp, bool self);
|
||||
|
||||
void insertChatline(ChatLine* l);
|
||||
|
||||
|
|
|
@ -17,15 +17,23 @@
|
|||
#include "filetransferwidget.h"
|
||||
#include "ui_filetransferwidget.h"
|
||||
|
||||
#include "src/core.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
|
||||
FileTransferWidget::FileTransferWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FileTransferWidget)
|
||||
FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::FileTransferWidget)
|
||||
, fileInfo(file)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->filenameLabel->setText(file.fileName);
|
||||
ui->progressBar->setValue(0);
|
||||
|
||||
connect(Core::getInstance(), &Core::fileTransferInfo, this, &FileTransferWidget::onFileTransferInfo);
|
||||
|
||||
setFixedHeight(100);
|
||||
}
|
||||
|
||||
|
@ -34,17 +42,12 @@ FileTransferWidget::~FileTransferWidget()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void FileTransferWidget::on_pushButton_2_clicked()
|
||||
void FileTransferWidget::onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction)
|
||||
{
|
||||
qDebug() << "Button Cancel Clicked";
|
||||
}
|
||||
if(FileNum != fileInfo.fileNum)
|
||||
return;
|
||||
|
||||
void FileTransferWidget::on_pushButton_clicked()
|
||||
{
|
||||
qDebug() << "Button Resume Clicked";
|
||||
}
|
||||
|
||||
void FileTransferWidget::on_pushButton_2_pressed()
|
||||
{
|
||||
qDebug() << "Button Resume Clicked";
|
||||
// update progress
|
||||
qreal progress = static_cast<qreal>(Filesize)/static_cast<qreal>(BytesSent);
|
||||
ui->progressBar->setValue(static_cast<int>(progress * 100.0));
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include "../chatlinecontent.h"
|
||||
#include "../../corestructs.h"
|
||||
|
||||
namespace Ui {
|
||||
class FileTransferWidget;
|
||||
|
@ -29,16 +30,15 @@ class FileTransferWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileTransferWidget(QWidget *parent = 0);
|
||||
explicit FileTransferWidget(QWidget *parent, ToxFile file);
|
||||
virtual ~FileTransferWidget();
|
||||
|
||||
protected slots:
|
||||
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
|
||||
|
||||
private:
|
||||
Ui::FileTransferWidget *ui;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_2_clicked();
|
||||
void on_pushButton_clicked();
|
||||
void on_pushButton_2_pressed();
|
||||
ToxFile fileInfo;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>729</width>
|
||||
<height>124</height>
|
||||
<width>619</width>
|
||||
<height>86</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,99 +19,181 @@
|
|||
<property name="styleSheet">
|
||||
<string notr="true">background-color:transparent;</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame {
|
||||
border-radius:10;
|
||||
background-color:green;
|
||||
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>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:white;</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="filenameLabel">
|
||||
<property name="text">
|
||||
<string>SomeRandomFile.7z</string>
|
||||
<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="styleSheet">
|
||||
<string notr="true">color:white;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>142/1742 YiB</string>
|
||||
<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>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:white;</string>
|
||||
<string notr="true">QProgressBar {
|
||||
border: 2px solid black;
|
||||
border-radius: 0px;
|
||||
color: white;
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
QProgressBar::chunk {
|
||||
background-color: black;
|
||||
width: 20px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="format">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color:red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<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>50</width>
|
||||
<height>50</height>
|
||||
<width>25</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color:rgb(0, 255, 0);</string>
|
||||
<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>Resume</string>
|
||||
<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>
|
||||
|
@ -122,6 +204,8 @@ background-color:green;
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../../res.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -164,16 +164,18 @@ void ChatForm::startFileSend(ToxFile file)
|
|||
if (file.friendId != f->getFriendID())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
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)));
|
||||
|
||||
QString name;
|
||||
if (!previousId.isMine())
|
||||
|
@ -183,9 +185,8 @@ void ChatForm::startFileSend(ToxFile file)
|
|||
previousId = core->getSelfId();
|
||||
}
|
||||
|
||||
//TODO:
|
||||
// chatWidget->insertMessage(ChatActionPtr(new FileTransferAction(fileTrans, getElidedName(name),
|
||||
// QTime::currentTime().toString("hh:mm"), true)));
|
||||
|
||||
chatWidget->addFileTransferMessage(name, file, QDateTime::currentDateTime(), true);
|
||||
}
|
||||
|
||||
void ChatForm::onFileRecvRequest(ToxFile file)
|
||||
|
|
BIN
ui/fileTransferInstance/arrow_white_2x.png
Normal file
BIN
ui/fileTransferInstance/arrow_white_2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 214 B |
BIN
ui/fileTransferInstance/background_red.png
Normal file
BIN
ui/fileTransferInstance/background_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 493 B |
BIN
ui/fileTransferInstance/no_2x.png
Normal file
BIN
ui/fileTransferInstance/no_2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 265 B |
BIN
ui/fileTransferInstance/pause_2x.png
Normal file
BIN
ui/fileTransferInstance/pause_2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 B |
BIN
ui/fileTransferInstance/yes_2x.png
Normal file
BIN
ui/fileTransferInstance/yes_2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 267 B |
Loading…
Reference in New Issue
Block a user