Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 6d4f1bc2 authored by Laurent Montel's avatar Laurent Montel 😁

Use more QStringLiteral/nullptr

parent 78f4cc6f
......@@ -29,6 +29,7 @@
#include <QStringList>
#include <QVariant>
#include <QDBusServiceWatcher>
#include <QDBusConnection>
PanelAgent::PanelAgent(QObject *parent)
: QObject(parent)
......@@ -38,43 +39,43 @@ PanelAgent::PanelAgent(QObject *parent)
{
watcher->setConnection(QDBusConnection::sessionBus());
watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
QDBusConnection::connectToBus(QDBusConnection::SessionBus, "kimpanel_bus").registerObject("/org/kde/impanel", this);
QDBusConnection::connectToBus(QDBusConnection::SessionBus, "kimpanel_bus").registerService("org.kde.impanel");
QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("kimpanel_bus")).registerObject(QStringLiteral("/org/kde/impanel"), this);
QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("kimpanel_bus")).registerService(QStringLiteral("org.kde.impanel"));
// directly connect to corresponding signal
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"Enable", this, SIGNAL(enable(bool)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"ShowPreedit", this, SIGNAL(showPreedit(bool)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"ShowAux", this, SIGNAL(showAux(bool)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"ShowLookupTable", this, SIGNAL(showLookupTable(bool)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdateLookupTableCursor", this, SIGNAL(updateLookupTableCursor(int)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("Enable"), this, SIGNAL(enable(bool)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("ShowPreedit"), this, SIGNAL(showPreedit(bool)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("ShowAux"), this, SIGNAL(showAux(bool)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("ShowLookupTable"), this, SIGNAL(showLookupTable(bool)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdateLookupTableCursor"), this, SIGNAL(updateLookupTableCursor(int)));
// do some serialization
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdateLookupTable", this, SLOT(UpdateLookupTable(QStringList,
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdateLookupTable"), this, SLOT(UpdateLookupTable(QStringList,
QStringList, QStringList, bool, bool)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdatePreeditCaret", this, SIGNAL(updatePreeditCaret(int)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdatePreeditText", this, SLOT(UpdatePreeditText(QString, QString)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdateAux", this, SLOT(UpdateAux(QString, QString)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdateSpotLocation", this, SIGNAL(updateSpotLocation(int, int)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdateScreen", this, SLOT(UpdateScreen(int)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"UpdateProperty", this, SLOT(UpdateProperty(QString)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"RegisterProperties", this, SLOT(RegisterProperties(QStringList)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"ExecDialog", this, SLOT(ExecDialog(QString)));
QDBusConnection("kimpanel_bus").connect("", "", "org.kde.kimpanel.inputmethod",
"ExecMenu", this, SLOT(ExecMenu(QStringList)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdatePreeditCaret"), this, SIGNAL(updatePreeditCaret(int)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdatePreeditText"), this, SLOT(UpdatePreeditText(QString, QString)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdateAux"), this, SLOT(UpdateAux(QString, QString)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdateSpotLocation"), this, SIGNAL(updateSpotLocation(int, int)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdateScreen"), this, SLOT(UpdateScreen(int)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("UpdateProperty"), this, SLOT(UpdateProperty(QString)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("RegisterProperties"), this, SLOT(RegisterProperties(QStringList)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("ExecDialog"), this, SLOT(ExecDialog(QString)));
QDBusConnection(QStringLiteral("kimpanel_bus")).connect(QString(), QString(), QStringLiteral("org.kde.kimpanel.inputmethod"),
QStringLiteral("ExecMenu"), this, SLOT(ExecMenu(QStringList)));
connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(serviceUnregistered(QString)));
}
......@@ -82,7 +83,7 @@ PanelAgent::PanelAgent(QObject *parent)
PanelAgent::~PanelAgent()
{
// destructor
QDBusConnection::disconnectFromBus("kimpanel_bus");
QDBusConnection::disconnectFromBus(QStringLiteral("kimpanel_bus"));
}
void PanelAgent::serviceUnregistered(const QString& service)
......
......@@ -58,11 +58,11 @@ struct KimpanelProperty {
QVariantMap toMap() const {
QVariantMap map;
map["key"] = key;
map["label"] = label;
map["icon"] = icon;
map["tip"] = tip;
map["hint"] = hint;
map[QStringLiteral("key")] = key;
map[QStringLiteral("label")] = label;
map[QStringLiteral("icon")] = icon;
map[QStringLiteral("tip")] = tip;
map[QStringLiteral("hint")] = hint;
return map;
}
};
......
......@@ -31,7 +31,7 @@
#include <Plasma/DataContainer>
KimpanelEngine::KimpanelEngine(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args), m_panelAgent(0)
: Plasma::DataEngine(parent, args), m_panelAgent(nullptr)
{
init();
}
......@@ -48,9 +48,9 @@ void KimpanelEngine::init()
{
m_panelAgent = new PanelAgent(this);
KimpanelInputPanelContainer* inputpanelSource = new KimpanelInputPanelContainer(this, m_panelAgent);
inputpanelSource->setObjectName(INPUTPANEL_SOURCE_NAME);
inputpanelSource->setObjectName(QLatin1String(INPUTPANEL_SOURCE_NAME));
KimpanelStatusBarContainer* statusbarSource = new KimpanelStatusBarContainer(this, m_panelAgent);
statusbarSource->setObjectName(STATUSBAR_SOURCE_NAME);
statusbarSource->setObjectName(QLatin1String(STATUSBAR_SOURCE_NAME));
addSource(inputpanelSource);
addSource(statusbarSource);
this->m_panelAgent->created();
......@@ -60,11 +60,11 @@ void KimpanelEngine::init()
Plasma::Service* KimpanelEngine::serviceForSource(const QString& source)
{
if (source == INPUTPANEL_SOURCE_NAME) {
if (source == QLatin1String(INPUTPANEL_SOURCE_NAME)) {
KimpanelInputPanelContainer* container = qobject_cast< KimpanelInputPanelContainer* >(containerForSource(source));
if (container)
return container->service(this);
} else if (source == STATUSBAR_SOURCE_NAME) {
} else if (source == QLatin1String(STATUSBAR_SOURCE_NAME)) {
KimpanelStatusBarContainer* container = qobject_cast< KimpanelStatusBarContainer* >(containerForSource(source));
if (container)
return container->service(this);
......
......@@ -41,7 +41,7 @@ KimpanelInputPanelContainer::KimpanelInputPanelContainer(QObject* parent, PanelA
Plasma::Service* KimpanelInputPanelContainer::service(QObject* parent)
{
KimpanelService *controller = new KimpanelService(parent, INPUTPANEL_SOURCE_NAME, m_panelAgent);
KimpanelService *controller = new KimpanelService(parent, QLatin1String(INPUTPANEL_SOURCE_NAME), m_panelAgent);
connect(this, SIGNAL(updateRequested(DataContainer*)),
controller, SLOT(enableKimpanelOperations()));
return controller;
......@@ -50,20 +50,20 @@ Plasma::Service* KimpanelInputPanelContainer::service(QObject* parent)
void KimpanelInputPanelContainer::updateAux(const QString& text, const QList< TextAttribute >& attrList)
{
Q_UNUSED(attrList);
setData("AuxText", text);
setData(QStringLiteral("AuxText"), text);
checkForUpdate();
}
void KimpanelInputPanelContainer::updatePreeditText(const QString& text, const QList<TextAttribute>& attrList)
{
Q_UNUSED(attrList);
setData("PreeditText", text);
setData(QStringLiteral("PreeditText"), text);
checkForUpdate();
}
void KimpanelInputPanelContainer::updatePreeditCaret(int pos)
{
setData("CaretPos", pos);
setData(QStringLiteral("CaretPos"), pos);
checkForUpdate();
}
......@@ -72,13 +72,13 @@ void KimpanelInputPanelContainer::updateLookupTable(const KimpanelLookupTable& l
QVariantList candidateList;
Q_FOREACH(const KimpanelLookupTable::Entry & entry, lookupTable.entries) {
QVariantMap map;
map["label"] = entry.label;
map["text"] = entry.text;
map[QStringLiteral("label")] = entry.label;
map[QStringLiteral("text")] = entry.text;
candidateList += map;
}
setData("LookupTable", candidateList);
setData("HasPrev", lookupTable.has_prev);
setData("HasNext", lookupTable.has_next);
setData(QStringLiteral("LookupTable"), candidateList);
setData(QStringLiteral("HasPrev"), lookupTable.has_prev);
setData(QStringLiteral("HasNext"), lookupTable.has_next);
checkForUpdate();
}
......@@ -89,31 +89,31 @@ void KimpanelInputPanelContainer::updateSpotLocation(int x, int y)
void KimpanelInputPanelContainer::updateSpotRect(int x, int y, int w, int h)
{
setData("Position", QRect(x, y, w, h));
setData(QStringLiteral("Position"), QRect(x, y, w, h));
checkForUpdate();
}
void KimpanelInputPanelContainer::showAux(bool visible)
{
setData("AuxVisible", visible);
setData(QStringLiteral("AuxVisible"), visible);
checkForUpdate();
}
void KimpanelInputPanelContainer::showPreedit(bool visible)
{
setData("PreeditVisible", visible);
setData(QStringLiteral("PreeditVisible"), visible);
checkForUpdate();
}
void KimpanelInputPanelContainer::showLookupTable(bool visible)
{
setData("LookupTableVisible", visible);
setData(QStringLiteral("LookupTableVisible"), visible);
checkForUpdate();
}
void KimpanelInputPanelContainer::updateLookupTableCursor(int cursor)
{
setData("LookupTableCursor", cursor);
setData(QStringLiteral("LookupTableCursor"), cursor);
checkForUpdate();
}
......@@ -122,15 +122,15 @@ void KimpanelInputPanelContainer::updateLookupTableFull(const KimpanelLookupTabl
QVariantList candidateList;
Q_FOREACH(const KimpanelLookupTable::Entry & entry, lookupTable.entries) {
QVariantMap map;
map["label"] = entry.label;
map["text"] = entry.text;
map[QStringLiteral("label")] = entry.label;
map[QStringLiteral("text")] = entry.text;
candidateList += map;
}
setData("LookupTable", candidateList);
setData("HasPrev", lookupTable.has_prev);
setData("HasNext", lookupTable.has_next);
setData("LookupTableCursor", cursor);
setData("LookupTableLayout", layout);
setData(QStringLiteral("LookupTable"), candidateList);
setData(QStringLiteral("HasPrev"), lookupTable.has_prev);
setData(QStringLiteral("HasNext"), lookupTable.has_next);
setData(QStringLiteral("LookupTableCursor"), cursor);
setData(QStringLiteral("LookupTableLayout"), layout);
checkForUpdate();
}
\ No newline at end of file
}
......@@ -31,7 +31,7 @@ class KimpanelInputPanelContainer : public Plasma::DataContainer
Q_OBJECT
public:
KimpanelInputPanelContainer(QObject* parent, PanelAgent* panelAgent);
Plasma::Service* service(QObject* parent = 0);
Plasma::Service* service(QObject* parent = nullptr);
protected Q_SLOTS:
void updatePreeditText(const QString& text, const QList<TextAttribute>& attrList);
......
......@@ -33,30 +33,30 @@ KimpanelJob::KimpanelJob(PanelAgent* panelAgent,
void KimpanelJob::start()
{
const QString operation(operationName());
if (operation == "LookupTablePageUp") {
if (operation == QLatin1String("LookupTablePageUp")) {
m_panelAgent->lookupTablePageUp();
} else if (operation == "LookupTablePageDown") {
} else if (operation == QLatin1String("LookupTablePageDown")) {
m_panelAgent->lookupTablePageDown();
} else if (operation == "MovePreeditCaret") {
if (parameters().contains("position")) {
int position = parameters()["position"].toInt();
} else if (operation == QLatin1String("MovePreeditCaret")) {
if (parameters().contains(QStringLiteral("position"))) {
int position = parameters()[QStringLiteral("position")].toInt();
m_panelAgent->movePreeditCaret(position);
}
} else if (operation == "SelectCandidate") {
if (parameters().contains("candidate")) {
int candidate = parameters()["candidate"].toInt();
} else if (operation == QLatin1String("SelectCandidate")) {
if (parameters().contains(QStringLiteral("candidate"))) {
int candidate = parameters()[QStringLiteral("candidate")].toInt();
m_panelAgent->selectCandidate(candidate);
}
} else if (operation == "TriggerProperty") {
if (parameters().contains("key")) {
QString key = parameters()["key"].toString();
} else if (operation == QLatin1String("TriggerProperty")) {
if (parameters().contains(QStringLiteral("key"))) {
QString key = parameters()[QStringLiteral("key")].toString();
m_panelAgent->triggerProperty(key);
}
} else if (operation == "ReloadConfig") {
} else if (operation == QLatin1String("ReloadConfig")) {
m_panelAgent->reloadConfig();
} else if (operation == "Configure") {
} else if (operation == QLatin1String("Configure")) {
m_panelAgent->configure();
} else if (operation == "Exit") {
} else if (operation == QLatin1String("Exit")) {
m_panelAgent->exit();
}
}
......@@ -33,7 +33,7 @@ class KimpanelJob : public Plasma::ServiceJob
public:
KimpanelJob(PanelAgent* panelAgent, const QString& destination,
const QString& operation, const QMap< QString, QVariant >& parameters, QObject* parent = 0);
const QString& operation, const QMap< QString, QVariant >& parameters, QObject* parent = nullptr);
void start() override;
private:
......
......@@ -24,7 +24,7 @@
KimpanelService::KimpanelService(QObject* parent, const QString& name, PanelAgent* panelAgent):
Service(parent), m_panelAgent(panelAgent)
{
setName("kimpanel");
setName(QStringLiteral("kimpanel"));
setObjectName(name);
setDestination(name);
enableKimpanelOperations();
......@@ -32,16 +32,16 @@ KimpanelService::KimpanelService(QObject* parent, const QString& name, PanelAgen
void KimpanelService::enableKimpanelOperations()
{
if (destination() == INPUTPANEL_SOURCE_NAME) {
setOperationEnabled("LookupTablePageUp", true);
setOperationEnabled("LookupTablePageDown", true);
setOperationEnabled("MovePreeditCaret", true);
setOperationEnabled("SelectCandidate", true);
} else if (destination() == STATUSBAR_SOURCE_NAME) {
setOperationEnabled("TriggerProperty", true);
setOperationEnabled("Exit", true);
setOperationEnabled("ReloadConfig", true);
setOperationEnabled("Configure", true);
if (destination() == QLatin1String(INPUTPANEL_SOURCE_NAME)) {
setOperationEnabled(QStringLiteral("LookupTablePageUp"), true);
setOperationEnabled(QStringLiteral("LookupTablePageDown"), true);
setOperationEnabled(QStringLiteral("MovePreeditCaret"), true);
setOperationEnabled(QStringLiteral("SelectCandidate"), true);
} else if (destination() == QLatin1String(STATUSBAR_SOURCE_NAME)) {
setOperationEnabled(QStringLiteral("TriggerProperty"), true);
setOperationEnabled(QStringLiteral("Exit"), true);
setOperationEnabled(QStringLiteral("ReloadConfig"), true);
setOperationEnabled(QStringLiteral("Configure"), true);
}
}
......
......@@ -34,7 +34,7 @@ KimpanelStatusBarContainer::KimpanelStatusBarContainer(QObject* parent, PanelAge
Plasma::Service* KimpanelStatusBarContainer::service(QObject* parent)
{
KimpanelService *controller = new KimpanelService(parent, STATUSBAR_SOURCE_NAME, m_panelAgent);
KimpanelService *controller = new KimpanelService(parent, QLatin1String(STATUSBAR_SOURCE_NAME), m_panelAgent);
connect(this, SIGNAL(updateRequested(DataContainer*)),
controller, SLOT(enableKimpanelOperations()));
return controller;
......@@ -50,7 +50,7 @@ void KimpanelStatusBarContainer::updateProperty(const KimpanelProperty& property
Q_FOREACH(const KimpanelProperty & prop, m_props) {
varList << prop.toMap();
}
setData("Properties", varList);
setData(QStringLiteral("Properties"), varList);
checkForUpdate();
break;
}
......@@ -64,7 +64,7 @@ void KimpanelStatusBarContainer::registerProperties(const QList< KimpanelPropert
Q_FOREACH(const KimpanelProperty & prop, m_props) {
varList << prop.toMap();
}
setData("Properties", varList);
setData(QStringLiteral("Properties"), varList);
checkForUpdate();
}
......@@ -75,9 +75,9 @@ void KimpanelStatusBarContainer::execMenu(const QList< KimpanelProperty >& props
varList << prop.toMap();
}
QVariantMap map;
map["props"] = varList;
map["timestamp"] = QDateTime::currentMSecsSinceEpoch();
setData("Menu", map);
map[QStringLiteral("props")] = varList;
map[QStringLiteral("timestamp")] = QDateTime::currentMSecsSinceEpoch();
setData(QStringLiteral("Menu"), map);
checkForUpdate();
}
......
......@@ -31,7 +31,7 @@ class KimpanelStatusBarContainer : public Plasma::DataContainer
Q_OBJECT
public:
KimpanelStatusBarContainer(QObject* parent, PanelAgent* panelAgent);
Plasma::Service* service(QObject* parent = 0);
Plasma::Service* service(QObject* parent = nullptr);
protected Q_SLOTS:
void updateProperty(const KimpanelProperty& property);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment