dbusadaptor.cpp 2.6 KB

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