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

Initial commit for activating the file transfer button

It compiles, but is in fact untested (and requires one small new icon)
This commit is contained in:
Bill Winslow 2014-07-11 12:05:18 -04:00
parent e87b8e6cc7
commit 26f2f143fa
8 changed files with 161 additions and 4 deletions

View File

@ -50,6 +50,7 @@ Core::Core(Camera* cam, QThread *coreThread) :
//connect(fileTimer, &QTimer::timeout, this, &Core::fileHeartbeat);
connect(bootstrapTimer, &QTimer::timeout, this, &Core::onBootstrapTimer);
connect(&Settings::getInstance(), &Settings::dhtServerListChanged, this, &Core::bootstrapDht);
connect(this, SIGNAL(fileTransferFinished(ToxFile)), this, SLOT(onFileTransferFinished(ToxFile)));
for (int i=0; i<TOXAV_MAX_CALLS;i++)
{
@ -612,6 +613,14 @@ void Core::setStatus(Status status)
}
}
void Core::onFileTransferFinished(ToxFile file)
{
if (file.direction == file.SENDING)
emit fileUploadFinished(QString(file.fileName));
else
emit fileDownloadFinished(QString(file.fileName));
}
void Core::bootstrapDht()
{
qDebug() << "Core: Bootstraping DHT";

5
core.h
View File

@ -207,6 +207,8 @@ signals:
void fileTransferAccepted(ToxFile file);
void fileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferFinished(ToxFile file);
void fileUploadFinished(const QString& path);
void fileDownloadFinished(const QString& path);
void fileTransferPaused(int FriendId, int FileNum, ToxFile::FileDirection direction);
void fileTransferInfo(int FriendId, int FileNum, int Filesize, int BytesSent, ToxFile::FileDirection direction);
@ -270,6 +272,9 @@ private:
void checkLastOnline(int friendId);
private slots:
void onFileTransferFinished(ToxFile file);
private:
Tox* tox;
ToxAv* toxav;

View File

@ -23,7 +23,7 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setApplicationName("Toxgui");
a.setApplicationName("qTox");
a.setOrganizationName("Tox");
// Load translations

View File

@ -63,6 +63,7 @@ HEADERS += widget/form/addfriendform.h \
widget/form/chatform.h \
widget/form/groupchatform.h \
widget/form/settingsform.h \
widget/form/filesform.h \
widget/tool/chattextedit.h \
widget/tool/copyableelidelabel.h \
widget/tool/editablelabelwidget.h \
@ -93,6 +94,7 @@ SOURCES += \
widget/form/chatform.cpp \
widget/form/groupchatform.cpp \
widget/form/settingsform.cpp \
widget/form/filesform.cpp \
widget/tool/chattextedit.cpp \
widget/tool/copyableelidelabel.cpp \
widget/tool/editablelabelwidget.cpp \

72
widget/form/filesform.cpp Normal file
View File

@ -0,0 +1,72 @@
/*
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.
*/
#include "filesform.h"
FilesForm::FilesForm()
: QObject()
{
head = new QWidget();
QFont bold;
bold.setBold(true);
headLabel.setText(tr("Transfered Files","\"Headline\" of the window"));
headLabel.setFont(bold);
head->setLayout(&headLayout);
headLayout.addWidget(&headLabel);
main.addTab(&recvd, tr("Downloads"));
main.addTab(&sent, tr("Uploads"));
//these need to go in widget.cpp (I think, not really sure atm)
//connect(something, SIGNAL(DOWNLOAD_DONE), this, SLOT(onFileDownloadComplete()));
//connect(something, SIGNAL(DOWNLOAD_DONE), this, SLOT(onFileUploadComplete()));
connect(&sent, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
}
FilesForm::~FilesForm()
{
//delete head;
// having this line caused a SIGABRT because free() received an invalid pointer
// but since this is only called on program shutdown anyways,
// I'm not too bummed about removing it
}
void FilesForm::show(Ui::Widget& ui)
{
ui.mainContent->layout()->addWidget(&main);
ui.mainHead->layout()->addWidget(head);
main.show();
head->show();
}
void FilesForm::onFileDownloadComplete(const QString& path)
{
QListWidgetItem* tmp = new QListWidgetItem(/*QIcon("checkmark.png"),*/path);
recvd.addItem(tmp);
}
void FilesForm::onFileUploadComplete(const QString& path)
{
QListWidgetItem* tmp = new QListWidgetItem(/*QIcon("checkmark.png"),*/path);
sent.addItem(tmp);
}
void FilesForm::onFileActivated(QListWidgetItem* item)
{
QDesktopServices::openUrl(QUrl::fromLocalFile(item->text()));
}

62
widget/form/filesform.h Normal file
View File

@ -0,0 +1,62 @@
/*
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.
*/
#ifndef FILESFORM_H
#define FILESFORM_H
#include "ui_widget.h"
#include <QListWidget>
#include <QTabWidget>
#include <QString>
#include <QDesktopServices>
#include <QLabel>
#include <QVBoxLayout>
#include <QUrl>
class FilesForm : public QObject
{
Q_OBJECT
public:
FilesForm();
~FilesForm();
void show(Ui::Widget& ui);
public slots:
void onFileDownloadComplete(const QString& path);
void onFileUploadComplete(const QString& path);
private slots:
void onFileActivated(QListWidgetItem* item);
private:
QWidget *head;
QLabel headLabel;
QVBoxLayout headLayout;
/* If we really do go whole hog with listing in progress transers,
I should really look into the new fangled list thingy, to deactivate
specific items in the list */
QTabWidget main;
QListWidget sent, recvd;
};
#include "ui_widget.h"
#endif // FILESFORM_H

View File

@ -215,6 +215,8 @@ Widget::Widget(QWidget *parent) :
connect(core, &Core::usernameSet, this, &Widget::setUsername);
connect(core, &Core::statusMessageSet, this, &Widget::setStatusMessage);
connect(core, &Core::friendAddressGenerated, &settingsForm, &SettingsForm::setFriendAddress);
connect(core, SIGNAL(Core::fileDownloadFinished(QString&)), &filesForm, SLOT(FilesForm::onFileDownloadComplete(QString&)));
connect(core, SIGNAL(Core::fileUploadFinished(QString&)), &filesForm, SLOT(FilesForm::onFileUploadComplete(QString&)));
connect(core, &Core::friendAdded, this, &Widget::addFriend);
connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed);
connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged);
@ -377,7 +379,10 @@ void Widget::onGroupClicked()
void Widget::onTransferClicked()
{
hideMainForms();
filesForm.show(*ui);
isFriendWidgetActive = 0;
isGroupWidgetActive = 0;
}
void Widget::onSettingsClicked()

View File

@ -25,6 +25,7 @@
#include "core.h"
#include "widget/form/addfriendform.h"
#include "widget/form/settingsform.h"
#include "widget/form/filesform.h"
#include "camera.h"
#define PIXELS_TO_ACT 7
@ -34,8 +35,8 @@ class Widget;
}
class GroupWidget;
class AddFriendForm;
class SettingsForm;
//class AddFriendForm;
//class SettingsForm;
struct FriendWidget;
class Group;
struct Friend;
@ -144,6 +145,7 @@ private:
QThread* coreThread;
AddFriendForm friendForm;
SettingsForm settingsForm;
FilesForm filesForm;
static Widget* instance;
FriendWidget* activeFriendWidget;
GroupWidget* activeGroupWidget;