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 ()
 
 wxDECLARE_EXPORTED_EVENT (AUDACITY_DLL_API, EVT_CLIPBOARD_CHANGE, wxCommandEvent)
 
 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 271 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().

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

Definition at line 339 of file AudacityApp.cpp.

References QuitAudacity().

340 {
341  QuitAudacity(false);
342 }
void QuitAudacity(bool bForce)
void SaveWindowSize ( )

Definition at line 344 of file AudacityApp.cpp.

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

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

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

Variable Documentation

bool gIsQuitting