Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
favourite_manager.h
1/*
2 * Copyright © 2017-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "model/favourite/favourite_manager.h"
22#include "storage/storage_manager.h"
23#include <cstdint>
24#include <functional>
25#include <string>
26#include <vector>
27
28class FavouritesManager {
29public:
30 struct Favorite {
31 int position;
32 std::optional<uint8_t> colour;
33 std::string filename;
34 };
35
36public:
37 FavouritesManager();
38 ~FavouritesManager();
39
40 void setCategory(const std::string& category);
41 void selectFavouritesBank(uint8_t bankNumber);
42 void setFavorite(uint8_t position, uint8_t colour, const std::string& filename);
43 void unsetFavorite(uint8_t position);
44 bool isEmpty(uint8_t position) const;
45 Error loadFavouritesFromFile(Deserializer& reader);
46 void close();
47 std::array<std::optional<uint8_t>, 16> getFavouriteColours() const;
48 void changeColour(uint8_t position, int32_t offset);
49 const std::string& getFavoriteFilename(uint8_t position);
50 static constexpr uint8_t favouriteDefaultColor = 4;
51
52 uint8_t currentBankNumber;
53 std::optional<uint8_t> currentFavouriteNumber;
54
55private:
56 void loadFavouritesBank();
57 void saveFavouriteBank() const;
58
59 std::string getFilenameForSave() const;
60 mutable bool unsavedChanges = false;
61
62 std::string currentCategory;
63 std::vector<Favorite> favourites;
64};
65
66extern FavouritesManager favouritesManager;
Definition storage_manager.h:185
Definition favourite_manager.h:28
Definition favourite_manager.h:30