Add an info StringView giving current time or error.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25072 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
adfe1993eb
commit
8b2e7d3032
@ -11,14 +11,14 @@
|
|||||||
#define BW 60
|
#define BW 60
|
||||||
|
|
||||||
LoginView::LoginView(BRect frame)
|
LoginView::LoginView(BRect frame)
|
||||||
: BView(frame, "LoginView", B_FOLLOW_ALL, 0)
|
: BView(frame, "LoginView", B_FOLLOW_ALL, B_PULSE_NEEDED)
|
||||||
{
|
{
|
||||||
// TODO: when I don't need to test in BeOS anymore,
|
// TODO: when I don't need to test in BeOS anymore,
|
||||||
// rewrite to use layout engine.
|
// rewrite to use layout engine.
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
SetLowColor(ViewColor());
|
SetLowColor(ViewColor());
|
||||||
BRect r;
|
BRect r;
|
||||||
r.Set(CSEP, CSEP, 80, Bounds().Height() - 3 * CSEP - BH);
|
r.Set(CSEP, CSEP, 90, Bounds().Height() - 3 * CSEP - BH);
|
||||||
fUserList = new BListView(r, "users");
|
fUserList = new BListView(r, "users");
|
||||||
BScrollView *sv = new BScrollView("userssv", fUserList,
|
BScrollView *sv = new BScrollView("userssv", fUserList,
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true);
|
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true);
|
||||||
@ -59,12 +59,20 @@ LoginView::LoginView(BRect frame)
|
|||||||
new BMessage(kRebootAction));
|
new BMessage(kRebootAction));
|
||||||
AddChild(fRebootButton);
|
AddChild(fRebootButton);
|
||||||
|
|
||||||
|
BRect infoRect(buttonRect);
|
||||||
|
infoRect.OffsetBySelf(buttonWidth + CSEP, 0);
|
||||||
|
|
||||||
buttonRect.OffsetToSelf(Bounds().Width() - CSEP - buttonWidth,
|
buttonRect.OffsetToSelf(Bounds().Width() - CSEP - buttonWidth,
|
||||||
Bounds().Height() - CSEP - BH);
|
Bounds().Height() - CSEP - BH);
|
||||||
fLoginButton = new BButton(buttonRect, "ok", "Ok",
|
fLoginButton = new BButton(buttonRect, "ok", "Ok",
|
||||||
new BMessage(kAttemptLogin));
|
new BMessage(kAttemptLogin));
|
||||||
AddChild(fLoginButton);
|
AddChild(fLoginButton);
|
||||||
|
|
||||||
|
infoRect.right = buttonRect.left - CSEP + 5;
|
||||||
|
BString info;
|
||||||
|
//info << hostname;
|
||||||
|
fInfoView = new BStringView(infoRect, "info", info.String());
|
||||||
|
AddChild(fInfoView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -130,6 +138,7 @@ LoginView::MessageReceived(BMessage *message)
|
|||||||
case kLoginBad:
|
case kLoginBad:
|
||||||
fPasswordControl->SetText("");
|
fPasswordControl->SetText("");
|
||||||
EnableControls(false);
|
EnableControls(false);
|
||||||
|
fInfoView->SetText("Invalid login!");
|
||||||
if (Window()) {
|
if (Window()) {
|
||||||
BPoint savedPos = Window()->Frame().LeftTop();
|
BPoint savedPos = Window()->Frame().LeftTop();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
@ -156,6 +165,19 @@ LoginView::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LoginView::Pulse()
|
||||||
|
{
|
||||||
|
BString info;
|
||||||
|
time_t now = time(NULL);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
// TODO: use strftime and locale settings
|
||||||
|
info << asctime(t);
|
||||||
|
info.RemoveSet("\r\n");
|
||||||
|
fInfoView->SetText(info.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LoginView::AddNextUser()
|
LoginView::AddNextUser()
|
||||||
{
|
{
|
||||||
@ -184,6 +206,10 @@ LoginView::AddNextUser()
|
|||||||
void
|
void
|
||||||
LoginView::EnableControls(bool enable)
|
LoginView::EnableControls(bool enable)
|
||||||
{
|
{
|
||||||
|
int32 i;
|
||||||
|
for (i = 0; i < fUserList->CountItems(); i++) {
|
||||||
|
fUserList->ItemAt(i)->SetEnabled(enable);
|
||||||
|
}
|
||||||
fLoginControl->SetEnabled(enable);
|
fLoginControl->SetEnabled(enable);
|
||||||
fPasswordControl->SetEnabled(enable);
|
fPasswordControl->SetEnabled(enable);
|
||||||
fHidePasswordCheckBox->SetEnabled(enable);
|
fHidePasswordCheckBox->SetEnabled(enable);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
#include <StringView.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
|
||||||
const uint32 kUserSelected = 'usel';
|
const uint32 kUserSelected = 'usel';
|
||||||
@ -19,6 +20,7 @@ public:
|
|||||||
virtual ~LoginView();
|
virtual ~LoginView();
|
||||||
void AttachedToWindow();
|
void AttachedToWindow();
|
||||||
void MessageReceived(BMessage *message);
|
void MessageReceived(BMessage *message);
|
||||||
|
void Pulse();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddNextUser();
|
void AddNextUser();
|
||||||
@ -31,5 +33,8 @@ private:
|
|||||||
BButton* fHaltButton;
|
BButton* fHaltButton;
|
||||||
BButton* fRebootButton;
|
BButton* fRebootButton;
|
||||||
BButton* fLoginButton;
|
BButton* fLoginButton;
|
||||||
|
BStringView* fInfoView;
|
||||||
|
//TODO:
|
||||||
|
//BShelf* fShelf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,13 +2,15 @@
|
|||||||
#include "LoginView.h"
|
#include "LoginView.h"
|
||||||
|
|
||||||
LoginWindow::LoginWindow(BRect frame)
|
LoginWindow::LoginWindow(BRect frame)
|
||||||
: BWindow(frame, /*"Login"*/"Welcome to Haiku", B_TITLED_WINDOW_LOOK,
|
: BWindow(frame, "Welcome to Haiku", B_TITLED_WINDOW_LOOK,
|
||||||
B_NORMAL_WINDOW_FEEL/*B_FLOATING_ALL_WINDOW_FEEL*/,
|
B_NORMAL_WINDOW_FEEL/*B_FLOATING_ALL_WINDOW_FEEL*/,
|
||||||
B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE |
|
B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE |
|
||||||
B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS)
|
B_NOT_MINIMIZABLE | B_NOT_RESIZABLE |
|
||||||
|
B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
LoginView *v = new LoginView(Bounds());
|
LoginView *v = new LoginView(Bounds());
|
||||||
AddChild(v);
|
AddChild(v);
|
||||||
|
SetPulseRate(1000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user