Changeset View
Changeset View
Standalone View
Standalone View
dataengines/kimpanel/kimpanelstatusbarcontainer.cpp
Show All 15 Lines | |||||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "kimpanelstatusbarcontainer.h" | 20 | #include "kimpanelstatusbarcontainer.h" | ||
21 | #include "kimpanelservice.h" | 21 | #include "kimpanelservice.h" | ||
22 | #include "kimpanelagent.h" | 22 | #include "kimpanelagent.h" | ||
23 | #include "kimpaneldataengine.h" | 23 | #include "kimpaneldataengine.h" | ||
24 | #include "input_sources.h" | ||||
25 | #include "layout_list_models.h" | ||||
26 | | ||||
27 | #include <QDebug> | ||||
24 | 28 | | |||
25 | KimpanelStatusBarContainer::KimpanelStatusBarContainer(QObject* parent, PanelAgent* panelAgent): | 29 | KimpanelStatusBarContainer::KimpanelStatusBarContainer(QObject* parent, PanelAgent* panelAgent): | ||
26 | DataContainer(parent), | 30 | DataContainer(parent), | ||
27 | m_panelAgent(panelAgent) | 31 | m_panelAgent(panelAgent) | ||
28 | { | 32 | { | ||
29 | connect(m_panelAgent, SIGNAL(updateProperty(KimpanelProperty)), this, SLOT(updateProperty(KimpanelProperty))); | 33 | connect(m_panelAgent, SIGNAL(updateProperty(KimpanelProperty)), this, SLOT(updateProperty(KimpanelProperty))); | ||
30 | connect(m_panelAgent, SIGNAL(registerProperties(QList<KimpanelProperty>)), this, SLOT(registerProperties(QList<KimpanelProperty>))); | 34 | connect(m_panelAgent, SIGNAL(registerProperties(QList<KimpanelProperty>)), this, SLOT(registerProperties(QList<KimpanelProperty>))); | ||
31 | connect(m_panelAgent, SIGNAL(execMenu(QList<KimpanelProperty>)), this, SLOT(execMenu(QList<KimpanelProperty>))); | 35 | connect(m_panelAgent, SIGNAL(execMenu(QList<KimpanelProperty>)), this, SLOT(execMenu(QList<KimpanelProperty>))); | ||
32 | connect(m_panelAgent, SIGNAL(execDialog(KimpanelProperty)), this, SLOT(execDialog(KimpanelProperty))); | 36 | connect(m_panelAgent, SIGNAL(execDialog(KimpanelProperty)), this, SLOT(execDialog(KimpanelProperty))); | ||
37 | connect(m_panelAgent, &PanelAgent::showPlasmoid, this, &KimpanelStatusBarContainer::showPlasmoid); | ||||
38 | connect(m_panelAgent, &PanelAgent::currentLayoutChanged, this, &KimpanelStatusBarContainer::setCurrentLayout); | ||||
39 | setData("LayoutList", QVariant::fromValue(panelAgent->models()->currentLayoutListModel())); | ||||
40 | setData("LayoutModels", QVariant::fromValue(panelAgent->models())); | ||||
41 | } | ||||
42 | | ||||
43 | void KimpanelStatusBarContainer::showPlasmoid(bool visible) | ||||
44 | { | ||||
45 | setData("Visibility", visible); | ||||
46 | checkForUpdate(); | ||||
47 | } | ||||
48 | | ||||
49 | void KimpanelStatusBarContainer::setCurrentLayout(const QString &tag, const QString &iconName) | ||||
50 | { | ||||
51 | qDebug() << tag << iconName; | ||||
52 | setData("CurrentLayoutIndex", m_panelAgent->models()->currentLayoutIndex()); | ||||
53 | setData("CurrentTag", tag); | ||||
54 | setData("CurrentIconName", iconName); | ||||
55 | checkForUpdate(); | ||||
33 | } | 56 | } | ||
34 | 57 | | |||
35 | Plasma::Service* KimpanelStatusBarContainer::service(QObject* parent) | 58 | Plasma::Service* KimpanelStatusBarContainer::service(QObject* parent) | ||
36 | { | 59 | { | ||
37 | KimpanelService *controller = new KimpanelService(parent, QLatin1String(STATUSBAR_SOURCE_NAME), m_panelAgent); | 60 | KimpanelService *controller = new KimpanelService(parent, QLatin1String(STATUSBAR_SOURCE_NAME), m_panelAgent); | ||
38 | connect(this, SIGNAL(updateRequested(DataContainer*)), | 61 | connect(this, SIGNAL(updateRequested(DataContainer*)), | ||
39 | controller, SLOT(enableKimpanelOperations())); | 62 | controller, SLOT(enableKimpanelOperations())); | ||
40 | return controller; | 63 | return controller; | ||
41 | } | 64 | } | ||
42 | 65 | | |||
43 | void KimpanelStatusBarContainer::updateProperty(const KimpanelProperty& property) | 66 | void KimpanelStatusBarContainer::updateProperty(const KimpanelProperty& property) | ||
44 | { | 67 | { | ||
45 | int i = 0; | 68 | for (int i = 0; i < m_props.size(); i++) { | ||
46 | for (i = 0; i < m_props.size(); i ++) { | | |||
47 | if (m_props[i].key == property.key) { | 69 | if (m_props[i].key == property.key) { | ||
48 | m_props[i] = property; | 70 | m_props[i] = property; | ||
49 | QList<QVariant> varList; | 71 | QList<QVariant> varList; | ||
50 | Q_FOREACH(const KimpanelProperty & prop, m_props) { | 72 | Q_FOREACH(const KimpanelProperty & prop, m_props) { | ||
73 | if (prop.key == "/Fcitx/logo" || prop.key == "/Fcitx/im") { | ||||
74 | continue; | ||||
75 | } | ||||
51 | varList << prop.toMap(); | 76 | varList << prop.toMap(); | ||
52 | } | 77 | } | ||
53 | setData(QStringLiteral("Properties"), varList); | 78 | setData(QStringLiteral("Properties"), varList); | ||
54 | checkForUpdate(); | 79 | checkForUpdate(); | ||
55 | break; | 80 | break; | ||
56 | } | 81 | } | ||
57 | } | 82 | } | ||
58 | } | 83 | } | ||
59 | 84 | | |||
60 | void KimpanelStatusBarContainer::registerProperties(const QList< KimpanelProperty >& props) | 85 | void KimpanelStatusBarContainer::registerProperties(const QList< KimpanelProperty >& props) | ||
61 | { | 86 | { | ||
62 | m_props = props; | 87 | m_props = props; | ||
63 | QList<QVariant> varList; | 88 | QList<QVariant> varList; | ||
64 | Q_FOREACH(const KimpanelProperty & prop, m_props) { | 89 | Q_FOREACH(const KimpanelProperty & prop, m_props) { | ||
90 | if (prop.key == "/Fcitx/logo" || prop.key == "/Fcitx/im") { | ||||
91 | continue; | ||||
92 | } | ||||
65 | varList << prop.toMap(); | 93 | varList << prop.toMap(); | ||
66 | } | 94 | } | ||
67 | setData(QStringLiteral("Properties"), varList); | 95 | setData(QStringLiteral("Properties"), varList); | ||
68 | checkForUpdate(); | 96 | checkForUpdate(); | ||
69 | } | 97 | } | ||
70 | 98 | | |||
71 | void KimpanelStatusBarContainer::execMenu(const QList< KimpanelProperty >& props) | 99 | void KimpanelStatusBarContainer::execMenu(const QList< KimpanelProperty >& props) | ||
72 | { | 100 | { | ||
Show All 15 Lines |