mirror of https://gitlab.com/basile.b/dexed.git
fix #311 - accept but now also warn about dup shortcuts in two different categories
This commit is contained in:
parent
928a8f5762
commit
f300fc526d
|
@ -7,8 +7,6 @@ object CEShortcutEditor: TCEShortcutEditor
|
||||||
ClientHeight = 449
|
ClientHeight = 449
|
||||||
ClientWidth = 424
|
ClientWidth = 424
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
DesignLeft = 1365
|
|
||||||
DesignTop = 176
|
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 449
|
Height = 449
|
||||||
|
|
|
@ -303,27 +303,56 @@ end;
|
||||||
procedure TCEShortcutEditor.propeditModified(Sender: TObject);
|
procedure TCEShortcutEditor.propeditModified(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
sh: TShortCut;
|
j: integer;
|
||||||
sht: string;
|
s: TShortCut;
|
||||||
dup: TShortcutItem = nil;
|
d: TShortcutItem = nil;
|
||||||
|
t: string;
|
||||||
|
o: TTreeNode;
|
||||||
const
|
const
|
||||||
msg = '"%s" is already assigned in the same category by "%s". The new shortcut will be ignored';
|
m1 = 'warning, "%s" is already assigned in the "%s" category and it is not guaranteed to work properly';
|
||||||
|
m2 = 'warning, "%s" is already assigned in the same category to "%s". The new shortcut will be ignored';
|
||||||
begin
|
begin
|
||||||
if not anItemIsSelected then
|
if not anItemIsSelected then
|
||||||
exit;
|
exit;
|
||||||
sh := propvalue.value;
|
s := propvalue.value;
|
||||||
sht := shortCutToText(sh);
|
t := shortCutToText(s);
|
||||||
if sht.isEmpty then
|
if t.isEmpty then
|
||||||
exit;
|
exit;
|
||||||
for i:= 0 to tree.Selected.Parent.Count-1 do
|
|
||||||
if i <> tree.Selected.Index then
|
// warn but accept a dup if already in another category
|
||||||
if TShortcutItem(tree.Selected.Parent.Items[i].Data).data = sh then
|
for i:= 0 to tree.Items.Count-1 do
|
||||||
dup := TShortcutItem(tree.Selected.Parent.Items[i].Data);
|
|
||||||
if dup.isNotNil then
|
|
||||||
dlgOkInfo(format(msg,[ShortCutToText(sh), dup.identifier]))
|
|
||||||
else if TShortcutItem(tree.Selected.Data).data <> sh then
|
|
||||||
begin
|
begin
|
||||||
TShortcutItem(tree.Selected.Data).data := sh;
|
if tree.Items[i] = tree.Selected.Parent then
|
||||||
|
continue;
|
||||||
|
for j := 0 to Tree.Items[i].Count-1 do
|
||||||
|
begin
|
||||||
|
o := Tree.Items[i].Items[j];
|
||||||
|
if o.Data.isNil then
|
||||||
|
continue;
|
||||||
|
if TShortcutItem(o.Data).data = s then
|
||||||
|
begin
|
||||||
|
dlgOkInfo(format(m1, [t, Tree.Items[i].Text]));
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// warn and discard aa dup if already in the same cat.
|
||||||
|
for i:= 0 to tree.Selected.Parent.Count-1 do
|
||||||
|
begin
|
||||||
|
if i = tree.Selected.Index then
|
||||||
|
continue;
|
||||||
|
o := tree.Selected.Parent.Items[i];
|
||||||
|
if o.Data.isNil then
|
||||||
|
continue;
|
||||||
|
if TShortcutItem(o.Data).data = s then
|
||||||
|
d := TShortcutItem(o.Data);
|
||||||
|
end;
|
||||||
|
if d.isNotNil then
|
||||||
|
dlgOkInfo(format(m2,[t, d.identifier]))
|
||||||
|
else if TShortcutItem(tree.Selected.Data).data <> s then
|
||||||
|
begin
|
||||||
|
TShortcutItem(tree.Selected.Data).data := s;
|
||||||
fHasChanged := true;
|
fHasChanged := true;
|
||||||
end;
|
end;
|
||||||
updateEditCtrls;
|
updateEditCtrls;
|
||||||
|
|
Loading…
Reference in New Issue