OBSIdianPlayground.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /******************************************************************************
  2. Copyright (C) 2023 by Dennis Sädtler <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include "OBSIdianPlayground.hpp"
  15. #include <Idian/Idian.hpp>
  16. #include <QTimer>
  17. #include "moc_OBSIdianPlayground.cpp"
  18. using namespace idian;
  19. OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(new Ui_OBSIdianPlayground)
  20. {
  21. ui->setupUi(this);
  22. setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  23. Group *test;
  24. Row *tmp;
  25. ComboBox *cbox = new ComboBox;
  26. cbox->addItem("Test 1");
  27. cbox->addItem("Test 2");
  28. // Group box 1
  29. test = new Group(this);
  30. tmp = new Row();
  31. tmp->setTitle("Row with a dropdown");
  32. tmp->setSuffix(cbox);
  33. test->properties()->addRow(tmp);
  34. cbox = new ComboBox;
  35. cbox->addItem("Test 3");
  36. cbox->addItem("Test 4");
  37. tmp = new Row();
  38. tmp->setTitle("Row with a dropdown");
  39. tmp->setDescription("And a subtitle!");
  40. tmp->setSuffix(cbox);
  41. test->properties()->addRow(tmp);
  42. tmp = new Row();
  43. tmp->setTitle("Toggle Switch");
  44. tmp->setSuffix(new ToggleSwitch());
  45. test->properties()->addRow(tmp);
  46. ui->scrollAreaWidgetContents->layout()->addWidget(test);
  47. tmp = new Row();
  48. tmp->setTitle("Delayed toggle switch");
  49. tmp->setDescription("The state can be set separately");
  50. auto tswitch = new ToggleSwitch;
  51. tswitch->setDelayed(true);
  52. connect(tswitch, &ToggleSwitch::pendingChecked, this, [=]() {
  53. // Do async enable stuff, then set toggle status when complete
  54. QTimer::singleShot(1000, [=]() { tswitch->setStatus(true); });
  55. });
  56. connect(tswitch, &ToggleSwitch::pendingUnchecked, this, [=]() {
  57. // Do async disable stuff, then set toggle status when complete
  58. QTimer::singleShot(1000, [=]() { tswitch->setStatus(false); });
  59. });
  60. tmp->setSuffix(tswitch);
  61. test->properties()->addRow(tmp);
  62. // Group box 2
  63. test = new Group();
  64. test->setTitle("Just a few checkboxes");
  65. tmp = new Row();
  66. tmp->setTitle("Box 1");
  67. tmp->setPrefix(new CheckBox);
  68. test->properties()->addRow(tmp);
  69. tmp = new Row();
  70. tmp->setTitle("Box 2");
  71. tmp->setPrefix(new CheckBox);
  72. test->properties()->addRow(tmp);
  73. ui->scrollAreaWidgetContents->layout()->addWidget(test);
  74. // Group box 2
  75. test = new Group();
  76. test->setTitle("Another Group");
  77. test->setDescription("With a subtitle");
  78. tmp = new Row();
  79. tmp->setTitle("Placeholder");
  80. tmp->setSuffix(new ToggleSwitch);
  81. test->properties()->addRow(tmp);
  82. CollapsibleRow *tmp2 = new CollapsibleRow(this);
  83. tmp2->setTitle("A Collapsible row!");
  84. tmp2->setCheckable(true);
  85. test->addRow(tmp2);
  86. tmp = new Row();
  87. tmp->setTitle("Spin box demo");
  88. tmp->setSuffix(new DoubleSpinBox());
  89. tmp2->addRow(tmp);
  90. tmp = new Row();
  91. tmp->setTitle("Just another placeholder");
  92. tmp->setSuffix(new ToggleSwitch(true));
  93. tmp2->addRow(tmp);
  94. tmp = new Row();
  95. tmp->setTitle("Placeholder 2");
  96. tmp->setSuffix(new ToggleSwitch);
  97. test->properties()->addRow(tmp);
  98. ui->scrollAreaWidgetContents->setContentsMargins(0, 0, 0, 0);
  99. ui->scrollAreaWidgetContents->layout()->setContentsMargins(0, 0, 0, 0);
  100. ui->scrollAreaWidgetContents->layout()->addWidget(test);
  101. ui->scrollAreaWidgetContents->layout()->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
  102. // Test Checkable Group
  103. Group *test2 = new Group();
  104. test2->setTitle("Checkable Group");
  105. test2->setDescription("Description goes here");
  106. test2->setCheckable(true);
  107. ui->scrollAreaWidgetContents->layout()->addWidget(test2);
  108. }