Skip to content

Commit 70b701d

Browse files
committed
Added inline URL option to launch a url closes #6
1 parent efe738e commit 70b701d

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

EntryTemplateManager.ChildViewer.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using KeePass.Plugins;
99
using KeePass.Resources;
1010
using KeePass.UI;
11+
using KeePass.Util;
1112
using KeePassLib;
1213
using KeePassLib.Cryptography.PasswordGenerator;
1314
using KeePassLib.Security;
@@ -238,12 +239,14 @@ private bool InitializeChildView(TabPage page, String uuid) {
238239
picker.ShowCheckBox = true;
239240
et_to_control[t] = picker;
240241
}
241-
else if (t.type == "Inline" || t.type == "Protected Inline") {
242+
else if (t.type == "Inline" || t.type == "Protected Inline" || t.type == "Inline URL") {
242243
TextBox box = new TextBox();
243244
box.Top = control_offset_y;
244245
box.Left = LEFT_CONTROL_OFFSET;
245-
box.Width = CONTROL_WIDTH;
246+
box.Width = t.type == "Inline URL" ? CONTROL_WIDTH-30 : CONTROL_WIDTH;
246247
int lines = LinesFromOption(t.options);
248+
if (t.type == "Inline URL")
249+
lines = 1;
247250
if (lines > 1) {
248251
box.Multiline = true;
249252
box.AcceptsReturn = true;
@@ -278,9 +281,15 @@ private bool InitializeChildView(TabPage page, String uuid) {
278281
}
279282
if (t.fieldName == PwDefs.PasswordField) {
280283
entry_pass = current_password_field = sedit;
281-
282284
}
285+
}else if (t.type == "Inline URL") {
286+
var link= new LinkLabel {Text = "Open"};
287+
link.LinkClicked += (sender, args) => WinUtil.OpenUrl(box.Text??"", form.EntryRef);
288+
link.Location = new Point(box.Left + box.Width + 10, control_offset_y);
289+
link.Width = 50;
290+
et_to_control2[t] = link;
283291
}
292+
284293
}
285294
else if (t.type == "Popout" || t.type == "Protected Popout") {
286295
Button btn = new Button();
@@ -388,7 +397,7 @@ private void save_child_vals() {
388397
CheckBox checkbox = (CheckBox)pair.Value;
389398
str = new ProtectedString(false, checkbox.Checked.ToString());
390399
}
391-
else if (t.type == "Inline") {
400+
else if (t.type == "Inline" || t.type == "Inline URL") {
392401
TextBox box = (TextBox)pair.Value;
393402
str = new ProtectedString(false, box.Text == null ? "" : box.Text.Replace("\r", ""));
394403
}
@@ -470,7 +479,7 @@ private void init_child_vals() {
470479
str = form.EntryStrings.Get(get_name);
471480
if (str == null)
472481
str = new ProtectedString(t.type.StartsWith("Protected"), "");
473-
if (t.type == "Inline") {
482+
if (t.type == "Inline" || t.type == "Inline URL") {
474483
TextBox box = (TextBox)pair.Value;
475484
String val = str.ReadString();
476485
val = val.Replace("\r", "");

EntryTemplateManager.TemplateEditor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private void InitializeGridView(TabPage page) {
107107
colType.Width = 100;
108108
colType.Items.AddRange(new object[] {
109109
"Inline",
110+
"Inline URL",
110111
"Popout",
111112
"Protected Inline",
112113
"Protected Popout",
@@ -115,7 +116,8 @@ private void InitializeGridView(TabPage page) {
115116
"Date Time",
116117
"Checkbox",
117118
"Divider",
118-
"Listbox"});
119+
"Listbox"
120+
});
119121
colType.DropDownWidth = 150;
120122
colOpt.HeaderText = "Opt";
121123
colOpt.Name = "colOpt";
@@ -247,7 +249,7 @@ void col_field_box_SelectedIndexChanged(object sender, EventArgs e) {
247249
break;
248250
case "URL":
249251
fieldName = PwDefs.UrlField;
250-
type = conf.ProtectUrl ? "Protected Inline" : "Inline";
252+
type = conf.ProtectUrl ? "Protected Inline" : "Inline URL";
251253
break;
252254
case "Override URL":
253255
fieldName = "@override";

Properties/AssemblyInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// associated with an assembly.
88
[assembly: AssemblyTitle("Entry Templates for KeePass")]
99
[assembly: AssemblyDescription("Provides Templating support for KeePass")]
10-
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("Mitch Capper")]
12-
[assembly: AssemblyProduct("KeePass Plugin")]
12+
[assembly: AssemblyProduct("KeePass Plugin")]
1313
[assembly: AssemblyCopyright("Copyright © 2016")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
@@ -31,6 +31,6 @@
3131
//
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("7.2.0.0")]
36-
[assembly: AssemblyFileVersion("7.2.0.0")]
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("7.3.0.0")]
36+
[assembly: AssemblyFileVersion("7.3.0.0")]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ KP Entry Templates for KeePass 2.x
33

44
CHANGES
55
-----
6+
- 7.3 Added inline url option that has a clickable link to open the url
67
- 7.2 Fixed bug that prevented working on *nix platforms, thanks to @x09
78
- 7.01 Fixed bug causing crash if first field was not a textbox on a template
89
- 7.0 Moved to git(hub), KP 2.3 support, High DPI support

0 commit comments

Comments
 (0)