Skip to content
Snippets Groups Projects
Commit 1bfcb87e authored by rswindell's avatar rswindell
Browse files

Added password on tray icon-restore option.

parent 9215b0b6
No related branches found
No related tags found
No related merge requests found
......@@ -1371,6 +1371,8 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender)
LoginCommand=Registry->ReadString("LoginCommand");
if(Registry->ValueExists("ConfigCommand"))
ConfigCommand=Registry->ReadString("ConfigCommand");
if(Registry->ValueExists("Password"))
Password=Registry->ReadString("Password");
if(Registry->ValueExists("MinimizeToSysTray"))
MinimizeToSysTray=Registry->ReadBool("MinimizeToSysTray");
if(Registry->ValueExists("NodeDisplayInterval"))
......@@ -1782,6 +1784,7 @@ void __fastcall TMainForm::SaveSettings(TObject* Sender)
Registry->WriteString("CtrlDirectory",CtrlDirectory);
Registry->WriteString("LoginCommand",LoginCommand);
Registry->WriteString("ConfigCommand",ConfigCommand);
Registry->WriteString("Password",Password);
Registry->WriteBool("MinimizeToSysTray",MinimizeToSysTray);
Registry->WriteInteger("NodeDisplayInterval",NodeDisplayInterval);
Registry->WriteInteger("ClientDisplayInterval",ClientDisplayInterval);
......@@ -1958,7 +1961,7 @@ void __fastcall TMainForm::ForceNetworkCalloutMenuItemClick(
for(i=0;i<cfg.total_qhubs;i++)
CodeInputForm->ComboBox->Items->Add(
AnsiString(cfg.qhub[i]->id).UpperCase());
CodeInputForm->ComboBox->ItemIndex=0;
CodeInputForm->ComboBox->ItemIndex=0;
if(CodeInputForm->ShowModal()==mrOk
&& CodeInputForm->ComboBox->Text.Length()) {
for(i=0;i<cfg.total_qhubs;i++) {
......@@ -2215,6 +2218,13 @@ void __fastcall TMainForm::WebPageMenuItemClick(TObject *Sender)
void __fastcall TMainForm::FormMinimize(TObject *Sender)
{
if(MinimizeToSysTray) {
if(Password.Length()) {
TrayIcon->RestoreOn=imNone;
TrayIcon->PopupMenuOn=imNone;
} else {
TrayIcon->RestoreOn=imDoubleClick;
TrayIcon->PopupMenuOn=imRightClickUp;
}
TrayIcon->Visible=true;
TrayIcon->Minimize();
}
......@@ -2236,10 +2246,12 @@ void __fastcall TMainForm::PropertiesExecute(TObject *Sender)
PropertiesDlg->ClientIntUpDown->Position=ClientDisplayInterval;
PropertiesDlg->TrayIconCheckBox->Checked=MinimizeToSysTray;
PropertiesDlg->UndockableCheckBox->Checked=UndockableForms;
PropertiesDlg->PasswordEdit->Text=Password;
if(PropertiesDlg->ShowModal()==mrOk) {
LoginCommand=PropertiesDlg->LoginCmdEdit->Text;
ConfigCommand=PropertiesDlg->ConfigCmdEdit->Text;
CtrlDirectory=PropertiesDlg->CtrlDirEdit->Text;
Password=PropertiesDlg->PasswordEdit->Text;
NodeDisplayInterval=PropertiesDlg->NodeIntUpDown->Position;
ClientDisplayInterval=PropertiesDlg->ClientIntUpDown->Position;
MinimizeToSysTray=PropertiesDlg->TrayIconCheckBox->Checked;
......@@ -2334,4 +2346,24 @@ void __fastcall TMainForm::UserTruncateMenuItemClick(TObject *Sender)
Application->MessageBox(str,"Users Truncated",MB_OK);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::TrayIconClick(TObject *Sender)
{
static inside;
if(inside)
return;
inside=true;
if(Password.Length()) {
Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
CodeInputForm->Label->Caption="Password";
CodeInputForm->Edit->Visible=true;
CodeInputForm->Edit->PasswordChar='*';
if(CodeInputForm->ShowModal()==mrOk
&& CodeInputForm->Edit->Text.AnsiCompareIC(Password)==0)
TrayIcon->Restore();
delete CodeInputForm;
}
inside=false;
}
//---------------------------------------------------------------------------
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -56,6 +56,7 @@
#include <Graphics.hpp>
#include <vcl\Registry.hpp> /* TRegistry */
#include "trayicon.h"
#include "Trayicon.h"
//---------------------------------------------------------------------------
#define APP_TITLE "Synchronet Control Panel"
#define REG_KEY "\\Software\\Swindell\\"APP_TITLE"\\"
......@@ -307,6 +308,7 @@ __published: // IDE-managed Components
void __fastcall ServicesStopExecute(TObject *Sender);
void __fastcall ServicesConfigureExecute(TObject *Sender);
void __fastcall UserTruncateMenuItemClick(TObject *Sender);
void __fastcall TrayIconClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TMainForm(TComponent* Owner);
......@@ -321,6 +323,7 @@ public: // User declarations
AnsiString CtrlDirectory;
AnsiString LoginCommand;
AnsiString ConfigCommand;
AnsiString Password;
bool MinimizeToSysTray;
bool UndockableForms;
scfg_t cfg;
......
......@@ -6,9 +6,22 @@
//---------------------------------------------------------------------
#pragma resource "*.dfm"
TPropertiesDlg *PropertiesDlg;
//---------------------------------------------------------------------
//---------------------------------------------------------------------
__fastcall TPropertiesDlg::TPropertiesDlg(TComponent* AOwner)
: TForm(AOwner)
{
}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
void __fastcall TPropertiesDlg::FormShow(TObject *Sender)
{
TrayIconCheckBoxClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TPropertiesDlg::TrayIconCheckBoxClick(TObject *Sender)
{
PasswordEdit->Enabled=TrayIconCheckBox->Checked;
PasswordLabel->Enabled=PasswordEdit->Enabled;
}
//---------------------------------------------------------------------------
......@@ -3,20 +3,24 @@ object PropertiesDlg: TPropertiesDlg
Top = 224
BorderStyle = bsDialog
Caption = 'Control Panel Properties'
ClientHeight = 261
ClientHeight = 294
ClientWidth = 433
Color = clBtnFace
ParentFont = True
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnShow = FormShow
DesignSize = (
433
294)
PixelsPerInch = 120
TextHeight = 16
object Bevel1: TBevel
Left = 10
Top = 10
Width = 306
Height = 237
Height = 270
Anchors = [akLeft, akTop, akRight, akBottom]
Shape = bsFrame
end
......@@ -60,6 +64,14 @@ object PropertiesDlg: TPropertiesDlg
AutoSize = False
Caption = 'Client Display Interval (in seconds)'
end
object PasswordLabel: TLabel
Left = 24
Top = 248
Width = 110
Height = 24
AutoSize = False
Caption = 'Password'
end
object OKBtn: TButton
Left = 329
Top = 10
......@@ -114,7 +126,7 @@ object PropertiesDlg: TPropertiesDlg
end
object TrayIconCheckBox: TCheckBox
Left = 24
Top = 182
Top = 214
Width = 281
Height = 24
Hint = 'Create tray icon when minimized'
......@@ -122,6 +134,7 @@ object PropertiesDlg: TPropertiesDlg
ParentShowHint = False
ShowHint = True
TabOrder = 4
OnClick = TrayIconCheckBoxClick
end
object NodeIntEdit: TEdit
Left = 256
......@@ -171,7 +184,7 @@ object PropertiesDlg: TPropertiesDlg
end
object UndockableCheckBox: TCheckBox
Left = 24
Top = 214
Top = 182
Width = 281
Height = 24
Hint = 'Allow child windows to be "un-docked" from main window'
......@@ -180,4 +193,15 @@ object PropertiesDlg: TPropertiesDlg
ShowHint = True
TabOrder = 10
end
object PasswordEdit: TEdit
Left = 136
Top = 248
Width = 169
Height = 24
Hint = 'Required password for restoring from system tray icon'
ParentShowHint = False
PasswordChar = '*'
ShowHint = True
TabOrder = 11
end
end
......@@ -34,6 +34,10 @@ __published:
TEdit *ClientIntEdit;
TUpDown *ClientIntUpDown;
TCheckBox *UndockableCheckBox;
TLabel *PasswordLabel;
TEdit *PasswordEdit;
void __fastcall FormShow(TObject *Sender);
void __fastcall TrayIconCheckBoxClick(TObject *Sender);
private:
public:
virtual __fastcall TPropertiesDlg(TComponent* AOwner);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment