├── florodoro ├── version.py ├── sounds │ ├── break_done.wav │ └── study_done.wav ├── utilities.py ├── history.py ├── images │ ├── icon.svg │ ├── logo.svg │ └── preview.svg ├── widgets.py ├── plants.py └── __init__.py ├── requirements.txt ├── .gitignore ├── .github └── workflows │ ├── official.workflow.yml │ └── testing.workflow.yml ├── CHANGELOG.md ├── setup.py ├── README.md └── LICENSE /florodoro/version.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.8" 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyqt5 2 | pyqtchart 3 | plyer 4 | qtawesome 5 | PyYAML 6 | -------------------------------------------------------------------------------- /florodoro/sounds/break_done.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxiae/Florodoro/HEAD/florodoro/sounds/break_done.wav -------------------------------------------------------------------------------- /florodoro/sounds/study_done.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxiae/Florodoro/HEAD/florodoro/sounds/study_done.wav -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | venv/ 3 | 4 | # generated 5 | */__pycache__/* 6 | 7 | # build 8 | *.egg-info 9 | build/ 10 | dist 11 | 12 | # private 13 | ignored/ 14 | -------------------------------------------------------------------------------- /florodoro/utilities.py: -------------------------------------------------------------------------------- 1 | from math import sin, pi 2 | 3 | 4 | def smoothen_curve(x: float): 5 | """f(x) with a smoother beginning and end.""" 6 | return (sin((x - 1 / 2) * pi) + 1) / 2 7 | -------------------------------------------------------------------------------- /.github/workflows/official.workflow.yml: -------------------------------------------------------------------------------- 1 | name: Publish to official 2 | 3 | on: 4 | push: 5 | branches: 6 | tags: 7 | - '[0-9]+.[0-9]+' 8 | 9 | 10 | jobs: 11 | deploy: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-python@v2 16 | - uses: casperdcl/deploy-pypi@v2 17 | with: 18 | password: ${{ secrets.pypi_token }} 19 | build: true 20 | -------------------------------------------------------------------------------- /.github/workflows/testing.workflow.yml: -------------------------------------------------------------------------------- 1 | name: Publish to testing 2 | 3 | on: 4 | push: 5 | tags: 6 | - '[0-9]+.[0-9]+.[0-9]+' 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-python@v2 14 | - uses: casperdcl/deploy-pypi@v2 15 | with: 16 | password: ${{ secrets.pypi_token_testing }} 17 | build: true 18 | url: "https://test.pypi.org/legacy/" 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | 8 | ## [0.8] - 2023-01-12 9 | 10 | ### Added 11 | - Version (-v) flag and version information to the about section 12 | 13 | ### Changed 14 | - Don't display -0 when overstudying (go to -1 immediately) 15 | - Migrate to GPLv3 16 | 17 | 18 | ## [0.7.2] - 2022-07-02 19 | 20 | ### Added 21 | - Infinite study (when cycles are set to 0) 22 | - Status label (for more apparent pausing) 23 | 24 | ### Changed 25 | - Set plant age to max when swapping to another one 26 | - Enable breaking earlier when not overstudying 27 | - Break now overstudies too 28 | - Fix pauses and studies sometimes not being saved correctly 29 | 30 | 31 | ## [0.7.1] - 2022-06-25 32 | 33 | ### Changed 34 | - Fix broken installation 35 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from os import path 3 | from re import search 4 | 5 | script_location = path.abspath(path.dirname(__file__)) 6 | 7 | # get required packages from requirements.txt 8 | with open("requirements.txt") as f: 9 | requirements = f.read().splitlines() 10 | 11 | # get long description from README 12 | with open(path.join(script_location, "README.md"), "r") as f: 13 | long_description = f.read() 14 | 15 | # get version 16 | with open("florodoro/version.py") as f: 17 | exec(f.read()) 18 | 19 | setup( 20 | name="florodoro", 21 | version=__version__, 22 | author="Tomáš Sláma", 23 | author_email="tomas@slama.dev", 24 | keywords="education pyqt5 plants pomodoro", 25 | url="https://github.com/xiaoxiae/Florodoro", 26 | description="A pomodoro timer that grows procedurally generated trees and flowers while you're studying.", 27 | long_description=long_description, 28 | long_description_content_type="text/markdown", 29 | classifiers=[ 30 | "Programming Language :: Python :: 3", 31 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", 32 | "Operating System :: OS Independent", 33 | ], 34 | 35 | packages=["florodoro"], 36 | include_package_data = True, 37 | package_data = {'florodoro': ["sounds/*", "images/*"]}, 38 | data_files=[("", ["LICENSE", "README.md", "requirements.txt", "CHANGELOG.md"])], 39 | 40 | entry_points={'console_scripts': ['florodoro=florodoro.__init__:run']}, 41 | 42 | # requirements 43 | install_requires=requirements, 44 | python_requires='>=3.7.1', 45 | ) 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://raw.githubusercontent.com/xiaoxiae/Florodoro/master/florodoro/images/logo.svg) 2 | 3 | --- 4 | 5 | A pomodoro timer that grows procedurally generated trees and flowers while you're studying. 6 | 7 | ![](https://raw.githubusercontent.com/xiaoxiae/Florodoro/master/florodoro/images/preview.svg) 8 | 9 | ## Running Florodoro 10 | First, install the app by running 11 | ``` 12 | pip install florodoro 13 | ``` 14 | 15 | To launch the application, simply run the `florodoro` command from a terminal of your choice. 16 | 17 | If you'd like to use the latest (unstable) version, install from TestPyPI using 18 | ``` 19 | pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple florodoro 20 | ``` 21 | 22 | ## Controls 23 | 24 | ### Top bar 25 | - **Presets** – contains common pomodoro timings for study/break/cycle 26 | - **Options** 27 | - **Notify** – notification options (sound/pop-ups) 28 | - **Plants** – plant settings (which ones to grow) 29 | - **Overstudy** – enables breaks and studies longer than set 30 | - **Statistics** – shows statistics + an interactive plant gallery 31 | - **About** – a small TLDR about the project 32 | 33 | ### Bottom bar 34 | - **Study for ...** – how long to study for 35 | - **Break for ...** – how long to break after study 36 | - **Cycles: ...** – how many times to repeat study-break (0 means infinite) 37 | - **Icon: Book** – start the study session 38 | - **Icon: Coffee** – start a break 39 | - **Icon: Pause/continue** – pause/continue an ongoing study/break 40 | - **Icon: Reset** – reset everything 41 | 42 | ## Local development 43 | 44 | ### Setup 45 | 1. create virtual environment: `python3 -m venv venv` 46 | 2. activate it `. venv/bin/activate` (assuming you use Bash) 47 | 3. install the package locally: `python3 -m pip install -e .` 48 | - the `-e` flag ensures local changes are used when running the package 49 | 4. develop 50 | 5. run `florodoro` (make sure that `venv` is active) 51 | 52 | _Note: this might not work when the path to the cloned reposity contains whitespace. I didn't look into the reason why (likely a bug in `venv`), just something to try if something fails._ 53 | 54 | ### Publishing 55 | All tagged commits in the `x.y.z` format are automatically published on PyPi using GitGub Actions. 56 | If the commit is on the `testing` branch, the test PyPi instance is used. 57 | 58 | The project follows [Semver](https://semver.org/) for version numbers and is currently under MAJOR version `0` (under rapid prototyping). 59 | For as long as this is the case, the master branch will only contain MINOR versions, while the testing branch will contain PATCH versions. 60 | -------------------------------------------------------------------------------- /florodoro/history.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pickle 3 | from typing import List 4 | 5 | import yaml 6 | 7 | from florodoro.plants import Plant 8 | 9 | 10 | class History: 11 | """A class for working with the Florodoro history.""" 12 | 13 | def __init__(self, path): 14 | self.path = path 15 | 16 | self.history = {} 17 | self.load() 18 | 19 | def save(self): 20 | """Save the current history to the history file.""" 21 | with open(self.path, "w") as f: 22 | f.write(yaml.dump(self.history)) 23 | 24 | def load(self): 25 | """Load the history from the history file.""" 26 | if os.path.exists(self.path): 27 | with open(self.path) as file: 28 | self.history = yaml.load(file, Loader=yaml.FullLoader) 29 | 30 | # ignore the result if isn't a dictionary 31 | if not isinstance(self.history, dict): 32 | self.history = {} 33 | 34 | # create the activities that we save 35 | for activity in ("breaks", "studies"): 36 | if activity not in self.history: 37 | self.history[activity] = [] 38 | 39 | def add_break(self, date, duration: float): 40 | """Add a break to the history. The date is the ENDING time.""" 41 | self.history["breaks"].append({"date": date, "duration": duration}) 42 | self.save() 43 | 44 | def add_study(self, date, duration: float, plant: Plant): 45 | """Add a break to the history. The date is the ENDING time.""" 46 | self.history["studies"].append({ 47 | "date": date, 48 | "duration": duration, 49 | "plant": pickle.dumps(plant) 50 | }) 51 | self.save() 52 | 53 | def total_studied_time(self) -> float: 54 | """Return the total minutes of studied time.""" 55 | return self._total_activity_time("studies") 56 | 57 | def total_break_time(self) -> float: 58 | """Return the total minutes of studied time.""" 59 | return self._total_activity_time("breaks") 60 | 61 | def _total_activity_time(self, activity_type: str): 62 | """Calculate the total time of something.""" 63 | # TODO: check for correct formatting, don't just crash if it's wrong 64 | total = 0 65 | for study in self.history[activity_type]: 66 | total += study["duration"] 67 | 68 | return total 69 | 70 | def total_plants_grown(self) -> int: 71 | """Return the total number of plants grown.""" 72 | count = 0 73 | for study in self.get_studies(): 74 | # TODO: check for correct formatting, don't just crash if it's wrong 75 | 76 | if study["plant"] is not None: 77 | count += 1 78 | 79 | return count 80 | 81 | def get_studies(self, sort=True) -> List: 82 | """Return all of the studies. Possibly sort on date.""" 83 | studies = self.history["studies"] 84 | 85 | # TODO: check for correct formatting, don't just crash if it's wrong 86 | if sort: 87 | studies = sorted(studies, key=lambda x: x["date"]) 88 | 89 | return studies 90 | -------------------------------------------------------------------------------- /florodoro/images/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 45 | 47 | 48 | 50 | image/svg+xml 51 | 53 | 54 | 55 | 56 | 57 | 62 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /florodoro/widgets.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | from typing import Optional 3 | 4 | import qtawesome 5 | from PyQt5.QtChart import QStackedBarSeries, QBarSet, QChart, QBarCategoryAxis, QChartView 6 | from PyQt5.QtCore import QMargins, Qt 7 | from PyQt5.QtGui import QPainter, QBrush 8 | from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QHBoxLayout, QPushButton, QSlider, QGridLayout, QFrame, \ 9 | QFileDialog 10 | 11 | from florodoro.plants import Drawable, Plant 12 | 13 | 14 | class Canvas(QWidget): 15 | """A widget that takes a drawable object and draws it.""" 16 | 17 | def __init__(self, *args, **kwargs): 18 | super(Canvas, self).__init__(*args, **kwargs) 19 | self.object: Optional[Drawable] = None 20 | 21 | def save(self, path: str): 22 | """Save the drawable object to the specified file.""" 23 | self.object.save(path, self.width(), self.height()) 24 | 25 | def set_drawable(self, obj: Drawable): 26 | """Set the drawable that the canvas draws.""" 27 | self.object = obj 28 | 29 | def paintEvent(self, event): 30 | painter = QPainter(self) 31 | painter.setRenderHint(QPainter.Antialiasing, True) 32 | painter.setClipRect(0, 0, self.width(), self.height()) 33 | 34 | if self.object is None: 35 | return 36 | 37 | self.object.draw(painter, self.width(), self.height()) 38 | 39 | painter.end() 40 | 41 | 42 | class Statistics(QWidget): 43 | """A statistics widget that displays information about studied time, shows grown plants, etc...""" 44 | 45 | def __init__(self, history, *args, **kwargs): 46 | super().__init__(*args, **kwargs) 47 | 48 | self.history = history 49 | 50 | chart = self.generate_chart() 51 | 52 | self.SPACING = 10 53 | self.MIN_WIDTH = 400 54 | self.MIN_HEIGHT = 200 55 | 56 | chart.setMinimumWidth(self.MIN_WIDTH) 57 | chart.setMinimumHeight(self.MIN_HEIGHT) 58 | 59 | image_layout = QVBoxLayout() 60 | 61 | self.plant_study = None # the study record the plant is a part of 62 | self.plant: Optional[Plant] = None # the plant being displayed 63 | 64 | self.plant_date_label = QLabel(self) 65 | self.plant_date_label.setAlignment(Qt.AlignLeft) 66 | 67 | self.plant_duration_label = QLabel(self) 68 | self.plant_duration_label.setAlignment(Qt.AlignRight) 69 | 70 | label_layout = QHBoxLayout() 71 | label_layout.addWidget(self.plant_date_label) 72 | label_layout.addWidget(self.plant_duration_label) 73 | 74 | self.canvas = Canvas(self) 75 | self.canvas.setMinimumWidth(self.MIN_HEIGHT) 76 | self.canvas.setMinimumHeight(self.MIN_HEIGHT) 77 | 78 | stacked_layout = QVBoxLayout() 79 | stacked_layout.addLayout(label_layout) 80 | stacked_layout.addWidget(self.canvas) 81 | 82 | image_control = QHBoxLayout() 83 | 84 | text_color = self.palette().text().color() 85 | 86 | # a hack to get float (we're gonna be dividing by the maximum) 87 | self.age_slider = QSlider(Qt.Horizontal, minimum=0, maximum=1000, value=1000, 88 | valueChanged=self.slider_value_changed) 89 | 90 | self.left_button = QPushButton(self, clicked=self.left, 91 | icon=qtawesome.icon('fa5s.angle-left', color=text_color)) 92 | self.right_button = QPushButton(self, clicked=self.right, 93 | icon=qtawesome.icon('fa5s.angle-right', color=text_color)) 94 | self.save_button = QPushButton(self, clicked=self.save, 95 | icon=qtawesome.icon('fa5s.download', color=text_color)) 96 | 97 | image_control.addWidget(self.left_button) 98 | image_control.addWidget(self.right_button) 99 | image_control.addSpacing(self.SPACING) 100 | image_control.addWidget(self.age_slider) 101 | image_control.addSpacing(self.SPACING) 102 | image_control.addWidget(self.save_button) 103 | 104 | image_layout.addLayout(stacked_layout) 105 | image_layout.addLayout(image_control) 106 | image_layout.setContentsMargins(self.SPACING, self.SPACING, self.SPACING, self.SPACING) 107 | 108 | separator = QFrame() 109 | separator.setStyleSheet(f"background-color: {self.palette().text().color().name()}") 110 | separator.setFixedWidth(1) 111 | 112 | main_layout = QGridLayout() 113 | main_layout.setHorizontalSpacing(self.SPACING * 2) 114 | main_layout.setColumnStretch(0, 1) 115 | main_layout.setColumnStretch(2, 0) 116 | main_layout.addWidget(chart, 0, 0) 117 | main_layout.addWidget(separator, 0, 1) 118 | main_layout.addLayout(image_layout, 0, 2) 119 | 120 | self.setLayout(main_layout) 121 | 122 | self.move() # go to the most recent plant 123 | 124 | self.refresh() 125 | 126 | def generate_chart(self): 127 | """Generate the bar graph for the widget.""" 128 | self.tags = [QBarSet(tag) for tag in ["Study"]] 129 | 130 | series = QStackedBarSeries() 131 | 132 | for set in self.tags: 133 | series.append(set) 134 | 135 | self.chart = QChart() 136 | self.chart.addSeries(series) 137 | self.chart.setTitle("Total time studied (minutes per day)") 138 | 139 | days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] 140 | axis = QBarCategoryAxis() 141 | axis.append(days) 142 | 143 | self.chart.createDefaultAxes() 144 | self.chart.setAxisX(axis, series) 145 | self.chart.legend().setAlignment(Qt.AlignBottom) 146 | self.chart.legend().setVisible(False) 147 | self.chart.setTheme(QChart.ChartThemeQt) 148 | self.chart.setBackgroundVisible(False) 149 | self.chart.setBackgroundRoundness(0) 150 | self.chart.setMargins(QMargins(0, 0, 0, 0)) 151 | self.chart.setTitleBrush(QBrush(self.palette().text().color())) 152 | 153 | yAxis = self.chart.axes(Qt.Vertical)[0] 154 | yAxis.setGridLineVisible(False) 155 | yAxis.setLabelFormat("%d") 156 | yAxis.setLinePenColor(self.palette().text().color()) 157 | yAxis.setLabelsColor(self.palette().text().color()) 158 | 159 | xAxis = self.chart.axes(Qt.Horizontal)[0] 160 | xAxis.setGridLineVisible(False) 161 | xAxis.setLinePenColor(self.palette().text().color()) 162 | xAxis.setLabelsColor(self.palette().text().color()) 163 | 164 | chartView = QChartView(self.chart) 165 | chartView.setRenderHint(QPainter.Antialiasing) 166 | 167 | return chartView 168 | 169 | def slider_value_changed(self): 170 | """Called when the slider value has changed. Sets the age of the plant and updates it.""" 171 | if self.plant is not None: 172 | # makes it a linear function from 0 to whatever the duration was, so the plant appears to grow normally 173 | self.plant.set_age( 174 | self.plant.inverse_age_coefficient_function(self.age_slider.value() / self.age_slider.maximum() * 175 | self.plant.age_coefficient_function( 176 | self.plant_study["duration"]))) 177 | self.canvas.update() 178 | 179 | def refresh(self): 180 | """Refresh the labels.""" 181 | # clear tag values 182 | for tag in self.tags: 183 | tag.remove(0, tag.count()) 184 | 185 | study_minutes = [0] * 7 186 | for study in self.history.get_studies(): 187 | # TODO: don't just crash 188 | study_minutes[study["date"].weekday()] += study["duration"] 189 | 190 | for minutes in study_minutes: 191 | self.tags[0] << minutes 192 | 193 | # manually set the range of the y axis, because it doesn't for some reason 194 | yAxis = self.chart.axes(Qt.Vertical)[0] 195 | yAxis.setRange(0, max(study_minutes)) 196 | 197 | def left(self): 198 | """Move to the left (older) plant.""" 199 | self.move(-1) 200 | 201 | def right(self): 202 | """Move to the right (newer) plant.""" 203 | self.move(1) 204 | 205 | def move(self, delta: int = 0): 206 | """Move to the left/right plant by delta. If no plant is currently being displayed or delta is 0, pick the 207 | latest one.""" 208 | studies = self.history.get_studies() 209 | 210 | self.age_slider.setValue(self.age_slider.maximum()) 211 | 212 | # if there are no plants to display, don't do anything 213 | if len(studies) == 0: 214 | return 215 | 216 | # if no plant is being displayed or 0 is provided, pick the last one 217 | if self.plant is None or delta == 0: 218 | index = -1 219 | 220 | # if one is, find it and move by delta 221 | else: 222 | current_index = self.history.get_studies().index(self.plant_study) 223 | 224 | index = max(min(current_index + delta, len(studies) - 1), 0) 225 | 226 | # TODO: check for correct formatting, don't just crash if it's wrong 227 | self.plant = pickle.loads(studies[index]["plant"]) 228 | self.plant_study = studies[index] 229 | 230 | # TODO: check for correct formatting, don't just crash if it's wrong 231 | self.plant_date_label.setText(self.plant_study["date"].strftime("%-d/%-m/%Y")) 232 | self.plant_duration_label.setText(f"{int(self.plant_study['duration'])} minutes") 233 | 234 | self.canvas.set_drawable(self.plant) 235 | self.slider_value_changed() # it didn't, but the code should act as if it did (update plant) 236 | 237 | def save(self): 238 | """Save the current state of the plant to a file.""" 239 | if self.plant is not None: 240 | name, _ = QFileDialog.getSaveFileName(self, 'Save File', "", "SVG files (*.svg)") 241 | 242 | if name == "": 243 | return 244 | 245 | if not name.endswith(".svg"): 246 | name += ".svg" 247 | 248 | self.plant.save(name, 1000, 1000) 249 | 250 | 251 | class SpacedQWidget(QWidget): 252 | """A dummy class for adding spacing to the left and right of a QWidget. Used in a QMenuBar's QWidgetAction, because 253 | I haven't found a way to add spacing to the left/right of a QSlider.""" 254 | 255 | def __init__(self, widget: QWidget, *args, **kwargs): 256 | super().__init__(*args, **kwargs) 257 | 258 | self.SPACING = 5 259 | 260 | layout = QHBoxLayout() 261 | layout.addSpacing(self.SPACING) 262 | layout.addWidget(widget) 263 | layout.addSpacing(self.SPACING) 264 | layout.setContentsMargins(0, 0, 0, 0) 265 | 266 | self.setLayout(layout) 267 | -------------------------------------------------------------------------------- /florodoro/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 23 | 27 | 31 | 32 | 35 | 39 | 43 | 44 | 47 | 51 | 55 | 56 | 59 | 63 | 67 | 68 | 78 | 88 | 98 | 108 | 109 | 134 | 136 | 137 | 139 | image/svg+xml 140 | 142 | 143 | 144 | 145 | 146 | 151 | 156 | 161 | 166 | 171 | 176 | 182 | 187 | 192 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /florodoro/plants.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod, ABC 2 | from math import degrees, sin, acos, sqrt 3 | from random import uniform, random, randint, choice 4 | from typing import Callable 5 | 6 | from PyQt5.QtCore import QSize, QRect, QPointF, QRectF, Qt 7 | from PyQt5.QtGui import QPainter, QColor, QPainterPath, QPen, QBrush 8 | from PyQt5.QtSvg import QSvgGenerator 9 | 10 | from florodoro.utilities import smoothen_curve 11 | 12 | 13 | class Drawable(ABC): 14 | """Something that has a draw function that takes a painter to be painted. 15 | Also contains some convenience methods for drawing the thing and saving it to an SVG.""" 16 | 17 | @abstractmethod 18 | def draw(self, painter: QPainter, width: int, height: int): 19 | """Draw the drawable onto a painter, given its size.""" 20 | pass 21 | 22 | def save(self, path: str, width: int, height: int): 23 | """Save the drawable to the specified file, given its size.""" 24 | generator = QSvgGenerator() 25 | generator.setFileName(path) 26 | generator.setSize(QSize(width, height)) 27 | generator.setViewBox(QRect(0, 0, width, height)) 28 | 29 | painter = QPainter(generator) 30 | self.draw(painter, width, height) 31 | painter.end() 32 | 33 | 34 | class Color: 35 | green = QColor(0, 119, 0) 36 | white = QColor(255, 255, 255) 37 | brown = QColor(77, 51, 0) 38 | orange = QColor(243, 148, 30) 39 | 40 | logo_colors = [ 41 | QColor(139, 139, 255), # blue-ish 42 | QColor(72, 178, 173), # green-ish 43 | QColor(255, 85, 85), # red-ish 44 | QColor(238, 168, 43), # orange-ish 45 | QColor(226, 104, 155), # pink-ish 46 | ] 47 | 48 | 49 | class Plant(Drawable): 50 | age: float = 0 51 | 52 | # coefficient that change how quickly the plant grows 53 | age_coefficient = 15 54 | age_exponent = 2 55 | 56 | def __init__(self): 57 | # make the sizes somewhat random 58 | self.deficit_coefficient = uniform(0.9, 1) 59 | 60 | def set_age(self, age: float): 61 | """Set the current age of the plant (in minutes).""" 62 | self.age = age 63 | 64 | def age_coefficient_function(self, x) -> float: 65 | """The function that calculates the normalized age [0, 1] from actual age (in minutes).""" 66 | return - 1 / ((x / self.age_coefficient) ** self.age_exponent + 1) + 1 67 | 68 | def inverse_age_coefficient_function(self, x) -> float: 69 | """The inverse to the age function.""" 70 | return float('inf') if x == 1 else (self.age_coefficient * x ** (1 / self.age_exponent)) / (1 - x) ** ( 71 | 1 / self.age_exponent) 72 | 73 | def get_age_coefficient(self) -> float: 74 | """Return the age, adjusted from 0 to 1.""" 75 | return self.age_coefficient_function(self.age) 76 | 77 | def get_slower_age_coefficient(self) -> float: 78 | """Return the age, adjusted from 0 to 1, but increasing slower.""" 79 | return self.get_age_coefficient() ** 3 80 | 81 | @abstractmethod 82 | def _draw(self, painter: QPainter, width: int, height: int): 83 | """The actual implementation of the plant drawn.""" 84 | pass 85 | 86 | def draw(self, painter: QPainter, width: int, height: int): 87 | """Draw the plant on the painter, given the width and height.""" 88 | w = min(width, height) 89 | h = min(width, height) 90 | 91 | # position to the bottom center of the canvas 92 | painter.translate(width / 2, height) 93 | painter.scale(1, -1) 94 | 95 | self._draw(painter, w, h) 96 | 97 | 98 | class Flower(Plant): 99 | 100 | def __init__(self): 101 | super().__init__() 102 | 103 | # the ending x position of the flower -- so it tilts one way or another 104 | self.x_coefficient = uniform(0.4, 1) * (-1 if random() < 0.5 else 1) 105 | 106 | self.generate_leafs(2) 107 | 108 | self.stem_width = uniform(3.5, 4) 109 | 110 | def generate_leafs(self, count): 111 | """Generate the leafs of the flower.""" 112 | # position / size coefficient (smaller/larger leafs) / rotation 113 | self.leafs = [(uniform(self.deficit_coefficient * 0.25, self.deficit_coefficient * 0.40), uniform(0.9, 1.1), 114 | (((i - 1 / 2) * 2) if count == 2 else (-1 if random() < 0.5 else 1))) for i in 115 | range(count)] 116 | 117 | def flower_center_x(self, width): 118 | """The x coordinate of the center of the flower.""" 119 | return width / 9 * self.x_coefficient 120 | 121 | def flower_center_y(self, height): 122 | """The y coordinate of the center of the flower.""" 123 | return height / 2.5 * self.deficit_coefficient 124 | 125 | def leaf_size(self, width): 126 | """The size of the leaf.""" 127 | return width / 7 * self.deficit_coefficient 128 | 129 | def _draw(self, painter: QPainter, width: int, height: int): 130 | self.x = self.flower_center_x(width) * smoothen_curve(self.get_age_coefficient()) 131 | self.y = self.flower_center_y(height) * smoothen_curve(self.get_age_coefficient()) 132 | 133 | painter.setPen(QPen(Color.green, self.stem_width * smoothen_curve(self.get_age_coefficient()))) 134 | 135 | # draw the stem 136 | path = QPainterPath() 137 | path.quadTo(0, self.y * 0.6, self.x, self.y) 138 | painter.drawPath(path) 139 | 140 | # draw the leaves 141 | for position, coefficient, rotation in self.leafs: 142 | painter.save() 143 | 144 | # find the point on the stem and rotate the leaf accordingly 145 | painter.translate(path.pointAtPercent(position)) 146 | painter.rotate(degrees(rotation)) 147 | 148 | # rotate according to where the flower is leaning towards 149 | if self.y != 0: 150 | painter.rotate(-degrees(sin(self.x / self.y))) 151 | 152 | # make it so both leaves are facing the same direction 153 | if rotation < 0: 154 | painter.scale(-1, 1) 155 | 156 | painter.setBrush(QBrush(Color.green)) 157 | painter.setPen(QPen(0)) 158 | 159 | # draw the leaf 160 | leaf = QPainterPath() 161 | leaf.setFillRule(Qt.WindingFill) 162 | ls = self.leaf_size(width) * smoothen_curve(self.get_age_coefficient()) ** 2 * coefficient 163 | leaf.quadTo(0.4 * ls, 0.5 * ls, 0, ls) 164 | leaf.cubicTo(0, 0.5 * ls, -0.4 * ls, 0.4 * ls, 0, 0) 165 | painter.drawPath(leaf) 166 | 167 | painter.restore() 168 | 169 | 170 | class CircularFlower(Flower): 171 | """A class for creating a flower.""" 172 | 173 | def __init__(self): 174 | super().__init__() 175 | 176 | # color of the flower 177 | self.color = choice(Color.logo_colors) 178 | 179 | self.number_of_pellets = randint(5, 7) 180 | 181 | # the center of the plant is smaller, compared to other pellet sizes 182 | self.center_pellet_smaller_coefficient = uniform(0.75, 0.85) 183 | 184 | self.pellet_drawing_function: Callable[[QPainter, float], None] = choice( 185 | [self.circular_pellet, self.triangle_pellet, self.dip_pellet, self.round_pellet]) 186 | 187 | # the m and n pellets don't look good with any other number of leafs (other than 5) 188 | if self.pellet_drawing_function in [self.dip_pellet, self.round_pellet]: 189 | self.number_of_pellets = 5 190 | 191 | def triangle_pellet(self, painter: QPainter, pellet_size: float): 192 | """A pellet that is pointy and triangular (1st in logo)""" 193 | pellet_size *= 1.5 194 | 195 | pellet = QPainterPath() 196 | pellet.setFillRule(Qt.WindingFill) 197 | pellet.quadTo(0.9 * pellet_size, 0.5 * pellet_size, 0, pellet_size) 198 | pellet.quadTo(-0.5 * pellet_size, 0.4 * pellet_size, 0, 0) 199 | painter.drawPath(pellet) 200 | 201 | def circular_pellet(self, painter: QPainter, pellet_size): 202 | """A perfectly circular pellet (2nd in logo).""" 203 | painter.drawEllipse(QRectF(0, 0, pellet_size, pellet_size)) 204 | 205 | def round_pellet(self, painter: QPainter, pellet_size): 206 | """A pellet that is round but not a circle (3rd in the logo).""" 207 | pellet_size *= 1.3 208 | 209 | pellet = QPainterPath() 210 | pellet.setFillRule(Qt.WindingFill) 211 | 212 | for c in [1, -1]: 213 | pellet.quadTo(c * pellet_size * 0.8, pellet_size * 0.9, 0, pellet_size if c != -1 else 0) 214 | 215 | painter.drawPath(pellet) 216 | 217 | def dip_pellet(self, painter: QPainter, pellet_size): 218 | """A pellet that has a dip in the middle (4th in the logo).""" 219 | pellet_size *= 1.2 220 | 221 | pellet = QPainterPath() 222 | pellet.setFillRule(Qt.WindingFill) 223 | 224 | for c in [1, -1]: 225 | pellet.quadTo(c * pellet_size, pellet_size * 1.4, 0, pellet_size if c != -1 else 0) 226 | 227 | painter.drawPath(pellet) 228 | 229 | def pellet_size(self, width): 230 | """Return the size of the pellet.""" 231 | return width / 9 * self.deficit_coefficient 232 | 233 | def _draw(self, painter: QPainter, width: int, height: int): 234 | super()._draw(painter, width, height) 235 | 236 | painter.save() 237 | 238 | # move to the position of the flower 239 | painter.translate(self.x, self.y) 240 | 241 | painter.setPen(QPen(Qt.NoPen)) 242 | painter.setBrush(QBrush(self.color)) 243 | 244 | pellet_size = self.pellet_size(width) * smoothen_curve(self.get_age_coefficient()) 245 | 246 | # draw each of the pellets 247 | for i in range(self.number_of_pellets): 248 | self.pellet_drawing_function(painter, pellet_size) 249 | painter.rotate(360 / self.number_of_pellets) 250 | 251 | # draw the center of the flower 252 | painter.setBrush(QBrush(Color.white)) 253 | pellet_size *= self.center_pellet_smaller_coefficient 254 | painter.drawEllipse(QRectF(-pellet_size / 2, -pellet_size / 2, pellet_size, pellet_size)) 255 | 256 | painter.restore() 257 | 258 | 259 | class Tree(Plant): 260 | """A simple tree class that all trees originate from.""" 261 | 262 | def __init__(self): 263 | super().__init__() 264 | 265 | # generate somewhere between 1 and 2 branches 266 | self.generateBranches(round(uniform(1, 2))) 267 | 268 | def generateBranches(self, count): 269 | # positions of branches up the tree, + their orientations (where they're turned towards) 270 | self.branches = [(uniform(self.deficit_coefficient * 0.45, self.deficit_coefficient * 0.55), 271 | (((i - 1 / 2) * 2) if count == 2 else (-1 if random() < 0.5 else 1)) * acos( 272 | uniform(0.4, 0.6))) for i in 273 | range(count)] 274 | 275 | def base_width(self, width): 276 | """The width of the base of the tree.""" 277 | return width / 15 * self.deficit_coefficient 278 | 279 | def base_height(self, height): 280 | """The height of the base of the tree.""" 281 | return height / 1.7 * self.deficit_coefficient 282 | 283 | def branch_width(self, width): 284 | """The width of a branch of the tree.""" 285 | return width / 18 * self.deficit_coefficient 286 | 287 | def branch_height(self, height): 288 | """The height of a branch of the tree.""" 289 | return height / 2.7 * self.deficit_coefficient 290 | 291 | def _draw(self, painter: QPainter, width: int, height: int): 292 | painter.setBrush(QBrush(Color.brown)) 293 | 294 | # main branch 295 | painter.drawPolygon(QPointF(-self.base_width(width) * smoothen_curve(self.get_age_coefficient()), 0), 296 | QPointF(self.base_width(width) * smoothen_curve(self.get_age_coefficient()), 0), 297 | QPointF(0, self.base_height(height) * smoothen_curve(self.get_age_coefficient()))) 298 | 299 | # other branches 300 | for h, rotation in self.branches: 301 | painter.save() 302 | 303 | # translate/rotate to the position from which the branches grow 304 | painter.translate(0, self.base_height(height * h * smoothen_curve(self.get_age_coefficient()))) 305 | painter.rotate(degrees(rotation)) 306 | 307 | painter.drawPolygon( 308 | QPointF(-self.branch_width(width) * smoothen_curve(self.get_slower_age_coefficient()) * (1 - h), 0), 309 | QPointF(self.branch_width(width) * smoothen_curve(self.get_slower_age_coefficient()) * (1 - h), 0), 310 | QPointF(0, self.branch_height(height) * smoothen_curve(self.get_slower_age_coefficient()) * (1 - h))) 311 | 312 | painter.restore() 313 | 314 | 315 | class OrangeTree(Tree): 316 | """A tree with orange ellipses as leafs.""" 317 | 318 | def __init__(self): 319 | super().__init__() 320 | 321 | # orange trees will always have 2 branches 322 | # it just looks better 323 | self.generateBranches(2) 324 | 325 | # the size (percentage of width/height) + the position of the circle on the branch 326 | # the last one is the main ellipse 327 | self.branch_circles = [(uniform(self.deficit_coefficient * 0.30, self.deficit_coefficient * 0.37), 328 | uniform(self.deficit_coefficient * 0.9, self.deficit_coefficient)) for _ in 329 | range(len(self.branches) + 1)] 330 | 331 | def _draw(self, painter: QPainter, width: int, height: int): 332 | painter.setPen(QPen(Qt.NoPen)) 333 | painter.setBrush(QBrush(Color.orange)) 334 | 335 | for i, branch in enumerate(self.branches): 336 | h, rotation = branch 337 | 338 | painter.save() 339 | 340 | # translate/rotate to the position from which the branches grow 341 | painter.translate(0, self.base_height(height * h * smoothen_curve(self.get_age_coefficient()))) 342 | painter.rotate(degrees(rotation)) 343 | 344 | top_of_branch = self.branch_height(height) * smoothen_curve(self.get_slower_age_coefficient()) * (1 - h) 345 | circle_on_branch_position = top_of_branch * self.branch_circles[i][1] 346 | 347 | r = ((width + height) / 2) * self.branch_circles[i][0] * self.get_slower_age_coefficient() * ( 348 | 1 - h) * self.get_age_coefficient() 349 | 350 | painter.setBrush(QBrush(Color.orange)) 351 | painter.drawEllipse(QPointF(0, circle_on_branch_position), r, r) 352 | 353 | painter.restore() 354 | 355 | top_of_branch = self.base_height(height) * smoothen_curve(self.get_age_coefficient()) 356 | circle_on_branch_position = top_of_branch * self.branch_circles[-1][1] 357 | 358 | # make the main ellipse slightly larger 359 | increase_size = 1.3 360 | r = ((width + height) / 2) * self.branch_circles[-1][0] * self.get_age_coefficient() * ( 361 | 1 - self.branches[-1][0]) * increase_size 362 | 363 | painter.drawEllipse(QPointF(0, circle_on_branch_position), r, r) 364 | 365 | super()._draw(painter, width, height) 366 | 367 | 368 | class GreenTree(Tree): 369 | """A tree with a green triangle as leafs.""" 370 | 371 | def __init__(self): 372 | super().__init__() 373 | 374 | def green_width(self, width): 375 | """The width of the top part of the leafs.""" 376 | return width / 3.2 * self.deficit_coefficient 377 | 378 | def green_height(self, height): 379 | """The height of the top part of the leafs.""" 380 | return height / 1.5 * self.deficit_coefficient 381 | 382 | def offset(self, height): 383 | return min(height * 0.95, self.base_height(height * 0.3 * smoothen_curve(self.get_age_coefficient()))) 384 | 385 | def _draw(self, painter: QPainter, width: int, height: int): 386 | painter.setPen(QPen(Qt.NoPen)) 387 | painter.setBrush(QBrush(Color.green)) 388 | 389 | painter.drawPolygon( 390 | QPointF(-self.green_width(width) * smoothen_curve(self.get_age_coefficient()), self.offset(height)), 391 | QPointF(self.green_width(width) * smoothen_curve(self.get_age_coefficient()), self.offset(height)), 392 | QPointF(0, self.green_height(height) * smoothen_curve(self.get_age_coefficient()) + self.offset(height))) 393 | 394 | super()._draw(painter, width, height) 395 | 396 | 397 | class DoubleGreenTree(GreenTree): 398 | """A tree with a double green triangle as leafs.""" 399 | 400 | def __init__(self): 401 | super().__init__() 402 | 403 | def second_green_width(self, width): 404 | return width / 3.5 * self.deficit_coefficient 405 | 406 | def second_green_height(self, height): 407 | return height / 2.4 * self.deficit_coefficient 408 | 409 | def _draw(self, painter: QPainter, width: int, height: int): 410 | painter.setPen(QPen(Qt.NoPen)) 411 | painter.setBrush(QBrush(Color.green)) 412 | 413 | offset = self.base_height(height * 0.3 * smoothen_curve(self.get_age_coefficient())) 414 | second_offset = (self.green_height(height) - self.second_green_height(height)) * smoothen_curve( 415 | self.get_age_coefficient()) 416 | 417 | painter.drawPolygon( 418 | QPointF(-self.second_green_width(width) * smoothen_curve(self.get_age_coefficient()) ** 2, 419 | offset + second_offset), 420 | QPointF(self.second_green_width(width) * smoothen_curve(self.get_age_coefficient()) ** 2, 421 | offset + second_offset), 422 | QPointF(0, min( 423 | self.second_green_height(height) * smoothen_curve(self.get_age_coefficient()) + offset + second_offset, 424 | height * 0.95))) 425 | 426 | super()._draw(painter, width, height) 427 | -------------------------------------------------------------------------------- /florodoro/__init__.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | import sys 4 | import tempfile 5 | from datetime import datetime, timedelta 6 | from functools import partial 7 | from random import choice 8 | 9 | import qtawesome 10 | import yaml 11 | from PyQt5.QtCore import QTimer, QTime, Qt, QDir, QUrl 12 | from PyQt5.QtGui import QIcon, QKeyEvent 13 | from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer 14 | from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QPushButton, QSpinBox, QAction, QSizePolicy, \ 15 | QMessageBox, QMenuBar, QStackedLayout, QSlider, QWidgetAction 16 | from PyQt5.QtWidgets import QVBoxLayout, QLabel 17 | from plyer import notification 18 | 19 | from florodoro.version import __version__ 20 | from florodoro.history import History 21 | from florodoro.plants import GreenTree, DoubleGreenTree, OrangeTree, CircularFlower 22 | from florodoro.widgets import Canvas, Statistics, SpacedQWidget 23 | 24 | 25 | class Florodoro(QWidget): 26 | 27 | def parseArguments(self): 28 | parser = argparse.ArgumentParser( 29 | description="A pomodoro timer that grows procedurally generated trees and flowers while you're studying.", 30 | ) 31 | 32 | parser.add_argument( 33 | "-d", 34 | "--debug", 35 | action="store_true", 36 | help="start Florodoro in debug mode", 37 | ) 38 | 39 | parser.add_argument( 40 | "-v", 41 | "--version", 42 | action="store_true", 43 | help="print current version", 44 | ) 45 | 46 | return parser.parse_args() 47 | 48 | def __init__(self): 49 | super().__init__() 50 | 51 | arguments = self.parseArguments() 52 | 53 | if arguments.version: 54 | print(__version__) 55 | quit() 56 | 57 | self.DEBUG = arguments.debug 58 | 59 | os.chdir(os.path.dirname(os.path.realpath(__file__))) 60 | 61 | self.MIN_WIDTH = 600 62 | self.MIN_HEIGHT = 350 63 | 64 | self.setMinimumWidth(self.MIN_WIDTH) 65 | self.setMinimumHeight(self.MIN_HEIGHT) 66 | 67 | self.ROOT_FOLDER = os.path.expanduser("~/.florodoro/") 68 | 69 | self.HISTORY_FILE_PATH = self.ROOT_FOLDER + "history" + ("" if not self.DEBUG else "-debug") + ".yaml" 70 | self.CONFIGURATION_FILE_PATH = self.ROOT_FOLDER + "config" + ("" if not self.DEBUG else "-debug") + ".yaml" 71 | 72 | self.history = History(self.HISTORY_FILE_PATH) 73 | 74 | self.SOUNDS_FOLDER = "sounds/" 75 | self.PLANTS_FOLDER = "plants/" 76 | self.IMAGE_FOLDER = "images/" 77 | 78 | self.TEXT_COLOR = self.palette().text().color() 79 | self.BREAK_COLOR = "#B37700" 80 | 81 | self.APP_NAME = "Florodoro" 82 | 83 | self.STUDY_ICON = qtawesome.icon('fa5s.book', color=self.TEXT_COLOR) 84 | self.BREAK_ICON = qtawesome.icon('fa5s.coffee', color=self.BREAK_COLOR) 85 | self.CONTINUE_ICON = qtawesome.icon('fa5s.play', color=self.TEXT_COLOR) 86 | self.PAUSE_ICON = qtawesome.icon('fa5s.pause', color=self.TEXT_COLOR) 87 | self.RESET_ICON = qtawesome.icon('fa5s.undo', color=self.TEXT_COLOR) 88 | 89 | self.PLANTS = [GreenTree, DoubleGreenTree, OrangeTree, CircularFlower] 90 | self.PLANT_NAMES = ["Spruce", "Double spruce", "Maple", "Flower"] 91 | 92 | self.WIDGET_SPACING = 10 93 | 94 | self.MAX_TIME = 180 95 | self.STEP = 1 96 | 97 | self.INITIAL_TEXT = "Start!" 98 | 99 | self.menuBar = QMenuBar(self) 100 | self.presets_menu = self.menuBar.addMenu('&Presets') 101 | 102 | self.presets = { 103 | "Classic": (25, 5, 4), 104 | "Extended": (45, 12, 2), 105 | "Sitcomodoro": (65, 25, 1), 106 | } 107 | 108 | for name in self.presets: 109 | study_time, break_time, cycles = self.presets[name] 110 | 111 | self.presets_menu.addAction( 112 | QAction(f"{name} ({study_time} : {break_time} : {cycles})", self, 113 | triggered=partial(self.load_preset, study_time, break_time, cycles))) 114 | 115 | self.DEFAULT_PRESET = "Classic" 116 | 117 | self.options_menu = self.menuBar.addMenu('&Options') 118 | 119 | self.notify_menu = self.options_menu.addMenu("&Notify") 120 | 121 | self.sound_action = QAction("&Sound", self, checkable=True, checked=not self.DEBUG, 122 | triggered=lambda _: self.volume_slider.setDisabled( 123 | not self.sound_action.isChecked())) 124 | 125 | self.notify_menu.addAction(self.sound_action) 126 | 127 | self.volume_slider = QSlider(Qt.Horizontal, minimum=0, maximum=100, value=85) 128 | slider_action = QWidgetAction(self) 129 | slider_action.setDefaultWidget(SpacedQWidget(self.volume_slider)) 130 | self.notify_menu.addAction(slider_action) 131 | 132 | self.popup_action = QAction("&Pop-up", self, checkable=True, checked=True) 133 | self.notify_menu.addAction(self.popup_action) 134 | 135 | self.menuBar.addAction( 136 | QAction( 137 | "&Statistics", 138 | self, 139 | triggered=lambda: self.statistics.show() if self.statistics.isHidden() else self.statistics.hide() 140 | ) 141 | ) 142 | 143 | self.menuBar.addAction( 144 | QAction( 145 | "&About", 146 | self, 147 | triggered=lambda: QMessageBox.information( 148 | self, 149 | "About", 150 | f"

Florodoro v{__version__}

" 151 | "This application was created by Tomáš Sláma. It is heavily inspired by the Android app Forest, " 152 | "but with all of the plants generated procedurally. It's open source and licensed " 153 | "under GPLv3.", 154 | ), 155 | ) 156 | ) 157 | 158 | self.plant_menu = self.options_menu.addMenu("&Plants") 159 | 160 | self.overstudy_action = QAction("Overstudy", self, checkable=True) 161 | self.options_menu.addAction(self.overstudy_action) 162 | 163 | self.plant_images = [] 164 | self.plant_checkboxes = [] 165 | 166 | # dynamically create widgets for each plant 167 | for plant, name in zip(self.PLANTS, self.PLANT_NAMES): 168 | self.plant_images.append(tempfile.NamedTemporaryFile(suffix=".svg")) 169 | tmp = plant() 170 | tmp.set_age(float('inf')) 171 | tmp.save(self.plant_images[-1].name, 200, 200) 172 | 173 | setattr(self.__class__, name, 174 | QAction(self, icon=QIcon(self.plant_images[-1].name), text=name, checkable=True, checked=True)) 175 | 176 | action = getattr(self.__class__, name) 177 | 178 | self.plant_menu.addAction(action) 179 | self.plant_checkboxes.append(action) 180 | 181 | # the current plant that we're growing 182 | # if set to none, no plant is growing 183 | self.plant = None 184 | 185 | self.menuBar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) 186 | 187 | main_vertical_layout = QVBoxLayout(self) 188 | main_vertical_layout.setContentsMargins(0, 0, 0, 0) 189 | main_vertical_layout.setSpacing(0) 190 | main_vertical_layout.addWidget(self.menuBar) 191 | 192 | self.canvas = Canvas(self) 193 | 194 | self.statistics = Statistics(self.history) 195 | 196 | font = self.font() 197 | font.setPointSize(100) 198 | 199 | self.main_label = QLabel(self, alignment=Qt.AlignCenter) 200 | self.main_label.setFont(font) 201 | self.main_label.setText(self.INITIAL_TEXT) 202 | 203 | font.setPointSize(26) 204 | self.cycle_label = QLabel(self) 205 | self.cycle_label.setAlignment(Qt.AlignLeft | Qt.AlignTop) 206 | self.cycle_label.setMargin(20) 207 | self.cycle_label.setFont(font) 208 | 209 | self.status_label = QLabel(self) 210 | self.status_label.setAlignment(Qt.AlignRight | Qt.AlignTop) 211 | self.status_label.setMargin(20) 212 | self.status_label.setFont(font) 213 | 214 | main_horizontal_layout = QHBoxLayout(self) 215 | 216 | self.study_time_spinbox = QSpinBox(self, prefix="Study for: ", suffix="min.", minimum=1, maximum=self.MAX_TIME, 217 | singleStep=self.STEP) 218 | 219 | self.break_time_spinbox = QSpinBox(self, prefix="Break for: ", suffix="min.", minimum=1, maximum=self.MAX_TIME, 220 | singleStep=self.STEP, 221 | styleSheet=f'color:{self.BREAK_COLOR};') 222 | 223 | self.cycles_spinbox = QSpinBox(self, prefix="Cycles: ", minimum=0, value=1) 224 | self.cycles_spinbox.setSpecialValueText("Cycles: infinite") 225 | 226 | # keep track of remaining number of cycles and the starting number of cycles 227 | # this is separate from the cycles spinbox because it can change during the session 228 | self.remaining_cycles = 0 229 | self.total_cycles = 0 230 | 231 | # whether we're currently studying 232 | self.is_study_ongoing = False 233 | self.is_break_ongoing = False 234 | 235 | # whether we notified the user already during overstudy 236 | self.already_notified = False 237 | 238 | stacked_layout = QStackedLayout(self, stackingMode=QStackedLayout.StackAll) 239 | stacked_layout.addWidget(self.main_label) 240 | stacked_layout.addWidget(self.cycle_label) 241 | stacked_layout.addWidget(self.status_label) 242 | stacked_layout.addWidget(self.canvas) 243 | 244 | main_vertical_layout.addLayout(stacked_layout) 245 | 246 | self.setStyleSheet("") 247 | 248 | self.study_button = QPushButton(self, clicked=self.start, icon=self.STUDY_ICON) 249 | self.break_button = QPushButton(self, clicked=lambda: self.start(do_break=True), icon=self.BREAK_ICON) 250 | self.pause_button = QPushButton(self, clicked=self.toggle_pause, icon=self.PAUSE_ICON) 251 | self.reset_button = QPushButton(self, clicked=self.reset, icon=self.RESET_ICON) 252 | 253 | main_horizontal_layout.addWidget(self.study_time_spinbox) 254 | main_horizontal_layout.addWidget(self.break_time_spinbox) 255 | main_horizontal_layout.addWidget(self.cycles_spinbox) 256 | main_horizontal_layout.addWidget(self.study_button) 257 | main_horizontal_layout.addWidget(self.break_button) 258 | main_horizontal_layout.addWidget(self.pause_button) 259 | main_horizontal_layout.addWidget(self.reset_button) 260 | 261 | main_vertical_layout.addLayout(main_horizontal_layout) 262 | 263 | self.setLayout(main_vertical_layout) 264 | 265 | self.study_timer_frequency = 1 / 60 * 1000 266 | self.study_timer = QTimer(self, interval=int(self.study_timer_frequency), timeout=self.decrease_remaining_time) 267 | 268 | self.player = QMediaPlayer(self) 269 | 270 | self.setWindowIcon(QIcon(self.IMAGE_FOLDER + "icon.svg")) 271 | self.setWindowTitle(self.APP_NAME) 272 | 273 | # set initial UI state 274 | self.reset() 275 | 276 | # a list of name, getter and setter things to load/save when the app opens/closes 277 | # also dynamically get settings for selecting/unselecting plants 278 | self.CONFIGURATION_ATTRIBUTES = [("study-time", self.study_time_spinbox.value, 279 | self.study_time_spinbox.setValue), 280 | ("break-time", self.break_time_spinbox.value, 281 | self.break_time_spinbox.setValue), 282 | ("cycles", self.cycles_spinbox.value, self.cycles_spinbox.setValue), 283 | ("sound", self.sound_action.isChecked, self.sound_action.setChecked), 284 | ("sound-volume", self.volume_slider.value, self.volume_slider.setValue), 285 | ("pop-ups", self.popup_action.isChecked, self.popup_action.setChecked), 286 | ("overstudy", self.overstudy_action.isChecked, 287 | self.overstudy_action.setChecked)] + \ 288 | [(name.lower(), getattr(self.__class__, name).isChecked, 289 | getattr(self.__class__, name).setChecked) for _, name in 290 | zip(self.PLANTS, self.PLANT_NAMES)] 291 | # load the default preset 292 | self.load_preset(*self.presets[self.DEFAULT_PRESET]) 293 | 294 | self.load_settings() 295 | self.show() 296 | 297 | def load_settings(self): 298 | """Loads the settings file (if it exists).""" 299 | if os.path.exists(self.CONFIGURATION_FILE_PATH): 300 | with open(self.CONFIGURATION_FILE_PATH) as file: 301 | configuration = yaml.load(file, Loader=yaml.FullLoader) 302 | 303 | # don't crash if config is broken 304 | if not isinstance(configuration, dict): 305 | return 306 | 307 | for key in configuration: 308 | for name, _, setter in self.CONFIGURATION_ATTRIBUTES: 309 | if key == name: 310 | setter(configuration[key]) 311 | 312 | def save_settings(self): 313 | """Saves the settings file (if it exists).""" 314 | if not os.path.exists(self.ROOT_FOLDER): 315 | os.mkdir(self.ROOT_FOLDER) 316 | 317 | with open(self.CONFIGURATION_FILE_PATH, 'w') as file: 318 | configuration = {} 319 | 320 | for name, getter, _ in self.CONFIGURATION_ATTRIBUTES: 321 | configuration[name] = getter() 322 | 323 | file.write(yaml.dump(configuration)) 324 | 325 | def closeEvent(self, event): 326 | """Called when the app is being closed. Overridden to also save Florodoro settings.""" 327 | self.save_settings() 328 | super().closeEvent(event) 329 | 330 | def load_preset(self, study_value: int, break_value: int, cycles: int): 331 | """Load a pomodoro preset.""" 332 | self.study_time_spinbox.setValue(study_value) 333 | self.break_time_spinbox.setValue(break_value) 334 | self.cycles_spinbox.setValue(cycles) 335 | 336 | def infinite_cycles(self) -> bool: 337 | """Return True if we're doing an infinite number of cycles.""" 338 | return self.cycles_spinbox.value() == 0 339 | 340 | def start(self, do_break=False): 341 | """The function for starting either the study or break timer (depending on do_break). 342 | If save_study_or_break is set to true, the break/study that was ongoing will be saved.""" 343 | 344 | self.save() 345 | 346 | self.study_button.setEnabled(do_break) 347 | self.break_button.setEnabled(not do_break) 348 | self.reset_button.setDisabled(False) 349 | 350 | self.pause_button.setDisabled(False) 351 | self.pause_button.setIcon(self.PAUSE_ICON) 352 | 353 | if not do_break: 354 | # if we're initially starting to do cycles, reset their count 355 | # don't reset on break, because we could be doing a standalone break 356 | if self.remaining_cycles == 0: 357 | self.remaining_cycles = self.cycles_spinbox.value() 358 | self.total_cycles = self.remaining_cycles 359 | 360 | # when we're doing infinite cycles, the remaining cycles are negative 361 | # this is to determine when the infinite cycle started 362 | if self.remaining_cycles == 0: 363 | self.remaining_cycles -= 1 364 | 365 | elif not self.is_study_ongoing: 366 | self.remaining_cycles -= 1 367 | 368 | if self.remaining_cycles == 0 and not self.infinite_cycles(): 369 | self.reset() 370 | return 371 | 372 | # set depending on whether we are currently studying or not 373 | self.is_break_ongoing = do_break 374 | self.is_study_ongoing = not do_break 375 | self.already_notified = False 376 | 377 | self.main_label.setStyleSheet('' if not do_break else f'color:{self.BREAK_COLOR};') 378 | 379 | # the total time to study for (spinboxes are minutes) 380 | # since it's rounded down and it looks better to start at the exact time, 0.99 is added 381 | self.total_time = (self.study_time_spinbox if not do_break else self.break_time_spinbox).value() * 60 + 0.99 382 | self.ending_time = datetime.now() + timedelta(minutes=self.total_time / 60) 383 | 384 | # don't start showing canvas and growing the plant when we're not studying 385 | if not do_break: 386 | possible_plants = [plant for i, plant in enumerate(self.PLANTS) if self.plant_checkboxes[i].isChecked()] 387 | 388 | if len(possible_plants) != 0: 389 | self.plant = choice(possible_plants)() 390 | self.canvas.set_drawable(self.plant) 391 | self.plant.set_age(0) 392 | else: 393 | self.plant = None 394 | 395 | self.study_timer.stop() # it could be running - we could be currently in a break 396 | self.study_timer.start() 397 | 398 | # so it's displayed immediately 399 | self.update_time_label(self.total_time) 400 | self.update_cycles_label() 401 | self.update_status_label() 402 | 403 | def toggle_pause(self): 404 | """Called when the pause button is pressed. 405 | Either stops the timer or starts it again, while also doing stuff to the pause icons.""" 406 | 407 | # stop the timer, if it's running 408 | if self.study_timer.isActive(): 409 | self.study_timer.stop() 410 | self.pause_button.setIcon(self.CONTINUE_ICON) 411 | self.pause_time = datetime.now() 412 | 413 | # if not, resume 414 | else: 415 | self.ending_time += datetime.now() - self.pause_time 416 | self.study_timer.start() 417 | self.pause_button.setIcon(self.PAUSE_ICON) 418 | 419 | self.update_status_label() 420 | 421 | def save(self): 422 | """Save a study or break, whichever is currently running.""" 423 | if self.is_study_ongoing: 424 | self.save_study() 425 | 426 | if self.is_break_ongoing: 427 | self.save_break() 428 | 429 | def reset(self): 430 | """Reset the UI.""" 431 | self.study_timer.stop() 432 | self.pause_button.setIcon(self.PAUSE_ICON) 433 | 434 | self.main_label.setStyleSheet('') 435 | self.study_button.setDisabled(False) 436 | self.break_button.setDisabled(False) 437 | self.pause_button.setDisabled(True) 438 | self.reset_button.setDisabled(True) 439 | 440 | if self.plant is not None: 441 | self.plant.set_age(0) 442 | 443 | self.remaining_cycles = 0 444 | 445 | self.main_label.setText(self.INITIAL_TEXT) 446 | self.cycle_label.setText('') 447 | self.status_label.setText('') 448 | 449 | def update_time_label(self, time): 450 | """Update the text of the time label, given some time in seconds.""" 451 | sign = -1 if time < 0 else 1 452 | 453 | # done to immediately display -1 when time goes negative 454 | time = abs(time) + (1 if sign == -1 else 0) 455 | 456 | hours = int(time // 3600) 457 | minutes = int((time // 60) % 60) 458 | seconds = int(time % 60) 459 | 460 | # smooth timer: hide minutes/hours if there are none 461 | result = "-" if sign == -1 else "" 462 | if hours == 0: 463 | if minutes == 0: 464 | result += str(seconds) 465 | else: 466 | result += str(minutes) + QTime(0, 0, seconds).toString(":ss") 467 | else: 468 | result += str(hours) + QTime(0, minutes, seconds).toString(":mm:ss") 469 | 470 | self.main_label.setText(result) 471 | 472 | def play_sound(self, name: str): 473 | """Play a file from the sound directory. Extension is not included, will be added automatically.""" 474 | for file in os.listdir(self.SOUNDS_FOLDER): 475 | # if the file starts with the provided name and only contains an extension after, try to play it 476 | if file.startswith(name) and file[len(name):][0] == ".": 477 | path = QDir.current().absoluteFilePath(self.SOUNDS_FOLDER + file) 478 | url = QUrl.fromLocalFile(path) 479 | content = QMediaContent(url) 480 | self.player.setMedia(content) 481 | self.player.setVolume(self.volume_slider.value()) 482 | self.player.play() 483 | 484 | def show_notification(self, message: str): 485 | """Show the specified notification using plyer.""" 486 | notification.notify(self.APP_NAME, message, self.APP_NAME, os.path.abspath(self.IMAGE_FOLDER + "icon.svg")) 487 | 488 | def update_cycles_label(self): 489 | """Update the cycles label, if we're currently studying and it wouldn't be 1/1. 490 | If there are 0 total cycles, we're assuming infinity.""" 491 | if self.total_cycles != 1 and self.is_study_ongoing: 492 | if self.total_cycles == 0: 493 | self.cycle_label.setText(f"{- self.remaining_cycles}/∞") 494 | else: 495 | self.cycle_label.setText(f"{self.total_cycles - self.remaining_cycles + 1}/{self.total_cycles}") 496 | 497 | def update_status_label(self): 498 | """Says Studying / Paused / Breaking, depending on what's going on.""" 499 | if self.is_study_ongoing: 500 | self.status_label.setText('Studying') 501 | 502 | if not self.study_timer.isActive(): 503 | self.status_label.setText('Paused (studying)') 504 | 505 | elif self.is_break_ongoing: 506 | self.status_label.setText('Breaking') 507 | 508 | if not self.study_timer.isActive(): 509 | self.status_label.setText('Paused (breaking)') 510 | 511 | def get_leftover_time(self): 512 | """Return time until the timer runs out (in seconds). Can be negative!""" 513 | return (self.ending_time - datetime.now()).total_seconds() 514 | 515 | def decrease_remaining_time(self): 516 | """Decrease the remaining time by the timer frequency. Updates clock/plant growth.""" 517 | if self.DEBUG: 518 | self.ending_time -= timedelta(seconds=30) 519 | 520 | self.update_time_label(self.get_leftover_time()) 521 | 522 | if self.get_leftover_time() <= 0: 523 | if self.is_study_ongoing: 524 | if not self.already_notified: 525 | if self.sound_action.isChecked(): 526 | self.play_sound("study_done") 527 | 528 | if self.popup_action.isChecked(): 529 | self.show_notification("Studying finished, take a break!") 530 | 531 | self.already_notified = True 532 | 533 | if not self.overstudy_action.isChecked(): 534 | self.start(do_break=True) 535 | 536 | elif self.is_break_ongoing: 537 | if not self.already_notified: 538 | if self.sound_action.isChecked(): 539 | self.play_sound("break_done") 540 | 541 | if self.popup_action.isChecked(): 542 | self.show_notification("Break is over!") 543 | 544 | self.already_notified = True 545 | 546 | if not self.overstudy_action.isChecked(): 547 | if self.remaining_cycles == 0: 548 | self.save_break() 549 | self.reset() 550 | else: 551 | self.start() 552 | self.update_cycles_label() 553 | 554 | # if we haven't finished studying, grow the plant 555 | if self.is_study_ongoing: 556 | if self.plant is not None: 557 | self.plant.set_age(self.duration()) 558 | 559 | self.canvas.update() 560 | 561 | def duration(self): 562 | """Get the current duration of whatever is currently going on (in minutes).""" 563 | return (self.total_time - self.get_leftover_time()) / 60 564 | 565 | def save_break(self): 566 | self.history.add_break(datetime.now(), self.duration()) 567 | 568 | self.statistics.refresh() 569 | 570 | def save_study(self): 571 | """Save the record of the current study to the history file.""" 572 | self.history.add_study(datetime.now(), self.duration(), self.plant) 573 | 574 | self.statistics.move() 575 | self.statistics.refresh() 576 | 577 | 578 | def run(): 579 | app = QApplication(sys.argv) 580 | Florodoro() 581 | app.exit(app.exec_()) 582 | 583 | 584 | if __name__ == '__main__': 585 | run() 586 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | -------------------------------------------------------------------------------- /florodoro/images/preview.svg: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 24 | 26 | image/svg+xml 27 | 29 | 30 | 31 | 32 | 33 | 35 | 59 | 64 | 474 | 483 | 484 | 485 | --------------------------------------------------------------------------------