OBSIdianPlayground.cpp 4.2 KB

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