Debian Codegraph @

qt5/dbusaddons/fcitxqtkeyboardlayout.cpp

raw
1 /***************************************************************************
2 * Copyright (C) 2011~2012 by CSSlayer *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
19
20 // Qt
21 #include <QDBusArgument>
22 #include <QDBusMetaType>
23
24 // self
25 #include "fcitxqtkeyboardlayout.h"
26
27 const QString &FcitxQtKeyboardLayout::layout() const { return m_layout; }
28 const QString &FcitxQtKeyboardLayout::langCode() const { return m_langCode; }
29 const QString &FcitxQtKeyboardLayout::name() const { return m_name; }
30
31 const QString &FcitxQtKeyboardLayout::variant() const { return m_variant; }
32
33 void FcitxQtKeyboardLayout::setLayout(const QString &layout) {
34 m_layout = layout;
35 }
36
37 void FcitxQtKeyboardLayout::setLangCode(const QString &lang) {
38 m_langCode = lang;
39 }
40
41 void FcitxQtKeyboardLayout::setName(const QString &name) { m_name = name; }
42
43 void FcitxQtKeyboardLayout::setVariant(const QString &variant) {
44 m_variant = variant;
45 }
46
47 void FcitxQtKeyboardLayout::registerMetaType() {
48 qRegisterMetaType<FcitxQtKeyboardLayout>("FcitxQtKeyboardLayout");
49 qDBusRegisterMetaType<FcitxQtKeyboardLayout>();
50 qRegisterMetaType<FcitxQtKeyboardLayoutList>("FcitxQtKeyboardLayoutList");
51 qDBusRegisterMetaType<FcitxQtKeyboardLayoutList>();
52 }
53
54 FCITXQTDBUSADDONS_EXPORT
55 QDBusArgument &operator<<(QDBusArgument &argument,
56 const FcitxQtKeyboardLayout &layout) {
57 argument.beginStructure();
58 argument << layout.layout();
59 argument << layout.variant();
60 argument << layout.name();
61 argument << layout.langCode();
62 argument.endStructure();
63 return argument;
64 }
65
66 FCITXQTDBUSADDONS_EXPORT
67 const QDBusArgument &operator>>(const QDBusArgument &argument,
68 FcitxQtKeyboardLayout &layout) {
69 QString l;
70 QString variant;
71 QString name;
72 QString langCode;
73 argument.beginStructure();
74 argument >> l >> variant >> name >> langCode;
75 argument.endStructure();
76 layout.setLayout(l);
77 layout.setVariant(variant);
78 layout.setName(name);
79 layout.setLangCode(langCode);
80 return argument;
81 }