From 6a2e47339a1dd65c4866c1d907f6b74565953e02 Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 30 Sep 2009 14:39:12 +0000 Subject: [PATCH] WinGui: - Add a notice to the log to indicate if the user has used a custom query. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2854 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/EncodeQueue/EncodeAndQueueHandler.cs | 15 +++++++++------ win/C#/EncodeQueue/Job.cs | 7 +++++++ win/C#/frmActivityWindow.cs | 14 ++++++++------ win/C#/frmMain.cs | 8 +++++--- win/C#/frmQueue.cs | 2 +- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/win/C#/EncodeQueue/EncodeAndQueueHandler.cs b/win/C#/EncodeQueue/EncodeAndQueueHandler.cs index 93cab845a..f2a4eaedf 100644 --- a/win/C#/EncodeQueue/EncodeAndQueueHandler.cs +++ b/win/C#/EncodeQueue/EncodeAndQueueHandler.cs @@ -82,9 +82,10 @@ namespace Handbrake.EncodeQueue /// The query that will be passed to the HandBrake CLI. /// The location of the source video. /// The location where the encoded video will be. - public void AddJob(string query, string source, string destination) + /// + public void AddJob(string query, string source, string destination, bool customJob) { - Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination }; + Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination, CustomQuery = customJob }; queue.Add(newJob); WriteQueueStateToFile("hb_queue_recovery.xml"); @@ -306,7 +307,8 @@ namespace Handbrake.EncodeQueue // Run through each item on the queue while (this.Count != 0) { - string query = GetNextJob().Query; + Job encJob = GetNextJob(); + string query = encJob.Query; WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file RunCli(query); @@ -316,7 +318,7 @@ namespace Handbrake.EncodeQueue hbProcess.WaitForExit(); - AddCLIQueryToLog(query); + AddCLIQueryToLog(encJob); CopyLog(LastEncode.Destination); hbProcess.Close(); @@ -469,7 +471,7 @@ namespace Handbrake.EncodeQueue /// Append the CLI query to the start of the log file. /// /// - private static void AddCLIQueryToLog(string query) + private static void AddCLIQueryToLog(Job encJob) { string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; string logPath = Path.Combine(logDir, "last_encode_log.txt"); @@ -480,7 +482,8 @@ namespace Handbrake.EncodeQueue StreamWriter writer = new StreamWriter(File.Create(logPath)); - writer.Write("### CLI Query: " + query + "\n\n"); + writer.Write("### CLI Query: " + encJob.Query + "\n\n"); + writer.Write("### User Query: " + encJob.CustomQuery + "\n\n"); writer.Write("#########################################\n\n"); writer.WriteLine(log); writer.Flush(); diff --git a/win/C#/EncodeQueue/Job.cs b/win/C#/EncodeQueue/Job.cs index e912fd65a..7dfe7e518 100644 --- a/win/C#/EncodeQueue/Job.cs +++ b/win/C#/EncodeQueue/Job.cs @@ -4,6 +4,8 @@ Homepage: . It may be used under the terms of the GNU General Public License. */ +using System; + namespace Handbrake.EncodeQueue { public struct Job @@ -18,6 +20,11 @@ namespace Handbrake.EncodeQueue /// public string Query { get; set; } + /// + /// record if this is a user or GUI generated query + /// + public Boolean CustomQuery { get; set; } + /// /// Gets or sets the source file of encoding. /// diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 9509500a6..9f9f41128 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -74,11 +74,6 @@ namespace Handbrake rtf_actLog.AppendText(String.Format("### Install Dir: {0} \n", Application.StartupPath)); rtf_actLog.AppendText(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath)); rtf_actLog.AppendText("#########################################\n\n"); - if ((!_encodeQueue.LastEncode.IsEmpty) && _encodeQueue.LastEncode.Query != String.Empty) - { - rtf_actLog.AppendText("### CLI Query: " + _encodeQueue.LastEncode.Query + "\n\n"); - rtf_actLog.AppendText("#########################################\n\n"); - } // Seutp the log file if (scan) @@ -90,6 +85,13 @@ namespace Handbrake { _readFile = "last_encode_log.txt"; txt_log.Text = "Encode Log"; + if (_encodeQueue.isEncoding) + if ((!_encodeQueue.LastEncode.IsEmpty) && _encodeQueue.LastEncode.Query != String.Empty) + { + rtf_actLog.AppendText("### CLI Query: " + _encodeQueue.LastEncode.Query + "\n"); + rtf_actLog.AppendText("### Custom Query: " + _encodeQueue.LastEncode.CustomQuery + "\n\n"); + rtf_actLog.AppendText("#########################################\n\n"); + } } _lastUpdate = false; } @@ -184,7 +186,7 @@ namespace Handbrake fileNotFoundQuickFix = true; return "\n\n\nERROR: The log file could not be found. \nMaybe you cleared your system's tempory folder or maybe you just havn't run an encode yet. \nTried to find the log file in: " + logFile; } - + StreamReader sr = new StreamReader(logFile2); string line; int i = 1; diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 4e3a73ff9..2be9b168b 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -729,7 +729,7 @@ namespace Handbrake if (overwrite == DialogResult.Yes) { if (encodeQueue.Count == 0) - encodeQueue.AddJob(query, sourcePath, text_destination.Text); + encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != "")); queueWindow.setQueue(); if (encodeQueue.Count > 1) @@ -764,11 +764,11 @@ namespace Handbrake DialogResult result = MessageBox.Show("There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) - encodeQueue.AddJob(query, sourcePath, text_destination.Text); + encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != "")); } else - encodeQueue.AddJob(query, sourcePath, text_destination.Text); + encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != "")); lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue"; @@ -806,6 +806,8 @@ namespace Handbrake if (ActivityWindow == null) ActivityWindow = new frmActivityWindow(file, encodeQueue, this); + ActivityWindow.SetLogView(!encodeQueue.isEncoding); + ActivityWindow.Show(); } #endregion diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index e110a470e..352978960 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -379,7 +379,7 @@ namespace Handbrake { if (!queue.LastEncode.IsEmpty) { - queue.AddJob(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination); + queue.AddJob(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination, queue.LastEncode.CustomQuery); updateUIElements(); } } -- 2.40.0