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(); const char* Version();
void SetVersion(const char* version); void SetVersion(const char* version);
static BAboutWindow* GetWindow(const char* appName,
const char* signature, bool* needsInit = NULL);
private: private:
AboutView* fAboutView; AboutView* fAboutView;
static BAboutWindow* sAboutWindow;
}; };
#endif // B_ABOUT_WINDOW_H #endif // B_ABOUT_WINDOW_H
+16 -22
View File
@@ -267,32 +267,26 @@ CalcView::MessageReceived(BMessage* message)
// (replicant) about box requested // (replicant) about box requested
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
{ {
bool needsInit; BAboutWindow* window = new BAboutWindow(kAppName, kSignature);
BAboutWindow* window = BAboutWindow::GetWindow(kAppName,
kSignature, &needsInit);
if (needsInit) { // create the about window
// create the about window const char* extraCopyrights[] = {
const char* extraCopyrights[] = { "1997, 1998 R3 Software Ltd.",
"1997, 1998 R3 Software Ltd.", NULL
NULL };
};
const char* authors[] = { const char* authors[] = {
"Stephan Aßmus", "Stephan Aßmus",
"John Scipione", "John Scipione",
"Timothy Wayper", "Timothy Wayper",
"Ingo Weinhold", "Ingo Weinhold",
NULL NULL
}; };
window->AddCopyright(2006, "Haiku, Inc.", extraCopyrights); window->AddCopyright(2006, "Haiku, Inc.", extraCopyrights);
window->AddAuthors(authors); window->AddAuthors(authors);
}
if (window->IsHidden()) window->Show();
window->Show();
window->Activate();
break; break;
} }
+10 -15
View File
@@ -504,24 +504,19 @@ NetworkStatusView::MouseDown(BPoint point)
void void
NetworkStatusView::_AboutRequested() NetworkStatusView::_AboutRequested()
{ {
bool needsInit; BAboutWindow* window = new BAboutWindow(
BAboutWindow* window = BAboutWindow::GetWindow( B_TRANSLATE_SYSTEM_NAME("NetworkStatus"), kSignature);
B_TRANSLATE_SYSTEM_NAME("NetworkStatus"), kSignature, &needsInit);
if (needsInit) { const char* authors[] = {
const char* authors[] = { "Axel Dörfler",
"Axel Dörfler", "Hugo Santos",
"Hugo Santos", NULL
NULL };
};
window->AddCopyright(2007, "Haiku, Inc."); window->AddCopyright(2007, "Haiku, Inc.");
window->AddAuthors(authors); window->AddAuthors(authors);
}
if (window->IsHidden()) window->Show();
window->Show();
window->Activate();
} }
@@ -433,29 +433,24 @@ ProcessController::MessageReceived(BMessage *message)
void void
ProcessController::AboutRequested() ProcessController::AboutRequested()
{ {
bool needsInit; BAboutWindow* window = new BAboutWindow(
BAboutWindow* window = BAboutWindow::GetWindow( B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature);
B_TRANSLATE_SYSTEM_NAME("ProcessController"), kSignature, &needsInit);
if (needsInit) { const char* extraCopyrights[] = {
const char* extraCopyrights[] = { "2004 beunited.org",
"2004 beunited.org", "1997-2001 Georges-Edouard Berenger",
"1997-2001 Georges-Edouard Berenger", NULL
NULL };
};
const char* authors[] = { const char* authors[] = {
"Georges-Edouard Berenger", "Georges-Edouard Berenger",
NULL NULL
}; };
window->AddCopyright(2007, "Haiku, Inc.", extraCopyrights); window->AddCopyright(2007, "Haiku, Inc.", extraCopyrights);
window->AddAuthors(authors); window->AddAuthors(authors);
}
if (window->IsHidden()) window->Show();
window->Show();
window->Activate();
} }
+19 -24
View File
@@ -400,36 +400,31 @@ WorkspacesView::Archive(BMessage* archive, bool deep) const
void void
WorkspacesView::_AboutRequested() WorkspacesView::_AboutRequested()
{ {
bool needsInit; BAboutWindow* window = new BAboutWindow(
BAboutWindow* window = BAboutWindow::GetWindow( B_TRANSLATE_SYSTEM_NAME("Workspaces"), kSignature);
B_TRANSLATE_SYSTEM_NAME("Workspaces"), kSignature, &needsInit);
if (needsInit) { const char* authors[] = {
const char* authors[] = { "Axel Dörfler",
"Axel Dörfler", "Oliver \"Madison\" Kohl",
"Oliver \"Madison\" Kohl", "Matt Madia",
"Matt Madia", "François Revol",
"François Revol", NULL
NULL };
};
const char* extraCopyrights[] = { const char* extraCopyrights[] = {
"2002 François Revol", "2002 François Revol",
NULL NULL
}; };
const char* extraInfo = "Send windows behind using the Option key. " const char* extraInfo = "Send windows behind using the Option key. "
"Move windows to front using the Control key.\n"; "Move windows to front using the Control key.\n";
window->AddCopyright(2002, "Haiku, Inc.", window->AddCopyright(2002, "Haiku, Inc.",
extraCopyrights); extraCopyrights);
window->AddAuthors(authors); window->AddAuthors(authors);
window->AddExtraInfo(extraInfo); window->AddExtraInfo(extraInfo);
}
if (window->IsHidden()) window->Show();
window->Show();
window->Activate();
} }
+10 -24
View File
@@ -16,6 +16,7 @@
#include <Alert.h> #include <Alert.h>
#include <AppFileInfo.h> #include <AppFileInfo.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Button.h>
#include <File.h> #include <File.h>
#include <Font.h> #include <Font.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
@@ -182,6 +183,11 @@ AboutView::AboutView(const char* appName, const char* signature)
fStripeView = new StripeView(_GetIconFromSignature(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); GroupLayout()->SetSpacing(0);
BLayoutBuilder::Group<>(this) BLayoutBuilder::Group<>(this)
.AddGroup(B_HORIZONTAL, 0) .AddGroup(B_HORIZONTAL, 0)
@@ -192,6 +198,7 @@ AboutView::AboutView(const char* appName, const char* signature)
.Add(fNameView) .Add(fNameView)
.Add(fVersionView) .Add(fVersionView)
.Add(infoViewScroller) .Add(infoViewScroller)
.Add(closeButton)
.End() .End()
.AddGlue() .AddGlue()
.End(); .End();
@@ -352,12 +359,10 @@ AboutView::SetIcon(BBitmap* icon)
BAboutWindow::BAboutWindow(const char* appName, const char* signature) BAboutWindow::BAboutWindow(const char* appName, const char* signature)
: BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_TITLED_WINDOW, : BWindow(BRect(0.0, 0.0, 200.0, 200.0), appName, B_MODAL_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE B_ASYNCHRONOUS_CONTROLS | B_NOT_MOVABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE) | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{ {
sAboutWindow = this;
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
const char* about = B_TRANSLATE_MARK("About %app%"); const char* about = B_TRANSLATE_MARK("About %app%");
@@ -376,8 +381,6 @@ BAboutWindow::BAboutWindow(const char* appName, const char* signature)
BAboutWindow::~BAboutWindow() BAboutWindow::~BAboutWindow()
{ {
sAboutWindow = NULL;
fAboutView->RemoveSelf(); fAboutView->RemoveSelf();
delete fAboutView; delete fAboutView;
fAboutView = NULL; fAboutView = NULL;
@@ -613,20 +616,3 @@ BAboutWindow::SetIcon(BBitmap* icon)
fAboutView->SetIcon(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: case B_ABOUT_REQUESTED:
{ {
bool needsInit; BAboutWindow* window = new BAboutWindow(kAppName, kSignature);
BAboutWindow* window = BAboutWindow::GetWindow(kAppName,
kSignature, &needsInit);
if (needsInit) { const char* authors[] = {
const char* authors[] = { "Axel Dörfler",
"Axel Dörfler", "Adrien Destugues",
"Adrien Destugues", "Oliver Tappe",
"Oliver Tappe", NULL
NULL };
};
window = new BAboutWindow(kAppName, kSignature); window = new BAboutWindow(kAppName, kSignature);
window->AddCopyright(2005, "Haiku, Inc."); window->AddCopyright(2005, "Haiku, Inc.");
window->AddAuthors(authors); window->AddAuthors(authors);
}
if (window->IsHidden()) window->Show();
window->Show();
window->Activate();
break; break;
} }