1
0
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:
krepa098 2014-11-16 20:01:37 +01:00
parent 4ca45fd4f9
commit 1cf9fe3474
12 changed files with 187 additions and 81 deletions

View File

@ -94,6 +94,11 @@
<file>translations/fr.qm</file> <file>translations/fr.qm</file>
<file>translations/ru.qm</file> <file>translations/ru.qm</file>
<file>ui/fileTransferWidget/fileTransferWidget.css</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_away.png</file>
<file>ui/statusButton/dot_busy.png</file> <file>ui/statusButton/dot_busy.png</file>
<file>ui/statusButton/dot_idle.png</file> <file>ui/statusButton/dot_idle.png</file>

View File

@ -103,6 +103,17 @@ ChatMessage *ChatLog::addSystemMessage(const QString &msg, const QDateTime& time
return line; 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() void ChatLog::clearSelection()
{ {
if(selStartRow >= 0) if(selStartRow >= 0)

View File

@ -24,6 +24,7 @@ class QGraphicsScene;
class ChatLine; class ChatLine;
class ChatLineContent; class ChatLineContent;
class ChatMessage; class ChatMessage;
class ToxFile;
class ChatLog : public QGraphicsView class ChatLog : public QGraphicsView
{ {
@ -36,6 +37,7 @@ public:
ChatMessage* addChatMessage(const QString& sender, const QString& msg, bool self); ChatMessage* addChatMessage(const QString& sender, const QString& msg, bool self);
ChatMessage* addSystemMessage(const QString& msg, const QDateTime& timestamp); ChatMessage* addSystemMessage(const QString& msg, const QDateTime& timestamp);
ChatMessage* addFileTransferMessage(const QString& sender, const ToxFile& file, const QDateTime &timestamp, bool self);
void insertChatline(ChatLine* l); void insertChatline(ChatLine* l);

View File

@ -17,15 +17,23 @@
#include "filetransferwidget.h" #include "filetransferwidget.h"
#include "ui_filetransferwidget.h" #include "ui_filetransferwidget.h"
#include "src/core.h"
#include <QMouseEvent> #include <QMouseEvent>
#include <QDebug> #include <QDebug>
FileTransferWidget::FileTransferWidget(QWidget *parent) : FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
QWidget(parent), : QWidget(parent)
ui(new Ui::FileTransferWidget) , ui(new Ui::FileTransferWidget)
, fileInfo(file)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->filenameLabel->setText(file.fileName);
ui->progressBar->setValue(0);
connect(Core::getInstance(), &Core::fileTransferInfo, this, &FileTransferWidget::onFileTransferInfo);
setFixedHeight(100); setFixedHeight(100);
} }
@ -34,17 +42,12 @@ FileTransferWidget::~FileTransferWidget()
delete ui; 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() // update progress
{ qreal progress = static_cast<qreal>(Filesize)/static_cast<qreal>(BytesSent);
qDebug() << "Button Resume Clicked"; ui->progressBar->setValue(static_cast<int>(progress * 100.0));
}
void FileTransferWidget::on_pushButton_2_pressed()
{
qDebug() << "Button Resume Clicked";
} }

View File

@ -19,6 +19,7 @@
#include <QWidget> #include <QWidget>
#include "../chatlinecontent.h" #include "../chatlinecontent.h"
#include "../../corestructs.h"
namespace Ui { namespace Ui {
class FileTransferWidget; class FileTransferWidget;
@ -29,16 +30,15 @@ class FileTransferWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit FileTransferWidget(QWidget *parent = 0); explicit FileTransferWidget(QWidget *parent, ToxFile file);
virtual ~FileTransferWidget(); virtual ~FileTransferWidget();
protected slots:
void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection direction);
private: private:
Ui::FileTransferWidget *ui; Ui::FileTransferWidget *ui;
ToxFile fileInfo;
private slots:
void on_pushButton_2_clicked();
void on_pushButton_clicked();
void on_pushButton_2_pressed();
}; };

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>729</width> <width>619</width>
<height>124</height> <height>86</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -19,99 +19,181 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color:transparent;</string> <string notr="true">background-color:transparent;</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QFrame" name="frame"> <widget class="QFrame" name="frame_3">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QFrame { <string notr="true">QFrame {
border-radius:10; border-image: url(:/ui/fileTransferInstance/background_red.png);
background-color:green; 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>
</property> </property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Plain</enum>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="filenameLabel">
<property name="styleSheet">
<string notr="true">color:white;</string>
</property>
<property name="text"> <property name="text">
<string>SomeRandomFile.7z</string> <string>Filename</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="styleSheet"> <item>
<string notr="true">color:white;</string> <widget class="QLabel" name="label">
</property> <property name="text">
<property name="text"> <string>10Mb</string>
<string>142/1742 YiB</string> </property>
</property> <property name="alignment">
</widget> <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>
</item> </item>
<item> <item>
<widget class="QProgressBar" name="progressBar"> <widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>14</height>
</size>
</property>
<property name="styleSheet"> <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>
<property name="value"> <property name="value">
<number>24</number> <number>24</number>
</property> </property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="format">
<string/>
</property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item> <item>
<widget class="QPushButton" name="pushButton_2"> <widget class="QPushButton" name="pushButton">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <string/>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </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> <size>
<width>50</width> <width>25</width>
<height>50</height> <height>28</height>
</size> </size>
</property> </property>
<property name="styleSheet"> <property name="flat">
<string notr="true">background-color:red;</string> <bool>true</bool>
</property>
<property name="text">
<string>Cancel</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <spacer name="verticalSpacer">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <enum>Qt::Vertical</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="maximumSize"> <property name="sizeHint" stdset="0">
<size> <size>
<width>50</width> <width>20</width>
<height>50</height> <height>40</height>
</size> </size>
</property> </property>
<property name="styleSheet"> </spacer>
<string notr="true">background-color:rgb(0, 255, 0);</string> </item>
</property> <item>
<widget class="QPushButton" name="pushButton_2">
<property name="text"> <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> </property>
</widget> </widget>
</item> </item>
@ -122,6 +204,8 @@ background-color:green;
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../../../res.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -164,16 +164,18 @@ void ChatForm::startFileSend(ToxFile file)
if (file.friendId != f->getFriendID()) if (file.friendId != f->getFriendID())
return; return;
FileTransferInstance* fileTrans = new FileTransferInstance(file); FileTransferInstance* fileTrans = new FileTransferInstance(file);
ftransWidgets.insert(fileTrans->getId(), fileTrans); ftransWidgets.insert(fileTrans->getId(), fileTrans);
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(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(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(fileTransferRemotePausedUnpaused(ToxFile,bool)), fileTrans, SLOT(onFileTransferRemotePausedUnpaused(ToxFile,bool)));
connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool))); // connect(Core::getInstance(), SIGNAL(fileTransferBrokenUnbroken(ToxFile, bool)), fileTrans, SLOT(onFileTransferBrokenUnbroken(ToxFile, bool)));
QString name; QString name;
if (!previousId.isMine()) if (!previousId.isMine())
@ -183,9 +185,8 @@ void ChatForm::startFileSend(ToxFile file)
previousId = core->getSelfId(); previousId = core->getSelfId();
} }
//TODO:
// chatWidget->insertMessage(ChatActionPtr(new FileTransferAction(fileTrans, getElidedName(name), chatWidget->addFileTransferMessage(name, file, QDateTime::currentDateTime(), true);
// QTime::currentTime().toString("hh:mm"), true)));
} }
void ChatForm::onFileRecvRequest(ToxFile file) void ChatForm::onFileRecvRequest(ToxFile file)

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B