Skip to content

Commit

Permalink
Allow only one open Reconcile window
Browse files Browse the repository at this point in the history
  • Loading branch information
humdingerb committed Jul 23, 2024
1 parent 04e01e0 commit 282d39b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "IconMenuItem.h"
#include "PrefWindow.h"
#include "Preferences.h"
#include "ReconcileWindow.h"
#include "RegisterView.h"
#include "ReportWindow.h"
#include "ScheduleAddWindow.h"
Expand All @@ -47,7 +46,8 @@


MainWindow::MainWindow(BRect frame)
: BWindow(frame, "", B_DOCUMENT_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS)
: BWindow(frame, "", B_DOCUMENT_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
fReconcileWindow(NULL)
{
BString temp;
SetTitle(B_TRANSLATE_SYSTEM_NAME("CapitalBe"));
Expand Down Expand Up @@ -548,19 +548,25 @@ MainWindow::MessageReceived(BMessage* msg)
case M_SHOW_RECONCILE_WINDOW:
{
if (!acc) {
if (gDatabase.CountAccounts() < 1)
if (gDatabase.CountAccounts() < 1) {
ShowAlert(B_TRANSLATE("Oops!"),
B_TRANSLATE(
"You need to have an account created in order to reconcile it."));
else
} else {
ShowAlert(B_TRANSLATE("Oops!"),
B_TRANSLATE("You need to select an account in order to reconcile it."));
}
break;
}

ReconcileWindow* recwin = new ReconcileWindow(BRect(100, 100, 700, 425), acc);
recwin->CenterIn(Frame());
recwin->Show();
if (fReconcileWindow == NULL) {
fReconcileWindow = new ReconcileWindow(BRect(100, 100, 700, 425), acc);
fReconcileWindow->CenterIn(Frame());
fReconcileWindow->Show();
} else if (fReconcileWindow->IsHidden())
fReconcileWindow->Show();
else
fReconcileWindow->Activate();
break;
}
case M_SHOW_SCHEDULED_WINDOW:
Expand Down
4 changes: 3 additions & 1 deletion src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <MessageRunner.h>
#include <String.h>
#include <Window.h>
#include "Database.h"

#include "Notifier.h"
#include "ReconcileWindow.h"

class RegisterView;

Expand Down Expand Up @@ -72,6 +73,7 @@ class MainWindow : public BWindow, public Observer {
void CreateTransfer(BMessage* msg);

RegisterView* fRegisterView;
ReconcileWindow* fReconcileWindow;
BFilePanel *fImportPanel, *fExportPanel;

BString fLastFile;
Expand Down

0 comments on commit 282d39b

Please sign in to comment.