Skip to content

Commit

Permalink
Minor bugfix
Browse files Browse the repository at this point in the history
In rare cases KeePass could steal the focus when SoftLock is activated
  • Loading branch information
Rookiestyle committed Oct 27, 2021
1 parent dfb96f3 commit df1c197
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
10 changes: 2 additions & 8 deletions src/Config/LockAssistConfig_QU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ public bool QU_CopyFrom(LockAssistConfig NewOptions)
return SwitchToNoDBSpecific;
}

public void QU_WriteConfig()
{
QU_DBSpecific = false;
QU_WriteConfig(null);
}

public void QU_WriteConfig(PwDatabase db)
public void QU_WriteConfig(PwDatabase db, bool bChanged)
{
if (QU_DBSpecific)
{
Expand All @@ -90,7 +84,7 @@ public void QU_WriteConfig(PwDatabase db)
db.CustomData.Set(LockAssistKeyFromEnd, QU_UsePasswordFromEnd ? "true" : "false");
db.CustomData.Set(LockAssistQuickUnlockDBSpecific, "true");
db.CustomData.Set(LockAssistQU_ValiditySeconds, QU_ValiditySeconds.ToString());
QU_FlagDBChanged(db);
if (bChanged) QU_FlagDBChanged(db);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/LockAssist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ private void OptionsFormClosed(object sender, Tools.OptionsFormsEventArgs e)

if (SwitchToNoDBSpecific)
{
string sQuestion = string.Format(PluginTranslate.OptionsSwitchDBToGeneral, DialogResult.Yes.ToString(), DialogResult.No.ToString());
string sQuestion = string.Format(PluginTranslate.OptionsSwitchDBToGeneral, KeePass.Resources.KPRes.Yes, KeePass.Resources.KPRes.No);
if (Tools.AskYesNo(sQuestion) == DialogResult.No)
//Make current configuration the new global configuration
MyOptions.QU_WriteConfig(null);
MyOptions.QU_WriteConfig(null, false);
//Remove DB specific configuration
MyOptions.QU_DeleteDBConfig(m_host.Database);
}
else MyOptions.QU_WriteConfig(m_host.Database);
else MyOptions.QU_WriteConfig(m_host.Database, changedConfigTotal);

if (LockAssistConfig.LW_Active != options.GetLockWorkspace())
{
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1")]
[assembly: AssemblyFileVersion("3.1")]
[assembly: AssemblyVersion("3.1.1")]
[assembly: AssemblyFileVersion("3.1.1")]
15 changes: 8 additions & 7 deletions src/SoftLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ internal void SetVisibility(bool bVisible)
{
List<string> lMsg = new List<string>();
m_SoftLocked = !bVisible;
lMsg.Add("SoftLock active: " + m_SoftLocked.ToString());
if (m_SoftLocked)
{
m_dHiddenForms.Clear();
Expand Down Expand Up @@ -215,13 +216,13 @@ internal void SetVisibility(bool bVisible)
if (!kvp.Key.RightToLeftLayout)
kvp.Key.Opacity = !m_SoftLocked ? kvp.Value.Opacity : .1; //0 makes the window not react on mouse input
}
catch (Exception) { }
catch (Exception ex) { lMsg.Add("Ex:" + ex.Message); }
}
if (!m_SoftLocked) m_dHiddenForms.Clear();
PluginDebug.AddInfo("Toggle SoftLock", lMsg.ToArray());
}

private void HandleMenu(bool bVisible)
private void HandleMenu(bool bVisible)
{
HandleMenuEntry(LockAssistExt.c_OptionsMenuItemName, bVisible);
HandleMenuEntry("m_menuGroup", bVisible);
Expand Down Expand Up @@ -270,8 +271,8 @@ private void HandleMenuEntry(string sKey, bool bEnabled)
tsmi[0].Enabled = bEnabled;
}

private void HandlePanel(bool bVisible, Control c)
{
private void HandlePanel(bool bVisible, Control c)
{
string buttonName = "LockAssistPlugin_SoftLock_HideButton" + c.GetType().Name + c.Name;
Button bHide = Tools.GetControl(buttonName, c) as Button;
if (bHide != null)
Expand All @@ -287,17 +288,17 @@ private void HandlePanel(bool bVisible, Control c)
bHide.Name = buttonName;
if (m_dHiddenForms.Count == 0)
bHide.Text = PluginTranslate.SoftlockModeUnhide; //Display button on MainForm only, set text
else if (Application.OpenForms.Count > 1 && c == Application.OpenForms[Application.OpenForms.Count-1]) //Display button on topmost form, set text
else if (Application.OpenForms.Count > 1 && c == Application.OpenForms[Application.OpenForms.Count - 1]) //Display button on topmost form, set text
bHide.Text = PluginTranslate.SoftlockModeUnhideForms;

bHide.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
bHide.Dock = DockStyle.Fill;
bHide.Click += OnTimerTick;
bHide.KeyDown += OnTimerTick;

c.Controls.Add(bHide);
bHide.BringToFront();
bHide.Focus();
bHide.Select();
}
private void OnUIStateUpdated(object sender, EventArgs e)
{
Expand Down
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
LockAssist:3.1
LockAssist:3.1.1
LockAssist!de:4
LockAssist!pt:2
:

0 comments on commit df1c197

Please sign in to comment.