added an EULA, etc ...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14220 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-09-21 15:55:29 +00:00
parent dd7602bbec
commit 35d3acb250
3 changed files with 163 additions and 14 deletions

View File

@ -5,11 +5,19 @@
#include <Alert.h>
#include <Screen.h>
#include <ScrollView.h>
#include <TextView.h>
#include "InstallerApp.h"
const char *APP_SIG = "application/x-vnd.haiku-Installer";
#define EULA_TEXT "HAIKU INC - END USER LICENSE AGREEMENT\n\n\
NOTICE: READ THIS BEFORE INSTALLING OR USING Haiku\n\
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\
THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\
"
int main(int, char **)
{
InstallerApp theApp;
@ -25,6 +33,26 @@ InstallerApp::InstallerApp()
windowFrame.OffsetBy((frame.Width() - windowFrame.Width())/2,
frame.Height()/2 - windowFrame.Height()/4 - 113);
fWindow = new InstallerWindow(windowFrame);
// show the EULA
BAlert *alert = new BAlert("", EULA_TEXT, " Disagree ", " Agree ", NULL,
B_WIDTH_FROM_WIDEST, B_EMPTY_ALERT);
BTextView *alertView = alert->TextView();
alertView->SetViewColor(255,255,255);
BView *parent = alertView->Parent();
alertView->RemoveSelf();
alertView->MoveBy(3,7);
alertView->ResizeTo(460,283);
alertView->SetResizingMode(B_FOLLOW_ALL_SIDES);
alert->ResizeTo(500,350);
BScrollView *scroll = new BScrollView("", alertView, B_FOLLOW_ALL_SIDES, B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
parent->AddChild(scroll);
BRect alertFrame = alert->Frame();
alertFrame.OffsetTo((frame.Width() - alertFrame.Width())/2,
(frame.Height() - alertFrame.Height())/2);
alert->MoveTo(alertFrame.LeftTop());
if (alert->Go()!=1)
PostMessage(B_QUIT_REQUESTED);
}
void

View File

@ -3,16 +3,24 @@
* Distributed under the terms of the MIT License.
*/
#include <Alert.h>
#include <Application.h>
#include <Box.h>
#include "DrawButton.h"
#include <PopUpMenu.h>
#include <Roster.h>
#include <ScrollView.h>
#include <string.h>
#include "InstallerWindow.h"
const uint32 BEGIN_MESSAGE = 'iBMG';
const uint32 SHOW_BOTTOM_MESSAGE = 'iSMG';
#define DRIVESETUP_SIG "application/x-vnd.Be-DRV$"
const uint32 BEGIN_MESSAGE = 'iBGN';
const uint32 SHOW_BOTTOM_MESSAGE = 'iSBT';
const uint32 SETUP_MESSAGE = 'iSEP';
InstallerWindow::InstallerWindow(BRect frame_rect)
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fDriveSetupLaunched(false)
{
BRect bounds = Bounds();
@ -21,21 +29,59 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
fBackBox = new BBox(bounds, NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
AddChild(fBackBox);
fBeginButton = new BButton(BRect(bounds.right-90, bounds.bottom-34, bounds.right-10, bounds.bottom-10),
"begin_button", "Begin", new BMessage(BEGIN_MESSAGE));
BRect statusRect(bounds.left+120, bounds.top+14, bounds.right-14, bounds.top+60);
BRect textRect(statusRect);
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(2,2);
fStatusView = new BTextView(statusRect, "statusView", textRect,
be_plain_font, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
fStatusView->MakeEditable(false);
fStatusView->MakeSelectable(false);
BScrollView *scroll = new BScrollView("statusScroll", fStatusView, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_FRAME_EVENTS);
fBackBox->AddChild(scroll);
fBeginButton = new BButton(BRect(bounds.right-90, bounds.bottom-35, bounds.right-10, bounds.bottom-11),
"begin_button", "Begin", new BMessage(BEGIN_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fBeginButton->MakeDefault(true);
fBackBox->AddChild(fBeginButton);
DrawButton *drawButton = new DrawButton(BRect(bounds.left+12, bounds.bottom-33, bounds.left+100, bounds.bottom-20),
fSetupButton = new BButton(BRect(bounds.left+11, bounds.bottom-35, bounds.left+111, bounds.bottom-22),
"setup_button", "Setup partitions" B_UTF8_ELLIPSIS, new BMessage(SETUP_MESSAGE), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM);
fBackBox->AddChild(fSetupButton);
fSetupButton->Hide();
fDrawButton = new DrawButton(BRect(bounds.left+12, bounds.bottom-33, bounds.left+100, bounds.bottom-20),
"options_button", "Fewer options", "More options", new BMessage(SHOW_BOTTOM_MESSAGE));
fBackBox->AddChild(drawButton);
fBackBox->AddChild(fDrawButton);
fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS);
fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS);
BRect fieldRect(bounds.left+50, bounds.top+70, bounds.left+250, bounds.top+90);
fSrcMenuField = new BMenuField(fieldRect, "srcMenuField",
"Install from: ", fSrcMenu);
fSrcMenuField->SetDivider(70.0);
fSrcMenuField->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fSrcMenuField);
fieldRect.OffsetBy(0,23);
fDestMenuField = new BMenuField(fieldRect, "destMenuField",
"Onto: ", fDestMenu);
fDestMenuField->SetDivider(70.0);
fDestMenuField->SetAlignment(B_ALIGN_RIGHT);
fBackBox->AddChild(fDestMenuField);
// finish creating window
Show();
fDriveSetupLaunched = be_roster->IsRunning(DRIVESETUP_SIG);
be_roster->StartWatching(this);
}
InstallerWindow::~InstallerWindow()
{
be_roster->StopWatching(this);
}
@ -46,7 +92,21 @@ InstallerWindow::MessageReceived(BMessage *msg)
case BEGIN_MESSAGE:
break;
case SHOW_BOTTOM_MESSAGE:
ShowBottom();
break;
case SETUP_MESSAGE:
LaunchDriveSetup();
break;
case B_SOME_APP_LAUNCHED:
case B_SOME_APP_QUIT:
{
const char *signature;
if (msg->FindString("be:signature", &signature)==B_OK
&& strcasecmp(signature, DRIVESETUP_SIG)==0) {
DisableInterface(msg->what == B_SOME_APP_LAUNCHED);
}
break;
}
default:
BWindow::MessageReceived(msg);
break;
@ -56,18 +116,66 @@ InstallerWindow::MessageReceived(BMessage *msg)
bool
InstallerWindow::QuitRequested()
{
if (fDriveSetupLaunched) {
(new BAlert("driveSetup",
"Please close the DriveSetup window before closing the\nInstaller window.", "OK"))->Go();
return false;
}
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
void
InstallerWindow::ShowBottom(bool show)
InstallerWindow::ShowBottom()
{
if (show) {
if (fDrawButton->Value()) {
ResizeTo(332,306);
if (fSetupButton->IsHidden())
fSetupButton->Show();
} else {
ResizeTo(332,160);
if (!fSetupButton->IsHidden())
fSetupButton->Hide();
}
}
void
InstallerWindow::LaunchDriveSetup()
{
if (be_roster->Launch(DRIVESETUP_SIG)!=B_OK)
fprintf(stderr, "There was an error while launching DriveSetup\n");
}
void
InstallerWindow::DisableInterface(bool disable)
{
if (!disable) {
ScanningInProgress();
}
fDriveSetupLaunched = disable;
fBeginButton->SetEnabled(!disable);
fSetupButton->SetEnabled(!disable);
fSrcMenuField->SetEnabled(!disable);
fDestMenuField->SetEnabled(!disable);
if (disable)
fStatusView->SetText("Running DriveSetup" B_UTF8_ELLIPSIS "\nClose DriveSetup to continue with the\ninstallation.");
}
void
InstallerWindow::ScanningComplete()
{
fStatusView->SetText("Choose the disk you want to install onto\nfrom the pop-up menu. Then click \"Begin\".");
}
void
InstallerWindow::ScanningInProgress()
{
fStatusView->SetText("Scanning for disks" B_UTF8_ELLIPSIS);
}

View File

@ -8,7 +8,11 @@
#include <Box.h>
#include <Button.h>
#include <Menu.h>
#include <MenuField.h>
#include <TextView.h>
#include <Window.h>
#include "DrawButton.h"
class InstallerWindow : public BWindow {
public:
@ -19,9 +23,18 @@ public:
virtual bool QuitRequested();
private:
void ShowBottom(bool show);
void DisableInterface(bool disable);
void LaunchDriveSetup();
void ShowBottom();
void ScanningComplete();
void ScanningInProgress();
BBox *fBackBox;
BButton *fBeginButton;
BButton *fBeginButton, *fSetupButton;
DrawButton *fDrawButton;
bool fDriveSetupLaunched;
BTextView *fStatusView;
BMenu* fSrcMenu, *fDestMenu;
BMenuField* fSrcMenuField, *fDestMenuField;
};
#endif /* _InstallerWindow_h */