mainwindow.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*****************************************************************************
  2. * mainwindow.h - 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. #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);
  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 reload();
  73. void saveSettings();
  74. public slots:
  75. /**
  76. * Show translation of word.
  77. */
  78. void showTranslation(const QString &word);
  79. protected:
  80. void timerEvent(QTimerEvent *event);
  81. void keyPressEvent(QKeyEvent *event);
  82. void closeEvent(QCloseEvent *event);
  83. private slots:
  84. void on_actionAbout_triggered();
  85. void on_actionSettings_triggered();
  86. void on_actionHelp_triggered();
  87. void on_queryButton_clicked();
  88. void wordsListItemActivated(QListWidgetItem *item);
  89. void wordTranslated(const QString &word);
  90. void queryEdited(const QString &);
  91. private:
  92. void createConnections();
  93. void loadSettings();
  94. DictCore *m_dict;
  95. bool m_instantSearch;
  96. int m_queryTimer;
  97. };
  98. }
  99. #endif // MAINWINDOW_H
  100. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc