diff --git a/dataengines/kimpanel/kimpanelagent.cpp b/dataengines/kimpanel/kimpanelagent.cpp index a39f7131e..b406a9852 100644 --- a/dataengines/kimpanel/kimpanelagent.cpp +++ b/dataengines/kimpanel/kimpanelagent.cpp @@ -1,296 +1,297 @@ /*************************************************************************** * Copyright (C) 2009 by Wang Hoi * * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "kimpanelagent.h" #include "impaneladaptor.h" // Qt #include #include #include #include #include #include #include +#include PanelAgent::PanelAgent(QObject *parent) : QObject(parent) ,adaptor(new ImpanelAdaptor(this)) ,adaptor2(new Impanel2Adaptor(this)) ,watcher(new QDBusServiceWatcher(this)) { 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))); } PanelAgent::~PanelAgent() { // destructor - QDBusConnection::disconnectFromBus("kimpanel_bus"); + QDBusConnection::disconnectFromBus(QStringLiteral("kimpanel_bus")); } void PanelAgent::serviceUnregistered(const QString& service) { if (service == m_currentService) { watcher->setWatchedServices(QStringList()); cached_props.clear(); m_currentService = QString(); emit showAux(false); emit showPreedit(false); emit showLookupTable(false); emit registerProperties(QList()); } } void PanelAgent::configure() { emit Configure(); } void PanelAgent::lookupTablePageDown() { emit LookupTablePageDown(); } void PanelAgent::lookupTablePageUp() { emit LookupTablePageUp(); } void PanelAgent::movePreeditCaret(int pos) { emit MovePreeditCaret(pos); } void PanelAgent::triggerProperty(const QString& key) { emit TriggerProperty(key); } void PanelAgent::selectCandidate(int idx) { emit SelectCandidate(idx); } static QList String2AttrList(const QString &str) { QList result; if (str.isEmpty()) { return result; } foreach(const QString & s, str.split(QLatin1Char(';'))) { TextAttribute attr; QStringList list = s.split(QLatin1Char(':')); if (list.size() < 4) continue; switch (list.at(0).toInt()) { case 0: attr.type = TextAttribute::None; break; case 1: attr.type = TextAttribute::Decorate; break; case 2: attr.type = TextAttribute::Foreground; break; case 3: attr.type = TextAttribute::Background; break; default: attr.type = TextAttribute::None; } attr.start = list.at(1).toInt(); attr.length = list.at(2).toInt(); attr.value = list.at(3).toInt(); result << attr; } return result; } static KimpanelProperty String2Property(const QString &str) { KimpanelProperty result; QStringList list = str.split(QLatin1Char(':')); if (list.size() < 4) return result; result.key = list.at(0); result.label = list.at(1); result.icon = list.at(2); result.tip = list.at(3); result.hint = list.size() > 4 ? list.at(4) : QString(); return result; } static KimpanelLookupTable Args2LookupTable(const QStringList &labels, const QStringList &candis, const QStringList &attrs, bool has_prev, bool has_next) { Q_ASSERT(labels.size() == candis.size()); Q_ASSERT(labels.size() == attrs.size()); KimpanelLookupTable result; for (int i = 0; i < labels.size(); i++) { KimpanelLookupTable::Entry entry; entry.label = labels.at(i); entry.text = candis.at(i); entry.attr = String2AttrList(attrs.at(i)); result.entries << entry; } result.has_prev = has_prev; result.has_next = has_next; return result; } void PanelAgent::created() { emit PanelCreated(); emit PanelCreated2(); } void PanelAgent::exit() { emit Exit(); } void PanelAgent::reloadConfig() { emit ReloadConfig(); } void PanelAgent::UpdateLookupTable(const QStringList &labels, const QStringList &candis, const QStringList &attrlists, bool has_prev, bool has_next) { emit updateLookupTable(Args2LookupTable(labels, candis, attrlists, has_prev, has_next)); } void PanelAgent::UpdatePreeditText(const QString &text, const QString &attr) { emit updatePreeditText(text, String2AttrList(attr)); } void PanelAgent::UpdateAux(const QString &text, const QString &attr) { emit updateAux(text, String2AttrList(attr)); } void PanelAgent::UpdateScreen(int screen_id) { Q_UNUSED(screen_id); } void PanelAgent::UpdateProperty(const QString &prop) { emit updateProperty(String2Property(prop)); } void PanelAgent::RegisterProperties(const QStringList &props) { const QDBusMessage& msg = message(); if (msg.service() != m_currentService) { watcher->removeWatchedService(m_currentService); if (m_currentService.isEmpty()) { emit PanelRegistered(); } m_currentService = msg.service(); watcher->addWatchedService(m_currentService); } if (cached_props != props) { cached_props = props; QList list; foreach(const QString & prop, props) { list << String2Property(prop); } emit registerProperties(list); } } void PanelAgent::ExecDialog(const QString &prop) { emit execDialog(String2Property(prop)); } void PanelAgent::ExecMenu(const QStringList &entries) { QList list; foreach(const QString & entry, entries) { list << String2Property(entry); } emit execMenu(list); } void PanelAgent::SetSpotRect(int x, int y, int w, int h) { emit updateSpotRect(x, y, w, h); } void PanelAgent::SetLookupTable(const QStringList& labels, const QStringList& candis, const QStringList& attrlists, bool hasPrev, bool hasNext, int cursor, int layout) { emit updateLookupTableFull(Args2LookupTable(labels, candis, attrlists, hasPrev, hasNext), cursor, layout); } diff --git a/dataengines/kimpanel/kimpanelagenttype.h b/dataengines/kimpanel/kimpanelagenttype.h index 18b3044ce..6fa518822 100644 --- a/dataengines/kimpanel/kimpanelagenttype.h +++ b/dataengines/kimpanel/kimpanelagenttype.h @@ -1,82 +1,82 @@ /*************************************************************************** * Copyright (C) 2009 by Wang Hoi * * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef KIMPANEL_AGENTTYPE_H #define KIMPANEL_AGENTTYPE_H // Qt #include #include #include struct TextAttribute { enum Type { None, Decorate, Foreground, Background }; Type type; int start; int length; int value; }; struct KimpanelProperty { KimpanelProperty() { } KimpanelProperty(QString key, QString label, QString icon, QString tip, QString hint) { this->key = key; this->label = label; this->tip = tip; this->icon = icon; this->hint = hint; } QString key; QString label; QString icon; QString tip; QString hint; 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; } }; struct KimpanelLookupTable { struct Entry { QString label; QString text; QList attr; }; QList entries; bool has_prev; bool has_next; }; #endif // KIMPANEL_AGENTTYPE_H diff --git a/dataengines/kimpanel/kimpaneldataengine.cpp b/dataengines/kimpanel/kimpaneldataengine.cpp index 02d6f937b..2abf79b82 100644 --- a/dataengines/kimpanel/kimpaneldataengine.cpp +++ b/dataengines/kimpanel/kimpaneldataengine.cpp @@ -1,78 +1,78 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "kimpaneldataengine.h" #include "kimpanelagent.h" #include "kimpanelservice.h" #include "kimpanelinputpanelcontainer.h" #include "kimpanelstatusbarcontainer.h" #include "config-kimpanel.h" #include #include // Plasma #include KimpanelEngine::KimpanelEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent, args), m_panelAgent(0) + : Plasma::DataEngine(parent, args), m_panelAgent(nullptr) { init(); } static void ibusPanelLauncher() { // lets just blindly start the launcher. no need to use ifdef const QString path = QStringLiteral(KIMPANEL_LIBEXEC_DIR"/kimpanel-ibus-panel-launcher"); if (QFile::exists(path)) { QProcess::startDetached(path, QStringList()); } } 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(); ibusPanelLauncher(); } 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); } return Plasma::DataEngine::serviceForSource(source); } K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(kimpanel, KimpanelEngine, "plasma-dataengine-kimpanel.json") #include "kimpaneldataengine.moc" diff --git a/dataengines/kimpanel/kimpanelinputpanelcontainer.cpp b/dataengines/kimpanel/kimpanelinputpanelcontainer.cpp index f63597df1..73a944e0d 100644 --- a/dataengines/kimpanel/kimpanelinputpanelcontainer.cpp +++ b/dataengines/kimpanel/kimpanelinputpanelcontainer.cpp @@ -1,136 +1,136 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "kimpanelinputpanelcontainer.h" #include "kimpanelservice.h" #include "kimpanelagent.h" #include "kimpaneldataengine.h" KimpanelInputPanelContainer::KimpanelInputPanelContainer(QObject* parent, PanelAgent* panelAgent): DataContainer(parent), m_panelAgent(panelAgent) { connect(m_panelAgent, SIGNAL(updateAux(QString, QList)), this, SLOT(updateAux(QString, QList))); connect(m_panelAgent, SIGNAL(updatePreeditText(QString, QList)), this, SLOT(updatePreeditText(QString, QList))); connect(m_panelAgent, SIGNAL(updatePreeditCaret(int)), this, SLOT(updatePreeditCaret(int))); connect(m_panelAgent, SIGNAL(updateLookupTable(KimpanelLookupTable)), this, SLOT(updateLookupTable(KimpanelLookupTable))); connect(m_panelAgent, SIGNAL(updateSpotLocation(int,int)), this, SLOT(updateSpotLocation(int,int))); connect(m_panelAgent, SIGNAL(updateSpotRect(int, int, int, int)), this, SLOT(updateSpotRect(int, int, int, int))); connect(m_panelAgent, SIGNAL(showAux(bool)), this, SLOT(showAux(bool))); connect(m_panelAgent, SIGNAL(showPreedit(bool)), this, SLOT(showPreedit(bool))); connect(m_panelAgent, SIGNAL(showLookupTable(bool)), this, SLOT(showLookupTable(bool))); connect(m_panelAgent, SIGNAL(updateLookupTableCursor(int)), this, SLOT(updateLookupTableCursor(int))); connect(m_panelAgent, SIGNAL(updateLookupTableFull(KimpanelLookupTable,int,int)), this, SLOT(updateLookupTableFull(KimpanelLookupTable,int,int))); } 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; } 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& 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(); } void KimpanelInputPanelContainer::updateLookupTable(const KimpanelLookupTable& lookupTable) { 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(); } void KimpanelInputPanelContainer::updateSpotLocation(int x, int y) { updateSpotRect(x, y, 0, 0); } 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(); } void KimpanelInputPanelContainer::updateLookupTableFull(const KimpanelLookupTable& lookupTable, int cursor, int layout) { 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 +} diff --git a/dataengines/kimpanel/kimpanelinputpanelcontainer.h b/dataengines/kimpanel/kimpanelinputpanelcontainer.h index 6ffbc0ce6..f3b339326 100644 --- a/dataengines/kimpanel/kimpanelinputpanelcontainer.h +++ b/dataengines/kimpanel/kimpanelinputpanelcontainer.h @@ -1,53 +1,53 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef KIMPANEL_INPUTPANEL_CONTAINER_H #define KIMPANEL_INPUTPANEL_CONTAINER_H #include "kimpanelagenttype.h" #include class PanelAgent; class KimpanelService; 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& attrList); void updateAux(const QString& text, const QList& attrList); void updatePreeditCaret(int pos); void updateLookupTable(const KimpanelLookupTable& lookupTable); void updateLookupTableFull(const KimpanelLookupTable& lookupTable,int cursor, int layout); void updateSpotLocation(int x, int y); void updateSpotRect(int x, int y, int w, int h); void showAux(bool visible); void showPreedit(bool visible); void showLookupTable(bool visible); void updateLookupTableCursor(int cursor); private: PanelAgent* m_panelAgent; }; #endif diff --git a/dataengines/kimpanel/kimpaneljob.cpp b/dataengines/kimpanel/kimpaneljob.cpp index f938cf25a..af6ae81eb 100644 --- a/dataengines/kimpanel/kimpaneljob.cpp +++ b/dataengines/kimpanel/kimpaneljob.cpp @@ -1,62 +1,62 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "kimpaneljob.h" #include "kimpanelagent.h" KimpanelJob::KimpanelJob(PanelAgent* panelAgent, const QString& destination, const QString& operation, const QMap< QString, QVariant >& parameters, QObject* parent): Plasma::ServiceJob(destination, operation, parameters, parent), m_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(); } } diff --git a/dataengines/kimpanel/kimpaneljob.h b/dataengines/kimpanel/kimpaneljob.h index 08ec9b79a..34c2cf25d 100644 --- a/dataengines/kimpanel/kimpaneljob.h +++ b/dataengines/kimpanel/kimpaneljob.h @@ -1,44 +1,44 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef KIMPANEL_JOB_H #define KIMPANEL_JOB_H // Qt #include // Plasma #include class PanelAgent; class KimpanelJob : public Plasma::ServiceJob { Q_OBJECT 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: PanelAgent* m_panelAgent; }; #endif // KIMPANEL_JOB_H diff --git a/dataengines/kimpanel/kimpanelservice.cpp b/dataengines/kimpanel/kimpanelservice.cpp index 5a17c553e..1a4511b41 100644 --- a/dataengines/kimpanel/kimpanelservice.cpp +++ b/dataengines/kimpanel/kimpanelservice.cpp @@ -1,51 +1,51 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "kimpanelservice.h" #include "kimpaneljob.h" #include "kimpaneldataengine.h" KimpanelService::KimpanelService(QObject* parent, const QString& name, PanelAgent* panelAgent): Service(parent), m_panelAgent(panelAgent) { - setName("kimpanel"); + setName(QStringLiteral("kimpanel")); setObjectName(name); setDestination(name); enableKimpanelOperations(); } 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); } } Plasma::ServiceJob* KimpanelService::createJob(const QString &operation, QMap ¶meters) { return new KimpanelJob(m_panelAgent, destination(), operation, parameters, this); } diff --git a/dataengines/kimpanel/kimpanelstatusbarcontainer.cpp b/dataengines/kimpanel/kimpanelstatusbarcontainer.cpp index 64ae5f724..ecb0635c6 100644 --- a/dataengines/kimpanel/kimpanelstatusbarcontainer.cpp +++ b/dataengines/kimpanel/kimpanelstatusbarcontainer.cpp @@ -1,87 +1,87 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #include "kimpanelstatusbarcontainer.h" #include "kimpanelservice.h" #include "kimpanelagent.h" #include "kimpaneldataengine.h" KimpanelStatusBarContainer::KimpanelStatusBarContainer(QObject* parent, PanelAgent* panelAgent): DataContainer(parent), m_panelAgent(panelAgent) { connect(m_panelAgent, SIGNAL(updateProperty(KimpanelProperty)), this, SLOT(updateProperty(KimpanelProperty))); connect(m_panelAgent, SIGNAL(registerProperties(QList)), this, SLOT(registerProperties(QList))); connect(m_panelAgent, SIGNAL(execMenu(QList)), this, SLOT(execMenu(QList))); connect(m_panelAgent, SIGNAL(execDialog(KimpanelProperty)), this, SLOT(execDialog(KimpanelProperty))); } 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; } void KimpanelStatusBarContainer::updateProperty(const KimpanelProperty& property) { int i = 0; for (i = 0; i < m_props.size(); i ++) { if (m_props[i].key == property.key) { m_props[i] = property; QList varList; Q_FOREACH(const KimpanelProperty & prop, m_props) { varList << prop.toMap(); } - setData("Properties", varList); + setData(QStringLiteral("Properties"), varList); checkForUpdate(); break; } } } void KimpanelStatusBarContainer::registerProperties(const QList< KimpanelProperty >& props) { m_props = props; QList varList; Q_FOREACH(const KimpanelProperty & prop, m_props) { varList << prop.toMap(); } - setData("Properties", varList); + setData(QStringLiteral("Properties"), varList); checkForUpdate(); } void KimpanelStatusBarContainer::execMenu(const QList< KimpanelProperty >& props) { QList varList; Q_FOREACH(const KimpanelProperty & prop, 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(); } void KimpanelStatusBarContainer::execDialog(const KimpanelProperty& prop) { Q_UNUSED(prop) } diff --git a/dataengines/kimpanel/kimpanelstatusbarcontainer.h b/dataengines/kimpanel/kimpanelstatusbarcontainer.h index 2b83e5cae..b96ef78db 100644 --- a/dataengines/kimpanel/kimpanelstatusbarcontainer.h +++ b/dataengines/kimpanel/kimpanelstatusbarcontainer.h @@ -1,48 +1,48 @@ /*************************************************************************** * Copyright (C) 2011 by CSSlayer * * * * 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) any later version. * * * * 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, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef KIMPANEL_STATUSBAR_CONTAINER_H #define KIMPANEL_STATUSBAR_CONTAINER_H #include "kimpanelagenttype.h" #include class PanelAgent; class KimpanelService; 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); void registerProperties(const QList &props); void execDialog(const KimpanelProperty &prop); void execMenu(const QList &prop_list); private: PanelAgent* m_panelAgent; QList< KimpanelProperty > m_props; }; #endif