Version fix
[qstardict] / qstardict / dbusadaptor.cpp
1 /*****************************************************************************
2  * dbusadaptor.cpp - 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 #include "dbusadaptor.h"
21
22 #include <QDBusConnection>
23 #include "application.h"
24 #include "mainwindow.h"
25 #include "popupwindow.h"
26
27 namespace QStarDict
28 {
29
30 DBusAdaptor::DBusAdaptor(MainWindow *mainWindow)
31     : QDBusAbstractAdaptor(mainWindow), m_mainWindow(mainWindow)
32 {
33     QDBusConnection connection = QDBusConnection::sessionBus();
34     connection.registerService("org.qstardict.dbus");
35     connection.registerObject("/qstardict", mainWindow);
36 }
37
38 bool DBusAdaptor::mainWindowVisible() const
39 {
40     return m_mainWindow->isVisible();
41 }
42
43 void DBusAdaptor::setMainWindowVisible(bool visible)
44 {
45     m_mainWindow->setVisible(visible);
46 }
47
48 void DBusAdaptor::showTranslation(const QString &text)
49 {
50     m_mainWindow->showTranslation(text);
51 }
52
53 void DBusAdaptor::showPopup(const QString &text)
54 {
55     Application::instance()->popupWindow()->showTranslation(text);
56 }
57
58 QString DBusAdaptor::translate(const QString &text)
59 {
60     return Application::instance()->dictCore()->translate(text);
61 }
62
63 QString DBusAdaptor::translateHtml(const QString &text)
64 {
65     return Application::instance()->dictCore()->translate(text);
66 }
67
68 }
69
70 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc
71