Skip to content

Commit

Permalink
Let user confirm detected KeePass install type
Browse files Browse the repository at this point in the history
  • Loading branch information
Rookiestyle committed Jan 23, 2022
1 parent c04f9a5 commit 534f8a8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/EarlyUpdateCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,16 @@ private void OnUpdateCheckFormShown(object sender, EventArgs e)
}
}

private bool m_bActivateKeePassUpdateTab = false;
private void CheckKeePassInstallType(bool bShowOptions)
{
if (PluginConfig.KeePassInstallTypeConfigured) return;
m_bActivateKeePassUpdateTab = true;
if (!bShowOptions) Tools.ShowInfo(PluginTranslate.KeePassUpdate_RequestInstallType);
if (bShowOptions) Tools.ShowOptions();
}
}

private void LvPlugins_KeyPress(object sender, KeyPressEventArgs e)
private void LvPlugins_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != (char)Keys.Space) return;
var lv = sender as ListView;
Expand Down Expand Up @@ -772,7 +774,12 @@ private void LvPlugins_DrawSubItem(object sender, DrawListViewSubItemEventArgs e
ListView lvPlugins = sender as ListView;
e.DrawDefault = true;

if (e.ColumnIndex + 1 != lvPlugins.Items[0].SubItems.Count) return;
int iMaxColumns = -1;
foreach (ListViewItem lvi in lvPlugins.Items)
{
if (iMaxColumns < lvi.SubItems.Count) iMaxColumns = lvi.SubItems.Count;
}
if (e.ColumnIndex + 1 != iMaxColumns) return;
PluginUpdate upd = PluginUpdateHandler.Plugins.Find(x => x.Title == e.Item.SubItems[0].Text);
if (upd == null) upd = PluginUpdateHandler.Plugins.Find(x => x.Title + "*" == e.Item.SubItems[0].Text); //* is used to indicate a rename
if (upd == null && e.Item.Index == 0 && e.Item.SubItems[e.ColumnIndex].Tag is KeePass_Update) upd = e.Item.SubItems[e.ColumnIndex].Tag as KeePass_Update;
Expand Down Expand Up @@ -1134,12 +1141,13 @@ private void OptionsFormShown(object sender, Tools.OptionsFormsEventArgs e)
options.cgKeePassUpdate.Checked = PluginConfig.KeePassUpdateActive;
options.kpit = PluginConfig.KeePassInstallType;
options.Plugin = this;
//e.form.Resize += options.AdjustControls;
if (m_bActivateKeePassUpdateTab) e.form.Shown += options.ActivateKeePassUpdateTab;
Tools.AddPluginToOptionsForm(this, options);
}

private void OptionsFormClosed(object sender, Tools.OptionsFormsEventArgs e)
{
m_bActivateKeePassUpdateTab = false;
if (e.form.DialogResult != DialogResult.OK) return;
bool shown = false;
Options options = (Options)Tools.GetPluginFromOptions(this, out shown);
Expand Down
28 changes: 27 additions & 1 deletion src/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,33 @@ internal void AdjustControls(object sender, EventArgs e)
cbKeePassInstallType.Width = tbKeePassFolder.Width;
}

private void lKeePassFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
internal void ActivateKeePassUpdateTab(object sender, EventArgs e)
{
TabControl tcMain = null;
TabControl tcPluginOptions = null;
TabPage tpEUC = null;
TabPage tpOptions = null;
Control c = tcEUC.Parent;
while (c != null)
{
if (c is TabPage)
{
if (tpEUC == null) tpEUC = c as TabPage;
else if (tpOptions == null) tpOptions = c as TabPage;
}
else if (c is TabControl)
{
if (tcPluginOptions == null) tcPluginOptions = c as TabControl;
else if (tcMain == null) tcMain = c as TabControl;
}
c = c.Parent;
}
if (tcMain != null && tpOptions != null) tcMain.SelectedTab = tpOptions;
if (tcPluginOptions != null && tpEUC != null) tcPluginOptions.SelectedTab = tpEUC;
tcEUC.SelectedTab = tpKeePass;
}

private void lKeePassFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
PluginTools.Tools.OpenUrl(tbKeePassFolder.Text);
}
Expand Down
1 change: 0 additions & 1 deletion src/PluginUpdateInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ private void CheckRenamed(Dictionary<string, List<UpdateComponentInfo>> m_dUpdat
if (sParts.Length != 2) continue;
IsRenamed = true;
NewName = sParts[1];
PluginDebug.DebugMode = true;
PluginDebug.AddInfo("New plugin name detected", 0, "Old: " + Name, "New: " + NewName);
return;
}
Expand Down

0 comments on commit 534f8a8

Please sign in to comment.