Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit ace7af7

Browse files
committed
Now remembers if video/audiovizualizer was shown/hidden + fixed crash after a "new"
1 parent 90abd08 commit ace7af7

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

SubtitleEdit/AppDelegate.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public override void DidFinishLaunching(NSNotification notification)
5050
_mainWindowController.FindPrevious();
5151
};
5252

53-
_videoOpen.Activated += (object sender, EventArgs e) =>
53+
_videoOpen.Activated += (object sender, EventArgs e) =>
5454
{
5555
_mainWindowController.OpenVideo();
5656
};
5757

58-
_menuItemSpellCheck.Activated += (object sender, EventArgs e) =>
59-
{
60-
_mainWindowController.SpellCheckAndGrammer();
61-
};
58+
_menuItemSpellCheck.Activated += (object sender, EventArgs e) =>
59+
{
60+
_mainWindowController.SpellCheckAndGrammer();
61+
};
6262
}
6363

6464
public NSMenuItem OpenRecent { get { return _openRecent; } }

SubtitleEdit/Windows/MainWindow.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ void InitializeSubtitleTable()
158158
}
159159
};
160160

161-
162161
// drag'n'drop
163162
_subtitleTable.RegisterForDraggedTypes(new string[] { "public.data" });
164163
}
@@ -239,10 +238,12 @@ public void ShowHideAudioVisualizer()
239238
if (_audioVizBox.Hidden)
240239
{
241240
_toolbarShowAudioViz.Image = NSImage.ImageNamed("WaveformToggle.png");
241+
Configuration.Settings.General.ShowAudioVisualizer = false;
242242
}
243243
else
244244
{
245245
_toolbarShowAudioViz.Image = NSImage.ImageNamed("WaveformToggleActive.png");
246+
Configuration.Settings.General.ShowAudioVisualizer = true;
246247
}
247248
}
248249

@@ -254,10 +255,12 @@ public void ShowHideVideoPlayer()
254255
if (_videoBox.Hidden)
255256
{
256257
_toolbarShowVideo.Image = NSImage.ImageNamed("VideoToggle.png");
258+
Configuration.Settings.General.ShowVideoPlayer = false;
257259
}
258260
else
259261
{
260262
_toolbarShowVideo.Image = NSImage.ImageNamed("VideoToggleActive.png");
263+
Configuration.Settings.General.ShowVideoPlayer = true;
261264
}
262265
}
263266

@@ -354,7 +357,14 @@ public override void AwakeFromNib()
354357
_audioVisualizerView.SetFrameSize(_audioViz.Superview.Frame.Size);
355358
_audioVisualizerView.BecomeFirstResponder();
356359
_audioViz.Hidden = true;
357-
ShowHideAudioVisualizer(); //TODO: Use settings when audio visualizer has been rewritten!
360+
if (!Configuration.Settings.General.ShowAudioVisualizer)
361+
{
362+
ShowHideAudioVisualizer();
363+
}
364+
if (!Configuration.Settings.General.ShowVideoPlayer)
365+
{
366+
ShowHideVideoPlayer();
367+
}
358368
}
359369

360370
internal void ShowAddAudioVisualizer()

SubtitleEdit/Windows/MainWindowController.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ private void SetupAudioVisualizer()
6969
InvokeOnMainThread(() =>
7070
{
7171
_timerWaveform.Stop();
72+
7273
System.Threading.Thread.Sleep(100);
73-
if (_videoFileName != null)
74+
if (_videoFileName != null && _audioVisualizer != null)
7475
{
7576
int index = -1;
7677
var selectedIndices = Window.SubtitleTable.SelectedRows.ToList();
@@ -281,6 +282,16 @@ public void NewSubtitle()
281282
Window.SetEncoding(Encoding.UTF8.BodyName);
282283
Window.SubtitleText.StringValue = string.Empty;
283284
Window.SetTimeCode(new Paragraph());
285+
if (_videoPlayer != null)
286+
{
287+
_videoPlayer.DisposeVideoPlayer();
288+
}
289+
if (_audioVisualizer != null)
290+
{
291+
_audioVisualizer.WavePeaks = null;
292+
}
293+
_videoFileName = null;
294+
_audioVisualizer = null;
284295
}
285296
}
286297

@@ -361,6 +372,11 @@ public void DeleteLines()
361372

362373
public void ReloadDataKeepSelection()
363374
{
375+
if (_subtitle == null || _subtitle.Paragraphs.Count == 0)
376+
{
377+
return;
378+
}
379+
364380
var selectedIndices = Window.SubtitleTable.SelectedRows;
365381
Window.SubtitleTable.ReloadData();
366382
foreach (var index in selectedIndices)

0 commit comments

Comments
 (0)