sms: Added opening kdeconnect-sms on the plasmoid and indicator
Add a menu entry on the kdeconnect-indicator within devices' submenu that opens kdeconnect-sms. Also add it in the plasmoid in the device delegate.
This commit is contained in:
parent
bc468f1e07
commit
b7f8ceefcf
8 changed files with 50 additions and 11 deletions
|
@ -113,10 +113,18 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device)
|
||||||
|
|
||||||
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_share")), [sendFile](bool available) { sendFile->setVisible(available); }, this);
|
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_share")), [sendFile](bool available) { sendFile->setVisible(available); }, this);
|
||||||
|
|
||||||
|
|
||||||
|
if (!QStandardPaths::findExecutable(QStringLiteral("kdeconnect-sms")).isEmpty()) {
|
||||||
|
auto smsapp = addAction(QIcon::fromTheme(QStringLiteral("message-new")), i18n("SMS Messages..."));
|
||||||
|
QObject::connect(smsapp, &QAction::triggered, device, [device] () {
|
||||||
|
QProcess::startDetached(QLatin1String("kdeconnect-sms"), { QStringLiteral("--device"), device->id() });
|
||||||
|
});
|
||||||
|
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_sms")), [smsapp](bool available) { smsapp->setVisible(available); }, this);
|
||||||
|
}
|
||||||
|
|
||||||
QMenu* remoteCommandsMenu = new QMenu(i18n("Run command"), this);
|
QMenu* remoteCommandsMenu = new QMenu(i18n("Run command"), this);
|
||||||
QAction* menuAction = remoteCommandsMenu->menuAction();
|
QAction* menuAction = remoteCommandsMenu->menuAction();
|
||||||
QAction* addCommandAction = remoteCommandsMenu->addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add commands"));
|
QAction* addCommandAction = remoteCommandsMenu->addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add commands"));
|
||||||
|
|
||||||
connect(addCommandAction, &QAction::triggered, m_remoteCommandsInterface, &RemoteCommandsDbusInterface::editCommands);
|
connect(addCommandAction, &QAction::triggered, m_remoteCommandsInterface, &RemoteCommandsDbusInterface::editCommands);
|
||||||
|
|
||||||
addAction(menuAction);
|
addAction(menuAction);
|
||||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
||||||
// Get bundle path
|
// Get bundle path
|
||||||
CFURLRef url = (CFURLRef)CFAutorelease((CFURLRef)CFBundleCopyBundleURL(CFBundleGetMainBundle()));
|
CFURLRef url = (CFURLRef)CFAutorelease((CFURLRef)CFBundleCopyBundleURL(CFBundleGetMainBundle()));
|
||||||
QString basePath = QUrl::fromCFURL(url).path();
|
QString basePath = QUrl::fromCFURL(url).path();
|
||||||
|
|
||||||
// Start kdeconnectd
|
// Start kdeconnectd
|
||||||
QProcess kdeconnectdProcess;
|
QProcess kdeconnectdProcess;
|
||||||
kdeconnectdProcess.startDetached(basePath + QStringLiteral("Contents/MacOS/kdeconnectd"));
|
kdeconnectdProcess.startDetached(basePath + QStringLiteral("Contents/MacOS/kdeconnectd"));
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
|
|
||||||
Q_SCRIPTABLE DeviceDbusInterface* getDevice(int row) const;
|
Q_SCRIPTABLE DeviceDbusInterface* getDevice(int row) const;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
int rowForDevice(const QString& id) const;
|
Q_SCRIPTABLE int rowForDevice(const QString& id) const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void deviceAdded(const QString& id);
|
void deviceAdded(const QString& id);
|
||||||
|
|
|
@ -142,6 +142,23 @@ PlasmaComponents.ListItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SMS
|
||||||
|
PlasmaComponents.Button
|
||||||
|
{
|
||||||
|
SMS {
|
||||||
|
id: sms
|
||||||
|
device: root.device
|
||||||
|
}
|
||||||
|
|
||||||
|
iconSource: "message-new'"
|
||||||
|
visible: sms.available
|
||||||
|
tooltip: i18n("SMS Messages")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
sms.plugin.launchApp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
height: browse.height
|
height: browse.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
#include <core/device.h>
|
#include <core/device.h>
|
||||||
#include <core/daemon.h>
|
#include <core/daemon.h>
|
||||||
|
@ -116,11 +117,15 @@ bool SmsPlugin::handleBatchMessages(const NetworkPacket& np)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString SmsPlugin::dbusPath() const
|
QString SmsPlugin::dbusPath() const
|
||||||
{
|
{
|
||||||
return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/sms");
|
return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/sms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SmsPlugin::launchApp()
|
||||||
|
{
|
||||||
|
QProcess::startDetached(QLatin1String("kdeconnect-sms"), { QStringLiteral("--device"), device()->id() });
|
||||||
|
}
|
||||||
|
|
||||||
#include "smsplugin.moc"
|
#include "smsplugin.moc"
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,8 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
Q_SCRIPTABLE void requestConversation(const qint64& conversationID) const;
|
Q_SCRIPTABLE void requestConversation(const qint64& conversationID) const;
|
||||||
|
|
||||||
|
Q_SCRIPTABLE void launchApp();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,20 +41,20 @@ int main(int argc, char *argv[])
|
||||||
aboutData.addAuthor(i18n("Nicolas Fella"), {}, QStringLiteral("nicolas.fella@gmx.de"));
|
aboutData.addAuthor(i18n("Nicolas Fella"), {}, QStringLiteral("nicolas.fella@gmx.de"));
|
||||||
KAboutData::setApplicationData(aboutData);
|
KAboutData::setApplicationData(aboutData);
|
||||||
|
|
||||||
QString initialMessage;
|
QString initialMessage, deviceid;
|
||||||
|
|
||||||
{
|
{
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
aboutData.setupCommandLine(&parser);
|
aboutData.setupCommandLine(&parser);
|
||||||
parser.addVersionOption();
|
parser.addVersionOption();
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
|
parser.addOption(QCommandLineOption(QStringLiteral("device"), i18n("Select a device"), i18n("id")));
|
||||||
parser.addOption(QCommandLineOption(QStringLiteral("message"), i18n("Send a message"), i18n("message")));
|
parser.addOption(QCommandLineOption(QStringLiteral("message"), i18n("Send a message"), i18n("message")));
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
aboutData.processCommandLine(&parser);
|
aboutData.processCommandLine(&parser);
|
||||||
|
|
||||||
if (parser.isSet(QStringLiteral("message"))) {
|
initialMessage = parser.value(QStringLiteral("message"));
|
||||||
initialMessage = parser.value(QStringLiteral("message"));
|
deviceid = parser.value(QStringLiteral("device"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KDBusService service(KDBusService::Unique);
|
KDBusService service(KDBusService::Unique);
|
||||||
|
@ -66,8 +66,11 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||||
engine.rootContext()->setContextProperty(QStringLiteral("_initialMessage"), QVariant(initialMessage));
|
engine.rootContext()->setContextProperties({
|
||||||
engine.rootContext()->setContextProperty(QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData()));
|
{ QStringLiteral("initialMessage"), initialMessage },
|
||||||
|
{ QStringLiteral("initialDevice"), deviceid },
|
||||||
|
{ QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData()) }
|
||||||
|
});
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
|
@ -73,6 +73,7 @@ Kirigami.ScrollablePage
|
||||||
}
|
}
|
||||||
|
|
||||||
property string initialMessage
|
property string initialMessage
|
||||||
|
property string initialDevice
|
||||||
|
|
||||||
header: Kirigami.InlineMessage {
|
header: Kirigami.InlineMessage {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -97,7 +98,10 @@ Kirigami.ScrollablePage
|
||||||
//TODO: make it possible to filter if they can do sms
|
//TODO: make it possible to filter if they can do sms
|
||||||
sourceModel: DevicesModel { displayFilter: DevicesModel.Paired | DevicesModel.Reachable }
|
sourceModel: DevicesModel { displayFilter: DevicesModel.Paired | DevicesModel.Reachable }
|
||||||
onRowsInserted: if (devicesCombo.currentIndex < 0) {
|
onRowsInserted: if (devicesCombo.currentIndex < 0) {
|
||||||
devicesCombo.currentIndex = 0
|
if (page.initialDevice)
|
||||||
|
devicesCombo.currentIndex = devicesModel.rowForDevice(page.initialDevice);
|
||||||
|
else
|
||||||
|
devicesCombo.currentIndex = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
textRole: "display"
|
textRole: "display"
|
||||||
|
|
Loading…
Reference in a new issue