Exemple #1
0
/**
 * Launch a file dialog which allows the user to create a new file of the
 * specified type.  Used by <code>emitNewFile()</code> to create new native
 * document files, but can also be used to create files for exporting data,
 * etc.
 *
 * @param fileDescription The description of the file type as it is to appear
 *                        in the file dialog (null for the application default)
 * @param fileExtension The file extension of the file type (do not include
 *                      the period, use null for the application default)
 * @return The path of the file to be created (or an empty string if none)
 */
QString QQMenuHelper::createNewFile(const QString &fileDescription,
                      const QString &fileExtension)
{
    QString desc = fileDescription.isNull() ? description : fileDescription;
    QString ext = fileExtension.isNull() ? extension : fileExtension;
    QString filter = QString("%1 (*.%2)").arg(desc).arg(ext);
    QSettings settings;
    QString lastDir = getLastDir(&settings);
    QString filename = QFileDialog::getSaveFileName(mainWindow,
                           tr("Choose a filename to save under"), lastDir,
                           filter);
    if (filename.isEmpty()) {
        return "";
    }
    if (!filename.endsWith(ext, Qt::CaseInsensitive)) {
        filename += QString(".%1").arg(ext);
    }
#if !defined(Q_WS_MAC)
    // The native Mac file dialog confirms overwrites internally
    if (QFile::exists(filename)) {
        int choice = QMessageBox::warning(mainWindow,
                             qApp->applicationName(),
                             tr("File already exists; overwrite it?"),
                             QMessageBox::Yes|QMessageBox::No,
                             QMessageBox::No);
        if (choice != QMessageBox::Yes) {
            return "";
        }
    }
#endif
    QFileInfo info(filename);
    settings.setValue("Files/LastDir", info.absolutePath());
    return filename;
}
Exemple #2
0
void ZDLInterface::loadZdlFile(){
	LOGDATAO() << "Loading ZDL file" << endl;
	QStringList filters;
	QString filter;
	filters << "ZDL (*.zdl)" << "Any files (*)";
	filter = filters.join(";;");
	QString lastDir = getLastDir(ZDLConfigurationManager::getActiveConfiguration());
	QString fileName = QFileDialog::getOpenFileName(this, "Load ZDL", lastDir, filter);
	if(!fileName.isNull() && !fileName.isEmpty()){
		ZDLConf *current = ZDLConfigurationManager::getActiveConfiguration();
		for(int i = 0; i < current->sections.size(); i++){
			if(current->sections[i]->getName().compare("zdl.save") == 0){
				ZDLSection *section = current->sections[i];
				current->sections.remove(i);
				delete section;
				break;
			}
		}
		ZDLConf *newConf = new ZDLConf();
		newConf->readINI(fileName);
		for(int i = 0; i < newConf->sections.size(); i++){
			if(newConf->sections[i]->getName().compare("zdl.save") == 0){
				ZDLSection *section = newConf->sections[i];
				current->addSection(section->clone());
				break;
			}
		}
		saveLastDir(current, fileName);
		delete newConf;
		mw->startRead();
	}
}
Exemple #3
0
void ZDLInterface::loadConfigFile(){
	LOGDATAO() << "Loading config file" << endl;
	ZDLConf *zconf = ZDLConfigurationManager::getActiveConfiguration();
	QString filter;
	QStringList filters;
	
	filters << "ini (*.ini)"
		<< "Any files (*)";
	filter = filters.join(";;");
	QString lastDir = getLastDir(zconf);
	QString fileName = QFileDialog::getOpenFileName(this, "Load Configuration", lastDir, filter);
	if(!fileName.isNull() && !fileName.isEmpty()){
		QFileInfo fi(fileName);
                if(!fi.fileName().contains(".")){
                        fileName += ".ini";
                }
		delete zconf;
		ZDLConf* tconf = new ZDLConf();
		ZDLConfigurationManager::setConfigFileName(fileName);
		tconf->readINI(fileName);
		saveLastDir(zconf,fileName);
		ZDLConfigurationManager::setActiveConfiguration(tconf);

		mw->startRead();
	}

}
wxString wxOpenCommanderListCtrl::OnGetItemText(long item, long column) const
{
    wxString itemText = m_cCommander->getFileDirActualPath(item, column);
    if (column == 0 && !showPathAndFile) itemText = getLastDir(itemText);
    if (m_cCommander->getListDevices())
       return lang[itemText];
    else
       return itemText;
} 
Exemple #5
0
void MainWindow::moveToSlot()
{
    QString newFileName = QFileDialog::getExistingDirectory(this, tr("Move to"), getLastDir());
    if (fileUtils->moveFile(newFileName)) {
        qDebug() << "moved";
        recentFilesPath.removeAt(0);
        createRFActs();
        openImage();
    }
}
Exemple #6
0
/**
 * Handle a selection of the "File" menu's "Open" action by emitting
 * openFile() with an appropriate argument.  If no file has been selected,
 * return without doing anything.
 */
void QQMenuHelper::emitOpenFile()
{
    QSettings settings;
    QString lastDir = getLastDir(&settings);
    QString filter = QString("%1 (*.%2)").arg(description).arg(extension);
    QString filename = QFileDialog::getOpenFileName(mainWindow,
                           tr("Choose a file"), lastDir, filter);
    if (filename.isEmpty()) {
        return;
    }
    QFileInfo info(filename);
    settings.setValue("Files/LastDir", info.absolutePath());
    emit openFile(filename);
}
Exemple #7
0
void MainWindow::openDir()
{
    this->canCloseImage();
    QString dirName = QFileDialog::getExistingDirectory(this, tr("Open folder"),
                                                        getLastDir(), QFileDialog::ShowDirsOnly
                                                        | QFileDialog::DontResolveSymlinks);
    qDebug() << "folder" << dirName;
    if (dirName.isEmpty()) {
        qDebug() << tr("No folder selected");
        return;
    }

    if (fileUtils->openFolder(dirName)) {
        pixmapChanged = false;
        openImage();
    } else {
        QMessageBox::information(this, tr("EyeSight"), tr("No folder selected, i can't do anything"),
                                 QMessageBox::Ok);
    }
}
Exemple #8
0
void MainWindow::open()
{
    //check if the current image has been modificated (i.e turned to left)
    this->canCloseImage();

    //get a filename from a open dialog
    QString fileName = QFileDialog::getOpenFileName(this,
                                                    tr("Open file", "dialog to open file"),
                                                    getLastDir(),
                                                    tr("Image Files (%1)").arg(nameFilters.join(" ")));

    //if the filename name isn't empty, open the file
    if (!(fileName.isEmpty())) {
        if (fileUtils->openFile(fileName)) {
            pixmapChanged = false;
            openImage();
        } else {
            QMessageBox::information(this, tr("EyeSight"), tr("EyeSight couldn't open the image, what do you want to do?"),
                                     QMessageBox::Ok);
        }
    }
}
Exemple #9
0
// ojo, no pinta cuando distance es mayor que 1. Testear esto!!!!!!!!!!!!!!
bool RailPen::move(int distance, Sim * sim){
	Point p = getPos();
	if(getMode() == PAINTING){
		if(distance>0){
			for(int n= 0; n<distance;n++){
				Rail * newRail = makeNewRail(sim->railMap.getRailAt(p.row, p.col));
				sim->railMap.setRail(p.row, p.col, newRail);

				ForkRail *rf = dynamic_cast<ForkRail *>(newRail);
				if(rf){
					sim->addFork(rf);
				}

				Point lastPoint = getPos();
				Dir lastDir = getLastDir();
				Dir backDir = -lastDir; 
				lastPoint.move(backDir);
				Rail * lastRail = sim->railMap.getRailAt(lastPoint.row, lastPoint.col);
				if(lastRail){
					newRail->linkRailAt(backDir, lastRail);
				}
			 	forward();	
			}
		}else{
			for(int n=0; n>distance;n--){
				Point p = getPos();
				sim->railMap.setRail(p.row, p.col, 0);
				backwards();
			}
		}
	}else{
		pos.move(dir, distance);
		lastDir=dir;
	}
	return true;
}
Exemple #10
0
void ZDLInterface::saveZdlFile(){
	LOGDATAO() << "Saving ZDL File" << endl;
	sendSignals();
	QStringList filters;
	filters << "ZDL (*.zdl)" << "Any files (*)";
	QString filter = filters.join(";;");
	QString lastDir = getLastDir(ZDLConfigurationManager::getActiveConfiguration());
	QString fileName = QFileDialog::getSaveFileName(this, "Save ZDL", lastDir, filter);
	if(!fileName.isNull() && !fileName.isEmpty()){
		ZDLConf *current = ZDLConfigurationManager::getActiveConfiguration();
		ZDLConf *copy = new ZDLConf();
		for(int i = 0; i < current->sections.size(); i++){
			if(current->sections[i]->getName().compare("zdl.save") == 0){
				copy->addSection(current->sections[i]->clone());
				if(!fileName.contains(".")){
					fileName = fileName + QString(".zdl");
				}
				saveLastDir(current, fileName);
				copy->writeINI(fileName);
			}
		}
	}

}
Exemple #11
0
void ZDLInterface::saveConfigFile(){
	LOGDATAO() << "Saving config file" << endl;
	sendSignals();
	ZDLConf *zconf = ZDLConfigurationManager::getActiveConfiguration();
	QStringList filters;
	filters << "ini (*.ini)"
		<< "Any files (*)";

	QString filter = filters.join(";;");
	QString lastDir = getLastDir(zconf);
	QString fileName = QFileDialog::getSaveFileName(this, "Save Configuration", lastDir, filter);

	if(!fileName.isNull() && !fileName.isEmpty()){
		QFileInfo fi(fileName);
		if(!fi.fileName().contains(".")){
			fileName += ".ini";
		}
		ZDLConfigurationManager::setConfigFileName(fileName);
		saveLastDir(zconf,fileName);
		zconf->writeINI(fileName);
		mw->startRead();
	}

}