mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Don't load CPU when no active operations (fixes #606)
This commit is contained in:
parent
755adbed3a
commit
70e8b41fbe
1 changed files with 47 additions and 17 deletions
|
|
@ -684,6 +684,8 @@ type
|
|||
procedure OnUniqueInstanceMessage(Sender: TObject; Params: TCommandLineParams);
|
||||
procedure tbPasteClick(Sender: TObject);
|
||||
procedure AllProgressOnUpdateTimer(Sender: TObject);
|
||||
procedure OperationManagerNotify(Item: TOperationsManagerItem;
|
||||
Event: TOperationManagerEvent);
|
||||
{$IF (DEFINED(LCLQT) or DEFINED(LCLQT5) or DEFINED(LCLQT6)) and not DEFINED(MSWINDOWS)}
|
||||
private
|
||||
QEventHook: QObject_hookH;
|
||||
|
|
@ -1203,6 +1205,9 @@ begin
|
|||
QObject_hook_hook_events(QEventHook, @QObjectEventFilter);
|
||||
{$ENDIF}
|
||||
|
||||
OperationsManager.AddEventsListener([omevOperationAdded, omevOperationRemoved],
|
||||
@OperationManagerNotify);
|
||||
|
||||
UpdateWindowView;
|
||||
gFavoriteTabsList.AssociatedMainMenuItem := mnuFavoriteTabs;
|
||||
gFavoriteTabsList.RefreshAssociatedMainMenu;
|
||||
|
|
@ -1733,6 +1738,9 @@ begin
|
|||
HotMan.UnRegister(Self);
|
||||
end;
|
||||
|
||||
OperationsManager.RemoveEventsListener([omevOperationAdded, omevOperationRemoved],
|
||||
@OperationManagerNotify);
|
||||
|
||||
TDriveWatcher.RemoveObserver(@OnDriveWatcherEvent);
|
||||
TDriveWatcher.Finalize;
|
||||
DCDebug('Drive watcher finished');
|
||||
|
|
@ -5497,8 +5505,10 @@ begin
|
|||
FOperationsPanel.DoubleBuffered := True;
|
||||
PanelAllProgress.OnResize := @FOperationsPanel.ParentResized;
|
||||
end;
|
||||
|
||||
PanelAllProgress.Visible := gPanelOfOp;
|
||||
Timer.Enabled := gPanelOfOp or gProgInMenuBar;
|
||||
Timer.Enabled := (gPanelOfOp or gProgInMenuBar) and
|
||||
(OperationsManager.OperationsCount > 0);
|
||||
|
||||
// Log window
|
||||
seLogWindow.Visible := gLogWindow;
|
||||
|
|
@ -6766,28 +6776,48 @@ procedure TfrmMain.AllProgressOnUpdateTimer(Sender: TObject);
|
|||
var
|
||||
AllProgressPoint: Integer;
|
||||
begin
|
||||
// Hide progress bar if there are no operations
|
||||
if OperationsManager.OperationsCount = 0 then
|
||||
if gPanelOfOp = True then
|
||||
begin
|
||||
FOperationsPanel.UpdateView;
|
||||
end;
|
||||
|
||||
// Show progress in the menu
|
||||
if gProgInMenuBar = True then
|
||||
begin
|
||||
AllProgressPoint:= Round(OperationsManager.AllProgressPoint * 100);
|
||||
mnuAllOperProgress.Caption:= IntToStr(AllProgressPoint) + ' %';
|
||||
end;
|
||||
|
||||
Sleep(0);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.OperationManagerNotify(Item: TOperationsManagerItem;
|
||||
Event: TOperationManagerEvent);
|
||||
begin
|
||||
if Event = omevOperationRemoved then
|
||||
begin
|
||||
// Hide progress bar if there are no operations
|
||||
if OperationsManager.OperationsCount = 0 then
|
||||
begin
|
||||
mnuAllOperProgress.Visible:= False;
|
||||
mnuAllOperPause.Visible:= False;
|
||||
mnuAllOperStart.Visible:= False;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if gPanelOfOp = True then
|
||||
FOperationsPanel.UpdateView;
|
||||
|
||||
if gProgInMenuBar = True then
|
||||
begin
|
||||
AllProgressPoint:= Round(OperationsManager.AllProgressPoint * 100);
|
||||
// Show in menu line
|
||||
mnuAllOperProgress.Caption:=IntToStr(AllProgressPoint) + ' %';
|
||||
mnuAllOperProgress.Visible:= True;
|
||||
mnuAllOperPause.Visible:= True;
|
||||
mnuAllOperStart.Visible:= True;
|
||||
end;
|
||||
mnuAllOperStop.Visible:= False;
|
||||
end;
|
||||
end
|
||||
else if Event = omevOperationAdded then
|
||||
begin
|
||||
if gProgInMenuBar = True then
|
||||
begin
|
||||
mnuAllOperProgress.Visible:= True;
|
||||
mnuAllOperPause.Visible:= True;
|
||||
mnuAllOperStart.Visible:= True;
|
||||
mnuAllOperStop.Visible:= True;
|
||||
end;
|
||||
end;
|
||||
AllProgressOnUpdateTimer(Timer);
|
||||
Timer.Enabled := (gPanelOfOp or gProgInMenuBar) and
|
||||
(OperationsManager.OperationsCount > 0);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.SetPanelDrive(aPanel: TFilePanelSelect; Drive: PDrive; ActivateIfNeeded: Boolean);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue