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.
This commit is contained in:
james.k.crook@gmail.com 2014-10-10 15:36:51 +00:00
parent 66b3eb3d71
commit 221474e37a
4 changed files with 45 additions and 14 deletions

View File

@ -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();

View File

@ -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 ){

View File

@ -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.

View File

@ -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();
}