Skip to content
Snippets Groups Projects
Commit 8d4598c0 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Improve config window style

parent f3d893b9
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28532 failed
...@@ -25,6 +25,7 @@ set(GUI2SRC ...@@ -25,6 +25,7 @@ set(GUI2SRC
src/widgets/popupbutton.cpp src/widgets/popupbutton.cpp
src/widgets/imageview.cpp src/widgets/imageview.cpp
src/widgets/combobox.cpp src/widgets/combobox.cpp
src/widgets/leftbutton.cpp
) )
add_gui_module("themes") add_gui_module("themes")
......
...@@ -33,6 +33,10 @@ std::vector<std::string> AddCtrl::getHosts() { ...@@ -33,6 +33,10 @@ std::vector<std::string> AddCtrl::getHosts() {
return std::move(io->feed()->knownHosts()); return std::move(io->feed()->knownHosts());
} }
std::vector<std::string> AddCtrl::getGroups() {
return {};
}
std::set<ftl::stream::SourceInfo> AddCtrl::getRecent() { std::set<ftl::stream::SourceInfo> AddCtrl::getRecent() {
return std::move(io->feed()->recentSources()); return std::move(io->feed()->recentSources());
} }
......
...@@ -26,6 +26,7 @@ public: ...@@ -26,6 +26,7 @@ public:
std::vector<std::string> getNetSources(); std::vector<std::string> getNetSources();
std::vector<std::string> getFileSources(); std::vector<std::string> getFileSources();
std::vector<std::string> getDeviceSources(); std::vector<std::string> getDeviceSources();
std::vector<std::string> getGroups();
std::string getSourceName(const std::string &uri); std::string getSourceName(const std::string &uri);
bool isSourceActive(const std::string &uri); bool isSourceActive(const std::string &uri);
......
...@@ -65,9 +65,9 @@ void Themes::init() { ...@@ -65,9 +65,9 @@ void Themes::init() {
windowtheme_dark->mButtonGradientTopPushed = nanogui::Color(50,255); windowtheme_dark->mButtonGradientTopPushed = nanogui::Color(50,255);
windowtheme_dark->mButtonGradientBotPushed = nanogui::Color(90,255);*/ windowtheme_dark->mButtonGradientBotPushed = nanogui::Color(90,255);*/
windowtheme_dark->mButtonGradientBotFocused = nanogui::Color(60,255); windowtheme_dark->mButtonGradientBotFocused = nanogui::Color(60,255);
windowtheme_dark->mButtonGradientBotUnfocused = nanogui::Color(30,30,40,180); windowtheme_dark->mButtonGradientBotUnfocused = nanogui::Color(35,35,40,180);
windowtheme_dark->mButtonGradientTopFocused = nanogui::Color(60,255); windowtheme_dark->mButtonGradientTopFocused = nanogui::Color(60,255);
windowtheme_dark->mButtonGradientTopUnfocused = nanogui::Color(30,30,40,180); windowtheme_dark->mButtonGradientTopUnfocused = nanogui::Color(35,35,40,180);
windowtheme_dark->mButtonGradientTopPushed = nanogui::Color(90,180); windowtheme_dark->mButtonGradientTopPushed = nanogui::Color(90,180);
windowtheme_dark->mButtonGradientBotPushed = nanogui::Color(90,180); windowtheme_dark->mButtonGradientBotPushed = nanogui::Color(90,180);
windowtheme_dark->mButtonFontSize = 16; windowtheme_dark->mButtonFontSize = 16;
......
...@@ -104,6 +104,20 @@ void AddSourceWindow::rebuild() { ...@@ -104,6 +104,20 @@ void AddSourceWindow::rebuild() {
_addButton(s.uri, recentscroll); _addButton(s.uri, recentscroll);
} }
auto *group_tab = tabs->createTab("Groups");
group_tab->setLayout(new nanogui::BoxLayout
(nanogui::Orientation::Vertical, nanogui::Alignment::Fill, 0, 0));
vscroll = new VScrollPanel(group_tab);
vscroll->setFixedHeight(150);
Widget *groupscroll = new Widget(vscroll);
groupscroll->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 4));
auto groups = ctrl_->getGroups();
for (auto &s : groups) {
_addButton(s, groupscroll);
}
auto *dev_tab = tabs->createTab("Devices"); auto *dev_tab = tabs->createTab("Devices");
dev_tab->setLayout(new nanogui::BoxLayout dev_tab->setLayout(new nanogui::BoxLayout
(nanogui::Orientation::Vertical, nanogui::Alignment::Fill, 0, 0)); (nanogui::Orientation::Vertical, nanogui::Alignment::Fill, 0, 0));
...@@ -126,6 +140,15 @@ void AddSourceWindow::rebuild() { ...@@ -126,6 +140,15 @@ void AddSourceWindow::rebuild() {
Widget *hostscroll = new Widget(vscroll); Widget *hostscroll = new Widget(vscroll);
hostscroll->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 4)); hostscroll->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 4));
button = new Button(hostscroll, "Add Host", ENTYPO_ICON_PLUS);
button->setIconPosition(Button::IconPosition::Left);
button->setIconExtraScale(1.2);
button->setFontSize(18);
button->setTooltip("Manually add a new connection URI");
button->setCallback([this]() {
});
auto hostsrcs = ctrl_->getHosts(); auto hostsrcs = ctrl_->getHosts();
for (auto &s : hostsrcs) { for (auto &s : hostsrcs) {
...@@ -154,7 +177,7 @@ void AddSourceWindow::rebuild() { ...@@ -154,7 +177,7 @@ void AddSourceWindow::rebuild() {
Widget *filescroll = new Widget(vscroll); Widget *filescroll = new Widget(vscroll);
filescroll->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 4)); filescroll->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 4));
button = new Button(filescroll, "Open", ENTYPO_ICON_FOLDER); button = new Button(filescroll, "Open", ENTYPO_ICON_PLUS);
button->setIconPosition(Button::IconPosition::Left); button->setIconPosition(Button::IconPosition::Left);
button->setIconExtraScale(1.2); button->setIconExtraScale(1.2);
button->setFontSize(18); button->setFontSize(18);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "config.hpp" #include "config.hpp"
#include "../screen.hpp" #include "../screen.hpp"
#include "../widgets/leftbutton.hpp"
using ftl::gui2::ConfigWindow; using ftl::gui2::ConfigWindow;
using std::string; using std::string;
...@@ -85,7 +86,7 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl) ...@@ -85,7 +86,7 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl)
using namespace nanogui; using namespace nanogui;
setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_light")); setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_dark"));
auto close = new nanogui::Button(buttonPanel(), "", ENTYPO_ICON_CROSS); auto close = new nanogui::Button(buttonPanel(), "", ENTYPO_ICON_CROSS);
close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_dark")); close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_dark"));
...@@ -93,6 +94,7 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl) ...@@ -93,6 +94,7 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl)
close->setCallback([this](){ dispose();}); close->setCallback([this](){ dispose();});
setLayout(new GroupLayout(15, 6, 14, 10)); setLayout(new GroupLayout(15, 6, 14, 10));
setFixedWidth(400);
setPosition(Vector2i(parent->width()/2.0f - 100.0f, parent->height()/2.0f - 100.0f)); setPosition(Vector2i(parent->width()/2.0f - 100.0f, parent->height()/2.0f - 100.0f));
auto configurables = ftl::config::list(); auto configurables = ftl::config::list();
...@@ -110,7 +112,37 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl) ...@@ -110,7 +112,37 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl)
searchBox->setButtons(buttons); searchBox->setButtons(buttons);
std::vector<std::string> configurable_titles(size); std::vector<std::string> configurable_titles(size);
for (size_t i = 0; i < size; ++i) {
std::set<std::string> sorted_cfgs;
sorted_cfgs.insert(configurables.begin(), configurables.end());
for (auto &c : sorted_cfgs) {
ftl::URI uri(c);
std::string spacing = "";
for (size_t i=0; i<uri.getPathLength(); ++i) {
spacing += " ";
}
//if (uri.getFragment().size() == 0) {
std::string title = spacing + titleForURI(uri);
//configurable_titles[i] = title;
auto itembutton = new ftl::gui2::LeftButton(buttons, title);
/*if (_isEmpty(c)) {
itembutton->setEnabled(false);
}*/
itembutton->setTooltip(c);
//itembutton->setBackgroundColor(nanogui::Color(0.9f,0.9f,0.9f,0.9f));
itembutton->setCallback([this,c]() {
_buildForm(c);
setVisible(false);
dispose();
});
//}
}
/*for (size_t i = 0; i < size; ++i) {
ftl::URI uri(configurables[i]); ftl::URI uri(configurables[i]);
std::string label = uri.getFragment(); std::string label = uri.getFragment();
...@@ -149,7 +181,7 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl) ...@@ -149,7 +181,7 @@ ConfigWindow::ConfigWindow(nanogui::Widget *parent, ftl::ctrl::Master *ctrl)
setVisible(false); setVisible(false);
dispose(); dispose();
}); });
} }*/
} }
ConfigWindow::~ConfigWindow() { ConfigWindow::~ConfigWindow() {
...@@ -213,10 +245,11 @@ void ConfigWindow::__addElements(nanogui::FormHelper *form, const std::string &s ...@@ -213,10 +245,11 @@ void ConfigWindow::__addElements(nanogui::FormHelper *form, const std::string &s
string nuri; string nuri;
// Checking the URI with exists() prevents unloaded local configurations from being shown. // Checking the URI with exists() prevents unloaded local configurations from being shown.
if (suri.find('#') != string::npos && exists(suri+string("/")+key)) { //if (suri.find('#') != string::npos && exists(suri+string("/")+key)) {
// nuri = suri+string("/")+key;
//} else
if (exists(suri+string("/")+key)) {
nuri = suri+string("/")+key; nuri = suri+string("/")+key;
} else if (exists(suri+string("#")+key)) {
nuri = suri+string("#")+key;
} }
if (!nuri.empty()) { if (!nuri.empty()) {
...@@ -226,6 +259,7 @@ void ConfigWindow::__addElements(nanogui::FormHelper *form, const std::string &s ...@@ -226,6 +259,7 @@ void ConfigWindow::__addElements(nanogui::FormHelper *form, const std::string &s
}); });
button->setIcon(ENTYPO_ICON_FOLDER); button->setIcon(ENTYPO_ICON_FOLDER);
button->setIconPosition(nanogui::Button::IconPosition::Left);
if (_isEmpty(nuri)) { if (_isEmpty(nuri)) {
button->setEnabled(false); button->setEnabled(false);
} }
...@@ -284,7 +318,7 @@ void ConfigWindow::buildForm(nanogui::Screen *screen, const std::string &suri) { ...@@ -284,7 +318,7 @@ void ConfigWindow::buildForm(nanogui::Screen *screen, const std::string &suri) {
ftl::URI uri(suri); ftl::URI uri(suri);
FormHelper *form = new FormHelper(screen); FormHelper *form = new FormHelper(screen);
form->addWindow(Vector2i(100,50), uri.getFragment()); form->addWindow(Vector2i(100,50), titleForURI(uri));
//form->window()->setTheme(theme()); //form->window()->setTheme(theme());
{ {
...@@ -292,6 +326,10 @@ void ConfigWindow::buildForm(nanogui::Screen *screen, const std::string &suri) { ...@@ -292,6 +326,10 @@ void ConfigWindow::buildForm(nanogui::Screen *screen, const std::string &suri) {
existing_configs[suri] = form->window(); existing_configs[suri] = form->window();
} }
auto *window = form->window();
window->setTheme(dynamic_cast<ftl::gui2::Screen*>(window->screen())->getTheme("window_dark"));
window->setWidth(200);
__addElements(form, suri); __addElements(form, suri);
// prevent parent window from being destroyed too early // prevent parent window from being destroyed too early
...@@ -301,8 +339,6 @@ void ConfigWindow::buildForm(nanogui::Screen *screen, const std::string &suri) { ...@@ -301,8 +339,6 @@ void ConfigWindow::buildForm(nanogui::Screen *screen, const std::string &suri) {
close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen)->getTheme("window_dark")); close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen)->getTheme("window_dark"));
//close->setBackgroundColor(theme()->mWindowHeaderGradientBot); //close->setBackgroundColor(theme()->mWindowHeaderGradientBot);
auto *window = form->window();
close->setCallback([window, suri](){ close->setCallback([window, suri](){
window->dispose(); window->dispose();
//decRef(); //decRef();
......
#include "leftbutton.hpp"
#include <nanogui/button.h>
#include <nanogui/theme.h>
#include <nanogui/opengl.h>
void ftl::gui2::LeftButton::draw(NVGcontext* ctx) {
using namespace nanogui;
Widget::draw(ctx);
NVGcolor gradTop = mTheme->mButtonGradientTopUnfocused;
NVGcolor gradBot = mTheme->mButtonGradientBotUnfocused;
if (mPushed) {
gradTop = mTheme->mButtonGradientTopPushed;
gradBot = mTheme->mButtonGradientBotPushed;
} else if (mMouseFocus && mEnabled) {
gradTop = mTheme->mButtonGradientTopFocused;
gradBot = mTheme->mButtonGradientBotFocused;
}
nvgBeginPath(ctx);
nvgRoundedRect(ctx, mPos.x() + 1, mPos.y() + 1.0f, mSize.x() - 2,
mSize.y() - 2, mTheme->mButtonCornerRadius - 1);
if (mBackgroundColor.w() != 0) {
nvgFillColor(ctx, Color(mBackgroundColor.head<3>(), 1.f));
nvgFill(ctx);
if (mPushed) {
gradTop.a = gradBot.a = 0.8f;
} else {
double v = 1 - mBackgroundColor.w();
gradTop.a = gradBot.a = mEnabled ? v : v * .5f + .5f;
}
}
NVGpaint bg = nvgLinearGradient(ctx, mPos.x(), mPos.y(), mPos.x(),
mPos.y() + mSize.y(), gradTop, gradBot);
nvgFillPaint(ctx, bg);
nvgFill(ctx);
nvgBeginPath(ctx);
nvgStrokeWidth(ctx, 1.0f);
nvgRoundedRect(ctx, mPos.x() + 0.5f, mPos.y() + (mPushed ? 0.5f : 1.5f), mSize.x() - 1,
mSize.y() - 1 - (mPushed ? 0.0f : 1.0f), mTheme->mButtonCornerRadius);
nvgStrokeColor(ctx, mTheme->mBorderLight);
nvgStroke(ctx);
nvgBeginPath(ctx);
nvgRoundedRect(ctx, mPos.x() + 0.5f, mPos.y() + 0.5f, mSize.x() - 1,
mSize.y() - 2, mTheme->mButtonCornerRadius);
nvgStrokeColor(ctx, mTheme->mBorderDark);
nvgStroke(ctx);
int fontSize = mFontSize == -1 ? mTheme->mButtonFontSize : mFontSize;
nvgFontSize(ctx, fontSize);
nvgFontFace(ctx, "sans-bold");
float tw = nvgTextBounds(ctx, 0,0, mCaption.c_str(), nullptr, nullptr);
Vector2f center = mPos.cast<float>() + mSize.cast<float>() * 0.5f;
Vector2f textPos(mPos.x() + 8, center.y() - 1);
NVGcolor textColor =
mTextColor.w() == 0 ? mTheme->mTextColor : mTextColor;
if (!mEnabled)
textColor = mTheme->mDisabledTextColor;
if (mIcon) {
auto icon = utf8(mIcon);
float iw, ih = fontSize;
if (nvgIsFontIcon(mIcon)) {
ih *= icon_scale();
nvgFontSize(ctx, ih);
nvgFontFace(ctx, "icons");
iw = nvgTextBounds(ctx, 0, 0, icon.data(), nullptr, nullptr);
} else {
int w, h;
ih *= 0.9f;
nvgImageSize(ctx, mIcon, &w, &h);
iw = w * ih / h;
}
if (mCaption != "")
iw += mSize.y() * 0.15f;
nvgFillColor(ctx, textColor);
nvgTextAlign(ctx, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
Vector2f iconPos = center;
iconPos.y() -= 1;
if (mIconPosition == IconPosition::LeftCentered) {
iconPos.x() -= (tw + iw) * 0.5f;
textPos.x() += iw * 0.5f;
} else if (mIconPosition == IconPosition::RightCentered) {
textPos.x() -= iw * 0.5f;
iconPos.x() += tw * 0.5f;
} else if (mIconPosition == IconPosition::Left) {
iconPos.x() = mPos.x() + 8;
} else if (mIconPosition == IconPosition::Right) {
iconPos.x() = mPos.x() + mSize.x() - iw - 8;
}
if (nvgIsFontIcon(mIcon)) {
nvgText(ctx, iconPos.x(), iconPos.y()+1, icon.data(), nullptr);
} else {
NVGpaint imgPaint = nvgImagePattern(ctx,
iconPos.x(), iconPos.y() - ih/2, iw, ih, 0, mIcon, mEnabled ? 0.5f : 0.25f);
nvgFillPaint(ctx, imgPaint);
nvgFill(ctx);
}
}
nvgFontSize(ctx, fontSize);
nvgFontFace(ctx, "sans-bold");
nvgTextAlign(ctx, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
nvgFillColor(ctx, mTheme->mTextColorShadow);
nvgText(ctx, textPos.x(), textPos.y(), mCaption.c_str(), nullptr);
nvgFillColor(ctx, textColor);
nvgText(ctx, textPos.x(), textPos.y() + 1, mCaption.c_str(), nullptr);
}
\ No newline at end of file
#pragma once
#include <nanogui/button.h>
namespace ftl {
namespace gui2 {
/**
* Allow left aligned button text.
*/
class LeftButton : public nanogui::Button {
public:
LeftButton(nanogui::Widget *parent, const std::string &caption = "",
int buttonIcon = 0) : nanogui::Button(parent, caption, buttonIcon) {};
virtual ~LeftButton() {};
virtual void draw(NVGcontext* ctx) override;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
}
}
...@@ -32,7 +32,8 @@ namespace ftl { ...@@ -32,7 +32,8 @@ namespace ftl {
SCHEME_IPC, SCHEME_IPC,
SCHEME_FILE, SCHEME_FILE,
SCHEME_OTHER, SCHEME_OTHER,
SCHEME_DEVICE SCHEME_DEVICE,
SCHEME_GROUP
}; };
bool isValid() const { return m_valid; }; bool isValid() const { return m_valid; };
...@@ -57,6 +58,8 @@ namespace ftl { ...@@ -57,6 +58,8 @@ namespace ftl {
std::string getPathSegment(int n) const; std::string getPathSegment(int n) const;
inline size_t getPathLength() const { return m_pathseg.size(); }
void setAttribute(const std::string &key, const std::string &value); void setAttribute(const std::string &key, const std::string &value);
void setAttribute(const std::string &key, int value); void setAttribute(const std::string &key, int value);
......
...@@ -631,7 +631,7 @@ static void process_options(Configurable *root, const map<string, string> &opts) ...@@ -631,7 +631,7 @@ static void process_options(Configurable *root, const map<string, string> &opts)
auto v = nlohmann::json::parse(opt.second); auto v = nlohmann::json::parse(opt.second);
ftl::config::update(*root->get<string>("$id") + string("/") + opt.first, v); ftl::config::update(*root->get<string>("$id") + string("/") + opt.first, v);
} catch(...) { } catch(...) {
LOG(ERROR) << "Unrecognised option: " << *root->get<string>("$id") << "#" << opt.first; LOG(ERROR) << "Unrecognised option: " << *root->get<string>("$id") << "/" << opt.first;
} }
} }
} }
...@@ -734,22 +734,22 @@ std::vector<nlohmann::json*> ftl::config::_createArray(ftl::Configurable *parent ...@@ -734,22 +734,22 @@ std::vector<nlohmann::json*> ftl::config::_createArray(ftl::Configurable *parent
if (entity.is_object()) { if (entity.is_object()) {
if (!entity["$id"].is_string()) { if (!entity["$id"].is_string()) {
std::string id_str = *parent->get<std::string>("$id"); std::string id_str = *parent->get<std::string>("$id");
if (id_str.find('#') != std::string::npos) { //if (id_str.find('#') != std::string::npos) {
entity["$id"] = id_str + std::string("/") + name + std::string("/") + std::to_string(i); entity["$id"] = id_str + std::string("/") + name + std::string("/") + std::to_string(i);
} else { //} else {
entity["$id"] = id_str + std::string("#") + name + std::string("/") + std::to_string(i); // entity["$id"] = id_str + std::string("#") + name + std::string("/") + std::to_string(i);
} //}
} }
result.push_back(&entity); result.push_back(&entity);
} else if (entity.is_null()) { } else if (entity.is_null()) {
// Must create the object from scratch... // Must create the object from scratch...
std::string id_str = *parent->get<std::string>("$id"); std::string id_str = *parent->get<std::string>("$id");
if (id_str.find('#') != std::string::npos) { //if (id_str.find('#') != std::string::npos) {
id_str = id_str + std::string("/") + name + std::string("/") + std::to_string(i); id_str = id_str + std::string("/") + name + std::string("/") + std::to_string(i);
} else { //} else {
id_str = id_str + std::string("#") + name + std::string("/") + std::to_string(i); // id_str = id_str + std::string("#") + name + std::string("/") + std::to_string(i);
} //}
parent->getConfig()[name] = { parent->getConfig()[name] = {
// cppcheck-suppress constStatement // cppcheck-suppress constStatement
{"$id", id_str} {"$id", id_str}
...@@ -775,22 +775,22 @@ nlohmann::json &ftl::config::_create(ftl::Configurable *parent, const std::strin ...@@ -775,22 +775,22 @@ nlohmann::json &ftl::config::_create(ftl::Configurable *parent, const std::strin
if (entity.is_object()) { if (entity.is_object()) {
if (!entity["$id"].is_string()) { if (!entity["$id"].is_string()) {
std::string id_str = *parent->get<std::string>("$id"); std::string id_str = *parent->get<std::string>("$id");
if (id_str.find('#') != std::string::npos) { //if (id_str.find('#') != std::string::npos) {
entity["$id"] = id_str + std::string("/") + name; entity["$id"] = id_str + std::string("/") + name;
} else { //} else {
entity["$id"] = id_str + std::string("#") + name; // entity["$id"] = id_str + std::string("#") + name;
} //}
} }
return entity; return entity;
} else if (entity.is_null()) { } else if (entity.is_null()) {
// Must create the object from scratch... // Must create the object from scratch...
std::string id_str = *parent->get<std::string>("$id"); std::string id_str = *parent->get<std::string>("$id");
if (id_str.find('#') != std::string::npos) { //if (id_str.find('#') != std::string::npos) {
id_str = id_str + std::string("/") + name; id_str = id_str + std::string("/") + name;
} else { //} else {
id_str = id_str + std::string("#") + name; // id_str = id_str + std::string("#") + name;
} //}
parent->getConfig()[name] = { parent->getConfig()[name] = {
// cppcheck-suppress constStatement // cppcheck-suppress constStatement
{"$id", id_str} {"$id", id_str}
......
...@@ -82,6 +82,7 @@ void URI::_parse(uri_t puri) { ...@@ -82,6 +82,7 @@ void URI::_parse(uri_t puri) {
else if (prototext == "ipc") m_proto = SCHEME_IPC; else if (prototext == "ipc") m_proto = SCHEME_IPC;
else if (prototext == "device") m_proto = SCHEME_DEVICE; else if (prototext == "device") m_proto = SCHEME_DEVICE;
else if (prototext == "file") m_proto = SCHEME_FILE; else if (prototext == "file") m_proto = SCHEME_FILE;
else if (prototext == "group") m_proto = SCHEME_GROUP;
else m_proto = SCHEME_OTHER; else m_proto = SCHEME_OTHER;
m_protostr = prototext; m_protostr = prototext;
......
...@@ -563,6 +563,7 @@ std::set<ftl::stream::SourceInfo> Feed::recentSources() { ...@@ -563,6 +563,7 @@ std::set<ftl::stream::SourceInfo> Feed::recentSources() {
for (auto &f : recent.items()) { for (auto &f : recent.items()) {
ftl::stream::SourceInfo info; ftl::stream::SourceInfo info;
info.uri = f.key(); info.uri = f.key();
if (f.value().contains("uri")) info.uri = f.value()["uri"].get<std::string>();
info.last_used = f.value()["last_open"].get<int64_t>(); info.last_used = f.value()["last_open"].get<int64_t>();
result.insert(info); result.insert(info);
} }
...@@ -641,7 +642,7 @@ std::string Feed::getName(const std::string &puri) { ...@@ -641,7 +642,7 @@ std::string Feed::getName(const std::string &puri) {
if (uri.getPathSegment(0) == "realsense") return "Realsense"; if (uri.getPathSegment(0) == "realsense") return "Realsense";
if (uri.getPathSegment(0) == "screen") return "Screen Capture"; if (uri.getPathSegment(0) == "screen") return "Screen Capture";
if (uri.getPathSegment(0) == "render") return "3D Virtual"; if (uri.getPathSegment(0) == "render") return "3D Virtual";
if (uri.getPathSegment(0) == "openvr") return "VR"; if (uri.getPathSegment(0) == "openvr") return "OpenVR";
return "Unknown Device"; return "Unknown Device";
} else if (uri.getScheme() == ftl::URI::SCHEME_FILE) { } else if (uri.getScheme() == ftl::URI::SCHEME_FILE) {
return getConfig()["recent_files"][uri.getBaseURI()].value("name", "FTLFile"); return getConfig()["recent_files"][uri.getBaseURI()].value("name", "FTLFile");
...@@ -663,6 +664,7 @@ nlohmann::json &Feed::_add_recent_source(const ftl::URI &uri) { ...@@ -663,6 +664,7 @@ nlohmann::json &Feed::_add_recent_source(const ftl::URI &uri) {
name = name.substr(0, name.find_last_of('.')); name = name.substr(0, name.find_last_of('.'));
} }
details["uri"] = uri.to_string();
details["name"] = name; details["name"] = name;
details["last_open"] = ftl::timer::get_time(); details["last_open"] = ftl::timer::get_time();
return details; return details;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment