From 221474e37a1fe0216f11f0bd7b80914836bc1623 Mon Sep 17 00:00:00 2001 From: "james.k.crook@gmail.com" Date: Fri, 10 Oct 2014 15:36:51 +0000 Subject: [PATCH] Fixed bugs with MultiDialog. Fixed Bug with prompting about modules. Previously MultiDialog attempted to centre on parent dialog, but there was a NULL parent. Now the application top window is used. Dialog shows centred, for example when there are missing block files. If the top window is a WX_STAY_ON_TOP, we move our dialog to the left, as otherwise it would be partially hidden. Previously Audacity would ask about enabling a module whilst the splash screen was showing. For some as yet undetermined reason the MultiDialog and Splash Screen are incompatible. Possibly it's related to doing a ShowModal before a full application exists. The not ideal workaround is to now delay showing the splash screen until after the modules have been loaded. --- src/AudacityApp.cpp | 25 +++++++++++++++++++------ src/LoadModules.cpp | 2 +- src/prefs/ModulePrefs.cpp | 2 ++ src/widgets/MultiDialog.cpp | 30 +++++++++++++++++++++++------- 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index e1876a8a5..96c97efdf 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1167,10 +1167,24 @@ bool AudacityApp::OnInit() mLocale = NULL; InitLang( lang ); + + + //JKC We'd like to initialise the module manager WHILE showing the splash screen. + //Can't as MultiDialog interacts poorly with the splash screen. So we do it before. + //TODO: Find out why opening a multidialog wrecks the splash screen. + //best current guess is that it's something to do with doing a DoModal this early + //in the program. + + // Initialize the CommandHandler + InitCommandHandler(); + // Initialize the ModuleManager, including loading found modules + ModuleManager::Initialize(*mCmdHandler); + // BG: Create a temporary window to set as the top window wxImage logoimage((const char **) AudacityLogoWithName_xpm); logoimage.Rescale(logoimage.GetWidth() / 2, logoimage.GetHeight() / 2); wxBitmap logo(logoimage); + wxSplashScreen *temporarywindow = new wxSplashScreen(logo, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, @@ -1183,11 +1197,8 @@ bool AudacityApp::OnInit() temporarywindow->SetTitle(_("Audacity is starting up...")); SetTopWindow(temporarywindow); - // Initialize the CommandHandler - InitCommandHandler(); - // Initialize the ModuleManager, including loading found modules - ModuleManager::Initialize(*mCmdHandler); + // Init DirManager, which initializes the temp directory // If this fails, we must exit the program. @@ -1234,9 +1245,9 @@ bool AudacityApp::OnInit() SetExitOnFrameDelete(true); + AudacityProject *project = CreateNewAudacityProject(); mCmdHandler->SetProject(project); - wxWindow * pWnd = MakeHijackPanel() ; if( pWnd ) { @@ -1246,9 +1257,11 @@ bool AudacityApp::OnInit() pWnd->Show( true ); } - temporarywindow->Show( false ); + + temporarywindow->Show(false); delete temporarywindow; + if( project->mShowSplashScreen ) project->OnHelpWelcome(); diff --git a/src/LoadModules.cpp b/src/LoadModules.cpp index 42a5eae8b..2ddc694ef 100644 --- a/src/LoadModules.cpp +++ b/src/LoadModules.cpp @@ -245,7 +245,7 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler) msg += _("\n\nOnly use modules from trusted sources"); const wxChar *buttons[] = {_("Yes"), _("No"), NULL}; // could add a button here for 'yes and remember that', and put it into the cfg file. Needs more thought. int action; - action = ShowMultiDialog(msg, _("Module Loader"), buttons, _("Try and load this module?"), false); + action = ShowMultiDialog(msg, _("Audacity Module Loader"), buttons, _("Try and load this module?"), false); #ifdef EXPERIMENTAL_MODULE_PREFS // If we're not prompting always, accept the answer permanantly if( iModuleStatus == kModuleNew ){ diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index 2135d2999..eb977128a 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -47,6 +47,8 @@ void ModulePrefs::GetAllModuleStatuses(){ // mod-script-pipe // mod-nyq-bench // mod-track-panel + // mod-menu-munger + // mod-theming // TODO: On an Audacity upgrade we should (?) actually untick modules. // The old modules might be still around, and we do not want to use them. diff --git a/src/widgets/MultiDialog.cpp b/src/widgets/MultiDialog.cpp index 376df5405..8477b1657 100644 --- a/src/widgets/MultiDialog.cpp +++ b/src/widgets/MultiDialog.cpp @@ -36,7 +36,8 @@ for each problem encountered, since there can be many orphans. class MultiDialog : public wxDialog { public: - MultiDialog(wxString message, + MultiDialog(wxWindow * pParent, + wxString message, wxString title, const wxChar **buttons, wxString boxMsg, bool log); ~MultiDialog() {}; @@ -57,10 +58,11 @@ BEGIN_EVENT_TABLE(MultiDialog, wxDialog) EVT_BUTTON(ID_SHOW_LOG_BUTTON, MultiDialog::OnShowLog) END_EVENT_TABLE() -MultiDialog::MultiDialog(wxString message, +MultiDialog::MultiDialog(wxWindow * pParent, + wxString message, wxString title, const wxChar **buttons, wxString boxMsg, bool log) - : wxDialog(NULL, (wxWindowID)-1, title, + : wxDialog(pParent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION) // not wxDEFAULT_DIALOG_STYLE because we don't want wxCLOSE_BOX and wxSYSTEM_MENU { @@ -140,11 +142,25 @@ void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event)) int ShowMultiDialog(wxString message, - wxString title, - const wxChar **buttons, wxString boxMsg, bool log) + wxString title, + const wxChar **buttons, wxString boxMsg, bool log) { - MultiDialog dlog(message, title, buttons, boxMsg, log); - dlog.CentreOnParent(); + wxWindow * pParent = wxGetApp().GetTopWindow(); + if (pParent) { + if ((pParent->GetWindowStyle() & wxSTAY_ON_TOP) == wxSTAY_ON_TOP) + pParent = NULL; + } + MultiDialog dlog(pParent, + message, title, buttons, boxMsg, log); + // If dialog does not have a parent, cannot be centred on it. + if (pParent != NULL) + dlog.CentreOnParent(); + else { + dlog.CenterOnScreen(); + wxPoint Pos = dlog.GetPosition() + wxPoint(-300, -10); + dlog.Move(Pos); + dlog; + } return dlog.ShowModal(); }