peony-extensions/ 0000755 0001750 0001750 00000000000 14205133370 013023 5 ustar feng feng peony-extensions/peony-bluetooth-plugin/ 0000755 0001750 0001750 00000000000 14205133370 017454 5 ustar feng feng peony-extensions/peony-bluetooth-plugin/bluetoothplugin.cpp 0000644 0001750 0001750 00000006402 14205133370 023406 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2019, Tianjin KYLIN Information Technology Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: tang guang
*
*/
#include "bluetoothplugin.h"
#include
#include
using namespace Peony;
BluetoothPlugin::BluetoothPlugin(QObject *parent)
{
QTranslator *t = new QTranslator(this);
qDebug()<<"system().name:"<load(":/translations/peony-bluetooth-plugin_"+QLocale::system().name());
QApplication::installTranslator(t);
}
QList BluetoothPlugin::menuActions(Peony::MenuPluginInterface::Types types, const QString &uri, const QStringList &selectionUris)
{
qDebug() << Q_FUNC_INFO << uri << selectionUris;
QList actions;
QStringList target;
for (auto str : selectionUris) {
qDebug() << Q_FUNC_INFO << str << " = " << Peony::FileUtils::urlEncode(str);
target << Peony::FileUtils::urlEncode(str);
}
QProcess process;
process.start("rfkill list");
process.waitForFinished();
QByteArray output = process.readAllStandardOutput();
QString str_output = output;
if(!str_output.contains(QString("bluetooth"), Qt::CaseInsensitive))
return actions;
if(!QFileInfo::exists("/usr/bin/ukui-bluetooth")){
return actions;
}
if (types == MenuPluginInterface::DirectoryView || types == MenuPluginInterface::DesktopWindow)
{
if (! selectionUris.isEmpty()) {
auto info = FileInfo::fromUri(selectionUris.first());
//special type mountable, return
qDebug()<<"info isVirtual:"<isVirtual()<mimeType();
if (!selectionUris.first().startsWith("file:///"))
return actions;
else{
if(info->mimeType().split("/").at(1) != "directory"){
QAction *compress = new QAction(QIcon::fromTheme("blueman-tray"), tr("Send from bluetooth to..."), nullptr);
actions << compress;
connect(compress, &QAction::triggered, [=](){
QString path = selectionUris.at(0);
QDBusMessage m = QDBusMessage::createMethodCall("org.ukui.bluetooth","/org/ukui/bluetooth","org.ukui.bluetooth","file_transfer");
m << target;
qDebug() << Q_FUNC_INFO << m.arguments().at(0).value() <<__LINE__;
// 发送Message
QDBusConnection::sessionBus().call(m);
});
}
}
}
}
return actions;
}
peony-extensions/peony-bluetooth-plugin/peony-bluetooth-plugin.qrc 0000644 0001750 0001750 00000000173 14205101224 024606 0 ustar feng feng
translations/peony-bluetooth-plugin_zh_CN.qm
peony-extensions/peony-bluetooth-plugin/peony-bluetooth-plugin_global.h 0000644 0001750 0001750 00000002176 14205101224 025575 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2019, Tianjin KYLIN Information Technology Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: tang guang
*
*/
#ifndef PEONYBLUETOOTHPLUGIN_GLOBAL_H
#define PEONYBLUETOOTHPLUGIN_GLOBAL_H
#include
#if defined(PEONYENGRAMPAMENUPLUGIN_LIBRARY)
# define PEONYQTENGRAMPAMENUPLUGINSHARED_EXPORT Q_DECL_EXPORT
#else
# define PEONYQTENGRAMPAMENUPLUGINSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // PEONYBLUETOOTHPLUGIN_GLOBAL_H
peony-extensions/peony-bluetooth-plugin/bluetoothplugin.h 0000644 0001750 0001750 00000004227 14205101224 023047 0 ustar feng feng /*
* Peony-Qt's Library
*
* Copyright (C) 2019, Tianjin KYLIN Information Technology Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: tang guang
*
*/
#ifndef BLUETOOTHPLUGIN_H
#define BLUETOOTHPLUGIN_H
#include
#include
#include "peony-bluetooth-plugin_global.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace Peony {
class PEONYQTENGRAMPAMENUPLUGINSHARED_EXPORT BluetoothPlugin: public QObject, public MenuPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID MenuPluginInterface_iid FILE "common.json")
Q_INTERFACES(Peony::MenuPluginInterface)
public:
explicit BluetoothPlugin(QObject *parent = nullptr);
PluginInterface::PluginType pluginType() override {return PluginInterface::MenuPlugin;}
const QString name() override {return tr("Peony-Qt bluetooth Extension");}
const QString description() override {return tr("bluetooth Menu Extension.");}
const QIcon icon() override {return QIcon::fromTheme("blueman-tray");}
void setEnable(bool enable) override {m_enable = enable;}
bool isEnable() override {return m_enable;}
QString testPlugin() override {return "test compress";}
QList menuActions(Types types, const QString &uri, const QStringList &selectionUris) override;
private:
bool m_enable;
};
}
#endif // BLUETOOTHPLUGIN_H
peony-extensions/peony-bluetooth-plugin/peony-bluetooth-plugin.pro 0000644 0001750 0001750 00000002530 14205101224 024620 0 ustar feng feng ######################################################################
# Automatically generated by qmake (3.1) Wed Dec 2 15:23:52 2020
######################################################################
QT += widgets dbus
TEMPLATE = lib
TARGET = peony-bluetooth-plugin
#INCLUDEPATH += .
DEFINES += PEONYENGRAMPAMENUPLUGIN_LIBRARY
include(../common.pri)
# The following define makes your compiler warn you if you use any
# feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += debug link_pkgconfig plugin
PKGCONFIG += peony
TRANSLATIONS = translations/peony-bluetooth-plugin_zh_CN.ts
#DESTDIR += ../testdir
HEADERS += \
bluetoothplugin.h \
peony-bluetooth-plugin_global.h
SOURCES += \
bluetoothplugin.cpp
target.path = $$[QT_INSTALL_LIBS]/peony-extensions
INSTALLS += target
RESOURCES += \
peony-bluetooth-plugin.qrc
peony-extensions/peony-bluetooth-plugin/translations/ 0000755 0001750 0001750 00000000000 14205133370 022175 5 ustar feng feng peony-extensions/peony-bluetooth-plugin/translations/peony-bluetooth-plugin_zh_CN.qm 0000644 0001750 0001750 00000000455 14205101224 030243 0 ustar feng feng