Fixed #4 - added ui setting for setting path to VLC portable

This commit is contained in:
niksedk 2014-03-16 19:11:36 +01:00
parent 0c38223f08
commit 3c1f83f617
6 changed files with 142 additions and 12 deletions

View File

@ -191,6 +191,7 @@
this.checkBoxSpellCheckOneLetterWords = new System.Windows.Forms.CheckBox();
this.checkBoxSpellCheckAutoChangeNames = new System.Windows.Forms.CheckBox();
this.groupBoxFixCommonErrors = new System.Windows.Forms.GroupBox();
this.checkBoxFixShortDisplayTimesAllowMoveStartTime = new System.Windows.Forms.CheckBox();
this.checkBoxFixCommonOcrErrorsUsingHardcodedRules = new System.Windows.Forms.CheckBox();
this.comboBoxToolsMusicSymbol = new System.Windows.Forms.ComboBox();
this.textBoxMusicSymbolsToReplace = new System.Windows.Forms.TextBox();
@ -273,7 +274,9 @@
this.fontDialogSSAStyle = new System.Windows.Forms.FontDialog();
this.labelStatus = new System.Windows.Forms.Label();
this.openFileDialogFFMPEG = new System.Windows.Forms.OpenFileDialog();
this.checkBoxFixShortDisplayTimesAllowMoveStartTime = new System.Windows.Forms.CheckBox();
this.buttonVlcPathBrowse = new System.Windows.Forms.Button();
this.textBoxVlcPath = new System.Windows.Forms.TextBox();
this.labelVlcPath = new System.Windows.Forms.Label();
this.tabControlSettings.SuspendLayout();
this.tabPageGenerel.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
@ -352,6 +355,7 @@
this.buttonCancel.TabIndex = 1;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// tabControlSettings
//
@ -1672,6 +1676,9 @@
//
// groupBoxVideoEngine
//
this.groupBoxVideoEngine.Controls.Add(this.buttonVlcPathBrowse);
this.groupBoxVideoEngine.Controls.Add(this.textBoxVlcPath);
this.groupBoxVideoEngine.Controls.Add(this.labelVlcPath);
this.groupBoxVideoEngine.Controls.Add(this.labelVideoPlayerVLC);
this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerVLC);
this.groupBoxVideoEngine.Controls.Add(this.labelVideoPlayerMPlayer);
@ -2189,6 +2196,16 @@
this.groupBoxFixCommonErrors.TabStop = false;
this.groupBoxFixCommonErrors.Text = "Fix common errors";
//
// checkBoxFixShortDisplayTimesAllowMoveStartTime
//
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.AutoSize = true;
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Location = new System.Drawing.Point(15, 138);
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Name = "checkBoxFixShortDisplayTimesAllowMoveStartTime";
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Size = new System.Drawing.Size(252, 17);
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.TabIndex = 35;
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Text = "Fix short display time - allow move of start time";
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.UseVisualStyleBackColor = true;
//
// checkBoxFixCommonOcrErrorsUsingHardcodedRules
//
this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.AutoSize = true;
@ -3180,15 +3197,32 @@
//
this.openFileDialogFFMPEG.FileName = "openFileDialog1";
//
// checkBoxFixShortDisplayTimesAllowMoveStartTime
// buttonVlcPathBrowse
//
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.AutoSize = true;
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Location = new System.Drawing.Point(15, 138);
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Name = "checkBoxFixShortDisplayTimesAllowMoveStartTime";
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Size = new System.Drawing.Size(252, 17);
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.TabIndex = 35;
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Text = "Fix short display time - allow move of start time";
this.checkBoxFixShortDisplayTimesAllowMoveStartTime.UseVisualStyleBackColor = true;
this.buttonVlcPathBrowse.Location = new System.Drawing.Point(778, 44);
this.buttonVlcPathBrowse.Name = "buttonVlcPathBrowse";
this.buttonVlcPathBrowse.Size = new System.Drawing.Size(29, 21);
this.buttonVlcPathBrowse.TabIndex = 26;
this.buttonVlcPathBrowse.Text = "...";
this.buttonVlcPathBrowse.UseVisualStyleBackColor = true;
this.buttonVlcPathBrowse.Click += new System.EventHandler(this.buttonVlcPathBrowse_Click);
//
// textBoxVlcPath
//
this.textBoxVlcPath.Location = new System.Drawing.Point(382, 45);
this.textBoxVlcPath.MaxLength = 1000;
this.textBoxVlcPath.Name = "textBoxVlcPath";
this.textBoxVlcPath.Size = new System.Drawing.Size(390, 21);
this.textBoxVlcPath.TabIndex = 25;
//
// labelVlcPath
//
this.labelVlcPath.AutoSize = true;
this.labelVlcPath.Location = new System.Drawing.Point(379, 29);
this.labelVlcPath.Name = "labelVlcPath";
this.labelVlcPath.Size = new System.Drawing.Size(315, 13);
this.labelVlcPath.TabIndex = 24;
this.labelVlcPath.Text = "VLC path (only needed if you using the portable version of VLC)";
//
// Settings
//
@ -3541,5 +3575,8 @@
private System.Windows.Forms.PictureBox pictureBoxTBFixCommonErrors;
private System.Windows.Forms.CheckBox checkBoxTBFixCommonErrors;
private System.Windows.Forms.CheckBox checkBoxFixShortDisplayTimesAllowMoveStartTime;
private System.Windows.Forms.Button buttonVlcPathBrowse;
private System.Windows.Forms.TextBox textBoxVlcPath;
private System.Windows.Forms.Label labelVlcPath;
}
}

View File

@ -1,4 +1,6 @@
using System;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -8,8 +10,6 @@ using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
namespace Nikse.SubtitleEdit.Forms
{
@ -21,6 +21,8 @@ namespace Nikse.SubtitleEdit.Forms
bool _starting = true;
private string _listBoxSearchString = string.Empty;
private DateTime _listBoxSearchStringLastUsed = DateTime.Now;
string oldVlcLocation;
string oldVlcLocationRelative;
List<string> _wordListNamesEtc = new List<string>();
List<string> _userWordList = new List<string>();
@ -36,6 +38,20 @@ namespace Nikse.SubtitleEdit.Forms
}
}
string GetRelativePath(string fileName)
{
string folder = Configuration.BaseDirectory;
if (string.IsNullOrEmpty(fileName) || !fileName.ToUpper().StartsWith(folder.Substring(0,2)))
return string.Empty;
Uri pathUri = new Uri(fileName);
if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
folder += Path.DirectorySeparatorChar;
Uri folderUri = new Uri(folder);
return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar));
}
public Settings()
{
InitializeComponent();
@ -121,6 +137,10 @@ namespace Nikse.SubtitleEdit.Forms
if (!Utilities.IsQuartsDllInstalled)
radioButtonVideoPlayerDirectShow.Enabled = false;
textBoxVlcPath.Text = Configuration.Settings.General.VlcLocation;
textBoxVlcPath.Left = labelVideoPlayerVLC.Left + labelVideoPlayerVLC.Width + 5;
textBoxVlcPath.Width = buttonVlcPathBrowse.Left - textBoxVlcPath.Left - 5;
checkBoxVideoPlayerShowStopButton.Checked = gs.VideoPlayerShowStopButton;
checkBoxVideoPlayerShowMuteButton.Checked = gs.VideoPlayerShowMuteButton;
checkBoxVideoPlayerShowFullscreenButton.Checked = gs.VideoPlayerShowFullscreenButton;
@ -306,6 +326,9 @@ namespace Nikse.SubtitleEdit.Forms
radioButtonVideoPlayerVLC.Text = language.VlcMediaPlayer;
labelVideoPlayerVLC.Text = language.VlcMediaPlayerDescription;
}
if (!string.IsNullOrEmpty(language.VlcMediaPlayer))
Configuration.Settings.General.VlcLocation = textBoxVlcPath.Text;
checkBoxVideoPlayerShowStopButton.Text = language.ShowStopButton;
checkBoxVideoPlayerShowMuteButton.Text = language.ShowMuteButton;
@ -786,6 +809,9 @@ namespace Nikse.SubtitleEdit.Forms
labelShortcutKey.Left = checkBoxShortcutsShift.Left + checkBoxShortcutsShift.Width + 9;
comboBoxShortcutKey.Left = labelShortcutKey.Left + labelShortcutKey.Width + 2;
buttonUpdateShortcut.Left = comboBoxShortcutKey.Left + comboBoxShortcutKey.Width + 15;
oldVlcLocation = Configuration.Settings.General.VlcLocation;
oldVlcLocationRelative = Configuration.Settings.General.VlcLocationRelative;
}
private string GetShortcutText(string shortcut)
@ -1044,6 +1070,9 @@ namespace Nikse.SubtitleEdit.Forms
gs.VideoPlayer = "VLC";
else
gs.VideoPlayer = "DirectShow";
gs.VlcLocation = textBoxVlcPath.Text;
gs.VideoPlayerShowStopButton = checkBoxVideoPlayerShowStopButton.Checked;
gs.VideoPlayerShowMuteButton = checkBoxVideoPlayerShowMuteButton.Checked;
gs.VideoPlayerShowFullscreenButton = checkBoxVideoPlayerShowFullscreenButton.Checked;
@ -2605,5 +2634,30 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxListViewMouseEnterFocus.Enabled = checkBoxWaveformHoverFocus.Checked;
}
private void buttonVlcPathBrowse_Click(object sender, EventArgs e)
{
openFileDialogFFMPEG.FileName = string.Empty;
openFileDialogFFMPEG.Title = Configuration.Settings.Language.Settings.WaveformBrowseToVLC;
if (!Utilities.IsRunningOnLinux() && !Utilities.IsRunningOnMac())
{
openFileDialogFFMPEG.Filter = "vlc.exe|vlc.exe";
}
if (openFileDialogFFMPEG.ShowDialog(this) == DialogResult.OK)
{
textBoxVlcPath.Text = Path.GetDirectoryName(openFileDialogFFMPEG.FileName);
Configuration.Settings.General.VlcLocation = textBoxVlcPath.Text;
Configuration.Settings.General.VlcLocationRelative = GetRelativePath(textBoxVlcPath.Text);
radioButtonVideoPlayerVLC.Enabled = LibVlc11xDynamic.IsInstalled;
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
Configuration.Settings.General.VlcLocation = oldVlcLocation;
Configuration.Settings.General.VlcLocationRelative = oldVlcLocationRelative;
DialogResult = DialogResult.Cancel;
}
}
}

View File

@ -1710,6 +1710,7 @@ can edit in same subtitle file (collaboration)",
MPlayerDescription = "MPlayer2/Mplayer",
VlcMediaPlayer = "VLC Media Player",
VlcMediaPlayerDescription = "libvlc.dll from VLC Media Player 1.1.0 or newer",
VlcBrowseToLabel = "VLC path (only needed if you using the portable version of VLC)",
ShowStopButton = "Show stop button",
ShowMuteButton = "Show mute button",
ShowFullscreenButton = "Show fullscreen button",
@ -1739,6 +1740,7 @@ can edit in same subtitle file (collaboration)",
WaveformUseFFMPEG = "Use FFMPEG for wave extraction",
WaveformFFMPEGPath = "Path to FFMPEG",
WaveformBrowseToFFMPEG = "Browse to FFMPEG",
WaveformBrowseToVLC = "Browse to VLC portable",
SubStationAlphaStyle = "(Advanced) Sub Station Alpha style",
ChooseFont = "Choose font",
ChooseColor = "Choose color",

View File

@ -1605,6 +1605,7 @@
public string MPlayerDescription { get; set; }
public string VlcMediaPlayer { get; set; }
public string VlcMediaPlayerDescription { get; set; }
public string VlcBrowseToLabel { get; set; }
public string ShowStopButton { get; set; }
public string ShowMuteButton { get; set; }
public string ShowFullscreenButton { get; set; }
@ -1634,6 +1635,7 @@
public string WaveformUseFFMPEG { get; set; }
public string WaveformFFMPEGPath { get; set; }
public string WaveformBrowseToFFMPEG { get; set; }
public string WaveformBrowseToVLC { get; set; }
public string SubStationAlphaStyle { get; set; }
public string ChooseFont { get; set; }
public string ChooseColor { get; set; }

View File

@ -484,6 +484,7 @@ namespace Nikse.SubtitleEdit.Logic
public int ListViewTextWidth { get; set; }
public string VlcWaveTranscodeSettings { get; set; }
public string VlcLocation { get; set; }
public string VlcLocationRelative { get; set; }
public bool UseFFMPEGForWaveExtraction { get; set; }
public string FFMPEGLocation { get; set; }
public bool UseTimeFormatHHMMSSFF { get; set; }
@ -1381,6 +1382,9 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("VlcLocation");
if (subNode != null)
settings.General.VlcLocation = subNode.InnerText.Trim();
subNode = node.SelectSingleNode("VlcLocationRelative");
if (subNode != null)
settings.General.VlcLocationRelative = subNode.InnerText.Trim();
subNode = node.SelectSingleNode("UseFFMPEGForWaveExtraction");
if (subNode != null)
settings.General.UseFFMPEGForWaveExtraction = Convert.ToBoolean(subNode.InnerText.Trim());
@ -2574,6 +2578,7 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("ListViewTextWidth", settings.General.ListViewTextWidth.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("VlcWaveTranscodeSettings", settings.General.VlcWaveTranscodeSettings);
textWriter.WriteElementString("VlcLocation", settings.General.VlcLocation);
textWriter.WriteElementString("VlcLocationRelative", settings.General.VlcLocationRelative);
textWriter.WriteElementString("UseFFMPEGForWaveExtraction", settings.General.UseFFMPEGForWaveExtraction.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("FFMPEGLocation", settings.General.FFMPEGLocation);
textWriter.WriteElementString("UseTimeFormatHHMMSSFF", settings.General.UseTimeFormatHHMMSSFF.ToString(CultureInfo.InvariantCulture));

View File

@ -510,11 +510,41 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocation))
{
if (Configuration.Settings.General.VlcLocation.ToUpper().EndsWith(".exe"))
Configuration.Settings.General.VlcLocation = Path.GetDirectoryName(Configuration.Settings.General.VlcLocation);
path = Path.Combine(Configuration.Settings.General.VlcLocation, fileName);
if (File.Exists(path))
return path;
}
if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocationRelative))
{
try
{
path = Configuration.Settings.General.VlcLocationRelative;
if (path.ToUpper().EndsWith(".exe"))
path = Path.GetDirectoryName(path);
path = Path.Combine(path, fileName);
string path2 = Path.GetFullPath(path);
if (File.Exists(path2))
return path2;
while (path.StartsWith(".."))
{
path = path.Remove(0, 3);
path2 = Path.GetFullPath(path);
if (File.Exists(path2))
return path2;
}
}
catch
{
}
}
// XP via registry path
var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\VideoLAN\VLC");
if (key != null)