Skip to content

Commit

Permalink
Fixes drag/drop crash on non-manual docks, fixes buttons in docks fro…
Browse files Browse the repository at this point in the history
…m disappearing. (#16)

Fixes #15
  • Loading branch information
FiniteSingularity authored Jun 30, 2024
1 parent 4a41098 commit d6b2c4d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 63 deletions.
1 change: 1 addition & 0 deletions src/quick-access-dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ QuickAccessDock::QuickAccessDock(QWidget *parent, obs_data_t *obsData)
_clickableScenes = obs_data_get_bool(obsData, "clickable_scenes");

_widget = new QuickAccess(this, this, "quick_access_widget");
setMinimumWidth(200);
auto l = new QVBoxLayout;
l->setContentsMargins(0, 0, 0, 0);
l->addWidget(_widget);
Expand Down
106 changes: 47 additions & 59 deletions src/quick-access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,75 +77,54 @@ QuickAccessItem::QuickAccessItem(QWidget *parent, QuickAccessDock *dock,
layout->addSpacing(2);
layout->addWidget(_label);

_actionsToolbar = new QToolBar(this);
_actionsToolbar->setObjectName(QStringLiteral("actionsToolbar"));
_actionsToolbar->setIconSize(QSize(16, 16));
_actionsToolbar->setFixedHeight(22);
_actionsToolbar->setStyleSheet("QToolBar{spacing: 0px;}");
_actionsToolbar->setFloatable(false);
_actionsToolbar->setSizePolicy(QSizePolicy::Maximum,
QSizePolicy::Maximum);
_actionsToolbar->setStyleSheet(
"QToolButton {padding: 0px; margin-left: 2px; margin-right: 2px;}");

_actionProperties = new QAction(this);
_actionProperties->setObjectName(QStringLiteral("actionProperties"));
_actionProperties = new QPushButton();
_actionProperties->setProperty("themeID", "propertiesIconSmall");
_actionProperties->setText(QT_UTF8(obs_module_text("Properties")));
connect(_actionProperties, SIGNAL(triggered()), this,
SLOT(on_actionProperties_triggered()));
_actionsToolbar->addAction(_actionProperties);

_actionFilters = new QAction(this);
_actionFilters->setObjectName(QStringLiteral("actionFilters"));
_actionFilters->setShortcutContext(Qt::WidgetWithChildrenShortcut);
_actionProperties->setDisabled(false);
_actionProperties->setAccessibleDescription(
"Opens the source properties window.");
_actionProperties->setAccessibleName("Open Source Properties");
_actionProperties->setToolTip("Open Source Properties");
_actionProperties->setStyleSheet("padding: 0px; background: none");
connect(_actionProperties, &QPushButton::released, this,
&QuickAccessItem::on_actionProperties_triggered);

_actionFilters = new QPushButton();
_actionFilters->setProperty("themeID", "filtersIcon");
_actionFilters->setText(QT_UTF8(obs_module_text("Filters")));
connect(_actionFilters, SIGNAL(triggered()), this,
SLOT(on_actionFilters_triggered()));
_actionsToolbar->addAction(_actionFilters);

_actionScenes = new QAction(this);
_actionScenes->setObjectName(QStringLiteral("actionScenes"));
_actionScenes->setShortcutContext(Qt::WidgetWithChildrenShortcut);
_actionFilters->setDisabled(false);
_actionFilters->setAccessibleDescription(
"Opens the source filters window.");
_actionFilters->setAccessibleName("Open Source Filters");
_actionFilters->setToolTip("Open Source Filters");
_actionFilters->setStyleSheet("padding: 0px; background: none");
connect(_actionFilters, &QPushButton::released, this,
&QuickAccessItem::on_actionFilters_triggered);

_actionScenes = new QPushButton();
QIcon sceneIcon;
sceneIcon = qau->GetSceneIcon();
_actionScenes->setIcon(sceneIcon);
_actionScenes->setText(QT_UTF8(obs_module_text("Scenes")));
connect(_actionScenes, SIGNAL(triggered()), this,
SLOT(on_actionScenes_triggered()));
_actionsToolbar->addAction(_actionScenes);

SetButtonVisibility();
_actionScenes->setDisabled(false);
_actionScenes->setAccessibleDescription(
"Opens list of all parent scenes");
_actionScenes->setAccessibleName("Show Parent Scenes");
_actionScenes->setToolTip("Show Parent Scenes");
_actionScenes->setStyleSheet("padding: 0px; background: none");
connect(_actionScenes, &QPushButton::released, this,
&QuickAccessItem::on_actionScenes_triggered);

layout->addWidget(_actionProperties);
layout->addWidget(_actionFilters);
layout->addWidget(_actionScenes);

// Themes need the QAction dynamic properties
for (QAction *x : _actionsToolbar->actions()) {
QWidget *temp = _actionsToolbar->widgetForAction(x);

for (QByteArray &y : x->dynamicPropertyNames()) {
temp->setProperty(y, x->property(y));
}
}
layout->addWidget(_actionsToolbar);
setLayout(layout);
SetButtonVisibility();
}

void QuickAccessItem::SetButtonVisibility()
{
_actionProperties->setVisible(_configurable && _dock->ShowProperties());
_actionFilters->setVisible(_dock->ShowFilters());
_actionScenes->setVisible(_dock->ShowScenes());

// Refresh Toolbar Styling
for (auto x : _actionsToolbar->actions()) {
auto widget = _actionsToolbar->widgetForAction(x);

if (!widget) {
continue;
}
widget->style()->unpolish(widget);
widget->style()->polish(widget);
}
}

const char *QuickAccessItem::GetSourceName()
Expand All @@ -160,7 +139,9 @@ QuickAccessItem::~QuickAccessItem()
{
delete _label;
delete _iconLabel;
delete _actionsToolbar;
delete _actionProperties;
delete _actionFilters;
delete _actionScenes;
_clearSceneItems();
obs_weak_source_release(_source);
}
Expand Down Expand Up @@ -352,9 +333,16 @@ QuickAccess::QuickAccess(QWidget *parent, QuickAccessDock *dock, QString name)
_sourceList->setFrameShape(QFrame::NoFrame);
_sourceList->setFrameShadow(QFrame::Plain);
_sourceList->setProperty("showDropIndicator", QVariant(true));
_sourceList->setDragEnabled(_dock->GetType() == "Manual");
_sourceList->setDragDropMode(QAbstractItemView::InternalMove);
_sourceList->setDefaultDropAction(Qt::TargetMoveAction);
if (_dock->GetType() == "Manual") {
_sourceList->setDragEnabled(true);
_sourceList->setDragDropMode(QAbstractItemView::InternalMove);
_sourceList->setDefaultDropAction(Qt::TargetMoveAction);
} else {
_sourceList->setDragEnabled(false);
_sourceList->setDragDropMode(QAbstractItemView::NoDragDrop);
_sourceList->viewport()->setAcceptDrops(false);
}

connect(_sourceList, SIGNAL(itemSelectionChanged()), this,
SLOT(on_sourceList_itemSelectionChanged()));

Expand Down
7 changes: 3 additions & 4 deletions src/quick-access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ class QuickAccessItem : public QFrame {
QLabel *_label = nullptr;
QLabel *_iconLabel = nullptr;

QToolBar *_actionsToolbar = nullptr;
QAction *_actionProperties = nullptr;
QAction *_actionFilters = nullptr;
QAction *_actionScenes = nullptr;
QPushButton *_actionProperties = nullptr;
QPushButton *_actionFilters = nullptr;
QPushButton *_actionScenes = nullptr;

QPushButton *_filters = nullptr;
obs_weak_source_t *_source = nullptr;
Expand Down

0 comments on commit d6b2c4d

Please sign in to comment.