int usbhost_release_device(int virtdev_index) { D(bug("USBHost: release_device() %d", virtdev_index)); int r; int dev_index, int_index; int port_number; dev_index = virtual_device[virtdev_index].idx_dev; int_index = virtual_device[virtdev_index].idx_interface; r = libusb_release_interface(devh[dev_index], int_index); if (r < 0) { D(bug("USBHost: Releasing interface failed")); return -1; } virtual_device[virtdev_index].connected = false; port_number = virtual_device[virtdev_index].port_number; roothub.port[port_number].busy = false; fill_port_status(port_number, virtual_device[virtdev_index].connected); if ((--number_ports_used < NUMBER_OF_PORTS)) enable_buttons(); return r; }
void additional_parts_dialog::on_remove(wxCommandEvent &) { if (m_files.empty()) return; m_lv_files->Freeze(); for (int idx = m_files.size() - 1; 0 <= idx; idx--) if (m_lv_files->IsSelected(idx)) { m_files.erase(m_files.begin() + idx, m_files.begin() + idx + 1); m_lv_files->DeleteItem(idx); } m_lv_files->Thaw(); enable_buttons(); }
void job_dialog::on_key_pressed(wxKeyEvent &evt) { if (WXK_RETURN == evt.GetKeyCode()) { EndModal(0); return; } if (1 != evt.GetKeyCode()) { // Ctrl-A evt.Skip(true); return; } int i; for (i = 0; lv_jobs->GetItemCount() > i; ++i) lv_jobs->Select(i, true); enable_buttons(lv_jobs->GetSelectedItemCount() > 0, false); }
void additional_parts_dialog::on_add(wxCommandEvent &) { wxString wildcard = wxString::Format(wxT("*.%s|*.%s|%s"), m_primary_file_name.GetExt().c_str(), m_primary_file_name.GetExt().c_str(), wxString{ ALLFILES }.c_str()); wxFileDialog dlg(this, Z("Add additional parts"), m_primary_file_name.GetPath(), wxEmptyString, wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE); if (wxID_OK != dlg.ShowModal()) return; wxArrayString paths; dlg.GetPaths(paths); if (paths.IsEmpty()) return; m_lv_files->Freeze(); std::map<wxFileName, bool> exists{ { m_primary_file_name, true } }; for (auto &file_name : m_files) exists[file_name] = true; std::vector<wxFileName> file_names_to_add; for (size_t idx = 0; paths.GetCount() > idx; ++idx) { wxFileName file_name{ paths[idx] }; if (!exists[file_name]) file_names_to_add.push_back(file_name); } mtx::sort::naturally(file_names_to_add.begin(), file_names_to_add.end()); for (auto &file_name : file_names_to_add) { m_files.push_back(file_name); create_item(m_files.size() - 1); } m_lv_files->Thaw(); enable_buttons(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); memset(names, 0x00, 100*32); // load window size QSettings settings; restoreGeometry(settings.value("Windows/mainWindowGeometry").toByteArray()); restoreState(settings.value("Windows/mainWindowState").toByteArray()); // setting default values if there was none if(!settings.contains("Settings/checkForUpdates")) settings.setValue("Settings/checkForUpdates", true); if(!settings.contains("Settings/connectOnStartup")) settings.setValue("Settings/connectOnStartup", true); if(!settings.contains("Settings/oneSetToSetThemAll")) settings.setValue("Settings/oneSetToSetThemAll", false); if(!settings.contains("Settings/keepWindowsOpen")) settings.setValue("Settings/keepWindowsOpen", false); if(!settings.contains("Settings/popupChangedWindows")) settings.setValue("Settings/popupChangedWindows", true); if(!settings.contains("Settings/defaultEffectValues")) settings.setValue("Settings/defaultEffectValues", true); // create child objects amp_ops = new Mustang(); amp = new Amplifier(this); effect1 = new Effect(this, 0); effect2 = new Effect(this, 1); effect3 = new Effect(this, 2); effect4 = new Effect(this, 3); about_window = new About(this); save = new SaveOnAmp(this); load = new LoadFromAmp(this); seffects = new SaveEffects(this); settings_win = new Settings(this); saver = new SaveToFile(this); quickpres = new QuickPresets(this); connected = false; // connect buttons to slots // connect(ui->Amplifier, SIGNAL(clicked()), amp, SLOT(show())); connect(ui->EffectButton1, SIGNAL(clicked()), effect1, SLOT(show())); connect(ui->EffectButton2, SIGNAL(clicked()), effect2, SLOT(show())); connect(ui->EffectButton3, SIGNAL(clicked()), effect3, SLOT(show())); connect(ui->EffectButton4, SIGNAL(clicked()), effect4, SLOT(show())); connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(start_amp())); connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(stop_amp())); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionAbout, SIGNAL(triggered()), about_window, SLOT(open())); connect(ui->actionSave_to_amplifier, SIGNAL(triggered()), save, SLOT(show())); connect(ui->action_Load_from_amplifier, SIGNAL(triggered()), load, SLOT(show())); connect(ui->actionSave_effects, SIGNAL(triggered()), seffects, SLOT(open())); connect(ui->actionCheck_for_Updates, SIGNAL(triggered()), this, SLOT(check_for_updates())); connect(ui->action_Options, SIGNAL(triggered()), settings_win, SLOT(show())); connect(ui->actionL_oad_from_file, SIGNAL(triggered()), this, SLOT(loadfile())); connect(ui->actionS_ave_to_file, SIGNAL(triggered()), saver, SLOT(show())); connect(ui->action_Library_view, SIGNAL(triggered()), this, SLOT(show_library())); connect(ui->action_Update_firmware, SIGNAL(triggered()), this, SLOT(update_firmware())); connect(ui->action_Default_effects, SIGNAL(triggered()), this, SLOT(show_default_effects())); connect(ui->action_Quick_presets, SIGNAL(triggered()), quickpres, SLOT(show())); // shortcuts to activate effect windows QShortcut *showfx1 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_1), this, 0, 0, Qt::ApplicationShortcut); QShortcut *showfx2 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_2), this, 0, 0, Qt::ApplicationShortcut); QShortcut *showfx3 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_3), this, 0, 0, Qt::ApplicationShortcut); QShortcut *showfx4 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_4), this, 0, 0, Qt::ApplicationShortcut); QShortcut *showamp = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_5), this, 0, 0, Qt::ApplicationShortcut); connect(showfx1, SIGNAL(activated()), this, SLOT(show_fx1())); connect(showfx2, SIGNAL(activated()), this, SLOT(show_fx2())); connect(showfx3, SIGNAL(activated()), this, SLOT(show_fx3())); connect(showfx4, SIGNAL(activated()), this, SLOT(show_fx4())); connect(showamp, SIGNAL(activated()), this, SLOT(show_amp())); // shortcuts for quick loading presets QShortcut *loadpres0 = new QShortcut(QKeySequence(Qt::Key_0), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres1 = new QShortcut(QKeySequence(Qt::Key_1), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres2 = new QShortcut(QKeySequence(Qt::Key_2), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres3 = new QShortcut(QKeySequence(Qt::Key_3), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres4 = new QShortcut(QKeySequence(Qt::Key_4), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres5 = new QShortcut(QKeySequence(Qt::Key_5), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres6 = new QShortcut(QKeySequence(Qt::Key_6), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres7 = new QShortcut(QKeySequence(Qt::Key_7), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres8 = new QShortcut(QKeySequence(Qt::Key_8), this, 0, 0, Qt::ApplicationShortcut); QShortcut *loadpres9 = new QShortcut(QKeySequence(Qt::Key_9), this, 0, 0, Qt::ApplicationShortcut); connect(loadpres0, SIGNAL(activated()), this, SLOT(load_presets0())); connect(loadpres1, SIGNAL(activated()), this, SLOT(load_presets1())); connect(loadpres2, SIGNAL(activated()), this, SLOT(load_presets2())); connect(loadpres3, SIGNAL(activated()), this, SLOT(load_presets3())); connect(loadpres4, SIGNAL(activated()), this, SLOT(load_presets4())); connect(loadpres5, SIGNAL(activated()), this, SLOT(load_presets5())); connect(loadpres6, SIGNAL(activated()), this, SLOT(load_presets6())); connect(loadpres7, SIGNAL(activated()), this, SLOT(load_presets7())); connect(loadpres8, SIGNAL(activated()), this, SLOT(load_presets8())); connect(loadpres9, SIGNAL(activated()), this, SLOT(load_presets9())); // shortcut to activate buttons QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A), this); connect(shortcut, SIGNAL(activated()), this, SLOT(enable_buttons())); // connect the functions if needed if(settings.value("Settings/checkForUpdates").toBool()) connect(this, SIGNAL(started()), this, SLOT(check_for_updates())); if(settings.value("Settings/connectOnStartup").toBool()) connect(this, SIGNAL(started()), this, SLOT(start_amp())); this->show(); this->repaint(); emit started(); }
additional_parts_dialog::additional_parts_dialog(wxWindow *parent, mmg_file_t const &file) : wxDialog(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , m_file{&file} , m_primary_file_name{m_file->file_name} , m_files{ m_file->is_playlist ? m_file->playlist_files : m_file->other_files } { SetTitle(m_file->is_playlist ? Z("View files in playlist") : Z("Additional source file parts")); // Create controls m_lv_files = new wxListView(this, ID_ADDPARTS_LV_FILES, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxSUNKEN_BORDER); m_b_add = new wxButton(this, ID_ADDPARTS_B_ADD, Z("&Add")); m_b_remove = new wxButton(this, ID_ADDPARTS_B_REMOVE, Z("&Remove")); m_b_up = new wxButton(this, ID_ADDPARTS_B_UP, Z("&Up")); m_b_down = new wxButton(this, ID_ADDPARTS_B_DOWN, Z("&Down")); m_b_sort = new wxButton(this, ID_ADDPARTS_B_SORT, Z("&Sort")); m_b_close = new wxButton(this, ID_ADDPARTS_B_CLOSE, Z("&Close")); auto *st_title = new wxStaticText(this, wxID_ANY, m_file->is_playlist ? Z("View files in playlist") : Z("Edit additional source file parts")); auto *st_primary_file_name = new wxStaticText(this, wxID_ANY, Z("Primary file name:")); auto *st_directory = new wxStaticText(this, wxID_ANY, Z("Directory:")); wxString text; if (m_file->is_playlist) { text = wxString( Z("The following list shows the files that make up this playlist.") ) + wxT(" ") + Z("This list is for informational purposes only and cannot be changed."); } else { text = wxString( Z("The following parts are read after the primary file as if they were all part of one big file.") ) + wxT(" ") + Z("Typical use cases include reading VOBs from a DVD (e.g. VTS_01_1.VOB, VTS_01_2.VOB, VTS_01_3.VOB)."); } auto *st_additional_parts = new wxStaticText(this, wxID_ANY, wxString{ format_paragraph(to_wide(text), 0, L"", L"", 80) }.Strip()); auto *sl_title = new wxStaticLine(this); auto *tc_primary_file_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); auto *tc_directory = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); // Setup controls wxListItem column_item; column_item.SetMask(wxLIST_MASK_TEXT); column_item.SetText(Z("File name")); m_lv_files->InsertColumn(0, column_item); column_item.SetText(Z("Directory")); m_lv_files->InsertColumn(1, column_item); auto dummy = m_lv_files->InsertItem(0, wxT("some long file name dummy.mkv")); m_lv_files->SetItem(dummy, 1, wxT("and the path is even longer but hey such is life")); m_lv_files->SetColumnWidth(0, wxLIST_AUTOSIZE); m_lv_files->SetColumnWidth(1, wxLIST_AUTOSIZE); m_lv_files->DeleteItem(0); repopulate(); tc_primary_file_name->SetValue(m_primary_file_name.GetFullName()); tc_directory->SetValue(m_primary_file_name.GetPath()); enable_buttons(); // Create layout auto *siz_all = new wxBoxSizer(wxVERTICAL); siz_all->Add(st_title, 0, wxALL, 5); siz_all->Add(sl_title, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); auto *siz_primary_file_name = new wxFlexGridSizer(2, 2, 5, 5); siz_primary_file_name->AddGrowableCol(1); siz_primary_file_name->Add(st_primary_file_name); siz_primary_file_name->Add(tc_primary_file_name, 0, wxGROW); siz_primary_file_name->Add(st_directory); siz_primary_file_name->Add(tc_directory, 0, wxGROW); siz_all->Add(siz_primary_file_name, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); siz_all->Add(st_additional_parts, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); auto *siz_buttons = new wxBoxSizer(wxVERTICAL); siz_buttons->Add(m_b_add, 0, wxBOTTOM, 5); siz_buttons->Add(m_b_remove, 0, wxBOTTOM, 15); siz_buttons->Add(m_b_up, 0, wxBOTTOM, 5); siz_buttons->Add(m_b_down, 0, wxBOTTOM, 15); siz_buttons->Add(m_b_sort, 0, wxBOTTOM, 0); siz_buttons->AddStretchSpacer(); siz_buttons->Add(m_b_close); auto *siz_controls = new wxBoxSizer(wxHORIZONTAL); siz_controls->Add(m_lv_files, 1, wxGROW); siz_controls->Add(siz_buttons, 0, wxGROW | wxLEFT, 5); siz_all->Add(siz_controls, 1, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); SetSizerAndFit(siz_all); siz_all->SetSizeHints(this); SetSize(wxSize(700, 400)); // Run ShowModal(); }
void additional_parts_dialog::on_item_selected(wxListEvent &) { enable_buttons(); }
void job_dialog::on_item_selected(wxListEvent &) { enable_buttons(lv_jobs->GetSelectedItemCount() > 0, lv_jobs->GetSelectedItemCount() < lv_jobs->GetItemCount()); }
job_dialog::job_dialog(wxWindow *parent) : wxDialog(parent, -1, Z("Job queue management"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX) , m_geometry_saver{this, "job_dialog"} { wxBoxSizer *siz_all = new wxBoxSizer(wxVERTICAL); siz_all->Add(new wxStaticText(this, -1, Z("Current and past jobs:")), 0, wxALIGN_LEFT | wxALL, 10); lv_jobs = new jobdlg_list_view(this, ID_JOBS_LV_JOBS); wxListItem item; item.m_mask = wxLIST_MASK_TEXT; item.m_text = Z("ID"); item.m_image = -1; lv_jobs->InsertColumn(0, item); item.m_text = Z("Status"); lv_jobs->InsertColumn(1, item); item.m_text = Z("Description"); lv_jobs->InsertColumn(2, item); item.m_text = Z("Added on"); lv_jobs->InsertColumn(3, item); item.m_text = Z("Started on"); lv_jobs->InsertColumn(4, item); item.m_text = Z("Finished on"); lv_jobs->InsertColumn(5, item); size_t i; for (i = 0; i < jobs.size(); i++) create_list_item(i); long dummy = lv_jobs->InsertItem(0, wxT("12345")); lv_jobs->SetItem(dummy, 1, Z("aborted")); lv_jobs->SetItem(dummy, 2, wxT("2004-05-06 07:08:09")); lv_jobs->SetItem(dummy, 3, wxT("2004-05-06 07:08:09")); lv_jobs->SetItem(dummy, 4, wxT("2004-05-06 07:08:09")); lv_jobs->SetItem(dummy, 5, wxT("2004-05-06 07:08:09")); for (i = 0; i < 6; i++) lv_jobs->SetColumnWidth(i, wxLIST_AUTOSIZE); lv_jobs->DeleteItem(0); wxBoxSizer *siz_line = new wxBoxSizer(wxHORIZONTAL); siz_line->Add(lv_jobs, 1, wxGROW | wxRIGHT, 10); wxBoxSizer *siz_b_right = new wxBoxSizer(wxVERTICAL); b_up = new wxButton(this, ID_JOBS_B_UP, Z("&Up")); b_up->SetToolTip(TIP("Move the selected jobs up")); siz_b_right->Add(b_up, 0, wxGROW | wxLEFT | wxBOTTOM, 10); b_down = new wxButton(this, ID_JOBS_B_DOWN, Z("&Down")); b_down->SetToolTip(TIP("Move the selected jobs down")); siz_b_right->Add(b_down, 0, wxGROW | wxLEFT | wxBOTTOM, 10); siz_b_right->AddSpacer(15); b_reenable = new wxButton(this, ID_JOBS_B_REENABLE, Z("&Re-enable")); b_reenable->SetToolTip(TIP("Re-enable the selected jobs")); siz_b_right->Add(b_reenable, 0, wxGROW | wxLEFT | wxBOTTOM, 10); b_disable = new wxButton(this, ID_JOBS_B_DISABLE, Z("&Disable")); b_disable->SetToolTip(TIP("Disable the selected jobs and set their status to 'done'")); siz_b_right->Add(b_disable, 0, wxGROW | wxLEFT | wxBOTTOM, 10); siz_b_right->AddSpacer(15); b_delete = new wxButton(this, ID_JOBS_B_DELETE, Z("D&elete")); b_delete->SetToolTip(TIP("Delete the selected jobs from the job queue")); siz_b_right->Add(b_delete, 0, wxGROW | wxLEFT | wxBOTTOM, 10); siz_b_right->AddSpacer(15); b_view_log = new wxButton(this, ID_JOBS_B_VIEW_LOG, Z("&View log")); b_view_log->SetToolTip(TIP("View the output that mkvmerge generated during the muxing process for the selected jobs")); siz_b_right->Add(b_view_log, 0, wxGROW | wxLEFT, 10); siz_line->Add(siz_b_right, 0, 0, 0); siz_all->Add(siz_line, 1, wxGROW | wxLEFT | wxRIGHT, 10); siz_all->Add(new wxStaticLine(this, -1), 0, wxGROW | wxALL, 10); wxBoxSizer *siz_b_bottom = new wxBoxSizer(wxHORIZONTAL); b_ok = new wxButton(this, wxID_OK, Z("&Ok")); b_ok->SetDefault(); siz_b_bottom->Add(b_ok, 0, 0, 0); siz_b_bottom->Add(1, 0, 1, wxGROW, 0); b_start = new wxButton(this, ID_JOBS_B_START, Z("&Start")); b_start->SetToolTip(TIP("Start the jobs whose status is 'pending'")); siz_b_bottom->Add(b_start, 0, wxGROW | wxRIGHT, 10); siz_b_bottom->Add(10, 0, 0, 0, 0); b_start_selected = new wxButton(this, ID_JOBS_B_START_SELECTED, Z("S&tart selected")); b_start_selected->SetToolTip(TIP("Start the selected jobs regardless of their status")); siz_b_bottom->Add(b_start_selected, 0, wxGROW | wxLEFT, 10); siz_all->Add(siz_b_bottom, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 10); siz_all->SetSizeHints(this); SetSizerAndFit(siz_all); m_geometry_saver.set_default_size(800, 500, true).restore(); enable_buttons(false); b_start->Enable(!jobs.empty()); ShowModal(); }