Compare commits
1 commit
master
...
sms-indica
Author | SHA1 | Date | |
---|---|---|---|
|
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);
|
||||
|
||||
|
||||
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);
|
||||
QAction* menuAction = remoteCommandsMenu->menuAction();
|
||||
QAction* addCommandAction = remoteCommandsMenu->addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add commands"));
|
||||
|
||||
connect(addCommandAction, &QAction::triggered, m_remoteCommandsInterface, &RemoteCommandsDbusInterface::editCommands);
|
||||
|
||||
addAction(menuAction);
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
Q_SCRIPTABLE DeviceDbusInterface* getDevice(int row) const;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowForDevice(const QString& id) const;
|
||||
Q_SCRIPTABLE int rowForDevice(const QString& id) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
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
|
||||
width: parent.width
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QDebug>
|
||||
#include <QDBusConnection>
|
||||
#include <QLoggingCategory>
|
||||
#include <QProcess>
|
||||
|
||||
#include <core/device.h>
|
||||
#include <core/daemon.h>
|
||||
|
@ -116,11 +117,15 @@ bool SmsPlugin::handleBatchMessages(const NetworkPacket& np)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString SmsPlugin::dbusPath() const
|
||||
{
|
||||
return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/sms");
|
||||
}
|
||||
|
||||
void SmsPlugin::launchApp()
|
||||
{
|
||||
QProcess::startDetached(QLatin1String("kdeconnect-sms"), { QStringLiteral("--device"), device()->id() });
|
||||
}
|
||||
|
||||
#include "smsplugin.moc"
|
||||
|
||||
|
|
|
@ -140,6 +140,8 @@ public Q_SLOTS:
|
|||
*/
|
||||
Q_SCRIPTABLE void requestConversation(const qint64& conversationID) const;
|
||||
|
||||
Q_SCRIPTABLE void launchApp();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,20 +41,20 @@ int main(int argc, char *argv[])
|
|||
aboutData.addAuthor(i18n("Nicolas Fella"), {}, QStringLiteral("nicolas.fella@gmx.de"));
|
||||
KAboutData::setApplicationData(aboutData);
|
||||
|
||||
QString initialMessage;
|
||||
QString initialMessage, deviceid;
|
||||
|
||||
{
|
||||
QCommandLineParser parser;
|
||||
aboutData.setupCommandLine(&parser);
|
||||
parser.addVersionOption();
|
||||
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.process(app);
|
||||
aboutData.processCommandLine(&parser);
|
||||
|
||||
if (parser.isSet(QStringLiteral("message"))) {
|
||||
initialMessage = parser.value(QStringLiteral("message"));
|
||||
}
|
||||
deviceid = parser.value(QStringLiteral("device"));
|
||||
}
|
||||
|
||||
KDBusService service(KDBusService::Unique);
|
||||
|
@ -66,8 +66,11 @@ int main(int argc, char *argv[])
|
|||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("_initialMessage"), QVariant(initialMessage));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData()));
|
||||
engine.rootContext()->setContextProperties({
|
||||
{ QStringLiteral("initialMessage"), initialMessage },
|
||||
{ QStringLiteral("initialDevice"), deviceid },
|
||||
{ QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData()) }
|
||||
});
|
||||
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||
|
||||
return app.exec();
|
||||
|
|
|
@ -73,6 +73,7 @@ Kirigami.ScrollablePage
|
|||
}
|
||||
|
||||
property string initialMessage
|
||||
property string initialDevice
|
||||
|
||||
header: Kirigami.InlineMessage {
|
||||
Layout.fillWidth: true
|
||||
|
@ -97,6 +98,9 @@ Kirigami.ScrollablePage
|
|||
//TODO: make it possible to filter if they can do sms
|
||||
sourceModel: DevicesModel { displayFilter: DevicesModel.Paired | DevicesModel.Reachable }
|
||||
onRowsInserted: if (devicesCombo.currentIndex < 0) {
|
||||
if (page.initialDevice)
|
||||
devicesCombo.currentIndex = devicesModel.rowForDevice(page.initialDevice);
|
||||
else
|
||||
devicesCombo.currentIndex = 0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue