Almost context location
This commit is contained in:
parent
b7cb84bb9b
commit
f4132ee37c
2 changed files with 21 additions and 4 deletions
|
|
@ -472,23 +472,33 @@ GraphEditorWidget::GraphEditorWidget(Potato::PipeWireController *controller, QWi
|
|||
m_view->addAction(loadPresetAction);
|
||||
|
||||
auto *createVirtualSinkAction = new QAction(QString("Create Virtual Sink"), m_view);
|
||||
createVirtualSinkAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(createVirtualSinkAction, &QAction::triggered, [this]() {
|
||||
const int index = ++m_virtualSinkCount;
|
||||
const QString name = QString("Potato_Virtual_Sink_%1").arg(index);
|
||||
const QString description = QString("Virtual Sink %1").arg(index);
|
||||
|
||||
m_pendingPastePositions.insert(name, m_lastContextMenuPos);
|
||||
|
||||
if (!m_controller->createVirtualSink(name, description, 2, 48000)) {
|
||||
qWarning() << "Failed to create virtual sink" << name;
|
||||
m_pendingPastePositions.remove(name);
|
||||
}
|
||||
});
|
||||
m_view->addAction(createVirtualSinkAction);
|
||||
|
||||
auto *createVirtualSourceAction = new QAction(QString("Create Virtual Source"), m_view);
|
||||
createVirtualSourceAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(createVirtualSourceAction, &QAction::triggered, [this]() {
|
||||
const int index = ++m_virtualSourceCount;
|
||||
const QString name = QString("Potato_Virtual_Source_%1").arg(index);
|
||||
const QString description = QString("Virtual Source %1").arg(index);
|
||||
|
||||
m_pendingPastePositions.insert(name, m_lastContextMenuPos);
|
||||
|
||||
if (!m_controller->createVirtualSource(name, description, 2, 48000)) {
|
||||
qWarning() << "Failed to create virtual source" << name;
|
||||
m_pendingPastePositions.remove(name);
|
||||
}
|
||||
});
|
||||
m_view->addAction(createVirtualSourceAction);
|
||||
|
|
@ -1048,12 +1058,18 @@ void GraphEditorWidget::updateNodeMeterLabel(QLabel *label)
|
|||
|
||||
bool GraphEditorWidget::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if (auto *label = qobject_cast<QLabel*>(object)) {
|
||||
if (event->type() == QEvent::Resize || event->type() == QEvent::Show) {
|
||||
updateNodeMeterLabel(label);
|
||||
if (object == m_view->viewport()) {
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
if (mouseEvent->button() == Qt::MiddleButton) {
|
||||
m_view->centerOn(m_view->mapToScene(mouseEvent->pos()));
|
||||
return true;
|
||||
}
|
||||
} else if (event->type() == QEvent::ContextMenu) {
|
||||
QContextMenuEvent *contextEvent = static_cast<QContextMenuEvent*>(event);
|
||||
m_lastContextMenuPos = m_view->mapToScene(contextEvent->pos());
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,4 +134,5 @@ private:
|
|||
int m_meterProfileFrames = 0;
|
||||
PresetManager *m_presetManager = nullptr;
|
||||
bool m_ignoreVolumeUndo = false;
|
||||
QPointF m_lastContextMenuPos;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue