Fix shortcuts broken when monitor is in fullscreen

BUG: 356803
parent e85541f9
......@@ -257,7 +257,6 @@ bool LineEventEater::eventFilter(QObject *obj, QEvent *event)
if (((QKeyEvent*)event)->key() == Qt::Key_Escape) {
emit clearSearchLine();
}
return QObject::eventFilter(obj, event);
}
return QObject::eventFilter(obj, event);
}
......
......@@ -190,6 +190,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
connect(m_projectList, SIGNAL(refreshClip(QString,bool)), pCore->monitorManager(), SLOT(slotRefreshCurrentMonitor(QString)));
connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));*/
connect(m_clipMonitor, SIGNAL(extractZone(QString)), pCore->bin(), SLOT(slotStartCutJob(QString)));
connect(m_clipMonitor, SIGNAL(passKeyPress(QKeyEvent*)), this, SLOT(triggerKey(QKeyEvent*)));
m_projectMonitor = new Monitor(Kdenlive::ProjectMonitor, pCore->monitorManager(), this);
......@@ -3258,6 +3259,25 @@ void MainWindow::slotAlignPlayheadToMousePos()
pCore->projectManager()->currentTimeline()->projectView()->slotAlignPlayheadToMousePos();
}
void MainWindow::triggerKey(QKeyEvent* ev)
{
// Hack: The QQuickWindow that displays fullscreen monitor does not integrate quith QActions.
// so on keypress events we parse keys and check for shortcuts in all existing actions
QKeySequence seq(ev->key() + ev->modifiers());
QList< KActionCollection * > collections = KActionCollection::allCollections();
for (int i = 0; i < collections.count(); ++i) {
KActionCollection *coll = collections.at(i);
foreach( QAction* tempAction, coll->actions()) {
if (tempAction->shortcuts().contains(seq)) {
// Trigger action
tempAction->trigger();
ev->accept();
return;
}
}
}
}
QDockWidget *MainWindow::addDock(const QString &title, const QString &objectName, QWidget* widget, Qt::DockWidgetArea area)
{
QDockWidget *dockWidget = new QDockWidget(title, this);
......
......@@ -442,6 +442,7 @@ private slots:
void slotReloadTheme();
/** @brief Close Kdenlive and try to restart it */
void slotRestart();
void triggerKey(QKeyEvent* ev);
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -568,16 +568,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
void GLWidget::keyPressEvent(QKeyEvent* event)
{
if (event->key()==Qt::Key_Escape) {
emit switchFullScreen(true);
}
else {
event->ignore();
}
return;
//QQuickView::keyPressEvent(event);
//if (event->isAccepted()) return;
//MAIN.keyPressEvent(event);
emit passKeyEvent(event);
}
void GLWidget::createThread(RenderThread **thread, thread_function_t function, void *data)
......
......@@ -129,6 +129,7 @@ signals:
void audioSamplesSignal(const audioShortVector&,int,int,int);
void showContextMenu(const QPoint);
void lockMonitor(bool);
void passKeyEvent(QKeyEvent*);
private:
QRect m_rect;
......
......@@ -91,6 +91,22 @@ bool QuickEventEater::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
QuickMonitorEventEater::QuickMonitorEventEater(Monitor *parent) : QObject(parent)
, m_monitor(parent)
{
}
bool QuickMonitorEventEater::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ev = static_cast< QKeyEvent* >(event);
if (ev) {
m_monitor->doKeyPressEvent(ev);
return true;
}
}
return QObject::eventFilter(obj, event);
}
Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *parent) :
......@@ -125,12 +141,16 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
glayout->setContentsMargins(0, 0, 0, 0);
// Create QML OpenGL widget
m_glMonitor = new GLWidget();
connect(m_glMonitor, SIGNAL(passKeyEvent(QKeyEvent*)), this, SLOT(doKeyPressEvent(QKeyEvent*)));
m_videoWidget = QWidget::createWindowContainer(qobject_cast<QWindow*>(m_glMonitor));
m_videoWidget->setAcceptDrops(true);
QuickEventEater *leventEater = new QuickEventEater(this);
m_videoWidget->installEventFilter(leventEater);
connect(leventEater, &QuickEventEater::addEffect, this, &Monitor::slotAddEffect);
QuickMonitorEventEater *monitorEventEater = new QuickMonitorEventEater(this);
m_glWidget->installEventFilter(monitorEventEater);
glayout->addWidget(m_videoWidget, 0, 0);
m_verticalScroll = new QScrollBar(Qt::Vertical);
glayout->addWidget(m_verticalScroll, 0, 1);
......@@ -800,6 +820,22 @@ void Monitor::mouseDoubleClickEvent(QMouseEvent * event)
event->accept();
}
void Monitor::keyPressEvent(QKeyEvent* event)
{
if (event->key()==Qt::Key_Escape) {
slotSwitchFullScreen();
event->accept();
return;
}
if (m_glWidget->isFullScreen()) {
event->ignore();
emit passKeyPress(event);
return;
}
QWidget::keyPressEvent(event);
}
void Monitor::slotMouseSeek(int eventDelta, bool fast)
{
if (fast) {
......@@ -1678,4 +1714,7 @@ bool Monitor::stopCapture()
return true;
}
void Monitor::doKeyPressEvent(QKeyEvent *ev)
{
keyPressEvent(ev);
}
......@@ -65,6 +65,20 @@ signals:
void addEffect(QDomElement);
};
class QuickMonitorEventEater : public QObject
{
Q_OBJECT
public:
explicit QuickMonitorEventEater(Monitor *parent);
protected:
bool eventFilter(QObject *obj, QEvent *event);
private:
Monitor *m_monitor;
};
class Monitor : public AbstractMonitor
{
Q_OBJECT
......@@ -129,6 +143,7 @@ protected:
void mouseReleaseEvent(QMouseEvent * event);
void mouseDoubleClickEvent(QMouseEvent * event);
void resizeEvent(QResizeEvent *event);
void keyPressEvent(QKeyEvent* event);
/** @brief Move to another position on mouse wheel event.
*
......@@ -268,6 +283,8 @@ public slots:
void slotSwitchRec(bool enable);
/** @brief Request QImage of current frame */
void slotGetCurrentImage();
/** @brief Pass keypress event to mainwindow */
void doKeyPressEvent(QKeyEvent *ev);
signals:
void renderPosition(int);
......@@ -289,6 +306,7 @@ signals:
void refreshCurrentClip();
void addEffect(QDomElement);
void addMasterEffect(QString,QDomElement);
void passKeyPress(QKeyEvent*);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment