Cleanup
This commit is contained in:
@@ -15,6 +15,8 @@ class DatabaseInit:
|
|||||||
self.create_database()
|
self.create_database()
|
||||||
|
|
||||||
def create_database(self):
|
def create_database(self):
|
||||||
|
# TODO
|
||||||
|
# Add a separate column for directory tags
|
||||||
self.database.execute(
|
self.database.execute(
|
||||||
"CREATE TABLE books \
|
"CREATE TABLE books \
|
||||||
(id INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Year INTEGER, \
|
(id INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Year INTEGER, \
|
||||||
|
@@ -7,91 +7,91 @@ from PyQt5 import QtGui
|
|||||||
|
|
||||||
|
|
||||||
def generate_pie(progress_percent, temp_dir=None):
|
def generate_pie(progress_percent, temp_dir=None):
|
||||||
progress_percent = int(progress_percent)
|
progress_percent = int(progress_percent)
|
||||||
|
|
||||||
lSlices = (progress_percent, 100 - progress_percent) # percentages to show in pie
|
lSlices = (progress_percent, 100 - progress_percent) # percentages to show in pie
|
||||||
|
|
||||||
lOffsetX = 150
|
lOffsetX = 150
|
||||||
lOffsetY = 150
|
lOffsetY = 150
|
||||||
|
|
||||||
lRadius = 100
|
lRadius = 100
|
||||||
|
|
||||||
def endpoint(pAngleInRadians, pRadius, pCentreOffsetX, pCentreOffsetY):
|
def endpoint(pAngleInRadians, pRadius, pCentreOffsetX, pCentreOffsetY):
|
||||||
"""
|
"""
|
||||||
Calculate position of point on circle given an angle, a radius,
|
Calculate position of point on circle given an angle, a radius,
|
||||||
and the location of the center of the circle
|
and the location of the center of the circle
|
||||||
Zero line points west.
|
Zero line points west.
|
||||||
"""
|
"""
|
||||||
lCosAngle = math.cos(pAngleInRadians)
|
lCosAngle = math.cos(pAngleInRadians)
|
||||||
lSinAngle = math.sin(pAngleInRadians)
|
lSinAngle = math.sin(pAngleInRadians)
|
||||||
lStartLineDestinationX = pCentreOffsetX - (lRadius * lCosAngle)
|
lStartLineDestinationX = pCentreOffsetX - (lRadius * lCosAngle)
|
||||||
lStartLineDestinationY = pCentreOffsetY - (lRadius * lSinAngle)
|
lStartLineDestinationY = pCentreOffsetY - (lRadius * lSinAngle)
|
||||||
|
|
||||||
return (lStartLineDestinationX, lStartLineDestinationY)
|
return (lStartLineDestinationX, lStartLineDestinationY)
|
||||||
|
|
||||||
|
|
||||||
GRADIENTS = ('myRadialGradientGreen', 'myRadialGradientOrange',
|
GRADIENTS = ('myRadialGradientGreen', 'myRadialGradientOrange',
|
||||||
'myRadialGradientGreen', 'myRadialGradientOrange')
|
'myRadialGradientGreen', 'myRadialGradientOrange')
|
||||||
DEGREES_IN_CIRCLE = 360.0
|
DEGREES_IN_CIRCLE = 360.0
|
||||||
lSvgPath = ""
|
lSvgPath = ""
|
||||||
lCurrentAngle = 0
|
lCurrentAngle = 0
|
||||||
lTotalSlices = 0
|
lTotalSlices = 0
|
||||||
lIndex = 0
|
lIndex = 0
|
||||||
lSvgPath = ""
|
lSvgPath = ""
|
||||||
for x in lSlices:
|
for x in lSlices:
|
||||||
lTotalSlices += x
|
lTotalSlices += x
|
||||||
|
|
||||||
for lSlice in lSlices:
|
for lSlice in lSlices:
|
||||||
lLineOneX, lLineOneY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY)
|
lLineOneX, lLineOneY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY)
|
||||||
lLineOne = "M%d,%d L%d,%d" % (lOffsetX, lOffsetY, lLineOneX, lLineOneY)
|
lLineOne = "M%d,%d L%d,%d" % (lOffsetX, lOffsetY, lLineOneX, lLineOneY)
|
||||||
|
|
||||||
lDegrees = (DEGREES_IN_CIRCLE / lTotalSlices) * lSlice
|
lDegrees = (DEGREES_IN_CIRCLE / lTotalSlices) * lSlice
|
||||||
lRadians = math.radians(lDegrees)
|
lRadians = math.radians(lDegrees)
|
||||||
lCurrentAngle += lRadians
|
lCurrentAngle += lRadians
|
||||||
lLineTwoX, lLineTwoY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY)
|
lLineTwoX, lLineTwoY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY)
|
||||||
|
|
||||||
lRoute = 0
|
lRoute = 0
|
||||||
if lDegrees > 180:
|
if lDegrees > 180:
|
||||||
lRoute = 1
|
lRoute = 1
|
||||||
lArc = "A%d,%d 0 %d,1 %d %d" % (
|
lArc = "A%d,%d 0 %d,1 %d %d" % (
|
||||||
lRadius, lRadius, lRoute, lLineTwoX, lLineTwoY)
|
lRadius, lRadius, lRoute, lLineTwoX, lLineTwoY)
|
||||||
lLineTwo = "L%d,%d" % (lOffsetX, lOffsetY)
|
lLineTwo = "L%d,%d" % (lOffsetX, lOffsetY)
|
||||||
|
|
||||||
lPath = "%s %s %s" % (lLineOne, lArc, lLineTwo)
|
lPath = "%s %s %s" % (lLineOne, lArc, lLineTwo)
|
||||||
lGradient = GRADIENTS[lIndex]
|
lGradient = GRADIENTS[lIndex]
|
||||||
lSvgPath += "<path d='%s' style='stroke:#097b8c; fill:url(#%s);'/>" % (
|
lSvgPath += "<path d='%s' style='stroke:#097b8c; fill:url(#%s);'/>" % (
|
||||||
lPath, lGradient)
|
lPath, lGradient)
|
||||||
lIndex += 1
|
lIndex += 1
|
||||||
|
|
||||||
lSvg = """
|
lSvg = """
|
||||||
<svg xmlns="http://www.w3.org/2000/svg"
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<defs>
|
<defs>
|
||||||
<radialGradient id="myRadialGradientGreen" r="65%%" cx="0" cy="0" spreadMethod="pad">
|
<radialGradient id="myRadialGradientGreen" r="65%%" cx="0" cy="0" spreadMethod="pad">
|
||||||
<stop offset="0%%" stop-color="#11e0ff" stop-opacity="1"/>
|
<stop offset="0%%" stop-color="#11e0ff" stop-opacity="1"/>
|
||||||
<stop offset="100%%" stop-color="#11e0ff" stop-opacity="1" />
|
<stop offset="100%%" stop-color="#11e0ff" stop-opacity="1" />
|
||||||
</radialGradient>
|
</radialGradient>
|
||||||
</defs>
|
</defs>
|
||||||
<defs>
|
<defs>
|
||||||
<radialGradient id="myRadialGradientOrange" r="65%%" cx="0" cy="0" spreadMethod="pad">
|
<radialGradient id="myRadialGradientOrange" r="65%%" cx="0" cy="0" spreadMethod="pad">
|
||||||
<stop offset="0%%" stop-color="#097b8c" stop-opacity="1"/>
|
<stop offset="0%%" stop-color="#097b8c" stop-opacity="1"/>
|
||||||
<stop offset="100%%" stop-color="#097b8c" stop-opacity="1" />
|
<stop offset="100%%" stop-color="#097b8c" stop-opacity="1" />
|
||||||
</radialGradient>
|
</radialGradient>
|
||||||
</defs>
|
</defs>
|
||||||
|
|
||||||
%s
|
%s
|
||||||
<!-- <circle cx="%d" cy="%d" r="100" style="stroke:#097b8c; fill:none;"/> -->
|
<!-- <circle cx="%d" cy="%d" r="100" style="stroke:#097b8c; fill:none;"/> -->
|
||||||
</svg>
|
</svg>
|
||||||
""" % (lSvgPath, lOffsetX, lOffsetY)
|
""" % (lSvgPath, lOffsetX, lOffsetY)
|
||||||
|
|
||||||
|
|
||||||
if temp_dir:
|
if temp_dir:
|
||||||
svg_path = os.path.join(temp_dir, 'lector_progress.svg')
|
svg_path = os.path.join(temp_dir, 'lector_progress.svg')
|
||||||
lFile = open(svg_path, 'w')
|
lFile = open(svg_path, 'w')
|
||||||
lFile.write(lSvg)
|
lFile.write(lSvg)
|
||||||
lFile.close()
|
lFile.close()
|
||||||
else:
|
else:
|
||||||
return lSvg
|
return lSvg
|
||||||
|
|
||||||
|
|
||||||
def pixmapper(current_chapter, total_chapters, temp_dir, size):
|
def pixmapper(current_chapter, total_chapters, temp_dir, size):
|
||||||
|
Reference in New Issue
Block a user