1 /*****************************************************************************
2 * dbusadaptor.cpp - QStarDict, a StarDict clone written with using Qt *
3 * Copyright (C) 2007 Alexander Rodin *
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. *
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. *
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 *****************************************************************************/
20 #include "dbusadaptor.h"
22 #include <QDBusConnection>
23 #include "application.h"
24 #include "mainwindow.h"
25 #include "popupwindow.h"
30 DBusAdaptor::DBusAdaptor(MainWindow *mainWindow)
31 : QDBusAbstractAdaptor(mainWindow), m_mainWindow(mainWindow)
33 QDBusConnection connection = QDBusConnection::sessionBus();
34 connection.registerService("org.qstardict.dbus");
35 connection.registerObject("/qstardict", mainWindow);
38 bool DBusAdaptor::mainWindowVisible() const
40 return m_mainWindow->isVisible();
43 void DBusAdaptor::setMainWindowVisible(bool visible)
45 m_mainWindow->setVisible(visible);
48 void DBusAdaptor::showTranslation(const QString &text)
50 m_mainWindow->showTranslation(text);
53 void DBusAdaptor::showPopup(const QString &text)
55 Application::instance()->popupWindow()->showTranslation(text);
58 QString DBusAdaptor::translate(const QString &text)
60 return Application::instance()->dictCore()->translate(text);
63 QString DBusAdaptor::translateHtml(const QString &text)
65 return Application::instance()->dictCore()->translate(text);
70 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc