Skip to content

Commit

Permalink
Preserve entry list
Browse files Browse the repository at this point in the history
Don't rebuild entry list after changing OTP settings.
Has no effect if working within a regular group.
Preserves the list of entries if working in a virtual group like search results, "show entries in subgroups", ...
  • Loading branch information
Rookiestyle committed Dec 7, 2020
1 parent d1bbc00 commit b9f5404
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/DAO/OTPDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public static void SaveOTP(KPOTP myOTP, PwEntry pe)
OTPHandler_Base h = GetOTPHandler(pe);
h.SaveOTP(myOTP, pe);
myOTP.ResetSanitizedChange();
Program.MainForm.RefreshEntriesList();
bool bModified = (h is OTPHandler_DB) ? (h as OTPHandler_DB).DB == Program.MainForm.ActiveDatabase : true;
Program.MainForm.UpdateUI(false, null, false, null, true, null, bModified);
System.Windows.Forms.ListView lv = (System.Windows.Forms.ListView)Tools.GetControl("m_lvEntries");
Tools.RefreshEntriesList(bModified);
}

internal static PwDatabase GetDB(this PwEntry pe)
Expand Down
1 change: 1 addition & 0 deletions src/KeePassOTP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Compile Include="Utilities\Tools_Controls.cs" />
<Compile Include="Utilities\Tools_Main.cs" />
<Compile Include="Utilities\Tools_Options.cs" />
<Compile Include="Utilities\Tools_UI.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
Expand Down
3 changes: 1 addition & 2 deletions src/KeePassOTPExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ private void OnOTPCopy(object sender, EventArgs e)
CopyOTP(m_host.MainWindow.GetSelectedEntry(true));
}


private void OnOTPQRCode(object sender, EventArgs e)
{
if (m_host.MainWindow.GetSelectedEntriesCount() != 1) return;
Expand Down Expand Up @@ -447,7 +446,7 @@ private void MigratePlacholderInOpenDatabases(string sOldPlaceholder, string pla
m.SetDB(null);
}
if (bChanged)
m_host.MainWindow.UpdateUI(false, null, false, null, false, null, (m_host.Database != null) && m_host.Database.IsOpen && m_host.Database.Modified);
Tools.RefreshEntriesList((m_host.Database != null) && m_host.Database.IsOpen && m_host.Database.Modified);
};
m_tMigratePlaceholder.Start();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.20.2")]
[assembly: AssemblyFileVersion("0.20.2")]
[assembly: AssemblyVersion("0.21")]
[assembly: AssemblyFileVersion("0.21")]
34 changes: 34 additions & 0 deletions src/Utilities/Tools_UI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace PluginTools
{
public static partial class Tools
{
public static bool PreserveEntriesShown
{
get { return KeePass.Program.Config.CustomConfig.GetBool("Rookiestyle.PreserveEntriesShown", true); }
set { KeePass.Program.Config.CustomConfig.SetBool("Rookiestyle.PreserveEntriesShown", value); }
}

public static void RefreshEntriesList(bool bSetModified)
{
UpdateUIAndRefreshEntriesList(false, null, false, null, false, null, bSetModified);
}

public static void UpdateUIAndRefreshEntriesList(bool bRecreateTabBar, KeePass.UI.PwDocument dsSelect,
bool bUpdateGroupList, KeePassLib.PwGroup pgSelect, bool bUpdateEntryList,
KeePassLib.PwGroup pgEntrySource, bool bSetModified)
{
//Update entries that are currently shown
if (PreserveEntriesShown && !bUpdateEntryList && !bUpdateEntryList)
{
KeePass.Program.MainForm.RefreshEntriesList();
//bUpdateGroupList = false;
//bUpdateEntryList = false;
}

//Update UI to update all other parts of the UI
KeePass.Program.MainForm.UpdateUI(bRecreateTabBar, dsSelect,
bUpdateGroupList, bUpdateGroupList ? pgSelect : null,
bUpdateEntryList, bUpdateEntryList ? pgEntrySource : null, bSetModified);
}
}
}
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
KeePassOTP:0.20.2
KeePassOTP:0.21
KeePassOTP!de:11
KeePassOTP!fr:3
:

0 comments on commit b9f5404

Please sign in to comment.