|
9 | 9 | using namespace std;
|
10 | 10 | #define UPDATEEVT 2004
|
11 | 11 | #define REENABLEEVT 2005
|
| 12 | +#define EXECUTEEVT 2006 |
12 | 13 | wxDEFINE_EVENT(updateEvt, wxCommandEvent);
|
13 | 14 | wxDEFINE_EVENT(reenableEvt, wxCommandEvent);
|
| 15 | +wxDEFINE_EVENT(executeEvt, wxCommandEvent); |
14 | 16 |
|
15 | 17 | //Declare events here
|
16 | 18 | wxBEGIN_EVENT_TABLE(AddNewInstallDlg, wxDialog)
|
17 | 19 | EVT_COMMAND(UPDATEEVT, updateEvt, AddNewInstallDlg::PopulateTable)
|
18 | 20 | EVT_COMMAND(REENABLEEVT, reenableEvt, AddNewInstallDlg::Reenable)
|
| 21 | +EVT_COMMAND(EXECUTEEVT, executeEvt, AddNewInstallDlg::ExecuteProc) |
19 | 22 | EVT_BUTTON(wxID_FILE,AddNewInstallDlg::InstallSelected)
|
20 | 23 | EVT_BUTTON(INSTALLVIAHUB,AddNewInstallDlg::InstallSelectedWithHub)
|
21 | 24 | EVT_SEARCHCTRL_SEARCH_BTN(wxID_FIND,AddNewInstallDlg::Filter)
|
@@ -172,12 +175,20 @@ void AddNewInstallDlg::InstallSelected(wxCommandEvent&){
|
172 | 175 | }
|
173 | 176 | else{
|
174 | 177 | // write the file to temp location
|
175 |
| - auto outpath = fmt::format("{}{}{}{}.{}", cachedir,dirsep,"UnityDownloadAssistant",data.hashcode,installerExt); |
| 178 | + auto outpath = fmt::format("{}{}{}.{}", cachedir,"UnityDownloadAssistant",data.hashcode,installerExt); |
176 | 179 | ofstream outfile(outpath, std::ios::binary);
|
177 | 180 | outfile.write(r.text.c_str(),r.text.size());
|
178 | 181 |
|
179 | 182 | // open the file
|
180 |
| - launch_process(fmt::format("open \"{}\"", outpath)); |
| 183 | + wxCommandEvent lnevt(executeEvt); |
| 184 | +#ifdef __APPLE__ |
| 185 | + lnevt.SetString(fmt::format("open \"{}\"", outpath)); |
| 186 | +#elif defined _WIN32 |
| 187 | + lnevt.SetString(fmt::format("\"{}\"", outpath)); |
| 188 | +#endif |
| 189 | + lnevt.SetId(EXECUTEEVT); |
| 190 | + wxPostEvent(this,lnevt); |
| 191 | + |
181 | 192 | wxCommandEvent evt(reenableEvt);
|
182 | 193 | evt.SetId(REENABLEEVT);
|
183 | 194 | wxPostEvent(this, evt);
|
@@ -206,3 +217,13 @@ void AddNewInstallDlg::Reenable(wxCommandEvent &){
|
206 | 217 | installViaHubBtn->Enable();
|
207 | 218 | installBtn->SetLabel("Install Selected");
|
208 | 219 | }
|
| 220 | + |
| 221 | +void AddNewInstallDlg::ExecuteProc(wxCommandEvent& evt) |
| 222 | +{ |
| 223 | + auto cmd = evt.GetString(); |
| 224 | +#ifdef _WIN32 |
| 225 | + ShellExecute(0, 0, cmd.c_str(), NULL, 0, SW_SHOW); |
| 226 | +#else |
| 227 | + launch_process(cmd.ToStdString()); |
| 228 | +#endif |
| 229 | +} |
0 commit comments