mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-28 22:28:44 +02:00
Move SaveWindowSize to Project.cpp & it no longer needs AudacityApp.h
This commit is contained in:
parent
d4b0fd1b83
commit
187e3be0d6
@ -292,7 +292,6 @@ void QuitAudacity(bool bForce)
|
|||||||
else
|
else
|
||||||
/*end+*/
|
/*end+*/
|
||||||
{
|
{
|
||||||
SaveWindowSize();
|
|
||||||
bool closedAll = AllProjects::Close( bForce );
|
bool closedAll = AllProjects::Close( bForce );
|
||||||
if ( !closedAll )
|
if ( !closedAll )
|
||||||
{
|
{
|
||||||
@ -329,84 +328,6 @@ void QuitAudacity()
|
|||||||
QuitAudacity(false);
|
QuitAudacity(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveWindowSize()
|
|
||||||
{
|
|
||||||
if (wxGetApp().GetWindowRectAlreadySaved())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bool validWindowForSaveWindowSize = FALSE;
|
|
||||||
AudacityProject * validProject = NULL;
|
|
||||||
bool foundIconizedProject = FALSE;
|
|
||||||
size_t numProjects = gAudacityProjects.size();
|
|
||||||
for (size_t i = 0; i < numProjects; i++)
|
|
||||||
{
|
|
||||||
if (!gAudacityProjects[i]->IsIconized()) {
|
|
||||||
validWindowForSaveWindowSize = TRUE;
|
|
||||||
validProject = gAudacityProjects[i].get();
|
|
||||||
i = numProjects;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
foundIconizedProject = TRUE;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (validWindowForSaveWindowSize)
|
|
||||||
{
|
|
||||||
wxRect windowRect = validProject->GetRect();
|
|
||||||
wxRect normalRect = validProject->GetNormalizedWindowState();
|
|
||||||
bool wndMaximized = validProject->IsMaximized();
|
|
||||||
gPrefs->Write(wxT("/Window/X"), windowRect.GetX());
|
|
||||||
gPrefs->Write(wxT("/Window/Y"), windowRect.GetY());
|
|
||||||
gPrefs->Write(wxT("/Window/Width"), windowRect.GetWidth());
|
|
||||||
gPrefs->Write(wxT("/Window/Height"), windowRect.GetHeight());
|
|
||||||
gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
|
|
||||||
gPrefs->Write(wxT("/Window/Iconized"), FALSE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (foundIconizedProject) {
|
|
||||||
validProject = gAudacityProjects[0].get();
|
|
||||||
bool wndMaximized = validProject->IsMaximized();
|
|
||||||
wxRect normalRect = validProject->GetNormalizedWindowState();
|
|
||||||
// store only the normal rectangle because the itemized rectangle
|
|
||||||
// makes no sense for an opening project window
|
|
||||||
gPrefs->Write(wxT("/Window/X"), normalRect.GetX());
|
|
||||||
gPrefs->Write(wxT("/Window/Y"), normalRect.GetY());
|
|
||||||
gPrefs->Write(wxT("/Window/Width"), normalRect.GetWidth());
|
|
||||||
gPrefs->Write(wxT("/Window/Height"), normalRect.GetHeight());
|
|
||||||
gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
|
|
||||||
gPrefs->Write(wxT("/Window/Iconized"), TRUE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// this would be a very strange case that might possibly occur on the Mac
|
|
||||||
// Audacity would have to be running with no projects open
|
|
||||||
// in this case we are going to write only the default values
|
|
||||||
wxRect defWndRect;
|
|
||||||
GetDefaultWindowRect(&defWndRect);
|
|
||||||
gPrefs->Write(wxT("/Window/X"), defWndRect.GetX());
|
|
||||||
gPrefs->Write(wxT("/Window/Y"), defWndRect.GetY());
|
|
||||||
gPrefs->Write(wxT("/Window/Width"), defWndRect.GetWidth());
|
|
||||||
gPrefs->Write(wxT("/Window/Height"), defWndRect.GetHeight());
|
|
||||||
gPrefs->Write(wxT("/Window/Maximized"), FALSE);
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_X"), defWndRect.GetX());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Y"), defWndRect.GetY());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Width"), defWndRect.GetWidth());
|
|
||||||
gPrefs->Write(wxT("/Window/Normal_Height"), defWndRect.GetHeight());
|
|
||||||
gPrefs->Write(wxT("/Window/Iconized"), FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gPrefs->Flush();
|
|
||||||
wxGetApp().SetWindowRectAlreadySaved(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__WXGTK__) && defined(HAVE_GTK)
|
#if defined(__WXGTK__) && defined(HAVE_GTK)
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1532,8 +1453,6 @@ bool AudacityApp::OnInit()
|
|||||||
|
|
||||||
ModuleManager::Get().Dispatch(AppInitialized);
|
ModuleManager::Get().Dispatch(AppInitialized);
|
||||||
|
|
||||||
mWindowRectAlreadySaved = FALSE;
|
|
||||||
|
|
||||||
mTimer.SetOwner(this, kAudacityAppTimerID);
|
mTimer.SetOwner(this, kAudacityAppTimerID);
|
||||||
mTimer.Start(200);
|
mTimer.Start(200);
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ class AppCommandEvent;
|
|||||||
class AudacityLogger;
|
class AudacityLogger;
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
|
||||||
void SaveWindowSize();
|
|
||||||
|
|
||||||
void QuitAudacity(bool bForce);
|
void QuitAudacity(bool bForce);
|
||||||
void QuitAudacity();
|
void QuitAudacity();
|
||||||
|
|
||||||
@ -98,9 +96,6 @@ class AudacityApp final : public wxApp {
|
|||||||
void AssociateFileTypes();
|
void AssociateFileTypes();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool GetWindowRectAlreadySaved()const {return mWindowRectAlreadySaved;}
|
|
||||||
void SetWindowRectAlreadySaved(bool alreadySaved) {mWindowRectAlreadySaved = alreadySaved;}
|
|
||||||
|
|
||||||
AudacityLogger *GetLogger();
|
AudacityLogger *GetLogger();
|
||||||
|
|
||||||
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
||||||
@ -128,8 +123,6 @@ class AudacityApp final : public wxApp {
|
|||||||
|
|
||||||
std::unique_ptr<wxCmdLineParser> ParseCommandLine();
|
std::unique_ptr<wxCmdLineParser> ParseCommandLine();
|
||||||
|
|
||||||
bool mWindowRectAlreadySaved;
|
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
std::unique_ptr<IPCServ> mIPCServ;
|
std::unique_ptr<IPCServ> mIPCServ;
|
||||||
#else
|
#else
|
||||||
|
@ -99,7 +99,6 @@ scroll information. It also has some status flags.
|
|||||||
#include "FreqWindow.h"
|
#include "FreqWindow.h"
|
||||||
#include "effects/Contrast.h"
|
#include "effects/Contrast.h"
|
||||||
#include "AutoRecovery.h"
|
#include "AutoRecovery.h"
|
||||||
#include "AudacityApp.h"
|
|
||||||
#include "AColor.h"
|
#include "AColor.h"
|
||||||
#include "AudioIO.h"
|
#include "AudioIO.h"
|
||||||
#include "BatchProcessDialog.h"
|
#include "BatchProcessDialog.h"
|
||||||
@ -174,10 +173,13 @@ scroll information. It also has some status flags.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool AllProjects::sbClosing = false;
|
bool AllProjects::sbClosing = false;
|
||||||
|
bool AllProjects::sbWindowRectAlreadySaved = false;
|
||||||
|
|
||||||
bool AllProjects::Close( bool force )
|
bool AllProjects::Close( bool force )
|
||||||
{
|
{
|
||||||
ValueRestorer<bool> cleanup{ sbClosing, true };
|
ValueRestorer<bool> cleanup{ sbClosing, true };
|
||||||
|
if (gAudacityProjects.size())
|
||||||
|
SaveWindowSize();
|
||||||
while (gAudacityProjects.size())
|
while (gAudacityProjects.size())
|
||||||
{
|
{
|
||||||
// Closing the project has global side-effect
|
// Closing the project has global side-effect
|
||||||
@ -195,6 +197,84 @@ bool AllProjects::Close( bool force )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AllProjects::SaveWindowSize()
|
||||||
|
{
|
||||||
|
if (sbWindowRectAlreadySaved)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool validWindowForSaveWindowSize = FALSE;
|
||||||
|
AudacityProject * validProject = NULL;
|
||||||
|
bool foundIconizedProject = FALSE;
|
||||||
|
size_t numProjects = gAudacityProjects.size();
|
||||||
|
for (size_t i = 0; i < numProjects; i++)
|
||||||
|
{
|
||||||
|
if (!gAudacityProjects[i]->IsIconized()) {
|
||||||
|
validWindowForSaveWindowSize = TRUE;
|
||||||
|
validProject = gAudacityProjects[i].get();
|
||||||
|
i = numProjects;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
foundIconizedProject = TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (validWindowForSaveWindowSize)
|
||||||
|
{
|
||||||
|
wxRect windowRect = validProject->GetRect();
|
||||||
|
wxRect normalRect = validProject->GetNormalizedWindowState();
|
||||||
|
bool wndMaximized = validProject->IsMaximized();
|
||||||
|
gPrefs->Write(wxT("/Window/X"), windowRect.GetX());
|
||||||
|
gPrefs->Write(wxT("/Window/Y"), windowRect.GetY());
|
||||||
|
gPrefs->Write(wxT("/Window/Width"), windowRect.GetWidth());
|
||||||
|
gPrefs->Write(wxT("/Window/Height"), windowRect.GetHeight());
|
||||||
|
gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
|
||||||
|
gPrefs->Write(wxT("/Window/Iconized"), FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (foundIconizedProject) {
|
||||||
|
validProject = gAudacityProjects[0].get();
|
||||||
|
bool wndMaximized = validProject->IsMaximized();
|
||||||
|
wxRect normalRect = validProject->GetNormalizedWindowState();
|
||||||
|
// store only the normal rectangle because the itemized rectangle
|
||||||
|
// makes no sense for an opening project window
|
||||||
|
gPrefs->Write(wxT("/Window/X"), normalRect.GetX());
|
||||||
|
gPrefs->Write(wxT("/Window/Y"), normalRect.GetY());
|
||||||
|
gPrefs->Write(wxT("/Window/Width"), normalRect.GetWidth());
|
||||||
|
gPrefs->Write(wxT("/Window/Height"), normalRect.GetHeight());
|
||||||
|
gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
|
||||||
|
gPrefs->Write(wxT("/Window/Iconized"), TRUE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// this would be a very strange case that might possibly occur on the Mac
|
||||||
|
// Audacity would have to be running with no projects open
|
||||||
|
// in this case we are going to write only the default values
|
||||||
|
wxRect defWndRect;
|
||||||
|
GetDefaultWindowRect(&defWndRect);
|
||||||
|
gPrefs->Write(wxT("/Window/X"), defWndRect.GetX());
|
||||||
|
gPrefs->Write(wxT("/Window/Y"), defWndRect.GetY());
|
||||||
|
gPrefs->Write(wxT("/Window/Width"), defWndRect.GetWidth());
|
||||||
|
gPrefs->Write(wxT("/Window/Height"), defWndRect.GetHeight());
|
||||||
|
gPrefs->Write(wxT("/Window/Maximized"), FALSE);
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_X"), defWndRect.GetX());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Y"), defWndRect.GetY());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Width"), defWndRect.GetWidth());
|
||||||
|
gPrefs->Write(wxT("/Window/Normal_Height"), defWndRect.GetHeight());
|
||||||
|
gPrefs->Write(wxT("/Window/Iconized"), FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gPrefs->Flush();
|
||||||
|
sbWindowRectAlreadySaved = true;
|
||||||
|
}
|
||||||
|
|
||||||
ODLock &AudacityProject::AllProjectDeleteMutex()
|
ODLock &AudacityProject::AllProjectDeleteMutex()
|
||||||
{
|
{
|
||||||
static ODLock theMutex;
|
static ODLock theMutex;
|
||||||
@ -2581,7 +2661,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
|
|||||||
//
|
//
|
||||||
// LL: Save before doing anything else to the window that might make
|
// LL: Save before doing anything else to the window that might make
|
||||||
// its size change.
|
// its size change.
|
||||||
SaveWindowSize();
|
AllProjects::SaveWindowSize();
|
||||||
|
|
||||||
mIsDeleting = true;
|
mIsDeleting = true;
|
||||||
|
|
||||||
@ -2707,7 +2787,8 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
|
|||||||
QuitAudacity();
|
QuitAudacity();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxGetApp().SetWindowRectAlreadySaved(FALSE);
|
AllProjects::Reset();
|
||||||
|
// For non-Mac, always keep at least one project window open
|
||||||
CreateNewAudacityProject();
|
CreateNewAudacityProject();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -157,11 +157,14 @@ public:
|
|||||||
// But if return is false, that means the user cancelled close of at least
|
// But if return is false, that means the user cancelled close of at least
|
||||||
// one un-saved project.
|
// one un-saved project.
|
||||||
static bool Close( bool force = false );
|
static bool Close( bool force = false );
|
||||||
|
static void SaveWindowSize();
|
||||||
|
|
||||||
static bool Closing() { return sbClosing; }
|
static bool Closing() { return sbClosing; }
|
||||||
|
static void Reset() { sbWindowRectAlreadySaved = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool sbClosing;
|
static bool sbClosing;
|
||||||
|
static bool sbWindowRectAlreadySaved;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EffectPlugs;
|
class EffectPlugs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user