bool dlgStartupShowModal() { LogFormat("Startup dialog"); logo = new LogoView(); wf = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(), Layout::landscape ? _T("IDR_XML_STARTUP_L") : _T("IDR_XML_STARTUP")); assert(wf != NULL); WndProperty* wp = ((WndProperty *)wf->FindByName(_T("prpProfile"))); assert(wp != NULL); DataFieldFileReader* dfe = (DataFieldFileReader*)wp->GetDataField(); assert(dfe != NULL); dfe->ScanDirectoryTop(_T("*.prf")); if (dfe->GetNumFiles() <= 1) { SelectProfile(dfe->GetPathFile()); delete wf; delete logo; return true; } unsigned best_index = 0; uint64_t best_timestamp = 0; unsigned length = dfe->size(); for (unsigned i = 0; i < length; ++i) { const TCHAR *path = dfe->GetItem(i); uint64_t timestamp = File::GetLastModification(path); if (timestamp > best_timestamp) { best_timestamp = timestamp; best_index = i; } } dfe->Set(best_index); wp->RefreshDisplay(); if (wf->ShowModal() != mrOK) { delete wf; delete logo; return false; } SelectProfile(dfe->GetPathFile()); delete wf; delete logo; return true; }
bool dlgStartupShowModal() { LogFormat("Startup dialog"); /* scan all profile files */ DataFieldFileReader *dfe = new DataFieldFileReader(); dfe->ScanDirectoryTop(_T("*.prf")); /* skip this dialog if there is only one (or none) */ if (dfe->GetNumFiles() <= 1) { SelectProfile(dfe->GetPathFile()); delete dfe; return true; } /* preselect the most recently used profile */ unsigned best_index = 0; uint64_t best_timestamp = 0; unsigned length = dfe->size(); for (unsigned i = 0; i < length; ++i) { const TCHAR *path = dfe->GetItem(i); uint64_t timestamp = File::GetLastModification(path); if (timestamp > best_timestamp) { best_timestamp = timestamp; best_index = i; } } dfe->Set(best_index); /* show the dialog */ const DialogLook &look = UIGlobals::GetDialogLook(); WidgetDialog dialog(look); TwoWidgets widget(new LogoQuitWidget(look.button, dialog), new StartupWidget(look, dialog, dfe)); dialog.CreateFull(UIGlobals::GetMainWindow(), _T(""), &widget); const int result = dialog.ShowModal(); dialog.StealWidget(); return result == mrOK; }