Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: HaikuArchives/Calendar
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 31a2672d4abe
Choose a base ref
...
head repository: HaikuArchives/Calendar
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 12e1362b7b12
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Dec 19, 2021

  1. Simplify Settings window

    As there are currently only few options, do away with the BBoxes and
    simply add those two pop-up menus and the checkbox.
    Adding a horizontal separator above BButtons for aethetics.
    
    Other minor changes:
    * open Settings window in center of main window
    * minor changes in labels
    * change app description in About
    * a few minor coding style changes I couldn't resist
    Humdinger committed Dec 19, 2021
    Copy the full SHA
    4907b5c View commit details
  2. Category window: rename Button "Add" to "New"

    For consistency with how events are created.
    Humdinger committed Dec 19, 2021
    Copy the full SHA
    12e1362 View commit details
Showing with 51 additions and 93 deletions.
  1. +5 −3 src/App.cpp
  2. +2 −2 src/CategoryWindow.cpp
  3. +1 −1 src/CategoryWindow.h
  4. +33 −66 src/PreferenceWindow.cpp
  5. +10 −21 src/PreferenceWindow.h
8 changes: 5 additions & 3 deletions src/App.cpp
Original file line number Diff line number Diff line change
@@ -67,15 +67,16 @@ App::AboutRequested()
{
const char* authors[] = {
"Akshay Agarwal",
"humdinger",
"Humdinger",
"Jaidyn Levesque",
"malbx",
"Fredrik Modéen",
"Bach Nguyen",
NULL
};
BAboutWindow* aboutW = new BAboutWindow(kAppName, kSignature);
aboutW->AddDescription(B_TRANSLATE("A native Calendar application for Haiku."));
aboutW->AddDescription(B_TRANSLATE(
"A calendar application to manage your appointments."));
aboutW->AddCopyright(2017, "Akshay Agarwal");
aboutW->AddAuthors(authors);
aboutW->Show();
@@ -122,7 +123,8 @@ App::MessageReceived(BMessage* message)
case kMenuAppPref:
{
if (fPreferenceWindow == NULL) {
fPreferenceWindow = new PreferenceWindow(fPreferences);
fPreferenceWindow = new PreferenceWindow(fMainWindow->Frame(),
fPreferences);
fPreferenceWindow->Show();
}

4 changes: 2 additions & 2 deletions src/CategoryWindow.cpp
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ CategoryWindow::_InitInterface()
fCategoryListView->SetSelectionMessage(new BMessage(kCategorySelected));
fCategoryListView->SetInvocationMessage(new BMessage(kCategoryEditSelected));

fAddButton = new BButton("AddButton", B_TRANSLATE("Add" B_UTF8_ELLIPSIS),
fNewButton = new BButton("NewButton", B_TRANSLATE("New" B_UTF8_ELLIPSIS),
new BMessage(kAddPressed));
fDeleteButton = new BButton("DeleteButton", B_TRANSLATE("Delete"),
new BMessage(kDeletePressed));
@@ -200,7 +200,7 @@ CategoryWindow::_InitInterface()
.AddGroup(B_HORIZONTAL, B_USE_HALF_ITEM_SPACING)
.Add(fDeleteButton)
.AddGlue()
.Add(fAddButton)
.Add(fNewButton)
.Add(fEditButton)
.End()
.End();
2 changes: 1 addition & 1 deletion src/CategoryWindow.h
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ class CategoryWindow: public BWindow {
BView* fMainView;
BListView* fCategoryListView;
BScrollView* fCategoryScroll;
BButton* fAddButton;
BButton* fNewButton;
BButton* fDeleteButton;
BButton* fEditButton;
CategoryEditWindow* fCategoryEditWindow;
99 changes: 33 additions & 66 deletions src/PreferenceWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Copyright 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com
* All rights reserved. Distributed under the terms of the MIT license.
* Contributed by:
* Humdinger <humdingerb@gmail.com>, 2021
*/


#include "PreferenceWindow.h"

#include <Application.h>
#include <Box.h>
#include <Button.h>
#include <Catalog.h>
#include <ColorMenuItem.h>
#include <CheckBox.h>
#include <ColorMenuItem.h>
#include <LayoutBuilder.h>
#include <PopUpMenu.h>
#include <MenuField.h>
#include <StringView.h>
#include <View.h>
#include <SeparatorView.h>
#include <Window.h>

#include "App.h"
@@ -28,9 +28,10 @@
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "PreferenceWindow"

PreferenceWindow::PreferenceWindow(Preferences* preferences)
:BWindow(BRect(), B_TRANSLATE("Settings"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE| B_AUTO_UPDATE_SIZE_LIMITS)
PreferenceWindow::PreferenceWindow(BRect frame, Preferences* preferences)
:
BWindow(BRect(), B_TRANSLATE("Settings"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
fCurrentPreferences = preferences;

@@ -43,8 +44,8 @@ PreferenceWindow::PreferenceWindow(Preferences* preferences)
fDBManager = new QueryDBManager();

_InitInterface();
CenterOnScreen();

CenterIn(frame);
_SyncPreferences(fCurrentPreferences);
}

@@ -101,6 +102,7 @@ PreferenceWindow::MessageReceived(BMessage* message)
BMenuItem* item = fDefaultCatMenu->FindMarked();
fTempPreferences->fDefaultCategory = BString(item->Label());
_PreferencesModified();
break;
}

default:
@@ -121,9 +123,6 @@ PreferenceWindow::QuitRequested()
void
PreferenceWindow::_InitInterface()
{
fMainView = new BView("MainView", B_WILL_DRAW);
fMainView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

fDayOfWeekMenu = new BPopUpMenu("DayOfWeekMenu");
fDefaultCatMenu = new BPopUpMenu("DefaultCatMenu");

@@ -136,7 +135,8 @@ PreferenceWindow::_InitInterface()
fDayOfWeekMenu->AddItem(new BMenuItem(startOfWeekItems[i],
new BMessage(kStartOfWeekChangeMessage)));
fDayOfWeekMenu->ItemAt(0)->SetMarked(true);
fDayOfWeekMenuField = new BMenuField("DayOfWeekMenu", NULL, fDayOfWeekMenu);
fDayOfWeekMenuField = new BMenuField("DayOfWeekMenu", B_TRANSLATE(
"First day of the week:"), fDayOfWeekMenu);

BList* categories = fDBManager->GetAllCategories();
for (int i = 0; i < categories->CountItems(); i++) {
@@ -145,22 +145,11 @@ PreferenceWindow::_InitInterface()
new BMessage(kDefaultCategoryChangeMessage), category->GetColor()));
}
fDefaultCatMenu->ItemAt(0)->SetMarked(true);
fDefaultCatMenuField = new BMenuField("DefaultCatMenu", NULL, fDefaultCatMenu);

fWeekCategoryLabel = new BStringView("PrefCategory", "Week");
fOrgCategoryLabel = new BStringView("PrefCategory", "Organization");
BFont font;
fWeekCategoryLabel->GetFont(&font);
font.SetSize(font.Size() * 1.2);
font.SetFace(B_BOLD_FACE);
fWeekCategoryLabel->SetFont(&font, B_FONT_ALL);
fOrgCategoryLabel->SetFont(&font, B_FONT_ALL);

fStartOfWeekLabel = new BStringView("StartOfWeek", B_TRANSLATE("First day of week"));
fDefaultCatLabel = new BStringView("DefaultCat", B_TRANSLATE("Default category"));

fWeekNumberHeaderCB = new BCheckBox("WeekNumberHeader",
B_TRANSLATE("Show week number in Calendar"), new BMessage(kShowWeekChangeMessage));
fDefaultCatMenuField = new BMenuField("DefaultCatMenu", B_TRANSLATE(
"Default category:"), fDefaultCatMenu);

fWeekNumberHeaderCB = new BCheckBox("WeekNumberHeader", B_TRANSLATE(
"Show week numbers in calendar"), new BMessage(kShowWeekChangeMessage));
fWeekNumberHeaderCB->SetValue(B_CONTROL_OFF);

fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(kApplyPreferencesMessage));
@@ -169,53 +158,31 @@ PreferenceWindow::_InitInterface()
fApplyButton->SetEnabled(false);
fRevertButton->SetEnabled(false);

fWeekPreferencesBox = new BBox("Week");
fOrgPreferencesBox = new BBox("Organization");

BLayoutBuilder::Group<>(fWeekPreferencesBox, B_VERTICAL, B_USE_HALF_ITEM_SPACING)
.SetInsets(B_USE_ITEM_INSETS)
.AddStrut(B_USE_ITEM_SPACING)
.Add(fStartOfWeekLabel)
.Add(fDayOfWeekMenuField)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(fWeekNumberHeaderCB)
.End();
fWeekPreferencesBox->SetLabel(fWeekCategoryLabel);

BLayoutBuilder::Group<>(fOrgPreferencesBox, B_VERTICAL, B_USE_HALF_ITEM_SPACING)
.SetInsets(B_USE_ITEM_INSETS)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(fDefaultCatLabel)
.Add(fDefaultCatMenuField)
.End();
fOrgPreferencesBox->SetLabel(fOrgCategoryLabel);


BLayoutBuilder::Group<>(fMainView, B_VERTICAL, B_USE_DEFAULT_SPACING)
.SetInsets(B_USE_SMALL_INSETS)
.Add(fWeekPreferencesBox)
.Add(fOrgPreferencesBox)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(fRevertButton)
.AddGlue()
.Add(fApplyButton)
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
.SetInsets(B_USE_SMALL_INSETS, B_USE_SMALL_INSETS, B_USE_SMALL_INSETS, 0)
.AddMenuField(fDefaultCatMenuField, 0, 0)
.AddMenuField(fDayOfWeekMenuField, 0, 1)
.Add(fWeekNumberHeaderCB, 0, 2, 2)
.End()
.End();

BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.Add(fMainView)
.End();
.Add(new BSeparatorView(B_HORIZONTAL))
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.SetInsets(B_USE_SMALL_INSETS, 0, B_USE_SMALL_INSETS, B_USE_SMALL_INSETS)
.Add(fRevertButton)
.AddGlue()
.Add(fApplyButton)
.End()
.End();
}


void
PreferenceWindow::_SyncPreferences(Preferences* preferences)
{
if(preferences->fHeaderVisible == true) {
if (preferences->fHeaderVisible == true)
fWeekNumberHeaderCB->SetValue(B_CONTROL_ON);
} else {
else
fWeekNumberHeaderCB->SetValue(B_CONTROL_OFF);
}

BMenuItem* item = fDayOfWeekMenu->ItemAt(preferences->fStartOfWeekOffset);
item->SetMarked(true);
31 changes: 10 additions & 21 deletions src/PreferenceWindow.h
Original file line number Diff line number Diff line change
@@ -7,13 +7,10 @@

#include <Window.h>

class BBox;
class BButton;
class BCheckBox;
class BPopUpMenu;
class BMenuField;
class BStringView;
class BView;
class Preferences;
class QueryDBManager;

@@ -24,8 +21,8 @@ const uint32 kAppPreferencesChanged = 'kpcd';

class PreferenceWindow : public BWindow {
public:
PreferenceWindow(Preferences* preferences);
~PreferenceWindow();
PreferenceWindow(BRect position, Preferences* preferences);
~PreferenceWindow();

void MessageReceived(BMessage *message);
bool QuitRequested();
@@ -35,31 +32,23 @@ class PreferenceWindow : public BWindow {
void _SyncPreferences(Preferences* preferences);
void _PreferencesModified();

static const int kStartOfWeekChangeMessage = 1000;
static const int kShowWeekChangeMessage = 1001;
static const int kApplyPreferencesMessage = 1002;
static const int kRevertPreferencesMessage = 1003;
static const int kDefaultCategoryChangeMessage = 1004;
static const int kStartOfWeekChangeMessage = 1000;
static const int kShowWeekChangeMessage = 1001;
static const int kApplyPreferencesMessage = 1002;
static const int kRevertPreferencesMessage = 1003;
static const int kDefaultCategoryChangeMessage = 1004;


BView* fMainView;
BCheckBox* fWeekNumberHeaderCB;
BStringView* fWeekCategoryLabel;
BStringView* fOrgCategoryLabel;
BStringView* fStartOfWeekLabel;
BStringView* fDefaultCatLabel;
BPopUpMenu* fDayOfWeekMenu;
BPopUpMenu* fDefaultCatMenu;
BMenuField* fDayOfWeekMenuField;
BMenuField* fDefaultCatMenuField;
BBox* fWeekPreferencesBox;
BBox* fOrgPreferencesBox;
BButton* fApplyButton;
BButton* fRevertButton;

Preferences* fStartPreferences;
Preferences* fCurrentPreferences;
Preferences* fTempPreferences;
Preferences* fStartPreferences;
Preferences* fCurrentPreferences;
Preferences* fTempPreferences;

QueryDBManager* fDBManager;
};