Skip to content

Commit 62c8c15

Browse files
committed
Add option to hide tooltips
1 parent ccee2c9 commit 62c8c15

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/core/OSTreeTUI.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ std::vector<std::string> OSTreeTUI::parseVisibleCommitMap(cpplibostree::OSTreeRe
4848
return visible_commit_view_map;
4949
}
5050

51-
int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& startupBranches) {
51+
int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& startupBranches, bool showTooltips) {
5252
using namespace ftxui;
5353

5454
// - STATES ---------- ----------
@@ -124,7 +124,7 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
124124
});
125125

126126
// promotion
127-
ContentPromotionManager promotionManager;
127+
ContentPromotionManager promotionManager(showTooltips);
128128
promotionManager.setBranchRadiobox(Radiobox(&allBranches, &promotionManager.branch_selected));
129129
promotionManager.setApplyButton(Button(" Apply ", [&] {
130130
ostree_repo.promoteCommit(visible_commit_view_map.at(selected_commit),
@@ -238,6 +238,7 @@ int OSTreeTUI::help(const std::string& caller, const std::string& errorMessage)
238238
// option, arguments, meaning
239239
{"-h, --help", "", "Show help options. The REPOSITORY_PATH can be omitted"},
240240
{"-r, --refs", "REF [REF...]", "Specify a list of visible refs at startup if not specified, show all refs"},
241+
{"-n, --no-tooltips", "", "Hide Tooltips in promotion view."}
241242
};
242243

243244
Elements options = {text("Options:")};

src/core/OSTreeTUI.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace OSTreeTUI {
1515
*
1616
* @param repo ostree repository path
1717
*/
18-
int main(const std::string& repo, const std::vector<std::string>& startupBranches = {});
18+
int main(const std::string& repo, const std::vector<std::string>& startupBranches = {}, bool showTooltips = true);
1919

2020
/**
2121
* @brief Print help page

src/core/manager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ftxui::Element CommitInfoManager::renderInfoView(const cpplibostree::Commit& dis
9090

9191
// ContentPromotionManager
9292

93-
ContentPromotionManager::ContentPromotionManager() {
93+
ContentPromotionManager::ContentPromotionManager(bool show_tooltips): show_tooltips(show_tooltips) {
9494
using namespace ftxui;
9595

9696
subject_component = Input(&new_subject, "subject");
@@ -191,7 +191,7 @@ ftxui::Element ContentPromotionManager::renderPromotionView(cpplibostree::OSTree
191191
text(" 🛈 " + tool_tip_strings.at(tip)),
192192
});
193193
};
194-
auto tool_tips_win = tooltips_win_height < 2 ? filler() : // only show if screen is reasonable size
194+
auto tool_tips_win = !show_tooltips || tooltips_win_height < 2 ? filler() : // only show if screen is reasonable size
195195
branch_selection->Focused() ? toolTipContent(0) :
196196
flags->Focused() ? toolTipContent(1) :
197197
subject_component->Focused() ? toolTipContent(2) :

src/core/manager.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class ContentPromotionManager {
8484
ftxui::Component apply_button; // must be set from OSTreeTUI
8585

8686
// tool-tips
87+
bool show_tooltips{true};
8788
ftxui::Component tool_tips_comp;
8889
const std::vector<std::string> tool_tip_strings = {
8990
"Branch to promote the Commit to.",
@@ -100,7 +101,7 @@ class ContentPromotionManager {
100101
* using the respective set-methods AFTER construction, as they
101102
* have to be constructed in the OSTreeTUI::main
102103
*/
103-
ContentPromotionManager();
104+
ContentPromotionManager(bool show_tooltips = true);
104105

105106
/// Setter
106107
void setBranchRadiobox(ftxui::Component radiobox);

src/main.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ int main(int argc, const char** argv) {
5050
std::string repo = args.at(0);
5151
// -r, --refs
5252
std::vector<std::string> startupBranches = getArgOptions(args, {"-r", "--refs"});
53-
53+
// -n, --no-tooltips
54+
bool hideTooltips = argExists(args, "-n") || argExists(args, "--no-tooltips");
55+
5456
// OSTree TUI
55-
return OSTreeTUI::main(repo, startupBranches);
57+
return OSTreeTUI::main(repo, startupBranches, !hideTooltips);
5658
}

0 commit comments

Comments
 (0)