mirror of
https://github.com/YACReader/yacreader
synced 2025-07-20 22:14:41 -04:00
added rating support to comics grid view
This commit is contained in:
@ -60,6 +60,7 @@ void GridComicsView::setModel(TableModel *model)
|
||||
ctxt->setContextProperty("comicsList", this->model);
|
||||
ctxt->setContextProperty("comicsSelection", _selectionModel);
|
||||
ctxt->setContextProperty("comicsSelectionHelper", this);
|
||||
ctxt->setContextProperty("comicRatingHelper", this);
|
||||
ctxt->setContextProperty("dummyValue", true);
|
||||
}
|
||||
|
||||
@ -140,7 +141,7 @@ void GridComicsView::setViewActions(const QList<QAction *> &actions)
|
||||
this->addActions(actions);
|
||||
|
||||
//TODO this is completely unsafe, but QActions can't be used directly in QML
|
||||
if(actions.length()>17)
|
||||
if(actions.length()>=19)
|
||||
{
|
||||
QQmlContext *ctxt = view->rootContext();
|
||||
|
||||
@ -179,6 +180,12 @@ void GridComicsView::selectAll()
|
||||
QLOG_INFO() << "selectAll";
|
||||
}
|
||||
|
||||
void GridComicsView::rate(int index, int rating)
|
||||
{
|
||||
QLOG_INFO() << "Comic "<< index << "rated" << rating;
|
||||
model->updateRating(rating,model->index(index,0));
|
||||
}
|
||||
|
||||
QSize GridComicsView::sizeHint()
|
||||
{
|
||||
QLOG_INFO() << "sizeHint";
|
||||
|
@ -29,7 +29,6 @@ public:
|
||||
void setItemActions(const QList<QAction *> & actions);
|
||||
void setViewActions(const QList<QAction *> & actions);
|
||||
void enableFilterMode(bool enabled);
|
||||
|
||||
QSize sizeHint();
|
||||
signals:
|
||||
signals:
|
||||
@ -48,6 +47,10 @@ public slots:
|
||||
void setShowMarks(bool show);
|
||||
void selectAll();
|
||||
|
||||
//rating
|
||||
void rate(int index, int rating);
|
||||
|
||||
|
||||
private:
|
||||
QItemSelectionModel * _selectionModel;
|
||||
QQuickView *view;
|
||||
|
@ -4,5 +4,6 @@
|
||||
<file>qml/YACReaderScrollView.qml</file>
|
||||
<file>qml/tick.png</file>
|
||||
<file>qml/reading.png</file>
|
||||
<file>qml/star_menu.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -77,7 +77,6 @@ Rectangle {
|
||||
|
||||
comicsSelectionHelper.selectIndex(index)
|
||||
grid.currentIndex = index;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +186,30 @@ Rectangle {
|
||||
id: ratingImage
|
||||
anchors {bottom: realCell.bottom; right: pageImage.left; bottomMargin: 5; rightMargin: Math.floor(pages.width)+12}
|
||||
source: "star.png"
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
console.log("rating");
|
||||
comicsSelectionHelper.clear();
|
||||
comicsSelectionHelper.selectIndex(index);
|
||||
grid.currentIndex = index;
|
||||
ratingConextMenu.popup();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: ratingConextMenu
|
||||
MenuItem { text: "1"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,1) }
|
||||
MenuItem { text: "2"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,2) }
|
||||
MenuItem { text: "3"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,3) }
|
||||
MenuItem { text: "4"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,4) }
|
||||
MenuItem { text: "5"; enabled: true; iconSource:"star_menu.png"; onTriggered: comicRatingHelper.rate(index,5) }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//comic rating
|
||||
Text {
|
||||
id: comicRating
|
||||
|
BIN
YACReaderLibrary/qml/star_menu.png
Normal file
BIN
YACReaderLibrary/qml/star_menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 277 B |
Reference in New Issue
Block a user