Dashboard GUI update: add button to start pairing, add banner warning about missing monado layers

This commit is contained in:
Guillaume Meunier
2024-11-26 23:59:35 +01:00
committed by Patrick Nicolas
parent ad7beaf80f
commit 6209d5e6d5
8 changed files with 314 additions and 71 deletions
+46
View File
@@ -0,0 +1,46 @@
/*
* WiVRn VR streaming
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "strings.h"
std::string utils::trim(std::string input)
{
input.resize(input.find_last_not_of("\n ") + 1);
return input;
}
std::vector<std::string> utils::split(const std::string & s, const std::string & sep)
{
std::string::size_type i = 0;
std::vector<std::string> v;
while (true)
{
std::string::size_type j = s.find_first_of(sep, i);
if (j == std::string::npos)
{
v.push_back(s.substr(i));
return v;
}
v.push_back(s.substr(i, j - i));
i = j + 1;
}
}
+50
View File
@@ -0,0 +1,50 @@
/*
* WiVRn VR streaming
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <sstream>
#include <string>
#include <vector>
namespace utils
{
std::string trim(std::string input);
template <typename T>
std::string join(const std::vector<T> & vec, const std::string & sep = ", ")
{
std::stringstream s;
if (!vec.empty())
{
s << vec[0];
for (size_t i = 1, n = vec.size(); i < n; i++)
{
s << sep << vec[i];
}
}
return s.str();
}
std::vector<std::string> split(const std::string & s, const std::string & sep = "\n");
} // namespace utils
+55 -8
View File
@@ -17,27 +17,74 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "strings.h"
#include <cstdlib>
#include <filesystem>
std::filesystem::path xdg_config_home()
{
const char * xdg_config_home = std::getenv("XDG_CONFIG_HOME");
if (xdg_config_home)
if (const char * xdg_config_home = std::getenv("XDG_CONFIG_HOME"))
return xdg_config_home;
const char * home = std::getenv("HOME");
if (home)
if (const char * home = std::getenv("HOME"))
return std::filesystem::path(home) / ".config";
return ".";
}
std::filesystem::path xdg_cache_home()
{
const char * xdg_cache_home = std::getenv("XDG_CACHE_HOME");
if (xdg_cache_home)
if (const char * xdg_cache_home = std::getenv("XDG_CACHE_HOME"))
return xdg_cache_home;
const char * home = std::getenv("HOME");
if (home)
if (const char * home = std::getenv("HOME"))
return std::filesystem::path(home) / ".cache";
return ".";
}
std::filesystem::path xdg_data_home()
{
if (const char * xdg_data_home = std::getenv("XDG_DATA_HOME"))
return xdg_data_home;
if (const char * home = std::getenv("HOME"))
return std::filesystem::path(home) / ".local/share";
return ".";
}
std::vector<std::filesystem::path> xdg_config_dirs()
{
std::vector<std::filesystem::path> paths;
if (const char * xdg_config_dirs = std::getenv("XDG_CONFIG_DIRS"))
{
for (const auto & path: utils::split(xdg_config_dirs, ":"))
paths.push_back(path);
}
else
{
paths.push_back("/etc/xdg");
}
return paths;
}
std::vector<std::filesystem::path> xdg_data_dirs()
{
std::vector<std::filesystem::path> paths;
if (const char * xdg_config_dirs = std::getenv("XDG_DATA_DIRS"))
{
for (const auto & path: utils::split(xdg_config_dirs, ":"))
paths.push_back(path);
}
else
{
paths.push_back("/usr/local/share");
paths.push_back("/usr/share");
}
return paths;
}
+4
View File
@@ -20,6 +20,10 @@
#pragma once
#include <filesystem>
#include <vector>
std::filesystem::path xdg_config_home();
std::filesystem::path xdg_cache_home();
std::filesystem::path xdg_data_home();
std::vector<std::filesystem::path> xdg_config_dirs();
std::vector<std::filesystem::path> xdg_data_dirs();