Skip to content

Commit 7fc1ac5

Browse files
committed
- fix crash if process_names are ommitted
- minor ui improvements
1 parent a6f5d32 commit 7fc1ac5

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "lastfm.hpp"
1414
#include "rsrc.hpp"
1515
#include "utils.hpp"
16+
#include "wx/sizer.h"
1617

1718
std::string lastPlayingSong = "";
1819
std::string lastMediaSource = "";
@@ -228,11 +229,8 @@ class EditAppDialog : public wxDialog {
228229
wxEVT_TEXT, [this, app](wxCommandEvent& event) { app->searchEndpoint = event.GetString().ToStdString(); });
229230
formSizer->Add(searchEndpointInput, 1, wxALL | wxEXPAND, 5);
230231

231-
mainSizer->Add(formSizer, 0, wxEXPAND | wxALL, 5);
232-
233232
// Dropdown
234-
wxBoxSizer* dropdownSizer = new wxBoxSizer(wxHORIZONTAL);
235-
dropdownSizer->Add(new wxStaticText(this, wxID_ANY, "Activity Type:"), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
233+
formSizer->Add(new wxStaticText(this, wxID_ANY, "Activity Type:"), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
236234
wxString choices[] = {_("Listening"), _("Watching"), _("Playing")};
237235
wxChoice* activityChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 3, choices);
238236

@@ -259,11 +257,12 @@ class EditAppDialog : public wxDialog {
259257
app->type = typeMap.at(event.GetString());
260258
});
261259

262-
dropdownSizer->Add(activityChoice, 1, wxALL | wxEXPAND, 5);
263-
mainSizer->Add(dropdownSizer, 0, wxEXPAND);
260+
formSizer->Add(activityChoice, 1, wxALL | wxEXPAND, 5);
261+
mainSizer->Add(formSizer, 0, wxEXPAND);
264262

265263
// Process names group
266-
wxStaticBoxSizer* processBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Process names"));
264+
formSizer->Add(new wxStaticText(this, wxID_ANY, _("Process names:")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
265+
wxBoxSizer* processBox = new wxBoxSizer(wxVERTICAL);
267266

268267
wxListBox* listBox = new wxListBox(this, wxID_ANY);
269268

src/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ namespace utils {
317317
a.enabled = app.value("enabled", false);
318318
a.type = app.value("type", 2);
319319

320-
for (const auto& process : app["process_names"]) a.processNames.push_back(process.get<std::string>());
320+
for (const auto& process : app.value("process_names", nlohmann::json())) a.processNames.push_back(process.get<std::string>());
321321

322322
ret.apps.push_back(a);
323323
}

0 commit comments

Comments
 (0)