OBSIdianPlayground.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. using namespace idian;
  18. OBSIdianPlayground::OBSIdianPlayground(QWidget *parent) : QDialog(parent), ui(new Ui_OBSIdianPlayground)
  19. {
  20. ui->setupUi(this);
  21. setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  22. Group *test;
  23. Row *tmp;
  24. ComboBox *cbox = new ComboBox;
  25. cbox->addItem("Test 1");
  26. cbox->addItem("Test 2");
  27. // Group box 1
  28. test = new Group(this);
  29. tmp = new Row();
  30. tmp->setTitle("Row with a dropdown");
  31. tmp->setSuffix(cbox);
  32. test->properties()->addRow(tmp);
  33. cbox = new ComboBox;
  34. cbox->addItem("Test 3");
  35. cbox->addItem("Test 4");
  36. tmp = new Row();
  37. tmp->setTitle("Row with a dropdown");
  38. tmp->setDescription("And a subtitle!");
  39. tmp->setSuffix(cbox);
  40. test->properties()->addRow(tmp);
  41. tmp = new Row();
  42. tmp->setTitle("Toggle Switch");
  43. tmp->setSuffix(new ToggleSwitch());
  44. test->properties()->addRow(tmp);
  45. ui->scrollAreaWidgetContents->layout()->addWidget(test);
  46. tmp = new Row();
  47. tmp->setTitle("Delayed toggle switch");
  48. tmp->setDescription("The state can be set separately");
  49. auto tswitch = new ToggleSwitch;
  50. tswitch->setDelayed(true);
  51. connect(tswitch, &ToggleSwitch::pendingChecked, this, [=]() {
  52. // Do async enable stuff, then set toggle status when complete
  53. QTimer::singleShot(1000, [=]() { tswitch->setStatus(true); });
  54. });
  55. connect(tswitch, &ToggleSwitch::pendingUnchecked, this, [=]() {
  56. // Do async disable stuff, then set toggle status when complete
  57. QTimer::singleShot(1000, [=]() { tswitch->setStatus(false); });
  58. });
  59. tmp->setSuffix(tswitch);
  60. test->properties()->addRow(tmp);
  61. // Group box 2
  62. test = new Group();
  63. test->setTitle("Just a few checkboxes");
  64. tmp = new Row();
  65. tmp->setTitle("Box 1");
  66. tmp->setPrefix(new CheckBox);
  67. test->properties()->addRow(tmp);
  68. tmp = new Row();
  69. tmp->setTitle("Box 2");
  70. tmp->setPrefix(new CheckBox);
  71. test->properties()->addRow(tmp);
  72. ui->scrollAreaWidgetContents->layout()->addWidget(test);
  73. // Group box 2
  74. test = new Group();
  75. test->setTitle("Another Group");
  76. test->setDescription("With a subtitle");
  77. tmp = new Row();
  78. tmp->setTitle("Placeholder");
  79. tmp->setSuffix(new ToggleSwitch);
  80. test->properties()->addRow(tmp);
  81. CollapsibleRow *tmp2 = new CollapsibleRow("A Collapsible row!", this);
  82. tmp2->setCheckable(true);
  83. test->addRow(tmp2);
  84. tmp = new Row();
  85. tmp->setTitle("Spin box demo");
  86. tmp->setSuffix(new DoubleSpinBox());
  87. tmp2->addRow(tmp);
  88. tmp = new Row();
  89. tmp->setTitle("Just another placeholder");
  90. tmp->setSuffix(new ToggleSwitch(true));
  91. tmp2->addRow(tmp);
  92. tmp = new Row();
  93. tmp->setTitle("Placeholder 2");
  94. tmp->setSuffix(new ToggleSwitch);
  95. test->properties()->addRow(tmp);
  96. ui->scrollAreaWidgetContents->setContentsMargins(0, 0, 0, 0);
  97. ui->scrollAreaWidgetContents->layout()->setContentsMargins(0, 0, 0, 0);
  98. ui->scrollAreaWidgetContents->layout()->addWidget(test);
  99. ui->scrollAreaWidgetContents->layout()->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
  100. // Test Checkable Group
  101. Group *test2 = new Group();
  102. test2->setTitle("Checkable Group");
  103. test2->setDescription("Description goes here");
  104. test2->setCheckable(true);
  105. ui->scrollAreaWidgetContents->layout()->addWidget(test2);
  106. }