cssedit.h 2.6 KB

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