Commit cf1ddd35 authored by Rafał Malinowski's avatar Rafał Malinowski

file-transfer: dynamically react on canChange values

Signed-off-by: Rafał Malinowski's avatarRafał Przemysław Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent 4e0566e1
......@@ -55,10 +55,10 @@ SendFileAction::~SendFileAction()
void SendFileAction::actionInstanceCreated(Action *action)
{
auto account = action->context()->chat().chatAccount();
if (!account)
if (!account || !account.protocolHandler() || !account.protocolHandler()->fileTransferService())
return;
//
connect(account.protocolHandler()->fileTransferService(), SIGNAL(canSendChanged()), action, SLOT(checkState()));
}
void SendFileAction::triggered(QWidget* widget, ActionContext* context, bool toggled)
......@@ -77,6 +77,7 @@ void SendFileAction::triggered(QWidget* widget, ActionContext* context, bool tog
void SendFileAction::updateActionState(Action *action)
{
action->setEnabled(false);
action->setToolTip(text());
auto contacts = action->context()->contacts();
......@@ -95,7 +96,8 @@ void SendFileAction::updateActionState(Action *action)
auto canSend = account.protocolHandler()->fileTransferService()->canSend(contact);
if (!canSend.canSend())
{
action->setToolTip(canSend.reason());
if (!canSend.reason().isEmpty())
action->setToolTip(canSend.reason());
return;
}
}
......
......@@ -46,6 +46,7 @@ public:
virtual FileTransferCanSendResult canSend(Contact contact) = 0;
signals:
void canSendChanged();
void incomingFileTransfer(FileTransfer fileTransfer);
};
......
......@@ -44,6 +44,8 @@
GaduFileTransferService::GaduFileTransferService(GaduProtocol *protocol) :
FileTransferService(protocol), Protocol(protocol)
{
connect(Protocol, SIGNAL(connected(Account)), this, SIGNAL(canSendChanged()));
connect(Protocol, SIGNAL(disconnected(Account)), this, SIGNAL(canSendChanged()));
}
GaduFileTransferService::~GaduFileTransferService()
......@@ -53,6 +55,8 @@ GaduFileTransferService::~GaduFileTransferService()
void GaduFileTransferService::setGaduIMTokenService(GaduIMTokenService *imTokenService)
{
m_imTokenService = imTokenService;
connect(m_imTokenService, SIGNAL(imTokenChanged(QByteArray)), this, SIGNAL(canSendChanged()));
}
FileTransferHandler * GaduFileTransferService::createFileTransferHandler(FileTransfer fileTransfer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment