/****************************************************************************** * Copyright (C) 2014 by Olivier Goffart #include #include #include #include #include #include #include #include "ownclouddolphinpluginhelper.h" class OwncloudDolphinPluginAction : public KAbstractFileItemActionPlugin { public: explicit OwncloudDolphinPluginAction(QObject* parent, const QList&) : KAbstractFileItemActionPlugin(parent) { } QList actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget) Q_DECL_OVERRIDE { auto helper = OwncloudDolphinPluginHelper::instance(); QList urls = fileItemInfos.urlList(); if (urls.count() != 1 || !helper->isConnected()) return {}; auto url = urls.first(); if (!url.isLocalFile()) return {}; auto localFile = url.toLocalFile(); const auto paths = helper->paths(); if (!std::any_of(paths.begin(), paths.end(), [&](const QString &s) { return localFile.startsWith(s); } )) return {}; auto act = new QAction(parentWidget); act->setText(helper->shareActionString()); connect(act, &QAction::triggered, this, [localFile, helper] { helper->sendCommand("SHARE:"+localFile.toUtf8()+"\n"); } ); return { act }; } }; K_PLUGIN_FACTORY(OwncloudDolphinPluginActionFactory, registerPlugin();) K_EXPORT_PLUGIN(OwncloudDolphinPluginActionFactory("ownclouddolhpinpluginaction")) #include "ownclouddolphinactionplugin.moc"