Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
Added gallery type ribbon;
Browse files Browse the repository at this point in the history
Changed gallery star on favourite to ribbon in gridview;
Updated licence stuff;
  • Loading branch information
twiddli committed Jan 6, 2016
1 parent f2069b2 commit 716a013
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 708 deletions.
690 changes: 16 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions LICENSE-3RD-PARTY
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
-----------------------------------------------------------------------------
The MIT License (MIT)
applies to:
- Beautiful Soup
- Robobrowser
-----------------------------------------------------------------------------

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-----------------------------------------------------------------------------
Apache License, Version 2.0 (the "License")
applies to:
- requests
- watchdog
-----------------------------------------------------------------------------

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


-----------------------------------------------------------------------------
applies to:
- scandir
-----------------------------------------------------------------------------
Copyright (c) 2012, Ben Hoyt
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Ben Hoyt nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


-----------------------------------------------------------------------------
The ISC License
applies to:
- rarfile
-----------------------------------------------------------------------------
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

-----------------------------------------------------------------------------
The GPL v3
applies to:
- PyQt5
-----------------------------------------------------------------------------
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

-----------------------------------------------------------------------------
The LGPL
applies to:
- Qt5
-----------------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ see [INSTALL.md](INSTALL.md)

# Contributing
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Pewpews/happypanda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
I'm available there! Also, please check the wiki.
I'm available there! Also, please check the wiki.
6 changes: 3 additions & 3 deletions version/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,9 @@ def init_toolbar(self):
# debug specfic code
if app_constants.DEBUG:
def debug_func():
s = misc.Spinner(self)
s.set_text("this is a really long text")
s.show()
from pyqtgraph import examples
print("yes!")
examples.run()

debug_btn = QToolButton()
debug_btn.setText("DEBUG BUTTON")
Expand Down
13 changes: 12 additions & 1 deletion version/app_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
GRIDBOX_W_SIZE = GRIDBOX_H_SIZE//1.40 #1.47
LISTBOX_H_SIZE = 190
LISTBOX_W_SIZE = 950
GRIDBOX_LBL_H = 50 + SIZE_FACTOR
GRIDBOX_LBL_H = 60
GRIDBOX_H_SIZE += GRIDBOX_LBL_H
THUMB_H_SIZE = 190 + SIZE_FACTOR
THUMB_W_SIZE = 133 + SIZE_FACTOR
Expand Down Expand Up @@ -161,6 +161,7 @@
HIGH_QUALITY_THUMBS = get(False, 'Visual', 'high quality thumbs', bool)
USE_EXTERNAL_PROG_ICO = get(False, 'Visual', 'use external prog ico', bool) if not sys.platform.startswith('darwin') else False
DISPLAY_GALLERY_TYPE = get(False, 'Visual', 'display gallery type', bool) if not sys.platform.startswith('darwin') else False
DISPLAY_GALLERY_RIBBON = get(True, 'Visual', 'display gallery ribbon', bool)
GALLERY_FONT = (get('Segoe UI', 'Visual', 'gallery font family', str),
get(11, 'Visual', 'gallery font size', int))
GALLERY_FONT_ELIDE = get(True, 'Visual', 'gallery font elide', bool)
Expand All @@ -170,6 +171,16 @@
GRID_VIEW_ARTIST_COLOR = get('#585858', 'Visual', 'grid view artist color', str)
GRID_VIEW_LABEL_COLOR = get('#F2F2F2', 'Visual', 'grid view label color', str)

GRID_VIEW_T_MANGA_COLOR = get('#3498db', 'Visual', 'grid view t manga color', str)
GRID_VIEW_T_DOUJIN_COLOR = get('#e74c3c', 'Visual', 'grid view t doujin color', str)
GRID_VIEW_T_ARTIST_CG_COLOR = get('#16a085', 'Visual', 'grid view t artist cg color', str)
GRID_VIEW_T_GAME_CG_COLOR = get('#2ecc71', 'Visual', 'grid view t game cg color', str)
GRID_VIEW_T_WESTERN_COLOR = get('#ecf0f1', 'Visual', 'grid view t western color', str)
GRID_VIEW_T_IMAGE_COLOR = get('#f39c12', 'Visual', 'grid view t image color', str)
GRID_VIEW_T_NON_H_COLOR = get('#f1c40f', 'Visual', 'grid view t non-h color', str)
GRID_VIEW_T_COSPLAY_COLOR = get('#9b59b6', 'Visual', 'grid view t cosplay color', str)
GRID_VIEW_T_OTHER_COLOR = get('#34495e', 'Visual', 'grid view t other color', str)

# Search
SEARCH_AUTOCOMPLETE = get(True, 'Application', 'search autocomplete', bool)
ALLOW_SEARCH_REGEX = get(False, 'Application', 'allow search regex', bool)
Expand Down
97 changes: 77 additions & 20 deletions version/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
QPixmapCache, QCursor, QPalette, QKeyEvent,
QFont, QTextOption, QFontMetrics, QFontMetricsF,
QTextLayout, QPainterPath, QScrollPrepareEvent,
QWheelEvent)
QWheelEvent, QPolygonF)
from PyQt5.QtWidgets import (QListView, QFrame, QLabel,
QStyledItemDelegate, QStyle,
QMenu, QAction, QToolTip, QVBoxLayout,
Expand Down Expand Up @@ -877,9 +877,51 @@ def img_too_big(start_x):
painter.drawPixmap(QPoint(img_x,y),
self.image)

# draw star if it's favorited
# draw ribbon type
painter.save()
painter.setPen(Qt.NoPen)
if app_constants.DISPLAY_GALLERY_RIBBON:
type_ribbon_w = type_ribbon_l = w*0.11
rib_top_1 = QPointF(x+w-type_ribbon_l-type_ribbon_w, y)
rib_top_2 = QPointF(x+w-type_ribbon_l, y)
rib_side_1 = QPointF(x+w, y+type_ribbon_l)
rib_side_2 = QPointF(x+w, y+type_ribbon_l+type_ribbon_w)
ribbon_polygon = QPolygonF([rib_top_1, rib_top_2, rib_side_1, rib_side_2])
ribbon_path = QPainterPath()
ribbon_path.setFillRule(Qt.WindingFill)
ribbon_path.addPolygon(ribbon_polygon)
ribbon_path.closeSubpath()
painter.setBrush(QBrush(QColor(self._ribbon_color(gallery.type))))
painter.drawPath(ribbon_path)

# draw if favourited
if gallery.fav == 1:
painter.drawPixmap(QPointF(x,y), QPixmap(app_constants.STAR_PATH))
star_ribbon_w = star_ribbon_l = w*0.08
rib_top_1 = QPointF(x+star_ribbon_l, y)
rib_side_1 = QPointF(x, y+star_ribbon_l)
rib_top_2 = QPointF(x+star_ribbon_l+star_ribbon_w, y)
rib_side_2 = QPointF(x, y+star_ribbon_l+star_ribbon_w)
rib_star_mid_1 = QPointF((rib_top_1.x()+rib_side_1.x())/2, (rib_top_1.y()+rib_side_1.y())/2)
rib_star_factor = star_ribbon_l/4
rib_star_p1_1 = rib_star_mid_1 + QPointF(rib_star_factor, -rib_star_factor)
rib_star_p1_2 = rib_star_p1_1 + QPointF(-rib_star_factor, -rib_star_factor)
rib_star_p1_3 = rib_star_mid_1 + QPointF(-rib_star_factor, rib_star_factor)
rib_star_p1_4 = rib_star_p1_3 + QPointF(-rib_star_factor, -rib_star_factor)

crown_1 = QPolygonF([rib_star_p1_1, rib_star_p1_2, rib_star_mid_1, rib_star_p1_4, rib_star_p1_3])
painter.setBrush(QBrush(QColor("yellow")))
painter.drawPolygon(crown_1)

ribbon_polygon = QPolygonF([rib_top_1, rib_side_1, rib_side_2, rib_top_2])
ribbon_path = QPainterPath()
ribbon_path.setFillRule(Qt.WindingFill)
ribbon_path.addPolygon(ribbon_polygon)
ribbon_path.closeSubpath()
painter.drawPath(ribbon_path)
#painter.setPen(QColor("#d35400"))
#painter.drawPolyline(rib_top_1, rib_star_p1_1, rib_star_p1_2, rib_star_mid_1, rib_star_p1_4, rib_star_p1_3, rib_side_1)
#painter.drawLine(rib_top_2, rib_side_2)
painter.restore()

if app_constants._REFRESH_EXTERNAL_VIEWER:
if app_constants.USE_EXTERNAL_VIEWER:
Expand Down Expand Up @@ -971,13 +1013,6 @@ def draw_text_label(lbl_h):
selected_rect = QRectF(x, y, w, lbl_rect.height()+app_constants.THUMB_H_SIZE)
painter.setPen(Qt.NoPen)
painter.setBrush(QBrush(QColor(164,164,164,120)))
#p_path = QPainterPath()
#p_path.setFillRule(Qt.WindingFill)
#p_path.addRoundedRect(selected_rect, 5,5)
#s_factor = app_constants.SIZE_FACTOR + 10
#p_path.addRect(x,y, s_factor, s_factor)
#p_path.addRect(x+w-s_factor,y, s_factor, s_factor)
#painter.drawPath(p_path.simplified())
painter.drawRoundedRect(selected_rect, 5, 5)
#painter.fillRect(selected_rect, QColor(164,164,164,120))
painter.restore()
Expand All @@ -996,19 +1031,41 @@ def draw_text_label(lbl_h):
#painter.fillRect(selected_rect, QColor(164,164,164,120))
painter.restore()

if app_constants.DEBUG:
painter.save()
painter.setBrush(QBrush(QColor("red")))
painter.setPen(QColor("white"))
txt_l = self.title_font_m.width(str(gallery.id))
painter.drawRect(x, y, txt_l*2, self.title_font_m.height())
painter.drawText(x+1, y+11, str(gallery.id))
painter.restore()
#if app_constants.DEBUG:
# painter.save()
# painter.setBrush(QBrush(QColor("red")))
# painter.setPen(QColor("white"))
# txt_l = self.title_font_m.width(str(gallery.id))
# painter.drawRect(x, y, txt_l*2, self.title_font_m.height())
# painter.drawText(x+1, y+11, str(gallery.id))
# painter.restore()
#if option.state & QStyle.State_Selected:
# painter.setPen(QPen(option.palette.highlightedText().color()))
else:
super().paint(painter, option, index)

def _ribbon_color(self, gallery_type):
if gallery_type:
gallery_type = gallery_type.lower()
if gallery_type == "manga":
return app_constants.GRID_VIEW_T_MANGA_COLOR
elif gallery_type == "doujinshi":
return app_constants.GRID_VIEW_T_DOUJIN_COLOR
elif "artist cg" in gallery_type:
return app_constants.GRID_VIEW_T_ARTIST_CG_COLOR
elif "game cg" in gallery_type:
return app_constants.GRID_VIEW_T_GAME_CG_COLOR
elif gallery_type == "western":
return app_constants.GRID_VIEW_T_WESTERN_COLOR
elif "image" in gallery_type:
return app_constants.GRID_VIEW_T_IMAGE_COLOR
elif gallery_type == "non-h":
return app_constants.GRID_VIEW_T_NON_H_COLOR
elif gallery_type == "cosplay":
return app_constants.GRID_VIEW_T_COSPLAY_COLOR
else:
return app_constants.GRID_VIEW_T_OTHER_COLOR

def sizeHint(self, option, index):
return QSize(self.W, self.H)

Expand All @@ -1028,7 +1085,7 @@ def __init__(self, parent=None):
#self.setIconSize(QSize(app_constants.THUMB_W_SIZE-app_constants.SIZE_FACTOR,
# app_constants.THUMB_H_SIZE-app_constants.SIZE_FACTOR))
# all items have the same size (perfomance)
#self.setUniformItemSizes(True)
self.setUniformItemSizes(True)
# improve scrolling
self.setVerticalScrollMode(self.ScrollPerPixel)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
Expand Down Expand Up @@ -1107,7 +1164,7 @@ def __init__(self, parent=None):
self.setIconSize(QSize(app_constants.THUMB_W_SIZE,
app_constants.THUMB_H_SIZE))
# all items have the same size (perfomance)
self.setUniformItemSizes(True)
#self.setUniformItemSizes(True)
# improve scrolling
self.setAutoScroll(False)
self.setVerticalScrollMode(self.ScrollPerPixel)
Expand Down
Loading

0 comments on commit 716a013

Please sign in to comment.