Merge branch '1.x'

This commit is contained in:
Kai Uwe Broulik 2016-09-10 22:53:37 +02:00
commit 6f7c419baa
12 changed files with 135 additions and 34 deletions

View file

@ -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();
}

View file

@ -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<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
this, &FileTransferJob::transferFailed);

View file

@ -24,8 +24,8 @@
#include <KJob>
#include <QElapsedTimer>
#include <QIODevice>
#include <QTime>
#include <QSharedPointer>
#include <QUrl>
#include <QNetworkReply>
@ -69,7 +69,7 @@ private:
QNetworkReply* mReply;
QString mFrom;
QUrl mDestination;
QTime mTime;
QElapsedTimer mTimer;
qulonglong mSpeedBytes;
qint64 mWritten;
};

View file

@ -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

View file

@ -224,20 +224,16 @@ void KdeConnectKcm::resetDeviceView()
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
QList<KPluginInfo> availablePluginInfo;
QList<KPluginInfo> 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()));
}

View file

@ -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"

View file

@ -55,7 +55,7 @@ PlasmaComponents.ListItem
}
id: ring
iconSource: "question"
iconSource: "irc-voice"
visible: findmyphone.available
tooltip: i18n("Ring my phone")

View file

@ -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})

View file

@ -0,0 +1,51 @@
/**
* Copyright 2016 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View file

@ -0,0 +1,60 @@
/**
* Copyright 2016 Albert Vaca <albertvaka@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CLIPBOARDLISTENER_H
#define CLIPBOARDLISTENER_H
#include <QObject>
#include <QClipboard>
#include <QGuiApplication>
/**
* 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

View file

@ -20,8 +20,7 @@
#include "clipboardplugin.h"
#include <QClipboard>
#include <QGuiApplication>
#include "clipboardlistener.h"
#include <KPluginFactory>
@ -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<QString>("content"));
QString content = np.get<QString>("content");
ClipboardListener::instance()->setText(content);
return true;
}

View file

@ -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