Audacity  2.3.1
Classes | Functions | Variables
AudacityApp.h File Reference
#include "Audacity.h"
#include "MemoryX.h"
#include <wx/app.h>
#include <wx/cmdline.h>
#include <wx/dir.h>
#include <wx/event.h>
#include <wx/docview.h>
#include <wx/intl.h>
#include <wx/snglinst.h>
#include <wx/log.h>
#include <wx/socket.h>
#include <wx/timer.h>
#include "widgets/FileHistory.h"
#include "ondemand/ODTaskThread.h"
#include "Experimental.h"

Go to the source code of this file.

Classes

class  AudacityApp
 AudacityApp is the 'main' class for Audacity. More...
 

Functions

void SaveWindowSize ()
 
void QuitAudacity (bool bForce)
 
void QuitAudacity ()
 
 DECLARE_EXPORTED_EVENT_TYPE (AUDACITY_DLL_API, EVT_OPEN_AUDIO_FILE,-1)
 
AudacityAppwxGetApp ()
 

Variables

bool gIsQuitting
 

Function Documentation

DECLARE_EXPORTED_EVENT_TYPE ( AUDACITY_DLL_API  ,
EVT_OPEN_AUDIO_FILE  ,
1 
)
void QuitAudacity ( bool  bForce)

Definition at line 269 of file AudacityApp.cpp.

References AppQuiting, CloseScoreAlignDialog(), CloseScreenshotTools(), AudacityProject::DeleteClipboard(), ModuleManager::Dispatch(), gAudacityProjects, ModuleManager::Get(), ODManager::Quit(), and SaveWindowSize().

Referenced by AudacityApp::OnInit(), AudacityApp::OnMenuExit(), and QuitAudacity().

270 {
271  if (gIsQuitting)
272  return;
273 
274  gIsQuitting = true;
275 
276  wxTheApp->SetExitOnFrameDelete(true);
277 
278  // Try to close each open window. If the user hits Cancel
279  // in a Save Changes dialog, don't continue.
280  // BG: unless force is true
281 
282  // BG: Are there any projects open?
283  //- if (!gAudacityProjects.IsEmpty())
284 /*start+*/
285  if (gAudacityProjects.empty())
286  {
287 #ifdef __WXMAC__
289 #endif
290  }
291  else
292 /*end+*/
293  {
294  SaveWindowSize();
295  while (gAudacityProjects.size())
296  {
297  // Closing the project has global side-effect
298  // of deletion from gAudacityProjects
299  if (bForce)
300  {
301  gAudacityProjects[0]->Close(true);
302  }
303  else
304  {
305  if (!gAudacityProjects[0]->Close())
306  {
307  gIsQuitting = false;
308  return;
309  }
310  }
311  }
312  }
313 
315 
316 #ifdef EXPERIMENTAL_SCOREALIGN
318 #endif
320 
321  //release ODManager Threads
322  ODManager::Quit();
323 
324  //print out profile if we have one by deleting it
325  //temporarilly commented out till it is added to all projects
326  //DELETE Profiler::Instance();
327 
328  //remove our logger
329  std::unique_ptr<wxLog>{ wxLog::SetActiveTarget(NULL) }; // DELETE
330 
331  if (bForce)
332  {
333  wxExit();
334  }
335 }
static ModuleManager & Get()
static void Quit()
Kills the ODMananger Thread.
Definition: ODManager.cpp:363
void SaveWindowSize()
AProjectArray gAudacityProjects
Definition: Project.cpp:307
int Dispatch(ModuleDispatchTypes type)
void CloseScreenshotTools()
Definition: Screenshot.cpp:127
void CloseScoreAlignDialog()
bool gIsQuitting
static void DeleteClipboard()
Definition: Project.cpp:4806
void QuitAudacity ( )

Definition at line 337 of file AudacityApp.cpp.

References QuitAudacity().

338 {
339  QuitAudacity(false);
340 }
void QuitAudacity(bool bForce)
void SaveWindowSize ( )

Definition at line 342 of file AudacityApp.cpp.

References gAudacityProjects, GetDefaultWindowRect(), AudacityProject::GetNormalizedWindowState(), gPrefs, AudacityApp::SetWindowRectAlreadySaved(), and wxGetApp().

Referenced by AudacityProject::OnCloseWindow(), and QuitAudacity().

343 {
344  if (wxGetApp().GetWindowRectAlreadySaved())
345  {
346  return;
347  }
348  bool validWindowForSaveWindowSize = FALSE;
349  AudacityProject * validProject = NULL;
350  bool foundIconizedProject = FALSE;
351  size_t numProjects = gAudacityProjects.size();
352  for (size_t i = 0; i < numProjects; i++)
353  {
354  if (!gAudacityProjects[i]->IsIconized()) {
355  validWindowForSaveWindowSize = TRUE;
356  validProject = gAudacityProjects[i].get();
357  i = numProjects;
358  }
359  else
360  foundIconizedProject = TRUE;
361 
362  }
363  if (validWindowForSaveWindowSize)
364  {
365  wxRect windowRect = validProject->GetRect();
366  wxRect normalRect = validProject->GetNormalizedWindowState();
367  bool wndMaximized = validProject->IsMaximized();
368  gPrefs->Write(wxT("/Window/X"), windowRect.GetX());
369  gPrefs->Write(wxT("/Window/Y"), windowRect.GetY());
370  gPrefs->Write(wxT("/Window/Width"), windowRect.GetWidth());
371  gPrefs->Write(wxT("/Window/Height"), windowRect.GetHeight());
372  gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
373  gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
374  gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
375  gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
376  gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
377  gPrefs->Write(wxT("/Window/Iconized"), FALSE);
378  }
379  else
380  {
381  if (foundIconizedProject) {
382  validProject = gAudacityProjects[0].get();
383  bool wndMaximized = validProject->IsMaximized();
384  wxRect normalRect = validProject->GetNormalizedWindowState();
385  // store only the normal rectangle because the itemized rectangle
386  // makes no sense for an opening project window
387  gPrefs->Write(wxT("/Window/X"), normalRect.GetX());
388  gPrefs->Write(wxT("/Window/Y"), normalRect.GetY());
389  gPrefs->Write(wxT("/Window/Width"), normalRect.GetWidth());
390  gPrefs->Write(wxT("/Window/Height"), normalRect.GetHeight());
391  gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
392  gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
393  gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
394  gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
395  gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
396  gPrefs->Write(wxT("/Window/Iconized"), TRUE);
397  }
398  else {
399  // this would be a very strange case that might possibly occur on the Mac
400  // Audacity would have to be running with no projects open
401  // in this case we are going to write only the default values
402  wxRect defWndRect;
403  GetDefaultWindowRect(&defWndRect);
404  gPrefs->Write(wxT("/Window/X"), defWndRect.GetX());
405  gPrefs->Write(wxT("/Window/Y"), defWndRect.GetY());
406  gPrefs->Write(wxT("/Window/Width"), defWndRect.GetWidth());
407  gPrefs->Write(wxT("/Window/Height"), defWndRect.GetHeight());
408  gPrefs->Write(wxT("/Window/Maximized"), FALSE);
409  gPrefs->Write(wxT("/Window/Normal_X"), defWndRect.GetX());
410  gPrefs->Write(wxT("/Window/Normal_Y"), defWndRect.GetY());
411  gPrefs->Write(wxT("/Window/Normal_Width"), defWndRect.GetWidth());
412  gPrefs->Write(wxT("/Window/Normal_Height"), defWndRect.GetHeight());
413  gPrefs->Write(wxT("/Window/Iconized"), FALSE);
414  }
415  }
416  gPrefs->Flush();
418 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AProjectArray gAudacityProjects
Definition: Project.cpp:307
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:175
void SetWindowRectAlreadySaved(bool alreadySaved)
Definition: AudacityApp.h:157
void GetDefaultWindowRect(wxRect *defRect)
Definition: Project.cpp:627
wxRect GetNormalizedWindowState() const
Definition: Project.h:711
AudacityApp & wxGetApp()
AudacityApp& wxGetApp ( )

Variable Documentation

bool gIsQuitting