Audacity  2.2.2
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 268 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().

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

Definition at line 336 of file AudacityApp.cpp.

References QuitAudacity().

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

Definition at line 341 of file AudacityApp.cpp.

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

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

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

Variable Documentation

bool gIsQuitting