Skip to content

Commit

Permalink
Fix #344 shortcut not working with undocked Timeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Feb 9, 2018
1 parent deb2413 commit 78d3724
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
17 changes: 16 additions & 1 deletion src/docks/playlistdock.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2017 Meltytech, LLC
* Copyright (c) 2012-2018 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -31,6 +31,7 @@
#include <QPainter>
#include <QDebug>
#include <QHeaderView>
#include <QKeyEvent>

class TiledItemDelegate : public QStyledItemDelegate
{
Expand Down Expand Up @@ -748,3 +749,17 @@ void PlaylistDock::on_detailsButton_clicked()
ui->actionIcons->setChecked(false);
updateViewModeFromActions();
}

void PlaylistDock::keyPressEvent(QKeyEvent* event)
{
QDockWidget::keyPressEvent(event);
if (!event->isAccepted())
MAIN.keyPressEvent(event);
}

void PlaylistDock::keyReleaseEvent(QKeyEvent* event)
{
QDockWidget::keyReleaseEvent(event);
if (!event->isAccepted())
MAIN.keyReleaseEvent(event);
}
6 changes: 5 additions & 1 deletion src/docks/playlistdock.h
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2017 Meltytech, LLC
* Copyright (c) 2012-2018 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -114,6 +114,10 @@ private slots:

void on_detailsButton_clicked();

protected:
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);

private:
void setViewMode(PlaylistModel::ViewMode mode);

Expand Down
18 changes: 16 additions & 2 deletions src/docks/timelinedock.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2017 Meltytech, LLC
* Copyright (c) 2013-2018 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -64,7 +64,7 @@ TimelineDock::TimelineDock(QWidget *parent) :

connect(&m_model, SIGNAL(modified()), this, SLOT(clearSelectionIfInvalid()));

m_quickView.setFocusPolicy(Qt::StrongFocus);
m_quickView.setFocusPolicy(Qt::NoFocus);
setWidget(&m_quickView);

connect(this, SIGNAL(clipMoved(int,int,int,int)), SLOT(onClipMoved(int,int,int,int)), Qt::QueuedConnection);
Expand Down Expand Up @@ -971,6 +971,20 @@ bool TimelineDock::event(QEvent *event)
return result;
}

void TimelineDock::keyPressEvent(QKeyEvent* event)
{
QDockWidget::keyPressEvent(event);
if (!event->isAccepted())
MAIN.keyPressEvent(event);
}

void TimelineDock::keyReleaseEvent(QKeyEvent* event)
{
QDockWidget::keyReleaseEvent(event);
if (!event->isAccepted())
MAIN.keyReleaseEvent(event);
}

void TimelineDock::load(bool force)
{
if (m_quickView.source().isEmpty() || force) {
Expand Down
4 changes: 3 additions & 1 deletion src/docks/timelinedock.h
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2017 Meltytech, LLC
* Copyright (c) 2013-2018 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -144,6 +144,8 @@ public slots:
void dragLeaveEvent(QDragLeaveEvent* event);
void dropEvent(QDropEvent* event);
bool event(QEvent *event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);

private:
bool isBlank(int trackIndex, int clipIndex);
Expand Down
4 changes: 1 addition & 3 deletions src/mainwindow.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2017 Meltytech, LLC
* Copyright (c) 2011-2018 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -458,8 +458,6 @@ MainWindow::MainWindow()

connect(&m_network, SIGNAL(finished(QNetworkReply*)), SLOT(onUpgradeCheckFinished(QNetworkReply*)));

m_timelineDock->setFocusPolicy(Qt::StrongFocus);

LOG_DEBUG() << "end";
}

Expand Down

0 comments on commit 78d3724

Please sign in to comment.