ctkMenuButtonPlugin.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QMenu>
  16. // CTK includes
  17. #include "ctkMenuButtonPlugin.h"
  18. #include "ctkMenuButton.h"
  19. // --------------------------------------------------------------------------
  20. ctkMenuButtonPlugin::ctkMenuButtonPlugin(QObject *_parent)
  21. : QObject(_parent)
  22. {
  23. }
  24. // --------------------------------------------------------------------------
  25. QWidget *ctkMenuButtonPlugin::createWidget(QWidget *_parent)
  26. {
  27. ctkMenuButton* _widget = new ctkMenuButton(_parent);
  28. QMenu* dummyMenu = new QMenu(_widget);
  29. dummyMenu->addAction("foo");
  30. dummyMenu->addAction("bar");
  31. dummyMenu->addAction("barbarbarbarbarbarbarbarbarbar");
  32. _widget->setMenu(dummyMenu);
  33. return _widget;
  34. }
  35. // --------------------------------------------------------------------------
  36. QString ctkMenuButtonPlugin::domXml() const
  37. {
  38. return "<widget class=\"ctkMenuButton\" name=\"CTKMenuButton\">\n"
  39. " <property name=\"text\">"
  40. " <string>MenuButton</string>"
  41. " </property>"
  42. "</widget>\n";
  43. }
  44. // --------------------------------------------------------------------------
  45. QIcon ctkMenuButtonPlugin::icon() const
  46. {
  47. return QIcon(":/Icons/combobox.png");
  48. }
  49. // --------------------------------------------------------------------------
  50. QString ctkMenuButtonPlugin::includeFile() const
  51. {
  52. return "ctkMenuButton.h";
  53. }
  54. // --------------------------------------------------------------------------
  55. bool ctkMenuButtonPlugin::isContainer() const
  56. {
  57. return false;
  58. }
  59. // --------------------------------------------------------------------------
  60. QString ctkMenuButtonPlugin::name() const
  61. {
  62. return "ctkMenuButton";
  63. }