From 1a6e6a72c4e86efddfe8c787b852e5fedbae23f3 Mon Sep 17 00:00:00 2001 From: Humdinger Date: Sat, 25 May 2024 18:23:42 +0200 Subject: [PATCH] Account and Settings: Layout tweaks * Account settings + Show the "Currency format" as BBox label. Saves the extra StringView. + Layout tweaks + Fix crash when renaming an account. + For new accounts, change the window title to "New accounts" instead of using the same "Account settings". * CapitalBe settings + Rename from "Options" to "Settings", just like the menu item. + Center "Default account settings" and increase font size a bit. + Show "Currency/Date format" as BBox labels. Saves the extra StringViews. + Use another date than 01.01.1970, because that doesn't show the difference between MDY and DMY setting... * Use B_USE_BIG_SPACING instead of "font.Size() * 1.3" everywhere that was used to space BBox labels. --- src/AccountSettingsWindow.cpp | 35 +++++------ src/AccountSettingsWindow.h | 2 +- src/BudgetWindow.cpp | 5 +- src/BudgetWindow.h | 1 + src/CheckView.cpp | 5 +- src/PrefWindow.cpp | 108 +++++++++++++++++++--------------- src/PrefWindow.h | 7 ++- src/RegisterView.cpp | 4 +- 8 files changed, 92 insertions(+), 75 deletions(-) diff --git a/src/AccountSettingsWindow.cpp b/src/AccountSettingsWindow.cpp index 3405ec0..59fa58b 100644 --- a/src/AccountSettingsWindow.cpp +++ b/src/AccountSettingsWindow.cpp @@ -28,8 +28,8 @@ AccountSettingsWindow::AccountSettingsWindow(Account* account) AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('Q', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); - BView* back = new BView("back", B_WILL_DRAW); - back->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); + if (fAccount == NULL) + SetTitle(B_TRANSLATE("New account")); fAccountName = new AutoTextControl("accname", B_TRANSLATE("Name:"), (fAccount ? fAccount->Name() : NULL), new BMessage(M_NAME_CHANGED)); @@ -50,28 +50,29 @@ AccountSettingsWindow::AccountSettingsWindow(Account* account) if (strlen(fAccountName->Text()) < 1) fOK->SetEnabled(false); - fCancel = new BButton("cancelbutton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); + BButton* cancel = new BButton("cancelbutton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); SetDefaultButton(fOK); if (!fAccount || fAccount->IsUsingDefaultLocale()) { fPrefView->Hide(); } - - BLayoutBuilder::Group<>(back, B_VERTICAL, 0.0f) - .SetInsets(10) - .AddGroup(B_VERTICAL, 0.0f) - .Add(fAccountName) - .Add(fUseDefault) - .Add(fPrefView) - .End() - .AddGrid(0.0f, 0.0f) - .AddGlue(0, 0) - .Add(fCancel, 1, 0) - .Add(fOK, 2, 0) - .End() +// clang off + BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) + .SetInsets(B_USE_DEFAULT_SPACING) + .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) + .Add(fAccountName) + .Add(fUseDefault) + .Add(fPrefView) + .End() + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) + .AddGlue() + .Add(cancel) + .Add(fOK) + .End() .End(); - BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f).SetInsets(0).Add(back).End(); +// clang on + CenterIn(Frame()); fAccountName->MakeFocus(true); } diff --git a/src/AccountSettingsWindow.h b/src/AccountSettingsWindow.h index f5bcb76..67384af 100644 --- a/src/AccountSettingsWindow.h +++ b/src/AccountSettingsWindow.h @@ -20,7 +20,7 @@ class AccountSettingsWindow : public BWindow { friend class NewAccountFilter; AutoTextControl* fAccountName; - BButton *fCancel, *fOK; + BButton* fOK; CurrencyPrefView* fPrefView; Account* fAccount; BCheckBox* fUseDefault; diff --git a/src/BudgetWindow.cpp b/src/BudgetWindow.cpp index ba6297f..20621bb 100644 --- a/src/BudgetWindow.cpp +++ b/src/BudgetWindow.cpp @@ -11,6 +11,7 @@ #include "Budget.h" #include "CurrencyBox.h" #include "Database.h" +#include "HelpButton.h" #include "MsgDefs.h" #include "TimeSupport.h" @@ -54,11 +55,9 @@ BudgetWindow::BudgetWindow(const BRect& frame) BuildStatsAndEditor(); BuildCategoryList(); - BFont font; - // clang-format off BLayoutBuilder::Group<>(fCatBox, B_VERTICAL, 0.0f) - .SetInsets(B_USE_DEFAULT_SPACING, font.Size() * 1.3, + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_BIG_SPACING, B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fAmountLabel) .Add(fAmountBox) diff --git a/src/BudgetWindow.h b/src/BudgetWindow.h index 73733a8..dbce16d 100644 --- a/src/BudgetWindow.h +++ b/src/BudgetWindow.h @@ -14,6 +14,7 @@ #include #include #include + #include "Budget.h" #include "ColumnListView.h" #include "ReportGrid.h" diff --git a/src/CheckView.cpp b/src/CheckView.cpp index 8a20c8d..31bf115 100644 --- a/src/CheckView.cpp +++ b/src/CheckView.cpp @@ -362,7 +362,10 @@ void CheckView::SetFieldsEnabled(bool enabled) { fDate->SetEnabled(enabled); - fDate->MakeFocus(enabled); + if (fDate->LockLooper()) + fDate->MakeFocus(enabled); + fDate->UnlockLooper(); + fType->SetEnabled(enabled); fPayee->SetEnabled(enabled); fAmount->SetEnabled(enabled); diff --git a/src/PrefWindow.cpp b/src/PrefWindow.cpp index 6c5b4df..423f52e 100644 --- a/src/PrefWindow.cpp +++ b/src/PrefWindow.cpp @@ -31,7 +31,7 @@ enum { PrefWindow::PrefWindow(const BRect& frame) - : BWindow(frame, B_TRANSLATE("Options"), B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, + : BWindow(frame, B_TRANSLATE("Settings"), B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE) { @@ -39,11 +39,10 @@ PrefWindow::PrefWindow(const BRect& frame) AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('Q', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); - BView* back = new BView(NULL, B_WILL_DRAW); - back->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); - - fLabel = new BStringView("windowlabel", B_TRANSLATE("Default account settings:")); - fLabel->SetFont(be_bold_font); + fLabel = new BStringView("windowlabel", B_TRANSLATE("Default account settings")); + BFont font(be_bold_font); + font.SetSize(font.Size() * 1.2f); + fLabel->SetFont(&font); fDatePrefView = new DatePrefView("dateview", &gDefaultLocale); @@ -52,23 +51,30 @@ PrefWindow::PrefWindow(const BRect& frame) fOK = new BButton("okbutton", B_TRANSLATE("Cancel"), new BMessage(M_EDIT_OPTIONS)); fOK->SetLabel(B_TRANSLATE("OK")); - fCancel = new BButton("cancelbutton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); + BButton* cancel = new BButton("cancelbutton", B_TRANSLATE("Cancel"), + new BMessage(B_QUIT_REQUESTED)); SetDefaultButton(fOK); - BLayoutBuilder::Group<>(back, B_VERTICAL, 0.0f) - .SetInsets(10, 10, 10, 10) - .Add(fLabel) +// clang off + BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) + .SetInsets(B_USE_DEFAULT_SPACING) + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) + .AddGlue() + .Add(fLabel) + .AddGlue() + .End() .Add(fDatePrefView) .Add(fCurrencyPrefView) - .AddGrid(0.0f, 0.0f) - .AddGlue(0, 0) - .Add(fCancel, 1, 0) - .Add(fOK, 2, 0) - .End() + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) + .AddGlue() + .Add(cancel) + .Add(fOK) + .End() .End(); - BLayoutBuilder::Group<>(this, B_VERTICAL).SetInsets(0).Add(back).End(); - this->CenterIn(Frame()); +// clang on + + CenterIn(Frame()); } void @@ -107,14 +113,13 @@ DatePrefView::DatePrefView(const char* name, Locale* locale, const int32& flags) else fLocale = gDefaultLocale; - BBox* fDateBox = new BBox("DateBox"); - fDateBox->SetLabel(B_TRANSLATE("Date")); + fDateBox = new BBox("DateBox"); BString datestr; - fLocale.DateToString(0, datestr); + fLocale.DateToString(640180800, datestr); temp = ""; temp.SetToFormat(B_TRANSLATE("Date format: %s"), datestr.String()); - fDateLabel = new BStringView("datelabel", temp.String()); + fDateBox->SetLabel(temp.String()); temp = ""; temp.SetToFormat(B_TRANSLATE("Month, Day, Year")); @@ -133,15 +138,22 @@ DatePrefView::DatePrefView(const char* name, Locale* locale, const int32& flags) fDateSeparatorBox->SetDivider(StringWidth(temp.String()) + 5); fDateSeparatorBox->SetCharacterLimit(2); - BFont font; +//clang off BLayoutBuilder::Group<>(fDateBox, B_VERTICAL, 0.0f) - .SetInsets(10, font.Size() * 1.3, 10, 10) - .Add(fDateLabel) + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_BIG_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING) .Add(fDateMDY) .Add(fDateDMY) - .Add(fDateSeparatorBox) + .AddGroup(B_HORIZONTAL) + .Add(fDateSeparatorBox) + .AddGlue() + .End() + .End(); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .Add(fDateBox) .End(); - BLayoutBuilder::Group<>(this, B_VERTICAL).Add(fDateBox).End(); +// clang on } void @@ -187,9 +199,9 @@ void DatePrefView::UpdateDateLabel(void) { BString temp, label; - fLocale.DateToString(0, temp); + fLocale.DateToString(640180800, temp); label.SetToFormat(B_TRANSLATE("Date format: %s"), temp.String()); - fDateLabel->SetText(label.String()); + fDateBox->SetLabel(label.String()); } void @@ -213,17 +225,14 @@ CurrencyPrefView::CurrencyPrefView(const char* name, Locale* locale, const int32 else fLocale = gDefaultLocale; - BBox* fCurrencyBox = new BBox("CurrencyBox"); - fCurrencyBox->SetLabel(B_TRANSLATE("Currency")); - + fCurrencyBox = new BBox("CurrencyBox"); BString curstr; fLocale.CurrencyToString(fSampleAmount, curstr); temp.SetToFormat(B_TRANSLATE("Currency format: %s"), curstr.String()); - fCurrencyLabel = new BStringView("datelabel", temp.String()); + fCurrencyBox->SetLabel(temp.String()); fCurrencySymbolBox = new AutoTextControl("moneysym", B_TRANSLATE("Symbol:"), fLocale.CurrencySymbol(), new BMessage(M_NEW_CURRENCY_SYMBOL)); - fCurrencySymbolBox->SetDivider(StringWidth(temp.String()) + 5); fCurrencySymbolBox->SetCharacterLimit(2); fCurrencySymbolPrefix = new BCheckBox( @@ -233,26 +242,31 @@ CurrencyPrefView::CurrencyPrefView(const char* name, Locale* locale, const int32 fCurrencySeparatorBox = new AutoTextControl("moneysep", B_TRANSLATE("Separator:"), fLocale.CurrencySeparator(), new BMessage(M_NEW_CURRENCY_SEPARATOR)); - fCurrencySeparatorBox->SetDivider(StringWidth(temp.String()) + 5); fCurrencySeparatorBox->SetCharacterLimit(2); fCurrencyDecimalBox = new AutoTextControl("moneydecimal", B_TRANSLATE("Decimal:"), fLocale.CurrencyDecimal(), new BMessage(M_NEW_CURRENCY_DECIMAL)); - fCurrencyDecimalBox->SetDivider(StringWidth(temp.String()) + 5); fCurrencyDecimalBox->SetCharacterLimit(2); - BFont font; - BLayoutBuilder::Group<>(fCurrencyBox, B_VERTICAL, 0.0f) - .SetInsets(10, font.Size() * 1.3, 10, 10) - .Add(fCurrencyLabel) - .AddGrid(1.0f, 1.0f) - .Add(fCurrencySymbolBox, 0, 0) - .Add(fCurrencySymbolPrefix, 1, 0) - .Add(fCurrencySeparatorBox, 0, 1) - .Add(fCurrencyDecimalBox, 1, 1) - .End() +// clang off + BLayoutBuilder::Group<>(fCurrencyBox, B_VERTICAL, B_USE_DEFAULT_SPACING) + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_BIG_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .AddGrid(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) + .Add(fCurrencySymbolBox->CreateLabelLayoutItem(), 0, 0) + .Add(fCurrencySymbolBox->CreateTextViewLayoutItem(), 1, 0) + .Add(fCurrencySymbolPrefix, 2, 0, 3, 1) + .Add(fCurrencySeparatorBox->CreateLabelLayoutItem(), 0, 1) + .Add(fCurrencySeparatorBox->CreateTextViewLayoutItem(), 1, 1) + .Add(fCurrencyDecimalBox->CreateLabelLayoutItem(), 2, 1) + .Add(fCurrencyDecimalBox->CreateTextViewLayoutItem(), 3, 1) + .AddGlue(4, 1) + .End() + .End(); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .Add(fCurrencyBox) .End(); - BLayoutBuilder::Group<>(this, B_VERTICAL).Add(fCurrencyBox).End(); +// clang on } void @@ -313,7 +327,7 @@ CurrencyPrefView::UpdateCurrencyLabel(void) BString temp, label; fLocale.CurrencyToString(fSampleAmount, temp); label.SetToFormat(B_TRANSLATE("Currency format: %s"), temp.String()); - fCurrencyLabel->SetText(label.String()); + fCurrencyBox->SetLabel(label.String()); } void diff --git a/src/PrefWindow.h b/src/PrefWindow.h index a3773d3..8d5ddae 100644 --- a/src/PrefWindow.h +++ b/src/PrefWindow.h @@ -2,6 +2,7 @@ #define PREFWIN_H #include +#include #include #include #include @@ -26,7 +27,7 @@ class PrefWindow : public BWindow { private: DatePrefView* fDatePrefView; CurrencyPrefView* fCurrencyPrefView; - BButton *fOK, *fCancel; + BButton* fOK; BStringView* fLabel; }; @@ -41,7 +42,7 @@ class DatePrefView : public BView { private: void UpdateDateLabel(void); - BStringView* fDateLabel; + BBox* fDateBox; BRadioButton *fDateMDY, *fDateDMY; AutoTextControl* fDateSeparatorBox; @@ -59,7 +60,7 @@ class CurrencyPrefView : public BView { private: void UpdateCurrencyLabel(void); - BStringView* fCurrencyLabel; + BBox* fCurrencyBox; AutoTextControl *fCurrencySymbolBox, *fCurrencyDecimalBox, *fCurrencySeparatorBox; BCheckBox* fCurrencySymbolPrefix; diff --git a/src/RegisterView.cpp b/src/RegisterView.cpp index e9d2448..869d8ec 100644 --- a/src/RegisterView.cpp +++ b/src/RegisterView.cpp @@ -56,11 +56,9 @@ RegisterView::RegisterView(const char* name, int32 flags) QTNetWorthItem* item; item = new QTNetWorthItem("networth"); - BFont font; - // clang-format off BLayoutBuilder::Group<>(fTrackBox, B_VERTICAL, 0) - .SetInsets(B_USE_DEFAULT_SPACING, font.Size() * 1.3, + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_BIG_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .Add(item) .AddGlue(1024 * 1024 * 2014)