Enabled context menut and double click for opening in comic info view.

This commit is contained in:
Luis Ángel San Martín 2016-04-18 17:56:39 +02:00
parent b983de8888
commit bd78b6f504
3 changed files with 35 additions and 3 deletions

View File

@ -81,8 +81,9 @@ void InfoComicsView::setModel(ComicModel *model)
ctxt->setContextProperty("backgroundImage", QUrl());
ctxt->setContextProperty("comicsSelection", selectionHelper->selectionModel());
/*ctxt->setContextProperty("contextMenuHelper",this);
ctxt->setContextProperty("comicsSelectionHelper", this);
ctxt->setContextProperty("contextMenuHelper",this);
ctxt->setContextProperty("currentIndexHelper", this);
/*ctxt->setContextProperty("comicsSelectionHelper", this);
ctxt->setContextProperty("comicRatingHelper", this);
ctxt->setContextProperty("dummyValue", true);
ctxt->setContextProperty("dragManager", this);*/
@ -188,3 +189,13 @@ void InfoComicsView::droppedFiles(const QList<QUrl> &urls, Qt::DropAction action
emit copyComicsToCurrentFolder(droppedFiles);
}
}
void InfoComicsView::requestedContextMenu(const QPoint &point)
{
emit customContextMenuViewRequested(point);
}
void InfoComicsView::selectedItem(int index)
{
emit selected(index);
}

View File

@ -39,6 +39,10 @@ protected slots:
bool canDropUrls(const QList<QUrl> & urls, Qt::DropAction action);
void droppedFiles(const QList<QUrl> & urls, Qt::DropAction action);
void requestedContextMenu(const QPoint & point);
void selectedItem(int index);
protected:
QToolBar * toolbar;
QObject *flow;

View File

@ -6,6 +6,8 @@ import QtGraphicalEffects 1.0
import com.yacreader.ComicModel 1.0
Rectangle {
id: main
property url backgroundImageURL;
property real backgroundBlurRadius : 100; //85;
@ -163,8 +165,23 @@ Rectangle {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
hoverEnabled: true
onDoubleClicked: {
list.currentIndex = index;
currentIndexHelper.selectedItem(index);
}
onReleased: {
list.currentIndex = index;
if(mouse.button === Qt.RightButton) // context menu is requested
{
var coordinates = main.mapFromItem(coverElement,mouseX,mouseY)
contextMenuHelper.requestedContextMenu(Qt.point(coordinates.x,coordinates.y));
}
mouse.accepted = true;
}
}
}