application.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*****************************************************************************
  2. * application.h - QStarDict, a StarDict clone written using Qt *
  3. * Copyright (C) 2008 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. namespace QStarDict
  26. {
  27. class DictCore;
  28. class MainWindow;
  29. class PopupWindow;
  30. class Speaker;
  31. class TrayIcon;
  32. #ifdef QSTARDICT_WITH_DBUS
  33. class DBusAdaptor;
  34. #endif // QSTARDICT_WITH_DBUS
  35. /**
  36. * Main application class.
  37. */
  38. class Application: public QApplication
  39. {
  40. Q_OBJECT
  41. public:
  42. /**
  43. * Construct new QStarDict application.
  44. */
  45. Application(int &argc, char **argv);
  46. /**
  47. * Destructor.
  48. */
  49. ~Application();
  50. /**
  51. * Enter the main event loop and wait until exit().
  52. */
  53. int exec();
  54. /**
  55. * Returns a pointer to the application's QStarDict::Application instance.
  56. */
  57. static Application *instance()
  58. { return qobject_cast<Application*>(QCoreApplication::instance()); }
  59. /**
  60. * Returns a pointer to the DictCore instance.
  61. */
  62. DictCore *dictCore()
  63. { return m_dictCore; }
  64. /**
  65. * Returns a pointer to the application's main window.
  66. */
  67. MainWindow *mainWindow()
  68. { return m_mainWindow; }
  69. /**
  70. * Returns a pointer to the application's popup window.
  71. */
  72. PopupWindow *popupWindow()
  73. { return m_popupWindow; }
  74. /**
  75. * Returns a pointer to the application's speacker.
  76. */
  77. Speaker *speaker()
  78. { return m_speaker; }
  79. /**
  80. * Returns a pointer to the tray icon.
  81. */
  82. TrayIcon *trayIcon()
  83. { return m_trayIcon; }
  84. #ifdef QSTARDICT_WITH_DBUS
  85. /**
  86. * Returns a pointer to the DBusAdaptor instance.
  87. */
  88. DBusAdaptor *dbusAdaptor()
  89. { return m_dbusAdaptor; }
  90. #endif // QSTARDICT_WITH_DBUS
  91. private:
  92. #ifdef QSTARDICT_WITH_TRANSLATIONS
  93. QTranslator *m_translator;
  94. QTranslator *m_qtTranslator;
  95. #endif // QSTARDICT_WITH_TRANSLATIONS
  96. DictCore *m_dictCore;
  97. MainWindow *m_mainWindow;
  98. PopupWindow *m_popupWindow;
  99. Speaker *m_speaker;
  100. TrayIcon *m_trayIcon;
  101. #ifdef QSTARDICT_WITH_DBUS
  102. DBusAdaptor *m_dbusAdaptor;
  103. #endif // QSTARDICT_WITH_DBUS
  104. QString commandLineText();
  105. };
  106. }
  107. #endif // APPLICATION_H
  108. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent