cssedit.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*****************************************************************************
  2. * cssedit.h - QStarDict, a StarDict clone written with 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 CSSEDIT_H
  20. #define CSSEDIT_H
  21. #include "ui_cssedit.h"
  22. #include <QHash>
  23. namespace QStarDict
  24. {
  25. /**
  26. * CSS styles editor.
  27. */
  28. class CSSEdit: public QWidget, private Ui::CSSEdit
  29. {
  30. Q_OBJECT
  31. public:
  32. /**
  33. * Constructor.
  34. */
  35. CSSEdit(QWidget *parent = 0);
  36. /**
  37. * Set CSS style for editing.
  38. */
  39. void setCSS(const QString &css);
  40. /**
  41. * Returns edited CSS style.
  42. */
  43. QString css() const;
  44. /**
  45. * Set aliases for elements.
  46. */
  47. void setElementsAliases(const QHash<QString, QString> &aliases);
  48. /**
  49. * Returns elements aliases.
  50. */
  51. const QHash<QString, QString> &elementsAliases() const
  52. { return m_elementsAliases; }
  53. private slots:
  54. void colorSelectClicked();
  55. void setCurrentElement(int index);
  56. void propertyChanged();
  57. private:
  58. typedef QHash<QString, QString> Element;
  59. void updateElementCombo();
  60. void updatePreview();
  61. Element getParentElement(const QString &elementName);
  62. QHash<QString, Element> m_elements;
  63. QHash<QString, QString> m_elementsAliases;
  64. QString m_currentElement;
  65. };
  66. }
  67. #endif // CSSEDIT_H
  68. // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent