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

86 lines
2.4 KiB
C
Raw Normal View History

2014-11-16 12:58:43 +01: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 14:11:25 +01:00
#ifndef FILETRANSFERWIDGET_H
#define FILETRANSFERWIDGET_H
#include <QWidget>
2014-11-17 16:05:14 +01:00
#include <QTime>
2015-02-04 17:21:56 +01:00
#include "src/chatlog/chatlinecontent.h"
#include "src/core/corestructs.h"
2014-11-12 14:11:25 +01:00
2015-01-17 18:17:40 +01:00
2014-11-12 14:11:25 +01:00
namespace Ui {
class FileTransferWidget;
}
class QVariantAnimation;
2014-11-17 16:05:14 +01:00
class QPushButton;
2014-11-12 14:11:25 +01:00
class FileTransferWidget : public QWidget
{
Q_OBJECT
public:
2014-11-16 20:01:37 +01:00
explicit FileTransferWidget(QWidget *parent, ToxFile file);
2014-11-12 14:11:25 +01:00
virtual ~FileTransferWidget();
2015-01-11 11:57:33 +01:00
void autoAcceptTransfer(const QString& path);
2014-12-13 21:11:03 +01:00
2014-11-16 20:01:37 +01:00
protected slots:
2014-11-17 16:05:14 +01:00
void onFileTransferInfo(ToxFile file);
void onFileTransferAccepted(ToxFile file);
void onFileTransferCancelled(ToxFile file);
void onFileTransferPaused(ToxFile file);
void onFileTransferResumed(ToxFile file);
2014-11-17 16:05:14 +01:00
void onFileTransferFinished(ToxFile file);
void fileTransferRemotePausedUnpaused(ToxFile file, bool paused);
2014-11-17 16:05:14 +01:00
protected:
QString getHumanReadableSize(qint64 size);
void hideWidgets();
void setupButtons();
void handleButton(QPushButton* btn);
2014-11-17 20:08:55 +01:00
void showPreview(const QString& filename);
2015-01-11 11:57:33 +01:00
void acceptTransfer(const QString& filepath);
2015-02-14 12:14:09 +01:00
void setBackgroundColor(const QColor& c, bool whiteFont);
void setButtonColor(const QColor& c);
2015-01-11 11:57:33 +01:00
2015-02-14 12:14:09 +01:00
bool drawButtonAreaNeeded() const;
2014-11-17 16:05:14 +01:00
virtual void paintEvent(QPaintEvent*);
2014-11-17 16:05:14 +01:00
private slots:
void on_topButton_clicked();
void on_bottomButton_clicked();
2014-11-16 20:01:37 +01:00
2014-11-12 14:11:25 +01:00
private:
Ui::FileTransferWidget *ui;
2014-11-16 20:01:37 +01:00
ToxFile fileInfo;
2014-11-17 16:05:14 +01:00
QTime lastTick;
quint64 lastBytesSent = 0;
2015-02-13 16:46:59 +01:00
QVariantAnimation* backgroundColorAnimation = nullptr;
2015-02-14 12:14:09 +01:00
QVariantAnimation* buttonColorAnimation = nullptr;
2015-02-13 16:46:59 +01:00
QColor backgroundColor;
QColor buttonColor;
2014-11-12 14:11:25 +01:00
2015-01-18 13:57:51 -06: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 14:11:25 +01:00
};
#endif // FILETRANSFERWIDGET_H