You can now change your name (the one seen by other devices on the network)
This commit is contained in:
parent
c7c91c1289
commit
b0cc45b52a
5 changed files with 123 additions and 4 deletions
|
@ -162,6 +162,17 @@ void Daemon::onDeviceReachableStatusChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Daemon::setAnnouncedName(QString name)
|
||||||
|
{
|
||||||
|
KdeConnectConfig::instance()->setName(name);
|
||||||
|
forceOnNetworkChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Daemon::announcedName()
|
||||||
|
{
|
||||||
|
return KdeConnectConfig::instance()->name();
|
||||||
|
}
|
||||||
|
|
||||||
Daemon::~Daemon()
|
Daemon::~Daemon()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ public Q_SLOTS:
|
||||||
|
|
||||||
Q_SCRIPTABLE void forceOnNetworkChange();
|
Q_SCRIPTABLE void forceOnNetworkChange();
|
||||||
|
|
||||||
|
Q_SCRIPTABLE QString announcedName();
|
||||||
|
Q_SCRIPTABLE void setAnnouncedName(QString name);
|
||||||
|
|
||||||
//Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
|
//Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
|
||||||
Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyVisible = false) const;
|
Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyVisible = false) const;
|
||||||
|
|
||||||
|
|
43
kcm/kcm.cpp
43
kcm/kcm.cpp
|
@ -35,7 +35,6 @@
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
|
|
||||||
#include "ui_kcm.h"
|
#include "ui_kcm.h"
|
||||||
#include "interfaces/dbusinterfaces.h"
|
#include "interfaces/dbusinterfaces.h"
|
||||||
#include "interfaces/devicesmodel.h"
|
#include "interfaces/devicesmodel.h"
|
||||||
|
@ -46,12 +45,13 @@ K_PLUGIN_FACTORY(KdeConnectKcmFactory, registerPlugin<KdeConnectKcm>();)
|
||||||
KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
|
KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
|
||||||
: KCModule(KAboutData::pluginData("kdeconnect-kcm"), parent)
|
: KCModule(KAboutData::pluginData("kdeconnect-kcm"), parent)
|
||||||
, kcmUi(new Ui::KdeConnectKcmUi())
|
, kcmUi(new Ui::KdeConnectKcmUi())
|
||||||
|
, daemon(new DaemonDbusInterface(this))
|
||||||
, devicesModel(new DevicesModel(this))
|
, devicesModel(new DevicesModel(this))
|
||||||
, currentDevice(0)
|
, currentDevice(0)
|
||||||
//, config(KSharedConfig::openConfig("kdeconnectrc"))
|
|
||||||
{
|
{
|
||||||
kcmUi->setupUi(this);
|
kcmUi->setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
kcmUi->deviceList->setIconSize(QSize(32,32));
|
kcmUi->deviceList->setIconSize(QSize(32,32));
|
||||||
|
|
||||||
sortProxyModel = new DevicesSortProxyModel(devicesModel);
|
sortProxyModel = new DevicesSortProxyModel(devicesModel);
|
||||||
|
@ -62,6 +62,10 @@ KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
|
||||||
kcmUi->progressBar->setVisible(false);
|
kcmUi->progressBar->setVisible(false);
|
||||||
kcmUi->messages->setVisible(false);
|
kcmUi->messages->setVisible(false);
|
||||||
|
|
||||||
|
kcmUi->rename_label->setText(daemon->announcedName());
|
||||||
|
kcmUi->rename_edit->setText(daemon->announcedName());
|
||||||
|
setRenameMode(false);
|
||||||
|
|
||||||
setButtons(KCModule::NoAdditionalButton);
|
setButtons(KCModule::NoAdditionalButton);
|
||||||
|
|
||||||
connect(devicesModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
connect(devicesModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
||||||
|
@ -76,6 +80,38 @@ KdeConnectKcm::KdeConnectKcm(QWidget *parent, const QVariantList&)
|
||||||
this, SLOT(sendPing()));
|
this, SLOT(sendPing()));
|
||||||
connect(kcmUi->refresh_button,SIGNAL(clicked()),
|
connect(kcmUi->refresh_button,SIGNAL(clicked()),
|
||||||
this, SLOT(refresh()));
|
this, SLOT(refresh()));
|
||||||
|
connect(kcmUi->rename_edit,SIGNAL(returnPressed()),
|
||||||
|
this, SLOT(renameDone()));
|
||||||
|
connect(kcmUi->renameDone_button,SIGNAL(clicked()),
|
||||||
|
this, SLOT(renameDone()));
|
||||||
|
connect(kcmUi->renameShow_button,SIGNAL(clicked()),
|
||||||
|
this, SLOT(renameShow()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void KdeConnectKcm::renameShow()
|
||||||
|
{
|
||||||
|
setRenameMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KdeConnectKcm::renameDone()
|
||||||
|
{
|
||||||
|
QString newName = kcmUi->rename_edit->text();
|
||||||
|
if (newName.isEmpty()) {
|
||||||
|
//Rollback changes
|
||||||
|
kcmUi->rename_edit->setText(kcmUi->rename_label->text());
|
||||||
|
} else {
|
||||||
|
kcmUi->rename_label->setText(newName);
|
||||||
|
daemon->setAnnouncedName(newName);
|
||||||
|
}
|
||||||
|
setRenameMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KdeConnectKcm::setRenameMode(bool b) {
|
||||||
|
kcmUi->renameDone_button->setVisible(b);
|
||||||
|
kcmUi->rename_edit->setVisible(b);
|
||||||
|
kcmUi->renameShow_button->setVisible(!b);
|
||||||
|
kcmUi->rename_label->setVisible(!b);
|
||||||
}
|
}
|
||||||
|
|
||||||
KdeConnectKcm::~KdeConnectKcm()
|
KdeConnectKcm::~KdeConnectKcm()
|
||||||
|
@ -85,8 +121,7 @@ KdeConnectKcm::~KdeConnectKcm()
|
||||||
|
|
||||||
void KdeConnectKcm::refresh()
|
void KdeConnectKcm::refresh()
|
||||||
{
|
{
|
||||||
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "forceOnNetworkChange");
|
daemon->forceOnNetworkChange();
|
||||||
QDBusConnection::sessionBus().call(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectKcm::resetSelection()
|
void KdeConnectKcm::resetSelection()
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class DeviceDbusInterface;
|
class DeviceDbusInterface;
|
||||||
|
class DaemonDbusInterface;
|
||||||
class DevicesModel;
|
class DevicesModel;
|
||||||
class DevicesSortProxyModel;
|
class DevicesSortProxyModel;
|
||||||
|
|
||||||
|
@ -56,9 +57,13 @@ private Q_SLOTS:
|
||||||
void pairingFailed(const QString& error);
|
void pairingFailed(const QString& error);
|
||||||
void unpaired();
|
void unpaired();
|
||||||
void refresh();
|
void refresh();
|
||||||
|
void renameShow();
|
||||||
|
void renameDone();
|
||||||
|
void setRenameMode(bool b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::KdeConnectKcmUi* kcmUi;
|
Ui::KdeConnectKcmUi* kcmUi;
|
||||||
|
DaemonDbusInterface* daemon;
|
||||||
DevicesModel* devicesModel;
|
DevicesModel* devicesModel;
|
||||||
DevicesSortProxyModel* sortProxyModel;
|
DevicesSortProxyModel* sortProxyModel;
|
||||||
DeviceDbusInterface* currentDevice;
|
DeviceDbusInterface* currentDevice;
|
||||||
|
|
65
kcm/kcm.ui
65
kcm/kcm.ui
|
@ -32,6 +32,71 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="rename_group_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="rename_label">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>KDE Connect</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::PlainText</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="renameShow_button">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-rename"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="rename_group">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="rename_edit">
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>64</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="renameDone_button">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="dialog-ok"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="deviceList"/>
|
<widget class="QListView" name="deviceList"/>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue