Skip to content

Commit

Permalink
Account and Settings: Layout tweaks
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
humdingerb committed May 26, 2024
1 parent fe57232 commit 1a6e6a7
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 75 deletions.
35 changes: 18 additions & 17 deletions src/AccountSettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AccountSettingsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AccountSettingsWindow : public BWindow {
friend class NewAccountFilter;

AutoTextControl* fAccountName;
BButton *fCancel, *fOK;
BButton* fOK;
CurrencyPrefView* fPrefView;
Account* fAccount;
BCheckBox* fUseDefault;
Expand Down
5 changes: 2 additions & 3 deletions src/BudgetWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Budget.h"
#include "CurrencyBox.h"
#include "Database.h"
#include "HelpButton.h"
#include "MsgDefs.h"
#include "TimeSupport.h"

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/BudgetWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <TextControl.h>
#include <Window.h>
#include <time.h>

#include "Budget.h"
#include "ColumnListView.h"
#include "ReportGrid.h"
Expand Down
5 changes: 4 additions & 1 deletion src/CheckView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
108 changes: 61 additions & 47 deletions src/PrefWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,18 @@ 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)
{
BString temp;
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);

Expand All @@ -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
Expand Down Expand Up @@ -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"));
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/PrefWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PREFWIN_H

#include <Button.h>
#include <Box.h>
#include <CheckBox.h>
#include <MenuField.h>
#include <Message.h>
Expand All @@ -26,7 +27,7 @@ class PrefWindow : public BWindow {
private:
DatePrefView* fDatePrefView;
CurrencyPrefView* fCurrencyPrefView;
BButton *fOK, *fCancel;
BButton* fOK;
BStringView* fLabel;
};

Expand All @@ -41,7 +42,7 @@ class DatePrefView : public BView {
private:
void UpdateDateLabel(void);

BStringView* fDateLabel;
BBox* fDateBox;
BRadioButton *fDateMDY, *fDateDMY;
AutoTextControl* fDateSeparatorBox;

Expand All @@ -59,7 +60,7 @@ class CurrencyPrefView : public BView {
private:
void UpdateCurrencyLabel(void);

BStringView* fCurrencyLabel;
BBox* fCurrencyBox;
AutoTextControl *fCurrencySymbolBox, *fCurrencyDecimalBox, *fCurrencySeparatorBox;
BCheckBox* fCurrencySymbolPrefix;

Expand Down
4 changes: 1 addition & 3 deletions src/RegisterView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1a6e6a7

Please sign in to comment.