application.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*****************************************************************************
  2. * application.h - QStarDict, a quasi-star dictionary *
  3. * Copyright (C) 2008-2019 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. #ifndef APPLICATION_H
  20. #define APPLICATION_H
  21. #include <QApplication>
  22. #ifdef QSTARDICT_WITH_TRANSLATIONS
  23. class QTranslator;
  24. #endif // QSTARDICT_WITH_TRANSLATIONS
  25. class QxtGlobalShortcut;
  26. namespace QStarDict
  27. {
  28. class DictCore;
  29. class PluginManager;
  30. class MainWindow;
  31. class PopupWindow;
  32. class Speaker;
  33. #ifdef QSTARDICT_WITH_TRAY_ICON
  34. class TrayIcon;
  35. #endif
  36. #ifdef QSTARDICT_WITH_DBUS
  37. class DBusAdaptor;
  38. #endif // QSTARDICT_WITH_DBUS
  39. /**
  40. * Main application class.
  41. */
  42. class Application: public QApplication
  43. {
  44. Q_OBJECT
  45. public:
  46. /**
  47. * Construct new QStarDict application.
  48. */
  49. Application(int &argc, char **argv);
  50. /**
  51. * Destructor.
  52. */
  53. ~Application();
  54. /**
  55. * Enter the main event loop and wait until exit().
  56. */
  57. int exec();
  58. /**
  59. * Returns a pointer to the application's QStarDict::Application instance.
  60. */
  61. static Application *instance()
  62. { return qobject_cast<Application*>(QCoreApplication::instance()); }
  63. /**
  64. * Returns a pointer to the DictCore instance.
  65. */
  66. DictCore *dictCore()
  67. { return m_dictCore; }
  68. /**
  69. * Returns pointer to PluginManager instance
  70. */
  71. PluginManager *pluginManager()
  72. { return m_pluginManager; }
  73. /**
  74. * Returns a pointer to the application's main window.
  75. */
  76. MainWindow *mainWindow()
  77. { return m_mainWindow; }
  78. /**
  79. * Returns a pointer to the application's popup window.
  80. */
  81. PopupWindow *popupWindow()
  82. { return m_popupWindow; }
  83. /**
  84. * Returns a pointer to the application's word speaker.
  85. */
  86. Speaker *speaker()
  87. { return m_speaker; }
  88. /**
  89. * Returns a pointer to the application's eSpeak speaker.
  90. */
  91. Speaker *espeakSpeaker()
  92. { return m_espeakSpeaker; }
  93. #ifdef QSTARDICT_WITH_TRAY_ICON
  94. /**
  95. * Returns a pointer to the tray icon.
  96. */
  97. TrayIcon *trayIcon()
  98. { return m_trayIcon; }
  99. #endif
  100. /**
  101. * Returns a pointer to the popupShortcut instance.
  102. */
  103. QxtGlobalShortcut *popupShortcut()
  104. { return m_popupShortcut; }
  105. /**
  106. * Returns a pointer to the switchScanningShortcut instance.
  107. */
  108. QxtGlobalShortcut *switchScanningShortcut()
  109. { return m_switchScanningShortcut; }
  110. #ifdef QSTARDICT_WITH_DBUS
  111. /**
  112. * Returns a pointer to the DBusAdaptor instance.
  113. */
  114. DBusAdaptor *dbusAdaptor()
  115. { return m_dbusAdaptor; }
  116. #endif // QSTARDICT_WITH_DBUS
  117. private:
  118. #ifdef QSTARDICT_WITH_TRANSLATIONS
  119. QTranslator *m_translator;
  120. QTranslator *m_qtTranslator;
  121. #endif // QSTARDICT_WITH_TRANSLATIONS
  122. DictCore *m_dictCore;
  123. PluginManager *m_pluginManager;
  124. MainWindow *m_mainWindow;
  125. PopupWindow *m_popupWindow;
  126. Speaker *m_speaker;
  127. Speaker *m_espeakSpeaker;
  128. #ifdef QSTARDICT_WITH_TRAY_ICON
  129. TrayIcon *m_trayIcon;
  130. #endif
  131. QxtGlobalShortcut *m_popupShortcut;
  132. QxtGlobalShortcut *m_switchScanningShortcut;
  133. #ifdef QSTARDICT_WITH_DBUS
  134. DBusAdaptor *m_dbusAdaptor;
  135. #endif // QSTARDICT_WITH_DBUS
  136. QString commandLineText();
  137. };
  138. }
  139. #endif // APPLICATION_H
  140. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent