From 8b2e7d30325194df8a440c30ab0b0dffe7d4e656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sun, 20 Apr 2008 03:32:07 +0000 Subject: [PATCH] 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 --- src/apps/login/LoginView.cpp | 30 ++++++++++++++++++++++++++++-- src/apps/login/LoginView.h | 5 +++++ src/apps/login/LoginWindow.cpp | 6 ++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/apps/login/LoginView.cpp b/src/apps/login/LoginView.cpp index 0645aad851..c32a8371f2 100644 --- a/src/apps/login/LoginView.cpp +++ b/src/apps/login/LoginView.cpp @@ -11,14 +11,14 @@ #define BW 60 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, // rewrite to use layout engine. SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ViewColor()); 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"); BScrollView *sv = new BScrollView("userssv", fUserList, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); @@ -59,12 +59,20 @@ LoginView::LoginView(BRect frame) new BMessage(kRebootAction)); AddChild(fRebootButton); + BRect infoRect(buttonRect); + infoRect.OffsetBySelf(buttonWidth + CSEP, 0); + buttonRect.OffsetToSelf(Bounds().Width() - CSEP - buttonWidth, Bounds().Height() - CSEP - BH); fLoginButton = new BButton(buttonRect, "ok", "Ok", new BMessage(kAttemptLogin)); 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: fPasswordControl->SetText(""); EnableControls(false); + fInfoView->SetText("Invalid login!"); if (Window()) { BPoint savedPos = Window()->Frame().LeftTop(); 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 LoginView::AddNextUser() { @@ -184,6 +206,10 @@ LoginView::AddNextUser() void LoginView::EnableControls(bool enable) { + int32 i; + for (i = 0; i < fUserList->CountItems(); i++) { + fUserList->ItemAt(i)->SetEnabled(enable); + } fLoginControl->SetEnabled(enable); fPasswordControl->SetEnabled(enable); fHidePasswordCheckBox->SetEnabled(enable); diff --git a/src/apps/login/LoginView.h b/src/apps/login/LoginView.h index a42d9b7f5b..6c19adf357 100644 --- a/src/apps/login/LoginView.h +++ b/src/apps/login/LoginView.h @@ -3,6 +3,7 @@ #include #include #include +#include #include const uint32 kUserSelected = 'usel'; @@ -19,6 +20,7 @@ public: virtual ~LoginView(); void AttachedToWindow(); void MessageReceived(BMessage *message); + void Pulse(); private: void AddNextUser(); @@ -31,5 +33,8 @@ private: BButton* fHaltButton; BButton* fRebootButton; BButton* fLoginButton; + BStringView* fInfoView; + //TODO: + //BShelf* fShelf; }; diff --git a/src/apps/login/LoginWindow.cpp b/src/apps/login/LoginWindow.cpp index 75edc14299..d59c7125b5 100644 --- a/src/apps/login/LoginWindow.cpp +++ b/src/apps/login/LoginWindow.cpp @@ -2,13 +2,15 @@ #include "LoginView.h" 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_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()); AddChild(v); + SetPulseRate(1000000LL); }