Back/Forward mouse buttons support (closes #4809) (#5440)

This commit is contained in:
Josef Vitu 2016-07-12 22:47:42 +02:00 committed by John Maguire
parent 126ed1a551
commit 32ed8ebba4
3 changed files with 25 additions and 9 deletions

View File

@ -56,6 +56,8 @@ FileView::FileView(QWidget* parent)
connect(ui_->up, SIGNAL(clicked()), SLOT(FileUp()));
connect(ui_->path, SIGNAL(textChanged(QString)),
SLOT(ChangeFilePath(QString)));
connect(ui_->list, SIGNAL(Back()), undo_stack_, SLOT(undo()));
connect(ui_->list, SIGNAL(Forward()), undo_stack_, SLOT(redo()));
connect(undo_stack_, SIGNAL(canUndoChanged(bool)), ui_->back,
SLOT(setEnabled(bool)));

View File

@ -132,17 +132,29 @@ void FileViewList::DeleteSlot() { emit Delete(FilenamesFromSelection()); }
void FileViewList::EditTagsSlot() { emit EditTags(UrlListFromSelection()); }
void FileViewList::mousePressEvent(QMouseEvent* e) {
QListView::mousePressEvent(e);
switch (e->button()) {
case Qt::XButton1:
emit Back();
break;
case Qt::XButton2:
emit Forward();
break;
// enqueue to playlist with middleClick
case Qt::MidButton: {
QListView::mousePressEvent(e);
// enqueue to playlist with middleClick
if (e->button() == Qt::MidButton) {
// we need to update the menu selection
menu_selection_ = selectionModel()->selection();
// we need to update the menu selection
menu_selection_ = selectionModel()->selection();
MimeData* data = new MimeData;
data->setUrls(UrlListFromSelection());
data->enqueue_now_ = true;
emit AddToPlaylist(data);
MimeData* data = new MimeData;
data->setUrls(UrlListFromSelection());
data->enqueue_now_ = true;
emit AddToPlaylist(data);
break;
}
default:
QListView::mousePressEvent(e);
break;
}
}

View File

@ -38,6 +38,8 @@ signals:
void CopyToDevice(const QList<QUrl>& urls);
void Delete(const QStringList& filenames);
void EditTags(const QList<QUrl>& urls);
void Back();
void Forward();
protected:
void contextMenuEvent(QContextMenuEvent* e);