Skip to content

Commit

Permalink
Bugfixes, icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Oleynikov committed Dec 6, 2019
1 parent 744f3ff commit 4621495
Show file tree
Hide file tree
Showing 33 changed files with 2,024 additions and 88 deletions.
2 changes: 1 addition & 1 deletion NightscoutWatcher.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="2"/>
<MinorVersionNr Value="9"/>
<BuildNr Value="118"/>
<BuildNr Value="120"/>
<StringTable CompanyName="Sergey Oleynikov" LegalCopyright="Sergey Oleynikov" ProductName="Nightscout Watcher"/>
</VersionInfo>
<BuildModes Count="3">
Expand Down
1,914 changes: 1,908 additions & 6 deletions forms/ufMain.lfm

Large diffs are not rendered by default.

176 changes: 105 additions & 71 deletions forms/ufMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TfMain = class(TForm)
actSnoozeAlarms30mins: TAction;
actSnoozeAlarms10mins: TAction;
actStayOnTop: TAction;
il: TImageList;
miSetTimeZoneCorrection: TMenuItem;
miEnableAudioAlarms: TMenuItem;
miEnableStaleDataAlarms: TMenuItem;
Expand Down Expand Up @@ -136,8 +137,8 @@ TfMain = class(TForm)
miDrawGlucoseSlope: TMenuItem;
actDrawGlucoseExtremePoints: TAction;
miDrawGlucoseExtremePoints: TMenuItem;
actSetHoursToRecive: TAction;
miSetHoursToRecive: TMenuItem;
actSetHoursToReceive: TAction;
miSetHoursToReceive: TMenuItem;
actShowSettings: TAction;
miShowSettings: TMenuItem;
actDrawAlertLines: TAction;
Expand Down Expand Up @@ -167,6 +168,7 @@ TfMain = class(TForm)
procedure CheckStaleDataAlarms;
procedure DoOpacityPercentClick(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure pmClose(Sender: TObject);
procedure pmPopup(Sender: TObject);
procedure tmrTimer(Sender: TObject);
procedure tmrProgressBarTimer(Sender: TObject);
Expand All @@ -183,12 +185,13 @@ TfMain = class(TForm)
procedure actSetUnitOfMeasureMmolLExecute(Sender: TObject);
procedure FormMouseEnter(Sender: TObject);
procedure FormMouseLeave(Sender: TObject);
procedure actSetHoursToReciveExecute(Sender: TObject);
procedure actSetHoursToReceiveExecute(Sender: TObject);
procedure DoShowSettingsExecute(Sender: TObject);
procedure actFullScreenExecute(Sender: TObject);
procedure TrayIconClick(Sender: TObject);
procedure DrawTrayIcon();
private
IsMenuPopuped: Boolean;
StaleAlarmBlinkTrigger: Boolean;
NeedStaleDataBlink: Boolean;
NeedGlucoseLevelAlarmBlink: Boolean;
Expand Down Expand Up @@ -537,43 +540,49 @@ procedure TfMain.actSetCheckIntervalExecute(Sender: TObject);
CheckIntervalStr, Msg: string;
begin
al.State := asSuspended;
CheckIntervalStr := IntToStr(Settings.CheckInterval);
if TfTimerDialog.Execute(Self, 'Check interval', cMsg, CheckIntervalStr, [pbOK, pbCancel]) = mrOK then
if not SetCheckIntervalByString(CheckIntervalStr) then
begin
Msg := 'You must type in time interval in seconds (int value)';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetCheckIntervalExecute(Sender);
end;
al.State := asNormal;
try
CheckIntervalStr := IntToStr(Settings.CheckInterval);
if TfTimerDialog.Execute(Self, 'Check interval', cMsg, CheckIntervalStr, [pbOK, pbCancel]) = mrOK then
if not SetCheckIntervalByString(CheckIntervalStr) then
begin
Msg := 'You must type in time interval in seconds (int value)';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetCheckIntervalExecute(Sender);
end;
finally
al.State := asNormal;
end;
end;

procedure TfMain.actSetHoursToReciveExecute(Sender: TObject);
procedure TfMain.actSetHoursToReceiveExecute(Sender: TObject);
var
Count, Msg: string;
CountEntered: Integer;
CanSetCount: Boolean;
begin
al.State := asSuspended;
Count := IntToStr(Settings.HoursToRecive);
Msg := 'Type in the hours to recieve data from Nightscout site';
if InputQuery('Hours to receive', Msg, Count) then
begin
CanSetCount := TryStrToInt(Count, CountEntered);
CanSetCount := CanSetCount and (CountEntered >= cHoursToReceiveMin) and (CountEntered <= cHoursToReceiveMax);
if CanSetCount then
begin
Settings.HoursToRecive := CountEntered;
tmrTimer(tmr);
end
else
try
Count := IntToStr(Settings.HoursToReceive);
Msg := 'Type in the hours to recieve data from Nightscout site';
if InputQuery('Hours to receive', Msg, Count) then
begin
Msg := Format('You must type in an integer value (between %d and %d).' + #13#10 + 'Try again?', [cHoursToReceiveMin, cHoursToReceiveMax]);
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetHoursToReciveExecute(Sender);
CanSetCount := TryStrToInt(Count, CountEntered);
CanSetCount := CanSetCount and (CountEntered >= cHoursToReceiveMin) and (CountEntered <= cHoursToReceiveMax);
if CanSetCount then
begin
Settings.HoursToReceive := CountEntered;
tmrTimer(tmr);
end
else
begin
Msg := Format('You must type in an integer value (between %d and %d).' + LineEnding + 'Try again?', [cHoursToReceiveMin, cHoursToReceiveMax]);
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetHoursToReceiveExecute(Sender);
end;
end;
finally
al.State := asNormal;
end;
al.State := asNormal;
end;

procedure TfMain.actSetNightscoutSiteExecute(Sender: TObject);
Expand All @@ -584,34 +593,37 @@ procedure TfMain.actSetNightscoutSiteExecute(Sender: TObject);
TimerIntervalSecs: Integer;
begin
al.State := asSuspended;
WasConnected := Connected;
Connected := False;
Url := Settings.NightscoutUrl;
TimerIntervalSecs := -1;
if WasConnected then
TimerIntervalSecs := 20;
Msg := 'Type in URL of Nightscout site.' + #13#10 +
'If there is an error appeare try to change protocol to HTTP instead of HTTPS in URL.';
DialogResult := TfTimerDialog.Execute(Self, 'Nighscout site', Msg, Url, [pbOK, pbCancel], TimerIntervalSecs);
if DialogResult = mrOK then
begin
if (Url <> '') and (SetNightscoutUrl(Url)) then
tmrTimer(tmr)
else
try
WasConnected := Connected;
Connected := False;
Url := Settings.NightscoutUrl;
TimerIntervalSecs := -1;
if WasConnected then
TimerIntervalSecs := 20;
Msg := 'Type in URL of Nightscout site.' + LineEnding +
'If an error occurs try to change protocol to HTTP instead of HTTPS in URL.';
DialogResult := TfTimerDialog.Execute(Self, 'Nighscout site', Msg, Url, [pbOK, pbCancel], TimerIntervalSecs);
if DialogResult = mrOK then
begin
actSetNightscoutSiteExecute(Sender);
if (Url <> '') and (SetNightscoutUrl(Url)) then
tmrTimer(tmr)
else
begin
actSetNightscoutSiteExecute(Sender);
end;
end
else if (DialogResult = mrCancel) and not WasConnected then
begin
Msg := 'To obtain CGM data you have to type in full URL of your Nightscout site.' + LineEnding +
'To support HTTPS you have to download libeay32.dll and ssleay32.dll and put it to the project directory.' + LineEnding +
'Otherwise only HTTP protocol is supported. Try to change protocol to HTTP instead of HTTPS in URL.' + LineEnding + LineEnding +
'Do you want to try again?';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetNightscoutSiteExecute(Sender);
end;
end
else if (DialogResult = mrCancel) and not WasConnected then
begin
Msg := 'To obtain CGM data you have to type in full URL of your Nightscout site.' + #13#10 +
'To support HTTPS you have to download libeay32.dll and ssleay32.dll and put it to the project directory.' + #13#10 +
'Otherwise only HTTP protocol is supported. Try to change protocol to HTTP instead of HTTPS in URL.' + #13#10#13#10 +
'Do you want to try again?';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetNightscoutSiteExecute(Sender);
finally
al.State := asNormal;
end;
al.State := asNormal;
end;

procedure TfMain.actShowCheckNewDataProgressBarExecute(Sender: TObject);
Expand Down Expand Up @@ -707,6 +719,7 @@ procedure TfMain.ShowIconInTaskbar(AVisible: Boolean);

procedure TfMain.FormCreate(Sender: TObject);
begin
IsMenuPopuped := True;
Loaded := False;
Connected := False;
Settings := TSettings.Create();
Expand Down Expand Up @@ -768,7 +781,8 @@ procedure TfMain.FormKeyDown(Sender: TObject; var Key: Word;
VK_UP: Top := Top - cMoveWindowDelta;
VK_DOWN: Top := Top + cMoveWindowDelta;
VK_APPS: pm.PopUp;
VK_Z:
VK_H: actSetHoursToReceive.Execute;
VK_E: actDrawHoursToReceiveData.Execute;
end;
end
else if Shift = [ssShift] then
Expand Down Expand Up @@ -879,11 +893,24 @@ procedure TfMain.FormResize(Sender: TObject);
LoadWallpaper(Settings.WallpaperFileName);
end;

procedure TfMain.pmClose(Sender: TObject);
begin
IsMenuPopuped := False;
end;

procedure TfMain.pmPopup(Sender: TObject);
var
i: Integer;
Opacity: Integer;
begin
IsMenuPopuped := True;

// Update hours to receive item
miSetHoursToReceive.Caption := Format('Set hours to receive data (%d h)', [Settings.HoursToReceive] );

// Check interval item
miSetCheckInterval.Caption := Format('Set time interval to check new data (%d secs)', [Settings.CheckInterval]);

// Update snooze menu items
miAlarms.Caption := 'Alarms/Snooze';
if not Settings.IsSnoozeAlarmsEndTimePassed() then
Expand Down Expand Up @@ -951,7 +978,7 @@ procedure TfMain.actShowIconOnTaskbarExecute(Sender: TObject);
Msg: String;
begin
ShowIconInTaskbar(TAction(Sender).Checked);
Msg := 'To apply setting you should restart application.' + #13#10 + 'Restart now?';
Msg := 'To apply setting you should restart application.' + LineEnding + 'Restart now?';
if MessageDlg(Msg, mtConfirmation, mbYesNo, -1) = mrYes then
Restart();
end;
Expand All @@ -964,6 +991,7 @@ procedure TfMain.alUpdate(AAction: TBasicAction; var Handled: Boolean);

procedure TfMain.ShowIconInTray(AVisible: Boolean);
begin
actShowIconInTray.Checked := AVisible;
Settings.ShowIconInTray := AVisible;
TrayIcon.Visible := AVisible;
end;
Expand Down Expand Up @@ -995,17 +1023,20 @@ procedure TfMain.actSetTimeZoneCorrectionExecute(Sender: TObject);
TimeZoneCorrectionStr, Msg: string;
begin
al.State := asSuspended;
TimeZoneCorrectionStr := IntToStr(Settings.TimeZoneCorrection);
if TfTimerDialog.Execute(Self, 'Time zone correction', cMsg, TimeZoneCorrectionStr, [pbOK, pbCancel]) = mrOK then
begin
if not TryStrToInt(TimeZoneCorrectionStr, Settings.TimeZoneCorrection) then
try
TimeZoneCorrectionStr := IntToStr(Settings.TimeZoneCorrection);
if TfTimerDialog.Execute(Self, 'Time zone correction', cMsg, TimeZoneCorrectionStr, [pbOK, pbCancel]) = mrOK then
begin
Msg := 'You must type in time zone correction in hours (int value)';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetTimeZoneCorrectionExecute(Sender);
if not TryStrToInt(TimeZoneCorrectionStr, Settings.TimeZoneCorrection) then
begin
Msg := 'You must type in time zone correction in hours (int value)';
if MessageDlg(Msg, mtWarning, [mbYes, mbCancel], -1) = mrYes then
actSetTimeZoneCorrectionExecute(Sender);
end;
end;
finally
al.State := asNormal;
end;
al.State := asNormal;
end;

procedure TfMain.FormMouseEnter(Sender: TObject);
Expand Down Expand Up @@ -1090,27 +1121,30 @@ procedure TfMain.ShowTrayIconBaloonHint;
BaloonHint: string;
LastEntry: TNightscoutEntry;
begin
if not Settings.IsSnoozeAlarmsEndTimePassed() then
if IsMenuPopuped or not Settings.IsSnoozeAlarmsEndTimePassed() then
Exit;

BaloonHint := '';
LastEntry := Entries.Last;
TrayIcon.BalloonTitle := 'Alarm!';
if Settings.IsUrgentGlucoseLevelAlarmExists(LastEntry) then
begin
BaloonHint := BaloonHint + 'Urgent dangerous glucose level is reached!' + #13#10;
BaloonHint := BaloonHint + 'Urgent dangerous glucose level is reached!' + LineEnding;
TrayIcon.BalloonTitle := 'ALARM!!!';
end
else if Settings.IsGlucoseLevelAlarmExists(LastEntry) then
BaloonHint := BaloonHint + 'Dangerous glucose level is reached!' + #13#10;
BaloonHint := BaloonHint + 'Dangerous glucose level is reached!' + LineEnding;

if Settings.IsUrgentStaleDataAlarmExists(LastEntry) then
begin
BaloonHint := BaloonHint + 'Glucose data is very stale!' + #13#10;
BaloonHint := BaloonHint + 'Glucose data is very stale!' + LineEnding;
TrayIcon.BalloonTitle := 'ALARM!!!';
end
else if Settings.IsStaleDataAlarmExists(LastEntry) then
BaloonHint := BaloonHint + 'Glucose data is stale!' + #13#10;
BaloonHint := BaloonHint + 'Glucose data is stale!' + LineEnding;

if BaloonHint = '' then
Exit;

TrayIcon.BalloonHint := BaloonHint;
TrayIcon.BalloonFlags := bfWarning;
Expand Down Expand Up @@ -1618,7 +1652,7 @@ procedure TfMain.DoDrawStages(DrawStages: TDrawStages);
begin
cnv.Brush.Color := Color;
SetBkMode(cnv.Handle, TRANSPARENT);
AText := 'Hours: ' + IntToStr(Settings.HoursToRecive);
AText := 'Hours: ' + IntToStr(Settings.HoursToReceive);
SetMaximumDrawStageSizeToCanvas(dsHoursToReceiveData, AText);
TextSize := cnv.TextExtent(AText);
DrawStrokedText(AText, cSmallMargin, 0, cHoursToReceiveDataColor);
Expand Down Expand Up @@ -1877,7 +1911,7 @@ function TfMain.GetHintText(): string;
Lst := TStringList.Create();
try
Lst.Add(Format('Count of entries with glucose data: %d', [Entries.Count]));
Lst.Add(Format('Hours to recieve data: %d', [Settings.HoursToRecive]));
Lst.Add(Format('Hours to recieve data: %d', [Settings.HoursToReceive]));
Lst.Add(Format('Glucose average: %s', [Entries.GetAvgGlucoseStr(Settings.IsMmolL)]));
if Assigned(Entries.First) then
begin
Expand Down
4 changes: 2 additions & 2 deletions forms/ufSettings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ procedure TfSettings.AssignSettingsToComponents();
sbScale.Max := Length(cDrawStageSizes[1]);
sbScale.Position := NewSettings.ScaleIndex;
seCheckInterval.Value := NewSettings.CheckInterval;
seHoursToReceive.Value := NewSettings.HoursToRecive;
seHoursToReceive.Value := NewSettings.HoursToReceive;
seHighGlucoseAlarm.Value := NewSettings.HighGlucoseAlarm;
seLowGlucoseAlarm.Value := NewSettings.LowGlucoseAlarm;
seStaleDataAlarm.Value := NewSettings.StaleDataAlarm;
Expand All @@ -346,7 +346,7 @@ procedure TfSettings.AssignSettingsToComponents();
procedure TfSettings.AssignComponentsToSettings;
begin
NewSettings.CheckInterval := seCheckInterval.Value;
NewSettings.HoursToRecive := seHoursToReceive.Value;
NewSettings.HoursToReceive := seHoursToReceive.Value;

NewSettings.EnableAudioAlarms := cbEnableAudioAlarms.Checked;
NewSettings.EnableGlucoseLevelAlarms := cbEnableGlucoseLevelAlarms.Checked;
Expand Down
Binary file added resources/Icons/icons8-audio-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-diabetes-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-exit-sign-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-fire-alarm-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-fit-to-width-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-graph-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-help-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-low-volume-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-picture-50-2_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-picture-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-pin-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-popup-window-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-reboot-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-refresh-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-scatter-plot-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-settings-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-sleep-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-sound-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-time-machine-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-timezone-+3-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-website-50-2_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-website-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-zoom-in-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Icons/icons8-zzz-50_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/nightscout.png
Binary file modified screenshots/Main.Menu.jpg
2 changes: 1 addition & 1 deletion units/uNightscout.pas
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function TNightscoutEntryList.LoadFromFile(const FileName: string): Boolean;
FreeAndNil(Entry);
end;
RemoveDuplicatesWithTheSameDate;
//LimitEntries(Settings.HoursToRecive);
//LimitEntries(Settings.HoursToReceive);
CloseFile(DataFile);
Result := True;
except
Expand Down
Loading

0 comments on commit 4621495

Please sign in to comment.