mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 11:37:40 +00:00
[KOE-139] SharedFolderDialog now sets read-only flag on statically configured shared folders.
This commit is contained in:
parent
7404b15d7a
commit
b82e2ef839
@ -97,7 +97,7 @@ namespace Acacia.Controls
|
|||||||
|
|
||||||
private void ToggleCheck(KTreeNode node)
|
private void ToggleCheck(KTreeNode node)
|
||||||
{
|
{
|
||||||
if (_checkManager == null || node == null)
|
if (_checkManager == null || node == null || !node.CheckBoxEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!SelectedNodes.Contains(node) || SelectedNodes.Count == 1)
|
if (!SelectedNodes.Contains(node) || SelectedNodes.Count == 1)
|
||||||
|
@ -127,6 +127,20 @@ namespace Acacia.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _checkBoxEnabled = true;
|
||||||
|
public bool CheckBoxEnabled
|
||||||
|
{
|
||||||
|
get { return _checkBoxEnabled; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_checkBoxEnabled != value)
|
||||||
|
{
|
||||||
|
_checkBoxEnabled = value;
|
||||||
|
Owner?.Rerender(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool _isExpanded;
|
private bool _isExpanded;
|
||||||
public bool IsExpanded
|
public bool IsExpanded
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ namespace Acacia.Controls
|
|||||||
// Checkbox
|
// Checkbox
|
||||||
if (_tree.CheckManager != null && node.HasCheckBox)
|
if (_tree.CheckManager != null && node.HasCheckBox)
|
||||||
{
|
{
|
||||||
RenderCheckBox(graphics, node, dims.GetPartRect(KTreeNodeMeasurements.Part.CheckBox, true), highlight);
|
RenderCheckBox(graphics, node, dims.GetPartRect(KTreeNodeMeasurements.Part.CheckBox, true), highlight, node.CheckBoxEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
@ -159,10 +159,12 @@ namespace Acacia.Controls
|
|||||||
protected abstract void RenderNodeOutline(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight);
|
protected abstract void RenderNodeOutline(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight);
|
||||||
internal protected abstract void RenderNodeExpander(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight);
|
internal protected abstract void RenderNodeExpander(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight);
|
||||||
|
|
||||||
protected virtual void RenderCheckBox(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight)
|
protected virtual void RenderCheckBox(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight, bool enabled)
|
||||||
{
|
{
|
||||||
int state = (int)node.CheckState * 4 + 1;
|
int state = (int)node.CheckState * 4 + 1;
|
||||||
if (highlight != null && highlight.Value == KTreeNodeMeasurements.Part.CheckBox)
|
if (!enabled)
|
||||||
|
state += 3;
|
||||||
|
else if (highlight != null && highlight.Value == KTreeNodeMeasurements.Part.CheckBox)
|
||||||
state += 1;
|
state += 1;
|
||||||
|
|
||||||
CheckBoxRenderer.DrawCheckBox(graphics, rect.Location, (CheckBoxState)state);
|
CheckBoxRenderer.DrawCheckBox(graphics, rect.Location, (CheckBoxState)state);
|
||||||
|
@ -30,7 +30,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
private readonly StoreTreeNode _store;
|
private readonly StoreTreeNode _store;
|
||||||
private readonly AvailableFolder _folder;
|
private readonly AvailableFolder _folder;
|
||||||
private SharedFolder _share;
|
private SharedFolder _share;
|
||||||
public bool IsReadOnly { get { return _store.IsReadOnly; } }
|
public readonly bool IsReadOnly;
|
||||||
|
|
||||||
public FolderTreeNode(StoreTreeNode store, AvailableFolder folder, SharedFolder share)
|
public FolderTreeNode(StoreTreeNode store, AvailableFolder folder, SharedFolder share)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,9 @@ namespace Acacia.Features.SharedFolders
|
|||||||
|
|
||||||
this.Text = folder.Name;
|
this.Text = folder.Name;
|
||||||
|
|
||||||
HasCheckBox = !IsReadOnly;
|
IsReadOnly = share?.SyncId?.Kind == SyncKind.Configured;
|
||||||
|
HasCheckBox = true;
|
||||||
|
CheckBoxEnabled = !IsReadOnly;
|
||||||
|
|
||||||
// Image
|
// Image
|
||||||
// TODO: clean this up
|
// TODO: clean this up
|
||||||
|
@ -261,8 +261,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
|
|
||||||
// Add the node
|
// Add the node
|
||||||
node = new StoreTreeNode(_folders, gabLookup.GAB,
|
node = new StoreTreeNode(_folders, gabLookup.GAB,
|
||||||
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>(),
|
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>());
|
||||||
false);
|
|
||||||
node.DirtyChanged += UserSharesChanged;
|
node.DirtyChanged += UserSharesChanged;
|
||||||
_userFolders.Add(user, node);
|
_userFolders.Add(user, node);
|
||||||
kTreeFolders.RootNodes.Add(node);
|
kTreeFolders.RootNodes.Add(node);
|
||||||
|
@ -49,8 +49,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
public readonly bool IsReadOnly;
|
public readonly bool IsReadOnly;
|
||||||
|
|
||||||
public StoreTreeNode(SharedFoldersManager folders, GABHandler gab, GABUser user, string text,
|
public StoreTreeNode(SharedFoldersManager folders, GABHandler gab, GABUser user, string text,
|
||||||
Dictionary<BackendId, SharedFolder> currentFolders,
|
Dictionary<BackendId, SharedFolder> currentFolders)
|
||||||
bool readOnly)
|
|
||||||
:
|
:
|
||||||
base(text)
|
base(text)
|
||||||
{
|
{
|
||||||
@ -58,7 +57,7 @@ namespace Acacia.Features.SharedFolders
|
|||||||
this._feature = folders.Feature;
|
this._feature = folders.Feature;
|
||||||
this._gab = gab;
|
this._gab = gab;
|
||||||
this._user = user;
|
this._user = user;
|
||||||
this.IsReadOnly = readOnly;
|
this.IsReadOnly = false;
|
||||||
|
|
||||||
// Create an empty current state. When loading the nodes, the shares will be added. This has the benefit of
|
// Create an empty current state. When loading the nodes, the shares will be added. This has the benefit of
|
||||||
// cleaning up automatically any obsolote shares.
|
// cleaning up automatically any obsolote shares.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user