LHelp: In View menu, fix close with n tabs. Issue #28016, patch from Alexey Torgashin.

git-svn-id: trunk@48926 -
This commit is contained in:
juha 2015-05-03 20:53:01 +00:00
parent 21b3896421
commit 28708cc964
4 changed files with 72 additions and 8 deletions

View File

@ -53,6 +53,8 @@ type
fPopUp: TPopUpMenu;
fStatusBar: TStatusBar;
fContext: THelpContext;
function GetShowStatusbar: Boolean;
procedure SetShowStatusbar(AValue: Boolean);
protected
fIsUsingHistory: Boolean;
fChms: TChmFileList;
@ -114,6 +116,7 @@ type
procedure GoForward; override;
property TabsControl: TPageControl read fTabsControl;
property Splitter: TSplitter read fSplitter;
property ShowStatusbar: Boolean read GetShowStatusbar write SetShowStatusbar;
class function GetProperContentProvider(const {%H-}AURL: String): TBaseContentProviderClass; override;
constructor Create(AParent: TWinControl; AImageList: TImageList); override;
@ -242,6 +245,16 @@ end;
{ TChmContentProvider }
function TChmContentProvider.GetShowStatusbar: Boolean;
begin
Result := fStatusbar.Visible;
end;
procedure TChmContentProvider.SetShowStatusbar(AValue: Boolean);
begin
fStatusbar.Visible := AValue;
end;
function TChmContentProvider.MakeURI ( AUrl: String; AChm: TChmReader ) : String;
var
ChmIndex: Integer;

View File

@ -103,7 +103,6 @@
<ComponentName Value="HelpForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="lhelpcore"/>
</Unit4>
<Unit5>
<Filename Value="lnethttpdataprovider.pas"/>
@ -117,17 +116,14 @@
<Unit7>
<Filename Value="chmcontentprovider.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="chmcontentprovider"/>
</Unit7>
<Unit8>
<Filename Value="httpcontentprovider.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="HTTPContentProvider"/>
</Unit8>
<Unit9>
<Filename Value="lhelpstrconsts.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="lhelpstrconsts"/>
</Unit9>
</Units>
</ProjectOptions>

View File

@ -123,7 +123,7 @@ object HelpForm: THelpForm
OnClick = FileMenuOpenItemClick
end
object FileMenuOpenRecentItem: TMenuItem
Caption = 'Open Recent'
Caption = 'Open recent'
Enabled = False
end
object FileMenuOpenURLItem: TMenuItem
@ -131,7 +131,7 @@ object HelpForm: THelpForm
OnClick = FileMenuOpenURLItemClick
end
object FileMenuCloseItem: TMenuItem
Caption = '&Close All'
Caption = '&Close'
ShortCut = 16471
OnClick = FileMenuCloseItemClick
end
@ -146,6 +146,7 @@ object HelpForm: THelpForm
end
object ViewMenuItem: TMenuItem
Caption = '&View'
OnClick = ViewMenuItemClick
object ViewMenuContents: TMenuItem
Caption = 'Show contents'
Checked = True
@ -153,6 +154,14 @@ object HelpForm: THelpForm
ShowAlwaysCheckable = True
OnClick = ViewMenuContentsClick
end
object ViewShowStatus: TMenuItem
Caption = 'Open tabs with statusbar'
OnClick = ViewShowStatusClick
end
object ViewShowSepTabs: TMenuItem
Caption = 'Open separate tabs for files'
OnClick = ViewShowSepTabsClick
end
end
object HelpMenuItem: TMenuItem
Caption = '&Help'

View File

@ -17,6 +17,11 @@
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
}
{
Icons from Tango theme:
http://tango.freedesktop.org/Tango_Icon_Library
}
unit lhelpcore;
{$IFDEF LNET_VISUAL}
@ -72,6 +77,8 @@ type
HelpMenuItem: TMenuItem;
AboutItem: TMenuItem;
FileMenuOpenRecentItem: TMenuItem;
ViewShowStatus: TMenuItem;
ViewShowSepTabs: TMenuItem;
PageControl: TPageControl;
OpenDialog1: TOpenDialog;
ToolBar1: TToolBar;
@ -97,6 +104,9 @@ type
procedure PageControlChange(Sender: TObject);
procedure PageControlEnter(Sender: TObject);
procedure ViewMenuContentsClick(Sender: TObject);
procedure ViewMenuItemClick(Sender: TObject);
procedure ViewShowSepTabsClick(Sender: TObject);
procedure ViewShowStatusClick(Sender: TObject);
private
{ private declarations }
// SimpleIPC server name (including unique part as per help protocol)
@ -110,6 +120,8 @@ type
fInputIPCTimer: TTimer;
fContext: LongInt; // used once when we are started on the command line with --context
fConfig: TXMLConfig;
fShowSepTabs: Boolean;
fShowStatus: Boolean;
fHasShowed: Boolean;
fHide: boolean; //If yes, start with content hidden. Otherwise start normally
fUpdateCount: Integer;
@ -311,9 +323,14 @@ end;
procedure THelpForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
//close all tabs to avoid AV with many tabs
while Assigned(ActivePage) do
ActivePage.Free;
////was before: close tab
////FileMenuCloseItemClick(Sender);
Visible := false;
Application.ProcessMessages;
FileMenuCloseItemClick(Sender);
StopComms;
SavePreferences;
end;
@ -427,6 +444,26 @@ begin
end;
end;
procedure THelpForm.ViewMenuItemClick(Sender: TObject);
begin
ViewMenuContents.Checked :=
Assigned(ActivePage) and
(ActivePage.ContentProvider is TChmContentProvider) and
(ActivePage.ContentProvider as TChmContentProvider).TabsControl.Visible;
ViewShowSepTabs.Checked := fShowSepTabs;
ViewShowStatus.Checked := fShowStatus;
end;
procedure THelpForm.ViewShowSepTabsClick(Sender: TObject);
begin
fShowSepTabs := not fShowSepTabs;
end;
procedure THelpForm.ViewShowStatusClick(Sender: TObject);
begin
fShowStatus := not fShowStatus;
end;
procedure THelpForm.LoadPreferences(AIPCName: String);
var
PrefFile: String;
@ -454,6 +491,9 @@ begin
// downto since oldest are knocked off the list:
for i := RecentCount-1 downto 0 do
AddRecentFile(fConfig.GetValue('Recent/Item'+IntToStr(i)+'/Value',''));
fShowSepTabs := fConfig.GetValue('OpenSepTabs/Value', true);
fShowStatus := fConfig.GetValue('OpenWithStatus/Value', true);
end;
procedure THelpForm.SavePreferences;
@ -482,6 +522,9 @@ begin
for i := 0 to FileMenuOpenRecentItem.Count-1 do
fConfig.SetValue('Recent/Item'+IntToStr(i)+'/Value', TRecentMenuItem(FileMenuOpenRecentItem.Items[I]).URL);
fConfig.SetValue('OpenSepTabs/Value', fShowSepTabs);
fConfig.SetValue('OpenWithStatus/Value', fShowStatus);
fConfig.Flush;
fConfig.Free;
end;
@ -836,6 +879,7 @@ begin
Exit;
end;
if not fShowSepTabs then
for I := 0 to PageControl.PageCount-1 do
begin
if fRealContentProvider.ClassName = TContentTab(PageControl.Pages[I]).ContentProvider.ClassName then
@ -857,10 +901,12 @@ begin
// no existing page that can handle this content, so create one
fPage := TContentTab.Create(PageControl);
fPage.ContentProvider := fRealContentProvider.Create(fPage, ImageList1);
fPAge.ContentProvider.OnTitleChange:=@ContentTitleChange;
fPage.ContentProvider.OnTitleChange := @ContentTitleChange;
fPage.Parent := PageControl;
SetKeyUp(fPage);
fPage.ContentProvider.LoadPreferences(fConfig);
if fPage.ContentProvider is TChmContentProvider then
(fPage.ContentProvider as TChmContentProvider).ShowStatusbar := fShowStatus;
end;
if fUpdateCount > 0 then