mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
If settings save fail balloon tip clicked then debug log window will open
This commit is contained in:
parent
430e9dab55
commit
e3e54bf720
7 changed files with 92 additions and 20 deletions
39
ShareX/BalloonTipAction.cs
Normal file
39
ShareX/BalloonTipAction.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2019 ShareX Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class BalloonTipAction
|
||||
{
|
||||
public BalloonTipClickAction ClickAction { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -297,4 +297,11 @@ public enum StartupState
|
|||
EnabledByPolicy = StartupTaskState.EnabledByPolicy
|
||||
}
|
||||
#endif
|
||||
|
||||
public enum BalloonTipClickAction
|
||||
{
|
||||
None,
|
||||
OpenURL,
|
||||
OpenDebugLog
|
||||
}
|
||||
}
|
|
@ -1752,19 +1752,7 @@ private void tsbImageHistory_Click(object sender, EventArgs e)
|
|||
|
||||
private void tsmiShowDebugLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
DebugForm form = DebugForm.GetFormInstance(DebugHelper.Logger);
|
||||
if (!form.HasUploadRequested)
|
||||
{
|
||||
form.UploadRequested += (text) =>
|
||||
{
|
||||
DialogResult result = MessageBox.Show(form, Resources.MainForm_UploadDebugLogWarning, "ShareX", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
UploadManager.UploadText(text);
|
||||
}
|
||||
};
|
||||
}
|
||||
form.ForceActivate();
|
||||
TaskHelpers.OpenDebugLog();
|
||||
}
|
||||
|
||||
private void tsmiTestImageUpload_Click(object sender, EventArgs e)
|
||||
|
@ -1860,11 +1848,19 @@ private void niTray_MouseDoubleClick(object sender, MouseEventArgs e)
|
|||
|
||||
private void niTray_BalloonTipClicked(object sender, EventArgs e)
|
||||
{
|
||||
string url = niTray.Tag as string;
|
||||
BalloonTipAction action = niTray.Tag as BalloonTipAction;
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
if (action != null)
|
||||
{
|
||||
URLHelpers.OpenURL(url);
|
||||
switch (action.ClickAction)
|
||||
{
|
||||
case BalloonTipClickAction.OpenURL:
|
||||
URLHelpers.OpenURL(action.Text);
|
||||
break;
|
||||
case BalloonTipClickAction.OpenDebugLog:
|
||||
TaskHelpers.OpenDebugLog();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,12 @@ private static void Settings_SettingsSaveFailed(Exception e)
|
|||
message = e.Message;
|
||||
}
|
||||
|
||||
TaskHelpers.ShowBalloonTip(message, ToolTipIcon.Warning, 5000, "ShareX failed to save settings");
|
||||
BalloonTipAction action = new BalloonTipAction()
|
||||
{
|
||||
ClickAction = BalloonTipClickAction.OpenDebugLog
|
||||
};
|
||||
|
||||
TaskHelpers.ShowBalloonTip(message, ToolTipIcon.Warning, 5000, "ShareX failed to save settings", action);
|
||||
|
||||
settingsSaveFailWarningCount++;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
</When>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="BalloonTipAction.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureActiveMonitor.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureActiveWindow.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureBase.cs" />
|
||||
|
|
|
@ -772,6 +772,24 @@ public static void OpenImageHistory()
|
|||
imageHistoryForm.Show();
|
||||
}
|
||||
|
||||
public static void OpenDebugLog()
|
||||
{
|
||||
DebugForm form = DebugForm.GetFormInstance(DebugHelper.Logger);
|
||||
|
||||
if (!form.HasUploadRequested)
|
||||
{
|
||||
form.UploadRequested += text =>
|
||||
{
|
||||
if (MessageBox.Show(form, Resources.MainForm_UploadDebugLogWarning, "ShareX", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
||||
{
|
||||
UploadManager.UploadText(text);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
form.ForceActivate();
|
||||
}
|
||||
|
||||
public static void ShowScreenColorPickerDialog(TaskSettings taskSettings = null)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
@ -1765,11 +1783,11 @@ public static bool CheckQRCodeContent(string content)
|
|||
return !string.IsNullOrEmpty(content) && Encoding.UTF8.GetByteCount(content) <= 2952;
|
||||
}
|
||||
|
||||
public static void ShowBalloonTip(string text, ToolTipIcon icon, int timeout, string title = "ShareX", string tag = null)
|
||||
public static void ShowBalloonTip(string text, ToolTipIcon icon, int timeout, string title = "ShareX", BalloonTipAction clickAction = null)
|
||||
{
|
||||
if (Program.MainForm != null && !Program.MainForm.IsDisposed && Program.MainForm.niTray != null && Program.MainForm.niTray.Visible)
|
||||
{
|
||||
Program.MainForm.niTray.Tag = tag;
|
||||
Program.MainForm.niTray.Tag = clickAction;
|
||||
Program.MainForm.niTray.ShowBalloonTip(timeout, title, text, icon);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -418,8 +418,14 @@ private static void task_TaskCompleted(WorkerTask task)
|
|||
switch (info.TaskSettings.GeneralSettings.PopUpNotification)
|
||||
{
|
||||
case PopUpNotificationType.BalloonTip:
|
||||
BalloonTipAction action = new BalloonTipAction()
|
||||
{
|
||||
ClickAction = BalloonTipClickAction.OpenURL,
|
||||
Text = result
|
||||
};
|
||||
|
||||
TaskHelpers.ShowBalloonTip(result, ToolTipIcon.Info, 5000,
|
||||
"ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed, result);
|
||||
"ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed, action);
|
||||
break;
|
||||
case PopUpNotificationType.ToastNotification:
|
||||
task.KeepImage = true;
|
||||
|
|
Loading…
Reference in a new issue