Make BAboutWindow modal

Ã* Set its type to B_MODAL_WINDO, and also set B_NOT_MOVABLE
 * Since this removes the window tab, add an "Ok" button to close the window
 * Remove the GetWindow mess and just use it as any regular window
 * Adjust all callers again

The AlertPosition method doesn't seem to work right, the window pops up
offset to the right. I also noticed that some of our calls to BAboutWindow
are actually not reacable because we removed Abutrequested from the apps.
Maybe we should clean them up (locale preflet and activity monitor are examples)

More annoying is the fact that opening a modal window from a deskbar replicant
is modal against the whole deskbar. Not sure what to do about that.
This commit is contained in:
Adrien Destugues
2013-05-01 10:10:37 +02:00
parent 196ab88d06
commit 31535ac63b
7 changed files with 80 additions and 126 deletions
-5
View File
@@ -45,13 +45,8 @@ class BAboutWindow : public BWindow {
const char* Version();
void SetVersion(const char* version);
static BAboutWindow* GetWindow(const char* appName,
const char* signature, bool* needsInit = NULL);
private:
AboutView* fAboutView;
static BAboutWindow* sAboutWindow;
};
#endif // B_ABOUT_WINDOW_H
+16 -22
View File
@@ -267,32 +267,26 @@ CalcView::MessageReceived(BMessage* message)
// (replicant) about box requested
case B_ABOUT_REQUESTED:
{
bool needsInit;
BAboutWindow* window = BAboutWindow::GetWindow(kAppName,
kSignature, &needsInit);
BAboutWindow* window = new BAboutWindow(kAppName, kSignature);
if (needsInit) {
// create the about window
const char* extraCopyrights[] = {
"1997, 1998 R3 Software Ltd.",
NULL
};
// create the about window
const char* extraCopyrights[] = {
"1997, 1998 R3 Software Ltd.",
NULL
};
const char* authors[] = {
"Stephan Aßmus",
"John Scipione",
"Timothy Wayper",
"Ingo Weinhold",
NULL
};
const char* authors[] = {
"Stephan Aßmus",
"John Scipione",
"Timothy Wayper",
"Ingo Weinhold",
NULL
};
window->AddCopyright(2006, "Haiku, Inc.", extraCopyrights);
window->AddAuthors(authors);
}
window->AddCopyright(2006, "Haiku, Inc.", extraCopyrights);
window->AddAuthors(authors);
if (window->IsHidden())
window->Show();
window->Activate();
window->Show();
break;
}
+10 -15
View File
@@ -504,24 +504,19 @@ NetworkStatusView::MouseDown(BPoint point)
void
NetworkStatusView::_AboutRequested()
{
bool needsInit;
BAboutWindow* window = BAboutWindow::GetWindow(
B_TRANSLATE_SYSTEM_NAME("NetworkStatus"), kSignature, &needsInit);
BAboutWindow* window = new BAboutWindow(
B_TRANSLATE_SYSTEM_NAME("NetworkStatus"), kSignature);
if (needsInit) {
const char* authors[] = {
"Axel Dörfler",
"Hugo Santos",
NULL
};
const char* authors[] = {
"Axel Dörfler",
"Hugo Santos",
NULL
};
window->AddCopyright(2007, "Haiku, Inc.");
window->AddAuthors(authors);
}
window->AddCopyright(2007, "Haiku, Inc.");
window->AddAuthors(authors);
if (window->IsHidden())
window->Show();
window->Activate();
window->Show();
}
@@ -433,29 +433,24 @@ ProcessController::MessageReceived(BMessage *message)
void
ProcessController::AboutRequested()
{
bool needsInit;
BAboutWindow* window = BAboutWindow::GetWindow(
B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature, &needsInit);
BAboutWindow* window = new BAboutWindow(
B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature);
if (needsInit) {
const char* extraCopyrights[] = {
"2004 beunited.org",
"1997-2001 Georges-Edouard Berenger",
NULL
};
const char* extraCopyrights[] = {
"2004 beunited.org",
"1997-2001 Georges-Edouard Berenger",
NULL
};
const char* authors[] = {
"Georges-Edouard Berenger",
NULL
};
const char* authors[] = {
"Georges-Edouard Berenger",
NULL
};
window->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
window->AddAuthors(authors);
}
window->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
window->AddAuthors(authors);
if (window->IsHidden())
window->Show();
window->Activate();
window->Show();
}
+19 -24
View File
@@ -400,36 +400,31 @@ WorkspacesView::Archive(BMessage* archive, bool deep) const
void
WorkspacesView::_AboutRequested()
{
bool needsInit;
BAboutWindow* window = BAboutWindow::GetWindow(
B_TRANSLATE_SYSTEM_NAME("Workspaces"), kSignature, &needsInit);
BAboutWindow* window = new BAboutWindow(
B_TRANSLATE_SYSTEM_NAME("Workspaces"), kSignature);
if (needsInit) {
const char* authors[] = {
"Axel Dörfler",
"Oliver \"Madison\" Kohl",
"Matt Madia",
"François Revol",
NULL
};
const char* authors[] = {
"Axel Dörfler",
"Oliver \"Madison\" Kohl",
"Matt Madia",
"François Revol",
NULL
};
const char* extraCopyrights[] = {
"2002 François Revol",
NULL
};
const char* extraCopyrights[] = {
"2002 François Revol",
NULL
};
const char* extraInfo = "Send windows behind using the Option key. "
"Move windows to front using the Control key.\n";
const char* extraInfo = "Send windows behind using the Option key. "
"Move windows to front using the Control key.\n";
window->AddCopyright(2002, "Haiku, Inc.",
window->AddCopyright(2002, "Haiku, Inc.",
extraCopyrights);
window->AddAuthors(authors);
window->AddExtraInfo(extraInfo);
}
window->AddAuthors(authors);
window->AddExtraInfo(extraInfo);
if (window->IsHidden())
window->Show();
window->Activate();
window->Show();
}
+10 -24
View File
@@ -16,6 +16,7 @@
#include <Alert.h>
#include <AppFileInfo.h>
#include <Bitmap.h>
#include <Button.h>
#include <File.h>
#include <Font.h>
#include <GroupLayoutBuilder.h>
@@ -182,6 +183,11 @@ AboutView::AboutView(const char* appName, const char* signature)
fStripeView = new StripeView(_GetIconFromSignature(signature));
const char* ok = B_TRANSLATE_MARK("Ok");
BButton* closeButton = new BButton("ok",
gSystemCatalog.GetString(ok, "AboutWindow"),
new BMessage(B_QUIT_REQUESTED));
GroupLayout()->SetSpacing(0);
BLayoutBuilder::Group<>(this)
.AddGroup(B_HORIZONTAL, 0)
@@ -192,6 +198,7 @@ AboutView::AboutView(const char* appName, const char* signature)
.Add(fNameView)
.Add(fVersionView)
.Add(infoViewScroller)
.Add(closeButton)
.End()
.AddGlue()
.End();
@@ -352,12 +359,10 @@ AboutView::SetIcon(BBitmap* icon)
BAboutWindow::BAboutWindow(const char* appName, const char* signature)
: BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
: BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_MODAL_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_MOVABLE | B_NOT_ZOOMABLE
| B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{
sAboutWindow = this;
SetLayout(new BGroupLayout(B_VERTICAL));
const char* about = B_TRANSLATE_MARK("About %app%");
@@ -376,8 +381,6 @@ BAboutWindow::BAboutWindow(const char* appName, const char* signature)
BAboutWindow::~BAboutWindow()
{
sAboutWindow = NULL;
fAboutView->RemoveSelf();
delete fAboutView;
fAboutView = NULL;
@@ -613,20 +616,3 @@ BAboutWindow::SetIcon(BBitmap* icon)
fAboutView->SetIcon(icon);
}
/* static */ BAboutWindow*
BAboutWindow::GetWindow(const char* appName, const char* signature,
bool* needsInit)
{
if(needsInit != NULL)
*needsInit = (sAboutWindow == NULL);
if(sAboutWindow == NULL) {
new BAboutWindow(appName, signature);
}
return sAboutWindow;
}
/* static */ BAboutWindow*
BAboutWindow::sAboutWindow = NULL;
+11 -17
View File
@@ -74,26 +74,20 @@ LocalePreflet::MessageReceived(BMessage* message)
case B_ABOUT_REQUESTED:
{
bool needsInit;
BAboutWindow* window = BAboutWindow::GetWindow(kAppName,
kSignature, &needsInit);
BAboutWindow* window = new BAboutWindow(kAppName, kSignature);
if (needsInit) {
const char* authors[] = {
"Axel Dörfler",
"Adrien Destugues",
"Oliver Tappe",
NULL
};
const char* authors[] = {
"Axel Dörfler",
"Adrien Destugues",
"Oliver Tappe",
NULL
};
window = new BAboutWindow(kAppName, kSignature);
window->AddCopyright(2005, "Haiku, Inc.");
window->AddAuthors(authors);
}
window = new BAboutWindow(kAppName, kSignature);
window->AddCopyright(2005, "Haiku, Inc.");
window->AddAuthors(authors);
if (window->IsHidden())
window->Show();
window->Activate();
window->Show();
break;
}