summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-07-17 15:22:07 +0000
committersr55 <[email protected]>2009-07-17 15:22:07 +0000
commita8acbe50c4fef4efd39d83e8052f1012fae7232a (patch)
tree0d87d8041fb84248c45325ee47f9616f6f16becb /win
parent69faa2de07f1d0e488830ebec3fcc9b52fad6b99 (diff)
WinGui:
- Option to set an External SRT as default. - Import preset now adds the preset to the preset list. Includes a few UI/QueryGenerator.cs fixes for this. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2703 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/C#/Controls/Subtitles.Designer.cs20
-rw-r--r--win/C#/Controls/Subtitles.cs25
-rw-r--r--win/C#/Functions/QueryGenerator.cs17
-rw-r--r--win/C#/Presets/PresetsHandler.cs1
-rw-r--r--win/C#/frmAddPreset.cs4
-rw-r--r--win/C#/frmMain.cs23
6 files changed, 78 insertions, 12 deletions
diff --git a/win/C#/Controls/Subtitles.Designer.cs b/win/C#/Controls/Subtitles.Designer.cs
index bbef36333..26584ec99 100644
--- a/win/C#/Controls/Subtitles.Designer.cs
+++ b/win/C#/Controls/Subtitles.Designer.cs
@@ -65,6 +65,7 @@
this.srt_lang = new System.Windows.Forms.ComboBox();
this.btn_srtAdd = new System.Windows.Forms.Button();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
+ this.check_default_srt = new System.Windows.Forms.CheckBox();
this.SubTitlesGroup.SuspendLayout();
this.subMenu.SuspendLayout();
this.tabControl1.SuspendLayout();
@@ -311,6 +312,7 @@
// SRTGroup
//
this.SRTGroup.BackColor = System.Drawing.Color.Transparent;
+ this.SRTGroup.Controls.Add(this.check_default_srt);
this.SRTGroup.Controls.Add(this.srt_offset);
this.SRTGroup.Controls.Add(this.label5);
this.SRTGroup.Controls.Add(this.srt_browse);
@@ -338,7 +340,7 @@
// label5
//
this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(486, 23);
+ this.label5.Location = new System.Drawing.Point(555, 23);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(27, 13);
this.label5.TabIndex = 78;
@@ -349,9 +351,9 @@
this.srt_browse.BackColor = System.Drawing.Color.Transparent;
this.srt_browse.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.srt_browse.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
- this.srt_browse.Location = new System.Drawing.Point(519, 18);
+ this.srt_browse.Location = new System.Drawing.Point(588, 18);
this.srt_browse.Name = "srt_browse";
- this.srt_browse.Size = new System.Drawing.Size(111, 23);
+ this.srt_browse.Size = new System.Drawing.Size(67, 23);
this.srt_browse.TabIndex = 77;
this.srt_browse.Text = "Browse";
this.srt_browse.UseVisualStyleBackColor = false;
@@ -454,6 +456,17 @@
this.openFileDialog.DefaultExt = "srt";
this.openFileDialog.Filter = "SRT Files |*.srt";
//
+ // check_default_srt
+ //
+ this.check_default_srt.AutoSize = true;
+ this.check_default_srt.Location = new System.Drawing.Point(470, 22);
+ this.check_default_srt.Name = "check_default_srt";
+ this.check_default_srt.Size = new System.Drawing.Size(61, 17);
+ this.check_default_srt.TabIndex = 80;
+ this.check_default_srt.Text = "Default";
+ this.check_default_srt.UseVisualStyleBackColor = true;
+ this.check_default_srt.CheckedChanged += new System.EventHandler(this.check_default_srt_CheckedChanged);
+ //
// Subtitles
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -519,5 +532,6 @@
internal System.Windows.Forms.ComboBox srt_lang;
private System.Windows.Forms.NumericUpDown srt_offset;
private System.Windows.Forms.OpenFileDialog openFileDialog;
+ private System.Windows.Forms.CheckBox check_default_srt;
}
}
diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs
index 48a6f3c7a..c785cdeb6 100644
--- a/win/C#/Controls/Subtitles.cs
+++ b/win/C#/Controls/Subtitles.cs
@@ -103,12 +103,19 @@ namespace Handbrake.Controls
}
private void btn_srtAdd_Click(object sender, EventArgs e)
{
+ string defaultSub = "No";
+ if (check_default_srt.Checked)
+ {
+ defaultSub = "Yes";
+ setNoDefault();
+ }
+
ListViewItem newTrack = new ListViewItem(getNewID().ToString());
newTrack.SubItems.Add(srt_lang.SelectedItem + ", (" + srt_charcode.SelectedItem + ")");
newTrack.SubItems.Add("No");
newTrack.SubItems.Add("No");
- newTrack.SubItems.Add("No");
+ newTrack.SubItems.Add(defaultSub);
if (openFileDialog.FileName != null)
newTrack.SubItems.Add(openFileDialog.FileName);
else
@@ -138,6 +145,8 @@ namespace Handbrake.Controls
int.TryParse(lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[6].Text, out offsetVal);
srt_offset.Value = offsetVal;
+ check_default_srt.CheckState = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text == "Yes" ? CheckState.Checked : CheckState.Unchecked;
+
SRTGroup.Text = "Selected Track: " + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text;
SubTitlesGroup.Text = "Selected Track: None";
}
@@ -154,7 +163,7 @@ namespace Handbrake.Controls
drp_subtitleTracks.SelectedItem = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[1];
check_forced.CheckState = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[2].Text == "Yes" ? CheckState.Checked : CheckState.Unchecked;
- check_burned.CheckState = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[3].Text == "Yes" ? CheckState.Checked : CheckState.Unchecked;
+ check_burned.CheckState = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[3].Text == "Yes" ? CheckState.Checked : CheckState.Unchecked;
check_default.CheckState = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text == "Yes" ? CheckState.Checked : CheckState.Unchecked;
SubTitlesGroup.Text = "Selected Track: " + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text;
@@ -211,6 +220,18 @@ namespace Handbrake.Controls
lv_subList.Select();
}
}
+ private void check_default_srt_CheckedChanged(object sender, EventArgs e)
+ {
+ // Update an item in the list if required.
+ if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0)
+ {
+ if (check_default_srt.Checked) // Make sure we only have 1 default track
+ setNoDefault();
+
+ lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text = check_default_srt.Checked ? "Yes" : "No";
+ lv_subList.Select();
+ }
+ }
// SRT Controls
private void srt_offset_ValueChanged(object sender, EventArgs e)
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
index a6c59ee81..ed2b3b2d6 100644
--- a/win/C#/Functions/QueryGenerator.cs
+++ b/win/C#/Functions/QueryGenerator.cs
@@ -28,7 +28,7 @@ namespace Handbrake.Functions
if (mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")
query = " -i " + '"' + mainWindow.sourcePath + '"';
- if (mainWindow.drp_dvdtitle.Text != "Automatic")
+ if (mainWindow.drp_dvdtitle.Text != "")
{
string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');
query += " -t " + titleInfo[0];
@@ -38,11 +38,11 @@ namespace Handbrake.Functions
if (mainWindow.drop_angle.Items.Count != 0)
query += " --angle " + mainWindow.drop_angle.SelectedItem;
- if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "Auto")
+ if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")
query += " -c " + mainWindow.drop_chapterStart.Text;
else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;
- else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
+ else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")
query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;
// Destination tab
@@ -398,7 +398,9 @@ namespace Handbrake.Functions
string srtFile = String.Empty;
string srtCodeset = String.Empty;
string srtOffset = String.Empty;
- string srtLang = String.Empty;
+ string srtLang = String.Empty;
+ string srtDefault = String.Empty;
+ int srtCount = 0;
foreach (ListViewItem item in mainWindow.Subtitles.lv_subList.Items)
{
@@ -406,6 +408,7 @@ namespace Handbrake.Functions
if (item.SubItems.Count != 5) // We have an SRT file
{
+ srtCount++; // SRT track id.
string[] trackData = item.SubItems[1].Text.Split(',');
if (trackData != null)
{
@@ -415,7 +418,9 @@ namespace Handbrake.Functions
srtLang += srtLang == "" ? realLangCode : "," + realLangCode;
srtCodeset += srtCodeset == "" ? charCode : "," + charCode;
}
-
+ if (item.SubItems[4].Text == "Yes") // default
+ srtDefault = srtCount.ToString();
+
itemToAdd = item.SubItems[5].Text;
srtFile += srtFile == "" ? itemToAdd : "," + itemToAdd;
@@ -486,6 +491,8 @@ namespace Handbrake.Functions
query += " --srt-offset " + srtOffset;
if (srtLang != "")
query += " --srt-lang " + srtLang;
+ if (srtDefault != "")
+ query += " --subtitle-default " + srtDefault;
}
}
diff --git a/win/C#/Presets/PresetsHandler.cs b/win/C#/Presets/PresetsHandler.cs
index 616154534..52e13a354 100644
--- a/win/C#/Presets/PresetsHandler.cs
+++ b/win/C#/Presets/PresetsHandler.cs
@@ -37,7 +37,6 @@ namespace Handbrake.Presets
updateUserPresetsFile();
return true;
}
- MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
diff --git a/win/C#/frmAddPreset.cs b/win/C#/frmAddPreset.cs
index ca726c09b..0ddba9a62 100644
--- a/win/C#/frmAddPreset.cs
+++ b/win/C#/frmAddPreset.cs
@@ -37,6 +37,10 @@ namespace Handbrake
//frmMainWindow.loadPresetPanel();
this.Close();
+ }
+ else
+ {
+ MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 3076ae67a..a25aa5633 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -373,7 +373,28 @@ namespace Handbrake
if (openPreset.ShowDialog() == DialogResult.OK)
{
QueryParser parsed = imp.importMacPreset(openPreset.FileName);
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
+ if (presetHandler.checkIfUserPresetExists(parsed.PresetName + " (Imported)"))
+ {
+ DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+ if (result == DialogResult.Yes)
+ {
+ PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
+ presetHandler.updatePreset(parsed.PresetName + " (Imported)", queryGen.generateTheQuery(this),
+ parsed.UsesPictureSettings);
+ }
+ }
+ else
+ {
+ PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
+ presetHandler.addPreset(parsed.PresetName, queryGen.generateTheQuery(this), parsed.UsesPictureSettings);
+
+ if (presetHandler.addPreset(parsed.PresetName + " (Imported)", queryGen.generateTheQuery(this), parsed.UsesPictureSettings))
+ {
+ TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };
+ treeView_presets.Nodes.Add(preset_treeview);
+ }
+ }
}
}
private void btn_new_preset_Click(object sender, EventArgs e)