init
[qstardict] / qstardict / dbusadaptor.h
1 /*****************************************************************************
2  * dbusadaptor.h - QStarDict, a StarDict clone written with using Qt         *
3  * Copyright (C) 2007 Alexander Rodin                                        *
4  *                                                                           *
5  * This program is free software; you can redistribute it and/or modify      *
6  * it under the terms of the GNU General Public License as published by      *
7  * the Free Software Foundation; either version 2 of the License, or         *
8  * (at your option) any later version.                                       *
9  *                                                                           *
10  * This program is distributed in the hope that it will be useful,           *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
13  * GNU General Public License for more details.                              *
14  *                                                                           *
15  * You should have received a copy of the GNU General Public License along   *
16  * with this program; if not, write to the Free Software Foundation, Inc.,   *
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.               *
18  *****************************************************************************/
19
20 #ifndef DBUSADAPTOR_H
21 #define DBUSADAPTOR_H
22
23 #include <QDBusAbstractAdaptor>
24
25 namespace QStarDict
26 {
27
28 class MainWindow;
29
30 /**
31  * The DBusAdaptor class represents and QStarDict D-Bus interface.
32  */
33 class DBusAdaptor: public QDBusAbstractAdaptor
34 {
35     Q_OBJECT
36     Q_CLASSINFO("D-Bus Interface", "org.qstardict.dbus")
37     /**
38      * The main window visible property.
39      */
40     Q_PROPERTY(int mainWindowVisible READ mainWindowVisible WRITE setMainWindowVisible)
41
42     public:
43         /**
44          * Construct a DBusAdaptor.
45          */
46         DBusAdaptor(MainWindow *mainWindow);
47
48         /**
49          * Return true if main window is visible, otherwise return
50          * false.
51          */
52         bool mainWindowVisible() const;
53         /**
54          * Set visible state of main window.
55          */
56         void setMainWindowVisible(bool visible);
57
58     public slots:
59         /**
60          * Show main window with translation of text.
61          */
62         void showTranslation(const QString &text);
63         /**
64          * Show popup window with translation of text.
65          */
66         void showPopup(const QString &text);
67         /**
68          * Return a translation of text in plain text format.
69          */
70         QString translate(const QString &text);
71         /**
72          * Return a translation of text in HTML format.
73          */
74         QString translateHtml(const QString &text);
75
76     private:
77         MainWindow *m_mainWindow;
78 };
79
80 }
81
82 #endif // DBUSADAPTOR_H
83
84 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc
85