Changeset 70


Ignore:
Timestamp:
Aug 1, 2016, 1:10:13 PM (8 years ago)
Author:
chronos
Message:
  • Added: Allow to configure application to start automatically on user logon and start minimized to tray.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r69 r70  
    136136  public
    137137    AcronymDb: TAcronymDb;
     138    StartOnLogon: Boolean;
     139    StartMinimizedToTray: Boolean;
    138140    function CompareStrings(Strings1, Strings2: TStrings): Boolean;
    139141    property AlwaysOnTop: Boolean read FAlwaysOnTop write SetAlwaysOnTop;
     
    165167  DefaultFileName = 'Acronyms' + ProjectExt;
    166168  DefaultRegKey = '\Software\Acronym Decoder';
     169  RegistryRunKey = '\Software\Microsoft\Windows\CurrentVersion\Run';
     170  ExampleFile = 'Example acronyms.adp';
    167171
    168172{ TFormMain }
     
    305309begin
    306310  FormSettings.Load;
    307   if FormSettings.ShowModal = mrOk then
     311  if FormSettings.ShowModal = mrOk then begin
    308312    FormSettings.Save;
     313    SaveConfig;
     314  end;
    309315end;
    310316
     
    456462    LoadConfig;
    457463
     464    if StartMinimizedToTray then Visible := False;
     465
    458466    if ParamCount > 0 then begin
    459467      // Open file specified as command line parameter
     
    466474    end else begin
    467475      // Open default database with examples if no item is in recent openned history
    468       ProjectOpen(ExtractFileDir(Application.ExeName) + DirectorySeparator + 'Example Acronyms.adp');
     476      ProjectOpen(ExtractFileDir(Application.ExeName) + DirectorySeparator + ExampleFile);
    469477    end;
    470478    UpdateAcronymsList;
     
    590598      else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
    591599    AlwaysOnTop := ReadBoolWithDefault('AlwaysOnTop', False);
     600    StartMinimizedToTray := ReadBoolWithDefault('StartMinimizedToTray', False);
    592601    CheckBoxExactMath.Checked := ReadBoolWithDefault('ExactMatch', False);
    593602    MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
     603  finally
     604    Free;
     605  end;
     606
     607  with TRegistryEx.Create do
     608  try
     609    RootKey := HKEY_CURRENT_USER;
     610    OpenKey(RegistryRunKey, True);
     611    StartOnLogon := ValueExists('Acronym Decoder');
    594612  finally
    595613    Free;
     
    610628      else DeleteValue('LanguageCode');
    611629    WriteBool('AlwaysOnTop', AlwaysOnTop);
     630    WriteBool('StartMinimizedToTray', StartMinimizedToTray);
    612631    WriteBool('ExactMatch', CheckBoxExactMath.Checked);
    613632    WriteBool('ToolBarVisible', MenuItemToolbar.Checked);
     
    615634    Free;
    616635  end;
     636
     637  with TRegistryEx.Create do
     638  try
     639    RootKey := HKEY_CURRENT_USER;
     640    OpenKey(RegistryRunKey, True);
     641    if StartOnLogon then WriteString('Acronym Decoder', Application.ExeName)
     642      else DeleteValue('Acronym Decoder');
     643  finally
     644    Free;
     645  end;
    617646end;
    618647
  • trunk/Forms/UFormSettings.lfm

    r69 r70  
    5656    TabOrder = 1
    5757  end
     58  object CheckBoxStartOnLogon: TCheckBox
     59    Left = 16
     60    Height = 24
     61    Top = 96
     62    Width = 150
     63    Caption = 'Start on user logon'
     64    TabOrder = 4
     65  end
     66  object CheckBoxStartMinimizedToTray: TCheckBox
     67    Left = 16
     68    Height = 24
     69    Top = 128
     70    Width = 176
     71    Caption = 'Start minimized to tray'
     72    TabOrder = 5
     73  end
    5874end
  • trunk/Forms/UFormSettings.lrt

    r16 r70  
    44TFORMSETTINGS.BUTTONCANCEL.CAPTION=Cancel
    55TFORMSETTINGS.CHECKBOXALWAYSONTOP.CAPTION=Always on top
     6TFORMSETTINGS.CHECKBOXSTARTONLOGON.CAPTION=Start on user logon
     7TFORMSETTINGS.CHECKBOXSTARTMINIMIZEDTOTRAY.CAPTION=Start minimized to tray
  • trunk/Forms/UFormSettings.pas

    r16 r70  
    1616    ButtonOk: TButton;
    1717    ButtonCancel: TButton;
     18    CheckBoxStartMinimizedToTray: TCheckBox;
     19    CheckBoxStartOnLogon: TCheckBox;
    1820    CheckBoxAlwaysOnTop: TCheckBox;
    1921    ComboBoxLanguage: TComboBox;
     
    5658begin
    5759  CheckBoxAlwaysOnTop.Checked := FormMain.AlwaysOnTop;
     60  CheckBoxStartOnLogon.Checked := FormMain.StartOnLogon;
     61  CheckBoxStartMinimizedToTray.Checked := FormMain.StartMinimizedToTray;
    5862end;
    5963
     
    6165begin
    6266  FormMain.AlwaysOnTop := CheckBoxAlwaysOnTop.Checked;
     67  FormMain.StartOnLogon := CheckBoxStartOnLogon.Checked;
     68  FormMain.StartMinimizedToTray := CheckBoxStartMinimizedToTray.Checked;
    6369end;
    6470
  • trunk/Languages/AcronymDecoder.cs.po

    r65 r70  
    612612msgstr "Okno vždy navrchu"
    613613
     614#: tformsettings.checkboxstartminimizedtotray.caption
     615msgid "Start minimized to tray"
     616msgstr "Startovat schovaný v oznamovací oblasti"
     617
     618#: tformsettings.checkboxstartonlogon.caption
     619msgid "Start on user logon"
     620msgstr "Startovat při přihlášení uživatele"
     621
    614622#: tformsettings.label1.caption
    615623msgid "Language:"
     
    816824msgid "Process import sources"
    817825msgstr "Zpracovat zdroje importu"
    818 
  • trunk/Languages/AcronymDecoder.po

    r57 r70  
    602602msgstr ""
    603603
     604#: tformsettings.checkboxstartminimizedtotray.caption
     605msgid "Start minimized to tray"
     606msgstr ""
     607
     608#: tformsettings.checkboxstartonlogon.caption
     609msgid "Start on user logon"
     610msgstr ""
     611
    604612#: tformsettings.label1.caption
    605613msgid "Language:"
Note: See TracChangeset for help on using the changeset viewer.