xref: /haiku/src/apps/installer/EULAWindow.cpp (revision 5ac9b506412b11afb993bb52d161efe7666958a5)
1 /*
2  * Copyright 2013,	Jérôme DUVAL.
3  * All rights reserved. Distributed under the terms of the MIT license.
4  */
5 
6 
7 #include "EULAWindow.h"
8 
9 #include <Application.h>
10 #include <Box.h>
11 #include <Button.h>
12 #include <Catalog.h>
13 #include <LayoutBuilder.h>
14 #include <LayoutUtils.h>
15 #include <Roster.h>
16 #include <ScrollView.h>
17 #include <SpaceLayoutItem.h>
18 
19 #include "tracker_private.h"
20 
21 static const uint32 kMsgAgree = 'agre';
22 static const uint32 kMsgNext = 'next';
23 
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "InstallerApp"
26 
27 
28 EULAWindow::EULAWindow()
29 	:
30 	BWindow(BRect(0, 0, 600, 450), B_TRANSLATE("README"),
31 		B_MODAL_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE
32 		| B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS)
33 {
34 	BString infoText;
35 	infoText << B_TRANSLATE(
36 		"Welcome to the Haiku Installer!\n\n");
37 	infoText << B_TRANSLATE(
38 		"IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n");
39 	infoText << B_TRANSLATE(
40 		"This is beta-quality software! It means there is a risk of "
41 		"losing important data. Make frequent backups! You have been "
42 		"warned.\n\n\n");
43 	infoText << B_TRANSLATE(
44 		"1)   If you are installing Haiku onto real hardware (not inside an "
45 		"emulator), you may want to prepare a hard disk partition from "
46 		"another OS (you could, for example, use a GParted Live-CD, which "
47 		"can also resize existing partitions to make room).\n"
48 		"You can also set up partitions by launching DriveSetup from "
49 		"Installer, but you won't be able to resize existing partitions with "
50 		"it. While DriveSetup has been quite thoroughly tested over the "
51 		"years, it's recommended to have up-to-date backups of the other "
52 		"partitions on your system. Just in case" B_UTF8_ELLIPSIS);
53 	infoText << "\n\n\n";
54 	infoText << B_TRANSLATE(
55 		"2)   The Installer will make the Haiku partition itself bootable, "
56 		"but takes no steps to integrate Haiku into an existing boot menu. "
57 		"If you have GRUB already installed, you can add Haiku to it.\n"
58 		"For details, please consult the guide on booting Haiku on our "
59 		"website at https://www.haiku-os.org/guides/booting.\n"
60 		"Or you can set up a boot menu from Installer's \"Tools\" menu, see "
61 		"the Userguide's topic on the application \"BootManager\".\n\n\n");
62 	infoText << B_TRANSLATE(
63 		"3)   When you successfully boot into Haiku for the first time, make "
64 		"sure to read our \"Welcome\" and \"Userguide\" documentation. There "
65 		"are links on the Desktop and in WebPositive's bookmarks.\n\n");
66 	infoText << B_TRANSLATE(
67 		"Have fun and thanks for trying out Haiku!");
68 
69 	BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW);
70 	textView->SetInsets(10, 10, 10, 10);
71 	textView->MakeEditable(false);
72 	textView->MakeSelectable(false);
73 	textView->SetText(infoText);
74 
75 	BScrollView* scrollView = new BScrollView("eulaScroll",
76 		textView, B_WILL_DRAW, false, true);
77 
78 	BButton* cancelButton = new BButton(B_TRANSLATE("Quit"),
79 		new BMessage(B_QUIT_REQUESTED));
80 	cancelButton->SetTarget(be_app);
81 
82 	BButton* continueButton = new BButton(B_TRANSLATE("Continue"),
83 		new BMessage(kMsgAgree));
84 	continueButton->SetTarget(be_app);
85 	continueButton->MakeDefault(true);
86 
87 	if (!be_roster->IsRunning(kTrackerSignature))
88 		SetWorkspaces(B_ALL_WORKSPACES);
89 
90 	BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
91 		.SetInsets(B_USE_WINDOW_SPACING)
92 		.Add(scrollView)
93 		.AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
94 			.AddGlue()
95 			.Add(cancelButton)
96 			.Add(continueButton);
97 
98 	CenterOnScreen();
99 	Show();
100 }
101 
102 
103 bool
104 EULAWindow::QuitRequested()
105 {
106 	be_app->PostMessage(kMsgNext);
107 	return true;
108 }
109