Add option to remember last opened tag tab

Closes #5936

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-10-11 23:57:06 +02:00
parent 8318e42589
commit 2ce79b1ae8
2 changed files with 52 additions and 1 deletions

View File

@@ -42,6 +42,17 @@ public interface BankTagsConfig extends Config
return true;
}
@ConfigItem(
keyName = "rememberTab",
name = "Remember last Tag Tab",
description = "Enable the ability to remember last Tag Tab when closing/opening the bank.",
position = 2
)
default boolean rememberTab()
{
return true;
}
@ConfigItem(
keyName = "position",
name = "",
@@ -59,4 +70,22 @@ public interface BankTagsConfig extends Config
description = ""
)
void position(int idx);
@ConfigItem(
keyName = "tab",
name = "",
description = "",
hidden = true
)
default String tab()
{
return "";
}
@ConfigItem(
keyName = "tab",
name = "",
description = ""
)
void tab(String tab);
}

View File

@@ -190,6 +190,11 @@ public class TabInterface
tabManager.getAllTabs().forEach(this::loadTab);
activateTab(null);
scrollTab(0);
if (config.rememberTab() && !Strings.isNullOrEmpty(config.tab()))
{
openTag(TAG_SEARCH + config.tab());
}
}
public void destroy()
@@ -221,6 +226,23 @@ public class TabInterface
config.position(currentTabIndex);
}
// Do the same for last active tab
if (config.rememberTab())
{
if (activeTab == null && !Strings.isNullOrEmpty(config.tab()))
{
config.tab("");
}
else if (activeTab != null && !activeTab.getTag().equals(config.tab()))
{
config.tab(activeTab.getTag());
}
}
else if (!Strings.isNullOrEmpty(config.tab()))
{
config.tab("");
}
return;
}
@@ -790,7 +812,7 @@ public class TabInterface
private void openTag(String tag)
{
doSearch(InputType.SEARCH, tag);
activateTab(tabManager.find(tag.substring(4)));
activateTab(tabManager.find(tag.substring(TAG_SEARCH.length())));
// When tab is selected with search window open, the search window closes but the search button
// stays highlighted, this solves that issue