|
18 | 18 | #include <QDialog>
|
19 | 19 | #include <QMouseEvent>
|
20 | 20 | #include <QInputDialog>
|
| 21 | +#include <QMainWindow> |
21 | 22 |
|
22 | 23 | #include <algorithm>
|
23 | 24 | #include "version.h"
|
@@ -585,13 +586,12 @@ QuickAccess::QuickAccess(QWidget *parent, QuickAccessDock *dock, QString name)
|
585 | 586 | }
|
586 | 587 |
|
587 | 588 | layout->addWidget(_sourceList);
|
| 589 | + _actionsToolbar = new QToolBar(this); |
| 590 | + _actionsToolbar->setObjectName(QStringLiteral("actionsToolbar")); |
| 591 | + _actionsToolbar->setIconSize(QSize(16, 16)); |
| 592 | + _actionsToolbar->setFloatable(false); |
588 | 593 |
|
589 | 594 | if (_dock->GetType() == "Manual") {
|
590 |
| - _actionsToolbar = new QToolBar(this); |
591 |
| - _actionsToolbar->setObjectName( |
592 |
| - QStringLiteral("actionsToolbar")); |
593 |
| - _actionsToolbar->setIconSize(QSize(16, 16)); |
594 |
| - _actionsToolbar->setFloatable(false); |
595 | 595 |
|
596 | 596 | _actionAddSource = new QAction(this);
|
597 | 597 | _actionAddSource->setObjectName(
|
@@ -635,24 +635,36 @@ QuickAccess::QuickAccess(QWidget *parent, QuickAccessDock *dock, QString name)
|
635 | 635 | SLOT(on_actionSourceDown_triggered()));
|
636 | 636 | _actionsToolbar->addAction(_actionSourceDown);
|
637 | 637 |
|
638 |
| - // Themes need the QAction dynamic properties |
639 |
| - for (QAction *x : _actionsToolbar->actions()) { |
640 |
| - QWidget *temp = _actionsToolbar->widgetForAction(x); |
641 |
| - |
642 |
| - for (QByteArray &y : x->dynamicPropertyNames()) { |
643 |
| - temp->setProperty(y, x->property(y)); |
644 |
| - } |
645 |
| - } |
646 |
| - |
647 | 638 | _actionRemoveSource->setEnabled(false);
|
648 | 639 | _actionSourceUp->setEnabled(false);
|
649 | 640 | _actionSourceDown->setEnabled(false);
|
| 641 | + } |
650 | 642 |
|
651 |
| - layout->addWidget(_actionsToolbar); |
652 |
| - layout->addItem(new QSpacerItem(150, 0, QSizePolicy::Fixed, |
653 |
| - QSizePolicy::Minimum)); |
| 643 | + QWidget *spacer = new QWidget(); |
| 644 | + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
| 645 | + _actionsToolbar->addWidget(spacer); |
| 646 | + |
| 647 | + _actionDockProperties = new QAction(this); |
| 648 | + _actionDockProperties->setObjectName(QStringLiteral("actionSourceUp")); |
| 649 | + _actionDockProperties->setProperty("themeID", "propertiesIconSmall"); |
| 650 | + _actionDockProperties->setText(QT_UTF8(obs_module_text("Dock Props"))); |
| 651 | + connect(_actionDockProperties, SIGNAL(triggered()), this, |
| 652 | + SLOT(on_actionDockProperties_triggered())); |
| 653 | + _actionsToolbar->addAction(_actionDockProperties); |
| 654 | + |
| 655 | + // Themes need the QAction dynamic properties |
| 656 | + for (QAction *x : _actionsToolbar->actions()) { |
| 657 | + QWidget *temp = _actionsToolbar->widgetForAction(x); |
| 658 | + |
| 659 | + for (QByteArray &y : x->dynamicPropertyNames()) { |
| 660 | + temp->setProperty(y, x->property(y)); |
| 661 | + } |
654 | 662 | }
|
655 | 663 |
|
| 664 | + layout->addWidget(_actionsToolbar); |
| 665 | + layout->addItem(new QSpacerItem(150, 0, QSizePolicy::Fixed, |
| 666 | + QSizePolicy::Minimum)); |
| 667 | + |
656 | 668 | if (_dock->GetType() == "Dynamic") {
|
657 | 669 | QuickAccess::SceneChangeCallback(
|
658 | 670 | OBS_FRONTEND_EVENT_SCENE_CHANGED, this);
|
@@ -740,6 +752,9 @@ void QuickAccess::_LoadDynamicScenes()
|
740 | 752 | _dynamicScenes.clear();
|
741 | 753 | _sourceList->clear();
|
742 | 754 |
|
| 755 | + //obs_source_t *dsk = obs_get_output_source(8); |
| 756 | + //const char *dsk_name = obs_source_get_name(dsk); |
| 757 | + //obs_source_release(dsk); |
743 | 758 | obs_source_t *current = obs_weak_source_get_source(_current);
|
744 | 759 | obs_scene_t *currentScene = obs_scene_from_source(current);
|
745 | 760 | obs_scene_enum_items(currentScene, QuickAccess::DynAddSceneItems, this);
|
@@ -1168,6 +1183,14 @@ void QuickAccess::on_actionRemoveSource_triggered()
|
1168 | 1183 | }
|
1169 | 1184 | }
|
1170 | 1185 |
|
| 1186 | +void QuickAccess::on_actionDockProperties_triggered() |
| 1187 | +{ |
| 1188 | + const auto main_window = |
| 1189 | + static_cast<QMainWindow *>(obs_frontend_get_main_window()); |
| 1190 | + UpdateDockDialog *dockDialog = new UpdateDockDialog(_dock, main_window); |
| 1191 | + dockDialog->show(); |
| 1192 | +} |
| 1193 | + |
1171 | 1194 | void QuickAccess::on_actionSourceUp_triggered()
|
1172 | 1195 | {
|
1173 | 1196 | int index = _sourceList->currentRow();
|
@@ -1408,6 +1431,103 @@ void QuickAccessSceneItem::setHighlight(bool h)
|
1408 | 1431 | setAutoFillBackground(h);
|
1409 | 1432 | }
|
1410 | 1433 |
|
| 1434 | +UpdateDockDialog::UpdateDockDialog(QuickAccessDock *dock, QWidget *parent) |
| 1435 | + : QDialog(parent), |
| 1436 | + _dock(dock) |
| 1437 | +{ |
| 1438 | + setWindowModality(Qt::WindowModal); |
| 1439 | + setAttribute(Qt::WA_DeleteOnClose, true); |
| 1440 | + setWindowTitle(QString("Add Quick Access Dock")); |
| 1441 | + setMinimumWidth(400); |
| 1442 | + setMinimumHeight(300); |
| 1443 | + int labelWidth = 120; |
| 1444 | + _layout = new QVBoxLayout(); |
| 1445 | + |
| 1446 | + // Form layout |
| 1447 | + _layout2 = new QVBoxLayout(); |
| 1448 | + |
| 1449 | + auto layoutName = new QHBoxLayout(); |
| 1450 | + |
| 1451 | + auto inputLabel = new QLabel(this); |
| 1452 | + inputLabel->setText("Dock Name:"); |
| 1453 | + inputLabel->setFixedWidth(labelWidth); |
| 1454 | + |
| 1455 | + _inputName = new QLineEdit(this); |
| 1456 | + _inputName->setPlaceholderText("Dock Name"); |
| 1457 | + _inputName->setText(_dock->GetName().c_str()); |
| 1458 | + _inputName->connect(_inputName, &QLineEdit::textChanged, |
| 1459 | + [this](const QString text) { |
| 1460 | + _buttonBox->button(QDialogButtonBox::Ok) |
| 1461 | + ->setEnabled(text.length() > 0); |
| 1462 | + }); |
| 1463 | + |
| 1464 | + layoutName->addWidget(inputLabel); |
| 1465 | + layoutName->addWidget(_inputName); |
| 1466 | + |
| 1467 | + _layout2->addItem(layoutName); |
| 1468 | + |
| 1469 | + auto optionsLabel = new QLabel(this); |
| 1470 | + optionsLabel->setText("Dock Options:"); |
| 1471 | + _layout2->addWidget(optionsLabel); |
| 1472 | + |
| 1473 | + _showProperties = new QCheckBox(this); |
| 1474 | + _showProperties->setText("Show Properties?"); |
| 1475 | + _showProperties->setChecked(_dock->ShowProperties()); |
| 1476 | + _layout2->addWidget(_showProperties); |
| 1477 | + |
| 1478 | + _showFilters = new QCheckBox(this); |
| 1479 | + _showFilters->setText("Show Filters?"); |
| 1480 | + _showFilters->setChecked(_dock->ShowFilters()); |
| 1481 | + _layout2->addWidget(_showFilters); |
| 1482 | + |
| 1483 | + _showScenes = new QCheckBox(this); |
| 1484 | + _showScenes->setText("Show Parent Scenes?"); |
| 1485 | + _showScenes->setChecked(_dock->ShowScenes()); |
| 1486 | + _layout2->addWidget(_showScenes); |
| 1487 | + |
| 1488 | + _clickThroughScenes = new QCheckBox(this); |
| 1489 | + _clickThroughScenes->setText("Clickable Scenes?"); |
| 1490 | + _clickThroughScenes->setChecked(_dock->ClickableScenes()); |
| 1491 | + _layout2->addWidget(_clickThroughScenes); |
| 1492 | + |
| 1493 | + _buttonBox = new QDialogButtonBox(this); |
| 1494 | + _buttonBox->setStandardButtons(QDialogButtonBox::Cancel | |
| 1495 | + QDialogButtonBox::Ok); |
| 1496 | + |
| 1497 | + connect(_buttonBox, SIGNAL(accepted()), this, SLOT(on_update_dock())); |
| 1498 | + connect(_buttonBox, SIGNAL(rejected()), this, SLOT(on_cancel())); |
| 1499 | + |
| 1500 | + _layout->addItem(_layout2); |
| 1501 | + |
| 1502 | + // Spacer to push buttons to bottom of widget |
| 1503 | + QWidget *spacer = new QWidget(this); |
| 1504 | + spacer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
| 1505 | + spacer->setVisible(true); |
| 1506 | + _layout->addWidget(spacer); |
| 1507 | + |
| 1508 | + _layout->addWidget(_buttonBox); |
| 1509 | + |
| 1510 | + setLayout(_layout); |
| 1511 | +} |
| 1512 | + |
| 1513 | +void UpdateDockDialog::on_update_dock() |
| 1514 | +{ |
| 1515 | + blog(LOG_INFO, "Update Dock"); |
| 1516 | + _dock->SetName(QT_TO_UTF8(_inputName->text())); |
| 1517 | + _dock->SetProperties(_showProperties->isChecked()); |
| 1518 | + _dock->SetFilters(_showFilters->isChecked()); |
| 1519 | + _dock->SetScenes(_showScenes->isChecked()); |
| 1520 | + _dock->SetClickableScenes(_clickThroughScenes->isChecked()); |
| 1521 | + _dock->SetItemsButtonVisibility(); |
| 1522 | + done(DialogCode::Accepted); |
| 1523 | +} |
| 1524 | + |
| 1525 | +void UpdateDockDialog::on_cancel() |
| 1526 | +{ |
| 1527 | + blog(LOG_INFO, "Cancel"); |
| 1528 | + done(DialogCode::Rejected); |
| 1529 | +} |
| 1530 | + |
1411 | 1531 | bool AddSourceToWidget(void *data, obs_source_t *source)
|
1412 | 1532 | {
|
1413 | 1533 | auto qa = static_cast<QuickAccess *>(data);
|
|
0 commit comments