gradient_editor_plugin.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * \file
  3. *
  4. * \author Mattia Basaglia
  5. *
  6. * \copyright Copyright (C) 2013-2020 Mattia Basaglia
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "gradient_editor_plugin.hpp"
  23. #include "QtColorWidgets/gradient_editor.hpp"
  24. QWidget* GradientEditor_Plugin::createWidget(QWidget *parent)
  25. {
  26. color_widgets::GradientEditor *widget = new color_widgets::GradientEditor(parent);
  27. return widget;
  28. }
  29. QIcon GradientEditor_Plugin::icon() const
  30. {
  31. color_widgets::GradientEditor w;
  32. w.resize(64,16);
  33. QGradientStops cols;
  34. cols.push_back({0.2, Qt::green});
  35. cols.push_back({0.5, Qt::yellow});
  36. cols.push_back({0.8, Qt::red});
  37. w.setStops(cols);
  38. QPixmap pix(64,64);
  39. pix.fill(Qt::transparent);
  40. w.render(&pix, QPoint(0,16));
  41. return QIcon(pix);
  42. }
  43. QString GradientEditor_Plugin::domXml() const
  44. {
  45. return "<ui language=\"c++\">\n"
  46. " <widget class=\"color_widgets::GradientEditor\" name=\"gradient_editor\">\n"
  47. " </widget>\n"
  48. "</ui>\n";
  49. }
  50. bool GradientEditor_Plugin::isContainer() const
  51. {
  52. return false;
  53. }
  54. GradientEditor_Plugin::GradientEditor_Plugin(QObject *parent) :
  55. QObject(parent), initialized(false)
  56. {
  57. }
  58. void GradientEditor_Plugin::initialize(QDesignerFormEditorInterface *)
  59. {
  60. initialized = true;
  61. }
  62. bool GradientEditor_Plugin::isInitialized() const
  63. {
  64. return initialized;
  65. }
  66. QString GradientEditor_Plugin::name() const
  67. {
  68. return "color_widgets::GradientEditor";
  69. }
  70. QString GradientEditor_Plugin::group() const
  71. {
  72. return "Color Widgets";
  73. }
  74. QString GradientEditor_Plugin::toolTip() const
  75. {
  76. return "Widget to edit gradient stops";
  77. }
  78. QString GradientEditor_Plugin::whatsThis() const
  79. {
  80. return toolTip();
  81. }
  82. QString GradientEditor_Plugin::includeFile() const
  83. {
  84. return "QtColorWidgets/gradient_editor.hpp";
  85. }