diff --git a/src/application/mClockView.cpp b/src/application/mClockView.cpp index 9efeaa6..946f388 100644 --- a/src/application/mClockView.cpp +++ b/src/application/mClockView.cpp @@ -1,106 +1,27 @@ // mWindow.cpp +#include +#include +#include #include "mClockView.h" -const char* mPathToConfigFile3 = "LockWorkstationSettings"; -const char* mNameConfigBool = "clock"; -const char* mNameConfigColorR = "clockR"; -const char* mNameConfigColorG = "clockG"; -const char* mNameConfigColorB = "clockB"; -const char* mNameConfigPlaceX = "clockX"; -const char* mNameConfigPlaceY = "clockY"; -const char* mNameConfigFontSize = "fontSize"; - -const char* mDefaultBoolClock = "0"; -const char* mDefaultColorClockR = "0"; -const char* mDefaultColorClockG = "0"; -const char* mDefaultColorClockB = "0"; -const char* mDefaultClockPlaceX = "0"; -const char* mDefaultClockPlaceY = "0"; -const char* mDefaultFontSize = "8"; //*2 - /*************************************************/ /******************* Start ***********************/ /*************************************************/ -mClockView::mClockView(BRect rect, const char *name, uint32 resizingMode, uint32 flags) - : BView(BRect(0, 0, 200, 100), "Mariux", B_FOLLOW_TOP | B_FOLLOW_LEFT, B_FORCE_ANTIALIASING | B_WILL_DRAW | B_PULSE_NEEDED) +mClockView::mClockView(BRect rect, LWSettings* settings) +: BView(rect, "Mariux", B_FOLLOW_LEFT_TOP, B_WILL_DRAW | B_PULSE_NEEDED), + mSettings(settings) { -UserThread = spawn_thread(UserThreadChange_static, "Change Image Thread", - B_URGENT_DISPLAY_PRIORITY, this); -resume_thread(UserThread); -//FILEREAD -find_directory(B_USER_SETTINGS_DIRECTORY, &path); -path.Append(mPathToConfigFile3); -status = file.SetTo(path.Path(), B_READ_ONLY); - if (status == B_OK) - { - status = savemessage.Unflatten(&file); - } - -//Bool - if (savemessage.HasString(mNameConfigBool) == 0) - { - savemessage.AddString(mNameConfigBool, mDefaultBoolClock); - } -savemessage.FindString(mNameConfigBool, &mStringBoolClock); - -//Red - if (savemessage.HasString(mNameConfigColorR) == 0) - { - savemessage.AddString(mNameConfigColorR, mDefaultColorClockR); - } -savemessage.FindString(mNameConfigColorR, &mStringColorR); - -//Green - if (savemessage.HasString(mNameConfigColorG) == 0) - { - savemessage.AddString(mNameConfigColorG, mDefaultColorClockG); - } -savemessage.FindString(mNameConfigColorG, &mStringColorG); - -//Blue - if (savemessage.HasString(mNameConfigColorB) == 0) - { - savemessage.AddString(mNameConfigColorB, mDefaultColorClockB); - } -savemessage.FindString(mNameConfigColorB, &mStringColorB); + ThreadedCall(UserThread, UserThreadChange_static, "Change Image Thread", + B_URGENT_DISPLAY_PRIORITY, this); -//PlaceX - if (savemessage.HasString(mNameConfigPlaceX) == 0) - { - savemessage.AddString(mNameConfigPlaceX, mDefaultClockPlaceX); - } -savemessage.FindString(mNameConfigPlaceX, &mStringPlaceX); + _InitUIData(); -//PlaceY - if (savemessage.HasString(mNameConfigPlaceY) == 0) - { - savemessage.AddString(mNameConfigPlaceY, mDefaultClockPlaceY); - } -savemessage.FindString(mNameConfigPlaceY, &mStringPlaceY); - -//Bool - if (savemessage.HasString(mNameConfigFontSize) == 0) - { - savemessage.AddString(mNameConfigFontSize, mDefaultFontSize); - } -savemessage.FindString(mNameConfigFontSize, &mStringFontSize); - -if (file.SetTo(path.Path(), B_WRITE_ONLY | B_CREATE_FILE) == B_OK) - { - savemessage.Flatten(&file); - } - -mFontSize = atoi(mStringFontSize.String()); -mColorR = atoi(mStringColorR.String()); -mColorG = atoi(mStringColorG.String()); -mColorB = atoi(mStringColorB.String()); -mPlaceX = atoi(mStringPlaceX.String()); -mPlaceY = atoi(mStringPlaceY.String()); -SetHighColor(mColorR, mColorG, mColorB); -SetDrawingMode(B_OP_OVER); -SetFont(be_bold_font); -SetFontSize(((mFontSize)*2)); -SetViewColor(B_TRANSPARENT_COLOR); + SetHighColor(mColor); + SetDrawingMode(B_OP_ALPHA); + SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE_LIGHTEN); + SetFont(be_bold_font); + SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + ResizeToPreferred(); } /*********************************************/ @@ -108,61 +29,25 @@ SetViewColor(B_TRANSPARENT_COLOR); /*********************************************/ void mClockView::Draw(BRect updateRect) { -mSecond.SetTo(""); -mMinute.SetTo(""); -mHour.SetTo(""); -//second -if(todaysecond < 10) -{ -mSecond << "0" << todaysecond; -} -else -{ -mSecond << todaysecond; -} -//minute -if(todayminute < 10) -{ -mMinute << "0" << todayminute; -} -else -{ -mMinute << todayminute; -} -//hour -if(todayhour < 10) -{ -mHour << "0" << todayhour; -} -else -{ -mHour << todayhour; -} -if (mStringBoolClock == "0") -{ -mShowClock = false; -} -else -{ -mShowClock = true; -} -mTimer.SetTo(""); -if (mShowClock) -{ -mTimer << mHour.String() << ":" << mMinute.String() << ":" << mSecond.String(); -} -MovePenTo((mPlaceX+2), (mPlaceY+15)); -DrawString(mTimer.String()); + SetFontSize(mFontSize * 8); + float timewidth = StringWidth(mTimer.String()); + MovePenTo((Frame().Width() / 2) - (timewidth / 2), + (Frame().Height() * 0.5f)); + DrawString(mTimer.String()); + + SetFontSize(mFontSize * 4); + float datewidth = StringWidth(mDater.String()); + MovePenTo((Frame().Width() / 2) - (datewidth / 2), + (Frame().Height()) * 0.9f); + DrawString(mDater.String()); + + Invalidate(); } void mClockView::Pulse() { -time(&tmptodaytime); -TodayTime = localtime(&tmptodaytime); - if (todaysecond != TodayTime->tm_sec) - { - Invalidate(); - } + _TimeUpdate(); + Invalidate(); } int32 @@ -176,15 +61,30 @@ mClockView::UserThreadChange_static(void *data) void mClockView::UserThreadChangeImage() { -int a = 1; -while (a == 1) -{ -time(&tmptodaytime); -TodayTime = localtime(&tmptodaytime); -todaysecond = TodayTime->tm_sec; -todayminute = TodayTime->tm_min; -todayhour = TodayTime->tm_hour; -sleep(1); + while(mShowClock) { + _TimeUpdate(); + + mTimer.SetTo(""); + BTimeFormat tfmt; + tfmt.Format(mTimer, tmptodaytime, B_MEDIUM_TIME_FORMAT, NULL); + + mDater.SetTo(""); + BDateFormat fmt; + fmt.Format(mDater, tmptodaytime, B_LONG_DATE_FORMAT, NULL); + + sleep(1); + } } + +void mClockView::_InitUIData() +{ + mShowClock = mSettings->ClockIsEnabled(); + mColor = mSettings->ClockColor(); + mPlace = mSettings->ClockLocation(); + mFontSize = mSettings->ClockSize(); } +void mClockView::_TimeUpdate() +{ + std::time(&tmptodaytime); +} diff --git a/src/application/mClockView.h b/src/application/mClockView.h index 3471f01..9b6f604 100644 --- a/src/application/mClockView.h +++ b/src/application/mClockView.h @@ -4,42 +4,36 @@ #define _mClockView_h_ #include "mConstant.h" +#include "../common/LockWorkstationConfig.h" +#include "../common/ThreadedClass.h" class mClockView - : public BView + : public BView, ThreadedClass { public: - mClockView(BRect rect, const char *name, uint32 resizingMode, uint32 flags); + mClockView(BRect rect, LWSettings* settings); void Draw(BRect updateRect); virtual void Pulse(); - private: - time_t tmptodaytime; - char charer[1024]; - int todaysecond , todayminute , todayhour , todayday , todaymonth , todayyear ; - int mColorR, mColorG, mColorB, mPlaceX, mPlaceY, mFontSize; + void _InitUIData(); + void _TimeUpdate(); +private: + // From settings + LWSettings *mSettings; + int mFontSize; bool mShowClock; - struct tm *TodayTime; - BString mTimer; - BString mMinute; - BString mHour; - BString mSecond; - BPath path; - BFile file; - status_t status; - BMessage savemessage; - BString mStringBoolClock; - BString mStringColorR; - BString mStringColorG; - BString mStringColorB; - BString mStringPlaceX; - BString mStringPlaceY; - BString mStringFontSize; - mClockView* mCV; + rgb_color mColor; + BPoint mPlace; + + // Date & time + time_t tmptodaytime; + BString mTimer, + mDater; + //threads thread_id UserThread; static int32 UserThreadChange_static(void *data); void UserThreadChangeImage(); }; -#endif \ No newline at end of file +#endif diff --git a/src/application/mWindow.cpp b/src/application/mWindow.cpp index 89d192a..f7f6478 100644 --- a/src/application/mWindow.cpp +++ b/src/application/mWindow.cpp @@ -42,28 +42,42 @@ mWindow::mWindow(const char* mWindowTitle) if(!settings->SessionBarIsEnabled()) sessionbar->Hide(); + mClock = new mClockView(BRect(0, 0, 100, 100), settings); + if(!settings->ClockIsEnabled()) + mClock->Hide(); + // Background view mView = new mBackgroundView(BRect(0, 0, 2000, 2000), NULL, B_FOLLOW_NONE, B_WILL_DRAW, settings->BackgroundColor(), settings->BackgroundMode(), imgpath, settings->BackgroundImageSnooze()); - BLayoutBuilder::Group<>(mView, B_HORIZONTAL, 0) + // Layout kit + BLayoutBuilder::Group<>(mView, B_VERTICAL, 0) .SetInsets(B_USE_WINDOW_INSETS) - .AddGlue() - .AddGroup(B_VERTICAL) + .AddGlue(0.1f) + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 0.1f) .AddGlue() - .Add(loginbox) - .AddStrut(12.0f) - .Add(sessionbar) + .Add(mClock) .AddGlue() .End() - .AddGlue() - .AddGroup(B_VERTICAL) + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 0.7f) + .AddGlue() + .AddGroup(B_VERTICAL) + .AddGlue() + .Add(loginbox) + .AddStrut(12.0f) + .Add(sessionbar) + .AddGlue() + .End() .AddGlue() - .Add(infoview) + .AddGroup(B_VERTICAL) + .AddGlue() + .Add(infoview) + .AddGlue() + .End() .AddGlue() .End() - .AddGlue() + .AddGlue(0.1f) .End(); AddChild(mView); diff --git a/src/application/mWindow.h b/src/application/mWindow.h index 6d27526..b16d3ca 100644 --- a/src/application/mWindow.h +++ b/src/application/mWindow.h @@ -32,6 +32,7 @@ class mWindow : public BWindow mLoginBox *loginbox; mSystemInfo *infoview; mSessionBar *sessionbar; + mClockView *mClock; LWSettings *settings; mLogger *logger; diff --git a/src/preflet/mUserInfo.cpp b/src/preflet/mUserInfo.cpp index 84a11b9..035c748 100644 --- a/src/preflet/mUserInfo.cpp +++ b/src/preflet/mUserInfo.cpp @@ -69,7 +69,7 @@ mUserInfo::mUserInfo(BRect frame, BWindow* parent, const char* name) .End(); containerView->Hide(); - fBtShowPwdChangeView = new BButton("bt_change", B_TRANSLATE("Change pass"), + fBtShowPwdChangeView = new BButton("bt_change", B_TRANSLATE("Password"), new BMessage(UI_WINDOW_SHOW_PWDCHANGE)); fBtShowPwdChangeView->SetBehavior(BButton::B_TOGGLE_BEHAVIOR); fBtCloseWindow = new BButton("bt_ok", B_TRANSLATE("Cerrar"), diff --git a/src/preflet/mWindow.cpp b/src/preflet/mWindow.cpp index 71d574d..d07fcf3 100644 --- a/src/preflet/mWindow.cpp +++ b/src/preflet/mWindow.cpp @@ -810,7 +810,7 @@ BView* mWindow::CreateCardView_AccountMethod() mSliderAttemptsThrshld->SetLimitLabels(B_TRANSLATE("0 (limitless)"), B_TRANSLATE("10")); mSliderErrorWaitTime = new BSlider("sl_snzt", - B_TRANSLATE("Waiting seconds after too many failed attempts"), + B_TRANSLATE("Wait time after too many failed attempts"), new BMessage(M_AUTHOPTS_ERRSNZ), 0, 10, B_HORIZONTAL, B_TRIANGLE_THUMB, B_FRAME_EVENTS | B_WILL_DRAW | B_NAVIGABLE); mSliderErrorWaitTime->SetHashMarks(B_HASH_MARKS_BOTH); @@ -884,12 +884,16 @@ BView* mWindow::CreateCardView_User() BScrollView* userlistScroll = new BScrollView("scv_usrlst", mListOfUsers, B_FOLLOW_LEFT_TOP, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER); + BStringView* sysaccountsDesc = new BStringView("sv_sysacc", + B_TRANSLATE("List of user accounts available in the system.\n" + "A double click shows details of the selected account.")); BView* mListView = new BView("ListView", B_SUPPORTS_LAYOUT, NULL); mListView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); mListView->SetHighUIColor(B_PANEL_TEXT_COLOR); BLayoutBuilder::Group<>(mListView, B_VERTICAL) .SetInsets(B_USE_SMALL_INSETS) + .Add(sysaccountsDesc) .Add(userlistScroll) .End(); @@ -929,7 +933,7 @@ BView* mWindow::CreateCardView_Background() BBox* mBoxAroundColorControl = new BBox("box_col", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_FANCY_BORDER, mColorView); - mBoxAroundColorControl->SetLabel(B_TRANSLATE("Colors")); + mBoxAroundColorControl->SetLabel(B_TRANSLATE("Color")); /* ImagePath */ @@ -1010,13 +1014,15 @@ BView* mWindow::CreateCardView_Clock() { int32 mMinFontValue = 5, mMaxFontValue = 15; int32 HashMarksCount = 11; - const char* mStringSliderMinLimitLabel = "10"; - const char* mStringSliderMaxLimitLabel = "30"; + const char* mStringSliderMinLimitLabel = B_TRANSLATE_COMMENT("10", + "The number in your native language"); + const char* mStringSliderMaxLimitLabel = B_TRANSLATE_COMMENT("30", + "The number in your native language"); int CurrentSliderValue = 10; /* Clock feature enablement */ mCheckBoxBoolClock = new BCheckBox("Bool clock", - B_TRANSLATE("Show Clock? (option currently not available)"), new BMessage(BOOL_CLOCK), + B_TRANSLATE("Show Clock?"), new BMessage(BOOL_CLOCK), B_WILL_DRAW | B_NAVIGABLE); /* Clock font size */ @@ -1050,7 +1056,7 @@ BView* mWindow::CreateCardView_Clock() BBox* boxClockColor = new BBox("box_clock_col", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_FANCY_BORDER, clockColorView); - boxClockColor->SetLabel(B_TRANSLATE("Colors")); + boxClockColor->SetLabel(B_TRANSLATE("Color")); /* Clock placement */ mTextControlClockPlaceX = new BTextControl("ClockPlacementX",