Commit c8b51fb3 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Restore FileItemActionPlugin

The alternative using puropose is less mature than this and some of us
were missing the good old dolphin plugin.

This reverts commit a19713fb.

# Conflicts:
#	CMakeLists.txt
parent b50b7942
......@@ -112,6 +112,7 @@ if (NOT SAILFISHOS)
add_subdirectory(indicator)
add_subdirectory(urlhandler)
add_subdirectory(nautilus-extension)
add_subdirectory(fileitemactionplugin)
else()
add_subdirectory(sfos)
endif()
......
add_definitions(-DTRANSLATION_DOMAIN="kdeconnect-fileitemaction")
include_directories(${CMAKE_SOURCE_DIR})
add_library(kdeconnectfileitemaction MODULE sendfileitemaction.cpp)
target_link_libraries(kdeconnectfileitemaction
KF5::KIOWidgets
KF5::I18n
kdeconnectinterfaces
)
install(TARGETS kdeconnectfileitemaction DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kdeconnectsendfile.desktop DESTINATION ${SERVICES_INSTALL_DIR})
#!/usr/bin/env bash
$XGETTEXT `find . -name '*.cpp'` -o $podir/kdeconnect-fileitemaction.pot
[Desktop Entry]
Type=Service
Name=Send file via KDE Connect service
Name[ar]=أرسل ملفًّا عبر خدمة «كدي المتّصل»
Name[ast]=Unviar ficheru pel serviciu de KDE Connect
Name[bg]=Изпращане на файл през услугата KDE Connect
Name[bs]=Pošalji datoteku putem KDE Connect servisa
Name[ca]=Envia un fitxer a través del servei KDE Connect
Name[ca@valencia]=Envia un fitxer a través del servei KDE Connect
Name[cs]=Poslat soubor přes službu KDE Connect
Name[da]=Send fil via KDE Connect-tjeneste
Name[de]=Datei mit KDE-Connect -Dienst versenden
Name[el]=Αποστολή αρχείου μέσω της υπηρεσίας KDE Connect
Name[en_GB]=Send file via KDE Connect service
Name[es]=Enviar archivo usando el servicio KDE Connect
Name[et]=Faili saatmine KDE Connecti teenuse kaudu
Name[eu]=Bidali fitxategia KDE Connect zerbitzuaren bidez
Name[fi]=Lähetä tiedosto KDE Connect -palvelulla
Name[fr]=Envoyer un fichier via le service KDE Connect
Name[gl]=Enviar un ficheiro mediante o servizo de KDE Connect
Name[he]=שלח קובץ דרך שירות KDE Connect
Name[hu]=Fájl küldése a KDE csatlakozás szolgáltatáson keresztül
Name[id]=Kirim file via layanan KDE Connect
Name[it]=Invia un file tramite il servizio KDE Connect
Name[ko]=KDE Connect 서비스로 파일 보내기
Name[nl]=Bestand via de service KDE Connect versturen
Name[nn]=Send fil med KDE Connect-tenesta
Name[pl]=Wyślij plik przez usługę KDE Connect
Name[pt]=Enviar um ficheiro pelo serviço KDE Connect
Name[pt_BR]=Enviar arquivo pelo serviço KDE Connect
Name[ru]=Отправить файл через KDE Connect
Name[sk]=Poslať súbor cez službu KDE Connect
Name[sr]=Шаљи фајл преко КДЕ‑конекцијиног сервиса
Name[sr@ijekavian]=Шаљи фајл преко КДЕ‑конекцијиног сервиса
Name[sr@ijekavianlatin]=Šalji fajl preko KDE‑konekcijinog servisa
Name[sr@latin]=Šalji fajl preko KDE‑konekcijinog servisa
Name[sv]=Skicka fil via KDE:s anslutningstjänst
Name[tr]=KDE Connect servisi ile dosya gönderin
Name[uk]=Надсилання файла за допомогою служби з’єднання KDE
Name[x-test]=xxSend file via KDE Connect servicexx
Name[zh_CN]=通过 KDE Connect 服务发送文件
Name[zh_TW]=以已經連結到KDE之服務或裝置來傳送檔案
X-KDE-Library=kdeconnectfileitemaction
X-KDE-Submenu=Connect
X-KDE-Submenu[ar]=اتّصل,اتصل
X-KDE-Submenu[ast]=Coneutar
X-KDE-Submenu[bg]=Свързване
X-KDE-Submenu[bs]=Uspostavi vezu
X-KDE-Submenu[ca]=Connecta
X-KDE-Submenu[ca@valencia]=Connecta
X-KDE-Submenu[cs]=Připojit
X-KDE-Submenu[da]=Forbind
X-KDE-Submenu[de]=Verbinden
X-KDE-Submenu[el]=Σύνδεση
X-KDE-Submenu[en_GB]=Connect
X-KDE-Submenu[es]=Conectar
X-KDE-Submenu[et]=Ühendus
X-KDE-Submenu[eu]=Konektatu
X-KDE-Submenu[fi]=Yhdistä
X-KDE-Submenu[fr]=Connecter
X-KDE-Submenu[gl]=Conectar
X-KDE-Submenu[he]=חיבור
X-KDE-Submenu[hu]=Csatlakozás
X-KDE-Submenu[ia]=Connecte
X-KDE-Submenu[id]=Connect
X-KDE-Submenu[it]=Connetti
X-KDE-Submenu[ko]=연결
X-KDE-Submenu[nl]=Verbinden
X-KDE-Submenu[nn]=Kopla til
X-KDE-Submenu[pl]=Połącz
X-KDE-Submenu[pt]=Ligar
X-KDE-Submenu[pt_BR]=Conectar
X-KDE-Submenu[ru]=KDE Connect
X-KDE-Submenu[sk]=Pripojiť
X-KDE-Submenu[sr]=Повежи се
X-KDE-Submenu[sr@ijekavian]=Повежи се
X-KDE-Submenu[sr@ijekavianlatin]=Poveži se
X-KDE-Submenu[sr@latin]=Poveži se
X-KDE-Submenu[sv]=Anslut
X-KDE-Submenu[tr]=Bağlan
X-KDE-Submenu[uk]=З’єднання
X-KDE-Submenu[x-test]=xxConnectxx
X-KDE-Submenu[zh_CN]=连接
X-KDE-Submenu[zh_TW]=連線
Icon=preferences-system-network
ServiceTypes=KFileItemAction/Plugin
MimeType=application/octet-stream
/*
* Copyright (C) 2011 Alejandro Fiestas Olivares <afiestas@kde.org>
* Copyright (C) 2014 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* This program is free 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 2 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 GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "sendfileitemaction.h"
#include <QList>
#include <QMenu>
#include <QAction>
#include <QWidget>
#include <QVariantList>
#include <QUrl>
#include <QIcon>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KLocalizedString>
#include <interfaces/devicesmodel.h>
#include <interfaces/dbusinterfaces.h>
K_PLUGIN_FACTORY(SendFileItemActionFactory, registerPlugin<SendFileItemAction>();)
Q_LOGGING_CATEGORY(KDECONNECT_FILEITEMACTION, "kdeconnect.fileitemaction")
SendFileItemAction::SendFileItemAction(QObject* parent, const QVariantList& ): KAbstractFileItemActionPlugin(parent)
{
}
QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget)
{
QList<QAction*> actions;
DaemonDbusInterface iface;
if (!iface.isValid()) {
return actions;
}
QDBusPendingReply<QStringList> reply = iface.devices(true, true);
reply.waitForFinished();
const QStringList devices = reply.value();
for (const QString& id : devices) {
DeviceDbusInterface deviceIface(id);
if (!deviceIface.isValid()) {
continue;
}
if (!deviceIface.hasPlugin(QStringLiteral("kdeconnect_share"))) {
continue;
}
QAction* action = new QAction(QIcon::fromTheme(deviceIface.iconName()), deviceIface.name(), parentWidget);
action->setProperty("id", id);
action->setProperty("urls", QVariant::fromValue(fileItemInfos.urlList()));
action->setProperty("parentWidget", QVariant::fromValue(parentWidget));
connect(action, &QAction::triggered, this, &SendFileItemAction::sendFile);
actions += action;
}
if (actions.count() > 1) {
QAction* menuAction = new QAction(QIcon::fromTheme(QStringLiteral("kdeconnect")), i18n("Send via KDE Connect"), parentWidget);
QMenu* menu = new QMenu(parentWidget);
menu->addActions(actions);
menuAction->setMenu(menu);
return QList<QAction*>() << menuAction;
} else {
if(actions.count() == 1) {
actions.first()->setText(i18n("Send to '%1' via KDE Connect", actions.first()->text()));
}
return actions;
}
}
void SendFileItemAction::sendFile()
{
const QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>();
QString id = sender()->property("id").toString();
for (const QUrl& url : urls) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+id+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
msg.setArguments(QVariantList() << url.toString());
QDBusConnection::sessionBus().call(msg);
}
}
#include "sendfileitemaction.moc"
/*
* Copyright (C) 2011 Alejandro Fiestas Olivares <afiestas@kde.org>
* Copyright (C) 2014 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* This program is free 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 2 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 GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SENDFILEITEMACTION_H
#define SENDFILEITEMACTION_H
#include <KFileItemListProperties>
#include <KAbstractFileItemActionPlugin>
#include <QLoggingCategory>
class QAction;
class KFileItemListProperties;
class QWidget;
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_FILEITEMACTION)
class SendFileItemAction : public KAbstractFileItemActionPlugin
{
Q_OBJECT
public:
SendFileItemAction(QObject* parent, const QVariantList& args);
QList< QAction* > actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget) override;
private Q_SLOTS:
void sendFile();
};
#endif // SENDFILEITEMACTION_H
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