Add a confirmation before closing custom inventory tab

Signed-off-by: PanteraPolnocy <panterapolnocy@gmail.com>
This commit is contained in:
PanteraPolnocy
2026-06-20 08:33:04 +02:00
parent bdb1f853c2
commit d65f501e51
4 changed files with 67 additions and 2 deletions
+47 -2
View File
@@ -51,6 +51,7 @@ namespace
constexpr char SETTING_KEY[] = "FSInventoryCustomTabs";
constexpr char DEFAULT_NAME_KEY[] = "FSInventoryCustomTabDefaultName";
constexpr char RENAME_NOTIFY[] = "FSInventoryCustomTabRename";
constexpr char CLOSE_NOTIFY[] = "FSInventoryCustomTabClose";
constexpr char MENU_FILE[] = "menu_inventory_custom_tab.xml";
constexpr char ADD_TAB_PANEL_NAME[] = "FSInventoryCustomTabAdd";
constexpr char ADD_TAB_LABEL[] = "+";
@@ -114,6 +115,11 @@ FSInventoryCustomTabs::~FSInventoryCustomTabs()
LLNotifications::instance().cancel(mRenameNotification);
mRenameNotification.reset();
}
if (mCloseNotification)
{
LLNotifications::instance().cancel(mCloseNotification);
mCloseNotification.reset();
}
if (mAddClickConnection.connected())
{
mAddClickConnection.disconnect();
@@ -611,8 +617,47 @@ void FSInventoryCustomTabs::onCloseClicked()
return;
}
auto* to_remove = mContextPanel;
mContextPanel = nullptr;
if (mCloseNotification)
{
LLNotifications::instance().cancel(mCloseNotification);
mCloseNotification.reset();
}
LLSD args;
args["NAME"] = mContextPanel->getLabel();
LLSD payload;
payload["panel_name"] = mContextPanel->getName();
auto handle = getHandle();
mCloseNotification = LLNotificationsUtil::add(CLOSE_NOTIFY, args, payload,
[handle](const LLSD& notification, const LLSD& response)
{
if (auto* self = handle.get())
{
self->onCloseConfirmed(notification, response);
}
});
}
void FSInventoryCustomTabs::onCloseConfirmed(const LLSD& notification, const LLSD& response)
{
mCloseNotification.reset();
if (LLNotificationsUtil::getSelectedOption(notification, response) != 0)
{
return;
}
auto* to_remove = dynamic_cast<LLInventoryPanel*>(mTabs->getPanelByName(notification["payload"]["panel_name"].asString()));
if (!isCustomTab(to_remove) || !mTabs)
{
return;
}
if (mContextPanel == to_remove)
{
mContextPanel = nullptr;
}
if (mLastActivePanel == to_remove)
{
mLastActivePanel = nullptr;
+2
View File
@@ -91,6 +91,7 @@ private:
void installAddTab();
void onSettingChangedExternally();
void onRenameConfirmed(const LLSD& notification, const LLSD& response);
void onCloseConfirmed(const LLSD& notification, const LLSD& response);
void onFilterFocusLost();
void onClosePressed(LLInventoryPanel* panel);
void doLoad();
@@ -116,6 +117,7 @@ private:
LLInventoryPanel* mAddTabPanel{ nullptr };
LLInventoryPanel* mLastActivePanel{ nullptr };
LLNotificationPtr mRenameNotification;
LLNotificationPtr mCloseNotification;
boost::signals2::connection mSettingConnection;
boost::signals2::connection mAddClickConnection;
bool mSaving{ false };
@@ -3514,6 +3514,20 @@ See https://wiki.secondlife.com/wiki/Adding_Spelling_Dictionaries
</form>
</notification>
<notification
icon="alertmodal.tga"
label="Close Filter Tab"
name="FSInventoryCustomTabClose"
type="alertmodal">
Close the &quot;[NAME]&quot; filter tab? Its saved filters will be removed.
<tag>confirm</tag>
<usetemplate
name="okcancelignore"
notext="Cancel"
yestext="Yes, close"
ignoretext="Confirm before I close a custom inventory filter tab"/>
</notification>
<notification
icon="alertmodal.tga"
label="Rename Gesture"
@@ -1307,6 +1307,10 @@ do
<button name="Cancel" text="Anuluj"/>
</form>
</notification>
<notification label="Zamknij zakładkę filtra" name="FSInventoryCustomTabClose">
Zamknąć zakładkę filtra &quot;[NAME]&quot;? Jej zapisane filtry zostaną usunięte.
<usetemplate name="okcancelignore" notext="Anuluj" yestext="Tak, zamknij" ignoretext="Potwierdzaj przed zamknięciem niestandardowej zakładki filtra szafy" />
</notification>
<notification label="Zmień nazwę gestu" name="RenameGesture">
Nowa nazwa gestu:
<form name="form">