コード例 #1
0
ファイル: StatusDlg.cpp プロジェクト: Enelar/VkIM
BOOL CStatusDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
	// TODO: Add your specialized code here and/or call the base class

	if(wParam==M_ATT_PHOTO){//MP_FILE){
		CFileDialog fileDialog(true, NULL, NULL, 6, L"Изображения|*.jpg; *.jpeg; *.png; *.gif|", GetParent());
		int result = fileDialog.DoModal();
		if (result==IDOK)
		{
			att.filename=fileDialog.GetPathName();
			att.upload=true;
			att.type=ATT_PHOTO;
			hasAtt=true;
			wstring ws=L"     "+wstring(CLang::Get(L"att_photo"));
			btnAttach.SetWindowTextW(ws.c_str());
			Invalidate();
		}
	}

	if(wParam==M_ATT_AUDIO){//MA_FILE){
		CFileDialog fileDialog(true, NULL, NULL, 6, L"Аудиофайлы|*.mp3|", GetParent());
		int result = fileDialog.DoModal();
		if (result==IDOK)
		{
			att.filename=fileDialog.GetPathName();
			att.upload=true;
			att.type=ATT_AUDIO;
			hasAtt=true;
			wstring ws=L"     "+wstring(CLang::Get(L"att_audio"));
			btnAttach.SetWindowTextW(ws.c_str());
			Invalidate();
		}
	}

	if(wParam==M_ATT_VIDEO){
		CFileDialog fileDialog(true, NULL, NULL, 6, L"Видеофайлы|*.mp4; *.avi; *.3gp; *.mpg; *.mpeg; *.mov; *.flv; *.wmv|", GetParent());
		int result = fileDialog.DoModal();
		if (result==IDOK)
		{
			att.filename=fileDialog.GetPathName();
			att.upload=true;
			att.type=ATT_VIDEO;
			hasAtt=true;
			wstring ws=L"     "+wstring(CLang::Get(L"att_video"));
			btnAttach.SetWindowTextW(ws.c_str());
			Invalidate();
		}
	}

	return CDialog::OnCommand(wParam, lParam);
}
コード例 #2
0
void FreeEMS_Loader::rip() {
	connect();
	QSettings loaderSettings(settingsFile, QSettings::IniFormat);
	QString
	loadRipDirectory = loaderSettings.value("lastRipDirectory").toString();
	ui.chkRip->setEnabled(0);
	QFileDialog fileDialog(this, "Save s19 as");
	fileDialog.setNameFilter("s19 Files (*.s19)");
	fileDialog.setDirectory(loadRipDirectory);
	fileDialog.setDefaultSuffix("s19");
	fileDialog.setViewMode(QFileDialog::Detail);
	fileDialog.setFileMode(QFileDialog::AnyFile);
	fileDialog.setAcceptMode(QFileDialog::AcceptSave);
	fileDialog.exec();
	ripFileName = fileDialog.selectedFiles().first();
	if(!ripFileName.endsWith(".s19")) {
		displayMessage(MESSAGE_INFO, "no rip file name specified");
		return;
	}
	qDebug() << "Ripping flash as " << ripFileName;
	ripFileName = fileDialog.selectedFiles().first();
	loaderSettings.setValue("lastRipDirectory", ripFileName);
	loaderComms->setRipFilename(ripFileName);
	loaderComms->setAction("RIP");
	if (ui.chkRipSMCode->isChecked()) {
		loaderComms->ripSMCode(true);
	} else {
		loaderComms->ripSMCode(false);
	}
	loaderComms->start();
}
コード例 #3
0
void MainFrame::OnNewRaceEvent(wxCommandEvent &event){

	wxString defaultDir = _appPrefs.GetLastConfigFileDirectory();
	wxString defaultFile = "";
	wxFileDialog fileDialog(this, "New Race Event", defaultDir, defaultFile, OPEN_RACE_EVENT_FILTER, wxFD_SAVE);

	int result = fileDialog.ShowModal();

	if (wxID_OK == result){
		try{
			const wxString fileName = fileDialog.GetPath();
			if (wxFile::Exists(fileName)){
				wxMessageDialog dlg(this, wxString::Format("Race Event file already exists. Open this Event?"),"Open Existing Race Event", wxYES_DEFAULT | wxYES_NO);
				int result = dlg.ShowModal();
				if (result == wxID_YES){
					OpenRaceEvent(fileName);
				}
			}else{
				NewRaceEvent(fileName);
			}

			RaceEventUpdated();
		}
		catch(DatastoreException &e){
			wxMessageDialog dlg(this, wxString::Format("Failed to Create Race Event:\n\n%s", e.GetMessage().ToAscii()), "Error Creating Race Event", wxOK | wxICON_HAND);
		}
		_appPrefs.SetLastConfigFileDirectory(fileDialog.GetDirectory());
	}
	//Set default values
	NotifyConfigChanged();
}
コード例 #4
0
//------------------------------------------------------------------------------
void VisualModelPanel::OnBrowseButton(wxCommandEvent& event)
{
   wxString filename, path;
   // Open up a file dialog
   wxFileDialog fileDialog(this, wxT("Please select a model."), modelPath, wxEmptyString,
      wxT("3DS and POV files (*.3ds;*.pov)|*.3ds;*.pov"), wxOPEN);
   //wxFileDialog fileDialog(this, wxT("Please select a 3ds model."), modelPath, wxEmptyString,
      //wxT("3DS files (*.3ds)|*.3ds"), wxOPEN);
   // If it succeeded...
   if (fileDialog.ShowModal() == wxID_OK)
   {
      // Load the model indicated by the path
      filename = fileDialog.GetFilename();
      path = fileDialog.GetPath();
      modelCanvas->LoadModel(path);
      currentSpacecraft->modelFile = path;
      // Reset all of the sliders
      ResetSliders();
      dataChanged = true;
      theScPanel->EnableUpdate(true);
      // Set the textctrl to display the selected filename
      modelTextCtrl->ChangeValue(filename);
	  dataChanged = true;
	  theScPanel->EnableUpdate(true);
	  ToggleInterface(true);
   }
}
コード例 #5
0
ファイル: fldlgcmn.cpp プロジェクト: czxxjtu/wxPython-1
wxString wxFileSelectorEx(const wxChar *title,
                          const wxChar *defaultDir,
                          const wxChar *defaultFileName,
                          int* defaultFilterIndex,
                          const wxChar *filter,
                          int       flags,
                          wxWindow* parent,
                          int       x,
                          int       y)

{
    wxFileDialog fileDialog(parent,
                            title ? title : wxEmptyString,
                            defaultDir ? defaultDir : wxEmptyString,
                            defaultFileName ? defaultFileName : wxEmptyString,
                            filter ? filter : wxEmptyString,
                            flags, wxPoint(x, y));

    wxString filename;
    if ( fileDialog.ShowModal() == wxID_OK )
    {
        if ( defaultFilterIndex )
            *defaultFilterIndex = fileDialog.GetFilterIndex();

        filename = fileDialog.GetPath();
    }

    return filename;
}
コード例 #6
0
void MainFrame::SaveAsCurrentConfig(){

	wxString defaultDir = _appPrefs.GetLastConfigFileDirectory();
	wxString defaultFile = "";
	wxFileDialog fileDialog(this, "Save As Configuration", defaultDir, defaultFile, CONFIG_FILE_FILTER,wxFD_SAVE);

	int result = fileDialog.ShowModal();

	if (wxID_OK == result){
		RaceCaptureConfigFileWriter writer;

		const wxString fileName = fileDialog.GetPath();
		if (!wxFile::Exists(fileName) || (wxFile::Exists(fileName) && QueryFileOverwrite())){
			writer.SetFileName(fileName);

			try{
				writer.WriteConfigData(m_currentConfig);
				m_currentConfigFileName = new wxString(fileName);
				m_configModified = false;
				SetStatusMessage("RaceCapture Configuration Saved");
				_appPrefs.SetLastConfigFileDirectory(fileDialog.GetDirectory());
			}
			catch (FileAccessException &e){
				wxMessageDialog dlg(this, wxString::Format("Failed to save RaceCapture Configuration:\n\n%s", e.GetMessage().ToAscii()), "Error saving", wxOK | wxICON_HAND);
				dlg.ShowModal();
				return;
			}
		}
	}
	UpdateConfigFileStatus();
}
コード例 #7
0
void DatabaseTabWidget::saveDatabaseAs(Database* db)
{
    DatabaseManagerStruct& dbStruct = m_dbList[db];
    QString oldFileName;
    if (dbStruct.saveToFilename) {
        oldFileName = dbStruct.filePath;
    }
    QString fileName = fileDialog()->getSaveFileName(this, tr("Save database as"),
                                                     oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)"));
    if (!fileName.isEmpty()) {
        bool result = false;

        QSaveFile saveFile(fileName);
        if (saveFile.open(QIODevice::WriteOnly)) {
            m_writer.writeDatabase(&saveFile, db);
            result = saveFile.commit();
        }

        if (result) {
            dbStruct.modified = false;
            dbStruct.saveToFilename = true;
            QFileInfo fileInfo(fileName);
            dbStruct.filePath = fileInfo.absoluteFilePath();
            dbStruct.canonicalFilePath = fileInfo.canonicalFilePath();
            dbStruct.fileName = fileInfo.fileName();
            dbStruct.dbWidget->updateFilename(dbStruct.filePath);
            updateTabName(db);
            updateLastDatabases(dbStruct.filePath);
        }
        else {
            MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
                                 + saveFile.errorString());
        }
    }
}
コード例 #8
0
ファイル: SaveOperation.cpp プロジェクト: yudjin87/carousel
void SaveOperation::execute()
{
    IPersistenceService* persistenceService = m_serviceLocator->locate<IPersistenceService>();
    QFileInfo currentFile = persistenceService->absoluteFilePath();
    if (!currentFile.exists())
    {
        Log.d(QString("File \"%1\" doesn't exist, ask for a new one").arg(currentFile.absoluteFilePath()));
        QFileDialog fileDialog(m_serviceLocator->locate<QMainWindow>(), "Save project");
        fileDialog.setAcceptMode(QFileDialog::AcceptSave);
        if (!fileDialog.exec())
        {
            Log.d("Saving was canceled by user");
            return;
        }

        currentFile = fileDialog.selectedFiles().first();
    }

    bool result = persistenceService->saveAs(currentFile.absoluteFilePath());
    if (!result)
    {
        return;
    }

    IUndoStack *undoStack = m_serviceLocator->locate<IUndoStack>();
    undoStack->setClean();
}
コード例 #9
0
ファイル: screenshot.cpp プロジェクト: hsbiti/projet-sd
//! [3]
void Screenshot::saveScreenshot()
{
    const QString format = "png";
    QString initialPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
    if (initialPath.isEmpty())
        initialPath = QDir::currentPath();
    initialPath += tr("/untitled.") + format;

    QFileDialog fileDialog(this, tr("Save As"), initialPath);
    fileDialog.setAcceptMode(QFileDialog::AcceptSave);
    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.setDirectory(initialPath);
    QStringList mimeTypes;
    foreach (const QByteArray &bf, QImageWriter::supportedMimeTypes())
        mimeTypes.append(QLatin1String(bf));
    fileDialog.setMimeTypeFilters(mimeTypes);
    fileDialog.selectMimeTypeFilter("image/" + format);
    fileDialog.setDefaultSuffix(format);
    if (fileDialog.exec() != QDialog::Accepted)
        return;
    const QString fileName = fileDialog.selectedFiles().first();
    if (!originalPixmap.save(fileName)) {
        QMessageBox::warning(this, tr("Save Error"), tr("The image could not be saved to \"%1\".")
                             .arg(QDir::toNativeSeparators(fileName)));
    }
}
コード例 #10
0
ファイル: MainDialog.cpp プロジェクト: Aetherdyne/glintercept
void MainDialog::OnButtonTargetFile(wxCommandEvent& WXUNUSED(event))
{
  // Get the path of any currently selected file
  wxString oldDirectory = "";

  // Get the current file (if any) and set as the default
  wxFileName oldFileName(targetFileTextCtrl->GetValue());
  if(oldFileName.FileExists())
  {
    oldDirectory = oldFileName.GetPath();
  }

  // Open the file dialog
  wxFileDialog fileDialog(this, _T("Select the target OpenGL application"), oldDirectory, _T(""), _T("Executables (*.exe)|*.exe|Any (*.*)|*.*"), wxOPEN | wxFILE_MUST_EXIST );
  if (fileDialog.ShowModal() != wxID_OK)
  {
    return;
  }

  // If the selected string is empty, or the file does not exist, abort.
  if (fileDialog.GetPath().IsEmpty() || 
      !wxFileExists(fileDialog.GetPath()))
  {
    return;
  }
  
  // Set the new text in the text edit control
  targetFileTextCtrl->SetValue(fileDialog.GetPath());
}
コード例 #11
0
	//加载文字处理函数
	void CRecognitionTextView::OnLoadcharacter()
	{
		// TODO: 在此添加命令处理程序代码
		if (fileCount > 0)
		{
			static TCHAR BASED_CODE szFilter[] = _T("Map Files (*.dat)|*.dat||");			//进行文件过滤
			CFileDialog fileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);
			if(fileDialog.DoModal() == IDOK){
				CString datFileName;
				datFileName = fileDialog.GetPathName();			
				MessageBox(datFileName);
				USES_CONVERSION;			//声明标识符
				FILE *file = fopen(T2A(datFileName), "rb");		//调用函数库实现CString到const char*转换
				if(!file)
				{
					printf("打开文件失败");
					return;
				}
				for(int i = 0 ;i<7356;i++)
				{
					//读取字符
					fread(words[i], 2, 1, file);
					words[i][2] = '\0';

					printf("%s\t",words[i]);
				}
				fclose(file);
			}
		} 
		else 
		{
			MessageBox(_T("请先加载图片"));
		}
	}
コード例 #12
0
	//加载图片处理函数
	void CRecognitionTextView::OnLoadImage()
	{
		// TODO: 在此添加命令处理程序代
		//static TCHAR BASED_CODE szFilter[] = _T("Map Files (*.*)|*.*||");			//进行文件过滤
		CFileDialog fileDialog(TRUE,NULL,NULL,NULL,NULL,this);//OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, this);
		if(fileDialog.DoModal() == IDOK)
		{
			initData();
			CString temp;
			temp = fileDialog.GetPathName();
			fileDictionary = temp.Left(temp.ReverseFind('\\')) + CString("\\");
			MessageBox(fileDictionary);
		}
		else
		{
			return;
		}

		fileCount = tools.findFile(fileDictionary + "*.bmp", fileName);			//获取当前文件夹下文件数,并将文件名添加到数组中

		if(fileCount == -1)
		{
			MessageBox(TEXT("图片路径有误"));
		}
		filePath = fileDictionary + (CString)fileName[0];
		OnPaint();		//进行绘制第一幅图片
	}
コード例 #13
0
ファイル: Buttons.cpp プロジェクト: matemat13/Spektrograf
void ScreenshotButton::onClick(wxCommandEvent& WXUNUSED(event)) {
   SetBitmapPressed(normal);  //nechci aby na screenshotu vypadal zmacknuty
   Refresh();
   wxBitmap screenshot;
   GetScreenshot(screenshot);
   //screenshot.ClearAlpha();
   SetBitmapPressed(press);
   /**Ulozeni dp souboru**/
   wxFileDialog fileDialog(this, _("Save a screenshot"), wxT(""), wxT("spektrograf.bmp"), wxT("Rastr (*.bmp) | *.bmp|Obrázek PNG (nedoporuèuje se) (*.png) | *.png|JPEG formát (*.jpg) | *.jpeg;*.jpg"), wxFD_SAVE);
   if(fileDialog.ShowModal() == wxID_OK) {
          wxFileName namePath(fileDialog.GetPath());
          int fileType = wxBITMAP_TYPE_BMP;
          if( namePath.GetExt().CmpNoCase(wxT("jpeg")) == 0 ) fileType = wxBITMAP_TYPE_JPEG;
          if( namePath.GetExt().CmpNoCase(wxT("jpg")) == 0 )  fileType = wxBITMAP_TYPE_JPEG;
          if( namePath.GetExt().CmpNoCase(wxT("png")) == 0 )  fileType = wxBITMAP_TYPE_PNG;
		  if( namePath.GetExt().CmpNoCase(wxT("bmp")) == 0 )  fileType = wxBITMAP_TYPE_BMP;
		  wxImage tosave(screenshot.ConvertToImage());
		  if(tosave.HasAlpha())
		    tosave.ClearAlpha();

		  if(wxFileExists(fileDialog.GetPath())) 
		  {
			  wxMessageDialog potvrd(this, _("Soubor existuje! Chcete jej pøepsat?"), _("Soubor existuje"), wxYES_NO|wxNO_DEFAULT|wxICON_WARNING);
			  if(potvrd.ShowModal()==wxID_YES)
				  tosave.SaveFile(fileDialog.GetPath(),(wxBitmapType)fileType);

		  }
		  else 
		    tosave.SaveFile(fileDialog.GetPath(),(wxBitmapType)fileType);
   }
   return;
}
コード例 #14
0
//==============================================================================
// On Browse Target Button Clicked Slot
//==============================================================================
void CreateLinkDialog::on_browseTargetButton_clicked()
{
    // Get Current Dir
    QString currentDir = getDirPath(ui->linkTargetEdit->text());

    // Init New File Dialog
    QFileDialog fileDialog(NULL, tr(DEFAULT_TITLE_SELECT_LINK_TARGET), currentDir);

    // Set File Mode
    fileDialog.setFileMode(QFileDialog::AnyFile);
    // Set Accept Mode
    fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
    // Set Options
    fileDialog.setOptions(QFileDialog::ReadOnly);

    // Exec
    if (fileDialog.exec()) {
        // Get New Target Name
        QString newTargetName = fileDialog.selectedFiles().count() > 0 ? fileDialog.selectedFiles()[0] : "";

        // Check New Target Name
        if (!newTargetName.isEmpty()) {
            // Set Link Target
            ui->linkTargetEdit->setText(newTargetName);
        }
    }

    // ...
}
コード例 #15
0
/*---------------------------------------------------------------------------*/
void wxBackupRestoreDbDlg::OnGetfilebtnClick(wxCommandEvent& event)
{
   wxString dlgtitle;
   int style;

   if (m_BackUp)
   {
      dlgtitle = _("Target database");
      style = wxFD_OPEN;
   }
   else
   {
      dlgtitle = _("Source database");
      style = wxFD_OPEN|wxFD_FILE_MUST_EXIST;
   }

   wxFileDialog fileDialog(this, dlgtitle, wxEmptyString,
                           wxEmptyString,
                           _("SQLite files (*.db)|*.db|All files (*.*)|*.*"),
                           style);
   if (fileDialog.ShowModal() == wxID_OK)
   {
      m_EdFilename->SetValue(fileDialog.GetPath());
   }
}
コード例 #16
0
void WidgetMain::on_pushButtonFilter_clicked()
{
    filterFolderPaths_.clear();
    QFileDialog fileDialog(this, "select folder ", "./");
    fileDialog.setFileMode(QFileDialog::DirectoryOnly);
    fileDialog.setOption(QFileDialog::DontUseNativeDialog, true);
    QListView *pListView = fileDialog.findChild<QListView*>("listView");
    if(NULL != pListView)
    {
        qDebug() << "find listview!";
        pListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    }

    if(fileDialog.exec())
    {
        QStringList folderPaths = fileDialog.selectedFiles();
        if(folderPaths.isEmpty())
        {
            qDebug() << "folders is empty!";
            return;
        }
#ifdef WIN32
        foreach (QString tmp, folderPaths)
        {
            filterFolderPaths_ << tmp.replace("/", "\\");
        }
コード例 #17
0
LRESULT PageSettingsTabsColors::OnClickedBtnImportColors(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
  CFileDialog fileDialog(
    TRUE,
    NULL,
    NULL,
    OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST,
    L"Config Files (*.xml)\0*.xml\0All Files (*.*)\0*.*\0\0");

  if (fileDialog.DoModal() == IDOK)
  {
    CComPtr<IXMLDOMDocument> pSettingsDocument;
    CComPtr<IXMLDOMElement>  pSettingsRoot;
    if(FAILED(XmlHelper::OpenXmlDocument(
      fileDialog.m_szFileName,
      pSettingsDocument,
      pSettingsRoot))) return 0;

    CComPtr<IXMLDOMElement>	pConsoleElement;
    if (FAILED(XmlHelper::GetDomElement(pSettingsRoot, CComBSTR(L"console"), pConsoleElement))) return false;

    COLORREF colors[16];
    if(!XmlHelper::LoadColors(pConsoleElement, colors)) return 0;

    m_tabData->SetColors(colors, true);
    m_tabData->bInheritedColors = false;

    DoDataExchange(DDX_LOAD);
    Invalidate();
  }

  return 0;
}
コード例 #18
0
/**
 * @brief Saves the playbook persistently to a file after asking for a file name.
 */
void MainDialog::savePlaybookAs() {
    std::string stdFile = PBCPlaybook::getInstance()->name() + ".pbc";
    QFileDialog fileDialog(
                this, "Save Playbook",
                QString::fromStdString(stdFile),
                "PBC Files (*.pbc);;All Files (*.*)");

    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.setAcceptMode(QFileDialog::AcceptSave);
    if(fileDialog.exec() == true) {
        QStringList files = fileDialog.selectedFiles();
        assert(files.size() == 1);
        QString fileName = files.first();

        bool ok;
        QString password = QInputDialog::getText(this, "Save Playbook",
                                                 "Enter encryption password",
                                                 QLineEdit::Password, "", &ok);
        if(ok == true) {
            _currentPlaybookFileName = fileName;
            PBCStorage::getInstance()->savePlaybook(password.toStdString(),
                                                    fileName.toStdString());
            updateTitle(true);
        }
    }
}
コード例 #19
0
void CMainDlg::OnCommandsSavelogtofile()
{
TRY_CATCH
	CFileDialog fileDialog(	FALSE /*save*/,
							"log",
							"NetworkLayerTest");
	fileDialog.DoModal();
	tstring fileName = static_cast<LPCSTR>(fileDialog.GetPathName());
	HANDLE hFile = CreateFile(	fileName.c_str(),
								GENERIC_WRITE,
								FILE_SHARE_READ,
								NULL,
								CREATE_ALWAYS,
								0,
								NULL );
	if (hFile == INVALID_HANDLE_VALUE)
		throw MCStreamException_Win("failed to CreateFile",GetLastError());
	CString str;
	DWORD written;
	for(int i=0; 
		i<m_logList.GetCount();
		++i)
	{
		m_logList.GetText(i, str);
		str = "\r\n" + str;
		if (!WriteFile(hFile,(LPCSTR)str,str.GetLength()+1,&written,FALSE))
			throw MCStreamException_Win("failed to WriteFile",GetLastError());
	}
	CloseHandle(hFile);
CATCH_LOG("CMainDlg::OnCommandsSavelogtofile")
}
コード例 #20
0
ファイル: EditEntryWidget.cpp プロジェクト: BlueIce/keepassx
void EditEntryWidget::insertAttachment()
{
    Q_ASSERT(!m_history);

    // TODO: save last used dir
    QString filename = fileDialog()->getOpenFileName(this, tr("Select file"),
                QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
    if (filename.isEmpty() || !QFile::exists(filename)) {
        return;
    }

    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly)) {
        QMessageBox::warning(this, tr("Error"),
                tr("Unable to open file:\n").append(file.errorString()));
        return;
    }

    QByteArray data;
    if (!Tools::readAllFromDevice(&file, data)) {
        QMessageBox::warning(this, tr("Error"),
                tr("Unable to open file:\n").append(file.errorString()));
        return;
    }

    m_entryAttachments->set(QFileInfo(filename).fileName(), data);
}
コード例 #21
0
ファイル: EditEntryWidget.cpp プロジェクト: BlueIce/keepassx
void EditEntryWidget::saveCurrentAttachment()
{
    QModelIndex index = m_advancedUi->attachmentsView->currentIndex();
    if (!index.isValid()) {
        return;
    }

    QString filename = m_attachmentsModel->keyByIndex(index);
    // TODO: save last used dir
    QDir dir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
    QString savePath = fileDialog()->getSaveFileName(this, tr("Save attachment"),
                                                       dir.filePath(filename));
    if (!savePath.isEmpty()) {
        QByteArray attachmentData = m_entryAttachments->value(filename);

        QFile file(savePath);
        if (!file.open(QIODevice::WriteOnly)) {
            QMessageBox::warning(this, tr("Error"),
                    tr("Unable to save the attachment:\n").append(file.errorString()));
            return;
        }
        if (file.write(attachmentData) != attachmentData.size()) {
            QMessageBox::warning(this, tr("Error"),
                    tr("Unable to save the attachment:\n").append(file.errorString()));
            return;
        }
    }
}
コード例 #22
0
ファイル: mainwindow.cpp プロジェクト: damaki/Turtyl
void MainWindow::loadScript()
{
    QStringList filters;
    filters << tr("Lua (*.lua)")
            << tr("Text (*.txt)")
            << tr("All Files (*)");

    QFileDialog fileDialog(this);
    fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
    fileDialog.setNameFilters(filters);
    fileDialog.setWindowTitle(tr("Open Script"));

    if (fileDialog.exec() != 0)
    {
        ui->scriptTextEdit->clear();

        for (QString filename : fileDialog.selectedFiles())
        {
            QFile file(filename);
            if (file.open(QFile::ReadOnly | QFile::Text))
            {
                QTextStream stream(&file);
                ui->scriptTextEdit->appendPlainText(stream.readAll());
                file.close();
            }
            else
            {
                QString message = QString("Cannot open file: %1\n%2")
                        .arg(filename)
                        .arg(file.errorString());
                QMessageBox::critical(this, tr("Open Error"), message);
            }
        }
    }
}
コード例 #23
0
/// Display a file dialog.  If `directory` is an invalid file or directory the browser will start at the current
/// working directory.
/// \param const QString& title title of the window
/// \param const QString& directory directory to start the file browser at
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QString& directory, const QString& nameFilter,
                                                  QFileDialog::AcceptMode acceptMode) {
    // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
    // filename if the directory is valid.
    QString path = "";
    QFileInfo fileInfo = QFileInfo(directory);
    qDebug() << "File: " << directory << fileInfo.isFile();
    if (fileInfo.isDir()) {
        fileInfo.setFile(directory, "__HIFI_INVALID_FILE__");
        path = fileInfo.filePath();
    }
    
    QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter);
    fileDialog.setAcceptMode(acceptMode);
    qDebug() << "Opening!";
    QUrl fileUrl(directory);
    if (acceptMode == QFileDialog::AcceptSave) {
        fileDialog.setFileMode(QFileDialog::Directory);
        fileDialog.selectFile(fileUrl.fileName());
    }
    if (fileDialog.exec()) {
        return QScriptValue(fileDialog.selectedFiles().first());
    }
    return QScriptValue::NullValue;
}
コード例 #24
0
ファイル: mainform.cpp プロジェクト: cheinkn/basextreme
void MainForm::OnToolsCalculateLightMaps()
{
    CFileDialog fileDialog(
        true,
        "*.*",
        NULL,
        0,
        "RenderWare stream (*.rws)|*.rws|All Files (*.*)|*.*||",
        this
    );

    // setup browsing from import directory
    char currentDir[1024];
    GetCurrentDirectory( 1024, currentDir );
    std::string initialDir = currentDir;
    initialDir += "\\res";
    fileDialog.m_ofn.lpstrInitialDir = initialDir.c_str();

    if( fileDialog.DoModal() == IDOK )
    {
        // back to application current directory
        SetCurrentDirectory( currentDir );

        // resource path
        std::string fileName = fileDialog.GetPathName();
        makeEngineCompatiblePath( fileName );

        // calculate lightmaps
        import::IImport* iImport;
        queryInterfaceT( "Import", &iImport );
        iImport->calculateLightMaps( fileName.c_str(), lightMapCallback, this );
    }
}
コード例 #25
0
ファイル: mainform.cpp プロジェクト: cheinkn/basextreme
void MainForm::OnAssetImport() 
{
    CFileDialog fileDialog(
        true,
        "*.*",
        NULL,
        0,
        "RenderWare stream (*.rws)|*.rws|All Files (*.*)|*.*||",
        this
    );

    // setup browsing from import directory
    char currentDir[1024];
    GetCurrentDirectory( 1024, currentDir );
    std::string initialDir = currentDir;
    initialDir += "\\res";
    fileDialog.m_ofn.lpstrInitialDir = initialDir.c_str();

    if( fileDialog.DoModal() == IDOK )
    {
        // back to application current directory
        SetCurrentDirectory( currentDir );

        // destroy previous asset
        destroyAsset();

        // import new asset
        std::string fileName = fileDialog.GetPathName();
        makeEngineCompatiblePath( fileName );
        currentAsset = iEngine()->createAsset( engine::atImport, fileName.c_str() );

        // preparate
        preparateAsset();
    }
}
コード例 #26
0
ファイル: fileedit.cpp プロジェクト: niconil/actionaz
	void FileEdit::on_browse_clicked()
	{
		QFileDialog fileDialog(this, mCaption, mDirectory, mFilter);

		switch(mMode)
		{
		case FileOpen:
			fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
			fileDialog.setFileMode(QFileDialog::ExistingFile);
			break;
		case FileSave:
			fileDialog.setAcceptMode(QFileDialog::AcceptSave);
			fileDialog.setFileMode(QFileDialog::AnyFile);
			break;
		case DirectoryOpen:
			fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
			fileDialog.setFileMode(QFileDialog::Directory);
			fileDialog.setOption(QFileDialog::ShowDirsOnly);
			break;
		case DirectorySave:
			fileDialog.setAcceptMode(QFileDialog::AcceptSave);
			fileDialog.setFileMode(QFileDialog::Directory);
			fileDialog.setOption(QFileDialog::ShowDirsOnly);
			break;
		}

		if(fileDialog.exec())
		{
			QStringList fileNames = fileDialog.selectedFiles();
			if(fileNames.size() > 0)
				ui->path->setText(fileNames.at(0));
		}
	}
コード例 #27
0
GS_VOID CPokeMiniEmulatorDlg::OnRomOpen()
{
    OnRomClose();

    {
        CFileDialog fileDialog(TRUE, _T("*.min"), NULL, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_EXPLORER, _T("pokemon mini rom(*.min)|*.min"));
        if (IDOK == fileDialog.DoModal())
        {
            CString fileName = fileDialog.GetPathName();
            FILE *pFile = _wfopen(fileName, L"rb");
            fseek(pFile, 0, SEEK_END);
            m_romSize = ftell(pFile);
            m_pRomData = GS_MALLOCZ_OBJ_N(GS_BYTE, m_romSize);
            fseek(pFile, 0, SEEK_SET);
            fread(m_pRomData, 1, m_romSize, pFile);
            fclose(pFile);

            m_pSaveData = GS_MALLOCZ_OBJ_N(GS_BYTE, m_pSystem->SaveSize());
        }
    }

    if (m_pSystem->Initialize(m_pRomData, m_romSize, m_pSaveData))
    {
        HRESULT hr = S_OK;
        hr = m_pDirectSoundBuffer->SetCurrentPosition(0);
        GS_ASSERT(SUCCEEDED(hr));
        hr = m_pDirectSoundBuffer->Play(0, 0, DSBPLAY_LOOPING);
        GS_ASSERT(SUCCEEDED(hr));

        m_state = EMU_RUN;
        m_emuThread = CreateThread(NULL, 0, EmuThread, this, 0, &m_emuThreadID);
    }
}
コード例 #28
0
ファイル: mainwindow.cpp プロジェクト: vrruiz/visualino
void MainWindow::actionExportSketch() {
    // Export workspace as Arduino Sketch
    QString inoFileName;

    // Open file dialog
    QFileDialog fileDialog(this, tr("Save"));
    fileDialog.setFileMode(QFileDialog::AnyFile);
    fileDialog.setNameFilter(QString("Sketches %1").arg("(*.ino)"));
    fileDialog.setDefaultSuffix("ino");
    fileDialog.setLabelText(QFileDialog::Accept, tr("Export"));
    if (!fileDialog.exec()) return; // Return if cancelled
    QStringList selectedFiles = fileDialog.selectedFiles();
    // Return if no file to open
    if (selectedFiles.count() < 1) return;
    inoFileName = selectedFiles.at(0);

    int result = saveSketch(inoFileName);

    if (result == 0) {
        // Display error message
        QMessageBox msgBox(this);
        msgBox.setText(QString(tr("Couldn't open file to save content: %1.")
                               ).arg(inoFileName));
        msgBox.exec();
        return;
    }

    // Feedback
    QString message(tr("Done exporting: %1.").arg(inoFileName));
    statusBar()->showMessage(message, 2000);
}
void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event))
{

    wxString fileName;
    wxString NameofFile;

    wxFileDialog fileDialog(NULL, "Choose a file to load ...", "", "", "*.bmp;*.tif;*.gif;*.jpg", wxFD_OPEN, wxDefaultPosition);
    if( fileDialog.ShowModal() == wxID_OK )

    {
        fileName = fileDialog.GetPath();
        NameofFile = fileDialog.GetFilename();
        //Update the view of main frame
        if( pImage != NULL ) delete pImage;
        pImage = new wxImage(fileName);

        if( pImage == NULL )
            wxMessageBox("File Failed to Open!", _T("Error"), wxOK | wxICON_INFORMATION, this);
        else
        {
		masterImage = pImage;
		SetTitle(fileName);
		Refresh();
        }
    }
    fileDialog.Destroy();
}
コード例 #30
0
ファイル: FileDialog.cpp プロジェクト: DanielCJLee/audacity
wxString FileSelector(const wxString & title,
                      const wxString & defaultDir,
                      const wxString & defaultFileName,
                      const wxString & defaultExtension,
                      const wxString & filter,
                      int flags,
                      wxWindow *parent)
{
   // The defaultExtension, if non-empty, is
   // appended to the filename if the user fails to type an extension. The new
   // implementation (taken from wxFileSelectorEx) appends the extension
   // automatically, by looking at the filter specification. In fact this
   // should be better than the native Microsoft implementation because
   // Windows only allows *one* default extension, whereas here we do the
   // right thing depending on the filter the user has chosen.

   // If there's a default extension specified but no filter, we create a
   // suitable filter.

   wxString filter2;
   if (!defaultExtension.empty() && filter.empty())
      filter2 = wxString(wxT("*.")) + defaultExtension;
   else if (!filter.empty())
      filter2 = filter;

   FileDialog fileDialog(parent, title, defaultDir,
                         defaultFileName, filter2,
                         flags);

   // if filter is of form "All files (*)|*|..." set correct filter index
   if (!defaultExtension.empty() && filter2.find(wxT('|')) != wxString::npos)
   {
      int filterIndex = 0;
      
      wxArrayString descriptions, filters;
      // don't care about errors, handled already by FileDialog
      (void)wxParseCommonDialogsFilter(filter2, descriptions, filters);
      
      for (size_t n=0; n<filters.GetCount(); n++)
      {
         if (filters[n].Contains(defaultExtension))
         {
            filterIndex = (int)n; // Convert to int to avoid compiler warning, because we probably do not need many tens of thousands of filters.
            break;
         }
      }
      
      if (filterIndex > 0)
         fileDialog.SetFilterIndex(filterIndex);
   }
   
   wxString filename;
   if (fileDialog.ShowModal() == wxID_OK)
   {
      filename = fileDialog.GetPath();
   }
   
   return filename;
}