Example #1
0
bool Document::rename()
{
	// Request new filename
	if (m_filename.isEmpty()) {
		return false;
	}
	QString filename = getSaveFileName(tr("Rename File"));
	if (filename.isEmpty()) {
		return false;
	}

	// Rename file
	if (QFile::exists(filename) && (DocumentWatcher::instance()->isWatching(filename) || !QFile::remove(filename))) {
		QMessageBox::critical(window(), tr("Sorry"), tr("Unable to overwrite '%1'.").arg(QDir::toNativeSeparators(filename)));
		return false;
	}
	DocumentWatcher::instance()->pauseWatch(this);
	if (!QFile::rename(m_filename, filename)) {
		DocumentWatcher::instance()->resumeWatch(this);
		QMessageBox::critical(window(), tr("Sorry"), tr("Unable to rename '%1'.").arg(QDir::toNativeSeparators(m_filename)));
		return false;
	}
	DocumentWatcher::instance()->resumeWatch(this);
	m_filename = filename;
	m_encoding.clear();
	save();
	updateSaveLocation();
	m_text->document()->setModified(false);
	emit changedName();
	return true;
}
Example #2
0
bool AvalancheEngine::saveGame(const int16 slot, const Common::String &desc) {
	Common::String fileName = getSaveFileName(slot);
	Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(fileName);
	if (!f) {
		warning("Can't create file '%s', game not saved.", fileName.c_str());
		return false;
	}

	f->writeUint32LE(MKTAG('A', 'V', 'A', 'L'));

	// Write version. We can't restore from obsolete versions.
	f->writeByte(kSavegameVersion);

	f->writeUint32LE(desc.size());
	f->write(desc.c_str(), desc.size());
	Graphics::saveThumbnail(*f);

	TimeDate t;
	_system->getTimeAndDate(t);
	f->writeSint16LE(t.tm_mday);
	f->writeSint16LE(t.tm_mon);
	f->writeSint16LE(t.tm_year);

	_totalTime += getTimeInSeconds() - _startTime;

	Common::Serializer sz(NULL, f);
	synchronize(sz);
	f->finalize();
	delete f;

	return true;
}
Example #3
0
void Config::saveSettings()
{
    _settings->beginGroup("Base");
    _settings->setValue(KEY_SAVEDIR, getSaveDir());
    _settings->setValue(KEY_SAVENAME, getSaveFileName());
    _settings->setValue(KEY_SAVEFORMAT, getSaveFormat());
    _settings->setValue(KEY_DELAY, getDefDelay());
    _settings->setValue(KEY_FILENAME_TO_CLB, getAutoCopyFilenameOnSaving());
    _settings->setValue(KEY_FILENAMEDATE, getDateTimeInFilename());
    _settings->setValue(KEY_DATETIME_TPL, getDateTimeTpl());
    _settings->setValue(KEY_AUTOSAVE, getAutoSave());
    _settings->setValue(KEY_AUTOSAVE_FIRST, getAutoSaveFirst());
    _settings->setValue(KEY_IMG_QUALITY, getImageQuality());
    _settings->setValue(KEY_NODECOR, getNoDecoration());
    _settings->setValue(KEY_INCLUDE_CURSOR, getIncludeCursor());
    _settings->endGroup();

    _settings->beginGroup("Display");
    _settings->setValue(KEY_TRAYMESSAGES, getTrayMessages());
    _settings->setValue(KEY_TIME_NOTIFY, getTimeTrayMess());
    _settings->setValue(KEY_ZOOMBOX, getZoomAroundMouse());
    _settings->setValue(KEY_SHOW_TRAY, getShowTrayIcon());
    _settings->endGroup();
    saveWndSize();

    _settings->beginGroup("System");
    _settings->setValue(KEY_CLOSE_INTRAY, getCloseInTray());
    _settings->setValue(KEY_ALLOW_COPIES, getAllowMultipleInstance());
    _settings->setValue(KEY_ENABLE_EXT_VIEWER, getEnableExtView());
    _settings->endGroup();

    _shortcuts->saveSettings();

    resetScrNum();
}
Example #4
0
void
MergeWidget::onBrowseOutput() {
  auto filter   = m_config.m_webmMode ? QY("WebM files") + Q(" (*.webm)") : QY("Matroska files") + Q(" (*.mkv *.mka *.mks *.mk3d)");
  auto fileName = getSaveFileName(QY("Select output file name"), filter, ui->output);
  if (!fileName.isEmpty())
    m_config.m_destination = fileName;
}
Example #5
0
bool Document::saveAs()
{
	// Request new filename
	QString filename = getSaveFileName(tr("Save File As"));
	if (filename.isEmpty()) {
		return false;
	}
	if (m_filename == filename) {
		return save();
	}

	// Save file as new name
	if (QFile::exists(filename) && (DocumentWatcher::instance()->isWatching(filename) || !QFile::remove(filename))) {
		QMessageBox::critical(window(), tr("Sorry"), tr("Unable to overwrite '%1'.").arg(QDir::toNativeSeparators(filename)));
		return false;
	}

	QByteArray encoding;
	std::swap(m_filename, filename);
	std::swap(m_encoding, encoding);
	if (!save()) {
		std::swap(m_filename, filename);
		std::swap(m_encoding, encoding);
		return false;
	}

	clearIndex();
	updateSaveLocation();
	m_text->setReadOnly(false);
	m_text->document()->setModified(false);
	emit changedName();
	return true;
}
Example #6
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: attachSexyAPI(); break;
        case 1: { QStringList _r = exec((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; }  break;
        case 2: { QStringList _r = exec((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; }  break;
        case 3: alert((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 4: quit(); break;
        case 5: windowMinimize(); break;
        case 6: windowMaximize(); break;
        case 7: windowResize((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 8: { int _r = windowWidth();
            if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; }  break;
        case 9: { int _r = windowHeight();
            if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; }  break;
        case 10: { QStringList _r = getOpenFileName((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; }  break;
        case 11: { QStringList _r = getOpenFileName((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; }  break;
        case 12: { QStringList _r = getOpenFileName();
            if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; }  break;
        case 13: { QString _r = getSaveFileName((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 14: { QString _r = getSaveFileName((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 15: { QString _r = getSaveFileName();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 16: { QString _r = getDirectory((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 17: { QString _r = getDirectory();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 18: { QStringList _r = getArgs();
            if (_a[0]) *reinterpret_cast< QStringList*>(_a[0]) = _r; }  break;
        default: ;
        }
        _id -= 19;
    }
    return _id;
}
Example #7
0
void EffectRack::savePreset(int idx)/*{{{*/
{
    //QString name = getSaveFileName(QString(""), plug_file_pattern, this,
    QString name = getSaveFileName(QString(""), preset_file_save_pattern, this,
                                   tr("OOStudio: Save Preset"));

    if (name.isEmpty())
        return;

    //FILE* presetFp = fopen(name.ascii(),"w+");
    bool popenFlag;
    FILE* presetFp = fileOpen(this, name, QString(".pre"), "w", popenFlag, false, true);
    if (presetFp == 0)
    {
        //fprintf(stderr, "EffectRack::savePreset() fopen failed: %s\n",
        //   strerror(errno));
        return;
    }
    Xml xml(presetFp);
    Pipeline* pipe = track->efxPipe();
    if (pipe)
    {
        if ((*pipe)[idx] != NULL)
        {
            xml.header();
            xml.tag(0, "oom version=\"2.0\"");
            (*pipe)[idx]->writeConfiguration(1, xml);
            xml.tag(0, "/oom");
        }
        else
        {
            printf("no plugin!\n");
            //fclose(presetFp);
            if (popenFlag)
                pclose(presetFp);
            else
                fclose(presetFp);
            return;
        }
    }
    else
    {
        printf("no pipe!\n");
        //fclose(presetFp);
        if (popenFlag)
            pclose(presetFp);
        else
            fclose(presetFp);
        return;
    }
    //fclose(presetFp);
    if (popenFlag)
        pclose(presetFp);
    else
        fclose(presetFp);
}/*}}}*/
Example #8
0
void D3Cam::on_btnSaveImg_clicked()
{
	if (NULL != captureThread){
		captureThread->prepareImg4Save();
		QString fileName = getSaveFileName();
		if (fileName.isEmpty()){
			return;
		}
		captureThread->saveImg(fileName);
	}
}
Example #9
0
bool Sword2Engine::saveExists(uint16 slotNo) {
	char *saveFileName = getSaveFileName(slotNo);
	Common::InSaveFile *in;

	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
		return false;
	}

	delete in;
	return true;
}
Example #10
0
bool JsExtFile::saveFileAs(const QString &content,
                           const QString &title,
                           const QString &dir,
                           const QString &filter)
{
    QString fileName = getSaveFileName(title, dir, filter);

    if (!fileName.isEmpty()) {
        return saveFile(fileName, content);
    }
    return false;
}
Example #11
0
void InvoiceWizard::createInvoices() {
	PPSPerson pers;
	Invoice invoice;
	XmlPdf *pdf;
	QString fileName;
	bool reminder = (_invoiceState == INVOICE_STATE_TYPE_OUTSTANDING) || (_invoiceState == INVOICE_STATE_TYPE_REMINDER);

	int num = _previewModel.rowCount();
	int cnt = 0;
	QProgressDialog bar(this);
	bar.setRange(0, num);
	bar.setCancelButtonText(tr("&Cancel"));
	bar.setWindowTitle(tr("Create Invoices"));
	bar.setWindowModality(Qt::WindowModal);
	bar.show();

	for (qint32 i = 0; i < num; i++) {
		if (bar.wasCanceled()) {
			break;
		}
		bar.setValue(cnt++);

		qint32 uid = _previewModel.index(i, 0).data(Qt::DisplayRole).toInt();
		if (pers.load(uid)) {
			if (bar.wasCanceled()) break;
			bar.setLabelText(tr("Create Invoice for %1 %2 (%3 of %4)").arg(pers.familyName()).arg(pers.givenName()).arg(cnt).arg(num) );
			if (reminder) {
				invoice.loadLast(uid);
				invoice.setReminded(invoice.reminded() + 1);
				invoice.setLastReminded(QDate::currentDate());
				invoice.save();
			} else {
				invoice.create(&pers);
			}

			// Send invoice by SnailMail and not EMail if "print" is checked, the user likes to become SnailsMails or he has no EMailaddress
			// The "invoice" template is the one without an invoiceSlip, the "reminder" has attached one normally
			if (checkPrint->isChecked() || invoice.addressEmail().isEmpty() || (!noSnailMail->isChecked() && pers.isLoaded() && (pers.notify() == PPSPerson::SnailMail))) {
				if (fileName.isEmpty()) {
					fileName = getSaveFileName();
				}
				pdf = invoice.createPdf("reminder");
				pdf->print( fileName.arg(invoice.memberUid()) );
			} else {
				pdf = invoice.createPdf("invoice");
				pdf->send(invoice.addressEmail());
			}
		}
	}
	bar.setValue(num);
	updatePreviewTable();
}
Example #12
0
uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
	char *saveFileName = getSaveFileName(slotNo);

	Common::InSaveFile *in;

	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
		return SR_ERR_FILEOPEN;
	}

	in->readUint32LE();
	in->read(description, SAVE_DESCRIPTION_LEN);

	delete in;
	return SR_OK;
}
Example #13
0
const QString ViewFile::FilePathGet(const FileAction action, const QString &file_path,
                                    const QString &caption, const QString &filter)
{
    switch (action) {
        case FILE_READ:
            return getOpenFileName(NULL, caption, QDir(file_path).path(), filter);
            break;
        case FILE_WRITE:
            return getSaveFileName(NULL, caption, QDir(file_path).path(), filter);
            break;
        default:
            D_ASSERT(action != FILE_UNDEF);
            break;
    }
    return QString();
}
void TransFuncEditorIntensityPet::saveTransferFunction() {
    QStringList filter;
    for (size_t i = 0; i < transferFuncIntensity_->getSaveFileFormats().size(); ++i) {
        std::string temp = "transfer function (*." + transferFuncIntensity_->getSaveFileFormats()[i] + ")";
        filter << temp.c_str();
    }

    QString fileName = getSaveFileName(filter);
    if (!fileName.isEmpty()) {
        // save transfer function to disk
        if (!transferFuncIntensity_->save(fileName.toStdString())) {
            QMessageBox::critical(this, tr("Error"),
                                  tr("The transfer function could not be saved."));
            LERROR("The transfer function could not be saved. Maybe the disk is full?");
        }
    }
}
Example #15
0
void FileTransferManager::acceptFileTransfer(FileTransfer transfer, QString localFileName)
{
	if (!m_fileTransferHandlerManager->ensureHandler(transfer))
		return;

	auto chat = ChatTypeContact::findChat(m_chatManager, m_chatStorage, transfer.peer(), ActionReturnNull);
	QWidget *parent = m_chatWidgetRepository->widgetForChat(chat);
	if (parent == nullptr)
		parent = m_kaduWindowService->kaduWindow();

	auto remoteFileName = transfer.remoteFileName();
	auto saveFileName = localFileName;

	while (true)
	{
		saveFileName = getSaveFileName(saveFileName, remoteFileName, parent);
		if (saveFileName.isEmpty())
			break;

		auto file = new QFile{saveFileName};
		if (!file->open(QFile::WriteOnly | QIODevice::Truncate))
		{
			MessageDialog::show(m_iconsManager->iconByPath(KaduIcon(QStringLiteral("dialog-warning"))), tr("Kadu"), tr("Could not open file. Select another one."));
			saveFileName.clear();
			file->deleteLater();
			continue;
		}

		transfer.setLocalFileName(saveFileName);

		auto streamHandler = qobject_cast<StreamIncomingFileTransferHandler *>(transfer.handler());
		if (streamHandler)
			streamHandler->accept(file);

		auto urlHandler = qobject_cast<UrlIncomingFileTransferHandler *>(transfer.handler());
		if (urlHandler)
			urlHandler->save(file);

		transfer.setTransferStatus(FileTransferStatus::Transfer);
		showFileTransferWindow();
		break;
	}
}
Example #16
0
uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
	char *saveFileName = getSaveFileName(slotNo);

	Common::OutSaveFile *out;

	if (!(out = _saveFileMan->openForSaving(saveFileName))) {
		return SR_ERR_FILEOPEN;
	}

	out->write(buffer, bufferSize);
	out->finalize();

	if (!out->err()) {
		delete out;
		return SR_OK;
	}

	delete out;
	return SR_ERR_WRITEFAIL;
}
void SaveDocumentController::sl_fileDialogButtonClicked() {
    QString defaultFilter = prepareDefaultFileFilter();
    const QString filter = prepareFileFilter();

    QString defaultUrl = getSaveFileName();
    LastUsedDirHelper lod(conf.defaultDomain, defaultUrl);
    if (defaultUrl.isEmpty()) {
        defaultUrl = lod;
    }

    cutGzExtension(defaultUrl);

    lod.url = U2FileDialog::getSaveFileName(conf.parentWidget, conf.saveTitle, defaultUrl, filter, &defaultFilter);
    if (lod.url.isEmpty()) {
        return;
    }

    addFormatExtension(lod.url);
    addGzExtension(lod.url);
    overwritingConfirmed = true;
    setPath(lod.url);
}
Example #18
0
void InvoiceWizard::invoiceMembers() {
	PPSPerson pers;
	Invoice invoice;
	XmlPdf *pdf;
	QString fileName;

	QProgressDialog bar(this);
	int max = memberUidList->count();
	bar.setRange(0, max);
	bar.setCancelButtonText(tr("&Cancel"));
	bar.setWindowTitle(tr("Create Invoices"));
	bar.setWindowModality(Qt::WindowModal);
	bar.show();

	for (int i = 0; i < max; i++) {
		QListWidgetItem *item = memberUidList->item(i);
		bar.setValue(i);
		if (pers.load(item->text().toInt())) {
			if (bar.wasCanceled()) break;
			bar.setLabelText(tr("Create Invoice for %1 %2 (%3 of %4)").arg(pers.familyName()).arg(pers.givenName()).arg(i).arg(max) );
			invoice.create(&pers);

			// Send invoice by SnailMail and not EMail if "print" is checked, the user likes to become SnailsMails or he has no EMailaddress
			// The "invoice" template is the one without an invoiceSlip, the "reminder" has attached one normally
			if (checkPrint->isChecked() || invoice.addressEmail().isEmpty() || (pers.isLoaded() && (pers.notify() == PPSPerson::SnailMail))) {
				if (fileName.isEmpty()) {
					fileName = getSaveFileName();
				}
				pdf = invoice.createPdf("reminder");
				pdf->print( fileName.arg(invoice.memberUid()) );
			} else {
				pdf = invoice.createPdf("invoice");
				pdf->send(invoice.addressEmail());
			}
		}
	}
	bar.setValue(max);
}
Example #19
0
void PythonEditor::saveScriptAs() {

    if (!PythonModule::getInstance()) {
        LERROR("PythonModule not instantiated");
        return;
    }

    if (!script_) {
        LERROR("No script");
        return;
    }

    //create filter with supported file formats
    QStringList filter;
    filter << "Python Script (*.py)";

    QString fileName = getSaveFileName(filter);
    if (!fileName.isEmpty()) {
        if (saveScriptInternal(fileName, codeEdit_->toPlainText())) {
            clearScript();
            script_ = PythonModule::getInstance()->loadScript(fileName.toStdString(), false);
            scriptOwner_ = false;
            if (script_) {
                codeEdit_->setPlainText(QString::fromStdString(script_->getSource()));
            }
            else {
                QMessageBox::critical(this, tr("Python Error"), tr("Saved script '%1' could not be loaded.").arg(fileName));
            }
        }
        else {
            QString message = tr("Failed to save script to file '%1'").arg(fileName);
            QMessageBox::critical(this, tr("Python Error"), message);
        }
    }

    updateGuiState();
}
Example #20
0
uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
	char *saveFileName = getSaveFileName(slotNo);

	Common::InSaveFile *in;

	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
		// error: couldn't open file
		return SR_ERR_FILEOPEN;
	}

	// Read savegame into the buffer
	uint32 itemsRead = in->read(buffer, bufferSize);

	delete in;

	if (itemsRead != bufferSize) {
		// We didn't get all of it. At the moment we have no way of
		// knowing why, so assume that it's an incompatible savegame.

		return SR_ERR_INCOMPATIBLE;
	}

	return SR_OK;
}
void TestMainWindow::activatedListItem(HbListWidgetItem *item)
{
    if( item->text().compare( getDir ) == 0 ) {
        getExistingDirectory();
    } else if( item->text().compare( getFile ) == 0 ) {
        getOpenFileName();
    } else if( item->text().compare( saveFile ) == 0 ) {
       getSaveFileName();
    } else if( item->text().compare( getDir_SetDir ) == 0 ) {
        getExistingDirectory_SetDir();
    } else if( item->text().compare( getFile_SetDir ) == 0 ) {
       getOpenFileName_SetDir();
    } else if( item->text().compare( saveFile_SetDir ) == 0 ) {
        getSaveFileName_SetDir();
    } else if( item->text().compare( getDir_SetFilter ) == 0 ) {
        getExistingDirectory_SetFilter();
    } else if( item->text().compare( getDir_SetFilter_AllDirs ) == 0 ) {
        getExistingDirectory_SetFilter_AllDirs();
    } else if( item->text().compare( getFile_SetFilter ) == 0 ) {
        getOpenFileName_SetFilter();
    } else if( item->text().compare( saveFile_SetFilter ) == 0 ) {
       getSaveFileName_SetFilter();
    }
}
bool CProjectSettings::CloseProjectSettings()
{
	// check bool if settings have changed
	if ( IsChangedSinceLastSave ) 
	{
		// popup to ask if save - yes/no/(cancel)
		int answer = AfxMessageBox( "Do you want to save the changes in the project?", MB_YESNOCANCEL );

		// do what the user clicked
		if (answer == IDCANCEL)
		{
			// Cancel: we dont want to do anything...
			return FALSE;
		}
		else if ( answer == IDYES )
		{
			// get the filename
			StdString fileName = getSaveFileName();

			// check if it is a valid path
			if ( fileName.length() == 0 )
			{
				// Selecting a file
				StdString typeExtension( _T("gdsprj") );
				StdString filterStr = "GDS project files (*." + typeExtension + ")|*." + typeExtension + "||"; 
				CFileDialog myFileDialog(FALSE, typeExtension, NULL, OFN_ENABLESIZING|OFN_EXPLORER|OFN_OVERWRITEPROMPT, filterStr);

				// set the file selector default dir to project dir
				myFileDialog.m_ofn.lpstrInitialDir = GetDirectory();

				// Adding it to the listBox
				if ( myFileDialog.DoModal() == IDOK ) 
				{
					// get the selected file with path
					fileName = myFileDialog.GetPathName();
					
					// saving the filename in the object as well
					setSaveFileName( fileName );
				}
				else
				{
					// the user clicked cancel: exiting save dialog
					return FALSE;
				}
			}

			// send message to make projectloader serialize us.
			CHashString hszProjectLoader(_T("CProjectLoadSave"));
			CHashString hszNewParticleSaveFilepath( fileName );
			static DWORD msgHash_SaveFile = CHashString(_T("SaveFile")).GetUniqueID();
			DWORD result = EngineGetToolBox()->SendMessage(msgHash_SaveFile, sizeof(TCHAR *), (void *)hszNewParticleSaveFilepath.GetString(), 0, &hszProjectLoader);

			// mark settings as saved
			IsChangedSinceLastSave = FALSE;
		}
		else
		{
			// we are here, if the user clicked NO SAVE
			// then we don't save anything, but return TRUE
			// that will lead to close GDS
			return TRUE;
		}
	}
	// Closing project destroys consistency	
	SetSettingsStateConsistency( FALSE );
	
	return TRUE;
}
Example #23
0
//--------------------------------------------------------------
void testApp::buttonAction(int i)
{
    int butt = i;
    
    switch(butt)
    {
        case 0:
            d->set(770,242);
            if(ib->mode == 0 && ib->active)
                d->mode = ib->type; //rabbitfunction is populated based on ib->type
            else if(ib-> mode == 1)
                d->mode = 11; //display emulator 1
            else
                break;
            d->populateList();
            d->active=true;  
            break;
            
        case 1: 
            d->set(770,178);
            if(ib->mode == 0 || ib -> mode == 3)
                d->mode = 9; //change active element
            else
                d->mode = 10; //output resolution list

            d->populateList();
            d->active=true; 
            break;
        
        case 2:   
            d->set(770,440);
            if(ib->type==0 && ib->mode == 0 && ib->active)
            {
                d->mode = 4; //toggle
            } else if(ib->mode == 1)
            {
                d->mode = 13; //on source loss
            } else
                break;
            d->populateList();
            d->active=true;
            break;
            
        case 3:
        case 4:
        case 5:
        case 6:
            curSkin = butt-3;
            ib->mode=0;
            copyElementDataToInterface();
            break;
        
        case 7:
            ib->reset();
            ib->mode=1;
            
            for(int i = 0; i < numberOfElements; i++)
            {
                e[i]->selected = false;
            }
            break;
            
        case 8:
            saveToDisk(getSaveFileName());
            break;
            
        case 9:
            loadFromFile();
            break;
            
        case 10:
            saveToDevice(); //nooooooo!
            break;
            
        case 11:
            loadFromDevice();
            break;
            
        case 12:
            resetToDefault();
            break;
            
        //IP                   
        case 13: 
            ib->enterIPAddress();
            break;
        
        //enter OSC bar    
        case 14:
            if(ib->mode == 0 && ib->active)
            {
                ib->enterOscAddress();
                if(ib->oscAddress!="")
                {
                    ib->toggleOSC = true;
                    ib->stoggleOSC = d->onOffList[ib->toggleOSC];
                }
                else
                {
                    ib->toggleOSC = false;
                    ib->stoggleOSC = d->onOffList[ib->toggleOSC];
                }
                    
            
                
            }
            break;
        
        //display emulator two   
        case 15:
            
            if(ib->mode == 1)  
            {
                d->set(770,264);
                d->mode = 12; //display emulator 2
                d->populateList();
                d->active=true; 
            }
            break;
            
        case 16:
            d->set(770,330);
            if(ib->mode == 0 && ib->active)
                d->mode = 5; //toggle osc
            else if(ib->mode == 1)
                d->mode = 6; //output hdcp
            else
                break;
            d->populateList();
            d->active=true;  
            break; 
        case 17:
            if(ib->mode == 1)
            {
                d->set(770,350);
                d->mode = 7; //input 01 hdcp
                d->populateList();
                d->active=true;  
            }
            break; 
        case 18:
            if(ib->mode == 1)
            {
                d->set(770,370);
                d->mode = 8; //input 02 hdcp
                d->populateList();
                d->active=true;  
            }
            break;                
            
        default:
            break;
            
    }

}
Example #24
0
void CQueryTable::save()
{
  if (isBlocked())
    return;  
  tmpFileName = getSaveFileName(tmpFileName, "txt", tr("Text Files (*.txt);;All Files(*.*)"));  

  if (tmpFileName.isEmpty())
    return;
  
  QFile file( tmpFileName );    
  if (file.exists() && myApp()->confirmCritical())
    if ((QMessageBox::warning(0, tr("Replace File"), tr("The specified file name already exists.\nDo you want to replace it ?"),
      QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes))
      return;

  if ( !file.open( IO_WriteOnly ) )
  {
    if (mysql()->messagePanel())
      mysql()->messagePanel()->critical(tr("An error occurred while saving the file"));
    return;
  }

  setBlocked(true);

  QString line_terminator = mysql()->lineTerminator(true);

  QString title = caption() + line_terminator;
  title += tr("Connection") + ": " + mysql()->connectionName() + line_terminator;
  title += tr("Host") + ": " + mysql()->hostName() + line_terminator;  
  title += tr("Saved") + ": " + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") + line_terminator;  
  title = CApplication::commentText(title, line_terminator) + line_terminator;

  QTextStream ts( &file );
  ts << title;
  
  QString tmp = tr("Query") + ":" + line_terminator;
  tmp += query()->lastQuery().replace(QRegExp("\n"), line_terminator) + line_terminator;
  ts << CApplication::commentText(tmp, line_terminator) << line_terminator;
 
  query()->dataSeek(0);
  
  uint num_fields = query()->numFields();
  QString encl = mysql()->fieldEncloser(true);
  QString sep = mysql()->fieldSeparator(true);
  uint j;
  bool add_sep = false;
  for (j = 0; j < num_fields; j++)
  {
    if (horizontalHeader()->sectionSize(j) != 0)
    {
      if (add_sep)
        ts << sep;
      ts << encl << query()->fields(j).name << encl;
      if (!add_sep)
        add_sep = true;
    }
  }
  ts << line_terminator;


  if (numRows() <= 0 || numCols() <= 0)
    return;

  QString repl_empty = mysql()->replaceEmpty(true);
  
  while (query()->next(!hasProcessEvents()))
  {
    add_sep = false;
    for (j = 0; j < num_fields; j++)
      if (horizontalHeader()->sectionSize(j) != 0)
      {
        const char* r = query()->row(j);
        if (!r)
          r = "[NULL]";
        if (!*r)
          r = (const char*)repl_empty;
        if (add_sep)
          ts << sep;

        ts << encl << r << encl;
        if (!add_sep)
          add_sep = true;
      }
    ts << line_terminator;
  }

  file.close();
  if (mysql()->messagePanel()) 
    mysql()->messagePanel()->information(tr("Successfully saved") + ": " + tmpFileName);

  setBlocked(false);
}
Example #25
0
inline string Dataset::getSavePath(const string &dirPrefix, time_t slot, long framecnt)
{
	std::stringstream ss;
	ss << dirPrefix << "\\" << getSaveDirName(slot) << getSaveFileName(slot, framecnt);
	return ss.str();
}
Example #26
0
bool AvalancheEngine::loadGame(const int16 slot) {
	Common::String fileName = getSaveFileName(slot);
	Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName);
	if (!f)
		return false;

	uint32 signature = f->readUint32LE();
	if (signature != MKTAG('A', 'V', 'A', 'L'))
		return false;

	// Check version. We can't restore from obsolete versions.
	byte saveVersion = f->readByte();
	if (saveVersion > kSavegameVersion) {
		warning("Savegame of incompatible version!");
		delete f;
		return false;
	}

	// Read the description.
	uint32 descSize = f->readUint32LE();
	Common::String description;
	for (uint32 i = 0; i < descSize; i++) {
		char actChar = f->readByte();
		description += actChar;
	}

	description.toUppercase();
	Graphics::skipThumbnail(*f);

	// Read the time the game was saved.
	TimeDate t;
	t.tm_mday = f->readSint16LE();
	t.tm_mon = f->readSint16LE();
	t.tm_year = f->readSint16LE();

	resetAllVariables();

	Common::Serializer sz(f, NULL);
	synchronize(sz);
	delete f;

	_isLoaded = true;

	_animationsEnabled = false;

	if (_holdTheDawn) {
		_holdTheDawn = false;
		fadeIn();
	}

	_background->release();
	minorRedraw();
	_dropdown->setup();
	setRoom(kPeopleAvalot, _room);
	_alive = true;
	refreshObjectList();
	_animation->updateSpeed();
	drawDirection();
	_animation->animLink();
	_background->update();

	Common::String tmpStr = Common::String::format("%cLoaded: %c%s.ASG%c%c%c%s%c%csaved on %s.",
		kControlItalic, kControlRoman, description.c_str(), kControlCenter, kControlNewLine,
		kControlNewLine, _roomnName.c_str(), kControlNewLine, kControlNewLine,
		expandDate(t.tm_mday, t.tm_mon, t.tm_year).c_str());
	_dialogs->displayText(tmpStr);

	AnimationType *avvy = _animation->_sprites[0];
	if (avvy->_quick && avvy->_visible)
		_animation->setMoveSpeed(0, _animation->getDirection()); // We push Avvy in the right direction is he was moving.

	return true;
}