Add Reset Button
This commit is contained in:
parent
dd760cc6f2
commit
ed59e19c52
@ -2,9 +2,6 @@
|
||||
#include <cstring>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
|
||||
#include <libreborn/libreborn.h>
|
||||
|
||||
|
@ -21,6 +21,7 @@ static unsigned int find_indent_level(std::string &str) {
|
||||
return count / INDENT;
|
||||
}
|
||||
Flags::Flags(const std::string &data) {
|
||||
FlagNode::reset_id_counter();
|
||||
// Read Lines
|
||||
std::stringstream stream(data);
|
||||
std::string line;
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
// Internal
|
||||
static bool handle_line_prefix(const std::string &prefix, std::string &line);
|
||||
static std::unordered_map<std::string, bool> flag_prefixes;
|
||||
static void reset_id_counter();
|
||||
};
|
||||
|
||||
// All Flags
|
||||
|
@ -5,7 +5,10 @@
|
||||
#include "flags.h"
|
||||
|
||||
// Flag
|
||||
static int next_id = 1;
|
||||
static int next_id;
|
||||
void FlagNode::reset_id_counter() {
|
||||
next_id = 1;
|
||||
}
|
||||
FlagNode::FlagNode(const std::string &name_) {
|
||||
name = name_;
|
||||
value = false;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "configuration.h"
|
||||
#include "cache.h"
|
||||
|
||||
#include <imgui_stdlib.h>
|
||||
|
||||
@ -29,7 +30,7 @@ ConfigurationUI::ConfigurationUI(State &state_):
|
||||
// Render
|
||||
int ConfigurationUI::render() {
|
||||
const ImGuiStyle &style = ImGui::GetStyle();
|
||||
if (ImGui::BeginChild("Main", ImVec2(0, -ImGui::GetFrameHeightWithSpacing() /* Leave Room For One Line */), ImGuiChildFlags_None, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||
if (ImGui::BeginChild("General", ImVec2(0, -ImGui::GetFrameHeightWithSpacing() /* Leave Room For One Line */), ImGuiChildFlags_None, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||
// Tabs
|
||||
if (ImGui::BeginTabBar("tab_bar", ImGuiTabBarFlags_None)) {
|
||||
if (ImGui::BeginTabItem("Main", nullptr, ImGuiTabItemFlags_None)) {
|
||||
@ -98,6 +99,10 @@ void ConfigurationUI::draw_advanced() const {
|
||||
draw_category(category);
|
||||
}
|
||||
}
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Reset All Settings")) {
|
||||
state = State(empty_cache);
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ __attribute__((noreturn)) void safe_execvpe(const char *const argv[], const char
|
||||
|
||||
// Run Command And Get Output
|
||||
std::vector<unsigned char> *run_command(const char *const command[], int *exit_status);
|
||||
#define is_exit_status_success(status) (WIFEXITED(status) && WEXITSTATUS(status) == 0)
|
||||
bool is_exit_status_success(int status);
|
||||
|
||||
// Get Exit Status String
|
||||
std::string get_exit_status_string(int status);
|
@ -120,7 +120,7 @@ __attribute__((noreturn)) void safe_execvpe(const char *const argv[], const char
|
||||
DEBUG(" %s", argv[i]);
|
||||
}
|
||||
// Run
|
||||
int ret = execvpe(argv[0], (char *const *) argv, (char *const *) envp);
|
||||
const int ret = execvpe(argv[0], (char *const *) argv, (char *const *) envp);
|
||||
if (ret == -1) {
|
||||
ERR("Unable To Execute Program: %s: %s", argv[0], strerror(errno));
|
||||
} else {
|
||||
@ -174,3 +174,15 @@ std::string get_exit_status_string(const int status) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Check Exit Status
|
||||
bool is_exit_status_success(const int status) {
|
||||
if (WIFEXITED(status)) {
|
||||
return WEXITSTATUS(status) == 0;
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
const int signal_no = WTERMSIG(status);
|
||||
return signal_no == SIGINT || signal_no == SIGTERM;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user