diff --git a/database.py b/database.py index 94a2bd0..874788a 100644 --- a/database.py +++ b/database.py @@ -15,6 +15,8 @@ class DatabaseInit: self.create_database() def create_database(self): + # TODO + # Add a separate column for directory tags self.database.execute( "CREATE TABLE books \ (id INTEGER PRIMARY KEY, Title TEXT, Author TEXT, Year INTEGER, \ diff --git a/resources/pie_chart.py b/resources/pie_chart.py index f11a5f7..a51a212 100644 --- a/resources/pie_chart.py +++ b/resources/pie_chart.py @@ -7,91 +7,91 @@ from PyQt5 import QtGui 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 - lOffsetY = 150 + lOffsetX = 150 + lOffsetY = 150 - lRadius = 100 + lRadius = 100 - def endpoint(pAngleInRadians, pRadius, pCentreOffsetX, pCentreOffsetY): - """ - Calculate position of point on circle given an angle, a radius, - and the location of the center of the circle - Zero line points west. - """ - lCosAngle = math.cos(pAngleInRadians) - lSinAngle = math.sin(pAngleInRadians) - lStartLineDestinationX = pCentreOffsetX - (lRadius * lCosAngle) - lStartLineDestinationY = pCentreOffsetY - (lRadius * lSinAngle) + def endpoint(pAngleInRadians, pRadius, pCentreOffsetX, pCentreOffsetY): + """ + Calculate position of point on circle given an angle, a radius, + and the location of the center of the circle + Zero line points west. + """ + lCosAngle = math.cos(pAngleInRadians) + lSinAngle = math.sin(pAngleInRadians) + lStartLineDestinationX = pCentreOffsetX - (lRadius * lCosAngle) + lStartLineDestinationY = pCentreOffsetY - (lRadius * lSinAngle) - return (lStartLineDestinationX, lStartLineDestinationY) + return (lStartLineDestinationX, lStartLineDestinationY) - GRADIENTS = ('myRadialGradientGreen', 'myRadialGradientOrange', - 'myRadialGradientGreen', 'myRadialGradientOrange') - DEGREES_IN_CIRCLE = 360.0 - lSvgPath = "" - lCurrentAngle = 0 - lTotalSlices = 0 - lIndex = 0 - lSvgPath = "" - for x in lSlices: - lTotalSlices += x + GRADIENTS = ('myRadialGradientGreen', 'myRadialGradientOrange', + 'myRadialGradientGreen', 'myRadialGradientOrange') + DEGREES_IN_CIRCLE = 360.0 + lSvgPath = "" + lCurrentAngle = 0 + lTotalSlices = 0 + lIndex = 0 + lSvgPath = "" + for x in lSlices: + lTotalSlices += x - for lSlice in lSlices: - lLineOneX, lLineOneY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY) - lLineOne = "M%d,%d L%d,%d" % (lOffsetX, lOffsetY, lLineOneX, lLineOneY) + for lSlice in lSlices: + lLineOneX, lLineOneY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY) + lLineOne = "M%d,%d L%d,%d" % (lOffsetX, lOffsetY, lLineOneX, lLineOneY) - lDegrees = (DEGREES_IN_CIRCLE / lTotalSlices) * lSlice - lRadians = math.radians(lDegrees) - lCurrentAngle += lRadians - lLineTwoX, lLineTwoY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY) + lDegrees = (DEGREES_IN_CIRCLE / lTotalSlices) * lSlice + lRadians = math.radians(lDegrees) + lCurrentAngle += lRadians + lLineTwoX, lLineTwoY = endpoint(lCurrentAngle, lRadius, lOffsetX, lOffsetY) - lRoute = 0 - if lDegrees > 180: - lRoute = 1 - lArc = "A%d,%d 0 %d,1 %d %d" % ( - lRadius, lRadius, lRoute, lLineTwoX, lLineTwoY) - lLineTwo = "L%d,%d" % (lOffsetX, lOffsetY) + lRoute = 0 + if lDegrees > 180: + lRoute = 1 + lArc = "A%d,%d 0 %d,1 %d %d" % ( + lRadius, lRadius, lRoute, lLineTwoX, lLineTwoY) + lLineTwo = "L%d,%d" % (lOffsetX, lOffsetY) - lPath = "%s %s %s" % (lLineOne, lArc, lLineTwo) - lGradient = GRADIENTS[lIndex] - lSvgPath += "" % ( - lPath, lGradient) - lIndex += 1 + lPath = "%s %s %s" % (lLineOne, lArc, lLineTwo) + lGradient = GRADIENTS[lIndex] + lSvgPath += "" % ( + lPath, lGradient) + lIndex += 1 - lSvg = """ - - - - - - - - - - - - - + lSvg = """ + + + + + + + + + + + + + - %s - - - """ % (lSvgPath, lOffsetX, lOffsetY) + %s + + + """ % (lSvgPath, lOffsetX, lOffsetY) - if temp_dir: - svg_path = os.path.join(temp_dir, 'lector_progress.svg') - lFile = open(svg_path, 'w') - lFile.write(lSvg) - lFile.close() - else: - return lSvg + if temp_dir: + svg_path = os.path.join(temp_dir, 'lector_progress.svg') + lFile = open(svg_path, 'w') + lFile.write(lSvg) + lFile.close() + else: + return lSvg def pixmapper(current_chapter, total_chapters, temp_dir, size):