initial functional file indexer, added Qt / C++ port of Cartographer
This commit is contained in:
parent
fae3d30dbd
commit
c52386abb4
19 changed files with 721 additions and 149 deletions
|
@ -1,40 +1,43 @@
|
|||
#include "config.hpp"
|
||||
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
KotoConfig::KotoConfig() {
|
||||
// Define our application's config location
|
||||
auto configDir = QDir(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::AppConfigLocation));
|
||||
auto configDirPath = configDir.absolutePath();
|
||||
fs::path filePath {};
|
||||
auto configPathStd = configDirPath.toStdString();
|
||||
filePath /= configPathStd;
|
||||
filePath /= "config.toml";
|
||||
// Define our application's config location
|
||||
auto configDir = QDir(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::AppConfigLocation));
|
||||
auto configDirPath = configDir.absolutePath();
|
||||
fs::path filePath {};
|
||||
auto configPathStd = configDirPath.toStdString();
|
||||
filePath /= configPathStd;
|
||||
filePath /= "config.toml";
|
||||
|
||||
auto data = toml::parse(filePath);
|
||||
std::optional<toml::value> ui_prefs;
|
||||
auto data = toml::parse(filePath);
|
||||
std::optional<toml::value> ui_prefs;
|
||||
|
||||
if (data.contains("preferences.ui")) {
|
||||
auto ui_prefs_at = data.at("preferences.ui");
|
||||
if (ui_prefs_at.is_table()) ui_prefs = ui_prefs_at.as_table();
|
||||
}
|
||||
if (data.contains("preferences.ui")) {
|
||||
auto ui_prefs_at = data.at("preferences.ui");
|
||||
if (ui_prefs_at.is_table()) ui_prefs = ui_prefs_at.as_table();
|
||||
}
|
||||
|
||||
auto prefs = KotoUiPreferences(ui_prefs);
|
||||
this->i_uiPreferences = &prefs;
|
||||
auto prefs = KotoUiPreferences(ui_prefs);
|
||||
this->i_uiPreferences = &prefs;
|
||||
|
||||
this->i_libraries = {};
|
||||
for (const auto& lib_value : toml::find<std::vector<toml::value>>(data, "libraries")) {
|
||||
auto lib = KotoLibraryConfig(lib_value);
|
||||
this->i_libraries.push_back(lib);
|
||||
}
|
||||
this->i_libraries = {};
|
||||
for (const auto& lib_value : toml::find<std::vector<toml::value>>(data, "libraries")) {
|
||||
auto lib = KotoLibraryConfig(lib_value);
|
||||
this->i_libraries.push_back(lib);
|
||||
}
|
||||
}
|
||||
|
||||
KotoUiPreferences * KotoConfig::getUiPreferences() {
|
||||
return this->i_uiPreferences;
|
||||
KotoConfig::~KotoConfig() {}
|
||||
|
||||
KotoUiPreferences* KotoConfig::getUiPreferences() {
|
||||
return this->i_uiPreferences;
|
||||
}
|
||||
|
||||
std::vector<KotoLibraryConfig> KotoConfig::getLibraries() {
|
||||
return this->i_libraries;
|
||||
return this->i_libraries;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,25 @@
|
|||
#include "library.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <string>
|
||||
|
||||
KotoLibraryConfig::KotoLibraryConfig(const toml::value &v) {
|
||||
this->i_name = toml::find<std::string>(v, "name");
|
||||
this->i_path = toml::find<std::string>(v, "path");
|
||||
KotoLibraryConfig::KotoLibraryConfig(std::string name, fs::path path) {
|
||||
this->i_name = name;
|
||||
this->i_path = path;
|
||||
qDebug() << "Library: " << this->i_name.c_str() << " at " << this->i_path.c_str();
|
||||
}
|
||||
|
||||
KotoLibraryConfig::~KotoLibraryConfig() {}
|
||||
|
||||
KotoLibraryConfig::KotoLibraryConfig(const toml::value& v) {
|
||||
this->i_name = toml::find<std::string>(v, "name");
|
||||
this->i_path = toml::find<std::string>(v, "path");
|
||||
}
|
||||
|
||||
std::string KotoLibraryConfig::getName() {
|
||||
return this->i_name;
|
||||
return this->i_name;
|
||||
}
|
||||
|
||||
fs::path KotoLibraryConfig::getPath() {
|
||||
return this->i_path;
|
||||
return this->i_path;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
#pragma once
|
||||
#include "includes/toml.hpp"
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
#include "includes/toml.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class KotoLibraryConfig {
|
||||
public:
|
||||
KotoLibraryConfig(const toml::value &v);
|
||||
~KotoLibraryConfig();
|
||||
std::string getName();
|
||||
fs::path getPath();
|
||||
private:
|
||||
std::string i_name;
|
||||
fs::path i_path;
|
||||
public:
|
||||
KotoLibraryConfig(std::string name, fs::path path);
|
||||
KotoLibraryConfig(const toml::value& v);
|
||||
~KotoLibraryConfig();
|
||||
std::string getName();
|
||||
fs::path getPath();
|
||||
|
||||
private:
|
||||
std::string i_name;
|
||||
fs::path i_path;
|
||||
};
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
#include "ui_prefs.hpp"
|
||||
|
||||
KotoUiPreferences::KotoUiPreferences(std::optional<toml::value> v) {
|
||||
this->i_albumInfoShowDescription = true;
|
||||
this->i_albumInfoShowGenre = true;
|
||||
this->i_albumInfoShowNarrator = true;
|
||||
this->i_albumInfoShowYear = true;
|
||||
this->i_lastUsedVolume = 0.5;
|
||||
this->i_albumInfoShowDescription = true;
|
||||
this->i_albumInfoShowGenre = true;
|
||||
this->i_albumInfoShowNarrator = true;
|
||||
this->i_albumInfoShowYear = true;
|
||||
this->i_lastUsedVolume = 0.5;
|
||||
|
||||
// No UI prefs provided
|
||||
if (!v.has_value()) return;
|
||||
toml::value& uiPrefs = v.value();
|
||||
this->i_albumInfoShowDescription = toml::find_or<bool>(uiPrefs, "album_info_show_description", false);
|
||||
this->i_albumInfoShowGenre = toml::find_or<bool>(uiPrefs, "album_info_show_genre", false);
|
||||
this->i_albumInfoShowNarrator = toml::find_or<bool>(uiPrefs, "album_info_show_narrator", false);
|
||||
this->i_albumInfoShowYear = toml::find_or<bool>(uiPrefs, "album_info_show_year", false);
|
||||
this->i_lastUsedVolume = toml::find_or<float>(uiPrefs, "last_used_volume", 0.5);
|
||||
// No UI prefs provided
|
||||
if (!v.has_value()) return;
|
||||
toml::value& uiPrefs = v.value();
|
||||
this->i_albumInfoShowDescription = toml::find_or<bool>(uiPrefs, "album_info_show_description", false);
|
||||
this->i_albumInfoShowGenre = toml::find_or<bool>(uiPrefs, "album_info_show_genre", false);
|
||||
this->i_albumInfoShowNarrator = toml::find_or<bool>(uiPrefs, "album_info_show_narrator", false);
|
||||
this->i_albumInfoShowYear = toml::find_or<bool>(uiPrefs, "album_info_show_year", false);
|
||||
this->i_lastUsedVolume = toml::find_or<float>(uiPrefs, "last_used_volume", 0.5);
|
||||
}
|
||||
|
||||
KotoUiPreferences::~KotoUiPreferences() {}
|
||||
|
||||
bool KotoUiPreferences::getAlbumInfoShowDescription() {
|
||||
return this->i_albumInfoShowDescription;
|
||||
return this->i_albumInfoShowDescription;
|
||||
}
|
||||
|
||||
bool KotoUiPreferences::getAlbumInfoShowGenre() {
|
||||
return this->i_albumInfoShowGenre;
|
||||
return this->i_albumInfoShowGenre;
|
||||
}
|
||||
|
||||
bool KotoUiPreferences::getAlbumInfoShowNarrator() {
|
||||
return this->i_albumInfoShowNarrator;
|
||||
return this->i_albumInfoShowNarrator;
|
||||
}
|
||||
|
||||
bool KotoUiPreferences::getAlbumInfoShowYear() {
|
||||
return this->i_albumInfoShowYear;
|
||||
return this->i_albumInfoShowYear;
|
||||
}
|
||||
|
||||
float KotoUiPreferences::getLastUsedVolume() {
|
||||
return this->i_lastUsedVolume;
|
||||
return this->i_lastUsedVolume;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
#pragma once
|
||||
#include "includes/toml.hpp"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "includes/toml.hpp"
|
||||
|
||||
class KotoUiPreferences {
|
||||
public:
|
||||
KotoUiPreferences(std::optional<toml::value> v);
|
||||
~KotoUiPreferences();
|
||||
public:
|
||||
KotoUiPreferences(std::optional<toml::value> v);
|
||||
~KotoUiPreferences();
|
||||
|
||||
bool getAlbumInfoShowDescription();
|
||||
bool getAlbumInfoShowGenre();
|
||||
bool getAlbumInfoShowNarrator();
|
||||
bool getAlbumInfoShowYear();
|
||||
float getLastUsedVolume();
|
||||
bool getAlbumInfoShowDescription();
|
||||
bool getAlbumInfoShowGenre();
|
||||
bool getAlbumInfoShowNarrator();
|
||||
bool getAlbumInfoShowYear();
|
||||
float getLastUsedVolume();
|
||||
|
||||
void setAlbumInfoShowDescription(bool show);
|
||||
void setAlbumInfoShowGenre(bool show);
|
||||
void setAlbumInfoShowNarrator(bool show);
|
||||
void setAlbumInfoShowYear(bool show);
|
||||
void setLastUsedVolume(float volume);
|
||||
private:
|
||||
bool i_albumInfoShowDescription;
|
||||
bool i_albumInfoShowGenre;
|
||||
bool i_albumInfoShowNarrator;
|
||||
bool i_albumInfoShowYear;
|
||||
float i_lastUsedVolume;
|
||||
void setAlbumInfoShowDescription(bool show);
|
||||
void setAlbumInfoShowGenre(bool show);
|
||||
void setAlbumInfoShowNarrator(bool show);
|
||||
void setAlbumInfoShowYear(bool show);
|
||||
void setLastUsedVolume(float volume);
|
||||
|
||||
private:
|
||||
bool i_albumInfoShowDescription;
|
||||
bool i_albumInfoShowGenre;
|
||||
bool i_albumInfoShowNarrator;
|
||||
bool i_albumInfoShowYear;
|
||||
float i_lastUsedVolume;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue