mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-28 23:42:13 +12:00
Added tray menu entry and hotkey for be able to "Disable/Enable hotkeys"
This commit is contained in:
parent
dcb7758d00
commit
c399f48276
13 changed files with 125 additions and 2 deletions
18
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
18
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
|
@ -843,6 +843,24 @@ internal static string HotkeyType_CustomRegion_Category {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Disable/Enable hotkeys.
|
||||||
|
/// </summary>
|
||||||
|
internal static string HotkeyType_DisableHotkeys {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("HotkeyType_DisableHotkeys", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Other.
|
||||||
|
/// </summary>
|
||||||
|
internal static string HotkeyType_DisableHotkeys_Category {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("HotkeyType_DisableHotkeys_Category", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to DNS changer.
|
/// Looks up a localized string similar to DNS changer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -778,4 +778,10 @@ Would you like to download and install it?</value>
|
||||||
<data name="HotkeyType_CaptureWebpage_Category" xml:space="preserve">
|
<data name="HotkeyType_CaptureWebpage_Category" xml:space="preserve">
|
||||||
<value>Screen capture</value>
|
<value>Screen capture</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="HotkeyType_DisableHotkeys" xml:space="preserve">
|
||||||
|
<value>Disable/Enable hotkeys</value>
|
||||||
|
</data>
|
||||||
|
<data name="HotkeyType_DisableHotkeys_Category" xml:space="preserve">
|
||||||
|
<value>Other</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -42,6 +42,7 @@ public class ApplicationConfig : SettingsBase<ApplicationConfig>
|
||||||
public bool ShowTrayMiddleClickTip = true; // Tray icon middle click tip
|
public bool ShowTrayMiddleClickTip = true; // Tray icon middle click tip
|
||||||
public int NameParserAutoIncrementNumber = 0;
|
public int NameParserAutoIncrementNumber = 0;
|
||||||
public RecentItem[] RecentLinks = null;
|
public RecentItem[] RecentLinks = null;
|
||||||
|
public bool DisableHotkeys = false;
|
||||||
|
|
||||||
public ApplicationConfig()
|
public ApplicationConfig()
|
||||||
{
|
{
|
||||||
|
|
|
@ -182,6 +182,7 @@ public enum HotkeyType // Localized + Category
|
||||||
TweetMessage,
|
TweetMessage,
|
||||||
MonitorTest,
|
MonitorTest,
|
||||||
// Other
|
// Other
|
||||||
|
DisableHotkeys,
|
||||||
OpenScreenshotsFolder
|
OpenScreenshotsFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
ShareX/Forms/MainForm.Designer.cs
generated
10
ShareX/Forms/MainForm.Designer.cs
generated
|
@ -211,6 +211,7 @@ private void InitializeComponent()
|
||||||
this.tsmiTrayApplicationSettings = new System.Windows.Forms.ToolStripMenuItem();
|
this.tsmiTrayApplicationSettings = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.tsmiTrayTaskSettings = new System.Windows.Forms.ToolStripMenuItem();
|
this.tsmiTrayTaskSettings = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.tsmiTrayHotkeySettings = new System.Windows.Forms.ToolStripMenuItem();
|
this.tsmiTrayHotkeySettings = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.tsmiTrayToggleHotkeys = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.tssTray2 = new System.Windows.Forms.ToolStripSeparator();
|
this.tssTray2 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.tsmiScreenshotsFolder = new System.Windows.Forms.ToolStripMenuItem();
|
this.tsmiScreenshotsFolder = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.tsmiTrayHistory = new System.Windows.Forms.ToolStripMenuItem();
|
this.tsmiTrayHistory = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
@ -1222,6 +1223,7 @@ private void InitializeComponent()
|
||||||
this.tsmiTrayApplicationSettings,
|
this.tsmiTrayApplicationSettings,
|
||||||
this.tsmiTrayTaskSettings,
|
this.tsmiTrayTaskSettings,
|
||||||
this.tsmiTrayHotkeySettings,
|
this.tsmiTrayHotkeySettings,
|
||||||
|
this.tsmiTrayToggleHotkeys,
|
||||||
this.tssTray2,
|
this.tssTray2,
|
||||||
this.tsmiScreenshotsFolder,
|
this.tsmiScreenshotsFolder,
|
||||||
this.tsmiTrayHistory,
|
this.tsmiTrayHistory,
|
||||||
|
@ -1621,6 +1623,13 @@ private void InitializeComponent()
|
||||||
resources.ApplyResources(this.tsmiTrayHotkeySettings, "tsmiTrayHotkeySettings");
|
resources.ApplyResources(this.tsmiTrayHotkeySettings, "tsmiTrayHotkeySettings");
|
||||||
this.tsmiTrayHotkeySettings.Click += new System.EventHandler(this.tsbHotkeySettings_Click);
|
this.tsmiTrayHotkeySettings.Click += new System.EventHandler(this.tsbHotkeySettings_Click);
|
||||||
//
|
//
|
||||||
|
// tsmiTrayToggleHotkeys
|
||||||
|
//
|
||||||
|
this.tsmiTrayToggleHotkeys.Image = global::ShareX.Properties.Resources.keyboard__minus;
|
||||||
|
this.tsmiTrayToggleHotkeys.Name = "tsmiTrayToggleHotkeys";
|
||||||
|
resources.ApplyResources(this.tsmiTrayToggleHotkeys, "tsmiTrayToggleHotkeys");
|
||||||
|
this.tsmiTrayToggleHotkeys.Click += new System.EventHandler(this.tsmiTrayToggleHotkeys_Click);
|
||||||
|
//
|
||||||
// tssTray2
|
// tssTray2
|
||||||
//
|
//
|
||||||
this.tssTray2.Name = "tssTray2";
|
this.tssTray2.Name = "tssTray2";
|
||||||
|
@ -1909,5 +1918,6 @@ private void InitializeComponent()
|
||||||
private System.Windows.Forms.ToolStripMenuItem tsmiTrayRectangleTransparent;
|
private System.Windows.Forms.ToolStripMenuItem tsmiTrayRectangleTransparent;
|
||||||
private System.Windows.Forms.ToolStripMenuItem tsmiWebpageCapture;
|
private System.Windows.Forms.ToolStripMenuItem tsmiWebpageCapture;
|
||||||
private System.Windows.Forms.ToolStripMenuItem tsmiTrayWebpageCapture;
|
private System.Windows.Forms.ToolStripMenuItem tsmiTrayWebpageCapture;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem tsmiTrayToggleHotkeys;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -558,6 +558,7 @@ private void LoadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
|
UpdateToggleHotkeyButton();
|
||||||
|
|
||||||
TaskbarManager.Enabled = Program.Settings.TaskbarProgressEnabled;
|
TaskbarManager.Enabled = Program.Settings.TaskbarProgressEnabled;
|
||||||
}
|
}
|
||||||
|
@ -790,6 +791,21 @@ private void UpdateMenu()
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateToggleHotkeyButton()
|
||||||
|
{
|
||||||
|
// TODO: Translate
|
||||||
|
if (Program.Settings.DisableHotkeys)
|
||||||
|
{
|
||||||
|
tsmiTrayToggleHotkeys.Text = "Enable hotkeys";
|
||||||
|
tsmiTrayToggleHotkeys.Image = Resources.keyboard__plus;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tsmiTrayToggleHotkeys.Text = "Disable hotkeys";
|
||||||
|
tsmiTrayToggleHotkeys.Image = Resources.keyboard__minus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Form events
|
#region Form events
|
||||||
|
|
||||||
protected override void SetVisibleCore(bool value)
|
protected override void SetVisibleCore(bool value)
|
||||||
|
@ -1060,6 +1076,11 @@ private void tsbHotkeySettings_Click(object sender, EventArgs e)
|
||||||
Program.HotkeysConfig.SaveAsync(Program.HotkeysConfigFilePath);
|
Program.HotkeysConfig.SaveAsync(Program.HotkeysConfigFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tsmiTrayToggleHotkeys_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
TaskHelpers.ToggleHotkeys();
|
||||||
|
}
|
||||||
|
|
||||||
private void tsbDestinationSettings_Click(object sender, EventArgs e)
|
private void tsbDestinationSettings_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Program.UploadersConfig == null)
|
if (Program.UploadersConfig == null)
|
||||||
|
@ -1489,7 +1510,15 @@ private void HandleHotkeys(HotkeySettings hotkeySetting)
|
||||||
|
|
||||||
if (hotkeySetting.TaskSettings.Job != HotkeyType.None)
|
if (hotkeySetting.TaskSettings.Job != HotkeyType.None)
|
||||||
{
|
{
|
||||||
ExecuteJob(hotkeySetting.TaskSettings);
|
if (hotkeySetting.TaskSettings.Job == HotkeyType.DisableHotkeys)
|
||||||
|
{
|
||||||
|
TaskHelpers.ToggleHotkeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Program.Settings.DisableHotkeys)
|
||||||
|
{
|
||||||
|
ExecuteJob(hotkeySetting.TaskSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1419,6 +1419,12 @@
|
||||||
<data name="tsmiTrayHotkeySettings.Text" xml:space="preserve">
|
<data name="tsmiTrayHotkeySettings.Text" xml:space="preserve">
|
||||||
<value>Hotkey settings...</value>
|
<value>Hotkey settings...</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="tsmiTrayToggleHotkeys.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>188, 22</value>
|
||||||
|
</data>
|
||||||
|
<data name="tsmiTrayToggleHotkeys.Text" xml:space="preserve">
|
||||||
|
<value>Disable hotkeys</value>
|
||||||
|
</data>
|
||||||
<data name="tssTray2.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="tssTray2.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>185, 6</value>
|
<value>185, 6</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -1477,7 +1483,7 @@
|
||||||
<value>Exit</value>
|
<value>Exit</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cmsTray.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="cmsTray.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>189, 418</value>
|
<value>189, 440</value>
|
||||||
</data>
|
</data>
|
||||||
<data name=">>cmsTray.Name" xml:space="preserve">
|
<data name=">>cmsTray.Name" xml:space="preserve">
|
||||||
<value>cmsTray</value>
|
<value>cmsTray</value>
|
||||||
|
@ -2547,6 +2553,12 @@
|
||||||
<data name=">>tsmiTrayHotkeySettings.Type" xml:space="preserve">
|
<data name=">>tsmiTrayHotkeySettings.Type" xml:space="preserve">
|
||||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name=">>tsmiTrayToggleHotkeys.Name" xml:space="preserve">
|
||||||
|
<value>tsmiTrayToggleHotkeys</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>tsmiTrayToggleHotkeys.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
<data name=">>tssTray2.Name" xml:space="preserve">
|
<data name=">>tssTray2.Name" xml:space="preserve">
|
||||||
<value>tssTray2</value>
|
<value>tssTray2</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
20
ShareX/Properties/Resources.Designer.cs
generated
20
ShareX/Properties/Resources.Designer.cs
generated
|
@ -949,6 +949,26 @@ public static System.Drawing.Bitmap keyboard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Bitmap keyboard__minus {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("keyboard__minus", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Bitmap keyboard__plus {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("keyboard__plus", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -727,4 +727,10 @@ Would you like to restart ShareX?</value>
|
||||||
<data name="document_globe" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="document_globe" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\document-globe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\document-globe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="keyboard__minus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\keyboard--minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="keyboard__plus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\keyboard--plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
ShareX/Resources/keyboard--minus.png
Normal file
BIN
ShareX/Resources/keyboard--minus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 513 B |
BIN
ShareX/Resources/keyboard--plus.png
Normal file
BIN
ShareX/Resources/keyboard--plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 599 B |
|
@ -930,6 +930,8 @@
|
||||||
<None Include="Resources\es.png" />
|
<None Include="Resources\es.png" />
|
||||||
<None Include="Resources\nl.png" />
|
<None Include="Resources\nl.png" />
|
||||||
<None Include="Resources\document-globe.png" />
|
<None Include="Resources\document-globe.png" />
|
||||||
|
<None Include="Resources\keyboard--minus.png" />
|
||||||
|
<None Include="Resources\keyboard--plus.png" />
|
||||||
<Content Include="ShareX_Icon.ico" />
|
<Content Include="ShareX_Icon.ico" />
|
||||||
<None Include="Resources\globe--pencil.png" />
|
<None Include="Resources\globe--pencil.png" />
|
||||||
<None Include="Resources\camcorder--pencil.png" />
|
<None Include="Resources\camcorder--pencil.png" />
|
||||||
|
|
|
@ -757,5 +757,23 @@ public static EDataType FindDataType(string filePath, TaskSettings taskSettings)
|
||||||
|
|
||||||
return EDataType.File;
|
return EDataType.File;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool ToggleHotkeys()
|
||||||
|
{
|
||||||
|
bool result = !Program.Settings.DisableHotkeys;
|
||||||
|
Program.Settings.DisableHotkeys = result;
|
||||||
|
|
||||||
|
Program.MainForm.UpdateToggleHotkeyButton();
|
||||||
|
|
||||||
|
if (Program.MainForm.niTray.Visible)
|
||||||
|
{
|
||||||
|
Program.MainForm.niTray.Tag = null;
|
||||||
|
// TODO: Translate
|
||||||
|
string balloonTipText = result ? "Hotkeys disabled." : "Hotkeys enabled.";
|
||||||
|
Program.MainForm.niTray.ShowBalloonTip(3000, "ShareX", balloonTipText, ToolTipIcon.Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue