registrar: Properly clear out icons and resize when text changes.

May help with #18006.
This commit is contained in:
Augustin Cavalier
2022-10-24 22:43:27 -04:00
parent 781db1b43f
commit 93e536ab5d
+16 -4
View File
@@ -31,6 +31,7 @@
#include <Roster.h> // for B_REQUEST_QUIT #include <Roster.h> // for B_REQUEST_QUIT
#include <Screen.h> #include <Screen.h>
#include <String.h> #include <String.h>
#include <TextView.h>
#include <Window.h> #include <Window.h>
#include <TokenSpace.h> #include <TokenSpace.h>
@@ -362,6 +363,18 @@ public:
fKillAppMessage->ReplaceInt32("team", team); fKillAppMessage->ReplaceInt32("team", team);
} }
void SetText(const char* text)
{
const int32 initialLength = TextView()->TextLength(),
initialLines = TextView()->CountLines();
BAlert::SetText(text);
if (TextView()->CountLines() > initialLines
|| TextView()->CountLines() > (initialLength * 2))
ResizeToPreferred();
}
void SetCancelShutdownButtonEnabled(bool enable) void SetCancelShutdownButtonEnabled(bool enable)
{ {
fCancelShutdownButton->SetEnabled(enable); fCancelShutdownButton->SetEnabled(enable);
@@ -393,9 +406,7 @@ public:
fRebootSystemButton->Show(); fRebootSystemButton->Show();
SetTitle(B_TRANSLATE("System is shut down")); SetTitle(B_TRANSLATE("System is shut down"));
SetText( SetText(B_TRANSLATE("It's now safe to turn off the computer."));
B_TRANSLATE("It's now safe to turn off the computer."));
ResizeToPreferred();
} }
void SetWaitForAbortedOK() void SetWaitForAbortedOK()
@@ -467,7 +478,8 @@ private:
fCurrentIconBitmap = NULL; fCurrentIconBitmap = NULL;
} else } else
SetIcon(fCurrentIconBitmap); SetIcon(fCurrentIconBitmap);
} } else
SetIcon(NULL);
} }
void IconWaitAnimationEnabled(bool enable) void IconWaitAnimationEnabled(bool enable)