Skip to content

Commit

Permalink
more useless ui removal
Browse files Browse the repository at this point in the history
  • Loading branch information
aloneguid committed Jun 27, 2023
1 parent e0073f8 commit 2912c21
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Build'

env:
VERSION: 3.1.4
VERSION: 3.1.5
BUILD_TYPE: Release
ARCH: x64
VCPKG_DEFAULT_VCPKG_TRIPLET: x64-windows-static
Expand Down
16 changes: 0 additions & 16 deletions bt/app/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <cctype>
#include <functional>
#include "win32/shell.h"
#include "win32/process.h"
#include "str.h"
#include "../globals.h"
#include <fmt/core.h>
Expand Down Expand Up @@ -160,21 +159,6 @@ namespace bt {
return b1.id == b2.id;
}

std::vector<win32::process> browser::get_system_processes() {
vector<win32::process> r;
for(auto& p : win32::process::enumerate()) {
if(p.get_module_filename() != open_cmd) continue;
r.push_back(p);
}
return r;
}

bool browser::is_running() {
auto all_procs = win32::process::enumerate();
return std::any_of(all_procs.begin(), all_procs.end(),
[this](const win32::process& p) { return p.get_module_filename() == open_cmd; });
}

std::vector<std::shared_ptr<browser>> browser::get_cache(bool reload) {
if(reload || cache.empty())
cache = config::i.load_browsers();
Expand Down
3 changes: 0 additions & 3 deletions bt/app/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ namespace bt {
std::string vdf; // vendor data folder
//std::vector<chrome_profile> chrome_profiles;

std::vector<win32::process> get_system_processes();
bool is_running();

friend bool operator==(const browser& b1, const browser& b2);

// ---- static members
Expand Down
55 changes: 13 additions & 42 deletions bt/app/config_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ namespace bt
w_dash->is_visible = true;
check_health();
};
st_health->on_hovered = [this](component&, bool is_hovered) {
if(is_hovered) {
check_health();
}
};

status->make_label("|")->is_enabled = false;
auto coffee = status->make_label(ICON_FA_MUG_HOT);
Expand Down Expand Up @@ -223,7 +228,7 @@ namespace bt
};

g_static->same_line();
auto pf = g_static->make_button(ICON_FA_FOLDER_OPEN " profile");
auto pf = g_static->make_button(ICON_FA_FOLDER_TREE " profile");
pf->tooltip = "open profile folder in Explorer.";
profiles_tabs->on_tab_changed = [pf, b](size_t idx) {
auto profile = b->instances[idx];
Expand All @@ -237,43 +242,20 @@ namespace bt

if(b->is_firefox) {
g_static->same_line();
auto pmgr = g_static->make_button(ICON_FA_LIST);
auto pmgr = g_static->make_button(ICON_FA_ADDRESS_CARD);
pmgr->tooltip = "open Firefox Profile Manager (-P flag)";
pmgr->on_pressed = [b](button&) {
win32::shell::exec(b->open_cmd, "-P");
};

g_static->same_line();
pmgr = g_static->make_button(ICON_FA_LIST);
pmgr = g_static->make_button(ICON_FA_ID_CARD);
pmgr->tooltip = "open Firefox Profile Manager in Firefox itself";
pmgr->on_pressed = [b](button&) {
win32::shell::exec(b->open_cmd, "about:profiles");
};
}
}

browser_toolbar->same_line();
auto g_sys_on = browser_toolbar->make_group();
{
auto cmd_kill = g_sys_on->make_button(ICON_FA_GAVEL);
cmd_kill->tooltip = "kill all browser processes";
cmd_kill->on_pressed = [b](button&) {
for(auto& p : b->get_system_processes()) {
p.terminate();
}
};
}

g_sys_on->is_visible = false;
g_sys_on->on_frame = [b, g_sys_on](component&) {
g_sys_on->tag_float += ImGui::GetIO().DeltaTime;
if(g_sys_on->tag_float >= 0.5) {
bool is_running = b->is_running();
g_sys_on->is_visible = is_running;
g_sys_on->tag_float = 0;
}
};
g_sys_on->tag_float = 100;
} else {
browser_toolbar->same_line();
auto cmd_rm = browser_toolbar->make_button(
Expand Down Expand Up @@ -491,21 +473,6 @@ special keyword - %url% which is replaced by opening url.)";
c->set_pos(left_pad, 0, true);
c->make_label(b->name);

// running indicator
c->same_line();
c->set_pos(370 * scale, -1, false);
auto lbl_on_off = c->make_label(ICON_FA_CIRCLE);
lbl_on_off->on_frame = [b, lbl_on_off](component&) {
lbl_on_off->tag_float += ImGui::GetIO().DeltaTime;
if(lbl_on_off->tag_float >= 2) {
bool is_running = b->is_running();
lbl_on_off->set_emphasis(is_running ? emphasis::primary : emphasis::error);
lbl_on_off->tooltip = is_running ? "running" : "not running";
lbl_on_off->tag_float = 0;
}
};
lbl_on_off->tag_float = 100;

c->set_pos(left_pad, 0, true);

if(b->instances.size() > 0) {
Expand Down Expand Up @@ -750,7 +717,11 @@ special keyword - %url% which is replaced by opening url.)";

bool healthy = w_dash->recheck();

if(!healthy) w_dash->is_visible = true;
if(!healthy) {
w_dash->is_visible = true;
w_dash->center();
w_dash->bring_to_top();
}
st_health->set_emphasis(healthy ? emphasis::primary : emphasis::error);
st_health->tooltip = healthy
? "good health"
Expand Down
2 changes: 1 addition & 1 deletion bt/app/dash_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace bt {
sc.recheck();

auto g = make_group();
auto sign = g->make_label(sc.is_ok ? ICON_FA_CHECK : ICON_FA_DELETE_LEFT);
auto sign = g->make_label(sc.is_ok ? ICON_FA_HEART_CIRCLE_CHECK : ICON_FA_HEART_CIRCLE_XMARK);
sign->set_emphasis(sc.is_ok ? grey::emphasis::primary : grey::emphasis::error);

g->same_line();
Expand Down
5 changes: 5 additions & 0 deletions local-build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake -B build -S . -D "CMAKE_BUILD_TYPE=Release" `
-D "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D "VCPKG_TARGET_TRIPLET=x64-windows-static"

cmake --build build --config Release
10 changes: 10 additions & 0 deletions log.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[
{
"version": "3.1.5",
"date": "2023-06-27",
"changes": {
"improvements": [
"BT does not check if browser process is running anymore, to avoid listing system processes which AVs don't like.",
"Some UI icons updated"
]
}
},
{
"version": "3.1.4",
"date": "2023-06-27",
Expand Down

0 comments on commit 2912c21

Please sign in to comment.