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

95 lines
2.6 KiB
C
Raw Normal View History

2014-11-16 19:58:43 +08:00
/*
Copyright © 2014-2019 by The qTox Project Contributors
2014-11-16 19:58:43 +08:00
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre software: you can redistribute it and/or modify
2014-11-16 19:58:43 +08:00
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.
qTox is distributed in the hope that it will be useful,
2014-11-16 19:58:43 +08:00
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2014-11-16 19:58:43 +08:00
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
2014-11-16 19:58:43 +08:00
*/
#pragma once
2014-11-12 21:11:25 +08:00
2014-11-17 23:05:14 +08:00
#include <QTime>
#include <QWidget>
2015-02-05 00:21:56 +08:00
#include "src/chatlog/chatlinecontent.h"
#include "src/core/toxfile.h"
2014-11-12 21:11:25 +08:00
class CoreFile;
2015-01-18 01:17:40 +08:00
2014-11-12 21:11:25 +08:00
namespace Ui {
class FileTransferWidget;
}
class QVariantAnimation;
2014-11-17 23:05:14 +08:00
class QPushButton;
class FileTransferWidget : public QWidget
2014-11-12 21:11:25 +08:00
{
Q_OBJECT
public:
explicit FileTransferWidget(QWidget* parent, CoreFile& _coreFile, ToxFile file);
2014-11-12 21:11:25 +08:00
virtual ~FileTransferWidget();
bool isActive() const;
2019-05-23 01:48:23 +08:00
static QString getHumanReadableSize(qint64 size);
2014-12-14 04:11:03 +08:00
refactor(chatform): Remove message handling logic from gui path Functional changes * Offline messages are still sent when the chat log is cleared * Spinner now does not wait for history to be complete, just a receipt from our friend * Export chat and load chat history are now available in group chats * Merged save chat log and export chat log * Note that we lost the info messages in the process NonFunctional Changes * FileTransferWidget slots only called for correct file * Settings::getEnableGroupChatsColor now embedded in GenericChatForm::colorizeNames * Settings::setEnableGroupChatscolor now emits signal connected to GenericChatForm::setColorizedNames to keep state in sync * Chatlog history not reloaded on setPassword() * I am pretty sure this had no purpose * Removed a lot of responsibility from ChatForm * History moved to ChatHistory implementation of IChatLog * OfflineMsgEngine moved to FriendMessageDispatcher * Export chat and load chat history moved to GenericChatLog * Backed by IChatLog so can be used generically * Message processing moved to FriendMessageDispatcher * The action of sending files to coreFile is still handled by ChatForm, but displaying of the sent messages is done through IChatLog -> GenericChatForm * Search moved to ChatHistory/SessionChatLog * All insertion of chat log elements should be handled by GenericChatForm now * Removed overlapping responsibilities from GroupChatForm * Search and message sending goes through ichatlog/messagedispatcher too * Lots of search functionality pushed down into IChatLog * Some of the file logic was moved into Widget. This is mostly to avoid scope increase of this PR even further. * History APIs removed that were no longer used
2019-05-26 08:11:44 +08:00
void onFileTransferUpdate(ToxFile file);
2014-11-17 23:05:14 +08:00
protected:
void updateWidgetColor(ToxFile const& file);
void updateWidgetText(ToxFile const& file);
void updateFileProgress(ToxFile const& file);
void updateSignals(ToxFile const& file);
void updatePreview(ToxFile const& file);
void setupButtons(ToxFile const& file);
2014-11-17 23:05:14 +08:00
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);
2015-02-14 19:14:09 +08:00
void setBackgroundColor(const QColor& c, bool whiteFont);
void setButtonColor(const QColor& c);
2015-01-11 18:57:33 +08:00
2015-02-14 19:14:09 +08:00
bool drawButtonAreaNeeded() const;
2014-11-17 23:05:14 +08:00
void paintEvent(QPaintEvent*) final;
public slots:
void reloadTheme();
2014-11-17 23:05:14 +08:00
private slots:
void onLeftButtonClicked();
void onRightButtonClicked();
void onPreviewButtonClicked();
2014-11-17 03:01:37 +08:00
private:
static bool tryRemoveFile(const QString &filepath);
void updateWidget(ToxFile const& file);
void updateBackgroundColor(const ToxFile::FileStatus status);
2014-11-12 21:11:25 +08:00
private:
CoreFile& coreFile;
Ui::FileTransferWidget* ui;
2014-11-17 03:01:37 +08:00
ToxFile fileInfo;
2015-02-13 23:46:59 +08:00
QVariantAnimation* backgroundColorAnimation = nullptr;
2015-02-14 19:14:09 +08:00
QVariantAnimation* buttonColorAnimation = nullptr;
2015-02-13 23:46:59 +08:00
QColor backgroundColor;
QColor buttonColor;
QColor buttonBackgroundColor;
2014-11-12 21:11:25 +08:00
bool active;
QTime lastTransmissionUpdate;
ToxFile::FileStatus lastStatus = ToxFile::INITIALIZING;
2014-11-12 21:11:25 +08:00
};