Example #1
0
bool Advanced_Settings_Window::Save_Emulators_Info()
{
	// FIXME save only if emulators changed
	
	// Check defaults emulators
	bool installed_kvm, installed_qemu, default_kvm, default_qemu;
	installed_kvm = installed_qemu = default_kvm = default_qemu = false;
	
	for( int ix = 0; ix < Emulators.count(); ++ix )
	{
		if( Emulators[ix].Get_Type() == VM::QEMU )
		{
			installed_qemu = true;

			if( Emulators[ix].Get_Default() ) default_qemu = true;
		}
		else if( Emulators[ix].Get_Type() == VM::KVM )
		{
			installed_kvm = true;
			
			if( Emulators[ix].Get_Default() ) default_kvm = true;
		}
	}
	
	if( installed_qemu && default_qemu == false )
	{
		AQGraphic_Warning( tr("Error!"), tr("Default QEMU Emulator isn't selected!") );
		return false;
	}
	
	if( installed_kvm && default_kvm == false )
	{
		AQGraphic_Warning( tr("Error!"), tr("Default KVM Emulator isn't selected!") );
		return false;
	}
	
	// Remove old emulators files
	if( ! Remove_All_Emulators_Files() )
	{
		AQWarning( "bool Advanced_Settings_Window::Save_Emulators_Info()",
				   "Not all old emulators files removed!" );
	}
	
	// Save new files
	for( int ix = 0; ix < Emulators.count(); ++ix )
	{
		if( ! Emulators[ ix ].Save() )
		{
			AQGraphic_Warning( tr("Error!"),
							   tr("Cannot save emulator \"%1\"!").arg(Emulators[ix].Get_Name()) );
		}
	}
	
	return true;
}
void Edit_Emulator_Version_Window::done(int r)
{
    if ( QDialog::Accepted == r )
    {
	    // FIXME Optimize: save only changes
	
	    // Delete old emulators
	    Remove_All_Emulators_Files();
	
	    // Save New Emulators
	    for( int ix = 0; ix < Emulators.count(); ++ix )
		    Emulators[ ix ].Save();
    }
    QDialog::done(r);
}