diff --git a/core/device.cpp b/core/device.cpp index e2f6795d8..5f908493d 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -60,6 +60,9 @@ Device::Device(QObject* parent, const QString& id) //Register in bus QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); + //Assume every plugin is supported until addLink is called and we can get the actual list + m_supportedPlugins = PluginLoader::instance()->getPluginList().toSet(); + connect(this, &Device::pairingError, this, &warn); } @@ -259,7 +262,6 @@ void Device::removeLink(DeviceLink* link) //qCDebug(KDECONNECT_CORE) << "RemoveLink" << m_deviceLinks.size() << "links remaining"; if (m_deviceLinks.isEmpty()) { - m_supportedPlugins.clear(); reloadPlugins(); Q_EMIT reachableStatusChanged(); } diff --git a/core/filetransferjob.cpp b/core/filetransferjob.cpp index 9ee8205a5..afc8e46d9 100644 --- a/core/filetransferjob.cpp +++ b/core/filetransferjob.cpp @@ -80,7 +80,7 @@ void FileTransferJob::doStart() void FileTransferJob::startTransfer() { setProcessedAmount(Bytes, 0); - mTime = QTime::currentTime(); + mTimer.start(); description(this, i18n("Receiving file over KDE Connect"), { i18nc("File transfer origin", "From"), mFrom }, { i18nc("File transfer destination", "To"), mDestination.toLocalFile() }); @@ -91,7 +91,11 @@ void FileTransferJob::startTransfer() connect(mReply, &QNetworkReply::uploadProgress, this, [this](qint64 bytesSent, qint64 /*bytesTotal*/) { setProcessedAmount(Bytes, bytesSent); - emitSpeed(bytesSent/mTime.elapsed()); + + const auto elapsed = mTimer.elapsed(); + if (elapsed > 0) { + emitSpeed(bytesSent / elapsed); + } }); connect(mReply, static_cast(&QNetworkReply::error), this, &FileTransferJob::transferFailed); diff --git a/core/filetransferjob.h b/core/filetransferjob.h index ee434de87..ab8368ddf 100644 --- a/core/filetransferjob.h +++ b/core/filetransferjob.h @@ -24,8 +24,8 @@ #include +#include #include -#include #include #include #include @@ -69,7 +69,7 @@ private: QNetworkReply* mReply; QString mFrom; QUrl mDestination; - QTime mTime; + QElapsedTimer mTimer; qulonglong mSpeedBytes; qint64 mWritten; }; diff --git a/daemon/kdeconnectd.desktop.cmake b/daemon/kdeconnectd.desktop.cmake index 023201bb8..1e8d25bcd 100644 --- a/daemon/kdeconnectd.desktop.cmake +++ b/daemon/kdeconnectd.desktop.cmake @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application -Exec=${LIBEXEC_INSTALL_DIR}/kdeconnectd +Exec=${KDE_INSTALL_FULL_LIBEXECDIR}/kdeconnectd X-KDE-StartupNotify=false X-KDE-autostart-phase=0 X-GNOME-Autostart-enabled=true diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 63c6edc67..3e4b731e8 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -224,20 +224,16 @@ void KdeConnectKcm::resetDeviceView() const QList pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/")); QList availablePluginInfo; - QList unsupportedPluginInfo; m_oldSupportedPluginNames = currentDevice->supportedPlugins(); for (auto it = pluginInfo.cbegin(), itEnd = pluginInfo.cend(); it!=itEnd; ++it) { if (m_oldSupportedPluginNames.contains(it->pluginName())) { availablePluginInfo.append(*it); - } else { - unsupportedPluginInfo.append(*it); } } KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile()); kcmUi->pluginSelector->addPlugins(availablePluginInfo, KPluginSelector::ReadConfigFile, i18n("Available plugins"), QString(), deviceConfig); - kcmUi->pluginSelector->addPlugins(unsupportedPluginInfo, KPluginSelector::ReadConfigFile, i18n("Unavailable plugins"), QString(), deviceConfig); connect(kcmUi->pluginSelector, SIGNAL(changed(bool)), this, SLOT(pluginsConfigChanged())); } diff --git a/plasmoid/package/contents/ui/CompactRepresentation.qml b/plasmoid/package/contents/ui/CompactRepresentation.qml index c4edb6d41..af58dccf7 100644 --- a/plasmoid/package/contents/ui/CompactRepresentation.qml +++ b/plasmoid/package/contents/ui/CompactRepresentation.qml @@ -21,9 +21,11 @@ import QtQuick 2.1 import org.kde.plasma.core 2.0 as PlasmaCore -Item { +MouseArea { id: view + onClicked: plasmoid.expanded = !plasmoid.expanded + PlasmaCore.IconItem { id: icon source: "kdeconnect" diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml index e9419e7eb..5d9185b42 100644 --- a/plasmoid/package/contents/ui/DeviceDelegate.qml +++ b/plasmoid/package/contents/ui/DeviceDelegate.qml @@ -55,7 +55,7 @@ PlasmaComponents.ListItem } id: ring - iconSource: "question" + iconSource: "irc-voice" visible: findmyphone.available tooltip: i18n("Ring my phone") diff --git a/plugins/clipboard/CMakeLists.txt b/plugins/clipboard/CMakeLists.txt index 4e6d2ab63..3481a9a17 100644 --- a/plugins/clipboard/CMakeLists.txt +++ b/plugins/clipboard/CMakeLists.txt @@ -1,5 +1,6 @@ set(kdeconnect_clipboard_SRCS clipboardplugin.cpp + clipboardlistener.cpp ) kdeconnect_add_plugin(kdeconnect_clipboard JSON kdeconnect_clipboard.json SOURCES ${kdeconnect_clipboard_SRCS}) diff --git a/plugins/clipboard/clipboardlistener.cpp b/plugins/clipboard/clipboardlistener.cpp new file mode 100644 index 000000000..1c23f6870 --- /dev/null +++ b/plugins/clipboard/clipboardlistener.cpp @@ -0,0 +1,51 @@ +/** + * Copyright 2016 Albert Vaca + * + * 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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 General Public License + * along with this program. If not, see . + */ + +#include "clipboardlistener.h" + +ClipboardListener::ClipboardListener() + : clipboard(QGuiApplication::clipboard()) +{ + connect(clipboard, &QClipboard::changed, this, &ClipboardListener::updateClipboard); +} + +void ClipboardListener::updateClipboard(QClipboard::Mode mode) +{ + if (mode != QClipboard::Clipboard) { + return; + } + + QString content = clipboard->text(); + + if (content == currentContent) { + return; + } + currentContent = content; + + Q_EMIT clipboardChanged(content); +} + +void ClipboardListener::setText(const QString& content) +{ + currentContent = content; + clipboard->setText(content); +} + + diff --git a/plugins/clipboard/clipboardlistener.h b/plugins/clipboard/clipboardlistener.h new file mode 100644 index 000000000..6d5d70e15 --- /dev/null +++ b/plugins/clipboard/clipboardlistener.h @@ -0,0 +1,60 @@ +/** + * Copyright 2016 Albert Vaca + * + * 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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 General Public License + * along with this program. If not, see . + */ + +#ifndef CLIPBOARDLISTENER_H +#define CLIPBOARDLISTENER_H + +#include +#include +#include + +/** + * Wrapper around QClipboard, which emits clipboardChanged only when it really changed + */ +class ClipboardListener : public QObject +{ + Q_OBJECT + +private: + QString currentContent; + QClipboard* clipboard; + +public: + + static ClipboardListener* instance() + { + static ClipboardListener* me = nullptr; + if (!me) { + me = new ClipboardListener(); + } + return me; + } + + ClipboardListener(); + + void updateClipboard(QClipboard::Mode mode); + + void setText(const QString& content); + +Q_SIGNALS: + void clipboardChanged(const QString& content); +}; + +#endif diff --git a/plugins/clipboard/clipboardplugin.cpp b/plugins/clipboard/clipboardplugin.cpp index 6d8c65c0f..571167f7e 100644 --- a/plugins/clipboard/clipboardplugin.cpp +++ b/plugins/clipboard/clipboardplugin.cpp @@ -20,8 +20,7 @@ #include "clipboardplugin.h" -#include -#include +#include "clipboardlistener.h" #include @@ -31,32 +30,21 @@ Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_CLIPBOARD, "kdeconnect.plugin.clipboard") ClipboardPlugin::ClipboardPlugin(QObject *parent, const QVariantList &args) : KdeConnectPlugin(parent, args) - , clipboard(QGuiApplication::clipboard()) { - connect(clipboard, SIGNAL(changed(QClipboard::Mode)), this, SLOT(clipboardChanged(QClipboard::Mode))); + connect(ClipboardListener::instance(), &ClipboardListener::clipboardChanged, + this, &ClipboardPlugin::propagateClipboard); } -void ClipboardPlugin::clipboardChanged(QClipboard::Mode mode) +void ClipboardPlugin::propagateClipboard(const QString& content) { - if (mode != QClipboard::Clipboard) { - return; - } - - QString content = clipboard->text(); - - if (content == currentContent) { - return; - } - - currentContent = content; - NetworkPackage np(PACKAGE_TYPE_CLIPBOARD, {{"content", content}}); sendPackage(np); } bool ClipboardPlugin::receivePackage(const NetworkPackage& np) { - clipboard->setText(np.get("content")); + QString content = np.get("content"); + ClipboardListener::instance()->setText(content); return true; } diff --git a/plugins/clipboard/clipboardplugin.h b/plugins/clipboard/clipboardplugin.h index 6d1bc7a5d..22e834823 100644 --- a/plugins/clipboard/clipboardplugin.h +++ b/plugins/clipboard/clipboardplugin.h @@ -42,11 +42,8 @@ public Q_SLOTS: void connected() override { } private Q_SLOTS: - void clipboardChanged(QClipboard::Mode mode); + void propagateClipboard(const QString& content); -private: - QString currentContent; - QClipboard *clipboard; }; #endif