dictwidget.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*****************************************************************************
  2. * dictwidget.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 DICTWIDGET_H
  20. #define DICTWIDGET_H
  21. #include <QFrame>
  22. #include "dictcore.h"
  23. #include "dictbrowser.h"
  24. class QToolBar;
  25. class QAction;
  26. namespace QStarDict
  27. {
  28. class DictBrowserSearch;
  29. /**
  30. * The DictBrowser widget provides view of translations from given dictionary.
  31. */
  32. class DictWidget: public QFrame
  33. {
  34. Q_OBJECT
  35. public:
  36. /**
  37. * Construct empty DictWidget.
  38. */
  39. DictWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
  40. /**
  41. * Set source dictionary.
  42. * Warning: DictWidget will copy only a pointer to dict. So set dictionaries
  43. * allocated from heap and don't destroy it befor DictWidget.
  44. */
  45. void setDict(DictCore *dict)
  46. { m_translationView->setDict(dict); }
  47. /**
  48. * Return pointer to dictionary.
  49. */
  50. const DictCore* dict() const
  51. { return m_translationView->dict(); }
  52. /**
  53. * Clear translation text.
  54. */
  55. void clear()
  56. { m_translationView->clear(); }
  57. /**
  58. * Clear history.
  59. */
  60. void clearHistory()
  61. { m_translationView->clearHistory(); }
  62. /**
  63. * Show translation of str.
  64. */
  65. void translate(const QString &str);
  66. /**
  67. * Return last translated word.
  68. */
  69. QString translatedWord() const
  70. { return m_translationView->source().toString(QUrl::RemoveScheme); }
  71. /**
  72. * Return toolbar.
  73. */
  74. QToolBar *toolBar()
  75. { return m_toolBar; }
  76. void setDefaultStyleSheet(const QString &css);
  77. QString defaultStyleSheet() const
  78. { return m_translationView->document()->defaultStyleSheet(); }
  79. void reload()
  80. { m_translationView->reload(); }
  81. signals:
  82. /**
  83. * Emits when translated word is shown.
  84. */
  85. void wordTranslated(const QString &word);
  86. private slots:
  87. void on_translationView_sourceChanged(const QUrl &name);
  88. void saveToFile();
  89. void speak();
  90. void print();
  91. void handleSearch();
  92. private:
  93. DictBrowser *m_translationView;
  94. QToolBar *m_toolBar;
  95. DictBrowserSearch *m_search;
  96. };
  97. }
  98. #endif // DICTWIDGET_H
  99. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc