~ubuntu-branches/ubuntu/trusty/fcitx/trusty-proposed

« back to all changes in this revision

Viewing changes to src/lib/fcitx-qt/fcitxqtconnection.h

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-02-10 17:03:56 UTC
  • mfrom: (1.3.18) (33.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130210170356-2yuv6xy3ed378kn0
Tags: 1:4.2.7-1
* New upstream release.
* New binary packages:
  - fcitx-libs-gclient: D-Bus client library for Glib
  - fcitx-libs-qt: D-Bus client library for Qt
  - fcitx-module-quickphrase-editor: Quick Phrase editor module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2012~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
#ifndef FCITXQTCONNECTION_H
 
21
#define FCITXQTCONNECTION_H
 
22
 
 
23
#include "fcitxqt_export.h"
 
24
 
 
25
#include <QtCore/QObject>
 
26
 
 
27
class QDBusConnection;
 
28
 
 
29
class FcitxQtConnectionPrivate;
 
30
 
 
31
 
 
32
/**
 
33
 * dbus connection to fcitx
 
34
 **/
 
35
class FCITX_QT_EXPORT_API FcitxQtConnection : public QObject {
 
36
    Q_OBJECT
 
37
    Q_PROPERTY(bool autoReconnect READ autoReconnect WRITE setAutoReconnect)
 
38
    Q_PROPERTY(bool connected READ isConnected)
 
39
    Q_PROPERTY(QDBusConnection* connection READ connection)
 
40
    Q_PROPERTY(QString serviceName READ serviceName)
 
41
public:
 
42
    /**
 
43
     * create a new connection
 
44
     *
 
45
     * @param parent
 
46
     **/
 
47
    explicit FcitxQtConnection(QObject* parent = 0);
 
48
 
 
49
    /**
 
50
     * destroy the connection
 
51
     **/
 
52
    virtual ~FcitxQtConnection();
 
53
 
 
54
    /**
 
55
     * the connection will not start to work until you call this function
 
56
     * you may want to connect to the signal before you call this function
 
57
     **/
 
58
    void startConnection();
 
59
    void endConnection();
 
60
    /**
 
61
     * automatically reconnect if fcitx disappeared
 
62
     *
 
63
     * @param a ...
 
64
     * @return void
 
65
     **/
 
66
    void setAutoReconnect(bool a);
 
67
 
 
68
    /**
 
69
     * check this connection is doing automatical reconnect or not
 
70
     *
 
71
     * default value is true
 
72
     **/
 
73
    bool autoReconnect();
 
74
 
 
75
    /**
 
76
     * return the current dbus connection to fcitx, notice, the object return
 
77
     * by this function might be deteled if fcitx disappear, or might return 0
 
78
     * if fcitx is not running
 
79
     *
 
80
     * @return QDBusConnection*
 
81
     **/
 
82
    QDBusConnection* connection();
 
83
    /**
 
84
     * current fcitx dbus service name, can be used for create DBus proxy
 
85
     *
 
86
     * @return service name
 
87
     **/
 
88
    const QString& serviceName();
 
89
    /**
 
90
     * check its connected or not
 
91
     **/
 
92
    bool isConnected();
 
93
 
 
94
Q_SIGNALS:
 
95
    /**
 
96
     * this signal will be emitted upon fcitx appears
 
97
     **/
 
98
    void connected();
 
99
    /**
 
100
     * this signal will be emitted upon fcitx disappears
 
101
     *
 
102
     * it will come with connected in pair
 
103
     **/
 
104
    void disconnected();
 
105
 
 
106
private:
 
107
    FcitxQtConnectionPrivate * const d_ptr;
 
108
    Q_DECLARE_PRIVATE(FcitxQtConnection);
 
109
};
 
110
 
 
111
#endif // FCITXCONNECTION_H