mainwindow.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*****************************************************************************
  2. * mainwindow.h - QStarDict, a quasi-star dictionary *
  3. * Copyright (C) 2007-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 MAINWINDOW_H
  20. #define MAINWINDOW_H
  21. #include "ui_mainwindow.h"
  22. class QMenu;
  23. class QCloseEvent;
  24. namespace QStarDict {
  25. class DictCore;
  26. class SettingsDialog;
  27. /**
  28. * The main window of QStarDict.
  29. */
  30. class MainWindow: public QMainWindow, private Ui::MainWindow
  31. {
  32. Q_OBJECT
  33. public:
  34. /**
  35. * Create new MainWindow.
  36. */
  37. MainWindow(QWidget *parent = 0, bool background = false);
  38. /**
  39. * Destructor.
  40. */
  41. ~MainWindow();
  42. /**
  43. * Return true if instant search is on, otherwise false.
  44. */
  45. bool isInstantSearch() const
  46. { return m_instantSearch; }
  47. /**
  48. * Set instant search mode. If instantSearch is true
  49. * translation will be shown when typing, otherwise only when
  50. * "Search" button clicked.
  51. */
  52. void setInstantSearch(bool instantSearch);
  53. /**
  54. * Set the dictionary.
  55. */
  56. void setDict(DictCore *dict);
  57. /**
  58. * Return the dictionary.
  59. */
  60. DictCore *dict() const
  61. { return m_dict; }
  62. /**
  63. * Set default style sheet for translations.
  64. */
  65. void setDefaultStyleSheet(const QString &css)
  66. { translationView->setDefaultStyleSheet(css); }
  67. /**
  68. * Return default style sheet.
  69. */
  70. QString defaultStyleSheet() const
  71. { return translationView->defaultStyleSheet(); }
  72. void setShowLinks(bool showLinks)
  73. { translationView->setShowLinks(showLinks); }
  74. bool showLinks() const
  75. { return translationView->showLinks(); }
  76. void setShowLinksModifierKey(int key)
  77. { translationView->setShowLinksModifierKey(key); }
  78. int showLinksModifierKey() const
  79. { return translationView->showLinksModifierKey(); }
  80. void setShowIpaPronouncers(bool showIpaPronouncers)
  81. { translationView->setShowIpaPronouncers(showIpaPronouncers); }
  82. bool showIpaPronouncers() const
  83. { return translationView->showIpaPronouncers(); }
  84. void setQuitOnClose(bool quitOnClose)
  85. { m_quitOnClose = quitOnClose; }
  86. bool quitOnClose() const
  87. { return m_quitOnClose; }
  88. void reload();
  89. void reloadToolbar()
  90. { translationView->reloadToolbar(); }
  91. void saveSettings();
  92. public slots:
  93. /**
  94. * Show translation of word.
  95. */
  96. void showTranslation(const QString &word);
  97. protected:
  98. void timerEvent(QTimerEvent *event);
  99. void keyPressEvent(QKeyEvent *event);
  100. void closeEvent(QCloseEvent *event);
  101. private slots:
  102. void on_actionAbout_triggered();
  103. void on_actionSettings_triggered();
  104. void on_actionHelp_triggered();
  105. void on_queryButton_clicked();
  106. void wordsListItemActivated(QListWidgetItem *item);
  107. void wordTranslated(const QString &word);
  108. void queryEdited(const QString &);
  109. private:
  110. void createConnections();
  111. void loadSettings();
  112. void showIntro();
  113. DictCore *m_dict;
  114. bool m_instantSearch;
  115. int m_queryTimer;
  116. bool m_quitOnClose;
  117. bool m_background;
  118. };
  119. }
  120. #endif // MAINWINDOW_H
  121. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc