mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 23:05:48 +02:00
MessageOptionsPopup: add option to locally delete file
This button offers an option to remove sent/downloaded files from the device. Change-Id: Ida1b135681243fd6055034d8a2d699d11bf040e5 GitLab: #1287
This commit is contained in:
parent
306c428019
commit
8de099e38d
6 changed files with 45 additions and 2 deletions
|
@ -228,6 +228,18 @@ Popup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageOptionButton {
|
||||||
|
visible: type === Interaction.Type.DATA_TRANSFER && Status === Interaction.Status.TRANSFER_FINISHED
|
||||||
|
textButton: JamiStrings.removeLocally
|
||||||
|
iconSource: JamiResources.trash_black_24dp_svg
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: 5
|
||||||
|
onClicked: {
|
||||||
|
MessagesAdapter.removeFile(msgId, root.location)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MessageOptionButton {
|
MessageOptionButton {
|
||||||
id: buttonEdit
|
id: buttonEdit
|
||||||
|
|
||||||
|
|
|
@ -496,6 +496,7 @@ Item {
|
||||||
// Context Menu
|
// Context Menu
|
||||||
property string saveFile: qsTr("Save file")
|
property string saveFile: qsTr("Save file")
|
||||||
property string openLocation: qsTr("Open location")
|
property string openLocation: qsTr("Open location")
|
||||||
|
property string removeLocally: qsTr("Delete file from device")
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
property string betaInstall: qsTr("Install beta version")
|
property string betaInstall: qsTr("Install beta version")
|
||||||
|
|
|
@ -299,6 +299,13 @@ MessagesAdapter::openDirectory(const QString& path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MessagesAdapter::removeFile(const QString& interactionId, const QString& path)
|
||||||
|
{
|
||||||
|
auto convUid = lrcInstance_->get_selectedConvUid();
|
||||||
|
lrcInstance_->getCurrentConversationModel()->removeFile(convUid, interactionId, path);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MessagesAdapter::acceptFile(const QString& interactionId)
|
MessagesAdapter::acceptFile(const QString& interactionId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,6 +111,7 @@ protected:
|
||||||
Q_INVOKABLE void cancelFile(const QString& arg);
|
Q_INVOKABLE void cancelFile(const QString& arg);
|
||||||
Q_INVOKABLE void openUrl(const QString& url);
|
Q_INVOKABLE void openUrl(const QString& url);
|
||||||
Q_INVOKABLE void openDirectory(const QString& arg);
|
Q_INVOKABLE void openDirectory(const QString& arg);
|
||||||
|
Q_INVOKABLE void removeFile(const QString& interactionId, const QString& path);
|
||||||
Q_INVOKABLE void deleteInteraction(const QString& interactionId);
|
Q_INVOKABLE void deleteInteraction(const QString& interactionId);
|
||||||
Q_INVOKABLE void joinCall(const QString& uri,
|
Q_INVOKABLE void joinCall(const QString& uri,
|
||||||
const QString& deviceId,
|
const QString& deviceId,
|
||||||
|
|
|
@ -306,6 +306,9 @@ public:
|
||||||
void getTransferInfo(const QString& conversationId,
|
void getTransferInfo(const QString& conversationId,
|
||||||
const QString& interactionId,
|
const QString& interactionId,
|
||||||
api::datatransfer::Info& info) const;
|
api::datatransfer::Info& info) const;
|
||||||
|
void removeFile(const QString& conversationId,
|
||||||
|
const QString& interactionId,
|
||||||
|
const QString& path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a search of all medias in a conversation
|
* Starts a search of all medias in a conversation
|
||||||
|
|
|
@ -3384,8 +3384,7 @@ ConversationModelPimpl::slotNewCall(const QString& fromId, const QString& callId
|
||||||
// in case if we receive call after removing contact add conversation request;
|
// in case if we receive call after removing contact add conversation request;
|
||||||
try {
|
try {
|
||||||
auto contact = linked.owner.contactModel->getContact(fromId);
|
auto contact = linked.owner.contactModel->getContact(fromId);
|
||||||
if (!isOutgoing && !contact.isBanned
|
if (!isOutgoing && !contact.isBanned && fromId != linked.owner.profileInfo.uri) {
|
||||||
&& fromId != linked.owner.profileInfo.uri) {
|
|
||||||
addContactRequest(fromId);
|
addContactRequest(fromId);
|
||||||
}
|
}
|
||||||
if (isOutgoing && contact.profileInfo.type == profile::Type::TEMPORARY) {
|
if (isOutgoing && contact.profileInfo.type == profile::Type::TEMPORARY) {
|
||||||
|
@ -4049,6 +4048,26 @@ ConversationModel::getTransferInfo(const QString& conversationId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConversationModel::removeFile(const QString& conversationId,
|
||||||
|
const QString& interactionId,
|
||||||
|
const QString& path)
|
||||||
|
{
|
||||||
|
auto convOpt = getConversationForUid(conversationId);
|
||||||
|
if (!convOpt)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QFile::remove(path);
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lk(pimpl_->interactionsLocks[convOpt->get().uid]);
|
||||||
|
auto& interactions = convOpt->get().interactions;
|
||||||
|
auto it = interactions->find(interactionId);
|
||||||
|
if (it != interactions->end()) {
|
||||||
|
it->second.status = interaction::Status::TRANSFER_AWAITING_HOST;
|
||||||
|
interactions->emitDataChanged(it, {MessageList::Role::Status});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ConversationModel::getNumberOfUnreadMessagesFor(const QString& convUid)
|
ConversationModel::getNumberOfUnreadMessagesFor(const QString& convUid)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue