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

74 lines
1.9 KiB
C
Raw Normal View History

2014-11-16 19:58:43 +08:00
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
This file is part of qTox, a Qt-based graphical interface for Tox.
This program is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
2014-11-12 21:11:25 +08:00
#ifndef FILETRANSFERWIDGET_H
#define FILETRANSFERWIDGET_H
#include <QWidget>
2014-11-17 23:05:14 +08:00
#include <QTime>
2014-11-12 21:11:25 +08:00
#include "../chatlinecontent.h"
2014-11-17 03:01:37 +08:00
#include "../../corestructs.h"
2014-11-12 21:11:25 +08:00
2015-01-18 01:17:40 +08:00
2014-11-12 21:11:25 +08:00
namespace Ui {
class FileTransferWidget;
}
2014-11-17 23:05:14 +08:00
class QPushButton;
2014-11-12 21:11:25 +08:00
class FileTransferWidget : public QWidget
{
Q_OBJECT
public:
2014-11-17 03:01:37 +08:00
explicit FileTransferWidget(QWidget *parent, ToxFile file);
2014-11-12 21:11:25 +08:00
virtual ~FileTransferWidget();
2015-01-11 18:57:33 +08:00
void autoAcceptTransfer(const QString& path);
2014-12-14 04:11:03 +08:00
2014-11-17 03:01:37 +08:00
protected slots:
2014-11-17 23:05:14 +08:00
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);
2014-11-18 03:08:55 +08:00
void showPreview(const QString& filename);
2015-01-11 18:57:33 +08:00
void acceptTransfer(const QString& filepath);
bool isFilePathWritable(const QString& filepath);
2014-11-17 23:05:14 +08:00
private slots:
void on_topButton_clicked();
void on_bottomButton_clicked();
2014-11-17 03:01:37 +08:00
2014-11-12 21:11:25 +08:00
private:
Ui::FileTransferWidget *ui;
2014-11-17 03:01:37 +08:00
ToxFile fileInfo;
2014-11-17 23:05:14 +08:00
QTime lastTick;
qint64 lastBytesSent = 0;
2014-11-12 21:11:25 +08:00
2015-01-19 03:57:51 +08:00
static const uint8_t TRANSFER_ROLLING_AVG_COUNT = 4;
uint8_t meanIndex = 0;
qreal meanData[TRANSFER_ROLLING_AVG_COUNT] = {0.0};
2014-11-12 21:11:25 +08:00
};
#endif // FILETRANSFERWIDGET_H