FIRE-24125: Add option to close all floaters of a group (Ctrl-Shift-W or Shift + click on X-symbol)

master
Ansariel 2021-11-29 14:23:18 +01:00
parent 829eefba3d
commit 09d55793ac
7 changed files with 136 additions and 2 deletions

View File

@ -290,7 +290,8 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
mDefaultRelativeX(p.rel_x),
mDefaultRelativeY(p.rel_y),
mMinimizeSignal(NULL),
mHostedFloaterShowtitlebar(p.hosted_floater_show_titlebar) // <FS:Ansariel> MultiFloater without titlebar for hosted floater
mHostedFloaterShowtitlebar(p.hosted_floater_show_titlebar), // <FS:Ansariel> MultiFloater without titlebar for hosted floater
mShiftPressed(false) // <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
// mNotificationContext(NULL)
{
mPosition.setFloater(*this);
@ -1717,6 +1718,30 @@ BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
}
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
//virtual
BOOL LLFloater::handleKeyHere(KEY key, MASK mask)
{
if (mask == MASK_SHIFT)
{
mShiftPressed = true;
}
return LLPanel::handleKeyHere(key, mask);
}
//virtual
BOOL LLFloater::handleKeyUpHere(KEY key, MASK mask)
{
if (mask == MASK_SHIFT)
{
mShiftPressed = false;
}
return LLPanel::handleKeyHere(key, mask);
}
// </FS:Ansariel>
void LLFloater::bringToFront( S32 x, S32 y )
{
if (getVisible() && pointInView(x, y))
@ -1965,6 +1990,19 @@ void LLFloater::onClickClose( LLFloater* self )
void LLFloater::onClickCloseBtn(bool app_quitting)
{
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
if (mShiftPressed)
{
auto floaterlist = LLFloaterReg::getAllFloatersInGroup(this);
for (auto floater : floaterlist)
{
floater->closeFloater();
}
return;
}
// </FS:Ansariel>
closeFloater(false);
}

View File

@ -310,7 +310,12 @@ public:
virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleScrollWheel(S32 x, S32 y, S32 mask);
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleKeyUpHere(KEY key, MASK mask);
// </FS:Ansariel>
virtual void draw();
virtual void drawShadow(LLPanel* panel);
@ -555,6 +560,9 @@ private:
// <FS:Ansariel> MultiFloater without titlebar for hosted floater
bool mHostedFloaterShowtitlebar;
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
bool mShiftPressed;
};

View File

@ -103,6 +103,37 @@ LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name)
return NULL;
}
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
//static
LLFloaterReg::instance_list_t LLFloaterReg::getAllFloatersInGroup(LLFloater* floater)
{
if (floater)
{
for (const auto& group : sGroupMap)
{
const std::string& group_name = group.second;
if (group_name.empty())
{
continue;
}
instance_list_t& instances = sInstanceMap[group_name];
for (auto instance : instances)
{
if (instance == floater)
{
return sInstanceMap[group_name];
}
}
}
}
return {};
}
// </FS:Ansariel>
LLFloater* LLFloaterReg::getLastFloaterCascading()
{
LLRect candidate_rect;

View File

@ -114,6 +114,7 @@ public:
// Helpers
static LLFloater* getLastFloaterInGroup(const std::string& name);
static LLFloater* getLastFloaterCascading();
static instance_list_t getAllFloatersInGroup(LLFloater* floater); // <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
// Find / get (create) / remove / destroy
static LLFloater* findInstance(const std::string& name, const LLSD& key = LLSD());

View File

@ -683,6 +683,47 @@ class LLFileCloseWindow : public view_listener_t
}
};
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
class FSFileEnableCloseWindowGroup : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
bool frontmost_fl_exists = (NULL != gFloaterView->getFrontmostClosableFloater());
bool frontmost_snapshot_fl_exists = (NULL != gSnapshotFloaterView->getFrontmostClosableFloater());
return !LLNotificationsUI::LLToast::isAlertToastShown() && (frontmost_fl_exists || frontmost_snapshot_fl_exists);
}
};
class FSFileCloseWindowGroup : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
bool frontmost_fl_exists = (NULL != gFloaterView->getFrontmostClosableFloater());
LLFloater* snapshot_floater = gSnapshotFloaterView->getFrontmostClosableFloater();
if (snapshot_floater && (!frontmost_fl_exists || snapshot_floater->hasFocus()))
{
snapshot_floater->closeFloater();
if (gFocusMgr.getKeyboardFocus() == NULL)
{
gFloaterView->focusFrontFloater();
}
}
else
{
auto floaterlist = LLFloaterReg::getAllFloatersInGroup(gFloaterView->getFrontmostClosableFloater());
for (auto floater : floaterlist)
{
floater->closeFloater();
}
}
if (gMenuHolder) gMenuHolder->hideMenus();
return true;
}
};
// </FS:Ansariel>
class LLFileEnableCloseAllWindows : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@ -1153,5 +1194,10 @@ void init_menu_file()
view_listener_t::addEnable(new FSFileEnableImportWindlightBulk(), "File.EnableImportWindlightBulk");
// </FS:Ansariel>
// <FS:Ansariel> FIRE-24125: Add option to close all floaters of a group
view_listener_t::addCommit(new FSFileCloseWindowGroup(), "File.CloseWindowGroup");
view_listener_t::addEnable(new FSFileEnableCloseWindowGroup(), "File.EnableCloseWindowGroup");
// </FS:Ansariel>
// "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled.
}

View File

@ -385,6 +385,7 @@
<menu_item_check label="Immer rennen" name="Always Run"/>
<menu_item_check label="Fliegen" name="Fly"/>
<menu_item_call label="Fenster schließen" name="Close Window"/>
<menu_item_call label="Fenstergruppe schließen" name="Close Window Group"/>
<menu_item_call label="Alle Fenster schließen" name="Close All Windows"/>
<menu_item_call label="Foto auf Datenträger" name="Snapshot to Disk"/>
<menu_item_call label="Mouselook" name="Mouselook"/>

View File

@ -3378,6 +3378,15 @@
<menu_item_call.on_enable
function="File.EnableCloseWindow" />
</menu_item_call>
<menu_item_call
label="Close Window Group"
name="Close Window Group"
shortcut="control|alt|W">
<menu_item_call.on_click
function="File.CloseWindowGroup" />
<menu_item_call.on_enable
function="File.EnableCloseWindowGroup" />
</menu_item_call>
<menu_item_call
label="Close All Windows"
name="Close All Windows"