Add current/next comic view to GridView.

This commit is contained in:
Luis Ángel San Martín
2018-04-23 19:22:51 +02:00
parent b41884d5db
commit f6d389ff35
23 changed files with 933 additions and 32 deletions

View File

@ -0,0 +1,528 @@
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import com.yacreader.ComicInfo 1.0
import com.yacreader.ComicDB 1.0
Rectangle {
color : "transparent"
id: mainContainer
height: info.height + 2 * topMargin
property string infoColor: infoTextColor
property font infoFont: Qt.font({
family: "Arial",
pixelSize: 14
});
property int topMargin : 27
property bool compact : width <= 650
RowLayout
{
id:main_layout
anchors.fill: parent
//READ------------------------------------------------------------
ColumnLayout
{
Layout.topMargin: topMargin
Layout.maximumWidth: 61
Layout.fillHeight: true
id: readStatus
Layout.alignment: Qt.AlignTop |
Qt.AlignHCenter
Rectangle {
color: "transparent"
width: 61
height: 24
InfoTick {
x: 27
y: 5
read: comicInfo.read
onReadChangedByUser: {
comicInfo.read = read;
comicInfoHelper.setRead(comic_info_index, read);
}
}
}
visible: !mainContainer.compact
}
//INFO------------------------------------------------------------
ColumnLayout
{
id: info
//width: parent.width
//Layout.fillWidth: true
Layout.alignment: Qt.AlignTop |
Qt.AlignLeft
Layout.maximumWidth: mainContainer.compact ? mainContainer.width : 960
Layout.leftMargin: mainContainer.compact ? 30 : 0
RowLayout
{
Layout.topMargin: topMargin
InfoTick {
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
read: comicInfo.read
onReadChangedByUser: {
comicInfo.read = read;
comicInfoHelper.setRead(comic_info_index, read);
}
}
Item {
Layout.fillWidth: true
}
InfoFavorites {
Layout.topMargin: 1
Layout.rightMargin: 17
Layout.alignment: Qt.AlignTop
active: comicInfo.isFavorite
onActiveChangedByUser: {
if(active)
comicInfoHelper.addToFavorites(comic_info_index);
else
comicInfoHelper.removeFromFavorites(comic_info_index);
comicInfo.isFavorite = active;
}
}
InfoRating {
Layout.alignment: Qt.AlignTop
Layout.rightMargin: 30
rating: comicInfo.rating
onRatingChangedByUser: {
comicInfo.rating = rating;
comicInfoHelper.rate(comic_info_index, rating);
}
}
visible: mainContainer.compact
}
RowLayout
{
Text {
Layout.topMargin: mainContainer.compact ? 18 : topMargin
Layout.fillWidth: true
Layout.rightMargin: mainContainer.compact ? 30 : 0
id: title
color: infoTitleColor
font.family: "Arial"
font.bold: true
font.pixelSize: mainContainer.compact ? 18 : 21;
wrapMode: Text.WordWrap
text: comic.getTitleIncludingNumber()
}
RowLayout
{
visible: !mainContainer.compact
Layout.alignment: Qt.AlignTop
Layout.topMargin: topMargin
InfoFavorites {
Layout.topMargin: 1
Layout.rightMargin: 17
Layout.alignment: Qt.AlignTop
active: comicInfo.isFavorite
onActiveChangedByUser: {
if(active)
comicInfoHelper.addToFavorites(comic_info_index);
else
comicInfoHelper.removeFromFavorites(comic_info_index);
comicInfo.isFavorite = active;
}
}
InfoRating {
Layout.alignment: Qt.AlignTop
Layout.rightMargin: 30
rating: comicInfo.rating
onRatingChangedByUser: {
comicInfo.rating = rating;
comicInfoHelper.rate(comic_info_index, rating);
}
}
}
}
Flow {
spacing: 0
Layout.fillWidth: true
Text {
id: volume
color: infoColor
font: mainContainer.infoFont
text: comicInfo.volume
rightPadding: 20
visible: comicInfo.volume
}
Text {
id: numbering
color: infoColor
font: mainContainer.infoFont
text: comicInfo.number + "/" + comicInfo.count
rightPadding: 20
visible : comicInfo.number
}
Text {
id: genre
color: infoColor
font: mainContainer.infoFont
text: comicInfo.genere
rightPadding: 20
visible: comicInfo.genere
}
Text {
id: date
color: infoColor
font: mainContainer.infoFont
text: comicInfo.date
rightPadding: 20
visible: comicInfo.date
}
Text {
id: pages
color: infoColor
font: mainContainer.infoFont
text: comicInfo.numPages + " pages"
rightPadding: 20
visible: comicInfo.numPages
}
Text {
id: showInComicVine
font: mainContainer.infoFont
color: "#ffcc00"
text: "Show in Comic Vine"
visible: comicInfo.comicVineID
MouseArea {
anchors.fill: parent
onClicked: {
Qt.openUrlExternally("http://www.comicvine.com/comic/4000-%1/".arg(comicInfo.comicVineID));
}
}
}
}
Text {
Layout.topMargin: 22
Layout.rightMargin: 30
Layout.bottomMargin: 5
Layout.fillWidth: true
id: sinopsis
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignJustify
text: comicInfo.synopsis
visible: comicInfo.synopsis
}
Text {
Layout.topMargin: 25
Layout.bottomMargin: 5
id: authors_title
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 18
font.bold: true
text: "Authors"
visible: comicInfo.getWriters().length +
comicInfo.getPencillers().length +
comicInfo.getInkers().length +
comicInfo.getColorists().length +
comicInfo.getLetterers().length +
comicInfo.getCoverArtists().length > 0
}
Flow {
Layout.fillWidth: true
spacing: 20
Repeater {
id: writers
model: comicInfo.getWriters().length
Column{
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getWriters()[index]
}
Text {
color: infoTextColor
font.family: "Arial"
font.pixelSize: 13
font.italic: true
text: "writer"
}
}
}
Repeater {
id: pencilllers
model: comicInfo.getPencillers().length
Column{
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getPencillers()[index]
}
Text {
color: infoTextColor
font.family: "Arial"
font.pixelSize: 13
font.italic: true
text: "penciller"
}
}
}
Repeater {
id: inkers
model: comicInfo.getInkers().length
Column{
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getInkers()[index]
}
Text {
color: infoTextColor
font.family: "Arial"
font.pixelSize: 13
font.italic: true
text: "inker"
}
}
}
Repeater {
id: colorist
model: comicInfo.getColorists().length
Column{
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getColorists()[index]
}
Text {
color: infoTextColor
font.family: "Arial"
font.pixelSize: 13
font.italic: true
text: "colorist"
}
}
}
Repeater {
id: letterers
model: comicInfo.getLetterers().length
Column{
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getLetterers()[index]
}
Text {
color: infoTextColor
font.family: "Arial"
font.pixelSize: 13
font.italic: true
text: "letterer"
}
}
}
Repeater {
id: cover_artist
model: comicInfo.getCoverArtists().length
Column{
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getCoverArtists()[index]
}
Text {
color: infoTextColor
font.family: "Arial"
font.pixelSize: 13
font.italic: true
text: "cover artist"
}
}
}
}
Text {
Layout.topMargin: 25
id: publisher_title
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 18
font.bold: true
text: "Publisher"
visible: publisher.visible || format.visible || color.visible || age_rating.visible
}
Flow {
Layout.fillWidth: true
spacing: 20
Text {
id: publisher
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.publisher
visible: comicInfo.publisher
}
Text {
id: format
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.format
visible: comicInfo.format
}
Text {
id: color
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.color ? "color" : "b/w"
visible: comicInfo.color
}
Text {
id: age_rating
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.ageRating
visible: comicInfo.ageRating
}
}
Text {
Layout.topMargin: 25
Layout.bottomMargin: 5
id: characters_title
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 18
font.bold: true
text: "Characters"
visible: comicInfo.getCharacters().length > 0
}
Flow {
Layout.fillWidth: true
spacing: 20
Repeater {
id: characters
model: comicInfo.getCharacters().length
Text {
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 15
text: comicInfo.getCharacters()[index]
}
}
}
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
Layout.minimumWidth: 0
Layout.preferredWidth: 0
}
}
}

View File

@ -1,13 +1,16 @@
import QtQuick 2.3
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import QtQuick.Controls.Styles 1.4
import com.yacreader.ComicModel 1.0
import com.yacreader.ComicInfo 1.0
import com.yacreader.ComicDB 1.0
SplitView {
anchors.fill: parent
orientation: Qt.Horizontal
@ -171,7 +174,6 @@ Rectangle {
}
onPressed: {
var ci = grid.currentIndex; //save current index
/*if(mouse.button != Qt.RightButton && !(mouse.modifiers & Qt.ControlModifier || mouse.modifiers & Qt.ShiftModifier))
@ -385,12 +387,18 @@ Rectangle {
}
}
YACReaderScrollView {
__wheelAreaScrollSpeed: grid.cellHeight * 0.30
ScrollView {
__wheelAreaScrollSpeed: grid.cellHeight * 0.40
id: scrollView
objectName: "topScrollView"
anchors.fill: parent
anchors.margins: 0
function scrollToOrigin() {
flickableItem.contentY = showCurrentComic ? -270 : -20
flickableItem.contentX = 0
}
style: YACReaderScrollViewStyle {
transientScrollBars: false
incrementControl: Item {}
@ -456,22 +464,244 @@ Rectangle {
}
}
Component {
id: currentComicView
Rectangle {
id: currentComicViewTopView
color: "#00000000"
height: showCurrentComic ? 270 : 20
Rectangle {
color: "#88000000"
id: currentComicVisualView
width: main.width
height: 250
visible: showCurrentComic
//cover
Image {
id: currentCoverElement
anchors.fill: parent
width: paintedWidth
anchors.leftMargin: 15
anchors.topMargin: 15
anchors.bottomMargin: 15
anchors.rightMargin: 15
horizontalAlignment: Image.AlignLeft
anchors {horizontalCenter: parent.horizontalCenter; top: realCell.top; topMargin: 0}
source: comicsList.getCoverUrlPathForComicHash(currentComicInfo.hash.toString())
fillMode: Image.PreserveAspectFit
smooth: true
mipmap: true
asynchronous : true
cache: false //TODO clear cache only when it is needed
}
DropShadow {
anchors.fill: currentCoverElement
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#FF000000"
source: currentCoverElement
visible: (Qt.platform.os === "osx") ? false : true;
}
ColumnLayout
{
id: currentComicInfoView
x: currentCoverElement.anchors.rightMargin + currentCoverElement.paintedWidth + currentCoverElement.anchors.rightMargin
//y: currentCoverElement.anchors.topMargin
anchors.top: currentCoverElement.top
anchors.right: parent.right
anchors.left: readButton.left
spacing: 9
Text {
Layout.topMargin: 7
Layout.fillWidth: true
Layout.rightMargin: 20
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
id: currentComicInfoTitleView
color: infoTitleColor
font.family: "Arial"
font.bold: true
font.pixelSize: 21
wrapMode: Text.WordWrap
text: currentComic.getTitleIncludingNumber()
}
Flow {
spacing: 0
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
Layout.fillWidth: true
Layout.fillHeight: false
id: currentComicDetailsFlowView
property font infoFont: Qt.font({
family: "Arial",
pixelSize: 14
});
property string infoFlowTextColor: infoTextColor
Text {
id: currentComicInfoVolume
color: currentComicDetailsFlowView.infoFlowTextColor
font: currentComicDetailsFlowView.infoFont
text: currentComicInfo.volume
rightPadding: 20
visible: currentComicInfo.volume
}
Text {
id: currentComicInfoNumbering
color: currentComicDetailsFlowView.infoFlowTextColor
font: currentComicDetailsFlowView.infoFont
text: currentComicInfo.number + "/" + currentComicInfo.count
rightPadding: 20
visible : currentComicInfo.number
}
Text {
id: currentComicInfoGenre
color: currentComicDetailsFlowView.infoFlowTextColor
font: currentComicDetailsFlowView.infoFont
text: currentComicInfo.genere
rightPadding: 20
visible: currentComicInfo.genere
}
Text {
id: currentComicInfoDate
color: currentComicDetailsFlowView.infoFlowTextColor
font: currentComicDetailsFlowView.infoFont
text: currentComicInfo.date
rightPadding: 20
visible: currentComicInfo.date
}
Text {
id: currentComicInfoPages
color: currentComicDetailsFlowView.infoFlowTextColor
font: currentComicDetailsFlowView.infoFont
text: currentComicInfo.numPages + " pages"
rightPadding: 20
visible: currentComicInfo.numPages
}
Text {
id: currentComicInfoShowInComicVine
font: currentComicDetailsFlowView.infoFont
color: "#ffcc00"
text: "Show in Comic Vine"
visible: currentComicInfo.comicVineID
MouseArea {
anchors.fill: parent
onClicked: {
Qt.openUrlExternally("http://www.comicvine.com/comic/4000-%1/".arg(comicInfo.comicVineID));
}
}
}
}
Text {
Layout.topMargin: 6
Layout.rightMargin: 30
Layout.bottomMargin: 5
Layout.fillWidth: true
Layout.maximumHeight: (currentComicVisualView.height * 0.32)
Layout.maximumWidth: 960
id: currentComicInfoSinopsis
color: infoTitleColor
font.family: "Arial"
font.pixelSize: 14
wrapMode: Text.WordWrap
elide: Text.ElideRight
horizontalAlignment: Text.AlignJustify
text: currentComicInfo.synopsis
visible: currentComicInfo.synopsis
}
}
Button {
text: "Read"
id: readButton
x: currentCoverElement.anchors.rightMargin + currentCoverElement.paintedWidth + currentCoverElement.anchors.rightMargin
anchors.bottom: currentCoverElement.bottom
anchors.bottomMargin: 15
onClicked: comicOpener.triggerOpenCurrentComic()
style: ButtonStyle {
background: Rectangle {
implicitWidth: 100
implicitHeight: 30
border.width: control.activeFocus ? 2 : 1
border.color: "#FFCC00"
radius: height / 2
color: "#FFCC00"
}
label: Text {
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.family: "Arial"
font.pointSize: 12
font.bold: true
color: "white"
text: control.text
}
}
}
DropShadow {
anchors.fill: readButton
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#AA000000"
source: readButton
visible: ((Qt.platform.os === "osx") ? false : true) && !readButton.pressed
}
}
}
}
GridView {
id:grid
objectName: "grid"
anchors.fill: parent
cellHeight: cellCustomHeight
header: currentComicView
//highlight: appHighlight
focus: true
model: comicsList
delegate: appDelegate
anchors.topMargin: 20
anchors.topMargin: 0 //showCurrentComic ? 0 : 20
anchors.bottomMargin: 20
anchors.leftMargin: 10
anchors.rightMargin: 10
anchors.leftMargin: 0
anchors.rightMargin: 0
pixelAligned: true
//flickDeceleration: -2000
currentIndex: 0
cacheBuffer: 0
@ -620,7 +850,7 @@ Rectangle {
}
}
ComicInfo {
ComicInfoView {
width: info_container.width
}
}

View File

@ -91,7 +91,7 @@ Rectangle {
}
}
ComicInfo {
ComicInfoView {
width: info_container.width - 14
}
}

View File

@ -50,7 +50,7 @@ Style {
id: root
/*! The \l ScrollView this style is attached to. */
readonly property YACReaderScrollView control: __control
readonly property ScrollView control: __control
/*! This property controls the frame border padding of the scrollView. */
padding {left: 1; top: 1; right: 1; bottom: 1}