gradient_slider_plugin.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_slider_plugin.hpp"
  23. #include "QtColorWidgets/gradient_slider.hpp"
  24. #include <QtPlugin>
  25. GradientSlider_Plugin::GradientSlider_Plugin(QObject *parent)
  26. : QObject(parent), initialized(false)
  27. {
  28. }
  29. void GradientSlider_Plugin::initialize(QDesignerFormEditorInterface *)
  30. {
  31. if (initialized)
  32. return;
  33. initialized = true;
  34. }
  35. bool GradientSlider_Plugin::isInitialized() const
  36. {
  37. return initialized;
  38. }
  39. QWidget *GradientSlider_Plugin::createWidget(QWidget *parent)
  40. {
  41. return new color_widgets::GradientSlider(parent);
  42. }
  43. QString GradientSlider_Plugin::name() const
  44. {
  45. return "color_widgets::GradientSlider";
  46. }
  47. QString GradientSlider_Plugin::group() const
  48. {
  49. return "Color Widgets";
  50. }
  51. QIcon GradientSlider_Plugin::icon() const
  52. {
  53. color_widgets::GradientSlider w;
  54. w.resize(64,16);
  55. QVector<QColor> cols;
  56. cols.push_back(Qt::green);
  57. cols.push_back(Qt::yellow);
  58. cols.push_back(Qt::red);
  59. w.setColors(cols);
  60. QPixmap pix(64,64);
  61. pix.fill(Qt::transparent);
  62. w.render(&pix,QPoint(0,16));
  63. return QIcon(pix);
  64. }
  65. QString GradientSlider_Plugin::toolTip() const
  66. {
  67. return "Slider over a gradient";
  68. }
  69. QString GradientSlider_Plugin::whatsThis() const
  70. {
  71. return toolTip();
  72. }
  73. bool GradientSlider_Plugin::isContainer() const
  74. {
  75. return false;
  76. }
  77. QString GradientSlider_Plugin::domXml() const
  78. {
  79. return "<ui language=\"c++\">\n"
  80. " <widget class=\"color_widgets::GradientSlider\" name=\"GradientSlider\">\n"
  81. " </widget>\n"
  82. "</ui>\n";
  83. }
  84. QString GradientSlider_Plugin::includeFile() const
  85. {
  86. return "QtColorWidgets/gradient_slider.hpp";
  87. }